@pluv/crdt-loro 0.43.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.
- package/.turbo/turbo-build.log +8 -8
- package/CHANGELOG.md +7 -0
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +12 -13
- package/dist/index.mjs +12 -13
- package/package.json +5 -5
- package/src/doc/CrdtLoroDoc.ts +17 -16
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
> @pluv/crdt-loro@0.
|
|
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
|
[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
|
-
[32mESM[39m [1mdist/index.mjs [22m[32m8.
|
|
12
|
-
[32mESM[39m ⚡️ Build success in
|
|
13
|
-
[32mCJS[39m [1mdist/index.js [22m[
|
|
14
|
-
[32mCJS[39m ⚡️ Build success in
|
|
11
|
+
[32mESM[39m [1mdist/index.mjs [22m[32m8.90 KB[39m
|
|
12
|
+
[32mESM[39m ⚡️ Build success in 106ms
|
|
13
|
+
[32mCJS[39m [1mdist/index.js [22m[32m9.98 KB[39m
|
|
14
|
+
[32mCJS[39m ⚡️ Build success in 109ms
|
|
15
15
|
[34mDTS[39m Build start
|
|
16
|
-
[32mDTS[39m ⚡️ Build success in
|
|
17
|
-
[32mDTS[39m [1mdist/index.d.mts [22m[32m3.
|
|
18
|
-
[32mDTS[39m [1mdist/index.d.ts [22m[32m3.
|
|
16
|
+
[32mDTS[39m ⚡️ Build success in 1888ms
|
|
17
|
+
[32mDTS[39m [1mdist/index.d.mts [22m[32m3.47 KB[39m
|
|
18
|
+
[32mDTS[39m [1mdist/index.d.ts [22m[32m3.47 KB[39m
|
package/CHANGELOG.md
CHANGED
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(
|
|
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(
|
|
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(
|
|
101
|
-
var _a;
|
|
102
|
-
const
|
|
103
|
-
|
|
104
|
-
if (
|
|
105
|
-
|
|
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
|
|
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 (!
|
|
117
|
-
if (
|
|
118
|
-
const update = (
|
|
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(
|
|
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(
|
|
82
|
-
var _a;
|
|
83
|
-
const
|
|
84
|
-
|
|
85
|
-
if (
|
|
86
|
-
|
|
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
|
|
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 (!
|
|
98
|
-
if (
|
|
99
|
-
const update = (
|
|
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(
|
|
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.
|
|
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.
|
|
22
|
-
"@pluv/types": "^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.
|
|
33
|
-
"eslint-config-pluv": "^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",
|
package/src/doc/CrdtLoroDoc.ts
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
import type {
|
|
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(
|
|
66
|
-
const
|
|
67
|
-
if (!item) return acc;
|
|
70
|
+
public batchApplyEncodedState(params: DocBatchApplyEncodedStateParams): this {
|
|
71
|
+
const updates = params.updates ?? [];
|
|
68
72
|
|
|
69
|
-
|
|
70
|
-
|
|
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
|
|
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 (!
|
|
89
|
+
if (!filtered.length) return this;
|
|
89
90
|
|
|
90
|
-
if (
|
|
91
|
-
const update =
|
|
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(
|
|
99
|
+
this.value.importBatch(filtered);
|
|
99
100
|
|
|
100
101
|
return this;
|
|
101
102
|
}
|