@pluv/crdt 3.2.2 → 4.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,18 +1,16 @@
1
1
 
2
- > @pluv/crdt@3.2.2 build /home/runner/work/pluv/pluv/packages/crdt
3
- > tsup src/index.ts --format esm,cjs --dts
2
+ > @pluv/crdt@4.0.1 build /home/runner/work/pluv/pluv/packages/crdt
3
+ > tsdown
4
4
 
5
- CLI Building entry: src/index.ts
6
- CLI Using tsconfig: tsconfig.json
7
- CLI tsup v8.5.0
8
- CLI Target: es6
9
- ESM Build start
10
- CJS Build start
11
- CJS dist/index.js 3.05 KB
12
- CJS ⚡️ Build success in 22ms
13
- ESM dist/index.mjs 1.92 KB
14
- ESM ⚡️ Build success in 22ms
15
- DTS Build start
16
- DTS ⚡️ Build success in 494ms
17
- DTS dist/index.d.mts 2.77 KB
18
- DTS dist/index.d.ts 2.77 KB
5
+ ℹ tsdown v0.20.0-beta.4 powered by rolldown v1.0.0-beta.60
6
+ ℹ config file: /home/runner/work/pluv/pluv/packages/crdt/tsdown.config.ts
7
+ ℹ entry: src/index.ts
8
+ ℹ target: esnext
9
+ ℹ tsconfig: tsconfig.json
10
+ ℹ Build start
11
+ ℹ dist/index.mjs 1.93 kB │ gzip: 0.65 kB
12
+ ℹ dist/index.mjs.map 5.37 kB │ gzip: 1.61 kB
13
+ ℹ dist/index.d.mts.map 1.45 kB │ gzip: 0.54 kB
14
+ ℹ dist/index.d.mts 3.33 kB │ gzip: 0.92 kB
15
+ ℹ 4 files, total: 12.07 kB
16
+ ✔ Build complete in 515ms
package/CHANGELOG.md CHANGED
@@ -1,5 +1,29 @@
1
1
  # @pluv/crdt
2
2
 
3
+ ## 4.0.1
4
+
5
+ ### Patch Changes
6
+
7
+ - @pluv/types@4.0.1
8
+
9
+ ## 4.0.0
10
+
11
+ ### Major Changes
12
+
13
+ - df5c39c: Update all packages to be ESM only.
14
+
15
+ ### Minor Changes
16
+
17
+ - 037074e: Migrated build process from tsup to tsdown.
18
+
19
+ ### Patch Changes
20
+
21
+ - 2eb5def: Bumped dependencies.
22
+ - Updated dependencies [2eb5def]
23
+ - Updated dependencies [df5c39c]
24
+ - Updated dependencies [037074e]
25
+ - @pluv/types@4.0.0
26
+
3
27
  ## 3.2.2
4
28
 
5
29
  ### Patch Changes
package/dist/index.d.mts CHANGED
@@ -1,51 +1,56 @@
1
- import { CrdtType, CrdtDocFactory, CrdtDocLike, Maybe, DocApplyEncodedStateParams, DocBatchApplyEncodedStateParams, DocSubscribeCallbackParams } from '@pluv/types';
2
- export { CrdtDocLike, CrdtLibraryType, CrdtType, DocApplyEncodedStateParams, DocBatchApplyEncodedStateParams, DocSubscribeCallbackParams, InferCrdtJson } from '@pluv/types';
1
+ import { CrdtDocFactory, CrdtDocLike, CrdtDocLike as CrdtDocLike$1, CrdtLibraryType, CrdtType, CrdtType as CrdtType$1, DocApplyEncodedStateParams, DocApplyEncodedStateParams as DocApplyEncodedStateParams$1, DocBatchApplyEncodedStateParams, DocBatchApplyEncodedStateParams as DocBatchApplyEncodedStateParams$1, DocSubscribeCallbackParams, DocSubscribeCallbackParams as DocSubscribeCallbackParams$1, InferCrdtJson, Maybe } from "@pluv/types";
3
2
 
4
- declare abstract class AbstractCrdtDocFactory<TDoc extends any, TStorage extends Record<string, CrdtType<any, any>>> implements CrdtDocFactory<TDoc, TStorage> {
5
- _initialStorage: (builder: any) => TStorage;
6
- constructor(initialStorage: (builder: any) => TStorage);
7
- abstract getEmpty(): CrdtDocLike<TDoc, TStorage>;
8
- abstract getFactory(initialStorage?: (builder: any) => TStorage): AbstractCrdtDocFactory<TDoc, TStorage>;
9
- abstract getInitialized(initialStorage?: (builder: any) => TStorage): CrdtDocLike<TDoc, TStorage>;
10
- isEmpty(initialState: Maybe<string>): boolean;
11
- resolveEncodedState(updates: string | string[] | readonly string[]): string | null;
3
+ //#region src/AbstractCrdtDocFactory.d.ts
4
+ declare abstract class AbstractCrdtDocFactory<TDoc extends any, TStorage extends Record<string, CrdtType$1<any, any>>> implements CrdtDocFactory<TDoc, TStorage> {
5
+ _initialStorage: (builder: any) => TStorage;
6
+ constructor(initialStorage: (builder: any) => TStorage);
7
+ abstract getEmpty(): CrdtDocLike$1<TDoc, TStorage>;
8
+ abstract getFactory(initialStorage?: (builder: any) => TStorage): AbstractCrdtDocFactory<TDoc, TStorage>;
9
+ abstract getInitialized(initialStorage?: (builder: any) => TStorage): CrdtDocLike$1<TDoc, TStorage>;
10
+ isEmpty(initialState: Maybe<string>): boolean;
11
+ resolveEncodedState(updates: string | string[] | readonly string[]): string | null;
12
12
  }
13
-
14
- declare class NoopCrdtDoc implements CrdtDocLike<any, any> {
15
- value: any;
16
- applyEncodedState(params: DocApplyEncodedStateParams): this;
17
- batchApplyEncodedState(params: DocBatchApplyEncodedStateParams): this;
18
- canRedo(): boolean;
19
- canUndo(): boolean;
20
- destroy(): void;
21
- get(key?: undefined): {};
22
- get<TKey extends never>(key: TKey): {}[TKey];
23
- getEncodedState(): string;
24
- isEmpty(): boolean;
25
- rebuildStorage(): this;
26
- redo(): this;
27
- subscribe(listener: (params: DocSubscribeCallbackParams<any, any>) => void): () => void;
28
- toJson(): any;
29
- track(): this;
30
- transact(fn: () => void, origin?: string | undefined): this;
31
- undo(): this;
13
+ //#endregion
14
+ //#region src/NoopCrdtDoc.d.ts
15
+ declare class NoopCrdtDoc implements CrdtDocLike$1<any, any> {
16
+ value: any;
17
+ applyEncodedState(params: DocApplyEncodedStateParams$1): this;
18
+ batchApplyEncodedState(params: DocBatchApplyEncodedStateParams$1): this;
19
+ canRedo(): boolean;
20
+ canUndo(): boolean;
21
+ destroy(): void;
22
+ get(key?: undefined): {};
23
+ get<TKey extends never>(key: TKey): {}[TKey];
24
+ getEncodedState(): string;
25
+ isEmpty(): boolean;
26
+ rebuildStorage(): this;
27
+ redo(): this;
28
+ subscribe(listener: (params: DocSubscribeCallbackParams$1<any, any>) => void): () => void;
29
+ toJson(): any;
30
+ track(): this;
31
+ transact(fn: () => void, origin?: string | undefined): this;
32
+ undo(): this;
32
33
  }
33
-
34
+ //#endregion
35
+ //#region src/NoopCrdtDocFactory.d.ts
34
36
  declare class NoopCrdtDocFactory extends AbstractCrdtDocFactory<any, any> {
35
- constructor(initialStorage?: () => {});
36
- getEmpty(): NoopCrdtDoc;
37
- getFactory(initialStorage?: ((builder: any) => any) | undefined): NoopCrdtDocFactory;
38
- getInitialized(initialStorage?: ((builder: any) => any) | undefined): NoopCrdtDoc;
37
+ constructor(initialStorage?: () => {});
38
+ getEmpty(): NoopCrdtDoc;
39
+ getFactory(initialStorage?: ((builder: any) => any) | undefined): NoopCrdtDocFactory;
40
+ getInitialized(initialStorage?: ((builder: any) => any) | undefined): NoopCrdtDoc;
39
41
  }
40
-
42
+ //#endregion
43
+ //#region src/noop.d.ts
41
44
  declare const noop: {
42
- doc: (args?: any) => NoopCrdtDocFactory;
45
+ doc: (args?: any) => NoopCrdtDocFactory;
43
46
  };
44
-
47
+ //#endregion
48
+ //#region src/types.d.ts
45
49
  type InferDoc<TFactory extends AbstractCrdtDocFactory<any, any>> = InferDocLike<TFactory>["value"];
46
50
  type InferDocLike<TFactory extends AbstractCrdtDocFactory<any, any>> = ReturnType<TFactory["getInitialized"]>;
47
51
  type InferInitialStorageFn<TFactory extends AbstractCrdtDocFactory<any, any>> = TFactory["_initialStorage"];
48
52
  type InferStorage<TFactory extends AbstractCrdtDocFactory<any, any>> = ReturnType<InferInitialStorageFn<TFactory>>;
49
53
  type InferBuilder<TFactory extends AbstractCrdtDocFactory<any, any>> = Parameters<InferInitialStorageFn<TFactory>>[0];
50
-
51
- export { AbstractCrdtDocFactory, type InferBuilder, type InferDoc, type InferDocLike, type InferInitialStorageFn, type InferStorage, NoopCrdtDoc, NoopCrdtDocFactory, noop };
54
+ //#endregion
55
+ export { AbstractCrdtDocFactory, type CrdtDocLike, type CrdtLibraryType, type CrdtType, type DocApplyEncodedStateParams, type DocBatchApplyEncodedStateParams, type DocSubscribeCallbackParams, type InferBuilder, type InferCrdtJson, type InferDoc, type InferDocLike, type InferInitialStorageFn, type InferStorage, NoopCrdtDoc, NoopCrdtDocFactory, noop };
56
+ //# sourceMappingURL=index.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.mts","names":[],"sources":["../src/AbstractCrdtDocFactory.ts","../src/NoopCrdtDoc.ts","../src/NoopCrdtDocFactory.ts","../src/noop.ts","../src/types.ts"],"mappings":";;;uBAEsB,sBAAA,oCAED,MAAA,SAAe,UAAA,wBACvB,cAAA,CAAe,IAAA,EAAM,QAAA;EAEvB,eAAA,GAAkB,OAAA,UAAiB,QAAA;cAE9B,cAAA,GAAiB,OAAA,UAAiB,QAAA;EAAA,SAI9B,QAAA,CAAA,GAAY,aAAA,CAAY,IAAA,EAAM,QAAA;EAAA,SAC9B,UAAA,CACZ,cAAA,IAAkB,OAAA,UAAiB,QAAA,GACpC,sBAAA,CAAuB,IAAA,EAAM,QAAA;EAAA,SAChB,cAAA,CACZ,cAAA,IAAkB,OAAA,UAAiB,QAAA,GACpC,aAAA,CAAY,IAAA,EAAM,QAAA;EAEd,OAAA,CAAQ,YAAA,EAAc,KAAA;EAQtB,mBAAA,CAAoB,OAAA;AAAA;;;cCtBlB,WAAA,YAAuB,aAAA;EACzB,KAAA;EAEA,iBAAA,CAAkB,MAAA,EAAQ,4BAAA;EAI1B,sBAAA,CAAuB,MAAA,EAAQ,iCAAA;EAI/B,OAAA,CAAA;EAIA,OAAA,CAAA;EAIA,OAAA,CAAA;EAIA,GAAA,CAAI,GAAA;EACJ,GAAA,oBAAA,CAAwB,GAAA,EAAK,IAAA,MAAU,IAAA;EAKvC,eAAA,CAAA;EAIA,OAAA,CAAA;EAIA,cAAA,CAAA;EAIA,IAAA,CAAA;EAIA,SAAA,CAAU,QAAA,GAAW,MAAA,EAAQ,4BAAA;EAI7B,MAAA,CAAA;EAIA,KAAA,CAAA;EAIA,QAAA,CAAS,EAAA,cAAgB,MAAA;EAMzB,IAAA,CAAA;AAAA;;;cCnEE,kBAAA,SAA2B,sBAAA;cACxB,cAAA;EAIL,QAAA,CAAA,GAAY,WAAA;EAIZ,UAAA,CAAW,cAAA,KAAmB,OAAA,6BAAoC,kBAAA;EAIlE,cAAA,CAAe,cAAA,KAAmB,OAAA,6BAAoC,WAAA;AAAA;;;cCdpE,IAAA;uBACO,kBAAA;AAAA;;;KCCR,QAAA,kBAA0B,sBAAA,cAClC,YAAA,CAAa,QAAA;AAAA,KAEL,YAAA,kBAA8B,sBAAA,cAAoC,UAAA,CAC1E,QAAA;AAAA,KAGQ,qBAAA,kBAAuC,sBAAA,cAC/C,QAAA;AAAA,KAEQ,YAAA,kBAA8B,sBAAA,cAAoC,UAAA,CAC1E,qBAAA,CAAsB,QAAA;AAAA,KAGd,YAAA,kBAA8B,sBAAA,cAAoC,UAAA,CAC1E,qBAAA,CAAsB,QAAA"}
package/dist/index.mjs CHANGED
@@ -1,104 +1,100 @@
1
- // src/AbstractCrdtDocFactory.ts
1
+ //#region src/AbstractCrdtDocFactory.ts
2
2
  var AbstractCrdtDocFactory = class {
3
- constructor(initialStorage) {
4
- this._initialStorage = initialStorage;
5
- }
6
- isEmpty(initialState) {
7
- const doc = this.getEmpty().applyEncodedState({ update: initialState });
8
- const isEmpty = doc.isEmpty();
9
- doc.destroy();
10
- return isEmpty;
11
- }
12
- resolveEncodedState(updates) {
13
- if (typeof updates === "string") return updates;
14
- if (Array.isArray(updates) && !updates.length) return null;
15
- const applied = this.getEmpty().batchApplyEncodedState({ updates });
16
- if (applied.isEmpty()) {
17
- applied.destroy();
18
- return null;
19
- }
20
- const encodedState = applied.getEncodedState();
21
- applied.destroy();
22
- return encodedState;
23
- }
3
+ _initialStorage;
4
+ constructor(initialStorage) {
5
+ this._initialStorage = initialStorage;
6
+ }
7
+ isEmpty(initialState) {
8
+ const doc = this.getEmpty().applyEncodedState({ update: initialState });
9
+ const isEmpty = doc.isEmpty();
10
+ doc.destroy();
11
+ return isEmpty;
12
+ }
13
+ resolveEncodedState(updates) {
14
+ if (typeof updates === "string") return updates;
15
+ if (Array.isArray(updates) && !updates.length) return null;
16
+ const applied = this.getEmpty().batchApplyEncodedState({ updates });
17
+ if (applied.isEmpty()) {
18
+ applied.destroy();
19
+ return null;
20
+ }
21
+ const encodedState = applied.getEncodedState();
22
+ applied.destroy();
23
+ return encodedState;
24
+ }
24
25
  };
25
26
 
26
- // src/NoopCrdtDoc.ts
27
+ //#endregion
28
+ //#region src/NoopCrdtDoc.ts
27
29
  var NoopCrdtDoc = class {
28
- constructor() {
29
- this.value = null;
30
- }
31
- applyEncodedState(params) {
32
- return this;
33
- }
34
- batchApplyEncodedState(params) {
35
- return this;
36
- }
37
- canRedo() {
38
- return false;
39
- }
40
- canUndo() {
41
- return false;
42
- }
43
- destroy() {
44
- return;
45
- }
46
- get(key) {
47
- return typeof key === "string" ? void 0 : {};
48
- }
49
- getEncodedState() {
50
- return "";
51
- }
52
- isEmpty() {
53
- return true;
54
- }
55
- rebuildStorage() {
56
- return this;
57
- }
58
- redo() {
59
- return this;
60
- }
61
- subscribe(listener) {
62
- return () => void 0;
63
- }
64
- toJson() {
65
- return {};
66
- }
67
- track() {
68
- return this;
69
- }
70
- transact(fn, origin) {
71
- fn();
72
- return this;
73
- }
74
- undo() {
75
- return this;
76
- }
30
+ value = null;
31
+ applyEncodedState(params) {
32
+ return this;
33
+ }
34
+ batchApplyEncodedState(params) {
35
+ return this;
36
+ }
37
+ canRedo() {
38
+ return false;
39
+ }
40
+ canUndo() {
41
+ return false;
42
+ }
43
+ destroy() {}
44
+ get(key) {
45
+ return typeof key === "string" ? void 0 : {};
46
+ }
47
+ getEncodedState() {
48
+ return "";
49
+ }
50
+ isEmpty() {
51
+ return true;
52
+ }
53
+ rebuildStorage() {
54
+ return this;
55
+ }
56
+ redo() {
57
+ return this;
58
+ }
59
+ subscribe(listener) {
60
+ return () => void 0;
61
+ }
62
+ toJson() {
63
+ return {};
64
+ }
65
+ track() {
66
+ return this;
67
+ }
68
+ transact(fn, origin) {
69
+ fn();
70
+ return this;
71
+ }
72
+ undo() {
73
+ return this;
74
+ }
77
75
  };
78
76
 
79
- // src/NoopCrdtDocFactory.ts
77
+ //#endregion
78
+ //#region src/NoopCrdtDocFactory.ts
80
79
  var NoopCrdtDocFactory = class extends AbstractCrdtDocFactory {
81
- constructor(initialStorage = () => ({})) {
82
- super(initialStorage);
83
- }
84
- getEmpty() {
85
- return new NoopCrdtDoc();
86
- }
87
- getFactory(initialStorage) {
88
- return this;
89
- }
90
- getInitialized(initialStorage) {
91
- return new NoopCrdtDoc();
92
- }
80
+ constructor(initialStorage = () => ({})) {
81
+ super(initialStorage);
82
+ }
83
+ getEmpty() {
84
+ return new NoopCrdtDoc();
85
+ }
86
+ getFactory(initialStorage) {
87
+ return this;
88
+ }
89
+ getInitialized(initialStorage) {
90
+ return new NoopCrdtDoc();
91
+ }
93
92
  };
94
93
 
95
- // src/noop.ts
96
- var noop = {
97
- doc: (args) => new NoopCrdtDocFactory()
98
- };
99
- export {
100
- AbstractCrdtDocFactory,
101
- NoopCrdtDoc,
102
- NoopCrdtDocFactory,
103
- noop
104
- };
94
+ //#endregion
95
+ //#region src/noop.ts
96
+ const noop = { doc: (args) => new NoopCrdtDocFactory() };
97
+
98
+ //#endregion
99
+ export { AbstractCrdtDocFactory, NoopCrdtDoc, NoopCrdtDocFactory, noop };
100
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../src/AbstractCrdtDocFactory.ts","../src/NoopCrdtDoc.ts","../src/NoopCrdtDocFactory.ts","../src/noop.ts"],"sourcesContent":["import type { CrdtDocFactory, CrdtDocLike, CrdtType, Maybe } from \"@pluv/types\";\n\nexport abstract class AbstractCrdtDocFactory<\n TDoc extends any,\n TStorage extends Record<string, CrdtType<any, any>>,\n> implements CrdtDocFactory<TDoc, TStorage>\n{\n public _initialStorage: (builder: any) => TStorage;\n\n constructor(initialStorage: (builder: any) => TStorage) {\n this._initialStorage = initialStorage;\n }\n\n public abstract getEmpty(): CrdtDocLike<TDoc, TStorage>;\n public abstract getFactory(\n initialStorage?: (builder: any) => TStorage,\n ): AbstractCrdtDocFactory<TDoc, TStorage>;\n public abstract getInitialized(\n initialStorage?: (builder: any) => TStorage,\n ): CrdtDocLike<TDoc, TStorage>;\n\n public isEmpty(initialState: Maybe<string>): boolean {\n const doc = this.getEmpty().applyEncodedState({ update: initialState });\n const isEmpty = doc.isEmpty();\n doc.destroy();\n\n return isEmpty;\n }\n\n public resolveEncodedState(updates: string | string[] | readonly string[]): string | null {\n if (typeof updates === \"string\") return updates;\n if (Array.isArray(updates) && !updates.length) return null;\n\n const applied = this.getEmpty().batchApplyEncodedState({ updates });\n\n if (applied.isEmpty()) {\n applied.destroy();\n return null;\n }\n\n const encodedState = applied.getEncodedState();\n applied.destroy();\n\n return encodedState;\n }\n}\n","import {\n CrdtDocLike,\n DocApplyEncodedStateParams,\n DocBatchApplyEncodedStateParams,\n DocSubscribeCallbackParams,\n} from \"@pluv/types\";\n\nexport class NoopCrdtDoc implements CrdtDocLike<any, any> {\n public value: any = null;\n\n public applyEncodedState(params: DocApplyEncodedStateParams): this {\n return this;\n }\n\n public batchApplyEncodedState(params: DocBatchApplyEncodedStateParams): this {\n return this;\n }\n\n public canRedo(): boolean {\n return false;\n }\n\n public canUndo(): boolean {\n return false;\n }\n\n public destroy(): void {\n return;\n }\n\n public get(key?: undefined): {};\n public get<TKey extends never>(key: TKey): {}[TKey];\n public get(key?: string): {} | undefined {\n return typeof key === \"string\" ? undefined : {};\n }\n\n public getEncodedState(): string {\n return \"\";\n }\n\n public isEmpty(): boolean {\n return true;\n }\n\n public rebuildStorage(): this {\n return this;\n }\n\n public redo(): this {\n return this;\n }\n\n public subscribe(listener: (params: DocSubscribeCallbackParams<any, any>) => void): () => void {\n return () => undefined;\n }\n\n public toJson(): any {\n return {};\n }\n\n public track(): this {\n return this;\n }\n\n public transact(fn: () => void, origin?: string | undefined): this {\n fn();\n\n return this;\n }\n\n public undo(): this {\n return this;\n }\n}\n","import { AbstractCrdtDocFactory } from \"./AbstractCrdtDocFactory\";\nimport { NoopCrdtDoc } from \"./NoopCrdtDoc\";\n\nexport class NoopCrdtDocFactory extends AbstractCrdtDocFactory<any, any> {\n constructor(initialStorage: () => {} = () => ({})) {\n super(initialStorage);\n }\n\n public getEmpty(): NoopCrdtDoc {\n return new NoopCrdtDoc();\n }\n\n public getFactory(initialStorage?: ((builder: any) => any) | undefined): NoopCrdtDocFactory {\n return this;\n }\n\n public getInitialized(initialStorage?: ((builder: any) => any) | undefined): NoopCrdtDoc {\n return new NoopCrdtDoc();\n }\n}\n","import { NoopCrdtDocFactory } from \"./NoopCrdtDocFactory\";\n\nexport const noop = {\n doc: (args?: any) => new NoopCrdtDocFactory(),\n};\n"],"mappings":";AAEA,IAAsB,yBAAtB,MAIA;CACI,AAAO;CAEP,YAAY,gBAA4C;AACpD,OAAK,kBAAkB;;CAW3B,AAAO,QAAQ,cAAsC;EACjD,MAAM,MAAM,KAAK,UAAU,CAAC,kBAAkB,EAAE,QAAQ,cAAc,CAAC;EACvE,MAAM,UAAU,IAAI,SAAS;AAC7B,MAAI,SAAS;AAEb,SAAO;;CAGX,AAAO,oBAAoB,SAA+D;AACtF,MAAI,OAAO,YAAY,SAAU,QAAO;AACxC,MAAI,MAAM,QAAQ,QAAQ,IAAI,CAAC,QAAQ,OAAQ,QAAO;EAEtD,MAAM,UAAU,KAAK,UAAU,CAAC,uBAAuB,EAAE,SAAS,CAAC;AAEnE,MAAI,QAAQ,SAAS,EAAE;AACnB,WAAQ,SAAS;AACjB,UAAO;;EAGX,MAAM,eAAe,QAAQ,iBAAiB;AAC9C,UAAQ,SAAS;AAEjB,SAAO;;;;;;ACpCf,IAAa,cAAb,MAA0D;CACtD,AAAO,QAAa;CAEpB,AAAO,kBAAkB,QAA0C;AAC/D,SAAO;;CAGX,AAAO,uBAAuB,QAA+C;AACzE,SAAO;;CAGX,AAAO,UAAmB;AACtB,SAAO;;CAGX,AAAO,UAAmB;AACtB,SAAO;;CAGX,AAAO,UAAgB;CAMvB,AAAO,IAAI,KAA8B;AACrC,SAAO,OAAO,QAAQ,WAAW,SAAY,EAAE;;CAGnD,AAAO,kBAA0B;AAC7B,SAAO;;CAGX,AAAO,UAAmB;AACtB,SAAO;;CAGX,AAAO,iBAAuB;AAC1B,SAAO;;CAGX,AAAO,OAAa;AAChB,SAAO;;CAGX,AAAO,UAAU,UAA8E;AAC3F,eAAa;;CAGjB,AAAO,SAAc;AACjB,SAAO,EAAE;;CAGb,AAAO,QAAc;AACjB,SAAO;;CAGX,AAAO,SAAS,IAAgB,QAAmC;AAC/D,MAAI;AAEJ,SAAO;;CAGX,AAAO,OAAa;AAChB,SAAO;;;;;;ACpEf,IAAa,qBAAb,cAAwC,uBAAiC;CACrE,YAAY,wBAAkC,EAAE,GAAG;AAC/C,QAAM,eAAe;;CAGzB,AAAO,WAAwB;AAC3B,SAAO,IAAI,aAAa;;CAG5B,AAAO,WAAW,gBAA0E;AACxF,SAAO;;CAGX,AAAO,eAAe,gBAAmE;AACrF,SAAO,IAAI,aAAa;;;;;;ACfhC,MAAa,OAAO,EAChB,MAAM,SAAe,IAAI,oBAAoB,EAChD"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pluv/crdt",
3
- "version": "3.2.2",
3
+ "version": "4.0.1",
4
4
  "description": "crdt base for @pluv/io",
5
5
  "author": {
6
6
  "email": "david@pluv.io",
@@ -14,26 +14,30 @@
14
14
  "url": "git+https://github.com/pluv-io/pluv.git",
15
15
  "directory": "packages/crdt"
16
16
  },
17
- "main": "./dist/index.js",
18
- "module": "./dist/index.mjs",
19
- "types": "./dist/index.d.ts",
17
+ "type": "module",
18
+ "types": "./dist/index.d.mts",
20
19
  "publishConfig": {
21
20
  "access": "public"
22
21
  },
23
22
  "dependencies": {
24
- "@pluv/types": "^3.2.2"
23
+ "@pluv/types": "^4.0.1"
25
24
  },
26
25
  "devDependencies": {
27
- "eslint": "^9.31.0",
28
- "tsup": "^8.5.0",
29
- "typescript": "^5.8.3",
30
- "@pluv/tsconfig": "^3.2.2",
31
- "eslint-config-pluv": "^3.2.2"
26
+ "eslint": "^9.39.2",
27
+ "tsdown": "0.20.0-beta.4",
28
+ "typescript": "^5.9.3",
29
+ "@pluv/tsconfig": "^4.0.1",
30
+ "eslint-config-pluv": "^4.0.1"
31
+ },
32
+ "exports": {
33
+ ".": "./dist/index.mjs",
34
+ "./*": "./*"
32
35
  },
33
36
  "scripts": {
34
- "build": "tsup src/index.ts --format esm,cjs --dts",
35
- "dev": "tsup src/index.ts --format esm,cjs --watch --dts",
37
+ "build": "tsdown",
38
+ "dev": "tsdown --watch",
36
39
  "lint": "eslint \"src/**/*.ts*\" --fix --max-warnings 0",
40
+ "typecheck": "tsc --noEmit",
37
41
  "clean": "rm -rf .turbo && rm -rf node_modules && rm -rf dist"
38
42
  }
39
43
  }
@@ -0,0 +1,14 @@
1
+ import { defineConfig } from "tsdown";
2
+
3
+ export default defineConfig({
4
+ format: ["esm"],
5
+ dts: true,
6
+ outDir: "dist",
7
+ entry: "src/index.ts",
8
+ target: "esnext",
9
+ sourcemap: true,
10
+ clean: true,
11
+ exports: {
12
+ all: true,
13
+ },
14
+ });
package/dist/index.d.ts DELETED
@@ -1,51 +0,0 @@
1
- import { CrdtType, CrdtDocFactory, CrdtDocLike, Maybe, DocApplyEncodedStateParams, DocBatchApplyEncodedStateParams, DocSubscribeCallbackParams } from '@pluv/types';
2
- export { CrdtDocLike, CrdtLibraryType, CrdtType, DocApplyEncodedStateParams, DocBatchApplyEncodedStateParams, DocSubscribeCallbackParams, InferCrdtJson } from '@pluv/types';
3
-
4
- declare abstract class AbstractCrdtDocFactory<TDoc extends any, TStorage extends Record<string, CrdtType<any, any>>> implements CrdtDocFactory<TDoc, TStorage> {
5
- _initialStorage: (builder: any) => TStorage;
6
- constructor(initialStorage: (builder: any) => TStorage);
7
- abstract getEmpty(): CrdtDocLike<TDoc, TStorage>;
8
- abstract getFactory(initialStorage?: (builder: any) => TStorage): AbstractCrdtDocFactory<TDoc, TStorage>;
9
- abstract getInitialized(initialStorage?: (builder: any) => TStorage): CrdtDocLike<TDoc, TStorage>;
10
- isEmpty(initialState: Maybe<string>): boolean;
11
- resolveEncodedState(updates: string | string[] | readonly string[]): string | null;
12
- }
13
-
14
- declare class NoopCrdtDoc implements CrdtDocLike<any, any> {
15
- value: any;
16
- applyEncodedState(params: DocApplyEncodedStateParams): this;
17
- batchApplyEncodedState(params: DocBatchApplyEncodedStateParams): this;
18
- canRedo(): boolean;
19
- canUndo(): boolean;
20
- destroy(): void;
21
- get(key?: undefined): {};
22
- get<TKey extends never>(key: TKey): {}[TKey];
23
- getEncodedState(): string;
24
- isEmpty(): boolean;
25
- rebuildStorage(): this;
26
- redo(): this;
27
- subscribe(listener: (params: DocSubscribeCallbackParams<any, any>) => void): () => void;
28
- toJson(): any;
29
- track(): this;
30
- transact(fn: () => void, origin?: string | undefined): this;
31
- undo(): this;
32
- }
33
-
34
- declare class NoopCrdtDocFactory extends AbstractCrdtDocFactory<any, any> {
35
- constructor(initialStorage?: () => {});
36
- getEmpty(): NoopCrdtDoc;
37
- getFactory(initialStorage?: ((builder: any) => any) | undefined): NoopCrdtDocFactory;
38
- getInitialized(initialStorage?: ((builder: any) => any) | undefined): NoopCrdtDoc;
39
- }
40
-
41
- declare const noop: {
42
- doc: (args?: any) => NoopCrdtDocFactory;
43
- };
44
-
45
- type InferDoc<TFactory extends AbstractCrdtDocFactory<any, any>> = InferDocLike<TFactory>["value"];
46
- type InferDocLike<TFactory extends AbstractCrdtDocFactory<any, any>> = ReturnType<TFactory["getInitialized"]>;
47
- type InferInitialStorageFn<TFactory extends AbstractCrdtDocFactory<any, any>> = TFactory["_initialStorage"];
48
- type InferStorage<TFactory extends AbstractCrdtDocFactory<any, any>> = ReturnType<InferInitialStorageFn<TFactory>>;
49
- type InferBuilder<TFactory extends AbstractCrdtDocFactory<any, any>> = Parameters<InferInitialStorageFn<TFactory>>[0];
50
-
51
- export { AbstractCrdtDocFactory, type InferBuilder, type InferDoc, type InferDocLike, type InferInitialStorageFn, type InferStorage, NoopCrdtDoc, NoopCrdtDocFactory, noop };
package/dist/index.js DELETED
@@ -1,134 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // src/index.ts
21
- var index_exports = {};
22
- __export(index_exports, {
23
- AbstractCrdtDocFactory: () => AbstractCrdtDocFactory,
24
- NoopCrdtDoc: () => NoopCrdtDoc,
25
- NoopCrdtDocFactory: () => NoopCrdtDocFactory,
26
- noop: () => noop
27
- });
28
- module.exports = __toCommonJS(index_exports);
29
-
30
- // src/AbstractCrdtDocFactory.ts
31
- var AbstractCrdtDocFactory = class {
32
- constructor(initialStorage) {
33
- this._initialStorage = initialStorage;
34
- }
35
- isEmpty(initialState) {
36
- const doc = this.getEmpty().applyEncodedState({ update: initialState });
37
- const isEmpty = doc.isEmpty();
38
- doc.destroy();
39
- return isEmpty;
40
- }
41
- resolveEncodedState(updates) {
42
- if (typeof updates === "string") return updates;
43
- if (Array.isArray(updates) && !updates.length) return null;
44
- const applied = this.getEmpty().batchApplyEncodedState({ updates });
45
- if (applied.isEmpty()) {
46
- applied.destroy();
47
- return null;
48
- }
49
- const encodedState = applied.getEncodedState();
50
- applied.destroy();
51
- return encodedState;
52
- }
53
- };
54
-
55
- // src/NoopCrdtDoc.ts
56
- var NoopCrdtDoc = class {
57
- constructor() {
58
- this.value = null;
59
- }
60
- applyEncodedState(params) {
61
- return this;
62
- }
63
- batchApplyEncodedState(params) {
64
- return this;
65
- }
66
- canRedo() {
67
- return false;
68
- }
69
- canUndo() {
70
- return false;
71
- }
72
- destroy() {
73
- return;
74
- }
75
- get(key) {
76
- return typeof key === "string" ? void 0 : {};
77
- }
78
- getEncodedState() {
79
- return "";
80
- }
81
- isEmpty() {
82
- return true;
83
- }
84
- rebuildStorage() {
85
- return this;
86
- }
87
- redo() {
88
- return this;
89
- }
90
- subscribe(listener) {
91
- return () => void 0;
92
- }
93
- toJson() {
94
- return {};
95
- }
96
- track() {
97
- return this;
98
- }
99
- transact(fn, origin) {
100
- fn();
101
- return this;
102
- }
103
- undo() {
104
- return this;
105
- }
106
- };
107
-
108
- // src/NoopCrdtDocFactory.ts
109
- var NoopCrdtDocFactory = class extends AbstractCrdtDocFactory {
110
- constructor(initialStorage = () => ({})) {
111
- super(initialStorage);
112
- }
113
- getEmpty() {
114
- return new NoopCrdtDoc();
115
- }
116
- getFactory(initialStorage) {
117
- return this;
118
- }
119
- getInitialized(initialStorage) {
120
- return new NoopCrdtDoc();
121
- }
122
- };
123
-
124
- // src/noop.ts
125
- var noop = {
126
- doc: (args) => new NoopCrdtDocFactory()
127
- };
128
- // Annotate the CommonJS export names for ESM import in node:
129
- 0 && (module.exports = {
130
- AbstractCrdtDocFactory,
131
- NoopCrdtDoc,
132
- NoopCrdtDocFactory,
133
- noop
134
- });