@pluv/crdt-yjs 3.1.4 → 3.1.6
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 +7 -0
- package/package.json +5 -5
- package/src/doc/CrdtYjsDoc.ts +9 -7
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
> @pluv/crdt-yjs@3.1.
|
|
2
|
+
> @pluv/crdt-yjs@3.1.6 build /home/runner/work/pluv/pluv/packages/crdt-yjs
|
|
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
|
-
[32mCJS[39m [1mdist/index.js [22m[
|
|
12
|
-
[32mCJS[39m ⚡️ Build success in
|
|
13
|
-
[32mESM[39m [1mdist/index.mjs [22m[
|
|
14
|
-
[32mESM[39m ⚡️ Build success in
|
|
11
|
+
[32mCJS[39m [1mdist/index.js [22m[32m18.03 KB[39m
|
|
12
|
+
[32mCJS[39m ⚡️ Build success in 84ms
|
|
13
|
+
[32mESM[39m [1mdist/index.mjs [22m[32m17.12 KB[39m
|
|
14
|
+
[32mESM[39m ⚡️ Build success in 88ms
|
|
15
15
|
[34mDTS[39m Build start
|
|
16
|
-
[32mDTS[39m ⚡️ Build success in
|
|
17
|
-
[32mDTS[39m [1mdist/index.d.mts [22m[32m10.
|
|
18
|
-
[32mDTS[39m [1mdist/index.d.ts [22m[32m10.
|
|
16
|
+
[32mDTS[39m ⚡️ Build success in 4682ms
|
|
17
|
+
[32mDTS[39m [1mdist/index.d.mts [22m[32m10.76 KB[39m
|
|
18
|
+
[32mDTS[39m [1mdist/index.d.ts [22m[32m10.76 KB[39m
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# @pluv/crdt-yjs
|
|
2
2
|
|
|
3
|
+
## 3.1.6
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- @pluv/crdt@3.1.6
|
|
8
|
+
- @pluv/types@3.1.6
|
|
9
|
+
|
|
10
|
+
## 3.1.5
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- 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.
|
|
15
|
+
- @pluv/crdt@3.1.5
|
|
16
|
+
- @pluv/types@3.1.5
|
|
17
|
+
|
|
3
18
|
## 3.1.4
|
|
4
19
|
|
|
5
20
|
### Patch Changes
|
package/dist/index.d.mts
CHANGED
|
@@ -107,6 +107,7 @@ declare class CrdtYjsDoc<TStorage extends Record<string, YjsType<any, any>>> imp
|
|
|
107
107
|
toJson(): InferCrdtJson<TStorage>;
|
|
108
108
|
toJson<TKey extends keyof TStorage>(type: TKey): InferCrdtJson<TStorage[TKey]>;
|
|
109
109
|
undo(): this;
|
|
110
|
+
private _setPluvId;
|
|
110
111
|
private _warn;
|
|
111
112
|
}
|
|
112
113
|
|
package/dist/index.d.ts
CHANGED
|
@@ -107,6 +107,7 @@ declare class CrdtYjsDoc<TStorage extends Record<string, YjsType<any, any>>> imp
|
|
|
107
107
|
toJson(): InferCrdtJson<TStorage>;
|
|
108
108
|
toJson<TKey extends keyof TStorage>(type: TKey): InferCrdtJson<TStorage[TKey]>;
|
|
109
109
|
undo(): this;
|
|
110
|
+
private _setPluvId;
|
|
110
111
|
private _warn;
|
|
111
112
|
}
|
|
112
113
|
|
package/dist/index.js
CHANGED
|
@@ -259,6 +259,7 @@ var builder = (doc2) => {
|
|
|
259
259
|
|
|
260
260
|
// src/doc/CrdtYjsDoc.ts
|
|
261
261
|
var MERGE_INTERVAL_MS = 1e3;
|
|
262
|
+
var PLUV_ID_FIELD = "__$pluv";
|
|
262
263
|
var CrdtYjsDoc = class {
|
|
263
264
|
constructor(params = () => ({})) {
|
|
264
265
|
this.value = new import_yjs3.Doc();
|
|
@@ -269,6 +270,7 @@ var CrdtYjsDoc = class {
|
|
|
269
270
|
(acc, [key, node]) => keys.has(key) ? __spreadProps(__spreadValues({}, acc), { [key]: node }) : acc,
|
|
270
271
|
{}
|
|
271
272
|
);
|
|
273
|
+
if (!!Object.keys(storage).length) this._setPluvId();
|
|
272
274
|
}
|
|
273
275
|
applyEncodedState(params) {
|
|
274
276
|
const { origin, update } = params;
|
|
@@ -396,6 +398,11 @@ var CrdtYjsDoc = class {
|
|
|
396
398
|
(_a = this._undoManager) == null ? void 0 : _a.undo();
|
|
397
399
|
return this;
|
|
398
400
|
}
|
|
401
|
+
_setPluvId() {
|
|
402
|
+
const text2 = this.value.getText(PLUV_ID_FIELD);
|
|
403
|
+
const id = typeof crypto !== "undefined" ? crypto.randomUUID() : Math.random().toString();
|
|
404
|
+
text2.insert(0, id);
|
|
405
|
+
}
|
|
399
406
|
_warn(...data) {
|
|
400
407
|
var _a;
|
|
401
408
|
if (typeof process === "undefined") return;
|
package/dist/index.mjs
CHANGED
|
@@ -254,6 +254,7 @@ var builder = (doc2) => {
|
|
|
254
254
|
|
|
255
255
|
// src/doc/CrdtYjsDoc.ts
|
|
256
256
|
var MERGE_INTERVAL_MS = 1e3;
|
|
257
|
+
var PLUV_ID_FIELD = "__$pluv";
|
|
257
258
|
var CrdtYjsDoc = class {
|
|
258
259
|
constructor(params = () => ({})) {
|
|
259
260
|
this.value = new YDoc2();
|
|
@@ -264,6 +265,7 @@ var CrdtYjsDoc = class {
|
|
|
264
265
|
(acc, [key, node]) => keys.has(key) ? __spreadProps(__spreadValues({}, acc), { [key]: node }) : acc,
|
|
265
266
|
{}
|
|
266
267
|
);
|
|
268
|
+
if (!!Object.keys(storage).length) this._setPluvId();
|
|
267
269
|
}
|
|
268
270
|
applyEncodedState(params) {
|
|
269
271
|
const { origin, update } = params;
|
|
@@ -391,6 +393,11 @@ var CrdtYjsDoc = class {
|
|
|
391
393
|
(_a = this._undoManager) == null ? void 0 : _a.undo();
|
|
392
394
|
return this;
|
|
393
395
|
}
|
|
396
|
+
_setPluvId() {
|
|
397
|
+
const text2 = this.value.getText(PLUV_ID_FIELD);
|
|
398
|
+
const id = typeof crypto !== "undefined" ? crypto.randomUUID() : Math.random().toString();
|
|
399
|
+
text2.insert(0, id);
|
|
400
|
+
}
|
|
394
401
|
_warn(...data) {
|
|
395
402
|
var _a;
|
|
396
403
|
if (typeof process === "undefined") return;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pluv/crdt-yjs",
|
|
3
|
-
"version": "3.1.
|
|
3
|
+
"version": "3.1.6",
|
|
4
4
|
"description": "yjs for @pluv/io",
|
|
5
5
|
"author": "leedavidcs",
|
|
6
6
|
"license": "MIT",
|
|
@@ -20,8 +20,8 @@
|
|
|
20
20
|
"@types/node": "^22.15.21",
|
|
21
21
|
"js-base64": "^3.7.7",
|
|
22
22
|
"lib0": "^0.2.108",
|
|
23
|
-
"@pluv/crdt": "^3.1.
|
|
24
|
-
"@pluv/types": "^3.1.
|
|
23
|
+
"@pluv/crdt": "^3.1.6",
|
|
24
|
+
"@pluv/types": "^3.1.6"
|
|
25
25
|
},
|
|
26
26
|
"peerDependencies": {
|
|
27
27
|
"yjs": "^13.0.0"
|
|
@@ -31,8 +31,8 @@
|
|
|
31
31
|
"tsup": "^8.5.0",
|
|
32
32
|
"typescript": "^5.8.3",
|
|
33
33
|
"yjs": "^13.6.27",
|
|
34
|
-
"@pluv/tsconfig": "^3.1.
|
|
35
|
-
"eslint-config-pluv": "^3.1.
|
|
34
|
+
"@pluv/tsconfig": "^3.1.6",
|
|
35
|
+
"eslint-config-pluv": "^3.1.6"
|
|
36
36
|
},
|
|
37
37
|
"scripts": {
|
|
38
38
|
"build": "tsup src/index.ts --format esm,cjs --dts",
|
package/src/doc/CrdtYjsDoc.ts
CHANGED
|
@@ -20,18 +20,12 @@ import {
|
|
|
20
20
|
encodeStateAsUpdate,
|
|
21
21
|
mergeUpdates,
|
|
22
22
|
} from "yjs";
|
|
23
|
-
import { YjsArray } from "../array/YjsArray";
|
|
24
|
-
import { YjsMap } from "../map/YjsMap";
|
|
25
|
-
import { YjsText } from "../text/YjsText";
|
|
26
23
|
import type { YjsType } from "../types";
|
|
27
|
-
import { oneLine } from "../utils";
|
|
28
|
-
import { YjsXmlElement } from "../xmlElement/YjsXmlElement";
|
|
29
|
-
import { YjsXmlFragment } from "../xmlFragment/YjsXmlFragment";
|
|
30
|
-
import { YjsXmlText } from "../xmlText/YjsXmlText";
|
|
31
24
|
import type { YjsBuilder } from "./builder";
|
|
32
25
|
import { builder } from "./builder";
|
|
33
26
|
|
|
34
27
|
const MERGE_INTERVAL_MS = 1_000;
|
|
28
|
+
const PLUV_ID_FIELD = "__$pluv";
|
|
35
29
|
|
|
36
30
|
export type CrdtYjsDocParams<TStorage extends Record<string, YjsType<any, any>>> = (
|
|
37
31
|
builder: YjsBuilder,
|
|
@@ -53,6 +47,7 @@ export class CrdtYjsDoc<TStorage extends Record<string, YjsType<any, any>>>
|
|
|
53
47
|
(acc, [key, node]) => (keys.has(key) ? { ...acc, [key]: node } : acc),
|
|
54
48
|
{} as TStorage,
|
|
55
49
|
);
|
|
50
|
+
if (!!Object.keys(storage).length) this._setPluvId();
|
|
56
51
|
}
|
|
57
52
|
|
|
58
53
|
public applyEncodedState(params: DocApplyEncodedStateParams): this {
|
|
@@ -236,6 +231,13 @@ export class CrdtYjsDoc<TStorage extends Record<string, YjsType<any, any>>>
|
|
|
236
231
|
return this;
|
|
237
232
|
}
|
|
238
233
|
|
|
234
|
+
private _setPluvId() {
|
|
235
|
+
const text = this.value.getText(PLUV_ID_FIELD);
|
|
236
|
+
const id = typeof crypto !== "undefined" ? crypto.randomUUID() : Math.random().toString();
|
|
237
|
+
|
|
238
|
+
text.insert(0, id);
|
|
239
|
+
}
|
|
240
|
+
|
|
239
241
|
private _warn(...data: any[]) {
|
|
240
242
|
if (typeof process === "undefined") return;
|
|
241
243
|
if (process.env?.NODE_ENV === "production") return;
|