@pluv/crdt-yjs 3.1.4 → 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.
@@ -1,5 +1,5 @@
1
1
 
2
- > @pluv/crdt-yjs@3.1.4 build /home/runner/work/pluv/pluv/packages/crdt-yjs
2
+ > @pluv/crdt-yjs@3.1.5 build /home/runner/work/pluv/pluv/packages/crdt-yjs
3
3
  > tsup src/index.ts --format esm,cjs --dts
4
4
 
5
5
  CLI Building entry: src/index.ts
@@ -8,11 +8,11 @@
8
8
  CLI Target: es6
9
9
  ESM Build start
10
10
  CJS Build start
11
- CJS dist/index.js 17.76 KB
12
- CJS ⚡️ Build success in 90ms
13
- ESM dist/index.mjs 16.84 KB
14
- ESM ⚡️ Build success in 91ms
11
+ CJS dist/index.js 18.03 KB
12
+ CJS ⚡️ Build success in 100ms
13
+ ESM dist/index.mjs 17.12 KB
14
+ ESM ⚡️ Build success in 102ms
15
15
  DTS Build start
16
- DTS ⚡️ Build success in 5054ms
17
- DTS dist/index.d.mts 10.73 KB
18
- DTS dist/index.d.ts 10.73 KB
16
+ DTS ⚡️ Build success in 4635ms
17
+ DTS dist/index.d.mts 10.76 KB
18
+ DTS dist/index.d.ts 10.76 KB
package/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # @pluv/crdt-yjs
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
+
3
11
  ## 3.1.4
4
12
 
5
13
  ### 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.4",
3
+ "version": "3.1.5",
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.4",
24
- "@pluv/types": "^3.1.4"
23
+ "@pluv/crdt": "^3.1.5",
24
+ "@pluv/types": "^3.1.5"
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.4",
35
- "eslint-config-pluv": "^3.1.4"
34
+ "@pluv/tsconfig": "^3.1.5",
35
+ "eslint-config-pluv": "^3.1.5"
36
36
  },
37
37
  "scripts": {
38
38
  "build": "tsup src/index.ts --format esm,cjs --dts",
@@ -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;