@pluv/crdt-loro 0.42.0 → 0.44.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-loro@0.42.0 build /home/runner/work/pluv/pluv/packages/crdt-loro
2
+ > @pluv/crdt-loro@0.44.0 build /home/runner/work/pluv/pluv/packages/crdt-loro
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
- ESM dist/index.mjs 8.95 KB
12
- ESM ⚡️ Build success in 80ms
13
- CJS dist/index.js 10.06 KB
14
- CJS ⚡️ Build success in 81ms
11
+ ESM dist/index.mjs 8.90 KB
12
+ ESM ⚡️ Build success in 106ms
13
+ CJS dist/index.js 9.98 KB
14
+ CJS ⚡️ Build success in 109ms
15
15
  DTS Build start
16
- DTS ⚡️ Build success in 1892ms
17
- DTS dist/index.d.mts 3.48 KB
18
- DTS dist/index.d.ts 3.48 KB
16
+ DTS ⚡️ Build success in 1888ms
17
+ DTS dist/index.d.mts 3.47 KB
18
+ DTS dist/index.d.ts 3.47 KB
package/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # @pluv/crdt-loro
2
2
 
3
+ ## 0.44.0
4
+
5
+ ### Patch Changes
6
+
7
+ - @pluv/crdt@0.44.0
8
+ - @pluv/types@0.44.0
9
+
10
+ ## 0.43.0
11
+
12
+ ### Patch Changes
13
+
14
+ - @pluv/crdt@0.43.0
15
+ - @pluv/types@0.43.0
16
+
3
17
  ## 0.42.0
4
18
 
5
19
  ### Patch Changes
package/dist/index.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { CrdtType, AbstractCrdtDoc, DocApplyEncodedStateParams, InferCrdtJson, DocSubscribeCallbackParams, AbstractCrdtDocFactory } from '@pluv/crdt';
1
+ import { CrdtType, AbstractCrdtDoc, DocApplyEncodedStateParams, DocBatchApplyEncodedStateParams, InferCrdtJson, DocSubscribeCallbackParams, AbstractCrdtDocFactory } from '@pluv/crdt';
2
2
  import { LoroDoc, LoroList, LoroMap, LoroMovableList, LoroText, LoroTree } from 'loro-crdt';
3
3
 
4
4
  type LoroType<TValue extends unknown, TJson extends unknown = any> = TValue & CrdtType<TValue, TJson> & {
@@ -12,7 +12,7 @@ declare class CrdtLoroDoc<TStorage extends Record<string, LoroType<any, any>>> e
12
12
  private _undoManager;
13
13
  constructor(value?: TStorage);
14
14
  applyEncodedState(params: DocApplyEncodedStateParams): this;
15
- batchApplyEncodedState(updates: readonly (DocApplyEncodedStateParams | string | null | undefined)[]): this;
15
+ batchApplyEncodedState(params: DocBatchApplyEncodedStateParams): this;
16
16
  canRedo(): boolean;
17
17
  canUndo(): boolean;
18
18
  destroy(): void;
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { CrdtType, AbstractCrdtDoc, DocApplyEncodedStateParams, InferCrdtJson, DocSubscribeCallbackParams, AbstractCrdtDocFactory } from '@pluv/crdt';
1
+ import { CrdtType, AbstractCrdtDoc, DocApplyEncodedStateParams, DocBatchApplyEncodedStateParams, InferCrdtJson, DocSubscribeCallbackParams, AbstractCrdtDocFactory } from '@pluv/crdt';
2
2
  import { LoroDoc, LoroList, LoroMap, LoroMovableList, LoroText, LoroTree } from 'loro-crdt';
3
3
 
4
4
  type LoroType<TValue extends unknown, TJson extends unknown = any> = TValue & CrdtType<TValue, TJson> & {
@@ -12,7 +12,7 @@ declare class CrdtLoroDoc<TStorage extends Record<string, LoroType<any, any>>> e
12
12
  private _undoManager;
13
13
  constructor(value?: TStorage);
14
14
  applyEncodedState(params: DocApplyEncodedStateParams): this;
15
- batchApplyEncodedState(updates: readonly (DocApplyEncodedStateParams | string | null | undefined)[]): this;
15
+ batchApplyEncodedState(params: DocBatchApplyEncodedStateParams): this;
16
16
  canRedo(): boolean;
17
17
  canUndo(): boolean;
18
18
  destroy(): void;
package/dist/index.js CHANGED
@@ -97,29 +97,28 @@ var CrdtLoroDoc = class extends import_crdt.AbstractCrdtDoc {
97
97
  this.value.import(update);
98
98
  return this;
99
99
  }
100
- batchApplyEncodedState(updates) {
101
- var _a;
102
- const _updates = updates.reduce((acc, item) => {
103
- if (!item) return acc;
104
- if (typeof item === "string") {
105
- acc.push((0, import_js_base64.toUint8Array)(item));
100
+ batchApplyEncodedState(params) {
101
+ var _a, _b;
102
+ const updates = (_a = params.updates) != null ? _a : [];
103
+ const filtered = updates.reduce((acc, update) => {
104
+ if (!update) return acc;
105
+ if (typeof update === "string") {
106
+ acc.push((0, import_js_base64.toUint8Array)(update));
106
107
  return acc;
107
108
  }
108
- if (typeof item === "object") {
109
- const update = typeof item.update === "string" ? (0, import_js_base64.toUint8Array)(item.update) : item.update;
110
- if (!update) return acc;
109
+ if (typeof update === "object") {
111
110
  acc.push(update);
112
111
  return acc;
113
112
  }
114
113
  return acc;
115
114
  }, []);
116
- if (!_updates.length) return this;
117
- if (_updates.length === 1) {
118
- const update = (_a = _updates[0]) != null ? _a : null;
115
+ if (!filtered.length) return this;
116
+ if (filtered.length === 1) {
117
+ const update = (_b = filtered[0]) != null ? _b : null;
119
118
  if (!!update) this.value.import(update);
120
119
  return this;
121
120
  }
122
- this.value.importBatch(_updates);
121
+ this.value.importBatch(filtered);
123
122
  return this;
124
123
  }
125
124
  canRedo() {
package/dist/index.mjs CHANGED
@@ -78,29 +78,28 @@ var CrdtLoroDoc = class extends AbstractCrdtDoc {
78
78
  this.value.import(update);
79
79
  return this;
80
80
  }
81
- batchApplyEncodedState(updates) {
82
- var _a;
83
- const _updates = updates.reduce((acc, item) => {
84
- if (!item) return acc;
85
- if (typeof item === "string") {
86
- acc.push(toUint8Array(item));
81
+ batchApplyEncodedState(params) {
82
+ var _a, _b;
83
+ const updates = (_a = params.updates) != null ? _a : [];
84
+ const filtered = updates.reduce((acc, update) => {
85
+ if (!update) return acc;
86
+ if (typeof update === "string") {
87
+ acc.push(toUint8Array(update));
87
88
  return acc;
88
89
  }
89
- if (typeof item === "object") {
90
- const update = typeof item.update === "string" ? toUint8Array(item.update) : item.update;
91
- if (!update) return acc;
90
+ if (typeof update === "object") {
92
91
  acc.push(update);
93
92
  return acc;
94
93
  }
95
94
  return acc;
96
95
  }, []);
97
- if (!_updates.length) return this;
98
- if (_updates.length === 1) {
99
- const update = (_a = _updates[0]) != null ? _a : null;
96
+ if (!filtered.length) return this;
97
+ if (filtered.length === 1) {
98
+ const update = (_b = filtered[0]) != null ? _b : null;
100
99
  if (!!update) this.value.import(update);
101
100
  return this;
102
101
  }
103
- this.value.importBatch(_updates);
102
+ this.value.importBatch(filtered);
104
103
  return this;
105
104
  }
106
105
  canRedo() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pluv/crdt-loro",
3
- "version": "0.42.0",
3
+ "version": "0.44.0",
4
4
  "description": "loro for @pluv/io",
5
5
  "author": "leedavidcs",
6
6
  "license": "MIT",
@@ -18,8 +18,8 @@
18
18
  },
19
19
  "dependencies": {
20
20
  "js-base64": "^3.7.7",
21
- "@pluv/crdt": "^0.42.0",
22
- "@pluv/types": "^0.42.0"
21
+ "@pluv/crdt": "^0.44.0",
22
+ "@pluv/types": "^0.44.0"
23
23
  },
24
24
  "peerDependencies": {
25
25
  "loro-crdt": "^1.0.0"
@@ -29,8 +29,8 @@
29
29
  "loro-crdt": "^1.5.4",
30
30
  "tsup": "^8.4.0",
31
31
  "typescript": "^5.8.3",
32
- "@pluv/tsconfig": "^0.42.0",
33
- "eslint-config-pluv": "^0.42.0"
32
+ "@pluv/tsconfig": "^0.44.0",
33
+ "eslint-config-pluv": "^0.44.0"
34
34
  },
35
35
  "scripts": {
36
36
  "build": "tsup src/index.ts --format esm,cjs --dts",
@@ -1,4 +1,9 @@
1
- import type { DocApplyEncodedStateParams, DocSubscribeCallbackParams, InferCrdtJson } from "@pluv/crdt";
1
+ import type {
2
+ DocApplyEncodedStateParams,
3
+ DocBatchApplyEncodedStateParams,
4
+ DocSubscribeCallbackParams,
5
+ InferCrdtJson,
6
+ } from "@pluv/crdt";
2
7
  import { AbstractCrdtDoc } from "@pluv/crdt";
3
8
  import { fromUint8Array, toUint8Array } from "js-base64";
4
9
  import type { Container } from "loro-crdt";
@@ -62,40 +67,36 @@ export class CrdtLoroDoc<TStorage extends Record<string, LoroType<any, any>>> ex
62
67
  return this;
63
68
  }
64
69
 
65
- public batchApplyEncodedState(updates: readonly (DocApplyEncodedStateParams | string | null | undefined)[]): this {
66
- const _updates = updates.reduce<Uint8Array[]>((acc, item) => {
67
- if (!item) return acc;
70
+ public batchApplyEncodedState(params: DocBatchApplyEncodedStateParams): this {
71
+ const updates = params.updates ?? [];
68
72
 
69
- if (typeof item === "string") {
70
- acc.push(toUint8Array(item));
73
+ const filtered = updates.reduce<Uint8Array[]>((acc, update) => {
74
+ if (!update) return acc;
71
75
 
76
+ if (typeof update === "string") {
77
+ acc.push(toUint8Array(update));
72
78
  return acc;
73
79
  }
74
80
 
75
- if (typeof item === "object") {
76
- const update = typeof item.update === "string" ? toUint8Array(item.update) : item.update;
77
-
78
- if (!update) return acc;
79
-
81
+ if (typeof update === "object") {
80
82
  acc.push(update);
81
-
82
83
  return acc;
83
84
  }
84
85
 
85
86
  return acc;
86
87
  }, []);
87
88
 
88
- if (!_updates.length) return this;
89
+ if (!filtered.length) return this;
89
90
 
90
- if (_updates.length === 1) {
91
- const update = _updates[0] ?? null;
91
+ if (filtered.length === 1) {
92
+ const update = filtered[0] ?? null;
92
93
 
93
94
  if (!!update) this.value.import(update);
94
95
 
95
96
  return this;
96
97
  }
97
98
 
98
- this.value.importBatch(_updates);
99
+ this.value.importBatch(filtered);
99
100
 
100
101
  return this;
101
102
  }