@y/y 14.0.0-20 → 14.0.0-21

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,3 +1,3 @@
1
1
  export * from "./utils/meta.js";
2
- export { Doc, Transaction, YType as Type, YEvent, Item, AbstractStruct, GC, Skip, ContentBinary, ContentDeleted, ContentDoc, ContentEmbed, ContentFormat, ContentJSON, ContentAny, ContentString, ContentType, getTypeChildren, createRelativePositionFromTypeIndex, createRelativePositionFromJSON, createAbsolutePositionFromRelativePosition, compareRelativePositions, AbsolutePosition, RelativePosition, ID, createID, compareIDs, getState, Snapshot, createSnapshot, cleanupYTextFormatting, snapshot, emptySnapshot, findRootTypeKey, findIndexSS, getItem, getItemCleanStart, getItemCleanEnd, typeMapGetSnapshot, typeMapGetAllSnapshot, createDocFromSnapshot, applyUpdate, applyUpdateV2, readUpdate, readUpdateV2, encodeStateAsUpdate, encodeStateAsUpdateV2, encodeStateVector, UndoManager, decodeSnapshot, encodeSnapshot, decodeSnapshotV2, encodeSnapshotV2, decodeStateVector, logUpdate, logUpdateV2, decodeUpdate, decodeUpdateV2, relativePositionToJSON, isParentOf, equalSnapshots, tryGc, transact, logType, mergeUpdates, mergeUpdatesV2, encodeStateVectorFromUpdate, encodeStateVectorFromUpdateV2, encodeRelativePosition, decodeRelativePosition, diffUpdate, diffUpdateV2, convertUpdateFormatV1ToV2, convertUpdateFormatV2ToV1, obfuscateUpdate, obfuscateUpdateV2, UpdateEncoderV1, UpdateEncoderV2, UpdateDecoderV1, UpdateDecoderV2, snapshotContainsUpdate, IdSet, equalIdSets, createDeleteSetFromStructStore, IdMap, createIdMap, createContentAttribute, createInsertSetFromStructStore, diffIdMap, diffIdSet, ContentAttribute, encodeIdMap, createIdMapFromIdSet, TwosetAttributionManager, noAttributionsManager, AbstractAttributionManager, iterateStructsByIdSet, createAttributionManagerFromDiff, DiffAttributionManager, createAttributionManagerFromSnapshots, SnapshotAttributionManager, createIdSet, mergeIdSets, cloneDoc, readUpdateToContentIds, readUpdateToContentIdsV2, insertIntoIdMap, insertIntoIdSet, mergeIdMaps, readIdMap, readIdSet, decodeIdMap, diffDocsToDelta, getPathTo, Attributions, filterIdMap, undoContentIds } from "./internals.js";
2
+ export { Doc, Transaction, YType as Type, YEvent, Item, AbstractStruct, GC, Skip, ContentBinary, ContentDeleted, ContentDoc, ContentEmbed, ContentFormat, ContentJSON, ContentAny, ContentString, ContentType, getTypeChildren, createRelativePositionFromTypeIndex, createRelativePositionFromJSON, createAbsolutePositionFromRelativePosition, compareRelativePositions, AbsolutePosition, RelativePosition, ID, createID, compareIDs, getState, Snapshot, createSnapshot, cleanupYTextFormatting, snapshot, emptySnapshot, findRootTypeKey, findIndexSS, getItem, getItemCleanStart, getItemCleanEnd, typeMapGetSnapshot, typeMapGetAllSnapshot, createDocFromSnapshot, applyUpdate, applyUpdateV2, readUpdate, readUpdateV2, encodeStateAsUpdate, encodeStateAsUpdateV2, encodeStateVector, UndoManager, decodeSnapshot, encodeSnapshot, decodeSnapshotV2, encodeSnapshotV2, decodeStateVector, logUpdate, logUpdateV2, decodeUpdate, decodeUpdateV2, relativePositionToJSON, isParentOf, equalSnapshots, tryGc, transact, logType, mergeUpdates, mergeUpdatesV2, encodeStateVectorFromUpdate, encodeStateVectorFromUpdateV2, encodeRelativePosition, decodeRelativePosition, diffUpdate, diffUpdateV2, convertUpdateFormatV1ToV2, convertUpdateFormatV2ToV1, obfuscateUpdate, obfuscateUpdateV2, UpdateEncoderV1, UpdateEncoderV2, UpdateDecoderV1, UpdateDecoderV2, snapshotContainsUpdate, IdSet, equalIdSets, createDeleteSetFromStructStore, IdMap, createIdMap, createContentAttribute, createInsertSetFromStructStore, diffIdMap, diffIdSet, ContentAttribute, encodeIdMap, createIdMapFromIdSet, TwosetAttributionManager, noAttributionsManager, AbstractAttributionManager, iterateStructsByIdSet, createAttributionManagerFromDiff, DiffAttributionManager, createAttributionManagerFromSnapshots, SnapshotAttributionManager, createIdSet, mergeIdSets, cloneDoc, createContentIdsFromUpdate, createContentIdsFromUpdateV2, insertIntoIdMap, insertIntoIdSet, mergeIdMaps, readIdMap, readIdSet, decodeIdMap, diffDocsToDelta, getPathTo, Attributions, filterIdMap, undoContentIds, intersectUpdateWithContentIds, intersectUpdateWithContentIdsV2, createDocFromUpdate, createDocFromUpdateV2 } from "./internals.js";
3
3
  //# sourceMappingURL=index.d.ts.map
@@ -138,7 +138,7 @@ export class IdMap<Attrs> {
138
138
  }
139
139
  export function writeIdMap<Attr>(encoder: IdSetEncoderV1 | IdSetEncoderV2, idmap: IdMap<Attr>): void;
140
140
  export function encodeIdMap(idmap: IdMap<any>): Uint8Array<ArrayBuffer>;
141
- export function readIdMap(decoder: DSDecoderV1 | DSDecoderV2): IdMap<any>;
141
+ export function readIdMap(decoder: IdSetDecoderV1 | IdSetDecoderV2): IdMap<any>;
142
142
  export function decodeIdMap(data: Uint8Array): IdMap<any>;
143
143
  export function createIdMap(): IdMap<any>;
144
144
  /**
@@ -149,7 +149,7 @@ export function createIdMap(): IdMap<any>;
149
149
  export const insertIntoIdMap: <S extends IdSet | IdMap<any>>(dest: S, src: S) => void;
150
150
  export function diffIdMap<ISet extends IdMap<any>>(set: ISet, exclude: IdSet | IdMap<any>): ISet;
151
151
  export const intersectMaps: <SetA extends IdSet | IdMap<any>, SetB extends IdSet | IdMap<any>>(setA: SetA, setB: SetB) => SetA extends IdMap<infer A> ? (SetB extends IdMap<infer B> ? IdMap<A | B> : IdMap<A>) : IdSet;
152
- export function filterIdMap<Attrs>(idmap: IdMap<Attrs>, predicate: (attr: ContentAttribute<Attrs>) => boolean): IdMap<Attrs>;
152
+ export function filterIdMap<Attrs>(idmap: IdMap<Attrs>, predicate: (attr: Array<ContentAttribute<Attrs>>) => boolean): IdMap<Attrs>;
153
153
  export type MaybeAttrRange<Attrs> = {
154
154
  clock: number;
155
155
  len: number;
@@ -159,6 +159,6 @@ import { IdSet } from '../internals.js';
159
159
  import { ID } from '../internals.js';
160
160
  import { IdSetEncoderV1 } from '../internals.js';
161
161
  import { IdSetEncoderV2 } from '../internals.js';
162
- import { DSDecoderV1 } from '../internals.js';
163
- import { DSDecoderV2 } from '../internals.js';
162
+ import { IdSetDecoderV1 } from '../internals.js';
163
+ import { IdSetDecoderV2 } from '../internals.js';
164
164
  //# sourceMappingURL=IdMap.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"IdMap.d.ts","sourceRoot":"","sources":["../../../src/utils/IdMap.js"],"names":[],"mappings":"AAmBA;;;GAGG;AACH,8BAFa,CAAC;IAGZ;;;OAGG;IACH,kBAHW,MAAM,OACN,CAAC,EAKX;IAFC,aAAgB;IAChB,OAAc;IAGhB,eAKC;CACF;AAQM,uCALM,CAAC,QACH,MAAM,OACN,CAAC,GACA,gBAAgB,CAAC,CAAC,CAAC,CAEqD;AAe7E,wCAHI,KAAK,CAAC,GAAC,CAAC,KACR,KAAK,CAAC,GAAC,CAAC,WAEgF;AASnG;;GAEG;AACH,uBAFa,KAAK;IAGhB;;;;OAIG;IACH,mBAJW,MAAM,OACN,MAAM,SACN,KAAK,CAAC,gBAAgB,CAAC,KAAK,CAAC,CAAC,EAexC;IAZC;;OAEG;IACH,uBAAkB;IAClB;;OAEG;IACH,qBAAc;IACd;;OAEG;IACH,0CAAkB;IAGpB;;;OAGG;IACH,gBAHW,MAAM,OACN,MAAM,oBAIhB;CACF;AAeM,qCAPM,KAAK,SAEP,MAAM,OACN,MAAM,SACN,KAAK,CAAC,gBAAgB,CAAC,KAAK,CAAC,CAAC,OAAC,GAC9B,cAAc,CAAC,KAAK,CAAC,CAE+E;AAEhH;;;;GAIG;AACH,wBAFa,KAAK;IAGhB;;OAEG;IACH,iBAFW,KAAK,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,EAQjC;IALC,gBAAmB;IACnB;;OAEG;IACH,aAAe;IAGjB,0BAEC;IAED;;;;OAIG;IACH,WAJW,MAAM,UACN,MAAM,SACN,KAAK,CAAC,gBAAgB,C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CAAC,CAAC,OAAC,CAAA;CAAE;sBAhG5E,iBAAiB;mBAAjB,iBAAiB;+BAAjB,iBAAiB;+BAAjB,iBAAiB;+BAAjB,iBAAiB;+BAAjB,iBAAiB"}
@@ -145,8 +145,8 @@ export function createDeleteSetFromStructStore(ss: StructStore): IdSet;
145
145
  export function _createInsertSliceFromStructs(structs: Array<GC | Item>, filterDeleted: boolean): IdRange[];
146
146
  export function createInsertSetFromStructStore(ss: import("../internals.js").StructStore, filterDeleted: boolean): IdSet;
147
147
  export function writeIdSet(encoder: IdSetEncoderV1 | IdSetEncoderV2, idSet: IdSet): void;
148
- export function readIdSet(decoder: DSDecoderV1 | DSDecoderV2): IdSet;
149
- export function readAndApplyDeleteSet(decoder: DSDecoderV1 | DSDecoderV2, transaction: Transaction, store: StructStore): Uint8Array<ArrayBuffer> | null;
148
+ export function readIdSet(decoder: IdSetDecoderV1 | IdSetDecoderV2): IdSet;
149
+ export function readAndApplyDeleteSet(decoder: IdSetDecoderV1 | IdSetDecoderV2, transaction: Transaction, store: StructStore): Uint8Array<ArrayBuffer> | null;
150
150
  export function equalIdSets(ds1: IdSet, ds2: IdSet): boolean;
151
151
  import * as traits from 'lib0/traits';
152
152
  import { ID } from '../internals.js';
@@ -158,6 +158,6 @@ import { AbstractStruct } from '../internals.js';
158
158
  import { StructStore } from '../internals.js';
159
159
  import { IdSetEncoderV1 } from '../internals.js';
160
160
  import { IdSetEncoderV2 } from '../internals.js';
161
- import { DSDecoderV1 } from '../internals.js';
162
- import { DSDecoderV2 } from '../internals.js';
161
+ import { IdSetDecoderV1 } from '../internals.js';
162
+ import { IdSetDecoderV2 } from '../internals.js';
163
163
  //# sourceMappingURL=IdSet.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"IdSet.d.ts","sourceRoot":"","sources":["../../../src/utils/IdSet.js"],"names":[],"mappings":"AAkBA;IACE;;;OAGG;IACH,mBAHW,MAAM,OACN,MAAM,EAWhB;IARC;;OAEG;IACH,OAFU,MAAM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IAAI,QACJ,IAAI,GACH,IAAI,SAAS,KAAK,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,IAAI,SAAS,KAAK,CAAC,MAAM,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,KAAK,CAwCxG;AAaM,kCARI,KAAK,UACL,MAAM,SACN,MAAM,UACN,MAAM,QAahB;AASM,wCANI,KAAK,UACL,cAAc,QAK6F;AAE/G,qCAAqC;AASrC,mDANI,WAAW,GACV,KAAK,CA8BhB;AAOM,uDAJI,KAAK,CAAC,EAAE,GAAG,IAAI,CAAC,iBAChB,OAAO,aAuBjB;AAMM,mDAHI,OAAO,iBAAiB,EAAE,WAAW,iBACrC,OAAO,SAWjB;AASM,oCANI,cAAc,GAAG,cAAc,SAC/B,KAAK,QAsBf;AASM,mCANI,cAAc,GAAG,cAAc,GAC9B,KAAK,CAwBhB;AAeM,+CARI,cAAc,GAAG,cAAc,eAC/B,WAAW,SACX,WAAW,GACV,UAAU,CAAC,WAAW,CAAC,GAAC,IAAI,CA+DvC;AAMM,iCAHI,KAAK,OACL,KAAK,WAiBf;wBAxyBuB,aAAa;mBAN9B,iBAAiB;sBAAjB,iBAAiB;4BAAjB,iBAAiB;mBAAjB,iBAAiB;qBAAjB,iBAAiB;+BAAjB,iBAAiB;4BAAjB,iBAAiB;+BAAjB,iBAAiB;+BAAjB,iBAAiB;+BAAjB,iBAAiB;+BAAjB,iBAAiB"}
@@ -17,7 +17,7 @@ export class Snapshot {
17
17
  export function equalSnapshots(snap1: Snapshot, snap2: Snapshot): boolean;
18
18
  export function encodeSnapshotV2(snapshot: Snapshot, encoder?: IdSetEncoderV1 | IdSetEncoderV2): Uint8Array;
19
19
  export function encodeSnapshot(snapshot: Snapshot): Uint8Array;
20
- export function decodeSnapshotV2(buf: Uint8Array, decoder?: DSDecoderV1 | DSDecoderV2): Snapshot;
20
+ export function decodeSnapshotV2(buf: Uint8Array, decoder?: IdSetDecoderV1 | IdSetDecoderV2): Snapshot;
21
21
  export function decodeSnapshot(buf: Uint8Array): Snapshot;
22
22
  export function createSnapshot(ds: IdSet, sm: Map<number, number>): Snapshot;
23
23
  export const emptySnapshot: Snapshot;
@@ -30,8 +30,8 @@ export function snapshotContainsUpdate(snapshot: Snapshot, update: Uint8Array):
30
30
  import { IdSet } from '../internals.js';
31
31
  import { IdSetEncoderV1 } from '../internals.js';
32
32
  import { IdSetEncoderV2 } from '../internals.js';
33
- import { DSDecoderV1 } from '../internals.js';
34
- import { DSDecoderV2 } from '../internals.js';
33
+ import { IdSetDecoderV1 } from '../internals.js';
34
+ import { IdSetDecoderV2 } from '../internals.js';
35
35
  import { Doc } from '../internals.js';
36
36
  import { Item } from '../internals.js';
37
37
  import { Transaction } from '../internals.js';
@@ -1 +1 @@
1
- {"version":3,"file":"Snapshot.d.ts","sourceRoot":"","sources":["../../../src/utils/Snapshot.js"],"names":[],"mappings":"AA0BA;IACE;;;OAGG;IACH,gBAHW,KAAK,MACL,GAAG,CAAC,MAAM,EAAC,MAAM,CAAC,EAY5B;IATC;;OAEG;IACH,IAFU,KAAK,CAEH;IACZ;;;OAGG;IACH,IAFU,GAAG,CAAC,MAAM,EAAC,MAAM,CAAC,CAEhB;CAEf;AAOM,sCAJI,QAAQ,SACR,QAAQ,GACP,OAAO,CAclB;AAOM,2CAJI,QAAQ,YACR,cAAc,GAAG,cAAc,GAC9B,UAAU,CAMrB;AAMM,yCAHI,QAAQ,GACP,UAAU,CAEoE;AAOnF,sCAJI,UAAU,YACV,WAAW,GAAG,WAAW,GACxB,QAAQ,CAInB;AAMM,oCAHI,UAAU,GACT,QAAQ,CAEoF;AAOjG,mCAJI,KAAK,MACL,GAAG,CAAC,MAAM,EAAC,MAAM,CAAC,GACjB,QAAQ,CAE0C;AAE9D,qCAAqE;AAM9D,8BAHI,GAAG,GACF,QAAQ,CAE+F;AAS5G,gCANI,IAAI,YACJ,QAAQ,GAAC,SAA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ACR,UAAU,aACV,OAAO,eAAe,GAAG,OAAO,eAAe,WAczD;AAMM,iDAHI,QAAQ,UACR,UAAU,WAEkG;sBAxMhH,iBAAiB;+BAAjB,iBAAiB;+BAAjB,iBAAiB;+BAAjB,iBAAiB;+BAAjB,iBAAiB;oBAAjB,iBAAiB;qBAAjB,iBAAiB;4BAAjB,iBAAiB;gCAAjB,iBAAiB;gCAAjB,iBAAiB"}
@@ -1,4 +1,7 @@
1
- export class DSDecoderV1 {
1
+ /**
2
+ * @typedef {IdSetDecoderV1 | IdSetDecoderV2} IdSetDecoder
3
+ */
4
+ export class IdSetDecoderV1 {
2
5
  /**
3
6
  * @param {decoding.Decoder} decoder
4
7
  */
@@ -14,7 +17,7 @@ export class DSDecoderV1 {
14
17
  */
15
18
  readDsLen(): number;
16
19
  }
17
- export class UpdateDecoderV1 extends DSDecoderV1 {
20
+ export class UpdateDecoderV1 extends IdSetDecoderV1 {
18
21
  /**
19
22
  * @return {ID}
20
23
  */
@@ -69,7 +72,7 @@ export class UpdateDecoderV1 extends DSDecoderV1 {
69
72
  */
70
73
  readKey(): string;
71
74
  }
72
- export class DSDecoderV2 {
75
+ export class IdSetDecoderV2 {
73
76
  /**
74
77
  * @param {decoding.Decoder} decoder
75
78
  */
@@ -89,7 +92,7 @@ export class DSDecoderV2 {
89
92
  */
90
93
  readDsLen(): number;
91
94
  }
92
- export class UpdateDecoderV2 extends DSDecoderV2 {
95
+ export class UpdateDecoderV2 extends IdSetDecoderV2 {
93
96
  /**
94
97
  * List of cached keys. If the keys[id] does not exist, we read a new key
95
98
  * from stringEncoder and push it to keys.
@@ -162,6 +165,7 @@ export class UpdateDecoderV2 extends DSDecoderV2 {
162
165
  */
163
166
  readKey(): string;
164
167
  }
168
+ export type IdSetDecoder = IdSetDecoderV1 | IdSetDecoderV2;
165
169
  import * as decoding from 'lib0/decoding';
166
170
  import { ID } from '../internals.js';
167
171
  //# sourceMappingURL=UpdateDecoder.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"UpdateDecoder.d.ts","sourceRoot":"","sources":["../../../src/utils/UpdateDecoder.js"],"names":[],"mappings":"AAMA;IACE;;OAEG;IACH,qBAFW,QAAQ,CAAC,OAAO,EAI1B;IADC,+CAA0B;IAG5B,sBAEC;IAED;;OAEG;IACH,eAFY,MAAM,CAIjB;IAED;;OAEG;IACH,aAFY,MAAM,CAIjB;CACF;AAED;IACE;;OAEG;IACH,cAFY,EAAE,CAIb;IAED;;OAEG;IACH,eAFY,EAAE,CAIb;IAED;;;OAGG;IACH,qBAEC;IAED;;OAEG;IACH,YAFY,MAAM,CAIjB;IAED;;OAEG;IACH,cAFY,MAAM,CAIjB;IAED;;OAEG;IACH,kBAFY,OAAO,CAIlB;IAED;;OAEG;IACH,eAFY,MAAM,CAIjB;IAED;;;;OAIG;IACH,WAFY,MAAM,CAIjB;IAED;;OAEG;IACH,WAFY,GAAG,CAId;IAED;;OAEG;IACH,WAFY,UAAU,CAIrB;IAED;;;;OAIG;IACH,YAFY,GAAG,CAId;IAED;;OAEG;IACH,WAFY,MAAM,CAIjB;CACF;AAED;IACE;;OAEG;IACH,qBAFW,QAAQ,CAAC,OAAO,EAQ1B;IALC;;OAEG;IACH,kBAAkB;IAClB,+CAA0B;IAG5B,sBAEC;IAED;;OAEG;IACH,eAFY,MAAM,CAKjB;IAED;;OAEG;IACH,aAFY,MAAM,CAMjB;CACF;AAED;IAMI;;;;;OAKG;IACH,MAFU,KAAK,CAAC,MAAM,CAAC,CAET;IAEd,+CAA6F;IAC7F,0CAAwF;IACxF,gDAA8F;IAC9F,iDAA+F;IAC/F,yCAAmG;IACnG,sCAAoF;IACpF,+CAAyG;IACzG,2CAAyF;IACzF,uCAAqF;IAGvF;;OAEG;IACH,cAFY,EAAE,CAIb;IAED;;OAEG;IACH,eAFY,EAAE,CAIb;IAED;;;OAGG;IACH,qBAEC;IAED;;OAEG;IACH,YAFY,MAAM,CAIjB;IAED;;OAEG;IACH,cAFY,MAAM,CAIjB;IAED;;OAEG;IACH,kBAFY,OAAO,CAIlB;IAED;;OAEG;IACH,eAFY,MAAM,CAIjB;IAED;;;;OAIG;IACH,WAFY,MAAM,CAIjB;IAED;;OAEG;IACH,WAFY,GAAG,CAId;IAED;;OAEG;IACH,WAFY,UAAU,CAIrB;IAED;;;;;;OAMG;IACH,YAFY,GAAG,CAId;IAED;;OAEG;IACH,WAFY,MAAM,CAWjB;CACF;0BAvRyB,eAAe;mBAGlC,iBAAiB"}
1
+ {"version":3,"file":"UpdateDecoder.d.ts","sourceRoot":"","sources":["../../../src/utils/UpdateDecoder.js"],"names":[],"mappings":"AAMA;;GAEG;AAEH;IACE;;OAEG;IACH,qBAFW,QAAQ,CAAC,OAAO,EAI1B;IADC,+CAA0B;IAG5B,sBAEC;IAED;;OAEG;IACH,eAFY,MAAM,CAIjB;IAED;;OAEG;IACH,aAFY,MAAM,CAIjB;CACF;AAED;IACE;;OAEG;IACH,cAFY,EAAE,CAIb;IAED;;OAEG;IACH,eAFY,EAAE,CAIb;IAED;;;OAGG;IACH,qBAEC;IAED;;OAEG;IACH,YAFY,MAAM,CAIjB;IAED;;OAEG;IACH,cAFY,MAAM,CAIjB;IAED;;OAEG;IACH,kBAFY,OAAO,CAIlB;IAED;;OAEG;IACH,eAFY,MAAM,CAIjB;IAED;;;;OAIG;IACH,WAFY,MAAM,CAIjB;IAED;;OAEG;IACH,WAFY,GAAG,CAId;IAED;;OAEG;IACH,WAFY,UAAU,CAIrB;IAED;;;;OAIG;IACH,YAFY,GAAG,CAId;IAED;;OAEG;IACH,WAFY,MAAM,CAIjB;CACF;AAED;IACE;;OAEG;IACH,qBAFW,QAAQ,CAAC,OAAO,EAQ1B;IALC;;OAEG;IACH,kBAAkB;IAClB,+CAA0B;IAG5B,sBAEC;IAED;;OAEG;IACH,eAFY,MAAM,CAKjB;IAED;;OAEG;IACH,aAFY,MAAM,CAMjB;CACF;AAED;IAMI;;;;;OAKG;IACH,MAFU,KAAK,CAAC,MAAM,CAAC,CAET;IAEd,+CAA6F;IAC7F,0CAAwF;IACxF,gDAA8F;IAC9F,iDAA+F;IAC/F,yCAAmG;IACnG,sCAAoF;IACpF,+CAAyG;IACzG,2CAAyF;IACzF,uCAAqF;IAGvF;;OAEG;IACH,cAFY,EAAE,CAIb;IAED;;OAEG;IACH,eAFY,EAAE,CAIb;IAED;;;OAGG;IACH,qBAEC;IAED;;OAEG;IACH,YAFY,MAAM,CAIjB;IAED;;OAEG;IACH,cAFY,MAAM,CAIjB;IAED;;OAEG;IACH,kBAFY,OAAO,CAIlB;IAED;;OAEG;IACH,eAFY,MAAM,CAIjB;IAED;;;;OAIG;IACH,WAFY,MAAM,CAIjB;IAED;;OAEG;IACH,WAFY,GAAG,CAId;IAED;;OAEG;IACH,WAFY,UAAU,CAIrB;IAED;;;;;;OAMG;IACH,YAFY,GAAG,CAId;IAED;;OAEG;IACH,WAFY,MAAM,CAWjB;CACF;2BArRY,cAAc,GAAG,cAAc;0BANlB,eAAe;mBAGlC,iBAAiB"}
@@ -8,7 +8,7 @@ export function applyUpdate(ydoc: Doc, update: Uint8Array, transactionOrigin?: a
8
8
  export function writeStateAsUpdate(encoder: UpdateEncoderV1 | UpdateEncoderV2, doc: Doc, targetStateVector?: Map<number, number>): void;
9
9
  export function encodeStateAsUpdateV2(doc: Doc, encodedTargetStateVector?: Uint8Array, encoder?: UpdateEncoderV1 | UpdateEncoderV2): Uint8Array<ArrayBuffer>;
10
10
  export function encodeStateAsUpdate(doc: Doc, encodedTargetStateVector?: Uint8Array): Uint8Array<ArrayBuffer>;
11
- export function readStateVector(decoder: DSDecoderV1 | DSDecoderV2): Map<number, number>;
11
+ export function readStateVector(decoder: IdSetDecoderV1 | IdSetDecoderV2): Map<number, number>;
12
12
  export function decodeStateVector(decodedState: Uint8Array): Map<number, number>;
13
13
  export function writeStateVector(encoder: IdSetEncoderV1 | IdSetEncoderV2, sv: Map<number, number>): IdSetEncoderV1 | IdSetEncoderV2;
14
14
  export function writeDocumentStateVector(encoder: IdSetEncoderV1 | IdSetEncoderV2, doc: Doc): IdSetEncoderV1 | IdSetEncoderV2;
@@ -23,8 +23,8 @@ import * as decoding from 'lib0/decoding';
23
23
  import { Doc } from '../internals.js';
24
24
  import { UpdateDecoderV1 } from '../internals.js';
25
25
  import { UpdateDecoderV2 } from '../internals.js';
26
- import { DSDecoderV1 } from '../internals.js';
27
- import { DSDecoderV2 } from '../internals.js';
26
+ import { IdSetDecoderV1 } from '../internals.js';
27
+ import { IdSetDecoderV2 } from '../internals.js';
28
28
  import { IdSetEncoderV1 } from '../internals.js';
29
29
  import { IdSetEncoderV2 } from '../internals.js';
30
30
  //# sourceMappingURL=encoding.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"encoding.d.ts","sourceRoot":"","sources":["../../../src/utils/encoding.js"],"names":[],"mappings":"AAkHO,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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AAG,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,CAWrB;AAUM,uCALI,GAAG,GAAC,GAAG,CAAC,MAAM,EAAC,MAAM,CAAC,GACrB,UAAU,CAIgE;gCArkB/E,iBAAiB;gCAAjB,iBAAiB;4BAAjB,iBAAiB;sBAAjB,iBAAiB;4BAAjB,iBAAiB;0BAGE,eAAe;oBAHlC,iBAAiB;gCAAjB,iBAAiB;gCAAjB,iBAAiB;+BAAjB,iBAAiB;+BAAjB,iBAAiB;+BAAjB,iBAAiB;+BAAjB,iBAAiB"}
@@ -1,4 +1,4 @@
1
- export function createContentIds(inserts: import("./IdSet.js").IdSet, deletes: import("./IdSet.js").IdSet): {
1
+ export function createContentIds(inserts?: import("./IdSet.js").IdSet, deletes?: import("./IdSet.js").IdSet): {
2
2
  inserts: idset.IdSet;
3
3
  deletes: idset.IdSet;
4
4
  };
@@ -18,6 +18,18 @@ export function excludeContentIds(content: ContentIds, excludeContent: ContentId
18
18
  inserts: idset.IdSet;
19
19
  deletes: idset.IdSet;
20
20
  };
21
+ export function excludeContentMaps(content: ContentMap, excludeContent: ContentIds | ContentMap): {
22
+ inserts: idmap.IdMap<any>;
23
+ deletes: idmap.IdMap<any>;
24
+ };
25
+ export function mergeContentMaps(contents: Array<ContentMap>): {
26
+ inserts: idmap.IdMap<any>;
27
+ deletes: idmap.IdMap<any>;
28
+ };
29
+ export function mergeContentIds(contents: Array<ContentIds>): {
30
+ inserts: idset.IdSet;
31
+ deletes: idset.IdSet;
32
+ };
21
33
  export function createContentMap(inserts: import("./IdMap.js").IdMap<any>, deletes: import("./IdMap.js").IdMap<any>): {
22
34
  inserts: idmap.IdMap<any>;
23
35
  deletes: idmap.IdMap<any>;
@@ -27,9 +39,25 @@ export function createContentMapFromContentIds(contentIds: ContentIds, insertAtt
27
39
  deletes: idmap.IdMap<any>;
28
40
  };
29
41
  export function writeContentIds(encoder: import("./UpdateEncoder.js").IdSetEncoder, contentIds: ContentIds): void;
30
- export function encodeContentIds(contentIds: ContentIds): void;
42
+ export function encodeContentIds(contentIds: ContentIds): Uint8Array<ArrayBuffer>;
43
+ export function readContentIds(decoder: import("./UpdateDecoder.js").IdSetDecoder): ContentIds;
44
+ export function decodeContentIds(buf: Uint8Array<any>): ContentIds;
31
45
  export function writeContentMap(encoder: import("./UpdateEncoder.js").IdSetEncoder, contentMap: ContentMap): void;
32
- export function encodeContentMap(contentMap: ContentMap): void;
46
+ export function readContentMap(decoder: import("./UpdateDecoder.js").IdSetDecoder): ContentMap;
47
+ export function encodeContentMap(contentMap: ContentMap): Uint8Array<ArrayBuffer>;
48
+ export function intersectContentMap(mapA: ContentMap, mapB: ContentMap | ContentIds): {
49
+ inserts: idmap.IdMap<any>;
50
+ deletes: idmap.IdMap<any>;
51
+ };
52
+ export function intersectContentIds(setA: ContentIds, setB: ContentIds | ContentMap): {
53
+ inserts: idset.IdSet;
54
+ deletes: idset.IdSet;
55
+ };
56
+ export function decodeContentMap(buf: Uint8Array<any>): ContentMap;
57
+ export function filterContentMap(contentMap: ContentMap, insertPredicate: (c: Array<idmap.ContentAttribute<any>>) => boolean, deletePredicate: (c: Array<idmap.ContentAttribute<any>>) => boolean): {
58
+ inserts: idmap.IdMap<any>;
59
+ deletes: idmap.IdMap<any>;
60
+ };
33
61
  export type ContentIds = {
34
62
  inserts: import("./IdSet.js").IdSet;
35
63
  deletes: import("./IdSet.js").IdSet;
@@ -1 +1 @@
1
- {"version":3,"file":"meta.d.ts","sourceRoot":"","sources":["../../../src/utils/meta.js"],"names":[],"mappings":"AAoBO,0CAHI,OAAO,YAAY,EAAE,KAAK,WAC1B,OAAO,YAAY,EAAE,KAAK;;;EAEuC;AAKrE,2DAFI,UAAU;;;EAKpB;AAKM,8CAFI,OAAO,UAAU,EAAE,GAAG;;;EAKhC;AAMM,sDAHI,OAAO,UAAU,EAAE,GAAG,YACtB,OAAO,UAAU,EAAE,GAAG;;;EAGwD;AAMlF,2CAHI,UAAU,kBACV,UAAU;;;EAGiH;AAM/H,0CAHI,OAAO,YAAY,EAAE,KAAK,CAAC,GAAG,CAAC,WAC/B,OAAO,YAAY,EAAE,KAAK,CAAC,GAAG,CAAC;;;EAEkC;AAOrE,2DAJI,UAAU,eACV,KAAK,CAAC,KAAK,CAAC,gBAAgB,CAAC,GAAG,CAAC,CAAC,gBAClC,KAAK,CAAC,KAAK,CAAC,gBAAgB,CAAC,GAAG,CAAC,CAAC;;;EAK5C;AAMM,yCAHI,OAAO,oBAAoB,EAAE,YAAY,cACzC,UAAU,QAKpB;AAKM,6CAFI,UAAU,QAE0E;AAQxF,yCAHI,OAAO,oBAAoB,EAAE,YAAY,cACzC,UAAU,QAKpB;AAKM,6CAFI,UAAU,QAE0E;yBAvFlF;IAAE,OAAO,EAAE,OAAO,YAAY,EAAE,KAAK,CAAC;IAAC,OAAO,EAAE,OAAO,YAAY,EAAE,KAAK,CAAA;CAAE;yBAI5E;IAAE,OAAO,EAAE,OAAO,YAAY,EAAE,KAAK,CA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,0CAHI,UAAU,QACV,UAAU,GAAC,UAAU;;;EAK/B;AAMM,0CAHI,UAAU,QACV,UAAU,GAAC,UAAU;;;EAK/B;AAKM,sCAFI,UAAU,CAAC,GAAG,CAAC,cAE4E;AAQ/F,6CAJI,UAAU,mBACV,CAAC,CAAC,EAAC,KAAK,CAAC,KAAK,CAAC,gBAAgB,CAAC,GAAG,CAAC,CAAC,KAAG,OAAO,mBAC/C,CAAC,CAAC,EAAC,KAAK,CAAC,KAAK,CAAC,gBAAgB,CAAC,GAAG,CAAC,CAAC,KAAG,OAAO;;;EAEwJ;yBAlLrM;IAAE,OAAO,EAAE,OAAO,YAAY,EAAE,KAAK,CAAC;IAAC,OAAO,EAAE,OAAO,YAAY,EAAE,KAAK,CAAA;CAAE;yBAI5E;IAAE,OAAO,EAAE,OAAO,YAAY,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC;IAAC,OAAO,EAAE,OAAO,YAAY,EAAE,KAAK,CAAC,GAAG,CAAC,CAAA;CAAE;uBAV5E,YAAY;uBADZ,YAAY"}
@@ -20,11 +20,11 @@ export function logUpdate(update: Uint8Array): void;
20
20
  export function logUpdateV2(update: Uint8Array, YDecoder?: typeof UpdateDecoderV2 | typeof UpdateDecoderV1): void;
21
21
  export function decodeUpdate(update: Uint8Array): {
22
22
  structs: (GC | Item | Skip)[];
23
- ds: import("./IdSet.js").IdSet;
23
+ ds: idset.IdSet;
24
24
  };
25
25
  export function decodeUpdateV2(update: Uint8Array, YDecoder?: typeof UpdateDecoderV2 | typeof UpdateDecoderV1): {
26
26
  structs: (GC | Item | Skip)[];
27
- ds: import("./IdSet.js").IdSet;
27
+ ds: idset.IdSet;
28
28
  };
29
29
  export class LazyStructWriter {
30
30
  /**
@@ -53,8 +53,8 @@ export class LazyStructWriter {
53
53
  export function mergeUpdates(updates: Array<Uint8Array<ArrayBuffer>>): Uint8Array<ArrayBuffer>;
54
54
  export function encodeStateVectorFromUpdateV2(update: Uint8Array, YEncoder?: typeof IdSetEncoderV1 | typeof IdSetEncoderV2, YDecoder?: typeof UpdateDecoderV1 | typeof UpdateDecoderV2): Uint8Array;
55
55
  export function encodeStateVectorFromUpdate(update: Uint8Array): Uint8Array;
56
- export function readUpdateToContentIdsV2(update: Uint8Array, YDecoder?: typeof UpdateDecoderV2 | typeof UpdateDecoderV1): import("./meta.js").ContentIds;
57
- export function readUpdateToContentIds(update: Uint8Array): import("./meta.js").ContentIds;
56
+ export function createContentIdsFromUpdateV2(update: Uint8Array, YDecoder?: typeof UpdateDecoderV2 | typeof UpdateDecoderV1): import("./meta.js").ContentIds;
57
+ export function createContentIdsFromUpdate(update: Uint8Array): import("./meta.js").ContentIds;
58
58
  export function mergeUpdatesV2(updates: Array<Uint8Array<ArrayBuffer>>, YDecoder?: typeof UpdateDecoderV1 | typeof UpdateDecoderV2, YEncoder?: typeof UpdateEncoderV1 | typeof UpdateEncoderV2): Uint8Array<ArrayBuffer>;
59
59
  export function diffUpdateV2(update: Uint8Array, sv: Uint8Array, YDecoder?: typeof UpdateDecoderV1 | typeof UpdateDecoderV2, YEncoder?: typeof UpdateEncoderV1 | typeof UpdateEncoderV2): Uint8Array<ArrayBuffer>;
60
60
  export function diffUpdate(update: Uint8Array, sv: Uint8Array): Uint8Array<ArrayBuffer>;
@@ -63,6 +63,10 @@ export function obfuscateUpdate(update: Uint8Array, opts?: ObfuscatorOptions): U
63
63
  export function obfuscateUpdateV2(update: Uint8Array, opts?: ObfuscatorOptions): Uint8Array<ArrayBuffer>;
64
64
  export function convertUpdateFormatV1ToV2(update: Uint8Array): Uint8Array<ArrayBuffer>;
65
65
  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;
66
70
  export type ObfuscatorOptions = {
67
71
  formatting?: boolean | undefined;
68
72
  subdocs?: boolean | undefined;
@@ -76,8 +80,10 @@ import { Item } from '../internals.js';
76
80
  import { Skip } from '../internals.js';
77
81
  import { UpdateDecoderV1 } from '../internals.js';
78
82
  import { UpdateDecoderV2 } from '../internals.js';
83
+ import * as idset from './IdSet.js';
79
84
  import { UpdateEncoderV2 } from '../internals.js';
80
85
  import { UpdateEncoderV1 } from '../internals.js';
81
86
  import { IdSetEncoderV1 } from '../internals.js';
82
87
  import { IdSetEncoderV2 } from '../internals.js';
88
+ import { Doc } from '../internals.js';
83
89
  //# sourceMappingURL=updates.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"updates.d.ts","sourceRoot":"","sources":["../../../src/utils/updates.js"],"names":[],"mappings":"AAkFA;IACE;;;OAGG;IACH,qBAHW,eAAe,GAAG,eAAe,eACjC,OAAO,EAWjB;IARC,gDAA6C;IAC7C;;OAEG;IACH,MAFU,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,EAAE,CAEjB;IAChB,cAAiB;IACjB,qBAA8B;IAIhC;;OAEG;IACH,QAFY,IAAI,GAAG,EAAE,GAAG,IAAI,GAAE,IAAI,CAQjC;CACF;AAMM,kCAHI,UAAU,QAGkD;AAMhE,oCAHI,UAAU,aACV,OAAO,eAAe,GAAG,OAAO,eAAe,QAYzD;AAMM,qCAHI,UAAU;;;EAG0D;AAOxE,uCAJI,UAAU,aACV,OAAO,eAAe,GAAG,OAAO,eAAe;;;EAczD;AAED;IACE;;OAEG;IACH,qBAFW,eAAe,GAAG,eAAe,EAkB3C;IAfC,mBAAmB;IACnB,mBAAmB;IACnB,gBAAgB;IAChB,2CAAsB;IACtB;;;;;;;;;OASG;IACH,eAFU,KAAK,CAAC;QAAE,OAAO,EAAE,MA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UAAU,CAAC,WAAW,CAAC,CAAC,aAC9B,OAAO,eAAe,GAAG,OAAO,eAAe,aAC/C,OAAO,eAAe,GAAG,OAAO,eAAe,GAC9C,UAAU,CAAC,WAAW,CAAC,CAgIlC;AASM,qCALI,UAAU,MACV,UAAU,aACV,OAAO,eAAe,GAAG,OAAO,eAAe,aAC/C,OAAO,eAAe,GAAG,OAAO,eAAe,2BAoCzD;AASM,mCAHI,UAAU,MACV,UAAU,2BAE+E;AAyE7F,4CALI,UAAU,oBACV,CAAS,IAAY,EAAZ,IAAI,GAAC,EAAE,GAAC,IAAI,KAAE,IAAI,GAAC,EAAE,GAAC,IAAI,YACnC,OAAO,eAAe,GAAG,OAAO,eAAe,YAC/C,OAAO,eAAe,GAAG,OAAO,eAAe,2BAczD;AAgHM,wCAHI,UAAU,SACV,iBAAiB,2BAE0G;AAM/H,0CAHI,UAAU,SACV,iBAAiB,2BAE4G;AAKjI,kDAFI,UAAU,2BAEiG;AAK/G,kDAFI,UAAU,2BAEiG;AAkB/G,wDANI,UAAU,cACV,OAAO,WAAW,EAAE,UAAU,aAC9B,OAAO,eAAe,GAAG,OAAO,eAAe,aAC/C,OAAO,eAAe,GAAG,OAAO,eAAe,GAC9C,UAAU,CAqCrB;AASM,sDAJI,UAAU,cACV,OAAO,WAAW,EAAE,UAAU,GAC7B,UAAU,CAGiE;AAKhF,4CAFI,UAAU,OAMpB;AAKM,8CAFI,UAAU,OAMpB;;;;;;;;;mBA1vBM,iBAAiB;qBAAjB,iBAAiB;qBAAjB,iBAAiB;gCAAjB,iBAAiB;gCAAjB,iBAAiB;uBAED,YAAY;gCAF5B,iBAAiB;gCAAjB,iBAAiB;+BAAjB,iBAAiB;+BAAjB,iBAAiB;oBAAjB,iBAAiB"}
@@ -4,6 +4,7 @@ export function testMergeUpdates1(_tc: t.TestCase): void;
4
4
  export function testMergeUpdates2(_tc: t.TestCase): void;
5
5
  export function testMergePendingUpdates(_tc: t.TestCase): void;
6
6
  export function testObfuscateUpdates(_tc: t.TestCase): void;
7
+ export function testIntersectDoc(): void;
7
8
  export type Enc = {
8
9
  mergeUpdates: (arg0: Array<Uint8Array<ArrayBuffer>>) => Uint8Array<ArrayBuffer>;
9
10
  encodeStateAsUpdate: (arg0: Y.Doc) => Uint8Array<ArrayBuffer>;
@@ -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;;kBA5Va,CAAS,IAA8B,EAA9B,KAAK,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC,KAAE,UAAU,CAAC,WAAW,CAAC;yBAChE,CAAS,IAAK,EAAL,CAAC,CAAC,GAAG,KAAE,UAAU,CAAC,WAAW,CAAC;iBACvC,CAAS,IAAK,EAAL,CAAC,CAAC,GAAG,EAAE,IAAU,EAAV,UAAU,KAAE,IAAI;eAChC,CAAS,IAAU,EAAV,UAAU,KAAE,IAAI;4BACzB,CAAS,IAAU,EAAV,UAAU,KAAE;QAAC,OAAO,EAAC,CAAC,CAAC,KAAK,CAAC;QAAA,OAAO,EAAC,CAAC,CAAC,KAAK,CAAA;KAAC;uBACtD,CAAS,IAAK,EAAL,CAAC,CAAC,GAAG,KAAE,UAAU;iCAC1B,CAAS,IAAU,EAAV,UAAU,KAAE,UAAU;qBAC/B,QAAQ,GAAC,UAAU;iBACnB,MAAM;gBACN,CAAS,IAAU,EAAV,UAAU,EAAE,IAAU,EAAV,UAAU,KAAE,UAAU;;mBArBtC,cAAc;mBACd,iBAAiB"}
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;;kBAxWa,CAAS,IAA8B,EAA9B,KAAK,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC,KAAE,UAAU,CAAC,WAAW,CAAC;yBAChE,CAAS,IAAK,EAAL,CAAC,CAAC,GAAG,KAAE,UAAU,CAAC,WAAW,CAAC;iBACvC,CAAS,IAAK,EAAL,CAAC,CAAC,GAAG,EAAE,IAAU,EAAV,UAAU,KAAE,IAAI;eAChC,CAAS,IAAU,EAAV,UAAU,KAAE,IAAI;4BACzB,CAAS,IAAU,EAAV,UAAU,KAAE;QAAC,OAAO,EAAC,CAAC,CAAC,KAAK,CAAC;QAAA,OAAO,EAAC,CAAC,CAAC,KAAK,CAAA;KAAC;uBACtD,CAAS,IAAK,EAAL,CAAC,CAAC,GAAG,KAAE,UAAU;iCAC1B,CAAS,IAAU,EAAV,UAAU,KAAE,UAAU;qBAC/B,QAAQ,GAAC,UAAU;iBACnB,MAAM;gBACN,CAAS,IAAU,EAAV,UAAU,EAAE,IAAU,EAAV,UAAU,KAAE,UAAU;;mBArBtC,cAAc;mBACd,iBAAiB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@y/y",
3
- "version": "14.0.0-20",
3
+ "version": "14.0.0-21",
4
4
  "description": "Shared Editing Library",
5
5
  "types": "./dist/src/index.d.ts",
6
6
  "type": "module",
package/src/index.js CHANGED
@@ -106,8 +106,8 @@ export {
106
106
  createIdSet,
107
107
  mergeIdSets,
108
108
  cloneDoc,
109
- readUpdateToContentIds,
110
- readUpdateToContentIdsV2,
109
+ createContentIdsFromUpdate,
110
+ createContentIdsFromUpdateV2,
111
111
  insertIntoIdMap,
112
112
  insertIntoIdSet,
113
113
  mergeIdMaps,
@@ -118,7 +118,11 @@ export {
118
118
  getPathTo,
119
119
  Attributions,
120
120
  filterIdMap,
121
- undoContentIds
121
+ undoContentIds,
122
+ intersectUpdateWithContentIds,
123
+ intersectUpdateWithContentIdsV2,
124
+ createDocFromUpdate,
125
+ createDocFromUpdateV2
122
126
  } from './internals.js'
123
127
 
124
128
  export * from './utils/meta.js'
@@ -3,7 +3,7 @@ import {
3
3
  findIndexInIdRanges,
4
4
  findRangeStartInIdRanges,
5
5
  _deleteRangeFromIdSet,
6
- DSDecoderV1, DSDecoderV2, IdSetEncoderV1, IdSetEncoderV2, IdSet, ID, // eslint-disable-line
6
+ IdSetDecoderV1, IdSetDecoderV2, IdSetEncoderV1, IdSetEncoderV2, IdSet, ID, // eslint-disable-line
7
7
  _insertIntoIdSet,
8
8
  _intersectSets,
9
9
  createIdSet,
@@ -534,7 +534,7 @@ export const encodeIdMap = idmap => {
534
534
  }
535
535
 
536
536
  /**
537
- * @param {DSDecoderV1 | DSDecoderV2} decoder
537
+ * @param {IdSetDecoderV1 | IdSetDecoderV2} decoder
538
538
  * @return {IdMap<any>}
539
539
  *
540
540
  * @private
@@ -596,7 +596,7 @@ export const readIdMap = decoder => {
596
596
  * @param {Uint8Array} data
597
597
  * @return {IdMap<any>}
598
598
  */
599
- export const decodeIdMap = data => readIdMap(new DSDecoderV2(decoding.createDecoder(data)))
599
+ export const decodeIdMap = data => readIdMap(new IdSetDecoderV2(decoding.createDecoder(data)))
600
600
 
601
601
  /**
602
602
  * @template Attrs
@@ -645,7 +645,7 @@ export const intersectMaps = _intersectSets
645
645
  *
646
646
  * @template Attrs
647
647
  * @param {IdMap<Attrs>} idmap
648
- * @param {(attr: ContentAttribute<Attrs>) => boolean} predicate
648
+ * @param {(attr: Array<ContentAttribute<Attrs>>) => boolean} predicate
649
649
  * @return {IdMap<Attrs>}
650
650
  */
651
651
  export const filterIdMap = (idmap, predicate) => {
@@ -656,7 +656,7 @@ export const filterIdMap = (idmap, predicate) => {
656
656
  */
657
657
  const attrRanges = []
658
658
  ranges.getIds().forEach((range) => {
659
- if (range.attrs.some(predicate)) {
659
+ if (predicate(range.attrs)) {
660
660
  const rangeCpy = range.copyWith(range.clock, range.len)
661
661
  attrRanges.push(rangeCpy)
662
662
  rangeCpy.attrs.forEach(attr => {
@@ -7,7 +7,7 @@ import {
7
7
  IdMap,
8
8
  AttrRanges,
9
9
  AttrRange,
10
- Skip, AbstractStruct, DSDecoderV1, IdSetEncoderV1, DSDecoderV2, IdSetEncoderV2, Item, GC, StructStore, Transaction, ID // eslint-disable-line
10
+ Skip, AbstractStruct, IdSetDecoderV1, IdSetEncoderV1, IdSetDecoderV2, IdSetEncoderV2, Item, GC, StructStore, Transaction, ID // eslint-disable-line
11
11
  } from '../internals.js'
12
12
 
13
13
  import * as array from 'lib0/array'
@@ -703,7 +703,7 @@ export const writeIdSet = (encoder, idSet) => {
703
703
  }
704
704
 
705
705
  /**
706
- * @param {DSDecoderV1 | DSDecoderV2} decoder
706
+ * @param {IdSetDecoderV1 | IdSetDecoderV2} decoder
707
707
  * @return {IdSet}
708
708
  *
709
709
  * @private
@@ -735,7 +735,7 @@ export const readIdSet = decoder => {
735
735
  */
736
736
 
737
737
  /**
738
- * @param {DSDecoderV1 | DSDecoderV2} decoder
738
+ * @param {IdSetDecoderV1 | IdSetDecoderV2} decoder
739
739
  * @param {Transaction} transaction
740
740
  * @param {StructStore} store
741
741
  * @return {Uint8Array<ArrayBuffer>|null} Returns a v2 update containing all deletes that couldn't be applied yet; or null if all deletes were applied successfully.
@@ -15,7 +15,7 @@ import {
15
15
  applyUpdateV2,
16
16
  LazyStructReader,
17
17
  equalIdSets,
18
- UpdateDecoderV1, UpdateDecoderV2, IdSetEncoderV1, IdSetEncoderV2, DSDecoderV1, DSDecoderV2, Transaction, Doc, IdSet, Item, // eslint-disable-line
18
+ UpdateDecoderV1, UpdateDecoderV2, IdSetEncoderV1, IdSetEncoderV2, IdSetDecoderV1, IdSetDecoderV2, Transaction, Doc, IdSet, Item, // eslint-disable-line
19
19
  mergeIdSets
20
20
  } from '../internals.js'
21
21
 
@@ -80,10 +80,10 @@ export const encodeSnapshot = snapshot => encodeSnapshotV2(snapshot, new IdSetEn
80
80
 
81
81
  /**
82
82
  * @param {Uint8Array} buf
83
- * @param {DSDecoderV1 | DSDecoderV2} [decoder]
83
+ * @param {IdSetDecoderV1 | IdSetDecoderV2} [decoder]
84
84
  * @return {Snapshot}
85
85
  */
86
- export const decodeSnapshotV2 = (buf, decoder = new DSDecoderV2(decoding.createDecoder(buf))) => {
86
+ export const decodeSnapshotV2 = (buf, decoder = new IdSetDecoderV2(decoding.createDecoder(buf))) => {
87
87
  return new Snapshot(readIdSet(decoder), readStateVector(decoder))
88
88
  }
89
89
 
@@ -91,7 +91,7 @@ export const decodeSnapshotV2 = (buf, decoder = new DSDecoderV2(decoding.createD
91
91
  * @param {Uint8Array} buf
92
92
  * @return {Snapshot}
93
93
  */
94
- export const decodeSnapshot = buf => decodeSnapshotV2(buf, new DSDecoderV1(decoding.createDecoder(buf)))
94
+ export const decodeSnapshot = buf => decodeSnapshotV2(buf, new IdSetDecoderV1(decoding.createDecoder(buf)))
95
95
 
96
96
  /**
97
97
  * @param {IdSet} ds
@@ -4,7 +4,11 @@ import {
4
4
  ID, createID
5
5
  } from '../internals.js'
6
6
 
7
- export class DSDecoderV1 {
7
+ /**
8
+ * @typedef {IdSetDecoderV1 | IdSetDecoderV2} IdSetDecoder
9
+ */
10
+
11
+ export class IdSetDecoderV1 {
8
12
  /**
9
13
  * @param {decoding.Decoder} decoder
10
14
  */
@@ -31,7 +35,7 @@ export class DSDecoderV1 {
31
35
  }
32
36
  }
33
37
 
34
- export class UpdateDecoderV1 extends DSDecoderV1 {
38
+ export class UpdateDecoderV1 extends IdSetDecoderV1 {
35
39
  /**
36
40
  * @return {ID}
37
41
  */
@@ -122,7 +126,7 @@ export class UpdateDecoderV1 extends DSDecoderV1 {
122
126
  }
123
127
  }
124
128
 
125
- export class DSDecoderV2 {
129
+ export class IdSetDecoderV2 {
126
130
  /**
127
131
  * @param {decoding.Decoder} decoder
128
132
  */
@@ -156,7 +160,7 @@ export class DSDecoderV2 {
156
160
  }
157
161
  }
158
162
 
159
- export class UpdateDecoderV2 extends DSDecoderV2 {
163
+ export class UpdateDecoderV2 extends IdSetDecoderV2 {
160
164
  /**
161
165
  * @param {decoding.Decoder} decoder
162
166
  */
@@ -26,7 +26,7 @@ import {
26
26
  UpdateEncoderV1,
27
27
  UpdateEncoderV2,
28
28
  IdSetEncoderV2,
29
- DSDecoderV1,
29
+ IdSetDecoderV1,
30
30
  IdSetEncoderV1,
31
31
  mergeUpdates,
32
32
  mergeUpdatesV2,
@@ -36,7 +36,7 @@ import {
36
36
  readStructSet,
37
37
  removeRangesFromStructSet,
38
38
  createIdSet,
39
- StructSet, IdSet, DSDecoderV2, Doc, Transaction, GC, Item, StructStore, // eslint-disable-line
39
+ StructSet, IdSet, IdSetDecoderV2, Doc, Transaction, GC, Item, StructStore, // eslint-disable-line
40
40
  createID,
41
41
  IdRange
42
42
  } from '../internals.js'
@@ -536,7 +536,7 @@ export const encodeStateAsUpdate = (doc, encodedTargetStateVector) => encodeStat
536
536
  /**
537
537
  * Read state vector from Decoder and return as Map
538
538
  *
539
- * @param {DSDecoderV1 | DSDecoderV2} decoder
539
+ * @param {IdSetDecoderV1 | IdSetDecoderV2} decoder
540
540
  * @return {Map<number,number>} Maps `client` to the number next expected `clock` from that client.
541
541
  *
542
542
  * @function
@@ -570,7 +570,7 @@ export const readStateVector = decoder => {
570
570
  *
571
571
  * @function
572
572
  */
573
- export const decodeStateVector = decodedState => readStateVector(new DSDecoderV1(decoding.createDecoder(decodedState)))
573
+ export const decodeStateVector = decodedState => readStateVector(new IdSetDecoderV1(decoding.createDecoder(decodedState)))
574
574
 
575
575
  /**
576
576
  * @param {IdSetEncoderV1 | IdSetEncoderV2} encoder
package/src/utils/meta.js CHANGED
@@ -5,6 +5,8 @@
5
5
  import * as idmap from './IdMap.js'
6
6
  import * as idset from './IdSet.js'
7
7
  import { IdSetEncoderV2 } from './UpdateEncoder.js'
8
+ import { IdSetDecoderV2 } from './UpdateDecoder.js'
9
+ import * as decoding from 'lib0/decoding'
8
10
 
9
11
  /**
10
12
  * @typedef {{ inserts: import('./IdSet.js').IdSet, deletes: import('./IdSet.js').IdSet }} ContentIds
@@ -18,7 +20,7 @@ import { IdSetEncoderV2 } from './UpdateEncoder.js'
18
20
  * @param {import('./IdSet.js').IdSet} inserts
19
21
  * @param {import('./IdSet.js').IdSet} deletes
20
22
  */
21
- export const createContentIds = (inserts, deletes) => ({ inserts, deletes })
23
+ export const createContentIds = (inserts = idset.createIdSet(), deletes = idset.createIdSet()) => ({ inserts, deletes })
22
24
 
23
25
  /**
24
26
  * @param {ContentMap} contentMap
@@ -50,6 +52,31 @@ export const createContentIdsFromDocDiff = (ydocPrev, ydocNext) =>
50
52
  export const excludeContentIds = (content, excludeContent) =>
51
53
  createContentIds(idset.diffIdSet(content.inserts, excludeContent.inserts), idset.diffIdSet(content.deletes, excludeContent.deletes))
52
54
 
55
+ /**
56
+ * @param {ContentMap} content
57
+ * @param {ContentIds | ContentMap} excludeContent
58
+ */
59
+ export const excludeContentMaps = (content, excludeContent) => createContentMap(
60
+ idmap.diffIdMap(content.inserts, excludeContent.inserts),
61
+ idmap.diffIdMap(content.deletes, excludeContent.deletes)
62
+ )
63
+
64
+ /**
65
+ * @param {Array<ContentMap>} contents
66
+ */
67
+ export const mergeContentMaps = contents => createContentMap(
68
+ idmap.mergeIdMaps(contents.map(c => c.inserts)),
69
+ idmap.mergeIdMaps(contents.map(c => c.deletes))
70
+ )
71
+
72
+ /**
73
+ * @param {Array<ContentIds>} contents
74
+ */
75
+ export const mergeContentIds = contents => createContentIds(
76
+ idset.mergeIdSets(contents.map(c => c.inserts)),
77
+ idset.mergeIdSets(contents.map(c => c.deletes))
78
+ )
79
+
53
80
  /**
54
81
  * @param {import('./IdMap.js').IdMap<any>} inserts
55
82
  * @param {import('./IdMap.js').IdMap<any>} deletes
@@ -78,7 +105,27 @@ export const writeContentIds = (encoder, contentIds) => {
78
105
  /**
79
106
  * @param {ContentIds} contentIds
80
107
  */
81
- export const encodeContentIds = contentIds => writeContentIds(new IdSetEncoderV2(), contentIds)
108
+ export const encodeContentIds = contentIds => {
109
+ const encoder = new IdSetEncoderV2()
110
+ writeContentIds(encoder, contentIds)
111
+ return encoder.toUint8Array()
112
+ }
113
+
114
+ /**
115
+ * @todo this encoding needs to be heavily optimized for production
116
+ *
117
+ * @param {import('./UpdateDecoder.js').IdSetDecoder} decoder
118
+ * @return {ContentIds}
119
+ */
120
+ export const readContentIds = decoder => createContentIds(
121
+ idset.readIdSet(decoder),
122
+ idset.readIdSet(decoder)
123
+ )
124
+
125
+ /**
126
+ * @param {Uint8Array<any>} buf
127
+ */
128
+ export const decodeContentIds = buf => readContentIds(new IdSetDecoderV2(decoding.createDecoder(buf)))
82
129
 
83
130
  /**
84
131
  * @todo this encoding needs to be heavily optimized for production
@@ -92,6 +139,52 @@ export const writeContentMap = (encoder, contentMap) => {
92
139
  }
93
140
 
94
141
  /**
142
+ * @todo this encoding needs to be heavily optimized for production
143
+ *
144
+ * @param {import('./UpdateDecoder.js').IdSetDecoder} decoder
145
+ * @return {ContentMap} contentMap
146
+ */
147
+ export const readContentMap = (decoder) => createContentMap(
148
+ idmap.readIdMap(decoder),
149
+ idmap.readIdMap(decoder)
150
+ )
151
+
152
+ /**
153
+ * @param {ContentMap} contentMap
154
+ */
155
+ export const encodeContentMap = contentMap => {
156
+ const encoder = new IdSetEncoderV2()
157
+ writeContentMap(encoder, contentMap)
158
+ return encoder.toUint8Array()
159
+ }
160
+
161
+ /**
162
+ * @param {ContentMap} mapA
163
+ * @param {ContentMap|ContentIds} mapB
164
+ */
165
+ export const intersectContentMap = (mapA, mapB) => createContentMap(
166
+ idmap.intersectMaps(mapA.inserts, mapB.inserts),
167
+ idmap.intersectMaps(mapA.deletes, mapB.deletes)
168
+ )
169
+
170
+ /**
171
+ * @param {ContentIds} setA
172
+ * @param {ContentIds|ContentMap} setB
173
+ */
174
+ export const intersectContentIds = (setA, setB) => createContentIds(
175
+ idset.intersectSets(setA.inserts, setB.inserts),
176
+ idset.intersectSets(setA.deletes, setB.deletes)
177
+ )
178
+
179
+ /**
180
+ * @param {Uint8Array<any>} buf
181
+ */
182
+ export const decodeContentMap = buf => readContentMap(new IdSetDecoderV2(decoding.createDecoder(buf)))
183
+
184
+ /**
185
+ * @todo filter by array of content instead
95
186
  * @param {ContentMap} contentMap
187
+ * @param {(c:Array<idmap.ContentAttribute<any>>)=>boolean} insertPredicate
188
+ * @param {(c:Array<idmap.ContentAttribute<any>>)=>boolean} deletePredicate
96
189
  */
97
- export const encodeContentMap = contentMap => writeContentMap(new IdSetEncoderV2(), contentMap)
190
+ export const filterContentMap = (contentMap, insertPredicate, deletePredicate) => createContentMap(idmap.filterIdMap(contentMap.inserts, insertPredicate), idmap.filterIdMap(contentMap.deletes, deletePredicate))
@@ -33,9 +33,14 @@ import {
33
33
  UpdateEncoderV1,
34
34
  UpdateEncoderV2,
35
35
  writeIdSet,
36
- createIdSet
36
+ createIdSet,
37
+ Doc,
38
+ applyUpdate,
39
+ applyUpdateV2
37
40
  } from '../internals.js'
38
41
 
42
+ import * as idset from './IdSet.js'
43
+
39
44
  /**
40
45
  * @param {UpdateDecoderV1 | UpdateDecoderV2} decoder
41
46
  */
@@ -248,7 +253,7 @@ export const encodeStateVectorFromUpdate = update => encodeStateVectorFromUpdate
248
253
  * @param {typeof UpdateDecoderV2 | typeof UpdateDecoderV1} [YDecoder]
249
254
  * @return {import('./meta.js').ContentIds}
250
255
  */
251
- export const readUpdateToContentIdsV2 = (update, YDecoder = UpdateDecoderV2) => {
256
+ export const createContentIdsFromUpdateV2 = (update, YDecoder = UpdateDecoderV2) => {
252
257
  const updateDecoder = new YDecoder(decoding.createDecoder(update))
253
258
  const lazyDecoder = new LazyStructReader(updateDecoder, true)
254
259
  const inserts = createIdSet()
@@ -280,7 +285,7 @@ export const readUpdateToContentIdsV2 = (update, YDecoder = UpdateDecoderV2) =>
280
285
  * @param {Uint8Array} update
281
286
  * @return {import('./meta.js').ContentIds}
282
287
  */
283
- export const readUpdateToContentIds = update => readUpdateToContentIdsV2(update, UpdateDecoderV1)
288
+ export const createContentIdsFromUpdate = update => createContentIdsFromUpdateV2(update, UpdateDecoderV1)
284
289
 
285
290
  /**
286
291
  * This method is intended to slice any kind of struct and retrieve the right part.
@@ -390,7 +395,7 @@ export const mergeUpdatesV2 = (updates, YDecoder = UpdateDecoderV2, YEncoder = U
390
395
  }
391
396
 
392
397
  if (firstClient !== currWrite.struct.id.client) {
393
- writeStructToLazyStructWriter(lazyStructEncoder, currWrite.struct, currWrite.offset)
398
+ writeStructToLazyStructWriter(lazyStructEncoder, currWrite.struct, currWrite.offset, 0)
394
399
  currWrite = { struct: curr, offset: 0 }
395
400
  currDecoder.next()
396
401
  } else {
@@ -400,7 +405,7 @@ export const mergeUpdatesV2 = (updates, YDecoder = UpdateDecoderV2, YEncoder = U
400
405
  // extend existing skip
401
406
  currWrite.struct.length = curr.id.clock + curr.length - currWrite.struct.id.clock
402
407
  } else {
403
- writeStructToLazyStructWriter(lazyStructEncoder, currWrite.struct, currWrite.offset)
408
+ writeStructToLazyStructWriter(lazyStructEncoder, currWrite.struct, currWrite.offset, 0)
404
409
  const diff = curr.id.clock - currWrite.struct.id.clock - currWrite.struct.length
405
410
  /**
406
411
  * @type {Skip}
@@ -419,7 +424,7 @@ export const mergeUpdatesV2 = (updates, YDecoder = UpdateDecoderV2, YEncoder = U
419
424
  }
420
425
  }
421
426
  if (!currWrite.struct.mergeWith(/** @type {any} */ (curr))) {
422
- writeStructToLazyStructWriter(lazyStructEncoder, currWrite.struct, currWrite.offset)
427
+ writeStructToLazyStructWriter(lazyStructEncoder, currWrite.struct, currWrite.offset, 0)
423
428
  currWrite = { struct: curr, offset: 0 }
424
429
  currDecoder.next()
425
430
  }
@@ -434,12 +439,12 @@ export const mergeUpdatesV2 = (updates, YDecoder = UpdateDecoderV2, YEncoder = U
434
439
  next !== null && next.id.client === firstClient && next.id.clock === currWrite.struct.id.clock + currWrite.struct.length && next.constructor !== Skip;
435
440
  next = currDecoder.next()
436
441
  ) {
437
- writeStructToLazyStructWriter(lazyStructEncoder, currWrite.struct, currWrite.offset)
442
+ writeStructToLazyStructWriter(lazyStructEncoder, currWrite.struct, currWrite.offset, 0)
438
443
  currWrite = { struct: next, offset: 0 }
439
444
  }
440
445
  }
441
446
  if (currWrite !== null) {
442
- writeStructToLazyStructWriter(lazyStructEncoder, currWrite.struct, currWrite.offset)
447
+ writeStructToLazyStructWriter(lazyStructEncoder, currWrite.struct, currWrite.offset, 0)
443
448
  currWrite = null
444
449
  }
445
450
  finishLazyStructWriting(lazyStructEncoder)
@@ -451,6 +456,7 @@ export const mergeUpdatesV2 = (updates, YDecoder = UpdateDecoderV2, YEncoder = U
451
456
  }
452
457
 
453
458
  /**
459
+ * @deprecated
454
460
  * @param {Uint8Array} update
455
461
  * @param {Uint8Array} sv
456
462
  * @param {typeof UpdateDecoderV1 | typeof UpdateDecoderV2} [YDecoder]
@@ -472,10 +478,10 @@ export const diffUpdateV2 = (update, sv, YDecoder = UpdateDecoderV2, YEncoder =
472
478
  continue
473
479
  }
474
480
  if (curr.id.clock + curr.length > svClock) {
475
- writeStructToLazyStructWriter(lazyStructWriter, curr, math.max(svClock - curr.id.clock, 0))
481
+ writeStructToLazyStructWriter(lazyStructWriter, curr, math.max(svClock - curr.id.clock, 0), 0)
476
482
  reader.next()
477
483
  while (reader.curr && reader.curr.id.client === currClient) {
478
- writeStructToLazyStructWriter(lazyStructWriter, reader.curr, 0)
484
+ writeStructToLazyStructWriter(lazyStructWriter, reader.curr, 0, 0)
479
485
  reader.next()
480
486
  }
481
487
  } else {
@@ -493,6 +499,9 @@ export const diffUpdateV2 = (update, sv, YDecoder = UpdateDecoderV2, YEncoder =
493
499
  }
494
500
 
495
501
  /**
502
+ * @deprecated
503
+ * @todo remove this in favor of intersectupdate
504
+ *
496
505
  * @param {Uint8Array} update
497
506
  * @param {Uint8Array} sv
498
507
  */
@@ -513,8 +522,9 @@ const flushLazyStructWriter = lazyWriter => {
513
522
  * @param {LazyStructWriter} lazyWriter
514
523
  * @param {Item | GC} struct
515
524
  * @param {number} offset
525
+ * @param {number} offsetEnd
516
526
  */
517
- const writeStructToLazyStructWriter = (lazyWriter, struct, offset) => {
527
+ const writeStructToLazyStructWriter = (lazyWriter, struct, offset, offsetEnd) => {
518
528
  // flush curr if we start another client
519
529
  if (lazyWriter.written > 0 && lazyWriter.currClient !== struct.id.client) {
520
530
  flushLazyStructWriter(lazyWriter)
@@ -526,7 +536,7 @@ const writeStructToLazyStructWriter = (lazyWriter, struct, offset) => {
526
536
  // write startClock
527
537
  encoding.writeVarUint(lazyWriter.encoder.restEncoder, struct.id.clock + offset)
528
538
  }
529
- struct.write(lazyWriter.encoder, offset, 0)
539
+ struct.write(lazyWriter.encoder, offset, offsetEnd)
530
540
  lazyWriter.written++
531
541
  }
532
542
  /**
@@ -574,7 +584,7 @@ export const convertUpdateFormat = (update, blockTransformer, YDecoder, YEncoder
574
584
  const updateEncoder = new YEncoder()
575
585
  const lazyWriter = new LazyStructWriter(updateEncoder)
576
586
  for (let curr = lazyDecoder.curr; curr !== null; curr = lazyDecoder.next()) {
577
- writeStructToLazyStructWriter(lazyWriter, blockTransformer(curr), 0)
587
+ writeStructToLazyStructWriter(lazyWriter, blockTransformer(curr), 0, 0)
578
588
  }
579
589
  finishLazyStructWriting(lazyWriter)
580
590
  const ds = readIdSet(updateDecoder)
@@ -709,3 +719,84 @@ export const convertUpdateFormatV1ToV2 = update => convertUpdateFormat(update, f
709
719
  * @param {Uint8Array} update
710
720
  */
711
721
  export const convertUpdateFormatV2ToV1 = update => convertUpdateFormat(update, f.id, UpdateDecoderV2, UpdateEncoderV1)
722
+
723
+ /**
724
+ * Filter an update to only include content specified by a ContentIds pattern.
725
+ *
726
+ * This function extracts a subset of an update, keeping only the structs whose IDs
727
+ * are present in `contentIds.inserts` and only the delete set entries that are
728
+ * present in `contentIds.deletes`.
729
+ *
730
+ * Note: If a struct partially overlaps with the contentIds pattern, only the
731
+ * overlapping portion is included in the result.
732
+ *
733
+ * @param {Uint8Array} update
734
+ * @param {import('./meta.js').ContentIds} contentIds - Pattern specifying which content to include
735
+ * @param {typeof UpdateDecoderV1 | typeof UpdateDecoderV2} [YDecoder]
736
+ * @param {typeof UpdateEncoderV1 | typeof UpdateEncoderV2} [YEncoder]
737
+ * @return {Uint8Array}
738
+ */
739
+ export const intersectUpdateWithContentIdsV2 = (update, contentIds, YDecoder = UpdateDecoderV2, YEncoder = UpdateEncoderV2) => {
740
+ const { inserts, deletes } = contentIds
741
+ const encoder = new YEncoder()
742
+ const lazyStructWriter = new LazyStructWriter(encoder)
743
+ const decoder = new YDecoder(decoding.createDecoder(update))
744
+ const reader = new LazyStructReader(decoder, true)
745
+
746
+ while (reader.curr) {
747
+ const currClientId = reader.curr.id.client
748
+ let nextClock = reader.curr.id.clock
749
+ let firstWrite = false
750
+ while (reader.curr != null && reader.curr.id.client === currClientId) {
751
+ const curr = reader.curr
752
+ for (const slice of inserts.slice(currClientId, nextClock, curr.length)) {
753
+ if (slice.exists) {
754
+ const skipLen = slice.clock - nextClock
755
+ if (skipLen > 0 && firstWrite) {
756
+ // write missing skip
757
+ writeStructToLazyStructWriter(lazyStructWriter, new Skip(createID(currClientId, nextClock), skipLen), 0, 0)
758
+ }
759
+ // write sliced content
760
+ writeStructToLazyStructWriter(lazyStructWriter, curr, slice.clock - curr.id.clock, (curr.id.clock + curr.length) - (slice.clock + slice.len))
761
+ nextClock = slice.clock + slice.len
762
+ firstWrite = true
763
+ }
764
+ }
765
+ reader.next()
766
+ }
767
+ }
768
+ finishLazyStructWriting(lazyStructWriter)
769
+ // Filter the delete set to only include entries in contentIds.deletes
770
+ const ds = readIdSet(decoder)
771
+ const filteredDs = idset.intersectSets(ds, deletes)
772
+ writeIdSet(encoder, filteredDs)
773
+ return encoder.toUint8Array()
774
+ }
775
+
776
+ /**
777
+ * Filter an update (V1 format) to only include content specified by a ContentIds pattern.
778
+ *
779
+ * @param {Uint8Array} update
780
+ * @param {import('./meta.js').ContentIds} contentIds - Pattern specifying which content to include
781
+ * @return {Uint8Array}
782
+ */
783
+ export const intersectUpdateWithContentIds = (update, contentIds) =>
784
+ intersectUpdateWithContentIdsV2(update, contentIds, UpdateDecoderV1, UpdateEncoderV1)
785
+
786
+ /**
787
+ * @param {Uint8Array} update
788
+ */
789
+ export const createDocFromUpdate = update => {
790
+ const ydoc = new Doc()
791
+ applyUpdate(ydoc, update)
792
+ return ydoc
793
+ }
794
+
795
+ /**
796
+ * @param {Uint8Array} update
797
+ */
798
+ export const createDocFromUpdateV2 = update => {
799
+ const ydoc = new Doc()
800
+ applyUpdateV2(ydoc, update)
801
+ return ydoc
802
+ }