@y/y 14.0.0-22 → 14.0.0-rc.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/README.md +15 -9
- package/dist/src/internals.d.ts +1 -1
- package/dist/src/structs/Item.d.ts +4 -4
- package/dist/src/structs/Item.d.ts.map +1 -1
- package/dist/src/utils/AttributionManager.d.ts +1 -1
- package/dist/src/utils/AttributionManager.d.ts.map +1 -1
- package/dist/src/utils/BlockSet.d.ts +34 -0
- package/dist/src/utils/BlockSet.d.ts.map +1 -0
- package/dist/src/utils/UndoManager.d.ts +1 -1
- package/dist/src/utils/UndoManager.d.ts.map +1 -1
- package/dist/src/utils/encoding.d.ts +6 -2
- package/dist/src/utils/encoding.d.ts.map +1 -1
- package/dist/src/utils/updates.d.ts +8 -7
- package/dist/src/utils/updates.d.ts.map +1 -1
- package/dist/tests/attribution.tests.d.ts.map +1 -1
- package/dist/tests/testHelper.d.ts +4 -1
- package/dist/tests/testHelper.d.ts.map +1 -1
- package/dist/tests/updates.tests.d.ts +4 -3
- package/dist/tests/updates.tests.d.ts.map +1 -1
- package/dist/tests/y-text.tests.d.ts.map +1 -1
- package/package.json +7 -6
- package/src/internals.js +1 -1
- package/src/structs/Item.js +5 -3
- package/src/utils/AttributionManager.js +1 -1
- package/src/utils/BlockSet.js +291 -0
- package/src/utils/UndoManager.js +3 -2
- package/src/utils/encoding.js +8 -9
- package/src/utils/updates.js +25 -129
- package/src/ytype.js +1 -1
- package/tests/testHelper.js +3 -0
- package/dist/src/utils/StructSet.d.ts +0 -27
- package/dist/src/utils/StructSet.d.ts.map +0 -1
- package/src/utils/StructSet.js +0 -137
package/README.md
CHANGED
|
@@ -229,19 +229,25 @@ are available. Communication over the signaling servers can be encrypted by
|
|
|
229
229
|
providing a shared secret, keeping the connection information and the shared
|
|
230
230
|
document private.
|
|
231
231
|
</dd>
|
|
232
|
-
<dt><a href="https://github.com/
|
|
232
|
+
<dt><a href="https://github.com/ueberdosis/hocuspocus">Hocuspocus</a> 🌟</dt>
|
|
233
233
|
<dd>
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
</a>
|
|
234
|
+
A standalone extensible yjs server with sqlite persistence, webhooks, auth and more.
|
|
235
|
+
</dd>
|
|
236
|
+
<dt><a href="https://velt.dev/libraries/yjs">Velt YJs</a> ⭐</dt>
|
|
237
|
+
<dd><a href="https://docs.velt.dev/realtime-collaboration/crdt/overview">Velt</a>
|
|
238
|
+
A managed Yjs backend with realtime WebSocket sync and persistent storage - no
|
|
239
|
+
server setup required. Includes offline support with automatic reconnection,
|
|
240
|
+
version history, end-to-end custom encryption. Additionally it also provides Yjs
|
|
241
|
+
webhook events, REST API to read and update Yjs documents, and a browser
|
|
242
|
+
DevTools extension.
|
|
243
|
+
</dd>
|
|
244
|
+
<dt><a href="https://github.com/liveblocks/liveblocks">@liveblocks/yjs</a> ⭐</dt>
|
|
245
|
+
<dd>
|
|
246
|
+
<a href="https://liveblocks.io/docs/api-reference/liveblocks-yjs">Liveblocks Yjs</a>
|
|
237
247
|
provides a fully hosted WebSocket infrastructure and persisted data
|
|
238
248
|
store for Yjs documents. No configuration or maintenance is required. It
|
|
239
249
|
also features Yjs webhook events, REST API to read and update Yjs
|
|
240
250
|
documents, and a browser DevTools extension.
|
|
241
|
-
</dd>
|
|
242
|
-
<dt><a href="https://github.com/ueberdosis/hocuspocus">Hocuspocus</a> ⭐</dt>
|
|
243
|
-
<dd>
|
|
244
|
-
A standalone extensible yjs server with sqlite persistence, webhooks, auth and more.
|
|
245
251
|
</dd>
|
|
246
252
|
<dt><a href="https://github.com/nperez0111/teleportal">teleportal</a></dt>
|
|
247
253
|
<dd>
|
|
@@ -367,7 +373,6 @@ A database and connection provider for Yjs based on Firestore.
|
|
|
367
373
|
<dd>
|
|
368
374
|
Yjs persistence provider for op-sqlite
|
|
369
375
|
</dd>
|
|
370
|
-
|
|
371
376
|
</dl>
|
|
372
377
|
|
|
373
378
|
### Tooling
|
|
@@ -375,6 +380,7 @@ A database and connection provider for Yjs based on Firestore.
|
|
|
375
380
|
* [y-sweet debugger](https://y-sweet.cloud/advanced/debugger)
|
|
376
381
|
* [liveblocks devtools](https://liveblocks.io/devtools)
|
|
377
382
|
* [Yjs inspector](https://inspector.yjs.dev)
|
|
383
|
+
* [velt devtools](https://velt.dev/devtools)
|
|
378
384
|
|
|
379
385
|
### Ports
|
|
380
386
|
|
package/dist/src/internals.d.ts
CHANGED
|
@@ -14,7 +14,7 @@ export * from "./utils/Transaction.js";
|
|
|
14
14
|
export * from "./utils/UndoManager.js";
|
|
15
15
|
export * from "./utils/updates.js";
|
|
16
16
|
export * from "./utils/YEvent.js";
|
|
17
|
-
export * from "./utils/
|
|
17
|
+
export * from "./utils/BlockSet.js";
|
|
18
18
|
export * from "./utils/IdMap.js";
|
|
19
19
|
export * from "./utils/AttributionManager.js";
|
|
20
20
|
export * from "./utils/delta-helpers.js";
|
|
@@ -16,11 +16,11 @@ export class Item extends AbstractStruct {
|
|
|
16
16
|
* @param {ID | null} origin
|
|
17
17
|
* @param {Item | null} right
|
|
18
18
|
* @param {ID | null} rightOrigin
|
|
19
|
-
* @param {YType|ID|null} parent Is a type if integrated, is null if it is possible to copy parent from left or right, is ID before integration to search for it
|
|
19
|
+
* @param {YType|ID|string|null} parent Is a type if integrated, is null if it is possible to copy parent from left or right, is ID before integration to search for it, is string if child of top-level-parent
|
|
20
20
|
* @param {string | null} parentSub
|
|
21
21
|
* @param {AbstractContent} content
|
|
22
22
|
*/
|
|
23
|
-
constructor(id: ID, left: Item | null, origin: ID | null, right: Item | null, rightOrigin: ID | null, parent: YType | ID | null, parentSub: string | null, content: AbstractContent);
|
|
23
|
+
constructor(id: ID, left: Item | null, origin: ID | null, right: Item | null, rightOrigin: ID | null, parent: YType | ID | string | null, parentSub: string | null, content: AbstractContent);
|
|
24
24
|
/**
|
|
25
25
|
* The item that was originally to the left of this item.
|
|
26
26
|
* @type {ID | null}
|
|
@@ -42,9 +42,9 @@ export class Item extends AbstractStruct {
|
|
|
42
42
|
*/
|
|
43
43
|
rightOrigin: ID | null;
|
|
44
44
|
/**
|
|
45
|
-
* @type {YType|ID|null}
|
|
45
|
+
* @type {YType|ID|string|null}
|
|
46
46
|
*/
|
|
47
|
-
parent: YType | ID | null;
|
|
47
|
+
parent: YType | ID | string | null;
|
|
48
48
|
/**
|
|
49
49
|
* If the parent refers to this item with some kind of key (e.g. YMap, the
|
|
50
50
|
* key is specified here. The key is then used to refer to the list in which
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Item.d.ts","sourceRoot":"","sources":["../../../src/structs/Item.js"],"names":[],"mappings":"AAsCO,oCAJI,WAAW,MACX,EAAE,GACD;IAAC,IAAI,EAAC,IAAI,CAAC;IAAC,IAAI,EAAC,MAAM,CAAA;CAAC,CAoBnC;AAWM,+BAHI,IAAI,GAAC,IAAI,QACT,OAAO,QAOjB;AAYM,uCARI,WAAW,OAAC,YACZ,IAAI,QACJ,MAAM,GACL,IAAI,CA8Cf;AAYM,yCARI,WAAW,OAAC,cACZ,cAAc,QACd,MAAM,GACL,EAAE,GAAC,IAAI,CAalB;AAsBM,sCAXI,WAAW,QACX,IAAI,aACJ,GAAG,CAAC,IAAI,CAAC,iBACT,KAAK,0BACL,OAAO,MACP,OAAO,yBAAyB,EAAE,WAAW,GAE5C,IAAI,GAAC,IAAI,CAyGpB;AAED;;GAEG;AACH;IACE;;;;;;;;;OASG;IACH,gBATW,EAAE,QACF,IAAI,GAAG,IAAI,UACX,EAAE,GAAG,IAAI,SACT,IAAI,GAAG,IAAI,eACX,EAAE,GAAG,IAAI,UACT,KAAK,GAAC,EAAE,GAAC,IAAI,
|
|
1
|
+
{"version":3,"file":"Item.d.ts","sourceRoot":"","sources":["../../../src/structs/Item.js"],"names":[],"mappings":"AAsCO,oCAJI,WAAW,MACX,EAAE,GACD;IAAC,IAAI,EAAC,IAAI,CAAC;IAAC,IAAI,EAAC,MAAM,CAAA;CAAC,CAoBnC;AA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AM,CA2CxB;IA2HD;;OAEG;IACH,wBAMC;IAED;;OAEG;IACH,wBAMC;IAED;;OAEG;IACH,iBAGC;IAED;;;;;OAKG;IACH,iBAHW,IAAI,GACH,OAAO,CAwClB;IAED;;;;OAIG;IACH,oBAFW,WAAW,QAcrB;IAED;;;OAGG;IACH,OAHW,WAAW,aACX,OAAO,QAYjB;CAwDF;AAMM,yCAHI,eAAe,GAAG,eAAe,QACjC,MAAM,mBAE0E;AAE3F;;;;GAIG;AACH,0BAFU,KAAK,CAAC,CAAS,IAAiC,EAAjC,eAAe,GAAG,eAAe,KAAE,eAAe,CAAC,CAc3E;AAED;;GAEG;AACH;IACE;;OAEG;IACH,aAFY,MAAM,CAIjB;IAED;;OAEG;IACH,cAFY,KAAK,CAAC,GAAG,CAAC,CAIrB;IAED;;;;;;;;OAQG;IACH,eAFY,OAAO,CAIlB;IAED;;OAEG;IACH,QAFY,eAAe,CAI1B;IAED;;;OAGG;IACH,gBAHW,MAAM,GACL,eAAe,CAI1B;IAED;;;OAGG;IACH,kBAHW,eAAe,GACd,OAAO,CAIlB;IAED;;;OAGG;IACH,wBAHW,WAAW,SACX,IAAI,QAId;IAED;;OAEG;IACH,qBAFW,WAAW,QAIrB;IAED;;OAEG;IACH,iBAFW,WAAW,QAIrB;IAED;;;;OAIG;IACH,gBAJW,eAAe,GAAG,eAAe,WACjC,MAAM,cACN,MAAM,QAIhB;IAED;;OAEG;IACH,UAFY,MAAM,CAIjB;CACF;4BAjzBM,iBAAiB;mBAAjB,iBAAiB;4BAAjB,iBAAiB;+BAAjB,iBAAiB;mBAAjB,iBAAiB;sBAAjB,iBAAiB;sBAAjB,iBAAiB;gCAAjB,iBAAiB;gCAAjB,iBAAiB;gCAAjB,iBAAiB;gCAAjB,iBAAiB"}
|
|
@@ -184,7 +184,7 @@ export class DiffAttributionManager extends ObservableV2<{
|
|
|
184
184
|
contentLength(item: Item): number;
|
|
185
185
|
}
|
|
186
186
|
export function createAttributionManagerFromDiff(prevDoc: Doc, nextDoc: Doc, options?: {
|
|
187
|
-
attrs?:
|
|
187
|
+
attrs?: import("./meta.js").ContentMap | null | undefined;
|
|
188
188
|
}): DiffAttributionManager;
|
|
189
189
|
/**
|
|
190
190
|
* Intended for projects that used the v13 snapshot feature. With this AttributionManager you can
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AttributionManager.d.ts","sourceRoot":"","sources":["../../../src/utils/AttributionManager.js"],"names":[],"mappings":"AAqCA;;;;;;;;;GAOE;AAcK,6DAJI,KAAK,CAAC,OAAO,YAAY,EAAE,gBAAgB,CAAC,GAAG,CAAC,CAAC,OAAC,WAClD,OAAO,GACN,WAAW,OAAC,CAgCvB;AAED;;GAEG;AACH,+BAFa,CAAC;IAGZ;;;;;;OAMG;IACH,qBANW,eAAe,SACf,MAAM,WACN,OAAO,SACP,KAAK,CAAC,OAAO,YAAY,EAAE,gBAAgB,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,kBACtD,CAAC,GAAC,CAAC,GAAC,CAAC,EAQf;IALC,yBAAsB;IACtB,cAAkB;IAClB,iBAAsB;IACtB,yDAAkB;IAClB,gBAAwG;CAE3G;AAED;;;;;;;GAOG;AACH;YAFkC,CAAC,KAAK,EAAC,KAAK,EAAC,MAAM,EAAC,GAAG,EAAC,KAAK,EAAC,OAAO,KAAG,IAAI;;;IAG5E;;;;;;;OAOG;IACH,uBAPW,KAAK,CAAC,iBAAiB,CAAC,GAAG,CAAC,CAAC,WAC7B,MAAM,UACN,MAAM,YACN,OAAO,YACP,eAAe,iBACf,CAAC,GAAC,CAAC,GAAC,CAAC,QAIf;IAED;;;;;;;;OAQG;IACH,qBAHW,IAAI,GACH,MAAM,CAIjB;CACF;AAED;;;;GAIG;AACH;YAFkC,CAAC,KAAK,EAAC,KAAK,EAAC,MAAM,EAAC,GAAG,EAAC,KAAK,EAAC,OAAO,KAAG,IAAI;cAF/D,0BAA0B;IAKvC;;;OAGG;IACH,qBAHW,KAAK,CAAC,GAA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qBAHW,EAAE,QACF,EAAE,QAcZ;IAED;;;;;;;OAOG;IACH,sBAPW,KAAK,CAAC,iBAAiB,CAAC,GAAG,CAAC,CAAC,UAC7B,MAAM,SACN,MAAM,WACN,OAAO,YACP,eAAe,gBACf,CAAC,GAAC,CAAC,GAAC,CAAC,QAkCf;IAED;;;OAGG;IACH,oBAHW,IAAI,GACH,MAAM,CAYjB;CACF;AAUM,0DALI,GAAG,WACH,GAAG,YAEX;
|
|
1
|
+
{"version":3,"file":"AttributionManager.d.ts","sourceRoot":"","sources":["../../../src/utils/AttributionManager.js"],"names":[],"mappings":"AAqCA;;;;;;;;;GAOE;AAcK,6DAJI,KAAK,CAAC,OAAO,YAAY,EAAE,gBAAgB,CAAC,GAAG,CAAC,CAAC,OAAC,WAClD,OAAO,GACN,WAAW,OAAC,CAgCvB;AAED;;GAEG;AACH,+BAFa,CAAC;IAGZ;;;;;;OAMG;IACH,qBANW,eAAe,SACf,MAAM,WACN,OAAO,SACP,KAAK,CAAC,OAAO,YAAY,EAAE,gBAAgB,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,kBACtD,CAAC,GAAC,CAAC,GAAC,CAAC,EAQf;IALC,yBAAsB;IACtB,cAAkB;IAClB,iBAAsB;IACtB,yDAAkB;IAClB,gBAAwG;CAE3G;AAED;;;;;;;GAOG;AACH;YAFkC,CAAC,KAAK,EAAC,KAAK,EAAC,MAAM,EAAC,GAAG,EAAC,KAAK,EAAC,OAAO,KAAG,IAAI;;;IAG5E;;;;;;;OAOG;IACH,uBAPW,KAAK,CAAC,iBAAiB,CAAC,GAAG,CAAC,CAAC,WAC7B,MAAM,UACN,MAAM,YACN,OAAO,YACP,eAAe,iBACf,CAAC,GAAC,CAAC,GAAC,CAAC,QAIf;IAED;;;;;;;;OAQG;IACH,qBAHW,IAAI,GACH,MAAM,CAIjB;CACF;AAED;;;;GAIG;AACH;YAFkC,CAAC,KAAK,EAAC,KAAK,EAAC,MAAM,EAAC,GAAG,EAAC,KAAK,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function writeBlockSet(encoder: UpdateEncoderV1 | UpdateEncoderV2, blocks: BlockSet): void;
|
|
3
|
+
export class BlockSet {
|
|
4
|
+
/**
|
|
5
|
+
* @type {Map<number, BlockRange>}
|
|
6
|
+
*/
|
|
7
|
+
clients: Map<number, BlockRange>;
|
|
8
|
+
toIdSet(): import("./IdSet.js").IdSet;
|
|
9
|
+
/**
|
|
10
|
+
* Remove id-ranges from update - convert them to skip if applicable.
|
|
11
|
+
*
|
|
12
|
+
* @param {IdSet} exclude
|
|
13
|
+
*/
|
|
14
|
+
exclude(exclude: IdSet): void;
|
|
15
|
+
/**
|
|
16
|
+
* @param {BlockSet} inserts
|
|
17
|
+
*/
|
|
18
|
+
insertInto(inserts: BlockSet): void;
|
|
19
|
+
}
|
|
20
|
+
declare class BlockRange {
|
|
21
|
+
/**
|
|
22
|
+
* @param {Array<Item|GC>} refs
|
|
23
|
+
*/
|
|
24
|
+
constructor(refs: Array<Item | GC>);
|
|
25
|
+
i: number;
|
|
26
|
+
/**
|
|
27
|
+
* @type {Array<Item | GC>}
|
|
28
|
+
*/
|
|
29
|
+
refs: Array<Item | GC>;
|
|
30
|
+
}
|
|
31
|
+
import { Item } from '../internals.js';
|
|
32
|
+
import { GC } from '../internals.js';
|
|
33
|
+
export {};
|
|
34
|
+
//# sourceMappingURL=BlockSet.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BlockSet.d.ts","sourceRoot":"","sources":["../../../src/utils/BlockSet.js"],"names":[],"mappings":"AA2BO,sCANI,eAAe,GAAG,eAAe,GAChC,QAAQ,CA6DnB;AAMM,uCAHI,eAAe,GAAG,eAAe,UACjC,QAAQ,QAUlB;AAeD;IAEI;;OAEG;IACH,SAFU,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,CAEN;IAG7B,sCAmBC;IAED;;;;OAIG;IACH,iBAFW,KAAK,QAgCf;IAED;;OAEG;IACH,oBAFW,QAAQ,QA8GlB;CACF;AA/LD;IACE;;OAEG;IACH,kBAFW,KAAK,CAAC,IAAI,GAAC,EAAE,CAAC,EAQxB;IALC,UAAU;IACV;;OAEG;IACH,MAFU,KAAK,CAAC,IAAI,GAAG,EAAE,CAAC,CAEV;CAEnB;qBApGM,iBAAiB;mBAAjB,iBAAiB"}
|
|
@@ -150,7 +150,7 @@ export class UndoManager extends ObservableV2<{
|
|
|
150
150
|
*/
|
|
151
151
|
canRedo(): boolean;
|
|
152
152
|
}
|
|
153
|
-
export function undoContentIds(ydoc: Doc, contentIds: import("./meta.js").ContentIds): void;
|
|
153
|
+
export function undoContentIds(ydoc: Doc, contentIds: import("./meta.js").ContentIds, opts?: UndoManagerOptions): void;
|
|
154
154
|
export type UndoManagerOptions = {
|
|
155
155
|
captureTimeout?: number | undefined;
|
|
156
156
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UndoManager.d.ts","sourceRoot":"","sources":["../../../src/utils/UndoManager.js"],"names":[],"mappings":"AAmBA;IACE;;;OAGG;IACH,wBAHW,KAAK,aACL,KAAK,EASf;IANC,eAAyB;IACzB,eAAwB;IACxB;;OAEG;IACH,oBAAqB;CAExB;AAgGD;;;;;;;;;;;GAWG;AAEH;;;;;;GAMG;AAEH;;;;;;;;GAQG;AACH;wBAF8C,CAAS,IAAc,EAAd,cAAc,EAAE,IAAW,EAAX,WAAW,KAAE,IAAI;yBAAuB,CAAS,IAAc,EAAd,cAAc,EAAE,IAAW,EAAX,WAAW,KAAE,IAAI;qBAAmB,CAAS,IAAwD,EAAxD;QAAE,gBAAgB,EAAE,OAAO,CAAC;QAAC,gBAAgB,EAAE,OAAO,CAAA;KAAE,KAAE,IAAI;0BAAwB,CAAS,IAAc,EAAd,cAAc,EAAE,IAAW,EAAX,WAAW,KAAE,IAAI;;IAGnT;;;OAGG;IACH,uBAHW,GAAG,GAAC,KAAK,GAAC,KAAK,CAAC,KAAK,CAAC,sGACtB,kBAAkB,EAsG5B;IA3FC;;OAEG;IACH,OAFU,KAAK,CAAC,KAAK,GAAG,GAAG,CAAC,CAEb;IACf,SAAc;IAEd,qBA9CmB,IAAI,KAAE,OAAO,CA8CA;IAEhC,yBAAoC;IACpC,2BAlDmB,WAAW,KAAE,OAAO,CAkDK;IAC5C;;OAEG;IACH,WAFU,KAAK,CAAC,SAAS,CAAC,CAEP;IACnB;;OAEG;IACH,WAFU,KAAK,CAAC,SAAS,CAAC,CAEP;IACnB;;;;OAIG;IACH,SAFU,OAAO,CAEG;IACpB,iBAAoB;IACpB;;;;OAIG;IACH,eAFU,SAAS,GAAC,IAAI,CAEC;IACzB,mBAAmB;IACnB,gCAAoD;IACpD,uBAAoC;IACpC;;OAEG;IACH,uCAFW,WAAW,UAmDrB;IAOH;;;;OAIG;IACH,mBAFW,KAAK,CAAC,KAAK,GAAG,GAAG,CAAC,GAAG,KAAK,GAAG,GAAG,QAY1C;IAED;;OAEG;IACH,yBAFW,GAAG,QAIb;IAED;;OAEG;IACH,4BAFW,GAAG,QAIb;IAED,gEAcC;IAED;;;;;;;;;;;;;;;;;;;OAmBG;IACH,sBAEC;IAED;;;;OAIG;IACH,QAFY,SAAS,OAAC,CAWrB;IAED;;;;OAIG;IACH,QAFY,SAAS,OAAC,CAWrB;IAED;;;;OAIG;IACH,WAFY,OAAO,CAIlB;IAED;;;;OAIG;IACH,WAFY,OAAO,CAIlB;CAOF;
|
|
1
|
+
{"version":3,"file":"UndoManager.d.ts","sourceRoot":"","sources":["../../../src/utils/UndoManager.js"],"names":[],"mappings":"AAmBA;IACE;;;OAGG;IACH,wBAHW,KAAK,aACL,KAAK,EASf;IANC,eAAyB;IACzB,eAAwB;IACxB;;OAEG;IACH,oBAAqB;CAExB;AAgGD;;;;;;;;;;;GAWG;AAEH;;;;;;GAMG;AAEH;;;;;;;;GAQG;AACH;wBAF8C,CAAS,IAAc,EAAd,cAAc,EAAE,IAAW,EAAX,WAAW,KAAE,IAAI;yBAAuB,CAAS,IAAc,EAAd,cAAc,EAAE,IAAW,EAAX,WAAW,K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;;;;;iCAnRsB,WAAW,KAAE,OAAO;;;;;;;2BACpB,IAAI,KAAE,OAAO;;;;;;;;;;;;eAWtB,SAAS;YACT,GAAG;UACH,MAAM,GAAC,MAAM;wBACb,GAAG,CAAC,KAAK,EAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;;sBAtIpC,iBAAiB;6BAKK,iBAAiB;sBALvC,iBAAiB;oBAAjB,iBAAiB;qBAAjB,iBAAiB;4BAAjB,iBAAiB;uBAAjB,iBAAiB"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export function writeStructs(encoder: UpdateEncoderV1 | UpdateEncoderV2, structs: Array<GC | Item>, client: number, idranges: Array<IdRange>): void;
|
|
1
2
|
export function writeClientsStructs(encoder: UpdateEncoderV1 | UpdateEncoderV2, store: StructStore, _sm: Map<number, number>): void;
|
|
2
3
|
export function writeStructsFromIdSet(encoder: UpdateEncoderV1 | UpdateEncoderV2, store: StructStore, idset: IdSet): void;
|
|
3
4
|
export function writeStructsFromTransaction(encoder: UpdateEncoderV1 | UpdateEncoderV2, transaction: Transaction): void;
|
|
@@ -12,10 +13,13 @@ export function readStateVector(decoder: IdSetDecoderV1 | IdSetDecoderV2): Map<n
|
|
|
12
13
|
export function decodeStateVector(decodedState: Uint8Array): Map<number, number>;
|
|
13
14
|
export function writeStateVector(encoder: IdSetEncoderV1 | IdSetEncoderV2, sv: Map<number, number>): IdSetEncoderV1 | IdSetEncoderV2;
|
|
14
15
|
export function writeDocumentStateVector(encoder: IdSetEncoderV1 | IdSetEncoderV2, doc: Doc): IdSetEncoderV1 | IdSetEncoderV2;
|
|
15
|
-
export function encodeStateVectorV2(doc: Doc | Map<number, number>, encoder?: IdSetEncoderV1 | IdSetEncoderV2): Uint8Array
|
|
16
|
-
export function encodeStateVector(doc: Doc | Map<number, number>): Uint8Array
|
|
16
|
+
export function encodeStateVectorV2(doc: Doc | Map<number, number>, encoder?: IdSetEncoderV1 | IdSetEncoderV2): Uint8Array<ArrayBuffer>;
|
|
17
|
+
export function encodeStateVector(doc: Doc | Map<number, number>): Uint8Array<ArrayBuffer>;
|
|
17
18
|
import { UpdateEncoderV1 } from '../internals.js';
|
|
18
19
|
import { UpdateEncoderV2 } from '../internals.js';
|
|
20
|
+
import { GC } from '../internals.js';
|
|
21
|
+
import { Item } from '../internals.js';
|
|
22
|
+
import { IdRange } from '../internals.js';
|
|
19
23
|
import { StructStore } from '../internals.js';
|
|
20
24
|
import { IdSet } from '../internals.js';
|
|
21
25
|
import { Transaction } from '../internals.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"encoding.d.ts","sourceRoot":"","sources":["../../../src/utils/encoding.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"encoding.d.ts","sourceRoot":"","sources":["../../../src/utils/encoding.js"],"names":[],"mappings":"AAwDO,sCAPI,eAAe,GAAG,eAAe,WACjC,KAAK,CAAC,EAAE,GAAC,IAAI,CAAC,UACd,MAAM,YACN,KAAK,CAAC,OAAO,CAAC,QAmDxB;AAUM,6CAPI,eAAe,GAAG,eAAe,SACjC,WAAW,OACX,GAAG,CAAC,MAAM,EAAC,MAAM,CAAC,QA4B5B;AAYM,+CATI,eAAe,GAAG,eAAe,SACjC,WAAW,SACX,KAAK,QAiBf;AA6KM,qDANI,eAAe,GAAG,eAAe,eACjC,WAAW,QAK2H;AAc1I,sCAPI,QAAQ,CAAC,OAAO,QAChB,GAAG,sBACH,GAAG,kBACH,eAAe,GAAG,eAAe,QAqFd;AAavB,oCANI,QAAQ,CAAC,OAAO,QAChB,GAAG,sBACH,GAAG,QAI8H;AAcrI,oCAPI,GAAG,UACH,UAAU,sBACV,GAAG,aACH,OAAO,eAAe,GAAG,OAAO,eAAe,QAOzD;AAaM,kCANI,GAAG,UACH,UAAU,sBACV,GAAG,QAIiH;AAYxH,4CANI,eAAe,GAAG,eAAe,OACjC,GAAG,sBACH,GAAG,CAAC,MAAM,EAAC,MAAM,CAAC,QAO5B;AAeM,2CAPI,GAAG,6BACH,UAAU,YACV,eAAe,GAAG,eAAe,GAChC,UAAU,CAAC,WAAW,CAAC,CAuBlC;AAcM,yCANI,GAAG,6BACH,UAAU,GACT,UAAU,CAAC,WAAW,CAAC,CAI8G;AAU1I,yCALI,cAAc,GAAG,cAAc,GAC9B,GAAG,CAAC,MAAM,EAAC,MAAM,CAAC,CAa7B;AAoBM,gDALI,UAAU,GACT,GAAG,CAAC,MAAM,EAAC,MAAM,CAAC,CAI4F;AAOnH,0CAJI,cAAc,GAAG,cAAc,MAC/B,GAAG,CAAC,MAAM,EAAC,MAAM,CAAC,mCAU5B;AAQM,kDALI,cAAc,GAAG,cAAc,OAC/B,GAAG,mCAIgG;AAWvG,yCANI,GAAG,GAAC,GAAG,CAAC,MAAM,EAAC,MAAM,CAAC,YACtB,cAAc,GAAG,cAAc,GAC9B,UAAU,CAAC,WAAW,CAAC,CAWlC;AAUM,uCALI,GAAG,GAAC,GAAG,CAAC,MAAM,EAAC,MAAM,CAAC,GACrB,UAAU,CAAC,WAAW,CAAC,CAImD;gCArkB/E,iBAAiB;gCAAjB,iBAAiB;mBAAjB,iBAAiB;qBAAjB,iBAAiB;wBAAjB,iBAAiB;4BAAjB,iBAAiB;sBAAjB,iBAAiB;4BAAjB,iBAAiB;0BAGE,eAAe;oBAHlC,iBAAiB;gCAAjB,iBAAiB;gCAAjB,iBAAiB;+BAAjB,iBAAiB;+BAAjB,iBAAiB;+BAAjB,iBAAiB;+BAAjB,iBAAiB"}
|
|
@@ -51,22 +51,23 @@ export class LazyStructWriter {
|
|
|
51
51
|
}>;
|
|
52
52
|
}
|
|
53
53
|
export function mergeUpdates(updates: Array<Uint8Array<ArrayBuffer>>): Uint8Array<ArrayBuffer>;
|
|
54
|
-
export function encodeStateVectorFromUpdateV2(update: Uint8Array, YEncoder?: typeof IdSetEncoderV1 | typeof IdSetEncoderV2, YDecoder?: typeof UpdateDecoderV1 | typeof UpdateDecoderV2): Uint8Array
|
|
55
|
-
export function encodeStateVectorFromUpdate(update: Uint8Array): Uint8Array
|
|
54
|
+
export function encodeStateVectorFromUpdateV2(update: Uint8Array, YEncoder?: typeof IdSetEncoderV1 | typeof IdSetEncoderV2, YDecoder?: typeof UpdateDecoderV1 | typeof UpdateDecoderV2): Uint8Array<ArrayBuffer>;
|
|
55
|
+
export function encodeStateVectorFromUpdate(update: Uint8Array): Uint8Array<ArrayBuffer>;
|
|
56
56
|
export function createContentIdsFromUpdateV2(update: Uint8Array, YDecoder?: typeof UpdateDecoderV2 | typeof UpdateDecoderV1): import("./meta.js").ContentIds;
|
|
57
57
|
export function createContentIdsFromUpdate(update: Uint8Array): import("./meta.js").ContentIds;
|
|
58
|
+
export function sliceStruct(left: Item | GC | Skip, diff: number): Item | GC;
|
|
58
59
|
export function mergeUpdatesV2(updates: Array<Uint8Array<ArrayBuffer>>, YDecoder?: typeof UpdateDecoderV1 | typeof UpdateDecoderV2, YEncoder?: typeof UpdateEncoderV1 | typeof UpdateEncoderV2): Uint8Array<ArrayBuffer>;
|
|
59
60
|
export function diffUpdateV2(update: Uint8Array, sv: Uint8Array, YDecoder?: typeof UpdateDecoderV1 | typeof UpdateDecoderV2, YEncoder?: typeof UpdateEncoderV1 | typeof UpdateEncoderV2): Uint8Array<ArrayBuffer>;
|
|
60
|
-
export function diffUpdate(update: Uint8Array
|
|
61
|
+
export function diffUpdate(update: Uint8Array<ArrayBuffer>, sv: Uint8Array<ArrayBuffer>): Uint8Array<ArrayBuffer>;
|
|
61
62
|
export function convertUpdateFormat(update: Uint8Array, blockTransformer: (arg0: Item | GC | Skip) => Item | GC | Skip, YDecoder: typeof UpdateDecoderV2 | typeof UpdateDecoderV1, YEncoder: typeof UpdateEncoderV2 | typeof UpdateEncoderV1): Uint8Array<ArrayBuffer>;
|
|
62
63
|
export function obfuscateUpdate(update: Uint8Array, opts?: ObfuscatorOptions): Uint8Array<ArrayBuffer>;
|
|
63
64
|
export function obfuscateUpdateV2(update: Uint8Array, opts?: ObfuscatorOptions): Uint8Array<ArrayBuffer>;
|
|
64
65
|
export function convertUpdateFormatV1ToV2(update: Uint8Array): Uint8Array<ArrayBuffer>;
|
|
65
66
|
export function convertUpdateFormatV2ToV1(update: Uint8Array): Uint8Array<ArrayBuffer>;
|
|
66
|
-
export function intersectUpdateWithContentIdsV2(update: Uint8Array, contentIds: import("./meta.js").ContentIds, YDecoder?: typeof UpdateDecoderV1 | typeof UpdateDecoderV2, YEncoder?: typeof UpdateEncoderV1 | typeof UpdateEncoderV2): Uint8Array
|
|
67
|
-
export function intersectUpdateWithContentIds(update: Uint8Array, contentIds: import("./meta.js").ContentIds): Uint8Array
|
|
68
|
-
export function createDocFromUpdate(update: Uint8Array): Doc;
|
|
69
|
-
export function createDocFromUpdateV2(update: Uint8Array): Doc;
|
|
67
|
+
export function intersectUpdateWithContentIdsV2(update: Uint8Array, contentIds: import("./meta.js").ContentIds, YDecoder?: typeof UpdateDecoderV1 | typeof UpdateDecoderV2, YEncoder?: typeof UpdateEncoderV1 | typeof UpdateEncoderV2): Uint8Array<ArrayBuffer>;
|
|
68
|
+
export function intersectUpdateWithContentIds(update: Uint8Array, contentIds: import("./meta.js").ContentIds): Uint8Array<ArrayBuffer>;
|
|
69
|
+
export function createDocFromUpdate(update: Uint8Array, opts?: import("./Doc.js").DocOpts): Doc;
|
|
70
|
+
export function createDocFromUpdateV2(update: Uint8Array, opts?: import("./Doc.js").DocOpts): Doc;
|
|
70
71
|
export type ObfuscatorOptions = {
|
|
71
72
|
formatting?: boolean | undefined;
|
|
72
73
|
subdocs?: boolean | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"updates.d.ts","sourceRoot":"","sources":["../../../src/utils/updates.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"updates.d.ts","sourceRoot":"","sources":["../../../src/utils/updates.js"],"names":[],"mappings":"AA0FA;IACE;;;OAGG;IACH,qBAHW,eAAe,GAAG,eAAe,eACjC,OAAO,EAWjB;IARC,gD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],"names":[],"mappings":"AAeO,2CAFI,CAAC,CAAC,QAAQ,QAepB;AAKM,0CAFI,CAAC,CAAC,QAAQ,QAqBpB;AAKM,4DAFI,CAAC,CAAC,QAAQ,QAepB;AAKM,yDAFI,CAAC,CAAC,QAAQ,QAepB;AAEM,
|
|
1
|
+
{"version":3,"file":"attribution.tests.d.ts","sourceRoot":"","sources":["../../tests/attribution.tests.js"],"names":[],"mappings":"AAeO,2CAFI,CAAC,CAAC,QAAQ,QAepB;AAKM,0CAFI,CAAC,CAAC,QAAQ,QAqBpB;AAKM,4DAFI,CAAC,CAAC,QAAQ,QAepB;AAKM,yDAFI,CAAC,CAAC,QAAQ,QAepB;AAEM,qCAoBN;AAEM,6CAqBN;AAKM,4CAFI,CAAC,CAAC,QAAQ,QAqCpB;mBArKkB,cAAc"}
|
|
@@ -6,7 +6,7 @@ export namespace encV1 {
|
|
|
6
6
|
let applyUpdate: (ydoc: Y.Doc, update: Uint8Array, transactionOrigin?: any) => void;
|
|
7
7
|
let logUpdate: (update: Uint8Array) => void;
|
|
8
8
|
let updateEventName: "update";
|
|
9
|
-
let diffUpdate: (update: Uint8Array
|
|
9
|
+
let diffUpdate: (update: Uint8Array<ArrayBuffer>, sv: Uint8Array<ArrayBuffer>) => Uint8Array<ArrayBuffer>;
|
|
10
10
|
}
|
|
11
11
|
export namespace encV2 {
|
|
12
12
|
let encodeStateAsUpdate_1: (doc: Y.Doc, encodedTargetStateVector?: Uint8Array, encoder?: Y.UpdateEncoderV1 | Y.UpdateEncoderV2) => Uint8Array<ArrayBuffer>;
|
|
@@ -23,6 +23,9 @@ export namespace encV2 {
|
|
|
23
23
|
export { diffUpdate_1 as diffUpdate };
|
|
24
24
|
}
|
|
25
25
|
export namespace enc { }
|
|
26
|
+
/**
|
|
27
|
+
* @extends {Y.Doc}
|
|
28
|
+
*/
|
|
26
29
|
export class TestYInstance extends Y.Doc {
|
|
27
30
|
/**
|
|
28
31
|
* @param {TestConnector} testConnector
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"testHelper.d.ts","sourceRoot":"","sources":["../../tests/testHelper.js"],"names":[],"mappings":";AAoCA,0BAAwB;;;;;;yBAOM,QAAQ;;;;;;;;;;;;2BASR,UAAU;;;;;;AAiBxC;IACE;;;OAGG;IACH,2BAHW,aAAa,YACb,MAAM,EA8BhB;IA1BC,eAAsB;IACtB;;OAEG;IACH,IAFU,aAAa,CAEA;IACvB;;OAEG;IACH,WAFU,GAAG,CAAC,aAAa,EAAE,KAAK,CAAC,UAAU,CAAC,CAAC,CAErB;IAE1B;;;;OAIG;IACH,SAFU,KAAK,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC,CAEvB;IAanB;;OAEG;IACH,mBAGC;IAED;;;OAGG;IACH,gBAgBC;IAED;;;;;;OAMG;IACH,kBAHW,UAAU,gBACV,aAAa,QAIvB;CACF;AAED;;;;;GAKG;AACH;IACE;;OAEG;IACH,iBAFW,IAAI,CAAC,IAAI,EAenB;IAZC;;OAEG;IACH,UAFU,GAAG,CAAC,aAAa,CAAC,CAEH;IACzB;;OAEG;IACH,aAFU,GAAG,CAAC,aAAa,CAAC,CAEA;IAC5B;;OAEG;IACH,MAFU,IAAI,CAAC,IAAI,CAEJ;IAGjB;;;OAGG;IACH,kBAFW,MAAM,iBAIhB;IAED;;;;;OAKG;IACH,sBAFY,OAAO,CA0BlB;IAED;;OAEG;IACH,oBAFY,OAAO,CAQlB;IAED,qBAEC;IAED,sBAEC;IAED,gBAGC;IAED;;OAEG;IACH,oBAFY,OAAO,CAQlB;IAED;;OAEG;IACH,mBAFY,OAAO,CAiBlB;CACF;AASM,qBANM,CAAC,MACH,CAAC,CAAC,QAAQ,cACV;IAAC,KAAK,CAAC,EAAC,MAAM,CAAA;CAAC,mBACf,sBAAsB,CAAC,CAAC,CAAC,GACxB;IAAC,WAAW,EAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAAA,aAAa,EAAC,aAAa,CAAC;IAAA,KAAK,EAAC,KAAK,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B;AAOM,kCAJI,CAAC,CAAC,IAAI,OAAC,KACP,CAAC,CAAC,IAAI,OAAC,GACN,OAAO,CAEqF;AAMjG,yCAHI,OAAO,qBAAqB,EAAE,WAAW,OACzC,OAAO,qBAAqB,EAAE,WAAW,aAuCnD;AAgBM,iCANM,CAAC,MACH,CAAC,CAAC,QAAQ,QACV,KAAK,CAAC,CAAS,IAAK,EAAL,CAAC,CAAC,GAAG,EAAC,IAAS,EAAT,IAAI,CAAC,IAAI,EAAC,IAAC,EAAD,CAAC,KAAE,IAAI,CAAC,cACvC,MAAM,mBACN,sBAAsB,CAAC,CAAC,CAAC;iBAlSX,KAAK,CAAC,GAAG,CAAC;mBAAe,aAAa;WAAO,KAAK,CAAC,aAAa,CAAC;YAAQ,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC;YAAQ,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC;YAAQ,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC;UAAM,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC;UAAM,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC;UAAM,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC;UAAM,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC;WAAO,CAAC,CAAC,IAAI;WAAO,CAAC,CAAC,IAAI;WAAO,CAAC,CAAC,IAAI;UAAM,CAAC,CAAC,IAAI;UAAM,CAAC,CAAC,IAAI;UAAM,CAAC,CAAC,IAAI;EA6TjS;mCAtCY,CAAC,QAEH,aAAa,KACZ,CAAC;qCAsCA,UAAU,CAAC,OAAO,gBAAgB,CAAC;mBA5kB7B,iBAAiB;sBANd,WAAW;mBADd,cAAc"}
|
|
@@ -2,6 +2,7 @@ export function testMergeUpdates(tc: t.TestCase): void;
|
|
|
2
2
|
export function testKeyEncoding(tc: t.TestCase): void;
|
|
3
3
|
export function testMergeUpdates1(_tc: t.TestCase): void;
|
|
4
4
|
export function testMergeUpdates2(_tc: t.TestCase): void;
|
|
5
|
+
export function testMergeUpdatesStressTest(_tc: t.TestCase): void;
|
|
5
6
|
export function testMergePendingUpdates(_tc: t.TestCase): void;
|
|
6
7
|
export function testObfuscateUpdates(_tc: t.TestCase): void;
|
|
7
8
|
export function testIntersectDoc(): void;
|
|
@@ -14,11 +15,11 @@ export type Enc = {
|
|
|
14
15
|
deletes: Y.IdSet;
|
|
15
16
|
inserts: Y.IdSet;
|
|
16
17
|
};
|
|
17
|
-
encodeStateVector: (arg0: Y.Doc) => Uint8Array
|
|
18
|
-
encodeStateVectorFromUpdate: (arg0: Uint8Array) => Uint8Array
|
|
18
|
+
encodeStateVector: (arg0: Y.Doc) => Uint8Array<ArrayBuffer>;
|
|
19
|
+
encodeStateVectorFromUpdate: (arg0: Uint8Array) => Uint8Array<ArrayBuffer>;
|
|
19
20
|
updateEventName: "update" | "updateV2";
|
|
20
21
|
description: string;
|
|
21
|
-
diffUpdate: (arg0: Uint8Array
|
|
22
|
+
diffUpdate: (arg0: Uint8Array<ArrayBuffer>, arg1: Uint8Array<ArrayBuffer>) => Uint8Array<ArrayBuffer>;
|
|
22
23
|
};
|
|
23
24
|
import * as t from 'lib0/testing';
|
|
24
25
|
import * as Y from '../src/index.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"updates.tests.d.ts","sourceRoot":"","sources":["../../tests/updates.tests.js"],"names":[],"mappings":"AAwGO,qCAFI,CAAC,CAAC,QAAQ,QAapB;AAKM,oCAFI,CAAC,CAAC,QAAQ,QAuBpB;AA0FM,uCAFI,CAAC,CAAC,QAAQ,QAepB;AAKM,uCAFI,CAAC,CAAC,QAAQ,QAepB;AAKM,6CAFI,CAAC,CAAC,QAAQ,QA4CpB;AAKM,0CAFI,CAAC,CAAC,QAAQ,QAgDpB;AAEM,yCAUN;;
|
|
1
|
+
{"version":3,"file":"updates.tests.d.ts","sourceRoot":"","sources":["../../tests/updates.tests.js"],"names":[],"mappings":"AAwGO,qCAFI,CAAC,CAAC,QAAQ,QAapB;AAK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",
|
|
@@ -13,9 +13,9 @@
|
|
|
13
13
|
"clean": "rm -rf dist",
|
|
14
14
|
"test": "NODE_ENV=development node ./tests/index.js --repetition-time 50",
|
|
15
15
|
"test-extensive": "node ./tests/index.js --production --repetition-time 10000",
|
|
16
|
-
"dist": "npm run clean && (tsc --skipLibCheck|| true)",
|
|
16
|
+
"dist": "npm run clean && (tsc --skipLibCheck --noEmit false|| true)",
|
|
17
|
+
"release": "PRODUCTION=1 npm run dist && test -e dist/src/index.d.ts && np",
|
|
17
18
|
"lint": "markdownlint README.md && standard && tsc --skipLibCheck",
|
|
18
|
-
"preversion": "PRODUCTION=1 npm run dist && test -e dist/src/index.d.ts",
|
|
19
19
|
"debug": "npm run gentesthtml && 0serve -o test.html",
|
|
20
20
|
"debug:node": "node --inspect-brk tests/index.js",
|
|
21
21
|
"trace-deopt": "clear && node --trace-deopt ./tests/index.js",
|
|
@@ -76,15 +76,16 @@
|
|
|
76
76
|
},
|
|
77
77
|
"homepage": "https://docs.yjs.dev",
|
|
78
78
|
"dependencies": {
|
|
79
|
-
"lib0": "^1.0.0-
|
|
79
|
+
"lib0": "^1.0.0-rc.2"
|
|
80
80
|
},
|
|
81
81
|
"devDependencies": {
|
|
82
82
|
"@types/node": "^22.14.1",
|
|
83
|
-
"@y/protocols": "^1.0.6-1",
|
|
83
|
+
"@y/protocols": "^1.0.6-rc.1",
|
|
84
84
|
"markdownlint": "^0.40.0",
|
|
85
85
|
"markdownlint-cli": "^0.45.0",
|
|
86
86
|
"standard": "^17.1.2",
|
|
87
|
-
"typescript": "^5.9.3"
|
|
87
|
+
"typescript": "^5.9.3",
|
|
88
|
+
"@y/y": "."
|
|
88
89
|
},
|
|
89
90
|
"engines": {
|
|
90
91
|
"npm": ">=8.0.0",
|
package/src/internals.js
CHANGED
|
@@ -14,7 +14,7 @@ export * from './utils/Transaction.js'
|
|
|
14
14
|
export * from './utils/UndoManager.js'
|
|
15
15
|
export * from './utils/updates.js'
|
|
16
16
|
export * from './utils/YEvent.js'
|
|
17
|
-
export * from './utils/
|
|
17
|
+
export * from './utils/BlockSet.js'
|
|
18
18
|
export * from './utils/IdMap.js'
|
|
19
19
|
export * from './utils/AttributionManager.js'
|
|
20
20
|
export * from './utils/delta-helpers.js'
|
package/src/structs/Item.js
CHANGED
|
@@ -278,7 +278,7 @@ export class Item extends AbstractStruct {
|
|
|
278
278
|
* @param {ID | null} origin
|
|
279
279
|
* @param {Item | null} right
|
|
280
280
|
* @param {ID | null} rightOrigin
|
|
281
|
-
* @param {YType|ID|null} parent Is a type if integrated, is null if it is possible to copy parent from left or right, is ID before integration to search for it
|
|
281
|
+
* @param {YType|ID|string|null} parent Is a type if integrated, is null if it is possible to copy parent from left or right, is ID before integration to search for it, is string if child of top-level-parent
|
|
282
282
|
* @param {string | null} parentSub
|
|
283
283
|
* @param {AbstractContent} content
|
|
284
284
|
*/
|
|
@@ -305,7 +305,7 @@ export class Item extends AbstractStruct {
|
|
|
305
305
|
*/
|
|
306
306
|
this.rightOrigin = rightOrigin
|
|
307
307
|
/**
|
|
308
|
-
* @type {YType|ID|null}
|
|
308
|
+
* @type {YType|ID|string|null}
|
|
309
309
|
*/
|
|
310
310
|
this.parent = parent
|
|
311
311
|
/**
|
|
@@ -414,7 +414,7 @@ export class Item extends AbstractStruct {
|
|
|
414
414
|
}
|
|
415
415
|
if ((this.left && this.left.constructor === GC) || (this.right && this.right.constructor === GC)) {
|
|
416
416
|
this.parent = null
|
|
417
|
-
} else if (
|
|
417
|
+
} else if (this.parent == null) {
|
|
418
418
|
// only set parent if this shouldn't be garbage collected
|
|
419
419
|
if (this.left && this.left.constructor === Item) {
|
|
420
420
|
this.parent = this.left.parent
|
|
@@ -430,6 +430,8 @@ export class Item extends AbstractStruct {
|
|
|
430
430
|
} else {
|
|
431
431
|
this.parent = /** @type {ContentType} */ (parentItem.content).type
|
|
432
432
|
}
|
|
433
|
+
} else if (typeof this.parent === 'string') {
|
|
434
|
+
this.parent = transaction.doc.get(this.parent)
|
|
433
435
|
}
|
|
434
436
|
return null
|
|
435
437
|
}
|
|
@@ -569,7 +569,7 @@ export class DiffAttributionManager extends ObservableV2 {
|
|
|
569
569
|
* @param {Doc} prevDoc
|
|
570
570
|
* @param {Doc} nextDoc
|
|
571
571
|
* @param {Object} [options] - options for the attribution manager
|
|
572
|
-
* @param {
|
|
572
|
+
* @param {import('./meta.js').ContentMap?} [options.attrs] - the attributes to apply to the diff
|
|
573
573
|
*/
|
|
574
574
|
export const createAttributionManagerFromDiff = (prevDoc, nextDoc, options) => new DiffAttributionManager(prevDoc, nextDoc, options)
|
|
575
575
|
|
|
@@ -0,0 +1,291 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createID,
|
|
3
|
+
readItemContent,
|
|
4
|
+
findIndexCleanStart,
|
|
5
|
+
Skip,
|
|
6
|
+
createIdSet,
|
|
7
|
+
sliceStruct,
|
|
8
|
+
IdRange,
|
|
9
|
+
GC, Item, ID,
|
|
10
|
+
writeStructs
|
|
11
|
+
} from '../internals.js'
|
|
12
|
+
|
|
13
|
+
import * as decoding from 'lib0/decoding'
|
|
14
|
+
import * as binary from 'lib0/binary'
|
|
15
|
+
import * as map from 'lib0/map'
|
|
16
|
+
import * as array from 'lib0/array'
|
|
17
|
+
import * as math from 'lib0/math'
|
|
18
|
+
import * as encoding from 'lib0/encoding'
|
|
19
|
+
import * as number from 'lib0/number'
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* @param {UpdateDecoderV1 | UpdateDecoderV2} decoder The decoder object to read data from.
|
|
23
|
+
* @return {BlockSet}
|
|
24
|
+
*
|
|
25
|
+
* @private
|
|
26
|
+
* @function
|
|
27
|
+
*/
|
|
28
|
+
export const readBlockSet = (decoder) => {
|
|
29
|
+
const clientRefs = new BlockSet()
|
|
30
|
+
const numOfStateUpdates = decoding.readVarUint(decoder.restDecoder)
|
|
31
|
+
for (let i = 0; i < numOfStateUpdates; i++) {
|
|
32
|
+
const numberOfBlocks = decoding.readVarUint(decoder.restDecoder)
|
|
33
|
+
/**
|
|
34
|
+
* @type {Array<GC|Item>}
|
|
35
|
+
*/
|
|
36
|
+
const refs = new Array(numberOfBlocks)
|
|
37
|
+
const client = decoder.readClient()
|
|
38
|
+
let clock = decoding.readVarUint(decoder.restDecoder)
|
|
39
|
+
clientRefs.clients.set(client, new BlockRange(refs))
|
|
40
|
+
for (let i = 0; i < numberOfBlocks; i++) {
|
|
41
|
+
const info = decoder.readInfo()
|
|
42
|
+
switch (binary.BITS5 & info) {
|
|
43
|
+
case 0: { // GC
|
|
44
|
+
const len = decoder.readLen()
|
|
45
|
+
refs[i] = new GC(createID(client, clock), len)
|
|
46
|
+
clock += len
|
|
47
|
+
break
|
|
48
|
+
}
|
|
49
|
+
case 10: { // Skip Block (nothing to apply)
|
|
50
|
+
// @todo we could reduce the amount of checks by adding Skip block to clientRefs so we know that something is missing.
|
|
51
|
+
const len = decoding.readVarUint(decoder.restDecoder)
|
|
52
|
+
refs[i] = new Skip(createID(client, clock), len)
|
|
53
|
+
clock += len
|
|
54
|
+
break
|
|
55
|
+
}
|
|
56
|
+
default: { // Item with content
|
|
57
|
+
/**
|
|
58
|
+
* The optimized implementation doesn't use any variables because inlining variables is faster.
|
|
59
|
+
* Below a non-optimized version is shown that implements the basic algorithm with
|
|
60
|
+
* a few comments
|
|
61
|
+
*/
|
|
62
|
+
const cantCopyParentInfo = (info & (binary.BIT7 | binary.BIT8)) === 0
|
|
63
|
+
// If parent = null and neither left nor right are defined, then we know that `parent` is child of `y`
|
|
64
|
+
// and we read the next string as parentYKey.
|
|
65
|
+
// It indicates how we store/retrieve parent from `y.share`
|
|
66
|
+
// @type {string|null}
|
|
67
|
+
const block = new Item(
|
|
68
|
+
createID(client, clock),
|
|
69
|
+
null, // left
|
|
70
|
+
(info & binary.BIT8) === binary.BIT8 ? decoder.readLeftID() : null, // origin
|
|
71
|
+
null, // right
|
|
72
|
+
(info & binary.BIT7) === binary.BIT7 ? decoder.readRightID() : null, // right origin
|
|
73
|
+
cantCopyParentInfo ? (decoder.readParentInfo() ? decoder.readString() : decoder.readLeftID()) : null, // parent
|
|
74
|
+
cantCopyParentInfo && (info & binary.BIT6) === binary.BIT6 ? decoder.readString() : null, // parentSub
|
|
75
|
+
readItemContent(decoder, info) // item content
|
|
76
|
+
)
|
|
77
|
+
refs[i] = block
|
|
78
|
+
clock += block.length
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
return clientRefs
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* @param {UpdateEncoderV1 | UpdateEncoderV2} encoder
|
|
88
|
+
* @param {BlockSet} blocks
|
|
89
|
+
*/
|
|
90
|
+
export const writeBlockSet = (encoder, blocks) => {
|
|
91
|
+
// write # states that were updated
|
|
92
|
+
encoding.writeVarUint(encoder.restEncoder, blocks.clients.size)
|
|
93
|
+
// Write items with higher client ids first
|
|
94
|
+
// This heavily improves the conflict algorithm.
|
|
95
|
+
array.from(blocks.clients.entries()).sort((a, b) => b[0] - a[0]).forEach(([client, blockrange]) => {
|
|
96
|
+
writeStructs(encoder, blockrange.refs, client, [new IdRange(0, number.MAX_SAFE_INTEGER)])
|
|
97
|
+
})
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
class BlockRange {
|
|
101
|
+
/**
|
|
102
|
+
* @param {Array<Item|GC>} refs
|
|
103
|
+
*/
|
|
104
|
+
constructor (refs) {
|
|
105
|
+
this.i = 0
|
|
106
|
+
/**
|
|
107
|
+
* @type {Array<Item | GC>}
|
|
108
|
+
*/
|
|
109
|
+
this.refs = refs
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
export class BlockSet {
|
|
114
|
+
constructor () {
|
|
115
|
+
/**
|
|
116
|
+
* @type {Map<number, BlockRange>}
|
|
117
|
+
*/
|
|
118
|
+
this.clients = map.create()
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
toIdSet () {
|
|
122
|
+
const inserts = createIdSet()
|
|
123
|
+
this.clients.forEach((ranges, clientid) => {
|
|
124
|
+
let lastClock = 0
|
|
125
|
+
let lastLen = 0
|
|
126
|
+
ranges.refs.forEach(block => {
|
|
127
|
+
if (block instanceof Skip) return
|
|
128
|
+
if (lastClock + lastLen === block.id.clock) {
|
|
129
|
+
// default case: extend prev entry
|
|
130
|
+
lastLen += block.length
|
|
131
|
+
} else {
|
|
132
|
+
lastLen > 0 && inserts.add(clientid, lastClock, lastLen)
|
|
133
|
+
lastClock = block.id.clock
|
|
134
|
+
lastLen = block.length
|
|
135
|
+
}
|
|
136
|
+
})
|
|
137
|
+
inserts.add(clientid, lastClock, lastLen)
|
|
138
|
+
})
|
|
139
|
+
return inserts
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* Remove id-ranges from update - convert them to skip if applicable.
|
|
144
|
+
*
|
|
145
|
+
* @param {IdSet} exclude
|
|
146
|
+
*/
|
|
147
|
+
exclude (exclude) {
|
|
148
|
+
const clientids = this.clients.size < exclude.clients.size ? this.clients.keys() : exclude.clients.keys()
|
|
149
|
+
for (const client of clientids) {
|
|
150
|
+
const range = exclude.clients.get(client)
|
|
151
|
+
const structs = this.clients.get(client)?.refs
|
|
152
|
+
if (range == null || structs == null) return
|
|
153
|
+
const firstStruct = structs[0]
|
|
154
|
+
const lastStruct = structs[structs.length - 1]
|
|
155
|
+
const idranges = range.getIds()
|
|
156
|
+
for (let i = 0; i < idranges.length; i++) {
|
|
157
|
+
const range = idranges[i]
|
|
158
|
+
let startIndex = 0
|
|
159
|
+
if (range.clock >= lastStruct.id.clock + lastStruct.length) continue
|
|
160
|
+
if (range.clock > firstStruct.id.clock) {
|
|
161
|
+
startIndex = findIndexCleanStart(null, structs, range.clock)
|
|
162
|
+
}
|
|
163
|
+
let endIndex = structs.length // must be set here, after structs is modified
|
|
164
|
+
if (range.clock + range.len <= firstStruct.id.clock) continue
|
|
165
|
+
if (range.clock + range.len < lastStruct.id.clock + lastStruct.length) {
|
|
166
|
+
endIndex = findIndexCleanStart(null, structs, range.clock + range.len)
|
|
167
|
+
}
|
|
168
|
+
if (startIndex < endIndex) {
|
|
169
|
+
structs[startIndex] = new Skip(new ID(client, range.clock), range.len)
|
|
170
|
+
const d = endIndex - startIndex
|
|
171
|
+
if (d > 1) {
|
|
172
|
+
structs.splice(startIndex + 1, d - 1)
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* @param {BlockSet} inserts
|
|
181
|
+
*/
|
|
182
|
+
insertInto (inserts) {
|
|
183
|
+
inserts.clients.forEach((newranges, clientid) => {
|
|
184
|
+
const ranges = this.clients.get(clientid)
|
|
185
|
+
if (ranges == null) {
|
|
186
|
+
this.clients.set(clientid, newranges)
|
|
187
|
+
} else {
|
|
188
|
+
const localIsLeft = ranges.refs[0].id.clock < newranges.refs[0].id.clock
|
|
189
|
+
const leftRanges = (localIsLeft ? ranges : newranges).refs
|
|
190
|
+
const rightRanges = (localIsLeft ? newranges : ranges).refs
|
|
191
|
+
const lastBlockLeft = array.last(leftRanges)
|
|
192
|
+
const firstBlockRight = rightRanges[0]
|
|
193
|
+
const gapSize = firstBlockRight.id.clock - lastBlockLeft.id.clock - lastBlockLeft.length
|
|
194
|
+
if (gapSize >= 0) {
|
|
195
|
+
// we can do a simple efficient merge
|
|
196
|
+
if (gapSize > 0) {
|
|
197
|
+
leftRanges.push(new Skip(new ID(clientid, lastBlockLeft.id.clock + lastBlockLeft.length), gapSize))
|
|
198
|
+
}
|
|
199
|
+
leftRanges.push(...rightRanges)
|
|
200
|
+
ranges.refs = leftRanges
|
|
201
|
+
} else {
|
|
202
|
+
// requires more computation because we need to filter duplicates
|
|
203
|
+
/**
|
|
204
|
+
* @type {Array<GC|Item>}
|
|
205
|
+
*/
|
|
206
|
+
const result = []
|
|
207
|
+
let nextExpectedClock = leftRanges[0].id.clock
|
|
208
|
+
/**
|
|
209
|
+
* @param {Item|GC} block
|
|
210
|
+
*/
|
|
211
|
+
const addToResult = block => {
|
|
212
|
+
result.push(block)
|
|
213
|
+
nextExpectedClock = block.id.clock + block.length
|
|
214
|
+
}
|
|
215
|
+
let li = 0
|
|
216
|
+
let ri = 0
|
|
217
|
+
/**
|
|
218
|
+
* @type {Item|GC|undefined}
|
|
219
|
+
*/
|
|
220
|
+
let lblock = leftRanges[li]
|
|
221
|
+
/**
|
|
222
|
+
* @type {Item|GC|undefined}
|
|
223
|
+
*/
|
|
224
|
+
let rblock = rightRanges[ri]
|
|
225
|
+
const applyLeft = () => {
|
|
226
|
+
if (lblock === undefined) return
|
|
227
|
+
// first try to consume left
|
|
228
|
+
// left: filter skips and known ops
|
|
229
|
+
while (lblock !== undefined && (lblock.constructor === Skip || lblock.id.clock + lblock.length <= nextExpectedClock)) {
|
|
230
|
+
lblock = leftRanges[++li]
|
|
231
|
+
}
|
|
232
|
+
// left: trim first op
|
|
233
|
+
if (lblock !== undefined && lblock.id.clock < nextExpectedClock && lblock.id.clock + lblock.length > nextExpectedClock) {
|
|
234
|
+
lblock = sliceStruct(lblock, lblock.id.clock + lblock.length - nextExpectedClock)
|
|
235
|
+
}
|
|
236
|
+
// left: add to result
|
|
237
|
+
while (lblock !== undefined && lblock.id.clock === nextExpectedClock && lblock.constructor !== Skip) {
|
|
238
|
+
addToResult(lblock)
|
|
239
|
+
lblock = leftRanges[++li]
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
const applyRight = () => {
|
|
243
|
+
// right: filter skips and known ops
|
|
244
|
+
while (rblock !== undefined && (rblock.constructor === Skip || rblock.id.clock + rblock.length <= nextExpectedClock)) {
|
|
245
|
+
rblock = rightRanges[++ri]
|
|
246
|
+
}
|
|
247
|
+
// right: trim first op
|
|
248
|
+
if (rblock !== undefined && rblock.id.clock < nextExpectedClock && rblock.id.clock + rblock.length > nextExpectedClock) {
|
|
249
|
+
rblock = sliceStruct(rblock, rblock.id.clock + rblock.length - nextExpectedClock)
|
|
250
|
+
}
|
|
251
|
+
// right: add to result
|
|
252
|
+
while (rblock !== undefined && rblock.id.clock === nextExpectedClock && rblock.constructor !== Skip) {
|
|
253
|
+
addToResult(rblock)
|
|
254
|
+
rblock = rightRanges[++ri]
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
for (; li < leftRanges.length && ri < rightRanges.length;) {
|
|
258
|
+
applyLeft()
|
|
259
|
+
applyRight()
|
|
260
|
+
// add skip if necessary
|
|
261
|
+
const minNextClock = math.min(lblock?.id.clock || 0, rblock?.id.clock || 0)
|
|
262
|
+
const gapSize = minNextClock - nextExpectedClock
|
|
263
|
+
if (gapSize > 0) {
|
|
264
|
+
addToResult(new Skip(new ID(clientid, nextExpectedClock), gapSize))
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
while (li < leftRanges.length) {
|
|
268
|
+
applyLeft()
|
|
269
|
+
if (lblock !== undefined) {
|
|
270
|
+
const gapSize = lblock.id.clock - nextExpectedClock
|
|
271
|
+
if (gapSize > 0) {
|
|
272
|
+
addToResult(new Skip(new ID(clientid, nextExpectedClock), gapSize))
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
while (ri < rightRanges.length) {
|
|
277
|
+
applyRight()
|
|
278
|
+
if (rblock !== undefined) {
|
|
279
|
+
const gapSize = rblock.id.clock - nextExpectedClock
|
|
280
|
+
if (gapSize > 0) {
|
|
281
|
+
addToResult(new Skip(new ID(clientid, nextExpectedClock), gapSize))
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
ranges.refs = result
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
})
|
|
289
|
+
inserts.clients.clear()
|
|
290
|
+
}
|
|
291
|
+
}
|
package/src/utils/UndoManager.js
CHANGED
|
@@ -398,9 +398,10 @@ export class UndoManager extends ObservableV2 {
|
|
|
398
398
|
*
|
|
399
399
|
* @param {Doc} ydoc
|
|
400
400
|
* @param {import('./meta.js').ContentIds} contentIds
|
|
401
|
+
* @param {UndoManagerOptions} opts
|
|
401
402
|
*/
|
|
402
|
-
export const undoContentIds = (ydoc, contentIds) => {
|
|
403
|
-
const um = new UndoManager(ydoc)
|
|
403
|
+
export const undoContentIds = (ydoc, contentIds, opts = {}) => {
|
|
404
|
+
const um = new UndoManager(ydoc, opts)
|
|
404
405
|
um.undoStack.push(new StackItem(diffIdSet(contentIds.inserts, contentIds.deletes), diffIdSet(contentIds.deletes, contentIds.inserts)))
|
|
405
406
|
um.undo()
|
|
406
407
|
}
|
package/src/utils/encoding.js
CHANGED
|
@@ -33,10 +33,9 @@ import {
|
|
|
33
33
|
Skip,
|
|
34
34
|
diffUpdateV2,
|
|
35
35
|
convertUpdateFormatV2ToV1,
|
|
36
|
-
|
|
37
|
-
removeRangesFromStructSet,
|
|
36
|
+
readBlockSet,
|
|
38
37
|
createIdSet,
|
|
39
|
-
|
|
38
|
+
BlockSet, IdSet, IdSetDecoderV2, Doc, Transaction, GC, Item, StructStore, // eslint-disable-line
|
|
40
39
|
createID,
|
|
41
40
|
IdRange
|
|
42
41
|
} from '../internals.js'
|
|
@@ -55,7 +54,7 @@ import * as array from 'lib0/array'
|
|
|
55
54
|
*
|
|
56
55
|
* @function
|
|
57
56
|
*/
|
|
58
|
-
const writeStructs = (encoder, structs, client, idranges) => {
|
|
57
|
+
export const writeStructs = (encoder, structs, client, idranges) => {
|
|
59
58
|
let structsToWrite = 0 // this accounts for the skips
|
|
60
59
|
/**
|
|
61
60
|
* @type {Array<{ start: number, end: number, startClock: number, endClock: number }>}
|
|
@@ -180,7 +179,7 @@ export const writeStructsFromIdSet = (encoder, store, idset) => {
|
|
|
180
179
|
*
|
|
181
180
|
* @param {Transaction} transaction
|
|
182
181
|
* @param {StructStore} store
|
|
183
|
-
* @param {
|
|
182
|
+
* @param {BlockSet} clientsStructRefs
|
|
184
183
|
* @return { null | { update: Uint8Array<ArrayBuffer>, missing: Map<number,number> } }
|
|
185
184
|
*
|
|
186
185
|
* @private
|
|
@@ -352,7 +351,7 @@ export const readUpdateV2 = (decoder, ydoc, transactionOrigin, structDecoder = n
|
|
|
352
351
|
const doc = transaction.doc
|
|
353
352
|
const store = doc.store
|
|
354
353
|
// let start = performance.now()
|
|
355
|
-
const ss =
|
|
354
|
+
const ss = readBlockSet(structDecoder)
|
|
356
355
|
const knownState = createIdSet()
|
|
357
356
|
ss.clients.forEach((_, client) => {
|
|
358
357
|
const storeStructs = store.clients.get(client)
|
|
@@ -366,7 +365,7 @@ export const readUpdateV2 = (decoder, ydoc, transactionOrigin, structDecoder = n
|
|
|
366
365
|
}
|
|
367
366
|
})
|
|
368
367
|
// remove known items from ss
|
|
369
|
-
|
|
368
|
+
ss.exclude(knownState)
|
|
370
369
|
// console.log('time to read structs: ', performance.now() - start) // @todo remove
|
|
371
370
|
// start = performance.now()
|
|
372
371
|
// console.log('time to merge: ', performance.now() - start) // @todo remove
|
|
@@ -599,7 +598,7 @@ export const writeDocumentStateVector = (encoder, doc) => writeStateVector(encod
|
|
|
599
598
|
*
|
|
600
599
|
* @param {Doc|Map<number,number>} doc
|
|
601
600
|
* @param {IdSetEncoderV1 | IdSetEncoderV2} [encoder]
|
|
602
|
-
* @return {Uint8Array}
|
|
601
|
+
* @return {Uint8Array<ArrayBuffer>}
|
|
603
602
|
*
|
|
604
603
|
* @function
|
|
605
604
|
*/
|
|
@@ -616,7 +615,7 @@ export const encodeStateVectorV2 = (doc, encoder = new IdSetEncoderV2()) => {
|
|
|
616
615
|
* Encode State as Uint8Array.
|
|
617
616
|
*
|
|
618
617
|
* @param {Doc|Map<number,number>} doc
|
|
619
|
-
* @return {Uint8Array}
|
|
618
|
+
* @return {Uint8Array<ArrayBuffer>}
|
|
620
619
|
*
|
|
621
620
|
* @function
|
|
622
621
|
*/
|
package/src/utils/updates.js
CHANGED
|
@@ -36,7 +36,10 @@ import {
|
|
|
36
36
|
createIdSet,
|
|
37
37
|
Doc,
|
|
38
38
|
applyUpdate,
|
|
39
|
-
applyUpdateV2
|
|
39
|
+
applyUpdateV2,
|
|
40
|
+
readBlockSet,
|
|
41
|
+
writeBlockSet,
|
|
42
|
+
encodeStateAsUpdateV2
|
|
40
43
|
} from '../internals.js'
|
|
41
44
|
|
|
42
45
|
import * as idset from './IdSet.js'
|
|
@@ -115,7 +118,6 @@ export class LazyStructReader {
|
|
|
115
118
|
|
|
116
119
|
/**
|
|
117
120
|
* @param {Uint8Array} update
|
|
118
|
-
*
|
|
119
121
|
*/
|
|
120
122
|
export const logUpdate = update => logUpdateV2(update, UpdateDecoderV1)
|
|
121
123
|
|
|
@@ -137,7 +139,6 @@ export const logUpdateV2 = (update, YDecoder = UpdateDecoderV2) => {
|
|
|
137
139
|
|
|
138
140
|
/**
|
|
139
141
|
* @param {Uint8Array} update
|
|
140
|
-
*
|
|
141
142
|
*/
|
|
142
143
|
export const decodeUpdate = (update) => decodeUpdateV2(update, UpdateDecoderV1)
|
|
143
144
|
|
|
@@ -192,7 +193,7 @@ export const mergeUpdates = updates => mergeUpdatesV2(updates, UpdateDecoderV1,
|
|
|
192
193
|
* @param {Uint8Array} update
|
|
193
194
|
* @param {typeof IdSetEncoderV1 | typeof IdSetEncoderV2} YEncoder
|
|
194
195
|
* @param {typeof UpdateDecoderV1 | typeof UpdateDecoderV2} YDecoder
|
|
195
|
-
* @return {Uint8Array}
|
|
196
|
+
* @return {Uint8Array<ArrayBuffer>}
|
|
196
197
|
*/
|
|
197
198
|
export const encodeStateVectorFromUpdateV2 = (update, YEncoder = IdSetEncoderV2, YDecoder = UpdateDecoderV2) => {
|
|
198
199
|
const encoder = new YEncoder()
|
|
@@ -244,7 +245,7 @@ export const encodeStateVectorFromUpdateV2 = (update, YEncoder = IdSetEncoderV2,
|
|
|
244
245
|
|
|
245
246
|
/**
|
|
246
247
|
* @param {Uint8Array} update
|
|
247
|
-
* @return {Uint8Array}
|
|
248
|
+
* @return {Uint8Array<ArrayBuffer>}
|
|
248
249
|
*/
|
|
249
250
|
export const encodeStateVectorFromUpdate = update => encodeStateVectorFromUpdateV2(update, IdSetEncoderV1, UpdateDecoderV1)
|
|
250
251
|
|
|
@@ -295,7 +296,7 @@ export const createContentIdsFromUpdate = update => createContentIdsFromUpdateV2
|
|
|
295
296
|
* @param {number} diff
|
|
296
297
|
* @return {Item | GC}
|
|
297
298
|
*/
|
|
298
|
-
const sliceStruct = (left, diff) => {
|
|
299
|
+
export const sliceStruct = (left, diff) => {
|
|
299
300
|
if (left.constructor === GC) {
|
|
300
301
|
const { client, clock } = left.id
|
|
301
302
|
return new GC(createID(client, clock + diff), left.length - diff)
|
|
@@ -330,125 +331,18 @@ const sliceStruct = (left, diff) => {
|
|
|
330
331
|
export const mergeUpdatesV2 = (updates, YDecoder = UpdateDecoderV2, YEncoder = UpdateEncoderV2) => {
|
|
331
332
|
if (updates.length === 1) {
|
|
332
333
|
return updates[0]
|
|
334
|
+
} else if (updates.length === 0) {
|
|
335
|
+
return encodeStateAsUpdateV2(new Doc(), new Uint8Array([0]), new YEncoder())
|
|
333
336
|
}
|
|
334
337
|
const updateDecoders = updates.map(update => new YDecoder(decoding.createDecoder(update)))
|
|
335
|
-
|
|
338
|
+
const blocksets = updateDecoders.map(dec => readBlockSet(dec))
|
|
336
339
|
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
*/
|
|
341
|
-
let currWrite = null
|
|
342
|
-
|
|
343
|
-
const updateEncoder = new YEncoder()
|
|
344
|
-
// write structs lazily
|
|
345
|
-
const lazyStructEncoder = new LazyStructWriter(updateEncoder)
|
|
346
|
-
|
|
347
|
-
// Note: We need to ensure that all lazyStructDecoders are fully consumed
|
|
348
|
-
// Note: Should merge document updates whenever possible - even from different updates
|
|
349
|
-
// Note: Should handle that some operations cannot be applied yet ()
|
|
350
|
-
|
|
351
|
-
while (true) {
|
|
352
|
-
// Write higher clients first ⇒ sort by clientID & clock and remove decoders without content
|
|
353
|
-
lazyStructDecoders = lazyStructDecoders.filter(dec => dec.curr !== null)
|
|
354
|
-
lazyStructDecoders.sort(
|
|
355
|
-
/** @type {function(any,any):number} */ (dec1, dec2) => {
|
|
356
|
-
if (dec1.curr.id.client === dec2.curr.id.client) {
|
|
357
|
-
const clockDiff = dec1.curr.id.clock - dec2.curr.id.clock
|
|
358
|
-
if (clockDiff === 0) {
|
|
359
|
-
// @todo remove references to skip since the structDecoders must filter Skips.
|
|
360
|
-
return dec1.curr.constructor === dec2.curr.constructor
|
|
361
|
-
? 0
|
|
362
|
-
: dec1.curr.constructor === Skip ? 1 : -1 // we are filtering skips anyway.
|
|
363
|
-
} else {
|
|
364
|
-
return clockDiff
|
|
365
|
-
}
|
|
366
|
-
} else {
|
|
367
|
-
return dec2.curr.id.client - dec1.curr.id.client
|
|
368
|
-
}
|
|
369
|
-
}
|
|
370
|
-
)
|
|
371
|
-
if (lazyStructDecoders.length === 0) {
|
|
372
|
-
break
|
|
373
|
-
}
|
|
374
|
-
const currDecoder = lazyStructDecoders[0]
|
|
375
|
-
// write from currDecoder until the next operation is from another client or if filler-struct
|
|
376
|
-
// then we need to reorder the decoders and find the next operation to write
|
|
377
|
-
const firstClient = /** @type {Item | GC} */ (currDecoder.curr).id.client
|
|
378
|
-
|
|
379
|
-
if (currWrite !== null) {
|
|
380
|
-
let curr = /** @type {Item | GC | null} */ (currDecoder.curr)
|
|
381
|
-
let iterated = false
|
|
382
|
-
|
|
383
|
-
// iterate until we find something that we haven't written already
|
|
384
|
-
// remember: first the high client-ids are written
|
|
385
|
-
while (curr !== null && curr.id.clock + curr.length <= currWrite.struct.id.clock + currWrite.struct.length && curr.id.client >= currWrite.struct.id.client) {
|
|
386
|
-
curr = currDecoder.next()
|
|
387
|
-
iterated = true
|
|
388
|
-
}
|
|
389
|
-
if (
|
|
390
|
-
curr === null || // current decoder is empty
|
|
391
|
-
curr.id.client !== firstClient || // check whether there is another decoder that has has updates from `firstClient`
|
|
392
|
-
(iterated && curr.id.clock > currWrite.struct.id.clock + currWrite.struct.length) // the above while loop was used and we are potentially missing updates
|
|
393
|
-
) {
|
|
394
|
-
continue
|
|
395
|
-
}
|
|
396
|
-
|
|
397
|
-
if (firstClient !== currWrite.struct.id.client) {
|
|
398
|
-
writeStructToLazyStructWriter(lazyStructEncoder, currWrite.struct, currWrite.offset, 0)
|
|
399
|
-
currWrite = { struct: curr, offset: 0 }
|
|
400
|
-
currDecoder.next()
|
|
401
|
-
} else {
|
|
402
|
-
if (currWrite.struct.id.clock + currWrite.struct.length < curr.id.clock) {
|
|
403
|
-
// @todo write currStruct & set currStruct = Skip(clock = currStruct.id.clock + currStruct.length, length = curr.id.clock - self.clock)
|
|
404
|
-
if (currWrite.struct.constructor === Skip) {
|
|
405
|
-
// extend existing skip
|
|
406
|
-
currWrite.struct.length = curr.id.clock + curr.length - currWrite.struct.id.clock
|
|
407
|
-
} else {
|
|
408
|
-
writeStructToLazyStructWriter(lazyStructEncoder, currWrite.struct, currWrite.offset, 0)
|
|
409
|
-
const diff = curr.id.clock - currWrite.struct.id.clock - currWrite.struct.length
|
|
410
|
-
/**
|
|
411
|
-
* @type {Skip}
|
|
412
|
-
*/
|
|
413
|
-
const struct = new Skip(createID(firstClient, currWrite.struct.id.clock + currWrite.struct.length), diff)
|
|
414
|
-
currWrite = { struct, offset: 0 }
|
|
415
|
-
}
|
|
416
|
-
} else { // if (currWrite.struct.id.clock + currWrite.struct.length >= curr.id.clock) {
|
|
417
|
-
const diff = currWrite.struct.id.clock + currWrite.struct.length - curr.id.clock
|
|
418
|
-
if (diff > 0) {
|
|
419
|
-
if (currWrite.struct.constructor === Skip) {
|
|
420
|
-
// prefer to slice Skip because the other struct might contain more information
|
|
421
|
-
currWrite.struct.length -= diff
|
|
422
|
-
} else {
|
|
423
|
-
curr = sliceStruct(curr, diff)
|
|
424
|
-
}
|
|
425
|
-
}
|
|
426
|
-
if (!currWrite.struct.mergeWith(/** @type {any} */ (curr))) {
|
|
427
|
-
writeStructToLazyStructWriter(lazyStructEncoder, currWrite.struct, currWrite.offset, 0)
|
|
428
|
-
currWrite = { struct: curr, offset: 0 }
|
|
429
|
-
currDecoder.next()
|
|
430
|
-
}
|
|
431
|
-
}
|
|
432
|
-
}
|
|
433
|
-
} else {
|
|
434
|
-
currWrite = { struct: /** @type {Item | GC} */ (currDecoder.curr), offset: 0 }
|
|
435
|
-
currDecoder.next()
|
|
436
|
-
}
|
|
437
|
-
for (
|
|
438
|
-
let next = currDecoder.curr;
|
|
439
|
-
next !== null && next.id.client === firstClient && next.id.clock === currWrite.struct.id.clock + currWrite.struct.length && next.constructor !== Skip;
|
|
440
|
-
next = currDecoder.next()
|
|
441
|
-
) {
|
|
442
|
-
writeStructToLazyStructWriter(lazyStructEncoder, currWrite.struct, currWrite.offset, 0)
|
|
443
|
-
currWrite = { struct: next, offset: 0 }
|
|
444
|
-
}
|
|
445
|
-
}
|
|
446
|
-
if (currWrite !== null) {
|
|
447
|
-
writeStructToLazyStructWriter(lazyStructEncoder, currWrite.struct, currWrite.offset, 0)
|
|
448
|
-
currWrite = null
|
|
340
|
+
const mergedBlockset = blocksets[0]
|
|
341
|
+
for (let i = 1; i < blocksets.length; i++) {
|
|
342
|
+
mergedBlockset.insertInto(blocksets[i])
|
|
449
343
|
}
|
|
450
|
-
|
|
451
|
-
|
|
344
|
+
const updateEncoder = new YEncoder()
|
|
345
|
+
writeBlockSet(updateEncoder, mergedBlockset)
|
|
452
346
|
const dss = updateDecoders.map(decoder => readIdSet(decoder))
|
|
453
347
|
const ds = mergeIdSets(dss)
|
|
454
348
|
writeIdSet(updateEncoder, ds)
|
|
@@ -502,8 +396,8 @@ export const diffUpdateV2 = (update, sv, YDecoder = UpdateDecoderV2, YEncoder =
|
|
|
502
396
|
* @deprecated
|
|
503
397
|
* @todo remove this in favor of intersectupdate
|
|
504
398
|
*
|
|
505
|
-
* @param {Uint8Array} update
|
|
506
|
-
* @param {Uint8Array} sv
|
|
399
|
+
* @param {Uint8Array<ArrayBuffer>} update
|
|
400
|
+
* @param {Uint8Array<ArrayBuffer>} sv
|
|
507
401
|
*/
|
|
508
402
|
export const diffUpdate = (update, sv) => diffUpdateV2(update, sv, UpdateDecoderV1, UpdateEncoderV1)
|
|
509
403
|
|
|
@@ -734,7 +628,7 @@ export const convertUpdateFormatV2ToV1 = update => convertUpdateFormat(update, f
|
|
|
734
628
|
* @param {import('./meta.js').ContentIds} contentIds - Pattern specifying which content to include
|
|
735
629
|
* @param {typeof UpdateDecoderV1 | typeof UpdateDecoderV2} [YDecoder]
|
|
736
630
|
* @param {typeof UpdateEncoderV1 | typeof UpdateEncoderV2} [YEncoder]
|
|
737
|
-
* @return {Uint8Array}
|
|
631
|
+
* @return {Uint8Array<ArrayBuffer>}
|
|
738
632
|
*/
|
|
739
633
|
export const intersectUpdateWithContentIdsV2 = (update, contentIds, YDecoder = UpdateDecoderV2, YEncoder = UpdateEncoderV2) => {
|
|
740
634
|
const { inserts, deletes } = contentIds
|
|
@@ -778,25 +672,27 @@ export const intersectUpdateWithContentIdsV2 = (update, contentIds, YDecoder = U
|
|
|
778
672
|
*
|
|
779
673
|
* @param {Uint8Array} update
|
|
780
674
|
* @param {import('./meta.js').ContentIds} contentIds - Pattern specifying which content to include
|
|
781
|
-
* @return {Uint8Array}
|
|
675
|
+
* @return {Uint8Array<ArrayBuffer>}
|
|
782
676
|
*/
|
|
783
677
|
export const intersectUpdateWithContentIds = (update, contentIds) =>
|
|
784
678
|
intersectUpdateWithContentIdsV2(update, contentIds, UpdateDecoderV1, UpdateEncoderV1)
|
|
785
679
|
|
|
786
680
|
/**
|
|
787
681
|
* @param {Uint8Array} update
|
|
682
|
+
* @param {import('./Doc.js').DocOpts} opts
|
|
788
683
|
*/
|
|
789
|
-
export const createDocFromUpdate = update => {
|
|
790
|
-
const ydoc = new Doc()
|
|
684
|
+
export const createDocFromUpdate = (update, opts = {}) => {
|
|
685
|
+
const ydoc = new Doc(opts)
|
|
791
686
|
applyUpdate(ydoc, update)
|
|
792
687
|
return ydoc
|
|
793
688
|
}
|
|
794
689
|
|
|
795
690
|
/**
|
|
796
691
|
* @param {Uint8Array} update
|
|
692
|
+
* @param {import('./Doc.js').DocOpts} opts
|
|
797
693
|
*/
|
|
798
|
-
export const createDocFromUpdateV2 = update => {
|
|
799
|
-
const ydoc = new Doc()
|
|
694
|
+
export const createDocFromUpdateV2 = (update, opts = {}) => {
|
|
695
|
+
const ydoc = new Doc(opts)
|
|
800
696
|
applyUpdateV2(ydoc, update)
|
|
801
697
|
return ydoc
|
|
802
698
|
}
|
package/src/ytype.js
CHANGED
|
@@ -1179,7 +1179,7 @@ export class YType {
|
|
|
1179
1179
|
* @param {delta.FormattingAttributes} [format]
|
|
1180
1180
|
*/
|
|
1181
1181
|
insert (index, content, format) {
|
|
1182
|
-
this.applyDelta(delta.create().retain(index).insert(/** @type {any} */ (content), format))
|
|
1182
|
+
this.applyDelta(delta.create().retain(index).insert(/** @type {any} */ (content), format).done())
|
|
1183
1183
|
}
|
|
1184
1184
|
|
|
1185
1185
|
/**
|
package/tests/testHelper.js
CHANGED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
export function readStructSet(decoder: UpdateDecoderV1 | UpdateDecoderV2, doc: Doc): StructSet;
|
|
2
|
-
export function removeRangesFromStructSet(ss: StructSet, exclude: IdSet): void;
|
|
3
|
-
export class StructSet {
|
|
4
|
-
/**
|
|
5
|
-
* @type {Map<number, StructRange>}
|
|
6
|
-
*/
|
|
7
|
-
clients: Map<number, StructRange>;
|
|
8
|
-
}
|
|
9
|
-
import { UpdateDecoderV1 } from '../internals.js';
|
|
10
|
-
import { UpdateDecoderV2 } from '../internals.js';
|
|
11
|
-
import { Doc } from '../internals.js';
|
|
12
|
-
import { IdSet } from '../internals.js';
|
|
13
|
-
declare class StructRange {
|
|
14
|
-
/**
|
|
15
|
-
* @param {Array<Item|GC>} refs
|
|
16
|
-
*/
|
|
17
|
-
constructor(refs: Array<Item | GC>);
|
|
18
|
-
i: number;
|
|
19
|
-
/**
|
|
20
|
-
* @type {Array<Item | GC>}
|
|
21
|
-
*/
|
|
22
|
-
refs: Array<Item | GC>;
|
|
23
|
-
}
|
|
24
|
-
import { Item } from '../internals.js';
|
|
25
|
-
import { GC } from '../internals.js';
|
|
26
|
-
export {};
|
|
27
|
-
//# sourceMappingURL=StructSet.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"StructSet.d.ts","sourceRoot":"","sources":["../../../src/utils/StructSet.js"],"names":[],"mappings":"AAoBO,uCAPI,eAAe,GAAG,eAAe,OACjC,GAAG,GACF,SAAS,CA6DpB;AAQM,8CAHI,SAAS,WACT,KAAK,QAgCf;AAeD;IAEI;;OAEG;IACH,SAFU,GAAG,CAAC,MAAM,EAAE,WAAW,CAAC,CAEP;CAE9B;gCAlIM,iBAAiB;gCAAjB,iBAAiB;oBAAjB,iBAAiB;sBAAjB,iBAAiB;AA8GxB;IACE;;OAEG;IACH,kBAFW,KAAK,CAAC,IAAI,GAAC,EAAE,CAAC,EAQxB;IALC,UAAU;IACV;;OAEG;IACH,MAFU,KAAK,CAAC,IAAI,GAAG,EAAE,CAAC,CAEV;CAEnB;qBAzHM,iBAAiB;mBAAjB,iBAAiB"}
|
package/src/utils/StructSet.js
DELETED
|
@@ -1,137 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
createID,
|
|
3
|
-
readItemContent,
|
|
4
|
-
findIndexCleanStart,
|
|
5
|
-
Skip,
|
|
6
|
-
UpdateDecoderV1, UpdateDecoderV2, IdSet, Doc, GC, Item, ID, // eslint-disable-line
|
|
7
|
-
} from '../internals.js'
|
|
8
|
-
|
|
9
|
-
import * as decoding from 'lib0/decoding'
|
|
10
|
-
import * as binary from 'lib0/binary'
|
|
11
|
-
import * as map from 'lib0/map'
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* @param {UpdateDecoderV1 | UpdateDecoderV2} decoder The decoder object to read data from.
|
|
15
|
-
* @param {Doc} doc
|
|
16
|
-
* @return {StructSet}
|
|
17
|
-
*
|
|
18
|
-
* @private
|
|
19
|
-
* @function
|
|
20
|
-
*/
|
|
21
|
-
export const readStructSet = (decoder, doc) => {
|
|
22
|
-
const clientRefs = new StructSet()
|
|
23
|
-
const numOfStateUpdates = decoding.readVarUint(decoder.restDecoder)
|
|
24
|
-
for (let i = 0; i < numOfStateUpdates; i++) {
|
|
25
|
-
const numberOfStructs = decoding.readVarUint(decoder.restDecoder)
|
|
26
|
-
/**
|
|
27
|
-
* @type {Array<GC|Item>}
|
|
28
|
-
*/
|
|
29
|
-
const refs = new Array(numberOfStructs)
|
|
30
|
-
const client = decoder.readClient()
|
|
31
|
-
let clock = decoding.readVarUint(decoder.restDecoder)
|
|
32
|
-
clientRefs.clients.set(client, new StructRange(refs))
|
|
33
|
-
for (let i = 0; i < numberOfStructs; i++) {
|
|
34
|
-
const info = decoder.readInfo()
|
|
35
|
-
switch (binary.BITS5 & info) {
|
|
36
|
-
case 0: { // GC
|
|
37
|
-
const len = decoder.readLen()
|
|
38
|
-
refs[i] = new GC(createID(client, clock), len)
|
|
39
|
-
clock += len
|
|
40
|
-
break
|
|
41
|
-
}
|
|
42
|
-
case 10: { // Skip Struct (nothing to apply)
|
|
43
|
-
// @todo we could reduce the amount of checks by adding Skip struct to clientRefs so we know that something is missing.
|
|
44
|
-
const len = decoding.readVarUint(decoder.restDecoder)
|
|
45
|
-
refs[i] = new Skip(createID(client, clock), len)
|
|
46
|
-
clock += len
|
|
47
|
-
break
|
|
48
|
-
}
|
|
49
|
-
default: { // Item with content
|
|
50
|
-
/**
|
|
51
|
-
* The optimized implementation doesn't use any variables because inlining variables is faster.
|
|
52
|
-
* Below a non-optimized version is shown that implements the basic algorithm with
|
|
53
|
-
* a few comments
|
|
54
|
-
*/
|
|
55
|
-
const cantCopyParentInfo = (info & (binary.BIT7 | binary.BIT8)) === 0
|
|
56
|
-
// If parent = null and neither left nor right are defined, then we know that `parent` is child of `y`
|
|
57
|
-
// and we read the next string as parentYKey.
|
|
58
|
-
// It indicates how we store/retrieve parent from `y.share`
|
|
59
|
-
// @type {string|null}
|
|
60
|
-
const struct = new Item(
|
|
61
|
-
createID(client, clock),
|
|
62
|
-
null, // left
|
|
63
|
-
(info & binary.BIT8) === binary.BIT8 ? decoder.readLeftID() : null, // origin
|
|
64
|
-
null, // right
|
|
65
|
-
(info & binary.BIT7) === binary.BIT7 ? decoder.readRightID() : null, // right origin
|
|
66
|
-
cantCopyParentInfo ? (decoder.readParentInfo() ? doc.get(decoder.readString()) : decoder.readLeftID()) : null, // parent
|
|
67
|
-
cantCopyParentInfo && (info & binary.BIT6) === binary.BIT6 ? decoder.readString() : null, // parentSub
|
|
68
|
-
readItemContent(decoder, info) // item content
|
|
69
|
-
)
|
|
70
|
-
refs[i] = struct
|
|
71
|
-
clock += struct.length
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
return clientRefs
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
/**
|
|
80
|
-
* Remove item-ranges from the StructSet.
|
|
81
|
-
*
|
|
82
|
-
* @param {StructSet} ss
|
|
83
|
-
* @param {IdSet} exclude
|
|
84
|
-
*/
|
|
85
|
-
export const removeRangesFromStructSet = (ss, exclude) => {
|
|
86
|
-
// @todo walk through ss instead to reduce iterations
|
|
87
|
-
exclude.clients.forEach((range, client) => {
|
|
88
|
-
const structs = /** @type {StructRange} */ (ss.clients.get(client))?.refs
|
|
89
|
-
if (structs != null) {
|
|
90
|
-
const firstStruct = structs[0]
|
|
91
|
-
const lastStruct = structs[structs.length - 1]
|
|
92
|
-
const idranges = range.getIds()
|
|
93
|
-
for (let i = 0; i < idranges.length; i++) {
|
|
94
|
-
const range = idranges[i]
|
|
95
|
-
let startIndex = 0
|
|
96
|
-
if (range.clock >= lastStruct.id.clock + lastStruct.length) continue
|
|
97
|
-
if (range.clock > firstStruct.id.clock) {
|
|
98
|
-
startIndex = findIndexCleanStart(null, structs, range.clock)
|
|
99
|
-
}
|
|
100
|
-
let endIndex = structs.length // must be set here, after structs is modified
|
|
101
|
-
if (range.clock + range.len <= firstStruct.id.clock) continue
|
|
102
|
-
if (range.clock + range.len < lastStruct.id.clock + lastStruct.length) {
|
|
103
|
-
endIndex = findIndexCleanStart(null, structs, range.clock + range.len)
|
|
104
|
-
}
|
|
105
|
-
if (startIndex < endIndex) {
|
|
106
|
-
structs[startIndex] = new Skip(new ID(client, range.clock), range.len)
|
|
107
|
-
const d = endIndex - startIndex
|
|
108
|
-
if (d > 1) {
|
|
109
|
-
structs.splice(startIndex + 1, d - 1)
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
})
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
class StructRange {
|
|
118
|
-
/**
|
|
119
|
-
* @param {Array<Item|GC>} refs
|
|
120
|
-
*/
|
|
121
|
-
constructor (refs) {
|
|
122
|
-
this.i = 0
|
|
123
|
-
/**
|
|
124
|
-
* @type {Array<Item | GC>}
|
|
125
|
-
*/
|
|
126
|
-
this.refs = refs
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
export class StructSet {
|
|
131
|
-
constructor () {
|
|
132
|
-
/**
|
|
133
|
-
* @type {Map<number, StructRange>}
|
|
134
|
-
*/
|
|
135
|
-
this.clients = map.create()
|
|
136
|
-
}
|
|
137
|
-
}
|