@pluv/crdt-loro 2.3.1 → 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.
@@ -1,5 +1,5 @@
1
1
 
2
- > @pluv/crdt-loro@2.3.1 build /home/runner/work/pluv/pluv/packages/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
  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 15.54 KB
12
- CJS ⚡️ Build success in 104ms
13
- ESM dist/index.mjs 14.35 KB
14
- ESM ⚡️ Build success in 105ms
11
+ CJS dist/index.js 11.17 KB
12
+ CJS ⚡️ Build success in 97ms
13
+ ESM dist/index.mjs 10.11 KB
14
+ ESM ⚡️ Build success in 106ms
15
15
  DTS Build start
16
- DTS ⚡️ Build success in 4237ms
16
+ DTS ⚡️ Build success in 4117ms
17
17
  DTS dist/index.d.mts 4.60 KB
18
18
  DTS dist/index.d.ts 4.60 KB
package/CHANGELOG.md CHANGED
@@ -1,5 +1,16 @@
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
+
3
14
  ## 2.3.1
4
15
 
5
16
  ### 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((acc, [key, node]) => {
130
- if (keys.has(key)) return __spreadProps(__spreadValues({}, acc), { [key]: node });
131
- if (node instanceof import_loro_crdt3.LoroCounter) {
132
- this._warn(oneLine`
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((acc, [key, node]) => {
121
- if (keys.has(key)) return __spreadProps(__spreadValues({}, acc), { [key]: node });
122
- if (node instanceof LoroCounter2) {
123
- this._warn(oneLine`
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": "2.3.1",
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": "^2.3.1",
23
- "@pluv/types": "^2.3.1"
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": "^2.3.1",
34
- "eslint-config-pluv": "^2.3.1"
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",
@@ -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((acc, [key, node]) => {
51
- /**
52
- * @description These are all container types that we declared directly on the root
53
- * document. So we're going to store these on the storage type directly.
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
  }