@pluv/crdt-yjs 0.43.0 → 0.44.1
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 +15 -0
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +10 -5
- package/dist/index.mjs +12 -6
- package/package.json +5 -5
- package/src/doc/CrdtYjsDoc.ts +19 -8
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
> @pluv/crdt-yjs@0.
|
|
2
|
+
> @pluv/crdt-yjs@0.44.1 build /home/runner/work/pluv/pluv/packages/crdt-yjs
|
|
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
|
-
[
|
|
12
|
-
[
|
|
13
|
-
[
|
|
14
|
-
[
|
|
11
|
+
[32mCJS[39m [1mdist/index.js [22m[32m11.96 KB[39m
|
|
12
|
+
[32mCJS[39m ⚡️ Build success in 93ms
|
|
13
|
+
[32mESM[39m [1mdist/index.mjs [22m[32m11.15 KB[39m
|
|
14
|
+
[32mESM[39m ⚡️ Build success in 97ms
|
|
15
15
|
[34mDTS[39m Build start
|
|
16
|
-
[32mDTS[39m ⚡️ Build success in
|
|
16
|
+
[32mDTS[39m ⚡️ Build success in 2084ms
|
|
17
17
|
[32mDTS[39m [1mdist/index.d.mts [22m[32m3.95 KB[39m
|
|
18
18
|
[32mDTS[39m [1mdist/index.d.ts [22m[32m3.95 KB[39m
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# @pluv/crdt-yjs
|
|
2
2
|
|
|
3
|
+
## 0.44.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- @pluv/crdt@0.44.1
|
|
8
|
+
- @pluv/types@0.44.1
|
|
9
|
+
|
|
10
|
+
## 0.44.0
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- 503c23b: Updated `batchApplyEncodedState` to use `Yjs.mergeUpdates` to more efficiently update the document under-the-hood, while also producing a smaller document.
|
|
15
|
+
- @pluv/crdt@0.44.0
|
|
16
|
+
- @pluv/types@0.44.0
|
|
17
|
+
|
|
3
18
|
## 0.43.0
|
|
4
19
|
|
|
5
20
|
### Patch Changes
|
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Array, Doc, Map, Text, XmlElement, XmlText, XmlFragment } from 'yjs';
|
|
2
|
-
import { CrdtType, AbstractCrdtDoc, DocApplyEncodedStateParams, DocSubscribeCallbackParams, InferCrdtJson, AbstractCrdtDocFactory } from '@pluv/crdt';
|
|
2
|
+
import { CrdtType, AbstractCrdtDoc, DocApplyEncodedStateParams, DocBatchApplyEncodedStateParams, DocSubscribeCallbackParams, InferCrdtJson, AbstractCrdtDocFactory } from '@pluv/crdt';
|
|
3
3
|
|
|
4
4
|
type YjsType<TValue extends unknown, TJson extends unknown = any> = CrdtType<TValue, TJson> & {
|
|
5
5
|
initialValue?: any;
|
|
@@ -14,7 +14,7 @@ declare class CrdtYjsDoc<TStorage extends Record<string, YjsType<any, any>>> ext
|
|
|
14
14
|
private _undoManager;
|
|
15
15
|
constructor(value?: TStorage);
|
|
16
16
|
applyEncodedState(params: DocApplyEncodedStateParams): this;
|
|
17
|
-
batchApplyEncodedState(
|
|
17
|
+
batchApplyEncodedState(params: DocBatchApplyEncodedStateParams): this;
|
|
18
18
|
canRedo(): boolean;
|
|
19
19
|
canUndo(): boolean;
|
|
20
20
|
destroy(): void;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Array, Doc, Map, Text, XmlElement, XmlText, XmlFragment } from 'yjs';
|
|
2
|
-
import { CrdtType, AbstractCrdtDoc, DocApplyEncodedStateParams, DocSubscribeCallbackParams, InferCrdtJson, AbstractCrdtDocFactory } from '@pluv/crdt';
|
|
2
|
+
import { CrdtType, AbstractCrdtDoc, DocApplyEncodedStateParams, DocBatchApplyEncodedStateParams, DocSubscribeCallbackParams, InferCrdtJson, AbstractCrdtDocFactory } from '@pluv/crdt';
|
|
3
3
|
|
|
4
4
|
type YjsType<TValue extends unknown, TJson extends unknown = any> = CrdtType<TValue, TJson> & {
|
|
5
5
|
initialValue?: any;
|
|
@@ -14,7 +14,7 @@ declare class CrdtYjsDoc<TStorage extends Record<string, YjsType<any, any>>> ext
|
|
|
14
14
|
private _undoManager;
|
|
15
15
|
constructor(value?: TStorage);
|
|
16
16
|
applyEncodedState(params: DocApplyEncodedStateParams): this;
|
|
17
|
-
batchApplyEncodedState(
|
|
17
|
+
batchApplyEncodedState(params: DocBatchApplyEncodedStateParams): this;
|
|
18
18
|
canRedo(): boolean;
|
|
19
19
|
canUndo(): boolean;
|
|
20
20
|
destroy(): void;
|
package/dist/index.js
CHANGED
|
@@ -196,20 +196,25 @@ var CrdtYjsDoc = class extends import_crdt.AbstractCrdtDoc {
|
|
|
196
196
|
(0, import_yjs7.applyUpdate)(this.value, uint8Update, origin);
|
|
197
197
|
return this;
|
|
198
198
|
}
|
|
199
|
-
batchApplyEncodedState(
|
|
200
|
-
|
|
199
|
+
batchApplyEncodedState(params) {
|
|
200
|
+
var _a;
|
|
201
|
+
const { origin } = params;
|
|
202
|
+
const updates = (_a = params.updates) != null ? _a : [];
|
|
203
|
+
const filtered = updates.reduce((acc, update) => {
|
|
201
204
|
if (!update) return acc;
|
|
202
205
|
if (typeof update === "string") {
|
|
203
|
-
acc.push(
|
|
206
|
+
acc.push((0, import_js_base64.toUint8Array)(update));
|
|
204
207
|
return acc;
|
|
205
208
|
}
|
|
206
|
-
if (
|
|
209
|
+
if (typeof update === "object") {
|
|
207
210
|
acc.push(update);
|
|
208
211
|
return acc;
|
|
209
212
|
}
|
|
210
213
|
return acc;
|
|
211
214
|
}, []);
|
|
212
|
-
|
|
215
|
+
if (!filtered.length) return this;
|
|
216
|
+
const merged = (0, import_yjs7.mergeUpdates)(filtered);
|
|
217
|
+
return this.applyEncodedState({ origin, update: merged });
|
|
213
218
|
}
|
|
214
219
|
canRedo() {
|
|
215
220
|
var _a;
|
package/dist/index.mjs
CHANGED
|
@@ -67,7 +67,8 @@ import {
|
|
|
67
67
|
XmlFragment as YXmlFragment,
|
|
68
68
|
XmlText as YXmlText2,
|
|
69
69
|
applyUpdate,
|
|
70
|
-
encodeStateAsUpdate
|
|
70
|
+
encodeStateAsUpdate,
|
|
71
|
+
mergeUpdates
|
|
71
72
|
} from "yjs";
|
|
72
73
|
|
|
73
74
|
// src/map/YjsMap.ts
|
|
@@ -188,20 +189,25 @@ var CrdtYjsDoc = class extends AbstractCrdtDoc {
|
|
|
188
189
|
applyUpdate(this.value, uint8Update, origin);
|
|
189
190
|
return this;
|
|
190
191
|
}
|
|
191
|
-
batchApplyEncodedState(
|
|
192
|
-
|
|
192
|
+
batchApplyEncodedState(params) {
|
|
193
|
+
var _a;
|
|
194
|
+
const { origin } = params;
|
|
195
|
+
const updates = (_a = params.updates) != null ? _a : [];
|
|
196
|
+
const filtered = updates.reduce((acc, update) => {
|
|
193
197
|
if (!update) return acc;
|
|
194
198
|
if (typeof update === "string") {
|
|
195
|
-
acc.push(
|
|
199
|
+
acc.push(toUint8Array(update));
|
|
196
200
|
return acc;
|
|
197
201
|
}
|
|
198
|
-
if (
|
|
202
|
+
if (typeof update === "object") {
|
|
199
203
|
acc.push(update);
|
|
200
204
|
return acc;
|
|
201
205
|
}
|
|
202
206
|
return acc;
|
|
203
207
|
}, []);
|
|
204
|
-
|
|
208
|
+
if (!filtered.length) return this;
|
|
209
|
+
const merged = mergeUpdates(filtered);
|
|
210
|
+
return this.applyEncodedState({ origin, update: merged });
|
|
205
211
|
}
|
|
206
212
|
canRedo() {
|
|
207
213
|
var _a;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pluv/crdt-yjs",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.44.1",
|
|
4
4
|
"description": "yjs 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.1",
|
|
22
|
+
"@pluv/types": "^0.44.1"
|
|
23
23
|
},
|
|
24
24
|
"peerDependencies": {
|
|
25
25
|
"yjs": "^13.0.0"
|
|
@@ -29,8 +29,8 @@
|
|
|
29
29
|
"tsup": "^8.4.0",
|
|
30
30
|
"typescript": "^5.8.3",
|
|
31
31
|
"yjs": "^13.6.26",
|
|
32
|
-
"@pluv/tsconfig": "^0.
|
|
33
|
-
"eslint-config-pluv": "^0.
|
|
32
|
+
"@pluv/tsconfig": "^0.44.1",
|
|
33
|
+
"eslint-config-pluv": "^0.44.1"
|
|
34
34
|
},
|
|
35
35
|
"scripts": {
|
|
36
36
|
"build": "tsup src/index.ts --format esm,cjs --dts",
|
package/src/doc/CrdtYjsDoc.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 {
|
|
@@ -13,6 +18,7 @@ import {
|
|
|
13
18
|
XmlText as YXmlText,
|
|
14
19
|
applyUpdate,
|
|
15
20
|
encodeStateAsUpdate,
|
|
21
|
+
mergeUpdates,
|
|
16
22
|
} from "yjs";
|
|
17
23
|
import { YjsArray } from "../array/YjsArray";
|
|
18
24
|
import { YjsMap } from "../map/YjsMap";
|
|
@@ -108,26 +114,31 @@ export class CrdtYjsDoc<TStorage extends Record<string, YjsType<any, any>>> exte
|
|
|
108
114
|
return this;
|
|
109
115
|
}
|
|
110
116
|
|
|
111
|
-
public batchApplyEncodedState(
|
|
112
|
-
const
|
|
117
|
+
public batchApplyEncodedState(params: DocBatchApplyEncodedStateParams): this {
|
|
118
|
+
const { origin } = params;
|
|
119
|
+
const updates = params.updates ?? [];
|
|
120
|
+
|
|
121
|
+
const filtered = updates.reduce<Uint8Array[]>((acc, update) => {
|
|
113
122
|
if (!update) return acc;
|
|
114
123
|
|
|
115
124
|
if (typeof update === "string") {
|
|
116
|
-
acc.push(
|
|
117
|
-
|
|
125
|
+
acc.push(toUint8Array(update));
|
|
118
126
|
return acc;
|
|
119
127
|
}
|
|
120
128
|
|
|
121
|
-
if (
|
|
129
|
+
if (typeof update === "object") {
|
|
122
130
|
acc.push(update);
|
|
123
|
-
|
|
124
131
|
return acc;
|
|
125
132
|
}
|
|
126
133
|
|
|
127
134
|
return acc;
|
|
128
135
|
}, []);
|
|
129
136
|
|
|
130
|
-
|
|
137
|
+
if (!filtered.length) return this;
|
|
138
|
+
|
|
139
|
+
const merged = mergeUpdates(filtered);
|
|
140
|
+
|
|
141
|
+
return this.applyEncodedState({ origin, update: merged });
|
|
131
142
|
}
|
|
132
143
|
|
|
133
144
|
public canRedo(): boolean {
|