@pluv/crdt-loro 3.1.3 → 3.1.5
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.
- package/.turbo/turbo-build.log +8 -8
- package/CHANGELOG.md +15 -0
- package/dist/index.d.mts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +7 -0
- package/dist/index.mjs +15 -8
- package/package.json +5 -5
- package/src/doc/CrdtLoroDoc.ts +9 -2
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
> @pluv/crdt-loro@3.1.
|
|
2
|
+
> @pluv/crdt-loro@3.1.5 build /home/runner/work/pluv/pluv/packages/crdt-loro
|
|
3
3
|
> tsup src/index.ts --format esm,cjs --dts
|
|
4
4
|
|
|
5
5
|
[34mCLI[39m Building entry: src/index.ts
|
|
@@ -8,11 +8,11 @@
|
|
|
8
8
|
[34mCLI[39m Target: es6
|
|
9
9
|
[34mESM[39m Build start
|
|
10
10
|
[34mCJS[39m Build start
|
|
11
|
-
[
|
|
12
|
-
[
|
|
13
|
-
[
|
|
14
|
-
[
|
|
11
|
+
[32mCJS[39m [1mdist/index.js [22m[32m11.44 KB[39m
|
|
12
|
+
[32mCJS[39m ⚡️ Build success in 102ms
|
|
13
|
+
[32mESM[39m [1mdist/index.mjs [22m[32m10.39 KB[39m
|
|
14
|
+
[32mESM[39m ⚡️ Build success in 103ms
|
|
15
15
|
[34mDTS[39m Build start
|
|
16
|
-
[32mDTS[39m ⚡️ Build success in
|
|
17
|
-
[32mDTS[39m [1mdist/index.d.mts [22m[32m4.
|
|
18
|
-
[32mDTS[39m [1mdist/index.d.ts [22m[32m4.
|
|
16
|
+
[32mDTS[39m ⚡️ Build success in 3910ms
|
|
17
|
+
[32mDTS[39m [1mdist/index.d.mts [22m[32m4.68 KB[39m
|
|
18
|
+
[32mDTS[39m [1mdist/index.d.ts [22m[32m4.68 KB[39m
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# @pluv/crdt-loro
|
|
2
2
|
|
|
3
|
+
## 3.1.5
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 6d43c08: Fixed CRDT docs being considered as `empty` even when there are properties (i.e. yjs shared types and loro container types) on the document when they have not been modified.
|
|
8
|
+
- @pluv/crdt@3.1.5
|
|
9
|
+
- @pluv/types@3.1.5
|
|
10
|
+
|
|
11
|
+
## 3.1.4
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- @pluv/crdt@3.1.4
|
|
16
|
+
- @pluv/types@3.1.4
|
|
17
|
+
|
|
3
18
|
## 3.1.3
|
|
4
19
|
|
|
5
20
|
### Patch Changes
|
package/dist/index.d.mts
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -112,6 +112,7 @@ var builder = (doc2) => {
|
|
|
112
112
|
// src/doc/CrdtLoroDoc.ts
|
|
113
113
|
var MAX_UNDO_STEPS = 100;
|
|
114
114
|
var MERGE_INTERVAL_MS = 1e3;
|
|
115
|
+
var PLUV_ID_FIELD = "__$pluv";
|
|
115
116
|
var CrdtLoroDoc = class {
|
|
116
117
|
constructor(params = () => ({})) {
|
|
117
118
|
this.value = new import_loro_crdt3.LoroDoc();
|
|
@@ -125,6 +126,7 @@ var CrdtLoroDoc = class {
|
|
|
125
126
|
(acc, [key, node]) => keys.has(key) ? __spreadProps(__spreadValues({}, acc), { [key]: node }) : acc,
|
|
126
127
|
{}
|
|
127
128
|
);
|
|
129
|
+
if (!!Object.keys(storage).length) this._setPluvId();
|
|
128
130
|
this.value.commit();
|
|
129
131
|
}
|
|
130
132
|
applyEncodedState(params) {
|
|
@@ -264,6 +266,11 @@ var CrdtLoroDoc = class {
|
|
|
264
266
|
(_a = this._undoManager) == null ? void 0 : _a.undo();
|
|
265
267
|
return this;
|
|
266
268
|
}
|
|
269
|
+
_setPluvId() {
|
|
270
|
+
const text2 = this.value.getText(PLUV_ID_FIELD);
|
|
271
|
+
const id = typeof crypto !== "undefined" ? crypto.randomUUID() : Math.random().toString();
|
|
272
|
+
text2.insert(0, id);
|
|
273
|
+
}
|
|
267
274
|
_warn(...data) {
|
|
268
275
|
var _a;
|
|
269
276
|
if (typeof process === "undefined") return;
|
package/dist/index.mjs
CHANGED
|
@@ -102,6 +102,7 @@ var builder = (doc2) => {
|
|
|
102
102
|
// src/doc/CrdtLoroDoc.ts
|
|
103
103
|
var MAX_UNDO_STEPS = 100;
|
|
104
104
|
var MERGE_INTERVAL_MS = 1e3;
|
|
105
|
+
var PLUV_ID_FIELD = "__$pluv";
|
|
105
106
|
var CrdtLoroDoc = class {
|
|
106
107
|
constructor(params = () => ({})) {
|
|
107
108
|
this.value = new LoroDoc();
|
|
@@ -115,6 +116,7 @@ var CrdtLoroDoc = class {
|
|
|
115
116
|
(acc, [key, node]) => keys.has(key) ? __spreadProps(__spreadValues({}, acc), { [key]: node }) : acc,
|
|
116
117
|
{}
|
|
117
118
|
);
|
|
119
|
+
if (!!Object.keys(storage).length) this._setPluvId();
|
|
118
120
|
this.value.commit();
|
|
119
121
|
}
|
|
120
122
|
applyEncodedState(params) {
|
|
@@ -254,6 +256,11 @@ var CrdtLoroDoc = class {
|
|
|
254
256
|
(_a = this._undoManager) == null ? void 0 : _a.undo();
|
|
255
257
|
return this;
|
|
256
258
|
}
|
|
259
|
+
_setPluvId() {
|
|
260
|
+
const text2 = this.value.getText(PLUV_ID_FIELD);
|
|
261
|
+
const id = typeof crypto !== "undefined" ? crypto.randomUUID() : Math.random().toString();
|
|
262
|
+
text2.insert(0, id);
|
|
263
|
+
}
|
|
257
264
|
_warn(...data) {
|
|
258
265
|
var _a;
|
|
259
266
|
if (typeof process === "undefined") return;
|
|
@@ -286,44 +293,44 @@ var doc = (value = () => ({})) => {
|
|
|
286
293
|
};
|
|
287
294
|
|
|
288
295
|
// src/list.ts
|
|
289
|
-
import { LoroList as LoroList2, isContainer as
|
|
296
|
+
import { LoroList as LoroList2, isContainer as isContainer2 } from "loro-crdt";
|
|
290
297
|
var list = (value = []) => {
|
|
291
298
|
const container = new LoroList2();
|
|
292
299
|
value.forEach((item, i) => {
|
|
293
|
-
if (
|
|
300
|
+
if (isContainer2(item)) container.insertContainer(i, item);
|
|
294
301
|
else container.insert(i, item);
|
|
295
302
|
});
|
|
296
303
|
return container;
|
|
297
304
|
};
|
|
298
305
|
|
|
299
306
|
// src/map.ts
|
|
300
|
-
import { LoroMap as LoroMap2, isContainer as
|
|
307
|
+
import { LoroMap as LoroMap2, isContainer as isContainer3 } from "loro-crdt";
|
|
301
308
|
var map = (value = []) => {
|
|
302
309
|
const container = new LoroMap2();
|
|
303
310
|
value.forEach(([key, item]) => {
|
|
304
|
-
if (
|
|
311
|
+
if (isContainer3(item)) container.setContainer(key, item);
|
|
305
312
|
else container.set(key, item);
|
|
306
313
|
});
|
|
307
314
|
return container;
|
|
308
315
|
};
|
|
309
316
|
|
|
310
317
|
// src/movableList.ts
|
|
311
|
-
import { isContainer as
|
|
318
|
+
import { isContainer as isContainer4, LoroMovableList as LoroMovableList2 } from "loro-crdt";
|
|
312
319
|
var movableList = (value = []) => {
|
|
313
320
|
const container = new LoroMovableList2();
|
|
314
321
|
value.forEach((item, i) => {
|
|
315
|
-
if (
|
|
322
|
+
if (isContainer4(item)) container.insertContainer(i, item);
|
|
316
323
|
else container.insert(i, item);
|
|
317
324
|
});
|
|
318
325
|
return container;
|
|
319
326
|
};
|
|
320
327
|
|
|
321
328
|
// src/object.ts
|
|
322
|
-
import { LoroMap as LoroMap3, isContainer as
|
|
329
|
+
import { LoroMap as LoroMap3, isContainer as isContainer5 } from "loro-crdt";
|
|
323
330
|
var object = (value) => {
|
|
324
331
|
const container = new LoroMap3();
|
|
325
332
|
Object.entries(value).forEach(([key, item]) => {
|
|
326
|
-
if (
|
|
333
|
+
if (isContainer5(item)) container.setContainer(key, item);
|
|
327
334
|
else container.set(key, item);
|
|
328
335
|
});
|
|
329
336
|
return container;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pluv/crdt-loro",
|
|
3
|
-
"version": "3.1.
|
|
3
|
+
"version": "3.1.5",
|
|
4
4
|
"description": "loro for @pluv/io",
|
|
5
5
|
"author": "leedavidcs",
|
|
6
6
|
"license": "MIT",
|
|
@@ -19,8 +19,8 @@
|
|
|
19
19
|
"dependencies": {
|
|
20
20
|
"@types/node": "^22.15.21",
|
|
21
21
|
"js-base64": "^3.7.7",
|
|
22
|
-
"@pluv/crdt": "^3.1.
|
|
23
|
-
"@pluv/types": "^3.1.
|
|
22
|
+
"@pluv/crdt": "^3.1.5",
|
|
23
|
+
"@pluv/types": "^3.1.5"
|
|
24
24
|
},
|
|
25
25
|
"peerDependencies": {
|
|
26
26
|
"loro-crdt": "^1.0.0"
|
|
@@ -30,8 +30,8 @@
|
|
|
30
30
|
"loro-crdt": "^1.5.6",
|
|
31
31
|
"tsup": "^8.5.0",
|
|
32
32
|
"typescript": "^5.8.3",
|
|
33
|
-
"@pluv/tsconfig": "^3.1.
|
|
34
|
-
"eslint-config-pluv": "^3.1.
|
|
33
|
+
"@pluv/tsconfig": "^3.1.5",
|
|
34
|
+
"eslint-config-pluv": "^3.1.5"
|
|
35
35
|
},
|
|
36
36
|
"scripts": {
|
|
37
37
|
"build": "tsup src/index.ts --format esm,cjs --dts",
|
package/src/doc/CrdtLoroDoc.ts
CHANGED
|
@@ -17,15 +17,14 @@ import {
|
|
|
17
17
|
LoroText,
|
|
18
18
|
LoroTree,
|
|
19
19
|
UndoManager,
|
|
20
|
-
isContainer,
|
|
21
20
|
} from "loro-crdt";
|
|
22
21
|
import type { LoroType } from "../types";
|
|
23
|
-
import { oneLine } from "../utils";
|
|
24
22
|
import type { LoroBuilder } from "./builder";
|
|
25
23
|
import { builder } from "./builder";
|
|
26
24
|
|
|
27
25
|
const MAX_UNDO_STEPS = 100;
|
|
28
26
|
const MERGE_INTERVAL_MS = 1_000;
|
|
27
|
+
const PLUV_ID_FIELD = "__$pluv";
|
|
29
28
|
|
|
30
29
|
export type CrdtLoroDocParams<TStorage extends Record<string, LoroType<any, any>>> = (
|
|
31
30
|
builder: LoroBuilder,
|
|
@@ -51,6 +50,7 @@ export class CrdtLoroDoc<TStorage extends Record<string, LoroType<any, any>>>
|
|
|
51
50
|
(acc, [key, node]) => (keys.has(key) ? { ...acc, [key]: node } : acc),
|
|
52
51
|
{} as TStorage,
|
|
53
52
|
);
|
|
53
|
+
if (!!Object.keys(storage).length) this._setPluvId();
|
|
54
54
|
|
|
55
55
|
this.value.commit();
|
|
56
56
|
}
|
|
@@ -250,6 +250,13 @@ export class CrdtLoroDoc<TStorage extends Record<string, LoroType<any, any>>>
|
|
|
250
250
|
return this;
|
|
251
251
|
}
|
|
252
252
|
|
|
253
|
+
private _setPluvId() {
|
|
254
|
+
const text = this.value.getText(PLUV_ID_FIELD);
|
|
255
|
+
const id = typeof crypto !== "undefined" ? crypto.randomUUID() : Math.random().toString();
|
|
256
|
+
|
|
257
|
+
text.insert(0, id);
|
|
258
|
+
}
|
|
259
|
+
|
|
253
260
|
private _warn(...data: any[]) {
|
|
254
261
|
if (typeof process === "undefined") return;
|
|
255
262
|
if (process.env?.NODE_ENV === "production") return;
|