From f92b5abd556b5e364e62b75452b0608b94a8c963 Mon Sep 17 00:00:00 2001 From: waynesbrain <175370544+waynesbrain@users.noreply.github.com> Date: Fri, 4 Oct 2024 17:10:35 -0400 Subject: [PATCH 01/11] Notes --- packages/node/src/FsDriver.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/node/src/FsDriver.ts b/packages/node/src/FsDriver.ts index e5a96db..2484095 100644 --- a/packages/node/src/FsDriver.ts +++ b/packages/node/src/FsDriver.ts @@ -269,7 +269,7 @@ export class FsDriver> extends Driver { ): Promise { return this.#transaction(async () => { const { to, data } = params; - // TODO: Better isDir/isFile detection! + // CONSIDER: Do we need isDir/isFile signaling for the caller here? const isDir = !("data" in params); const toPath = this.#fullPath(to); console.log("[FS] add", to); From b8adb7c425f42be4b05a0cb07e8b36759f720388 Mon Sep 17 00:00:00 2001 From: waynesbrain <175370544+waynesbrain@users.noreply.github.com> Date: Fri, 4 Oct 2024 17:16:49 -0400 Subject: [PATCH 02/11] Bump version for breaking changes in v0.2.0. --- package-lock.json | 77 +++++++++++++++++++++-------------- packages/core/package.json | 2 +- packages/idb/package.json | 4 +- packages/node/package.json | 4 +- packages/typebox/package.json | 4 +- packages/web/package.json | 4 +- packages/ws/package.json | 4 +- 7 files changed, 58 insertions(+), 41 deletions(-) diff --git a/package-lock.json b/package-lock.json index ba6d3cc..abd6a30 100644 --- a/package-lock.json +++ b/package-lock.json @@ -16,6 +16,7 @@ "@types/node": "^20.14.8", "@typescript-eslint/eslint-plugin": "^7.11.0", "@typescript-eslint/parser": "^7.11.0", + "chalk": "^5.3.0", "datauri-cli": "^4.1.0", "delay-cli": "^2.0.0", "esbuild": "^0.21.3", @@ -125,17 +126,6 @@ "node": ">=18.0.0" } }, - "labs/demo-server/node_modules/chalk": { - "version": "5.3.0", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-5.3.0.tgz", - "integrity": "sha512-dLitG79d+GV1Nb/VYcCDFivJeK1hiukt9QjRNVOsUtTy1rR1YJsmpGGTZ3qJos+uw7WmWF4wUwBd9jxjocFC2w==", - "engines": { - "node": "^12.17.0 || ^14.13 || >=16.0.0" - }, - "funding": { - "url": "https://github.com/chalk/chalk?sponsor=1" - } - }, "labs/demo-shared": { "version": "1.0.0", "license": "MIT", @@ -3520,15 +3510,11 @@ } }, "node_modules/chalk": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", - "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", - "dependencies": { - "ansi-styles": "^4.1.0", - "supports-color": "^7.1.0" - }, + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-5.3.0.tgz", + "integrity": "sha512-dLitG79d+GV1Nb/VYcCDFivJeK1hiukt9QjRNVOsUtTy1rR1YJsmpGGTZ3qJos+uw7WmWF4wUwBd9jxjocFC2w==", "engines": { - "node": ">=10" + "node": "^12.17.0 || ^14.13 || >=16.0.0" }, "funding": { "url": "https://github.com/chalk/chalk?sponsor=1" @@ -4798,6 +4784,22 @@ "concat-map": "0.0.1" } }, + "node_modules/eslint/node_modules/chalk": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", + "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", + "dev": true, + "dependencies": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/chalk?sponsor=1" + } + }, "node_modules/eslint/node_modules/minimatch": { "version": "3.1.2", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", @@ -6410,6 +6412,21 @@ "concat-map": "0.0.1" } }, + "node_modules/jake/node_modules/chalk": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", + "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", + "dependencies": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/chalk?sponsor=1" + } + }, "node_modules/jake/node_modules/minimatch": { "version": "3.1.2", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", @@ -12357,7 +12374,7 @@ }, "packages/core": { "name": "@jrfs/core", - "version": "0.0.4", + "version": "0.2.0", "license": "MIT", "dependencies": { "mutative": "1.0.11" @@ -12371,19 +12388,19 @@ }, "packages/idb": { "name": "@jrfs/idb", - "version": "0.0.4", + "version": "0.2.0", "license": "MIT", "dependencies": { - "@jrfs/core": "^0.0.4", + "@jrfs/core": "^0.2.0", "idb": "^8.0.0" } }, "packages/node": { "name": "@jrfs/node", - "version": "0.0.4", + "version": "0.2.0", "license": "MIT", "dependencies": { - "@jrfs/core": "^0.0.4" + "@jrfs/core": "^0.2.0" }, "engines": { "node": "^18.18.0 || >=20.0.0" @@ -12391,10 +12408,10 @@ }, "packages/typebox": { "name": "@jrfs/typebox", - "version": "0.0.4", + "version": "0.2.0", "license": "MIT", "dependencies": { - "@jrfs/core": "^0.0.4" + "@jrfs/core": "^0.2.0" }, "devDependencies": { "@sinclair/typebox": "^0.33.7" @@ -12405,18 +12422,18 @@ }, "packages/web": { "name": "@jrfs/web", - "version": "0.0.4", + "version": "0.2.0", "license": "MIT", "dependencies": { - "@jrfs/core": "^0.0.4" + "@jrfs/core": "^0.2.0" } }, "packages/ws": { "name": "@jrfs/ws", - "version": "0.0.4", + "version": "0.2.0", "license": "MIT", "dependencies": { - "@jrfs/core": "^0.0.4" + "@jrfs/core": "^0.2.0" }, "devDependencies": { "ws": "^8.18.0" diff --git a/packages/core/package.json b/packages/core/package.json index 423558c..5957c82 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -1,6 +1,6 @@ { "name": "@jrfs/core", - "version": "0.1.0", + "version": "0.2.0", "description": "JRFS core library.", "repository": "github:jrfso/jrfs", "homepage": "https://github.com/jrfso/jrfs/tree/master/packages/core", diff --git a/packages/idb/package.json b/packages/idb/package.json index 8703487..bd2480f 100644 --- a/packages/idb/package.json +++ b/packages/idb/package.json @@ -1,6 +1,6 @@ { "name": "@jrfs/idb", - "version": "0.1.0", + "version": "0.2.0", "description": "JRFS idb file cache.", "repository": "github:jrfso/jrfs", "homepage": "https://github.com/jrfso/jrfs/tree/master/packages/idb", @@ -36,7 +36,7 @@ "watch-build": "node --watch-path=./src --watch-path=../../node_modules/@jrfs/core/lib ../../scripts/build-esm.mjs lib --tsconfig tsconfig.prod.json" }, "dependencies": { - "@jrfs/core": "^0.1.0", + "@jrfs/core": "^0.2.0", "idb": "^8.0.0" } } \ No newline at end of file diff --git a/packages/node/package.json b/packages/node/package.json index 5d04cb1..ca08dfa 100644 --- a/packages/node/package.json +++ b/packages/node/package.json @@ -1,6 +1,6 @@ { "name": "@jrfs/node", - "version": "0.1.0", + "version": "0.2.0", "description": "JRFS Node drivers.", "repository": "github:jrfso/jrfs", "homepage": "https://github.com/jrfso/jrfs/tree/master/packages/node", @@ -38,6 +38,6 @@ "watch-build": "node --watch-path=./src --watch-path=../../node_modules/@jrfs/core/lib ../../scripts/build-esm.mjs lib --tsconfig tsconfig.prod.json" }, "dependencies": { - "@jrfs/core": "^0.1.0" + "@jrfs/core": "^0.2.0" } } \ No newline at end of file diff --git a/packages/typebox/package.json b/packages/typebox/package.json index 092fe80..1fbd3b5 100644 --- a/packages/typebox/package.json +++ b/packages/typebox/package.json @@ -1,6 +1,6 @@ { "name": "@jrfs/typebox", - "version": "0.1.0", + "version": "0.2.0", "description": "JRFS TypeBox integration.", "repository": "github:jrfso/jrfs", "homepage": "https://github.com/jrfso/jrfs/tree/master/packages/typebox", @@ -36,7 +36,7 @@ "watch-build": "node --watch-path=./src --watch-path=../../node_modules/@jrfs/core/lib ../../scripts/build-esm.mjs lib --tsconfig tsconfig.prod.json" }, "dependencies": { - "@jrfs/core": "^0.1.0" + "@jrfs/core": "^0.2.0" }, "devDependencies": { "@sinclair/typebox": "^0.33.7" diff --git a/packages/web/package.json b/packages/web/package.json index 0ac034c..c404aa0 100644 --- a/packages/web/package.json +++ b/packages/web/package.json @@ -1,6 +1,6 @@ { "name": "@jrfs/web", - "version": "0.1.0", + "version": "0.2.0", "description": "JRFS browser drivers.", "repository": "github:jrfso/jrfs", "homepage": "https://github.com/jrfso/jrfs/tree/master/packages/web", @@ -35,6 +35,6 @@ "watch-build": "node --watch-path=./src --watch-path=../../node_modules/@jrfs/core/lib ../../scripts/build-esm.mjs lib --tsconfig tsconfig.prod.json" }, "dependencies": { - "@jrfs/core": "^0.1.0" + "@jrfs/core": "^0.2.0" } } \ No newline at end of file diff --git a/packages/ws/package.json b/packages/ws/package.json index 8194939..dd11531 100644 --- a/packages/ws/package.json +++ b/packages/ws/package.json @@ -1,6 +1,6 @@ { "name": "@jrfs/ws", - "version": "0.1.0", + "version": "0.2.0", "description": "JRFS ws integration.", "repository": "github:jrfso/jrfs", "homepage": "https://github.com/jrfso/jrfs/tree/master/packages/ws", @@ -36,7 +36,7 @@ "watch-build": "node --watch-path=./src --watch-path=../../node_modules/@jrfs/core/lib ../../scripts/build-esm.mjs lib --tsconfig tsconfig.prod.json" }, "dependencies": { - "@jrfs/core": "^0.1.0" + "@jrfs/core": "^0.2.0" }, "devDependencies": { "ws": "^8.18.0" From 4e2ad8aaf4c7474d51dfa9d0464b37768369ffbe Mon Sep 17 00:00:00 2001 From: waynesbrain <175370544+waynesbrain@users.noreply.github.com> Date: Fri, 4 Oct 2024 22:30:51 -0400 Subject: [PATCH 03/11] Simplify FileSystem generic signature and remove unnecessary driver property. --- packages/core/src/FileSystem.ts | 24 ++++++------------------ packages/core/src/Repository.ts | 4 ++-- 2 files changed, 8 insertions(+), 20 deletions(-) diff --git a/packages/core/src/FileSystem.ts b/packages/core/src/FileSystem.ts index 8813c17..6f22b53 100644 --- a/packages/core/src/FileSystem.ts +++ b/packages/core/src/FileSystem.ts @@ -9,7 +9,7 @@ import { type NodeInfo, } from "@/types"; import { INTERNAL, isDirectoryNode } from "@/internal/types"; -import type { Driver, DriverTypes, TransactionOutParams } from "@/Driver"; +import type { Driver, TransactionOutParams } from "@/Driver"; import { FileTree } from "@/FileTree"; import { FileTypeProvider } from "@/FileTypeProvider"; @@ -32,13 +32,7 @@ import { FileTypeProvider } from "@/FileTypeProvider"; * @template DK Driver key used in constructor option. * @template DT Driver type from `DriverTypes[DK]` else `Driver`. */ -export class FileSystem< - FT extends FileTypes, - DK extends keyof DriverTypes & string = keyof DriverTypes, - DT extends Driver = DriverTypes[DK] extends Driver - ? DriverTypes[DK] - : Driver, -> extends FileTree { +export class FileSystem> extends FileTree { #driver = null! as Driver; #fileTypes: FileTypeProvider; @@ -50,21 +44,19 @@ export class FileSystem< // #region -- Internal static #internal = { - create< - FT extends FileTypes, - DK extends keyof DriverTypes & string = keyof DriverTypes, - >(options: { + create>(options: { fileTypes: FileTypeProvider; callbacks: { setDriver: (value: Driver) => void; }; }) { const { fileTypes, callbacks } = options; - const fs = new FileSystem({ + const fs = new FileSystem({ fileTypes, }); callbacks.setDriver = (value: Driver) => { fs.#driver = value; + (fs as any)[Symbol.toStringTag] = `FileSystem(${value})`; }; return fs; }, @@ -74,10 +66,6 @@ export class FileSystem< } // #endregion // #region -- Props - /** The driver interface of the configured implementation. */ - get driver(): DT { - return this.#driver as DT; - } get fileTypes() { return this.#fileTypes; @@ -167,7 +155,7 @@ export class FileSystem< }; } // Get from driver. - const result = await this.driver.get({ from, fromEntry: entry }); + const result = await this.#driver.get({ from, fromEntry: entry }); return result; } diff --git a/packages/core/src/Repository.ts b/packages/core/src/Repository.ts index 95d374c..d44f329 100644 --- a/packages/core/src/Repository.ts +++ b/packages/core/src/Repository.ts @@ -30,7 +30,7 @@ export class Repository< : Driver, > { #driver: Driver; - #fs: FileSystem; + #fs: FileSystem; constructor( options: RepositoryOptions & Partial>, @@ -41,7 +41,7 @@ export class Repository< createShortId = defaultCreateShortId, } = options; const callbacks = {} as { setDriver(value: Driver): void }; - const fs = FileSystem[INTERNAL].create({ + const fs = FileSystem[INTERNAL].create({ fileTypes, callbacks, }); From 2a55a53a50557893754f3c5115a7bfcd7bd5420f Mon Sep 17 00:00:00 2001 From: waynesbrain <175370544+waynesbrain@users.noreply.github.com> Date: Fri, 4 Oct 2024 22:55:53 -0400 Subject: [PATCH 04/11] Simplify Driver types, make them non-generic. Drivers that need typed fileTypes can cast to that type. --- packages/core/src/Driver.ts | 21 +++++++-------------- packages/core/src/FileSystem.ts | 10 +++------- packages/core/src/Repository.ts | 20 +++++++++----------- packages/node/src/FsDriver.ts | 14 +++++++------- packages/web/src/WebDriver.ts | 16 ++++++++-------- 5 files changed, 34 insertions(+), 47 deletions(-) diff --git a/packages/core/src/Driver.ts b/packages/core/src/Driver.ts index 76dc42e..c70e1fb 100644 --- a/packages/core/src/Driver.ts +++ b/packages/core/src/Driver.ts @@ -3,7 +3,6 @@ import type { Entry, FileTree, FileTypeProvider, - FileTypes, MutativePatches, } from "@/index"; import { type CreateShortIdFunction } from "@/helpers"; @@ -11,13 +10,13 @@ import { INTERNAL } from "@/internal/types"; import { WritableFileTree } from "@/WritableFileTree"; /** Base JRFS driver class. */ -export abstract class Driver> { +export abstract class Driver { #fileTree: WritableFileTree; - #fileTypes: FileTypeProvider; + #fileTypes: FileTypeProvider; /** `true` if {@link open}, `false` if {@link close}d */ #opened = false; - constructor(props: DriverProps) { + constructor(props: DriverProps) { this.#fileTree = WritableFileTree[INTERNAL].create( props.fileTree, props.createShortId, @@ -164,14 +163,11 @@ export interface TransactionParams { } /** Callback to create a driver. */ -export type DriverFactory = >( - props: DriverProps, - options: any, -) => Driver; +export type DriverFactory = (props: DriverProps, options: any) => Driver; -export interface DriverProps> { +export interface DriverProps { createShortId: CreateShortIdFunction; - fileTypes: FileTypeProvider; + fileTypes: FileTypeProvider; fileTree: FileTree; } /** @@ -187,9 +183,6 @@ export interface DriverTypeOptions { // e.g. ["fs"]: FsDriverOptions; } /** Interface to declare driver types onto. */ -export interface DriverTypes< - // eslint-disable-next-line @typescript-eslint/no-unused-vars - FT extends FileTypes, -> { +export interface DriverTypes { // e.g. ["fs"]: FsDriver; } diff --git a/packages/core/src/FileSystem.ts b/packages/core/src/FileSystem.ts index 6f22b53..4641557 100644 --- a/packages/core/src/FileSystem.ts +++ b/packages/core/src/FileSystem.ts @@ -27,13 +27,9 @@ import { FileTypeProvider } from "@/FileTypeProvider"; /** * The top level file tree interface provided by a Repository. * @template FT File Types interface, to map file type names to TS types. - * Each key should be registered via {@link fileTypes} later. - * Each value must be in the shape of a `FileOf` type. - * @template DK Driver key used in constructor option. - * @template DT Driver type from `DriverTypes[DK]` else `Driver`. */ export class FileSystem> extends FileTree { - #driver = null! as Driver; + #driver = null! as Driver; #fileTypes: FileTypeProvider; private constructor(options: { fileTypes: FileTypeProvider }) { @@ -47,14 +43,14 @@ export class FileSystem> extends FileTree { create>(options: { fileTypes: FileTypeProvider; callbacks: { - setDriver: (value: Driver) => void; + setDriver: (value: Driver) => void; }; }) { const { fileTypes, callbacks } = options; const fs = new FileSystem({ fileTypes, }); - callbacks.setDriver = (value: Driver) => { + callbacks.setDriver = (value: Driver) => { fs.#driver = value; (fs as any)[Symbol.toStringTag] = `FileSystem(${value})`; }; diff --git a/packages/core/src/Repository.ts b/packages/core/src/Repository.ts index d44f329..814b0c1 100644 --- a/packages/core/src/Repository.ts +++ b/packages/core/src/Repository.ts @@ -20,16 +20,14 @@ import { * Each key should be registered via {@link FileTypeProvider} later. * Each value must be in the shape of a `FileOf` type. * @template DK Driver key used in constructor option. - * @template DT Driver type from `DriverTypes[DK]` else `Driver`. + * @template DT Driver type from `DriverTypes[DK]` else `Driver`. */ export class Repository< FT extends FileTypes, - DK extends keyof DriverTypes & string = keyof DriverTypes, - DT extends Driver = DriverTypes[DK] extends Driver - ? DriverTypes[DK] - : Driver, + DK extends keyof DriverTypes & string = keyof DriverTypes, + DT extends Driver = DriverTypes[DK] extends Driver ? DriverTypes[DK] : Driver, > { - #driver: Driver; + #driver: Driver; #fs: FileSystem; constructor( @@ -40,14 +38,14 @@ export class Repository< fileTypes, createShortId = defaultCreateShortId, } = options; - const callbacks = {} as { setDriver(value: Driver): void }; + const callbacks = {} as { setDriver(value: Driver): void }; const fs = FileSystem[INTERNAL].create({ fileTypes, callbacks, }); const driverFactory = getDriverFactory(driverType); const driverOptions = options[driverType]; - const driver = driverFactory( + const driver = driverFactory( { createShortId, fileTree: fs, @@ -97,7 +95,7 @@ export class Repository< /** Options to create a {@link Repository}. */ export interface RepositoryOptions< FT extends FileTypes, - DK extends keyof DriverTypes & string = keyof DriverTypes, + DK extends keyof DriverTypes & string = keyof DriverTypes, > { /** Name of the driver type to use. */ driver: DK; @@ -110,7 +108,7 @@ export interface RepositoryOptions< const driverFactories: Record = {}; export function getDriverFactory>( - driverType: keyof DriverTypes & string, + driverType: keyof DriverTypes & string, ) { const driverFactory = driverFactories[driverType]; if (!driverFactory) { @@ -124,7 +122,7 @@ export function getDriverFactory>( * @param name Driver to register. Also see the TS declaration example below. * @param factory Function to create the driver instance. */ -export function registerDriver>( +export function registerDriver( name: K, factory: DriverFactory, ) { diff --git a/packages/node/src/FsDriver.ts b/packages/node/src/FsDriver.ts index 2484095..dda3b14 100644 --- a/packages/node/src/FsDriver.ts +++ b/packages/node/src/FsDriver.ts @@ -18,8 +18,8 @@ import { import { FsConfig, FsIndexData, FsIndexDefaultFileExtension } from "./types"; declare module "@jrfs/core" { - interface DriverTypes> { - fs: FsDriver; + interface DriverTypes { + fs: FsDriver; } interface DriverTypeOptions { /** An absolute config file path or fs config options. */ @@ -35,7 +35,7 @@ export interface FsDriverOptions extends Partial { // CONSIDER: Save tx in order to sync between restarts! Apply it inside onOpen // in the fileTree.build() block by setting files.tx = txFromFile; -export class FsDriver> extends Driver { +export class FsDriver extends Driver { /** The repo configuration. */ #config: FsConfig; /** Full path to the config file, if any. */ @@ -50,7 +50,7 @@ export class FsDriver> extends Driver { #transactions: Transactions = { queue: [] }; constructor( - props: DriverProps, + props: DriverProps, optionsOrConfigPath: string | FsDriverOptions, ) { const { config, configFile, rootPath, indexFile } = @@ -385,10 +385,10 @@ export class FsDriver> extends Driver { (FsDriver as any)[Symbol.toStringTag] = "FsDriver"; function createFsDriver>( - props: DriverProps, + props: DriverProps, optionsOrConfigPath: string | FsDriverOptions, -): FsDriver { - return new FsDriver(props, optionsOrConfigPath); +): FsDriver { + return new FsDriver(props, optionsOrConfigPath); } registerDriver("fs", createFsDriver); diff --git a/packages/web/src/WebDriver.ts b/packages/web/src/WebDriver.ts index 4d19072..bcb6783 100644 --- a/packages/web/src/WebDriver.ts +++ b/packages/web/src/WebDriver.ts @@ -16,17 +16,17 @@ declare module "@jrfs/core" { interface DriverTypeOptions { web: WebDriverConfig; } - interface DriverTypes> { - web: WebDriver; + interface DriverTypes { + web: WebDriver; } } -export class WebDriver> extends Driver { +export class WebDriver extends Driver { /** The repo configuration. */ #client: WebClient; #cache: FileCacheProvider | undefined; - constructor(props: DriverProps, config: WebDriverConfig) { + constructor(props: DriverProps, config: WebDriverConfig) { super(props); // Set object name for the default `toString` implementation. (this as any)[Symbol.toStringTag] = `WebDriver`; @@ -154,15 +154,15 @@ export interface WebDriverConfig { (WebDriver as any)[Symbol.toStringTag] = "WebDriver"; function createWebDriver>( - props: DriverProps, + props: DriverProps, config: WebDriverConfig, -): WebDriver { - return new WebDriver(props, config); +): WebDriver { + return new WebDriver(props, config); } registerDriver("web", createWebDriver); async function fsAction( - tree: DriverProps["fileTree"], + tree: DriverProps["fileTree"], action: Promise<{ id: string; tx: number }>, out?: TransactionOutParams, ): Promise { From 6a4bafe3c779a2154bd1ed0b5c1dd4ebd5294129 Mon Sep 17 00:00:00 2001 From: waynesbrain <175370544+waynesbrain@users.noreply.github.com> Date: Fri, 4 Oct 2024 23:05:17 -0400 Subject: [PATCH 05/11] Re-export commonly used mutative helpers for use with integrations. --- labs/demo-server/src/api/project/repo/fs.ts | 1 - packages/core/src/FileSystem.ts | 6 +++--- packages/core/src/WritableFileTree.ts | 5 ++--- packages/core/src/helpers.ts | 4 ++++ packages/idb/src/FileCache.ts | 5 ++--- 5 files changed, 11 insertions(+), 10 deletions(-) diff --git a/labs/demo-server/src/api/project/repo/fs.ts b/labs/demo-server/src/api/project/repo/fs.ts index dbbf96d..333df93 100644 --- a/labs/demo-server/src/api/project/repo/fs.ts +++ b/labs/demo-server/src/api/project/repo/fs.ts @@ -1,4 +1,3 @@ -// import { apply } from "mutative"; // Local import { Maybe, Tags, Type, Static, apiController, define } from "@/common/api"; import { Entry, TransactionOutParams } from "@jrfs/node"; diff --git a/packages/core/src/FileSystem.ts b/packages/core/src/FileSystem.ts index 4641557..025e10a 100644 --- a/packages/core/src/FileSystem.ts +++ b/packages/core/src/FileSystem.ts @@ -1,4 +1,3 @@ -import { apply, create as createDataProxy } from "mutative"; // Local import { type Entry, @@ -8,6 +7,7 @@ import { type MutativePatches, type NodeInfo, } from "@/types"; +import { applyPatch, createPatchProxy } from "@/helpers"; import { INTERNAL, isDirectoryNode } from "@/internal/types"; import type { Driver, TransactionOutParams } from "@/Driver"; import { FileTree } from "@/FileTree"; @@ -212,7 +212,7 @@ export class FileSystem> extends FileTree { // caller can handle it. throw new Error(`Entry cannot be patched "${to}".`); } - const data = apply(origData, patches); + const data = applyPatch(origData, patches); return this.#driver.write( { to, @@ -294,7 +294,7 @@ export class FileSystem> extends FileTree { } if (typeof writerOrData === "function") { const writer = writerOrData; - const [draft, finalizeDraft] = createDataProxy(origData, { + const [draft, finalizeDraft] = createPatchProxy(origData, { enablePatches: true, }); // CONSIDER: We can also let the writer return the whole data to write. diff --git a/packages/core/src/WritableFileTree.ts b/packages/core/src/WritableFileTree.ts index 23f48b5..793c391 100644 --- a/packages/core/src/WritableFileTree.ts +++ b/packages/core/src/WritableFileTree.ts @@ -1,6 +1,5 @@ -import { apply } from "mutative"; // Local -import { type CreateShortIdFunction, deepFreeze } from "@/helpers"; +import { type CreateShortIdFunction, applyPatch, deepFreeze } from "@/helpers"; import { Node, INTERNAL, @@ -689,7 +688,7 @@ export class WritableFileTree extends FileTree { } else { // Patch away since the original patch ctime matches our ctime. dataProps = { - data: apply(node.data, patch.patches), + data: applyPatch(node.data, patch.patches), }; } } diff --git a/packages/core/src/helpers.ts b/packages/core/src/helpers.ts index e4cf84c..10f529e 100644 --- a/packages/core/src/helpers.ts +++ b/packages/core/src/helpers.ts @@ -1,3 +1,7 @@ +import { apply as applyPatch, create as createPatchProxy } from "mutative"; + +export { applyPatch, createPatchProxy }; + const ALPHANUMLOWER = "0123456789abcdefghijklmnopqrstuvwxyz"; /** diff --git a/packages/idb/src/FileCache.ts b/packages/idb/src/FileCache.ts index a8eb884..4fed1e7 100644 --- a/packages/idb/src/FileCache.ts +++ b/packages/idb/src/FileCache.ts @@ -12,10 +12,10 @@ import { type FileDataChange, type FileTree, type FileTreeChange, + applyPatch, isFileId, } from "@jrfs/core"; import type { FileCacheProvider } from "@jrfs/core/cache"; -import { apply } from "mutative"; export interface IdbFileCacheOptions { db?: string; @@ -116,8 +116,7 @@ export function createFileCache(options: IdbFileCacheOptions = {}) { return; } console.log(`[IDB] onTreeChange`, id, ctime, "(SET)"); - // TODO: Don't make me import `apply` from "mutative". - const data = apply(cached.data, patch.patches); + const data = applyPatch(cached.data, patch.patches); await trx.store.put({ ctime, data } satisfies FileCacheItem, id); } } From 7112bdddeb7380a930003a5ab501349e96f2ca46 Mon Sep 17 00:00:00 2001 From: waynesbrain <175370544+waynesbrain@users.noreply.github.com> Date: Fri, 4 Oct 2024 23:13:28 -0400 Subject: [PATCH 06/11] Notes --- packages/core/src/Driver.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/core/src/Driver.ts b/packages/core/src/Driver.ts index c70e1fb..97d1855 100644 --- a/packages/core/src/Driver.ts +++ b/packages/core/src/Driver.ts @@ -17,6 +17,10 @@ export abstract class Driver { #opened = false; constructor(props: DriverProps) { + // TODO: Create #fileTree in open() or when fileTree is set INTERNAL-ly. + // That way we can remove DriverProps.fileTree and then we can create + // FileSystem without callbacks AFTER the driver in Repository constructor. + this.#fileTree = WritableFileTree[INTERNAL].create( props.fileTree, props.createShortId, From 9ea5bfb2d044d7529ea59ea38776d8ba054fea29 Mon Sep 17 00:00:00 2001 From: waynesbrain <175370544+waynesbrain@users.noreply.github.com> Date: Fri, 4 Oct 2024 23:26:41 -0400 Subject: [PATCH 07/11] Remove DriverProps.fileTree to allow creating Repository fs after driver. Replaces wonky FileSystem factory with a standard constructor. --- packages/core/src/Driver.ts | 19 ++++++++----------- packages/core/src/FileSystem.ts | 30 ++++-------------------------- packages/core/src/Repository.ts | 14 +++++--------- packages/web/src/WebDriver.ts | 14 +++++++------- 4 files changed, 24 insertions(+), 53 deletions(-) diff --git a/packages/core/src/Driver.ts b/packages/core/src/Driver.ts index 97d1855..dd2f8ef 100644 --- a/packages/core/src/Driver.ts +++ b/packages/core/src/Driver.ts @@ -11,20 +11,14 @@ import { WritableFileTree } from "@/WritableFileTree"; /** Base JRFS driver class. */ export abstract class Driver { - #fileTree: WritableFileTree; + #createShortId: CreateShortIdFunction; + #fileTree = null! as WritableFileTree; #fileTypes: FileTypeProvider; /** `true` if {@link open}, `false` if {@link close}d */ #opened = false; constructor(props: DriverProps) { - // TODO: Create #fileTree in open() or when fileTree is set INTERNAL-ly. - // That way we can remove DriverProps.fileTree and then we can create - // FileSystem without callbacks AFTER the driver in Repository constructor. - - this.#fileTree = WritableFileTree[INTERNAL].create( - props.fileTree, - props.createShortId, - ); + this.#createShortId = props.createShortId; this.#fileTypes = props.fileTypes; } @@ -66,11 +60,15 @@ export abstract class Driver { /** Handles opening the repo. */ protected abstract onOpen(): Promise; - async open() { + async open(fileTree: FileTree) { const opened = this.#opened; if (opened) { throw new Error(`Driver has already opened ${this}`); } + this.#fileTree = WritableFileTree[INTERNAL].create( + fileTree, + this.#createShortId, + ); await this.onOpen(); // Save state. this.#opened = true; @@ -172,7 +170,6 @@ export type DriverFactory = (props: DriverProps, options: any) => Driver; export interface DriverProps { createShortId: CreateShortIdFunction; fileTypes: FileTypeProvider; - fileTree: FileTree; } /** * Interface to declare a driver options types onto. diff --git a/packages/core/src/FileSystem.ts b/packages/core/src/FileSystem.ts index 025e10a..63bb42f 100644 --- a/packages/core/src/FileSystem.ts +++ b/packages/core/src/FileSystem.ts @@ -8,7 +8,7 @@ import { type NodeInfo, } from "@/types"; import { applyPatch, createPatchProxy } from "@/helpers"; -import { INTERNAL, isDirectoryNode } from "@/internal/types"; +import { isDirectoryNode } from "@/internal/types"; import type { Driver, TransactionOutParams } from "@/Driver"; import { FileTree } from "@/FileTree"; import { FileTypeProvider } from "@/FileTypeProvider"; @@ -32,35 +32,13 @@ export class FileSystem> extends FileTree { #driver = null! as Driver; #fileTypes: FileTypeProvider; - private constructor(options: { fileTypes: FileTypeProvider }) { + constructor(props: { driver: Driver; fileTypes: FileTypeProvider }) { super(); - const { fileTypes } = options; + const { driver, fileTypes } = props; + this.#driver = driver; this.#fileTypes = fileTypes; } - // #region -- Internal - static #internal = { - create>(options: { - fileTypes: FileTypeProvider; - callbacks: { - setDriver: (value: Driver) => void; - }; - }) { - const { fileTypes, callbacks } = options; - const fs = new FileSystem({ - fileTypes, - }); - callbacks.setDriver = (value: Driver) => { - fs.#driver = value; - (fs as any)[Symbol.toStringTag] = `FileSystem(${value})`; - }; - return fs; - }, - }; - static get [INTERNAL]() { - return FileSystem.#internal; - } - // #endregion // #region -- Props get fileTypes() { diff --git a/packages/core/src/Repository.ts b/packages/core/src/Repository.ts index 814b0c1..165b7df 100644 --- a/packages/core/src/Repository.ts +++ b/packages/core/src/Repository.ts @@ -1,6 +1,5 @@ // Local import type { FileTypes } from "@/types"; -import { INTERNAL } from "@/internal/types"; import type { Driver, DriverFactory, @@ -38,22 +37,19 @@ export class Repository< fileTypes, createShortId = defaultCreateShortId, } = options; - const callbacks = {} as { setDriver(value: Driver): void }; - const fs = FileSystem[INTERNAL].create({ - fileTypes, - callbacks, - }); const driverFactory = getDriverFactory(driverType); const driverOptions = options[driverType]; const driver = driverFactory( { createShortId, - fileTree: fs, fileTypes, }, driverOptions, ); - callbacks.setDriver(driver); + const fs = new FileSystem({ + driver, + fileTypes, + }); this.#driver = driver; this.#fs = fs; // Set object name for the default `toString` implementation. @@ -79,7 +75,7 @@ export class Repository< * Loads all directories and files within the repo path. */ async open() { - return this.#driver.open(); + return this.#driver.open(this.#fs); } // #endregion // #region -- Diagnostics diff --git a/packages/web/src/WebDriver.ts b/packages/web/src/WebDriver.ts index bcb6783..3c8f96d 100644 --- a/packages/web/src/WebDriver.ts +++ b/packages/web/src/WebDriver.ts @@ -1,12 +1,12 @@ import { + type DriverProps, + type Entry, + type FileTree, + type FileTypes, + type TransactionOutParams, + type TransactionParams, Driver, - Entry, - FileTypes, - // Node, - TransactionParams, - DriverProps, registerDriver, - TransactionOutParams, } from "@jrfs/core"; import { FileCacheProvider } from "@jrfs/core/cache"; // Local @@ -162,7 +162,7 @@ function createWebDriver>( registerDriver("web", createWebDriver); async function fsAction( - tree: DriverProps["fileTree"], + tree: FileTree, action: Promise<{ id: string; tx: number }>, out?: TransactionOutParams, ): Promise { From d76ff5e0c2319e9079e9392db78b45df758cd026 Mon Sep 17 00:00:00 2001 From: waynesbrain <175370544+waynesbrain@users.noreply.github.com> Date: Fri, 4 Oct 2024 23:30:22 -0400 Subject: [PATCH 08/11] Notes --- packages/core/src/FileSystem.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/core/src/FileSystem.ts b/packages/core/src/FileSystem.ts index 63bb42f..028ac5d 100644 --- a/packages/core/src/FileSystem.ts +++ b/packages/core/src/FileSystem.ts @@ -20,6 +20,8 @@ import { FileTypeProvider } from "@/FileTypeProvider"; // CONSIDER: Misc transactions... // - appendFile (could be good for letting client write a text log?) +// TODO: A method to get a download url for any file. + // TODO: Add a `realpath` type method in the FileSystem class. // - On the client, it should return the full real FS path from the server. // - On the server, it should return the full real FS path. From d1a4f4c8daf56f74b2d06960ab355d1fe3dd62e0 Mon Sep 17 00:00:00 2001 From: waynesbrain <175370544+waynesbrain@users.noreply.github.com> Date: Sat, 5 Oct 2024 12:02:58 -0400 Subject: [PATCH 09/11] Use mutative makeCreator, use in FileSystem.write and allow returning whole data from FileSystem.write writer callback. --- packages/core/src/FileSystem.ts | 22 +++++++-------- packages/core/src/helpers.ts | 47 +++++++++++++++++++++++++++++++-- 2 files changed, 54 insertions(+), 15 deletions(-) diff --git a/packages/core/src/FileSystem.ts b/packages/core/src/FileSystem.ts index 028ac5d..b0f81e9 100644 --- a/packages/core/src/FileSystem.ts +++ b/packages/core/src/FileSystem.ts @@ -7,7 +7,7 @@ import { type MutativePatches, type NodeInfo, } from "@/types"; -import { applyPatch, createPatchProxy } from "@/helpers"; +import { applyPatch, createPatch } from "@/helpers"; import { isDirectoryNode } from "@/internal/types"; import type { Driver, TransactionOutParams } from "@/Driver"; import { FileTree } from "@/FileTree"; @@ -249,7 +249,7 @@ export class FileSystem> extends FileTree { */ async write( entry: EntryOrPath, - writer: (data: D) => void | Promise, + writer: (data: D) => D | Promise | void | Promise, out?: TransactionOutParams, ): Promise; /** @@ -263,7 +263,9 @@ export class FileSystem> extends FileTree { ): Promise; async write( entry: EntryOrPath, - writerOrData: ((data: D) => void | Promise) | Readonly, + writerOrData: + | ((data: D) => D | Promise | void | Promise) + | Readonly, out?: TransactionOutParams, ): Promise { const { path: to, node: toNode } = this.fileEntry(entry); @@ -274,16 +276,10 @@ export class FileSystem> extends FileTree { } if (typeof writerOrData === "function") { const writer = writerOrData; - const [draft, finalizeDraft] = createPatchProxy(origData, { - enablePatches: true, - }); - // CONSIDER: We can also let the writer return the whole data to write. - const dataOrPromise = writer(draft as D); - if (dataOrPromise && typeof dataOrPromise.then === "function") { - await dataOrPromise; - } - // Get whole data and patches for driver to decide which to send/write... - const [data, patches, undo] = finalizeDraft(); + const [data, patches, undo] = await createPatch( + origData, + writer as (data: unknown) => D | Promise | void | Promise, + ); if (patches.length < 1) { // No change. return toEntry; diff --git a/packages/core/src/helpers.ts b/packages/core/src/helpers.ts index 10f529e..89f3c2b 100644 --- a/packages/core/src/helpers.ts +++ b/packages/core/src/helpers.ts @@ -1,6 +1,47 @@ -import { apply as applyPatch, create as createPatchProxy } from "mutative"; +import { apply as applyPatch, rawReturn, makeCreator } from "mutative"; -export { applyPatch, createPatchProxy }; +// #region Mutative + +export { applyPatch, rawReturn }; +/** + * Creates patches to apply to a JS object. Creates new state from a base state. + * + * See [mutative.js](https://mutative.js.org/docs/api-reference/create) + * + * ```ts + * createPatch(baseState, + * (draft) => unknown | Promise + * ) => unknown | Promise; + * ``` + * + * ## Example + * + * ```ts + * import { createPatch, rawReturn } from '@jrfs/core'; + * + * const baseState = { foo: { bar: 'str' }, arr: [] }; + * const state = create( + * baseState, + * (draft) => { + * draft.foo.bar = 'str2'; + * // or return { ...draft, foo:{bar:'str2'} }; + * // or return rawReturn({ foo:{bar:'str2'}, arr:[] }); + * }, + * ); + * + * expect(state).toEqual({ foo: { bar: 'str2' }, arr: [] }); + * expect(state).not.toBe(baseState); + * expect(state.foo).not.toBe(baseState.foo); + * expect(state.arr).toBe(baseState.arr); + * ``` + */ +export const createPatch = makeCreator({ + enableAutoFreeze: true, + enablePatches: true, + strict: process.env.NODE_ENV === "development", +}); +// #endregion +// #region createShortId const ALPHANUMLOWER = "0123456789abcdefghijklmnopqrstuvwxyz"; @@ -27,6 +68,8 @@ export function createShortId(length: number = 9): string { } export type CreateShortIdFunction = typeof createShortId; +// #endregion + /** * Deep `Object.freeze()`, works with Map and Set. From * [deep-freeze-es6](https://github.com/christophehurpeau/deep-freeze-es6) From abbfd65c3f1760daacce6a99701ab00668bf4fa1 Mon Sep 17 00:00:00 2001 From: waynesbrain <175370544+waynesbrain@users.noreply.github.com> Date: Sat, 5 Oct 2024 14:54:18 -0400 Subject: [PATCH 10/11] Cleanup call to createPatch. --- packages/core/src/FileSystem.ts | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/packages/core/src/FileSystem.ts b/packages/core/src/FileSystem.ts index b0f81e9..27d6798 100644 --- a/packages/core/src/FileSystem.ts +++ b/packages/core/src/FileSystem.ts @@ -275,11 +275,13 @@ export class FileSystem> extends FileTree { origData = (await this.get(toEntry)).data as D; } if (typeof writerOrData === "function") { - const writer = writerOrData; - const [data, patches, undo] = await createPatch( - origData, - writer as (data: unknown) => D | Promise | void | Promise, - ); + // We don't need mutative's Draft here to remove readonly from D's + // properties since D represents a mutable type already. + const writer = writerOrData as ( + // data: Draft is default, but for local cast skip the type import. + data: unknown, + ) => D | Promise | void | Promise; + const [data, patches, undo] = await createPatch(origData, writer); if (patches.length < 1) { // No change. return toEntry; From c7fa52a5fca05118bfe260937e4a5c02a6876af8 Mon Sep 17 00:00:00 2001 From: waynesbrain <175370544+waynesbrain@users.noreply.github.com> Date: Sat, 5 Oct 2024 15:01:59 -0400 Subject: [PATCH 11/11] Rename watch-build commands to just watch. --- labs/demo-server/package.json | 4 ++-- labs/demo-shared/package.json | 2 +- packages/core/package.json | 2 +- packages/idb/package.json | 2 +- packages/node/package.json | 2 +- packages/typebox/package.json | 2 +- packages/web/package.json | 2 +- packages/ws/package.json | 2 +- 8 files changed, 9 insertions(+), 9 deletions(-) diff --git a/labs/demo-server/package.json b/labs/demo-server/package.json index 6e9e915..020c712 100644 --- a/labs/demo-server/package.json +++ b/labs/demo-server/package.json @@ -31,8 +31,8 @@ "start-win": "nodemon", "start-bin": "node bin/jrfs-demo-server.cjs", "test": "echo 'Sorry, no tests yet!'", - "watch": "tsc -w --noEmit --pretty --skipLibCheck --project tsconfig.eslint.json", - "watch-build": "node --watch-path=./src --watch-path=../../node_modules/@jrfs ../../scripts/build-esm.mjs" + "watch": "node --watch-path=./src --watch-path=../../node_modules/@jrfs ../../scripts/build-esm.mjs", + "watch-ts": "tsc -w --noEmit --pretty --skipLibCheck --project tsconfig.eslint.json" }, "nodemonConfig": { "delay": "250ms", diff --git a/labs/demo-shared/package.json b/labs/demo-shared/package.json index 15c4f54..d24caf1 100644 --- a/labs/demo-shared/package.json +++ b/labs/demo-shared/package.json @@ -27,7 +27,7 @@ "lint-fix": "eslint . --ext .ts --fix", "lint-ts": "tsc --noEmit --pretty --project ./tsconfig.eslint.json", "rm-build": "shx rm -rf lib/*", - "watch-build": "node --watch-path=./src --watch-path=../../node_modules/@jrfs ../../scripts/build-esm.mjs lib --tsconfig tsconfig.prod.json" + "watch": "node --watch-path=./src --watch-path=../../node_modules/@jrfs ../../scripts/build-esm.mjs lib --tsconfig tsconfig.prod.json" }, "dependencies": { "nanoid": "^5.0.7" diff --git a/packages/core/package.json b/packages/core/package.json index 5957c82..4409cf2 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -32,7 +32,7 @@ "lint-fix": "eslint . --ext .ts --fix", "lint-ts": "tsc --noEmit --pretty --project ./tsconfig.eslint.json", "rm-build": "shx rm -rf lib/*", - "watch-build": "node --watch-path=./src ../../scripts/build-esm.mjs lib --tsconfig tsconfig.prod.json" + "watch": "node --watch-path=./src ../../scripts/build-esm.mjs lib --tsconfig tsconfig.prod.json" }, "dependencies": { "mutative": "1.0.11" diff --git a/packages/idb/package.json b/packages/idb/package.json index bd2480f..c4ceac9 100644 --- a/packages/idb/package.json +++ b/packages/idb/package.json @@ -33,7 +33,7 @@ "lint-fix": "eslint . --ext .ts --fix", "lint-ts": "tsc --noEmit --pretty --project ./tsconfig.eslint.json", "rm-build": "shx rm -rf lib/*", - "watch-build": "node --watch-path=./src --watch-path=../../node_modules/@jrfs/core/lib ../../scripts/build-esm.mjs lib --tsconfig tsconfig.prod.json" + "watch": "node --watch-path=./src --watch-path=../../node_modules/@jrfs/core/lib ../../scripts/build-esm.mjs lib --tsconfig tsconfig.prod.json" }, "dependencies": { "@jrfs/core": "^0.2.0", diff --git a/packages/node/package.json b/packages/node/package.json index ca08dfa..98d6f40 100644 --- a/packages/node/package.json +++ b/packages/node/package.json @@ -35,7 +35,7 @@ "lint-fix": "eslint . --ext .ts --fix", "lint-ts": "tsc --noEmit --pretty --project ./tsconfig.eslint.json", "rm-build": "shx rm -rf lib/*", - "watch-build": "node --watch-path=./src --watch-path=../../node_modules/@jrfs/core/lib ../../scripts/build-esm.mjs lib --tsconfig tsconfig.prod.json" + "watch": "node --watch-path=./src --watch-path=../../node_modules/@jrfs/core/lib ../../scripts/build-esm.mjs lib --tsconfig tsconfig.prod.json" }, "dependencies": { "@jrfs/core": "^0.2.0" diff --git a/packages/typebox/package.json b/packages/typebox/package.json index 1fbd3b5..2252fcc 100644 --- a/packages/typebox/package.json +++ b/packages/typebox/package.json @@ -33,7 +33,7 @@ "lint-fix": "eslint . --ext .ts --fix", "lint-ts": "tsc --noEmit --pretty --project ./tsconfig.eslint.json", "rm-build": "shx rm -rf lib/*", - "watch-build": "node --watch-path=./src --watch-path=../../node_modules/@jrfs/core/lib ../../scripts/build-esm.mjs lib --tsconfig tsconfig.prod.json" + "watch": "node --watch-path=./src --watch-path=../../node_modules/@jrfs/core/lib ../../scripts/build-esm.mjs lib --tsconfig tsconfig.prod.json" }, "dependencies": { "@jrfs/core": "^0.2.0" diff --git a/packages/web/package.json b/packages/web/package.json index c404aa0..03d48e0 100644 --- a/packages/web/package.json +++ b/packages/web/package.json @@ -32,7 +32,7 @@ "lint-fix": "eslint . --ext .ts --fix", "lint-ts": "tsc --noEmit --pretty --project ./tsconfig.eslint.json", "rm-build": "shx rm -rf lib/*", - "watch-build": "node --watch-path=./src --watch-path=../../node_modules/@jrfs/core/lib ../../scripts/build-esm.mjs lib --tsconfig tsconfig.prod.json" + "watch": "node --watch-path=./src --watch-path=../../node_modules/@jrfs/core/lib ../../scripts/build-esm.mjs lib --tsconfig tsconfig.prod.json" }, "dependencies": { "@jrfs/core": "^0.2.0" diff --git a/packages/ws/package.json b/packages/ws/package.json index dd11531..8c15b26 100644 --- a/packages/ws/package.json +++ b/packages/ws/package.json @@ -33,7 +33,7 @@ "lint-fix": "eslint . --ext .ts --fix", "lint-ts": "tsc --noEmit --pretty --project ./tsconfig.eslint.json", "rm-build": "shx rm -rf lib/*", - "watch-build": "node --watch-path=./src --watch-path=../../node_modules/@jrfs/core/lib ../../scripts/build-esm.mjs lib --tsconfig tsconfig.prod.json" + "watch": "node --watch-path=./src --watch-path=../../node_modules/@jrfs/core/lib ../../scripts/build-esm.mjs lib --tsconfig tsconfig.prod.json" }, "dependencies": { "@jrfs/core": "^0.2.0"