@pluv/crdt 3.1.3 → 3.1.4

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@3.1.3 build /home/runner/work/pluv/pluv/packages/crdt
2
+ > @pluv/crdt@3.1.4 build /home/runner/work/pluv/pluv/packages/crdt
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 2.68 KB
12
- CJS ⚡️ Build success in 23ms
13
- ESM dist/index.mjs 1.55 KB
14
- ESM ⚡️ Build success in 25ms
11
+ ESM dist/index.mjs 1.74 KB
12
+ ESM ⚡️ Build success in 23ms
13
+ CJS dist/index.js 2.87 KB
14
+ CJS ⚡️ Build success in 24ms
15
15
  DTS Build start
16
- DTS ⚡️ Build success in 511ms
16
+ DTS ⚡️ Build success in 517ms
17
17
  DTS dist/index.d.mts 2.71 KB
18
18
  DTS dist/index.d.ts 2.71 KB
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @pluv/crdt
2
2
 
3
+ ## 3.1.4
4
+
5
+ ### Patch Changes
6
+
7
+ - @pluv/types@3.1.4
8
+
3
9
  ## 3.1.3
4
10
 
5
11
  ### Patch Changes
package/dist/index.js CHANGED
@@ -34,8 +34,15 @@ var AbstractCrdtDocFactory = class {
34
34
  }
35
35
  resolveEncodedState(updates) {
36
36
  if (typeof updates === "string") return updates;
37
- if (!updates.length) return null;
38
- return this.getEmpty().batchApplyEncodedState({ updates }).getEncodedState();
37
+ if (Array.isArray(updates) && !updates.length) return null;
38
+ const applied = this.getEmpty().batchApplyEncodedState({ updates });
39
+ if (applied.isEmpty()) {
40
+ applied.destroy();
41
+ return null;
42
+ }
43
+ const encodedState = applied.getEncodedState();
44
+ applied.destroy();
45
+ return encodedState;
39
46
  }
40
47
  };
41
48
 
package/dist/index.mjs CHANGED
@@ -5,8 +5,15 @@ var AbstractCrdtDocFactory = class {
5
5
  }
6
6
  resolveEncodedState(updates) {
7
7
  if (typeof updates === "string") return updates;
8
- if (!updates.length) return null;
9
- return this.getEmpty().batchApplyEncodedState({ updates }).getEncodedState();
8
+ if (Array.isArray(updates) && !updates.length) return null;
9
+ const applied = this.getEmpty().batchApplyEncodedState({ updates });
10
+ if (applied.isEmpty()) {
11
+ applied.destroy();
12
+ return null;
13
+ }
14
+ const encodedState = applied.getEncodedState();
15
+ applied.destroy();
16
+ return encodedState;
10
17
  }
11
18
  };
12
19
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pluv/crdt",
3
- "version": "3.1.3",
3
+ "version": "3.1.4",
4
4
  "description": "crdt base for @pluv/io",
5
5
  "author": "leedavidcs",
6
6
  "license": "MIT",
@@ -17,14 +17,14 @@
17
17
  "access": "public"
18
18
  },
19
19
  "dependencies": {
20
- "@pluv/types": "^3.1.3"
20
+ "@pluv/types": "^3.1.4"
21
21
  },
22
22
  "devDependencies": {
23
23
  "eslint": "^9.27.0",
24
24
  "tsup": "^8.5.0",
25
25
  "typescript": "^5.8.3",
26
- "@pluv/tsconfig": "^3.1.3",
27
- "eslint-config-pluv": "^3.1.3"
26
+ "@pluv/tsconfig": "^3.1.4",
27
+ "eslint-config-pluv": "^3.1.4"
28
28
  },
29
29
  "scripts": {
30
30
  "build": "tsup src/index.ts --format esm,cjs --dts",
@@ -21,8 +21,18 @@ export abstract class AbstractCrdtDocFactory<
21
21
 
22
22
  public resolveEncodedState(updates: string | string[] | readonly string[]): string | null {
23
23
  if (typeof updates === "string") return updates;
24
- if (!updates.length) return null;
24
+ if (Array.isArray(updates) && !updates.length) return null;
25
25
 
26
- return this.getEmpty().batchApplyEncodedState({ updates }).getEncodedState();
26
+ const applied = this.getEmpty().batchApplyEncodedState({ updates });
27
+
28
+ if (applied.isEmpty()) {
29
+ applied.destroy();
30
+ return null;
31
+ }
32
+
33
+ const encodedState = applied.getEncodedState();
34
+ applied.destroy();
35
+
36
+ return encodedState;
27
37
  }
28
38
  }