@pluv/crdt 3.1.6 → 3.2.0

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.6 build /home/runner/work/pluv/pluv/packages/crdt
2
+ > @pluv/crdt@3.2.0 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.87 KB
12
- CJS ⚡️ Build success in 20ms
13
- ESM dist/index.mjs 1.74 KB
14
- ESM ⚡️ Build success in 21ms
11
+ ESM dist/index.mjs 1.92 KB
12
+ ESM ⚡️ Build success in 25ms
13
+ CJS dist/index.js 3.05 KB
14
+ CJS ⚡️ Build success in 25ms
15
15
  DTS Build start
16
16
  DTS ⚡️ Build success in 500ms
17
- DTS dist/index.d.mts 2.71 KB
18
- DTS dist/index.d.ts 2.71 KB
17
+ DTS dist/index.d.mts 2.77 KB
18
+ DTS dist/index.d.ts 2.77 KB
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @pluv/crdt
2
2
 
3
+ ## 3.2.0
4
+
5
+ ### Patch Changes
6
+
7
+ - @pluv/types@3.2.0
8
+
9
+ ## 3.1.7
10
+
11
+ ### Patch Changes
12
+
13
+ - @pluv/types@3.1.7
14
+
3
15
  ## 3.1.6
4
16
 
5
17
  ### Patch Changes
package/dist/index.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { CrdtType, CrdtDocFactory, CrdtDocLike, DocApplyEncodedStateParams, DocBatchApplyEncodedStateParams, DocSubscribeCallbackParams } from '@pluv/types';
1
+ import { CrdtType, CrdtDocFactory, CrdtDocLike, Maybe, DocApplyEncodedStateParams, DocBatchApplyEncodedStateParams, DocSubscribeCallbackParams } from '@pluv/types';
2
2
  export { CrdtDocLike, CrdtLibraryType, CrdtType, DocApplyEncodedStateParams, DocBatchApplyEncodedStateParams, DocSubscribeCallbackParams, InferCrdtJson } from '@pluv/types';
3
3
 
4
4
  declare abstract class AbstractCrdtDocFactory<TDoc extends any, TStorage extends Record<string, CrdtType<any, any>>> implements CrdtDocFactory<TDoc, TStorage> {
@@ -7,6 +7,7 @@ declare abstract class AbstractCrdtDocFactory<TDoc extends any, TStorage extends
7
7
  abstract getEmpty(): CrdtDocLike<TDoc, TStorage>;
8
8
  abstract getFactory(initialStorage?: (builder: any) => TStorage): AbstractCrdtDocFactory<TDoc, TStorage>;
9
9
  abstract getInitialized(initialStorage?: (builder: any) => TStorage): CrdtDocLike<TDoc, TStorage>;
10
+ isEmpty(initialState: Maybe<string>): boolean;
10
11
  resolveEncodedState(updates: string | string[] | readonly string[]): string | null;
11
12
  }
12
13
 
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { CrdtType, CrdtDocFactory, CrdtDocLike, DocApplyEncodedStateParams, DocBatchApplyEncodedStateParams, DocSubscribeCallbackParams } from '@pluv/types';
1
+ import { CrdtType, CrdtDocFactory, CrdtDocLike, Maybe, DocApplyEncodedStateParams, DocBatchApplyEncodedStateParams, DocSubscribeCallbackParams } from '@pluv/types';
2
2
  export { CrdtDocLike, CrdtLibraryType, CrdtType, DocApplyEncodedStateParams, DocBatchApplyEncodedStateParams, DocSubscribeCallbackParams, InferCrdtJson } from '@pluv/types';
3
3
 
4
4
  declare abstract class AbstractCrdtDocFactory<TDoc extends any, TStorage extends Record<string, CrdtType<any, any>>> implements CrdtDocFactory<TDoc, TStorage> {
@@ -7,6 +7,7 @@ declare abstract class AbstractCrdtDocFactory<TDoc extends any, TStorage extends
7
7
  abstract getEmpty(): CrdtDocLike<TDoc, TStorage>;
8
8
  abstract getFactory(initialStorage?: (builder: any) => TStorage): AbstractCrdtDocFactory<TDoc, TStorage>;
9
9
  abstract getInitialized(initialStorage?: (builder: any) => TStorage): CrdtDocLike<TDoc, TStorage>;
10
+ isEmpty(initialState: Maybe<string>): boolean;
10
11
  resolveEncodedState(updates: string | string[] | readonly string[]): string | null;
11
12
  }
12
13
 
package/dist/index.js CHANGED
@@ -32,6 +32,12 @@ var AbstractCrdtDocFactory = class {
32
32
  constructor(initialStorage) {
33
33
  this._initialStorage = initialStorage;
34
34
  }
35
+ isEmpty(initialState) {
36
+ const doc = this.getEmpty().applyEncodedState({ update: initialState });
37
+ const isEmpty = doc.isEmpty();
38
+ doc.destroy();
39
+ return isEmpty;
40
+ }
35
41
  resolveEncodedState(updates) {
36
42
  if (typeof updates === "string") return updates;
37
43
  if (Array.isArray(updates) && !updates.length) return null;
package/dist/index.mjs CHANGED
@@ -3,6 +3,12 @@ var AbstractCrdtDocFactory = class {
3
3
  constructor(initialStorage) {
4
4
  this._initialStorage = initialStorage;
5
5
  }
6
+ isEmpty(initialState) {
7
+ const doc = this.getEmpty().applyEncodedState({ update: initialState });
8
+ const isEmpty = doc.isEmpty();
9
+ doc.destroy();
10
+ return isEmpty;
11
+ }
6
12
  resolveEncodedState(updates) {
7
13
  if (typeof updates === "string") return updates;
8
14
  if (Array.isArray(updates) && !updates.length) return null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pluv/crdt",
3
- "version": "3.1.6",
3
+ "version": "3.2.0",
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.6"
20
+ "@pluv/types": "^3.2.0"
21
21
  },
22
22
  "devDependencies": {
23
- "eslint": "^9.27.0",
23
+ "eslint": "^9.28.0",
24
24
  "tsup": "^8.5.0",
25
25
  "typescript": "^5.8.3",
26
- "@pluv/tsconfig": "^3.1.6",
27
- "eslint-config-pluv": "^3.1.6"
26
+ "@pluv/tsconfig": "^3.2.0",
27
+ "eslint-config-pluv": "^3.2.0"
28
28
  },
29
29
  "scripts": {
30
30
  "build": "tsup src/index.ts --format esm,cjs --dts",
@@ -1,4 +1,4 @@
1
- import type { CrdtDocFactory, CrdtDocLike, CrdtType } from "@pluv/types";
1
+ import type { CrdtDocFactory, CrdtDocLike, CrdtType, Maybe } from "@pluv/types";
2
2
 
3
3
  export abstract class AbstractCrdtDocFactory<
4
4
  TDoc extends any,
@@ -19,6 +19,14 @@ export abstract class AbstractCrdtDocFactory<
19
19
  initialStorage?: (builder: any) => TStorage,
20
20
  ): CrdtDocLike<TDoc, TStorage>;
21
21
 
22
+ public isEmpty(initialState: Maybe<string>): boolean {
23
+ const doc = this.getEmpty().applyEncodedState({ update: initialState });
24
+ const isEmpty = doc.isEmpty();
25
+ doc.destroy();
26
+
27
+ return isEmpty;
28
+ }
29
+
22
30
  public resolveEncodedState(updates: string | string[] | readonly string[]): string | null {
23
31
  if (typeof updates === "string") return updates;
24
32
  if (Array.isArray(updates) && !updates.length) return null;