@pluv/crdt-loro 2.3.0 → 3.0.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 +6 -6
- package/CHANGELOG.md +18 -0
- package/dist/index.js +4 -82
- package/dist/index.mjs +5 -84
- package/package.json +5 -5
- package/src/doc/CrdtLoroDoc.ts +4 -105
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
> @pluv/crdt-loro@
|
|
2
|
+
> @pluv/crdt-loro@3.0.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
|
-
[32mCJS[39m [1mdist/index.js [22m[
|
|
12
|
-
[32mCJS[39m ⚡️ Build success in
|
|
13
|
-
[32mESM[39m [1mdist/index.mjs [22m[
|
|
14
|
-
[32mESM[39m ⚡️ Build success in
|
|
11
|
+
[32mCJS[39m [1mdist/index.js [22m[32m11.17 KB[39m
|
|
12
|
+
[32mCJS[39m ⚡️ Build success in 97ms
|
|
13
|
+
[32mESM[39m [1mdist/index.mjs [22m[32m10.11 KB[39m
|
|
14
|
+
[32mESM[39m ⚡️ Build success in 106ms
|
|
15
15
|
[34mDTS[39m Build start
|
|
16
|
-
[32mDTS[39m ⚡️ Build success in
|
|
16
|
+
[32mDTS[39m ⚡️ Build success in 4117ms
|
|
17
17
|
[32mDTS[39m [1mdist/index.d.mts [22m[32m4.60 KB[39m
|
|
18
18
|
[32mDTS[39m [1mdist/index.d.ts [22m[32m4.60 KB[39m
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# @pluv/crdt-loro
|
|
2
2
|
|
|
3
|
+
## 3.0.0
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- bc1ae91: **BREAKING** Removed deprecated ability to set top-level document types via the yjs shared-type and loro container type utilities (e.g. `yjs.array`, `loro.list`). These must now use the builder type provided in the 1st positional parameter of `yjs.doc` and `loro.doc`.
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- @pluv/crdt@3.0.0
|
|
12
|
+
- @pluv/types@3.0.0
|
|
13
|
+
|
|
14
|
+
## 2.3.1
|
|
15
|
+
|
|
16
|
+
### Patch Changes
|
|
17
|
+
|
|
18
|
+
- @pluv/crdt@2.3.1
|
|
19
|
+
- @pluv/types@2.3.1
|
|
20
|
+
|
|
3
21
|
## 2.3.0
|
|
4
22
|
|
|
5
23
|
### Patch Changes
|
package/dist/index.js
CHANGED
|
@@ -67,11 +67,6 @@ var counter = () => {
|
|
|
67
67
|
var import_js_base64 = require("js-base64");
|
|
68
68
|
var import_loro_crdt3 = require("loro-crdt");
|
|
69
69
|
|
|
70
|
-
// src/utils/oneLine.ts
|
|
71
|
-
var oneLine = (strings, ...values) => {
|
|
72
|
-
return strings.map((str) => str.replace(/\s+/g, " ")).reduce((acc, str, i) => acc + str + (i < values.length ? values[i] : ""), "").replace(/\s+/g, " ").trim();
|
|
73
|
-
};
|
|
74
|
-
|
|
75
70
|
// src/doc/builder.ts
|
|
76
71
|
var import_loro_crdt2 = require("loro-crdt");
|
|
77
72
|
var builder = (doc2) => {
|
|
@@ -126,83 +121,10 @@ var CrdtLoroDoc = class {
|
|
|
126
121
|
(set, key) => set.add(key),
|
|
127
122
|
/* @__PURE__ */ new Set()
|
|
128
123
|
);
|
|
129
|
-
this._storage = Object.entries(storage).reduce(
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
Warning: You are using \`loro.counter\` to declare top-level storage value \`${key}\`.
|
|
134
|
-
Adding top-level values this way has been deprecated, to be removed in v3.
|
|
135
|
-
Please follow the v3 migration guide to declare top-level types correctly:
|
|
136
|
-
https://pluv.io/docs/migration-guides/v3
|
|
137
|
-
`);
|
|
138
|
-
const container = this.value.getCounter(key);
|
|
139
|
-
return __spreadProps(__spreadValues({}, acc), { [key]: container });
|
|
140
|
-
}
|
|
141
|
-
if (node instanceof import_loro_crdt3.LoroList) {
|
|
142
|
-
this._warn(oneLine`
|
|
143
|
-
Warning: You are using \`loro.list\` to declare top-level storage value \`${key}\`.
|
|
144
|
-
Adding top-level values this way has been deprecated, to be removed in v3.
|
|
145
|
-
Please follow the v3 migration guide to declare top-level types correctly:
|
|
146
|
-
https://pluv.io/docs/migration-guides/v3
|
|
147
|
-
`);
|
|
148
|
-
const container = this.value.getList(key);
|
|
149
|
-
node.toArray().forEach((item, i) => {
|
|
150
|
-
if ((0, import_loro_crdt3.isContainer)(item)) container.insertContainer(i, item);
|
|
151
|
-
else container.insert(i, item);
|
|
152
|
-
});
|
|
153
|
-
return __spreadProps(__spreadValues({}, acc), { [key]: container });
|
|
154
|
-
}
|
|
155
|
-
if (node instanceof import_loro_crdt3.LoroMap) {
|
|
156
|
-
this._warn(oneLine`
|
|
157
|
-
Warning: You are using \`loro.map\` to declare top-level storage value \`${key}\`.
|
|
158
|
-
Adding top-level values this way has been deprecated, to be removed in v3.
|
|
159
|
-
Please follow the v3 migration guide to declare top-level types correctly:
|
|
160
|
-
https://pluv.io/docs/migration-guides/v3
|
|
161
|
-
`);
|
|
162
|
-
const container = this.value.getMap(key);
|
|
163
|
-
container.entries().forEach(([key2, item]) => {
|
|
164
|
-
if ((0, import_loro_crdt3.isContainer)(item)) container.setContainer(key2, item);
|
|
165
|
-
else container.set(key2, item);
|
|
166
|
-
});
|
|
167
|
-
return __spreadProps(__spreadValues({}, acc), { [key]: container });
|
|
168
|
-
}
|
|
169
|
-
if (node instanceof import_loro_crdt3.LoroMovableList) {
|
|
170
|
-
this._warn(oneLine`
|
|
171
|
-
Warning: You are using \`loro.moveableList\` to declare top-level storage value \`${key}\`.
|
|
172
|
-
Adding top-level values this way has been deprecated, to be removed in v3.
|
|
173
|
-
Please follow the v3 migration guide to declare top-level types correctly:
|
|
174
|
-
https://pluv.io/docs/migration-guides/v3
|
|
175
|
-
`);
|
|
176
|
-
const container = this.value.getMovableList(key);
|
|
177
|
-
node.toArray().forEach((item, i) => {
|
|
178
|
-
if ((0, import_loro_crdt3.isContainer)(item)) container.insertContainer(i, item);
|
|
179
|
-
else container.insert(i, item);
|
|
180
|
-
});
|
|
181
|
-
return __spreadProps(__spreadValues({}, acc), { [key]: container });
|
|
182
|
-
}
|
|
183
|
-
if (node instanceof import_loro_crdt3.LoroText) {
|
|
184
|
-
this._warn(oneLine`
|
|
185
|
-
Warning: You are using \`loro.text\` to declare top-level storage value \`${key}\`.
|
|
186
|
-
Adding top-level values this way has been deprecated, to be removed in v3.
|
|
187
|
-
Please follow the v3 migration guide to declare top-level types correctly:
|
|
188
|
-
https://pluv.io/docs/migration-guides/v3
|
|
189
|
-
`);
|
|
190
|
-
const container = this.value.getText(key);
|
|
191
|
-
container.insert(0, node.toString());
|
|
192
|
-
return __spreadProps(__spreadValues({}, acc), { [key]: container });
|
|
193
|
-
}
|
|
194
|
-
if (node instanceof import_loro_crdt3.LoroTree) {
|
|
195
|
-
this._warn(oneLine`
|
|
196
|
-
Warning: You are using \`loro.tree\` to declare top-level storage value \`${key}\`.
|
|
197
|
-
Adding top-level values this way has been deprecated, to be removed in v3.
|
|
198
|
-
Please follow the v3 migration guide to declare top-level types correctly:
|
|
199
|
-
https://pluv.io/docs/migration-guides/v3
|
|
200
|
-
`);
|
|
201
|
-
const container = this.value.getTree(key);
|
|
202
|
-
return __spreadProps(__spreadValues({}, acc), { [key]: container });
|
|
203
|
-
}
|
|
204
|
-
return acc;
|
|
205
|
-
}, {});
|
|
124
|
+
this._storage = Object.entries(storage).reduce(
|
|
125
|
+
(acc, [key, node]) => keys.has(key) ? __spreadProps(__spreadValues({}, acc), { [key]: node }) : acc,
|
|
126
|
+
{}
|
|
127
|
+
);
|
|
206
128
|
this.value.commit();
|
|
207
129
|
}
|
|
208
130
|
applyEncodedState(params) {
|
package/dist/index.mjs
CHANGED
|
@@ -54,15 +54,9 @@ import {
|
|
|
54
54
|
LoroMovableList,
|
|
55
55
|
LoroText,
|
|
56
56
|
LoroTree,
|
|
57
|
-
UndoManager
|
|
58
|
-
isContainer as isContainer2
|
|
57
|
+
UndoManager
|
|
59
58
|
} from "loro-crdt";
|
|
60
59
|
|
|
61
|
-
// src/utils/oneLine.ts
|
|
62
|
-
var oneLine = (strings, ...values) => {
|
|
63
|
-
return strings.map((str) => str.replace(/\s+/g, " ")).reduce((acc, str, i) => acc + str + (i < values.length ? values[i] : ""), "").replace(/\s+/g, " ").trim();
|
|
64
|
-
};
|
|
65
|
-
|
|
66
60
|
// src/doc/builder.ts
|
|
67
61
|
import { isContainer } from "loro-crdt";
|
|
68
62
|
var builder = (doc2) => {
|
|
@@ -117,83 +111,10 @@ var CrdtLoroDoc = class {
|
|
|
117
111
|
(set, key) => set.add(key),
|
|
118
112
|
/* @__PURE__ */ new Set()
|
|
119
113
|
);
|
|
120
|
-
this._storage = Object.entries(storage).reduce(
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
Warning: You are using \`loro.counter\` to declare top-level storage value \`${key}\`.
|
|
125
|
-
Adding top-level values this way has been deprecated, to be removed in v3.
|
|
126
|
-
Please follow the v3 migration guide to declare top-level types correctly:
|
|
127
|
-
https://pluv.io/docs/migration-guides/v3
|
|
128
|
-
`);
|
|
129
|
-
const container = this.value.getCounter(key);
|
|
130
|
-
return __spreadProps(__spreadValues({}, acc), { [key]: container });
|
|
131
|
-
}
|
|
132
|
-
if (node instanceof LoroList) {
|
|
133
|
-
this._warn(oneLine`
|
|
134
|
-
Warning: You are using \`loro.list\` to declare top-level storage value \`${key}\`.
|
|
135
|
-
Adding top-level values this way has been deprecated, to be removed in v3.
|
|
136
|
-
Please follow the v3 migration guide to declare top-level types correctly:
|
|
137
|
-
https://pluv.io/docs/migration-guides/v3
|
|
138
|
-
`);
|
|
139
|
-
const container = this.value.getList(key);
|
|
140
|
-
node.toArray().forEach((item, i) => {
|
|
141
|
-
if (isContainer2(item)) container.insertContainer(i, item);
|
|
142
|
-
else container.insert(i, item);
|
|
143
|
-
});
|
|
144
|
-
return __spreadProps(__spreadValues({}, acc), { [key]: container });
|
|
145
|
-
}
|
|
146
|
-
if (node instanceof LoroMap) {
|
|
147
|
-
this._warn(oneLine`
|
|
148
|
-
Warning: You are using \`loro.map\` to declare top-level storage value \`${key}\`.
|
|
149
|
-
Adding top-level values this way has been deprecated, to be removed in v3.
|
|
150
|
-
Please follow the v3 migration guide to declare top-level types correctly:
|
|
151
|
-
https://pluv.io/docs/migration-guides/v3
|
|
152
|
-
`);
|
|
153
|
-
const container = this.value.getMap(key);
|
|
154
|
-
container.entries().forEach(([key2, item]) => {
|
|
155
|
-
if (isContainer2(item)) container.setContainer(key2, item);
|
|
156
|
-
else container.set(key2, item);
|
|
157
|
-
});
|
|
158
|
-
return __spreadProps(__spreadValues({}, acc), { [key]: container });
|
|
159
|
-
}
|
|
160
|
-
if (node instanceof LoroMovableList) {
|
|
161
|
-
this._warn(oneLine`
|
|
162
|
-
Warning: You are using \`loro.moveableList\` to declare top-level storage value \`${key}\`.
|
|
163
|
-
Adding top-level values this way has been deprecated, to be removed in v3.
|
|
164
|
-
Please follow the v3 migration guide to declare top-level types correctly:
|
|
165
|
-
https://pluv.io/docs/migration-guides/v3
|
|
166
|
-
`);
|
|
167
|
-
const container = this.value.getMovableList(key);
|
|
168
|
-
node.toArray().forEach((item, i) => {
|
|
169
|
-
if (isContainer2(item)) container.insertContainer(i, item);
|
|
170
|
-
else container.insert(i, item);
|
|
171
|
-
});
|
|
172
|
-
return __spreadProps(__spreadValues({}, acc), { [key]: container });
|
|
173
|
-
}
|
|
174
|
-
if (node instanceof LoroText) {
|
|
175
|
-
this._warn(oneLine`
|
|
176
|
-
Warning: You are using \`loro.text\` to declare top-level storage value \`${key}\`.
|
|
177
|
-
Adding top-level values this way has been deprecated, to be removed in v3.
|
|
178
|
-
Please follow the v3 migration guide to declare top-level types correctly:
|
|
179
|
-
https://pluv.io/docs/migration-guides/v3
|
|
180
|
-
`);
|
|
181
|
-
const container = this.value.getText(key);
|
|
182
|
-
container.insert(0, node.toString());
|
|
183
|
-
return __spreadProps(__spreadValues({}, acc), { [key]: container });
|
|
184
|
-
}
|
|
185
|
-
if (node instanceof LoroTree) {
|
|
186
|
-
this._warn(oneLine`
|
|
187
|
-
Warning: You are using \`loro.tree\` to declare top-level storage value \`${key}\`.
|
|
188
|
-
Adding top-level values this way has been deprecated, to be removed in v3.
|
|
189
|
-
Please follow the v3 migration guide to declare top-level types correctly:
|
|
190
|
-
https://pluv.io/docs/migration-guides/v3
|
|
191
|
-
`);
|
|
192
|
-
const container = this.value.getTree(key);
|
|
193
|
-
return __spreadProps(__spreadValues({}, acc), { [key]: container });
|
|
194
|
-
}
|
|
195
|
-
return acc;
|
|
196
|
-
}, {});
|
|
114
|
+
this._storage = Object.entries(storage).reduce(
|
|
115
|
+
(acc, [key, node]) => keys.has(key) ? __spreadProps(__spreadValues({}, acc), { [key]: node }) : acc,
|
|
116
|
+
{}
|
|
117
|
+
);
|
|
197
118
|
this.value.commit();
|
|
198
119
|
}
|
|
199
120
|
applyEncodedState(params) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pluv/crdt-loro",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"description": "loro for @pluv/io",
|
|
5
5
|
"author": "leedavidcs",
|
|
6
6
|
"license": "MIT",
|
|
@@ -19,8 +19,8 @@
|
|
|
19
19
|
"dependencies": {
|
|
20
20
|
"@types/node": "^22.15.21",
|
|
21
21
|
"js-base64": "^3.7.7",
|
|
22
|
-
"@pluv/crdt": "^
|
|
23
|
-
"@pluv/types": "^
|
|
22
|
+
"@pluv/crdt": "^3.0.0",
|
|
23
|
+
"@pluv/types": "^3.0.0"
|
|
24
24
|
},
|
|
25
25
|
"peerDependencies": {
|
|
26
26
|
"loro-crdt": "^1.0.0"
|
|
@@ -30,8 +30,8 @@
|
|
|
30
30
|
"loro-crdt": "^1.5.6",
|
|
31
31
|
"tsup": "^8.5.0",
|
|
32
32
|
"typescript": "^5.8.3",
|
|
33
|
-
"@pluv/tsconfig": "^
|
|
34
|
-
"eslint-config-pluv": "^
|
|
33
|
+
"@pluv/tsconfig": "^3.0.0",
|
|
34
|
+
"eslint-config-pluv": "^3.0.0"
|
|
35
35
|
},
|
|
36
36
|
"scripts": {
|
|
37
37
|
"build": "tsup src/index.ts --format esm,cjs --dts",
|
package/src/doc/CrdtLoroDoc.ts
CHANGED
|
@@ -47,111 +47,10 @@ export class CrdtLoroDoc<TStorage extends Record<string, LoroType<any, any>>>
|
|
|
47
47
|
new Set<string>(),
|
|
48
48
|
);
|
|
49
49
|
|
|
50
|
-
this._storage = Object.entries(storage).reduce(
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
* @date May 8, 2025
|
|
55
|
-
*/
|
|
56
|
-
if (keys.has(key)) return { ...acc, [key]: node };
|
|
57
|
-
|
|
58
|
-
if (node instanceof LoroCounter) {
|
|
59
|
-
this._warn(oneLine`
|
|
60
|
-
Warning: You are using \`loro.counter\` to declare top-level storage value \`${key}\`.
|
|
61
|
-
Adding top-level values this way has been deprecated, to be removed in v3.
|
|
62
|
-
Please follow the v3 migration guide to declare top-level types correctly:
|
|
63
|
-
https://pluv.io/docs/migration-guides/v3
|
|
64
|
-
`);
|
|
65
|
-
|
|
66
|
-
const container = this.value.getCounter(key);
|
|
67
|
-
|
|
68
|
-
return { ...acc, [key]: container };
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
if (node instanceof LoroList) {
|
|
72
|
-
this._warn(oneLine`
|
|
73
|
-
Warning: You are using \`loro.list\` to declare top-level storage value \`${key}\`.
|
|
74
|
-
Adding top-level values this way has been deprecated, to be removed in v3.
|
|
75
|
-
Please follow the v3 migration guide to declare top-level types correctly:
|
|
76
|
-
https://pluv.io/docs/migration-guides/v3
|
|
77
|
-
`);
|
|
78
|
-
|
|
79
|
-
const container = this.value.getList(key);
|
|
80
|
-
|
|
81
|
-
node.toArray().forEach((item, i) => {
|
|
82
|
-
if (isContainer(item)) container.insertContainer(i, item);
|
|
83
|
-
else container.insert(i, item);
|
|
84
|
-
});
|
|
85
|
-
|
|
86
|
-
return { ...acc, [key]: container };
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
if (node instanceof LoroMap) {
|
|
90
|
-
this._warn(oneLine`
|
|
91
|
-
Warning: You are using \`loro.map\` to declare top-level storage value \`${key}\`.
|
|
92
|
-
Adding top-level values this way has been deprecated, to be removed in v3.
|
|
93
|
-
Please follow the v3 migration guide to declare top-level types correctly:
|
|
94
|
-
https://pluv.io/docs/migration-guides/v3
|
|
95
|
-
`);
|
|
96
|
-
|
|
97
|
-
const container = this.value.getMap(key);
|
|
98
|
-
|
|
99
|
-
container.entries().forEach(([key, item]) => {
|
|
100
|
-
if (isContainer(item)) container.setContainer(key, item);
|
|
101
|
-
else container.set(key, item);
|
|
102
|
-
});
|
|
103
|
-
|
|
104
|
-
return { ...acc, [key]: container };
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
if (node instanceof LoroMovableList) {
|
|
108
|
-
this._warn(oneLine`
|
|
109
|
-
Warning: You are using \`loro.moveableList\` to declare top-level storage value \`${key}\`.
|
|
110
|
-
Adding top-level values this way has been deprecated, to be removed in v3.
|
|
111
|
-
Please follow the v3 migration guide to declare top-level types correctly:
|
|
112
|
-
https://pluv.io/docs/migration-guides/v3
|
|
113
|
-
`);
|
|
114
|
-
|
|
115
|
-
const container = this.value.getMovableList(key);
|
|
116
|
-
|
|
117
|
-
node.toArray().forEach((item, i) => {
|
|
118
|
-
if (isContainer(item)) container.insertContainer(i, item);
|
|
119
|
-
else container.insert(i, item);
|
|
120
|
-
});
|
|
121
|
-
|
|
122
|
-
return { ...acc, [key]: container };
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
if (node instanceof LoroText) {
|
|
126
|
-
this._warn(oneLine`
|
|
127
|
-
Warning: You are using \`loro.text\` to declare top-level storage value \`${key}\`.
|
|
128
|
-
Adding top-level values this way has been deprecated, to be removed in v3.
|
|
129
|
-
Please follow the v3 migration guide to declare top-level types correctly:
|
|
130
|
-
https://pluv.io/docs/migration-guides/v3
|
|
131
|
-
`);
|
|
132
|
-
|
|
133
|
-
const container = this.value.getText(key);
|
|
134
|
-
|
|
135
|
-
container.insert(0, node.toString());
|
|
136
|
-
|
|
137
|
-
return { ...acc, [key]: container };
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
if (node instanceof LoroTree) {
|
|
141
|
-
this._warn(oneLine`
|
|
142
|
-
Warning: You are using \`loro.tree\` to declare top-level storage value \`${key}\`.
|
|
143
|
-
Adding top-level values this way has been deprecated, to be removed in v3.
|
|
144
|
-
Please follow the v3 migration guide to declare top-level types correctly:
|
|
145
|
-
https://pluv.io/docs/migration-guides/v3
|
|
146
|
-
`);
|
|
147
|
-
|
|
148
|
-
const container = this.value.getTree(key);
|
|
149
|
-
|
|
150
|
-
return { ...acc, [key]: container };
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
return acc;
|
|
154
|
-
}, {} as TStorage);
|
|
50
|
+
this._storage = Object.entries(storage).reduce(
|
|
51
|
+
(acc, [key, node]) => (keys.has(key) ? { ...acc, [key]: node } : acc),
|
|
52
|
+
{} as TStorage,
|
|
53
|
+
);
|
|
155
54
|
|
|
156
55
|
this.value.commit();
|
|
157
56
|
}
|