@pluv/crdt 5.0.1 → 5.0.2

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.
@@ -0,0 +1,55 @@
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";
2
+ //#region src/AbstractCrdtDocFactory.d.ts
3
+ declare abstract class AbstractCrdtDocFactory<TDoc extends any, TStorage extends Record<string, CrdtType$1<any, any>>> implements CrdtDocFactory<TDoc, TStorage> {
4
+ _initialStorage: (builder: any) => TStorage;
5
+ constructor(initialStorage: (builder: any) => TStorage);
6
+ abstract getEmpty(): CrdtDocLike$1<TDoc, TStorage>;
7
+ abstract getFactory(initialStorage?: (builder: any) => TStorage): AbstractCrdtDocFactory<TDoc, TStorage>;
8
+ abstract getInitialized(initialStorage?: (builder: any) => TStorage): CrdtDocLike$1<TDoc, TStorage>;
9
+ isEmpty(initialState: Maybe<string>): boolean;
10
+ resolveEncodedState(updates: string | string[] | readonly string[]): string | null;
11
+ }
12
+ //#endregion
13
+ //#region src/NoopCrdtDoc.d.ts
14
+ declare class NoopCrdtDoc implements CrdtDocLike$1<any, any> {
15
+ value: any;
16
+ applyEncodedState(params: DocApplyEncodedStateParams$1): this;
17
+ batchApplyEncodedState(params: DocBatchApplyEncodedStateParams$1): 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$1<any, any>) => void): () => void;
28
+ toJson(): any;
29
+ track(): this;
30
+ transact(fn: () => void, origin?: string | undefined): this;
31
+ undo(): this;
32
+ }
33
+ //#endregion
34
+ //#region src/NoopCrdtDocFactory.d.ts
35
+ declare class NoopCrdtDocFactory extends AbstractCrdtDocFactory<any, any> {
36
+ constructor(initialStorage?: () => {});
37
+ getEmpty(): NoopCrdtDoc;
38
+ getFactory(initialStorage?: ((builder: any) => any) | undefined): NoopCrdtDocFactory;
39
+ getInitialized(initialStorage?: ((builder: any) => any) | undefined): NoopCrdtDoc;
40
+ }
41
+ //#endregion
42
+ //#region src/noop.d.ts
43
+ declare const noop: {
44
+ doc: (args?: any) => NoopCrdtDocFactory;
45
+ };
46
+ //#endregion
47
+ //#region src/types.d.ts
48
+ type InferDoc<TFactory extends AbstractCrdtDocFactory<any, any>> = InferDocLike<TFactory>["value"];
49
+ type InferDocLike<TFactory extends AbstractCrdtDocFactory<any, any>> = ReturnType<TFactory["getInitialized"]>;
50
+ type InferInitialStorageFn<TFactory extends AbstractCrdtDocFactory<any, any>> = TFactory["_initialStorage"];
51
+ type InferStorage<TFactory extends AbstractCrdtDocFactory<any, any>> = ReturnType<InferInitialStorageFn<TFactory>>;
52
+ type InferBuilder<TFactory extends AbstractCrdtDocFactory<any, any>> = Parameters<InferInitialStorageFn<TFactory>>[0];
53
+ //#endregion
54
+ 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 };
55
+ //# 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,uBAClB,kBACA,iBAAiB,eAAe,kCACvB,eAAe,MAAM;EACvB,kBAAkB,iBAAiB;EAE9B,YAAA,iBAAiB,iBAAiB;WAI9B,YAAY,cAAY,MAAM;WAC9B,WACZ,kBAAkB,iBAAiB,WACpC,uBAAuB,MAAM;WAChB,eACZ,kBAAkB,iBAAiB,WACpC,cAAY,MAAM;EAEd,QAAQ,cAAc;EAQtB,oBAAoB;;;;cCrBlB,uBAAuB;EACzB;EAEA,kBAAkB,QAAQ;EAI1B,uBAAuB,QAAQ;EAI/B;EAIA;EAIA;EAIA,IAAI;EACJ,IAAI,oBAAoB,KAAK,UAAU;EAKvC;EAIA;EAIA;EAIA;EAIA,UAAU,WAAW,QAAQ;EAI7B;EAIA;EAIA,SAAS,gBAAgB;EAMzB;;;;cCnEE,2BAA2B;EACxB,YAAA;EAIL,YAAY;EAIZ,WAAW,mBAAmB,oCAAoC;EAIlE,eAAe,mBAAmB,oCAAoC;;;;cCdpE;EACI,MAAA,eAAG;;;;KCCR,SAAS,iBAAiB,oCAClC,aAAa;KAEL,aAAa,iBAAiB,oCAAoC,WAC1E;KAGQ,sBAAsB,iBAAiB,oCAC/C;KAEQ,aAAa,iBAAiB,oCAAoC,WAC1E,sBAAsB;KAGd,aAAa,iBAAiB,oCAAoC,WAC1E,sBAAsB"}
package/dist/index.mjs ADDED
@@ -0,0 +1,97 @@
1
+ //#region src/AbstractCrdtDocFactory.ts
2
+ var AbstractCrdtDocFactory = class {
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
+ }
25
+ };
26
+ //#endregion
27
+ //#region src/NoopCrdtDoc.ts
28
+ var NoopCrdtDoc = class {
29
+ value = null;
30
+ applyEncodedState(params) {
31
+ return this;
32
+ }
33
+ batchApplyEncodedState(params) {
34
+ return this;
35
+ }
36
+ canRedo() {
37
+ return false;
38
+ }
39
+ canUndo() {
40
+ return false;
41
+ }
42
+ destroy() {}
43
+ get(key) {
44
+ return typeof key === "string" ? void 0 : {};
45
+ }
46
+ getEncodedState() {
47
+ return "";
48
+ }
49
+ isEmpty() {
50
+ return true;
51
+ }
52
+ rebuildStorage() {
53
+ return this;
54
+ }
55
+ redo() {
56
+ return this;
57
+ }
58
+ subscribe(listener) {
59
+ return () => void 0;
60
+ }
61
+ toJson() {
62
+ return {};
63
+ }
64
+ track() {
65
+ return this;
66
+ }
67
+ transact(fn, origin) {
68
+ fn();
69
+ return this;
70
+ }
71
+ undo() {
72
+ return this;
73
+ }
74
+ };
75
+ //#endregion
76
+ //#region src/NoopCrdtDocFactory.ts
77
+ var NoopCrdtDocFactory = class extends AbstractCrdtDocFactory {
78
+ constructor(initialStorage = () => ({})) {
79
+ super(initialStorage);
80
+ }
81
+ getEmpty() {
82
+ return new NoopCrdtDoc();
83
+ }
84
+ getFactory(initialStorage) {
85
+ return this;
86
+ }
87
+ getInitialized(initialStorage) {
88
+ return new NoopCrdtDoc();
89
+ }
90
+ };
91
+ //#endregion
92
+ //#region src/noop.ts
93
+ const noop = { doc: (args) => new NoopCrdtDocFactory() };
94
+ //#endregion
95
+ export { AbstractCrdtDocFactory, NoopCrdtDoc, NoopCrdtDocFactory, noop };
96
+
97
+ //# 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 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,MAG4C;CACxC;CAEA,YAAY,gBAA4C;EACpD,KAAK,kBAAkB;CAC3B;CAUA,QAAe,cAAsC;EACjD,MAAM,MAAM,KAAK,SAAS,CAAC,CAAC,kBAAkB,EAAE,QAAQ,aAAa,CAAC;EACtE,MAAM,UAAU,IAAI,QAAQ;EAC5B,IAAI,QAAQ;EAEZ,OAAO;CACX;CAEA,oBAA2B,SAA+D;EACtF,IAAI,OAAO,YAAY,UAAU,OAAO;EACxC,IAAI,MAAM,QAAQ,OAAO,KAAK,CAAC,QAAQ,QAAQ,OAAO;EAEtD,MAAM,UAAU,KAAK,SAAS,CAAC,CAAC,uBAAuB,EAAE,QAAQ,CAAC;EAElE,IAAI,QAAQ,QAAQ,GAAG;GACnB,QAAQ,QAAQ;GAChB,OAAO;EACX;EAEA,MAAM,eAAe,QAAQ,gBAAgB;EAC7C,QAAQ,QAAQ;EAEhB,OAAO;CACX;AACJ;;;ACrCA,IAAa,cAAb,MAA0D;CACtD,QAAoB;CAEpB,kBAAyB,QAA0C;EAC/D,OAAO;CACX;CAEA,uBAA8B,QAA+C;EACzE,OAAO;CACX;CAEA,UAA0B;EACtB,OAAO;CACX;CAEA,UAA0B;EACtB,OAAO;CACX;CAEA,UAAuB,CAEvB;CAIA,IAAW,KAA8B;EACrC,OAAO,OAAO,QAAQ,WAAW,KAAA,IAAY,CAAC;CAClD;CAEA,kBAAiC;EAC7B,OAAO;CACX;CAEA,UAA0B;EACtB,OAAO;CACX;CAEA,iBAA8B;EAC1B,OAAO;CACX;CAEA,OAAoB;EAChB,OAAO;CACX;CAEA,UAAiB,UAA8E;EAC3F,aAAa,KAAA;CACjB;CAEA,SAAqB;EACjB,OAAO,CAAC;CACZ;CAEA,QAAqB;EACjB,OAAO;CACX;CAEA,SAAgB,IAAgB,QAAmC;EAC/D,GAAG;EAEH,OAAO;CACX;CAEA,OAAoB;EAChB,OAAO;CACX;AACJ;;;ACtEA,IAAa,qBAAb,cAAwC,uBAAiC;CACrE,YAAY,wBAAkC,CAAC,IAAI;EAC/C,MAAM,cAAc;CACxB;CAEA,WAA+B;EAC3B,OAAO,IAAI,YAAY;CAC3B;CAEA,WAAkB,gBAA0E;EACxF,OAAO;CACX;CAEA,eAAsB,gBAAmE;EACrF,OAAO,IAAI,YAAY;CAC3B;AACJ;;;ACjBA,MAAa,OAAO,EAChB,MAAM,SAAe,IAAI,mBAAmB,EAChD"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pluv/crdt",
3
- "version": "5.0.1",
3
+ "version": "5.0.2",
4
4
  "description": "crdt base for @pluv/io",
5
5
  "author": {
6
6
  "email": "david@pluv.io",
@@ -16,16 +16,19 @@
16
16
  },
17
17
  "type": "module",
18
18
  "types": "./dist/index.d.mts",
19
+ "files": [
20
+ "dist"
21
+ ],
19
22
  "publishConfig": {
20
23
  "access": "public"
21
24
  },
22
25
  "dependencies": {
23
- "@pluv/types": "^5.0.1"
26
+ "@pluv/types": "^5.0.2"
24
27
  },
25
28
  "devDependencies": {
26
- "@pluv/tsconfig": "^5.0.1",
29
+ "@pluv/tsconfig": "^5.0.2",
27
30
  "eslint": "^10.9.0",
28
- "eslint-config-pluv": "^5.0.1",
31
+ "eslint-config-pluv": "^5.0.2",
29
32
  "tsdown": "0.22.14",
30
33
  "typescript": "^5.9.3"
31
34
  },
package/CHANGELOG.md DELETED
@@ -1,856 +0,0 @@
1
- # @pluv/crdt
2
-
3
- ## 5.0.1
4
-
5
- ### Patch Changes
6
-
7
- - @pluv/types@5.0.1
8
-
9
- ## 5.0.0
10
-
11
- ### Patch Changes
12
-
13
- - @pluv/types@5.0.0
14
-
15
- ## 4.1.0
16
-
17
- ### Patch Changes
18
-
19
- - @pluv/types@4.1.0
20
-
21
- ## 4.0.2
22
-
23
- ### Patch Changes
24
-
25
- - e1913b3: Upgraded internal dependencies
26
- - Updated dependencies [e1913b3]
27
- - @pluv/types@4.0.2
28
-
29
- ## 4.0.1
30
-
31
- ### Patch Changes
32
-
33
- - @pluv/types@4.0.1
34
-
35
- ## 4.0.0
36
-
37
- ### Major Changes
38
-
39
- - df5c39c: Update all packages to be ESM only.
40
-
41
- ### Minor Changes
42
-
43
- - 037074e: Migrated build process from tsup to tsdown.
44
-
45
- ### Patch Changes
46
-
47
- - 2eb5def: Bumped dependencies.
48
- - Updated dependencies [2eb5def]
49
- - Updated dependencies [df5c39c]
50
- - Updated dependencies [037074e]
51
- - @pluv/types@4.0.0
52
-
53
- ## 3.2.2
54
-
55
- ### Patch Changes
56
-
57
- - Updated dependencies [8665dbe]
58
- - @pluv/types@3.2.2
59
-
60
- ## 3.2.1
61
-
62
- ### Patch Changes
63
-
64
- - @pluv/types@3.2.1
65
-
66
- ## 3.2.0
67
-
68
- ### Patch Changes
69
-
70
- - @pluv/types@3.2.0
71
-
72
- ## 3.1.7
73
-
74
- ### Patch Changes
75
-
76
- - @pluv/types@3.1.7
77
-
78
- ## 3.1.6
79
-
80
- ### Patch Changes
81
-
82
- - @pluv/types@3.1.6
83
-
84
- ## 3.1.5
85
-
86
- ### Patch Changes
87
-
88
- - @pluv/types@3.1.5
89
-
90
- ## 3.1.4
91
-
92
- ### Patch Changes
93
-
94
- - @pluv/types@3.1.4
95
-
96
- ## 3.1.3
97
-
98
- ### Patch Changes
99
-
100
- - @pluv/types@3.1.3
101
-
102
- ## 3.1.2
103
-
104
- ### Patch Changes
105
-
106
- - @pluv/types@3.1.2
107
-
108
- ## 3.1.1
109
-
110
- ### Patch Changes
111
-
112
- - @pluv/types@3.1.1
113
-
114
- ## 3.1.0
115
-
116
- ### Patch Changes
117
-
118
- - @pluv/types@3.1.0
119
-
120
- ## 3.0.0
121
-
122
- ### Patch Changes
123
-
124
- - @pluv/types@3.0.0
125
-
126
- ## 2.3.1
127
-
128
- ### Patch Changes
129
-
130
- - @pluv/types@2.3.1
131
-
132
- ## 2.3.0
133
-
134
- ### Patch Changes
135
-
136
- - @pluv/types@2.3.0
137
-
138
- ## 2.2.8
139
-
140
- ### Patch Changes
141
-
142
- - @pluv/types@2.2.8
143
-
144
- ## 2.2.7
145
-
146
- ### Patch Changes
147
-
148
- - @pluv/types@2.2.7
149
-
150
- ## 2.2.6
151
-
152
- ### Patch Changes
153
-
154
- - @pluv/types@2.2.6
155
-
156
- ## 2.2.5
157
-
158
- ### Patch Changes
159
-
160
- - @pluv/types@2.2.5
161
-
162
- ## 2.2.4
163
-
164
- ### Patch Changes
165
-
166
- - @pluv/types@2.2.4
167
-
168
- ## 2.2.3
169
-
170
- ### Patch Changes
171
-
172
- - @pluv/types@2.2.3
173
-
174
- ## 2.2.2
175
-
176
- ### Patch Changes
177
-
178
- - @pluv/types@2.2.2
179
-
180
- ## 2.2.1
181
-
182
- ### Patch Changes
183
-
184
- - @pluv/types@2.2.1
185
-
186
- ## 2.2.0
187
-
188
- ### Patch Changes
189
-
190
- - @pluv/types@2.2.0
191
-
192
- ## 2.1.0
193
-
194
- ### Patch Changes
195
-
196
- - @pluv/types@2.1.0
197
-
198
- ## 2.0.2
199
-
200
- ### Patch Changes
201
-
202
- - @pluv/types@2.0.2
203
-
204
- ## 2.0.1
205
-
206
- ### Patch Changes
207
-
208
- - @pluv/types@2.0.1
209
-
210
- ## 2.0.0
211
-
212
- ### Patch Changes
213
-
214
- - 047a1d8: Moved several internal types to `@pluv/types`.
215
- - Updated dependencies [047a1d8]
216
- - @pluv/types@2.0.0
217
-
218
- ## 1.0.2
219
-
220
- ### Patch Changes
221
-
222
- - @pluv/types@1.0.2
223
-
224
- ## 1.0.1
225
-
226
- ### Patch Changes
227
-
228
- - @pluv/types@1.0.1
229
-
230
- ## 1.0.0
231
-
232
- ### Major Changes
233
-
234
- - af94706: pluv.io is now stable and production ready!
235
-
236
- With this v1 release, pluv.io will now follow [semantic versioning](https://semver.org/) with more comprehensive release notes for future changes to the library.
237
-
238
- Checkout the [full documentation here](https://pluv.io/docs/introduction) to get started today!
239
-
240
- ### Patch Changes
241
-
242
- - Updated dependencies [af94706]
243
- - @pluv/types@1.0.0
244
-
245
- ## 0.44.2
246
-
247
- ### Patch Changes
248
-
249
- - @pluv/types@0.44.2
250
-
251
- ## 0.44.1
252
-
253
- ### Patch Changes
254
-
255
- - @pluv/types@0.44.1
256
-
257
- ## 0.44.0
258
-
259
- ### Patch Changes
260
-
261
- - @pluv/types@0.44.0
262
-
263
- ## 0.43.0
264
-
265
- ### Patch Changes
266
-
267
- - @pluv/types@0.43.0
268
-
269
- ## 0.42.0
270
-
271
- ### Patch Changes
272
-
273
- - @pluv/types@0.42.0
274
-
275
- ## 0.41.7
276
-
277
- ### Patch Changes
278
-
279
- - @pluv/types@0.41.7
280
-
281
- ## 0.41.6
282
-
283
- ### Patch Changes
284
-
285
- - @pluv/types@0.41.6
286
-
287
- ## 0.41.5
288
-
289
- ### Patch Changes
290
-
291
- - @pluv/types@0.41.5
292
-
293
- ## 0.41.4
294
-
295
- ### Patch Changes
296
-
297
- - @pluv/types@0.41.4
298
-
299
- ## 0.41.3
300
-
301
- ### Patch Changes
302
-
303
- - @pluv/types@0.41.3
304
-
305
- ## 0.41.2
306
-
307
- ### Patch Changes
308
-
309
- - @pluv/types@0.41.2
310
-
311
- ## 0.41.1
312
-
313
- ### Patch Changes
314
-
315
- - @pluv/types@0.41.1
316
-
317
- ## 0.41.0
318
-
319
- ### Patch Changes
320
-
321
- - @pluv/types@0.41.0
322
-
323
- ## 0.40.2
324
-
325
- ### Patch Changes
326
-
327
- - @pluv/types@0.40.2
328
-
329
- ## 0.40.1
330
-
331
- ### Patch Changes
332
-
333
- - @pluv/types@0.40.1
334
-
335
- ## 0.40.0
336
-
337
- ### Patch Changes
338
-
339
- - @pluv/types@0.40.0
340
-
341
- ## 0.39.1
342
-
343
- ### Patch Changes
344
-
345
- - @pluv/types@0.39.1
346
-
347
- ## 0.39.0
348
-
349
- ### Patch Changes
350
-
351
- - @pluv/types@0.39.0
352
-
353
- ## 0.38.14
354
-
355
- ### Patch Changes
356
-
357
- - @pluv/types@0.38.14
358
-
359
- ## 0.38.13
360
-
361
- ### Patch Changes
362
-
363
- - @pluv/types@0.38.13
364
-
365
- ## 0.38.12
366
-
367
- ### Patch Changes
368
-
369
- - @pluv/types@0.38.12
370
-
371
- ## 0.38.11
372
-
373
- ### Patch Changes
374
-
375
- - @pluv/types@0.38.11
376
-
377
- ## 0.38.10
378
-
379
- ### Patch Changes
380
-
381
- - @pluv/types@0.38.10
382
-
383
- ## 0.38.9
384
-
385
- ### Patch Changes
386
-
387
- - @pluv/types@0.38.9
388
-
389
- ## 0.38.8
390
-
391
- ### Patch Changes
392
-
393
- - @pluv/types@0.38.8
394
-
395
- ## 0.38.7
396
-
397
- ### Patch Changes
398
-
399
- - @pluv/types@0.38.7
400
-
401
- ## 0.38.6
402
-
403
- ### Patch Changes
404
-
405
- - @pluv/types@0.38.6
406
-
407
- ## 0.38.5
408
-
409
- ### Patch Changes
410
-
411
- - @pluv/types@0.38.5
412
-
413
- ## 0.38.4
414
-
415
- ### Patch Changes
416
-
417
- - @pluv/types@0.38.4
418
-
419
- ## 0.38.3
420
-
421
- ### Patch Changes
422
-
423
- - @pluv/types@0.38.3
424
-
425
- ## 0.38.2
426
-
427
- ### Patch Changes
428
-
429
- - @pluv/types@0.38.2
430
-
431
- ## 0.38.1
432
-
433
- ### Patch Changes
434
-
435
- - @pluv/types@0.38.1
436
-
437
- ## 0.38.0
438
-
439
- ### Patch Changes
440
-
441
- - Updated dependencies [f4ceca3]
442
- - @pluv/types@0.38.0
443
-
444
- ## 0.37.7
445
-
446
- ### Patch Changes
447
-
448
- - @pluv/types@0.37.7
449
-
450
- ## 0.37.6
451
-
452
- ### Patch Changes
453
-
454
- - @pluv/types@0.37.6
455
-
456
- ## 0.37.5
457
-
458
- ### Patch Changes
459
-
460
- - @pluv/types@0.37.5
461
-
462
- ## 0.37.4
463
-
464
- ### Patch Changes
465
-
466
- - @pluv/types@0.37.4
467
-
468
- ## 0.37.3
469
-
470
- ### Patch Changes
471
-
472
- - @pluv/types@0.37.3
473
-
474
- ## 0.37.2
475
-
476
- ### Patch Changes
477
-
478
- - @pluv/types@0.37.2
479
-
480
- ## 0.37.1
481
-
482
- ### Patch Changes
483
-
484
- - @pluv/types@0.37.1
485
-
486
- ## 0.37.0
487
-
488
- ### Patch Changes
489
-
490
- - @pluv/types@0.37.0
491
-
492
- ## 0.36.0
493
-
494
- ### Patch Changes
495
-
496
- - @pluv/types@0.36.0
497
-
498
- ## 0.35.4
499
-
500
- ### Patch Changes
501
-
502
- - @pluv/types@0.35.4
503
-
504
- ## 0.35.3
505
-
506
- ### Patch Changes
507
-
508
- - @pluv/types@0.35.3
509
-
510
- ## 0.35.2
511
-
512
- ### Patch Changes
513
-
514
- - Updated dependencies [81cb692]
515
- - @pluv/types@0.35.2
516
-
517
- ## 0.35.1
518
-
519
- ### Patch Changes
520
-
521
- - @pluv/types@0.35.1
522
-
523
- ## 0.35.0
524
-
525
- ### Patch Changes
526
-
527
- - @pluv/types@0.35.0
528
-
529
- ## 0.34.1
530
-
531
- ### Patch Changes
532
-
533
- - @pluv/types@0.34.1
534
-
535
- ## 0.34.0
536
-
537
- ### Patch Changes
538
-
539
- - @pluv/types@0.34.0
540
-
541
- ## 0.33.0
542
-
543
- ### Patch Changes
544
-
545
- - @pluv/types@0.33.0
546
-
547
- ## 0.32.9
548
-
549
- ### Patch Changes
550
-
551
- - @pluv/types@0.32.9
552
-
553
- ## 0.32.8
554
-
555
- ### Patch Changes
556
-
557
- - @pluv/types@0.32.8
558
-
559
- ## 0.32.7
560
-
561
- ### Patch Changes
562
-
563
- - @pluv/types@0.32.7
564
-
565
- ## 0.32.6
566
-
567
- ### Patch Changes
568
-
569
- - @pluv/types@0.32.6
570
-
571
- ## 0.32.5
572
-
573
- ### Patch Changes
574
-
575
- - @pluv/types@0.32.5
576
-
577
- ## 0.32.4
578
-
579
- ### Patch Changes
580
-
581
- - @pluv/types@0.32.4
582
-
583
- ## 0.32.3
584
-
585
- ### Patch Changes
586
-
587
- - @pluv/types@0.32.3
588
-
589
- ## 0.32.2
590
-
591
- ### Patch Changes
592
-
593
- - @pluv/types@0.32.2
594
-
595
- ## 0.32.1
596
-
597
- ### Patch Changes
598
-
599
- - @pluv/types@0.32.1
600
-
601
- ## 0.32.0
602
-
603
- ### Patch Changes
604
-
605
- - @pluv/types@0.32.0
606
-
607
- ## 0.31.0
608
-
609
- ### Patch Changes
610
-
611
- - @pluv/types@0.31.0
612
-
613
- ## 0.30.2
614
-
615
- ### Patch Changes
616
-
617
- - @pluv/types@0.30.2
618
-
619
- ## 0.30.1
620
-
621
- ### Patch Changes
622
-
623
- - @pluv/types@0.30.1
624
-
625
- ## 0.30.0
626
-
627
- ### Patch Changes
628
-
629
- - @pluv/types@0.30.0
630
-
631
- ## 0.29.0
632
-
633
- ### Patch Changes
634
-
635
- - @pluv/types@0.29.0
636
-
637
- ## 0.28.0
638
-
639
- ### Patch Changes
640
-
641
- - @pluv/types@0.28.0
642
-
643
- ## 0.27.0
644
-
645
- ### Patch Changes
646
-
647
- - @pluv/types@0.27.0
648
-
649
- ## 0.26.0
650
-
651
- ### Patch Changes
652
-
653
- - @pluv/types@0.26.0
654
-
655
- ## 0.25.4
656
-
657
- ### Patch Changes
658
-
659
- - @pluv/types@0.25.4
660
-
661
- ## 0.25.3
662
-
663
- ### Patch Changes
664
-
665
- - @pluv/types@0.25.3
666
-
667
- ## 0.25.2
668
-
669
- ### Patch Changes
670
-
671
- - @pluv/types@0.25.2
672
-
673
- ## 0.25.1
674
-
675
- ### Patch Changes
676
-
677
- - @pluv/types@0.25.1
678
-
679
- ## 0.25.0
680
-
681
- ### Patch Changes
682
-
683
- - @pluv/types@0.25.0
684
-
685
- ## 0.24.1
686
-
687
- ### Patch Changes
688
-
689
- - @pluv/types@0.24.1
690
-
691
- ## 0.24.0
692
-
693
- ### Patch Changes
694
-
695
- - @pluv/types@0.24.0
696
-
697
- ## 0.23.0
698
-
699
- ### Patch Changes
700
-
701
- - @pluv/types@0.23.0
702
-
703
- ## 0.22.0
704
-
705
- ### Patch Changes
706
-
707
- - @pluv/types@0.22.0
708
-
709
- ## 0.21.1
710
-
711
- ### Patch Changes
712
-
713
- - @pluv/types@0.21.1
714
-
715
- ## 0.21.0
716
-
717
- ### Patch Changes
718
-
719
- - @pluv/types@0.21.0
720
-
721
- ## 0.20.0
722
-
723
- ### Minor Changes
724
-
725
- - 9492085: **BREAKING**: `@pluv/crdt-yjs` and `@pluv/crdt-loro` have been updated so that the utilities to create shared-types/containers no-longer return a wrapper around the underlying shared-types and containers, but rather return the shared-types/containers directly.
726
-
727
- This means that for methods such as `getStorage` from `@pluv/client` and `useStorage` from `@pluv/react`, the shared-types/containers are also returned instead of the wrapper types.
728
-
729
- The motivation for these changes are so that pluv.io is supplementary to `yjs` and `loro-crdt`, instead of having these libraries be an internal implementation of pluv.io.
730
-
731
- ```ts
732
- // Before
733
-
734
- import { yjs } from "@pluv/crdt-yjs";
735
-
736
- yjs.array([]); // Returns CrdtYjsArray
737
- yjs.object([]); // Returns CrdtYjsObject
738
-
739
- const room: PluvRoom = /* ... */;
740
-
741
- room.getStorage("messages"); // Returns AbstractCrdtType
742
-
743
- const [, sharedType] = useStorage("messages"); // sharedType is an AbstractCrdtType
744
- ```
745
-
746
- ```ts
747
- // Now
748
-
749
- import { yjs } from "@pluv/crdt-yjs";
750
-
751
- yjs.array([]); // Returns yjs.Array
752
- yjs.object([]); // Returns yjs.Map
753
-
754
- const room: PluvRoom = /* ... */;
755
-
756
- room.getStorage("messages"); // Returns yjs.AbstractType
757
-
758
- const [, sharedType] = useStorage("messages"); // sharedType is a yjs.AbstractType
759
- ```
760
-
761
- For `@pluv/crdt-loro` specifically, `@pluv/client` relies on [loro events and subscriptions](https://www.loro.dev/docs/tutorial/get_started#event) to detect changes. The `AbstractLoroCrdt` types previously called `Loro.commit` after each change as an abstraction, but now this no-longer happens. To ensure that changes to loro containers are properly handled in `@pluv/react`, make sure to commit your changes whenever possible:
762
-
763
- ```ts
764
- // Before
765
-
766
- const [data, container] = useStorage("messages");
767
-
768
- // This automatically called Loro.commit under the hood and rerendered the page with updated data.
769
- container.push(loro.object({ name: "John Doe", age: 35 }));
770
- ```
771
-
772
- ```ts
773
- // Now
774
-
775
- const [data, container] = useStorage("messages");
776
-
777
- const doc = useDoc();
778
- const transact = useTransact();
779
-
780
- // Updates need to be committed back to the doc whenever the changes need to be emitted to other users
781
- // The returned data also will not update until the changes are commited
782
-
783
- // The two operations below are functionally equivalent
784
- transact(() => {
785
- container.push(loro.object({ name: "John Doe", age: 35 }));
786
- });
787
-
788
- container.push(loro.object({ name: "John Doe", age: 35 }));
789
- doc.value.commit();
790
- ```
791
-
792
- ### Patch Changes
793
-
794
- - @pluv/types@0.20.0
795
-
796
- ## 0.19.0
797
-
798
- ### Patch Changes
799
-
800
- - @pluv/types@0.19.0
801
-
802
- ## 0.18.0
803
-
804
- ### Patch Changes
805
-
806
- - Updated dependencies [99b5ca9]
807
- - @pluv/types@0.18.0
808
-
809
- ## 0.17.3
810
-
811
- ### Patch Changes
812
-
813
- - @pluv/types@0.17.3
814
-
815
- ## 0.17.2
816
-
817
- ### Patch Changes
818
-
819
- - @pluv/types@0.17.2
820
-
821
- ## 0.17.1
822
-
823
- ### Patch Changes
824
-
825
- - @pluv/types@0.17.1
826
-
827
- ## 0.17.0
828
-
829
- ### Patch Changes
830
-
831
- - Updated dependencies [507bc00]
832
- - @pluv/types@0.17.0
833
-
834
- ## 0.16.3
835
-
836
- ### Patch Changes
837
-
838
- - @pluv/types@0.16.3
839
-
840
- ## 0.16.2
841
-
842
- ### Patch Changes
843
-
844
- - @pluv/types@0.16.2
845
-
846
- ## 0.16.1
847
-
848
- ### Patch Changes
849
-
850
- - @pluv/types@0.16.1
851
-
852
- ## 0.16.0
853
-
854
- ### Patch Changes
855
-
856
- - @pluv/types@0.16.0
package/eslint.config.mjs DELETED
@@ -1,4 +0,0 @@
1
- import { config } from "eslint-config-pluv/base";
2
-
3
- /** @type {import("eslint").Linter.Config} */
4
- export default config;
@@ -1,45 +0,0 @@
1
- import type { CrdtDocFactory, CrdtDocLike, CrdtType, Maybe } from "@pluv/types";
2
-
3
- export abstract class AbstractCrdtDocFactory<
4
- TDoc extends any,
5
- TStorage extends Record<string, CrdtType<any, any>>,
6
- > implements CrdtDocFactory<TDoc, TStorage> {
7
- public _initialStorage: (builder: any) => TStorage;
8
-
9
- constructor(initialStorage: (builder: any) => TStorage) {
10
- this._initialStorage = initialStorage;
11
- }
12
-
13
- public abstract getEmpty(): CrdtDocLike<TDoc, TStorage>;
14
- public abstract getFactory(
15
- initialStorage?: (builder: any) => TStorage,
16
- ): AbstractCrdtDocFactory<TDoc, TStorage>;
17
- public abstract getInitialized(
18
- initialStorage?: (builder: any) => TStorage,
19
- ): CrdtDocLike<TDoc, TStorage>;
20
-
21
- public isEmpty(initialState: Maybe<string>): boolean {
22
- const doc = this.getEmpty().applyEncodedState({ update: initialState });
23
- const isEmpty = doc.isEmpty();
24
- doc.destroy();
25
-
26
- return isEmpty;
27
- }
28
-
29
- public resolveEncodedState(updates: string | string[] | readonly string[]): string | null {
30
- if (typeof updates === "string") return updates;
31
- if (Array.isArray(updates) && !updates.length) return null;
32
-
33
- const applied = this.getEmpty().batchApplyEncodedState({ updates });
34
-
35
- if (applied.isEmpty()) {
36
- applied.destroy();
37
- return null;
38
- }
39
-
40
- const encodedState = applied.getEncodedState();
41
- applied.destroy();
42
-
43
- return encodedState;
44
- }
45
- }
@@ -1,74 +0,0 @@
1
- import {
2
- CrdtDocLike,
3
- DocApplyEncodedStateParams,
4
- DocBatchApplyEncodedStateParams,
5
- DocSubscribeCallbackParams,
6
- } from "@pluv/types";
7
-
8
- export class NoopCrdtDoc implements CrdtDocLike<any, any> {
9
- public value: any = null;
10
-
11
- public applyEncodedState(params: DocApplyEncodedStateParams): this {
12
- return this;
13
- }
14
-
15
- public batchApplyEncodedState(params: DocBatchApplyEncodedStateParams): this {
16
- return this;
17
- }
18
-
19
- public canRedo(): boolean {
20
- return false;
21
- }
22
-
23
- public canUndo(): boolean {
24
- return false;
25
- }
26
-
27
- public destroy(): void {
28
- return;
29
- }
30
-
31
- public get(key?: undefined): {};
32
- public get<TKey extends never>(key: TKey): {}[TKey];
33
- public get(key?: string): {} | undefined {
34
- return typeof key === "string" ? undefined : {};
35
- }
36
-
37
- public getEncodedState(): string {
38
- return "";
39
- }
40
-
41
- public isEmpty(): boolean {
42
- return true;
43
- }
44
-
45
- public rebuildStorage(): this {
46
- return this;
47
- }
48
-
49
- public redo(): this {
50
- return this;
51
- }
52
-
53
- public subscribe(listener: (params: DocSubscribeCallbackParams<any, any>) => void): () => void {
54
- return () => undefined;
55
- }
56
-
57
- public toJson(): any {
58
- return {};
59
- }
60
-
61
- public track(): this {
62
- return this;
63
- }
64
-
65
- public transact(fn: () => void, origin?: string | undefined): this {
66
- fn();
67
-
68
- return this;
69
- }
70
-
71
- public undo(): this {
72
- return this;
73
- }
74
- }
@@ -1,20 +0,0 @@
1
- import { AbstractCrdtDocFactory } from "./AbstractCrdtDocFactory";
2
- import { NoopCrdtDoc } from "./NoopCrdtDoc";
3
-
4
- export class NoopCrdtDocFactory extends AbstractCrdtDocFactory<any, any> {
5
- constructor(initialStorage: () => {} = () => ({})) {
6
- super(initialStorage);
7
- }
8
-
9
- public getEmpty(): NoopCrdtDoc {
10
- return new NoopCrdtDoc();
11
- }
12
-
13
- public getFactory(initialStorage?: ((builder: any) => any) | undefined): NoopCrdtDocFactory {
14
- return this;
15
- }
16
-
17
- public getInitialized(initialStorage?: ((builder: any) => any) | undefined): NoopCrdtDoc {
18
- return new NoopCrdtDoc();
19
- }
20
- }
package/src/index.ts DELETED
@@ -1,20 +0,0 @@
1
- export type {
2
- CrdtDocLike,
3
- CrdtType,
4
- DocApplyEncodedStateParams,
5
- DocBatchApplyEncodedStateParams,
6
- DocSubscribeCallbackParams,
7
- InferCrdtJson,
8
- } from "@pluv/types";
9
- export { AbstractCrdtDocFactory } from "./AbstractCrdtDocFactory";
10
- export { noop } from "./noop";
11
- export { NoopCrdtDoc } from "./NoopCrdtDoc";
12
- export { NoopCrdtDocFactory } from "./NoopCrdtDocFactory";
13
- export type {
14
- CrdtLibraryType,
15
- InferBuilder,
16
- InferDoc,
17
- InferDocLike,
18
- InferInitialStorageFn,
19
- InferStorage,
20
- } from "./types";
package/src/noop.ts DELETED
@@ -1,5 +0,0 @@
1
- import { NoopCrdtDocFactory } from "./NoopCrdtDocFactory";
2
-
3
- export const noop = {
4
- doc: (args?: any) => new NoopCrdtDocFactory(),
5
- };
package/src/types.ts DELETED
@@ -1,21 +0,0 @@
1
- import type { AbstractCrdtDocFactory } from "./AbstractCrdtDocFactory";
2
-
3
- export type { CrdtLibraryType } from "@pluv/types";
4
-
5
- export type InferDoc<TFactory extends AbstractCrdtDocFactory<any, any>> =
6
- InferDocLike<TFactory>["value"];
7
-
8
- export type InferDocLike<TFactory extends AbstractCrdtDocFactory<any, any>> = ReturnType<
9
- TFactory["getInitialized"]
10
- >;
11
-
12
- export type InferInitialStorageFn<TFactory extends AbstractCrdtDocFactory<any, any>> =
13
- TFactory["_initialStorage"];
14
-
15
- export type InferStorage<TFactory extends AbstractCrdtDocFactory<any, any>> = ReturnType<
16
- InferInitialStorageFn<TFactory>
17
- >;
18
-
19
- export type InferBuilder<TFactory extends AbstractCrdtDocFactory<any, any>> = Parameters<
20
- InferInitialStorageFn<TFactory>
21
- >[0];
package/tsconfig.json DELETED
@@ -1,8 +0,0 @@
1
- {
2
- "extends": "@pluv/tsconfig/library.json",
3
- "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"],
4
- "exclude": ["node_modules"],
5
- "compilerOptions": {
6
- "lib": ["esnext"]
7
- }
8
- }
package/tsdown.config.ts DELETED
@@ -1,14 +0,0 @@
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
- });