@fluidframework/sequence 2.42.0 → 2.43.0-343119
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/api-report/sequence.legacy.alpha.api.md +13 -5
- package/dist/intervalCollection.d.ts +14 -15
- package/dist/intervalCollection.d.ts.map +1 -1
- package/dist/intervalCollection.js +109 -104
- package/dist/intervalCollection.js.map +1 -1
- package/dist/intervalCollectionMap.d.ts +3 -3
- package/dist/intervalCollectionMap.d.ts.map +1 -1
- package/dist/intervalCollectionMap.js.map +1 -1
- package/dist/intervalCollectionMapInterfaces.d.ts +22 -5
- package/dist/intervalCollectionMapInterfaces.d.ts.map +1 -1
- package/dist/intervalCollectionMapInterfaces.js.map +1 -1
- package/dist/intervalIndex/overlappingIntervalsIndex.d.ts +4 -4
- package/dist/intervalIndex/overlappingIntervalsIndex.d.ts.map +1 -1
- package/dist/intervalIndex/overlappingIntervalsIndex.js.map +1 -1
- package/dist/intervals/intervalUtils.d.ts +12 -1
- package/dist/intervals/intervalUtils.d.ts.map +1 -1
- package/dist/intervals/intervalUtils.js.map +1 -1
- package/dist/intervals/sequenceInterval.d.ts +18 -5
- package/dist/intervals/sequenceInterval.d.ts.map +1 -1
- package/dist/intervals/sequenceInterval.js +2 -1
- package/dist/intervals/sequenceInterval.js.map +1 -1
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.d.ts.map +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/revertibles.d.ts.map +1 -1
- package/dist/revertibles.js +6 -3
- package/dist/revertibles.js.map +1 -1
- package/dist/sequence.d.ts.map +1 -1
- package/dist/sequence.js +1 -1
- package/dist/sequence.js.map +1 -1
- package/lib/intervalCollection.d.ts +14 -15
- package/lib/intervalCollection.d.ts.map +1 -1
- package/lib/intervalCollection.js +110 -105
- package/lib/intervalCollection.js.map +1 -1
- package/lib/intervalCollectionMap.d.ts +3 -3
- package/lib/intervalCollectionMap.d.ts.map +1 -1
- package/lib/intervalCollectionMap.js.map +1 -1
- package/lib/intervalCollectionMapInterfaces.d.ts +22 -5
- package/lib/intervalCollectionMapInterfaces.d.ts.map +1 -1
- package/lib/intervalCollectionMapInterfaces.js.map +1 -1
- package/lib/intervalIndex/overlappingIntervalsIndex.d.ts +4 -4
- package/lib/intervalIndex/overlappingIntervalsIndex.d.ts.map +1 -1
- package/lib/intervalIndex/overlappingIntervalsIndex.js +1 -1
- package/lib/intervalIndex/overlappingIntervalsIndex.js.map +1 -1
- package/lib/intervals/intervalUtils.d.ts +12 -1
- package/lib/intervals/intervalUtils.d.ts.map +1 -1
- package/lib/intervals/intervalUtils.js.map +1 -1
- package/lib/intervals/sequenceInterval.d.ts +18 -5
- package/lib/intervals/sequenceInterval.d.ts.map +1 -1
- package/lib/intervals/sequenceInterval.js +2 -1
- package/lib/intervals/sequenceInterval.js.map +1 -1
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.d.ts.map +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/lib/revertibles.d.ts.map +1 -1
- package/lib/revertibles.js +6 -3
- package/lib/revertibles.js.map +1 -1
- package/lib/sequence.d.ts.map +1 -1
- package/lib/sequence.js +1 -1
- package/lib/sequence.js.map +1 -1
- package/package.json +17 -17
- package/src/intervalCollection.ts +185 -159
- package/src/intervalCollectionMap.ts +4 -11
- package/src/intervalCollectionMapInterfaces.ts +25 -6
- package/src/intervalIndex/overlappingIntervalsIndex.ts +15 -11
- package/src/intervals/intervalUtils.ts +12 -1
- package/src/intervals/sequenceInterval.ts +22 -4
- package/src/packageVersion.ts +1 -1
- package/src/revertibles.ts +7 -6
- package/src/sequence.ts +5 -11
|
@@ -32,14 +32,16 @@ export function discardSharedStringRevertibles(sharedString: ISharedString, reve
|
|
|
32
32
|
|
|
33
33
|
// @alpha @legacy
|
|
34
34
|
export interface IInterval {
|
|
35
|
-
// (undocumented)
|
|
35
|
+
// @deprecated (undocumented)
|
|
36
36
|
clone(): IInterval;
|
|
37
37
|
compare(b: IInterval): number;
|
|
38
38
|
compareEnd(b: IInterval): number;
|
|
39
39
|
compareStart(b: IInterval): number;
|
|
40
|
+
// @deprecated
|
|
40
41
|
modify(label: string, start: SequencePlace | undefined, end: SequencePlace | undefined, op?: ISequencedDocumentMessage, localSeq?: number, useNewSlidingBehavior?: boolean): IInterval | undefined;
|
|
41
42
|
// (undocumented)
|
|
42
43
|
overlaps(b: IInterval): boolean;
|
|
44
|
+
// @deprecated
|
|
43
45
|
union(b: IInterval): IInterval;
|
|
44
46
|
}
|
|
45
47
|
|
|
@@ -128,7 +130,7 @@ export interface ISequenceIntervalCollection extends TypedEventEmitter<ISequence
|
|
|
128
130
|
end: SequencePlace;
|
|
129
131
|
props?: PropertySet;
|
|
130
132
|
}): SequenceInterval;
|
|
131
|
-
// (undocumented)
|
|
133
|
+
// @deprecated (undocumented)
|
|
132
134
|
attachDeserializer(onDeserialize: DeserializeCallback): void;
|
|
133
135
|
// (undocumented)
|
|
134
136
|
readonly attached: boolean;
|
|
@@ -175,11 +177,11 @@ export interface ISequenceOverlappingIntervalsIndex extends SequenceIntervalInde
|
|
|
175
177
|
gatherIterationResults(results: SequenceInterval[], iteratesForward: boolean, start?: SequencePlace, end?: SequencePlace): void;
|
|
176
178
|
}
|
|
177
179
|
|
|
178
|
-
// @alpha @legacy (undocumented)
|
|
180
|
+
// @alpha @deprecated @legacy (undocumented)
|
|
179
181
|
export interface ISerializableInterval extends IInterval {
|
|
180
182
|
getIntervalId(): string;
|
|
181
183
|
properties: PropertySet;
|
|
182
|
-
// (undocumented)
|
|
184
|
+
// @deprecated (undocumented)
|
|
183
185
|
serialize(): ISerializedInterval;
|
|
184
186
|
}
|
|
185
187
|
|
|
@@ -302,8 +304,9 @@ export interface SequenceEvent<TOperation extends MergeTreeDeltaOperationTypes =
|
|
|
302
304
|
|
|
303
305
|
// @alpha @legacy
|
|
304
306
|
export interface SequenceInterval extends ISerializableInterval {
|
|
307
|
+
// @deprecated
|
|
305
308
|
addPositionChangeListeners(beforePositionChange: () => void, afterPositionChange: () => void): void;
|
|
306
|
-
// (undocumented)
|
|
309
|
+
// @deprecated (undocumented)
|
|
307
310
|
clone(): SequenceInterval;
|
|
308
311
|
compare(b: SequenceInterval): number;
|
|
309
312
|
compareEnd(b: SequenceInterval): number;
|
|
@@ -311,13 +314,17 @@ export interface SequenceInterval extends ISerializableInterval {
|
|
|
311
314
|
readonly end: LocalReferencePosition;
|
|
312
315
|
// (undocumented)
|
|
313
316
|
readonly endSide: Side;
|
|
317
|
+
getIntervalId(): string;
|
|
314
318
|
// (undocumented)
|
|
315
319
|
readonly intervalType: IntervalType;
|
|
320
|
+
// @deprecated
|
|
316
321
|
modify(label: string, start: SequencePlace | undefined, end: SequencePlace | undefined, op?: ISequencedDocumentMessage, localSeq?: number, useNewSlidingBehavior?: boolean): SequenceInterval | undefined;
|
|
317
322
|
// (undocumented)
|
|
318
323
|
overlaps(b: SequenceInterval): boolean;
|
|
319
324
|
// (undocumented)
|
|
320
325
|
overlapsPos(bstart: number, bend: number): boolean;
|
|
326
|
+
properties: PropertySet;
|
|
327
|
+
// @deprecated
|
|
321
328
|
removePositionChangeListeners(): void;
|
|
322
329
|
// (undocumented)
|
|
323
330
|
readonly start: LocalReferencePosition;
|
|
@@ -325,6 +332,7 @@ export interface SequenceInterval extends ISerializableInterval {
|
|
|
325
332
|
readonly startSide: Side;
|
|
326
333
|
// (undocumented)
|
|
327
334
|
readonly stickiness: IntervalStickiness;
|
|
335
|
+
// @deprecated
|
|
328
336
|
union(b: SequenceInterval): SequenceInterval;
|
|
329
337
|
}
|
|
330
338
|
|
|
@@ -6,7 +6,7 @@ import { TypedEventEmitter } from "@fluid-internal/client-utils";
|
|
|
6
6
|
import { IEvent } from "@fluidframework/core-interfaces";
|
|
7
7
|
import { ISequencedDocumentMessage } from "@fluidframework/driver-definitions/internal";
|
|
8
8
|
import { Client, LocalReferencePosition, PropertySet, Side, SequencePlace } from "@fluidframework/merge-tree/internal";
|
|
9
|
-
import {
|
|
9
|
+
import { SequenceOptions, type IIntervalCollectionTypeOperationValue, type IntervalAddLocalMetadata, type IntervalChangeLocalMetadata } from "./intervalCollectionMapInterfaces.js";
|
|
10
10
|
import { type IEndpointIndex, type IIdIntervalIndex, type ISequenceOverlappingIntervalsIndex, type SequenceIntervalIndex } from "./intervalIndex/index.js";
|
|
11
11
|
import { CompressedSerializedInterval, ISerializedInterval, IntervalStickiness, SequenceInterval, SequenceIntervalClass, SerializedIntervalDelta } from "./intervals/index.js";
|
|
12
12
|
export type ISerializedIntervalCollectionV1 = ISerializedInterval[];
|
|
@@ -241,6 +241,9 @@ export interface ISequenceIntervalCollection extends TypedEventEmitter<ISequence
|
|
|
241
241
|
end?: SequencePlace;
|
|
242
242
|
props?: PropertySet;
|
|
243
243
|
}): SequenceInterval | undefined;
|
|
244
|
+
/**
|
|
245
|
+
* @deprecated This api is not meant or necessary for external consumption and will be removed in subsequent release
|
|
246
|
+
*/
|
|
244
247
|
attachDeserializer(onDeserialize: DeserializeCallback): void;
|
|
245
248
|
/**
|
|
246
249
|
* @returns an iterator over all intervals in this collection.
|
|
@@ -316,17 +319,15 @@ export interface ISequenceIntervalCollection extends TypedEventEmitter<ISequence
|
|
|
316
319
|
* {@inheritdoc IIntervalCollection}
|
|
317
320
|
*/
|
|
318
321
|
export declare class IntervalCollection extends TypedEventEmitter<ISequenceIntervalCollectionEvents> implements ISequenceIntervalCollection {
|
|
319
|
-
private readonly submitDelta;
|
|
320
322
|
private readonly options;
|
|
321
323
|
private savedSerializedIntervals?;
|
|
322
324
|
private localCollection;
|
|
323
325
|
private onDeserialize;
|
|
324
326
|
private client;
|
|
325
|
-
private readonly
|
|
326
|
-
private readonly localSeqToRebasedInterval;
|
|
327
|
-
private readonly pendingChanges;
|
|
327
|
+
private readonly pending;
|
|
328
328
|
get attached(): boolean;
|
|
329
|
-
|
|
329
|
+
private readonly submitDelta;
|
|
330
|
+
constructor(submitDelta: (op: IIntervalCollectionTypeOperationValue, md: unknown) => void, serializedIntervals: ISerializedIntervalCollectionV1 | ISerializedIntervalCollectionV2, options?: Partial<SequenceOptions>);
|
|
330
331
|
/**
|
|
331
332
|
* {@inheritdoc IIntervalCollection.attachIndex}
|
|
332
333
|
*/
|
|
@@ -335,9 +336,9 @@ export declare class IntervalCollection extends TypedEventEmitter<ISequenceInter
|
|
|
335
336
|
* {@inheritdoc IIntervalCollection.detachIndex}
|
|
336
337
|
*/
|
|
337
338
|
detachIndex(index: SequenceIntervalIndex): boolean;
|
|
338
|
-
rollback(op: IIntervalCollectionTypeOperationValue,
|
|
339
|
-
process(op: IIntervalCollectionTypeOperationValue, local: boolean, message: ISequencedDocumentMessage,
|
|
340
|
-
resubmitMessage(op: IIntervalCollectionTypeOperationValue,
|
|
339
|
+
rollback(op: IIntervalCollectionTypeOperationValue, maybeMetadata: unknown): void;
|
|
340
|
+
process(op: IIntervalCollectionTypeOperationValue, local: boolean, message: ISequencedDocumentMessage, maybeMetadata: unknown): void;
|
|
341
|
+
resubmitMessage(op: IIntervalCollectionTypeOperationValue, maybeMetadata: unknown): void;
|
|
341
342
|
applyStashedOp(op: IIntervalCollectionTypeOperationValue): void;
|
|
342
343
|
private rebasePositionWithSegmentSlide;
|
|
343
344
|
private computeRebasedPositions;
|
|
@@ -377,10 +378,8 @@ export declare class IntervalCollection extends TypedEventEmitter<ISequenceInter
|
|
|
377
378
|
rollback?: boolean;
|
|
378
379
|
}): SequenceIntervalClass | undefined;
|
|
379
380
|
private get isCollaborating();
|
|
380
|
-
private
|
|
381
|
-
|
|
382
|
-
private hasPendingChanges;
|
|
383
|
-
ackChange(serializedInterval: SerializedIntervalDelta, local: boolean, op: ISequencedDocumentMessage, localOpMetadata: IMapMessageLocalMetadata | undefined): void;
|
|
381
|
+
private hasPendingEndpointChanges;
|
|
382
|
+
ackChange(serializedInterval: SerializedIntervalDelta, local: boolean, op: ISequencedDocumentMessage): void;
|
|
384
383
|
/**
|
|
385
384
|
* {@inheritdoc IIntervalCollection.attachDeserializer}
|
|
386
385
|
*/
|
|
@@ -391,10 +390,10 @@ export declare class IntervalCollection extends TypedEventEmitter<ISequenceInter
|
|
|
391
390
|
* to a range that no longer exists, and the interval was unable to slide.
|
|
392
391
|
*
|
|
393
392
|
*/
|
|
394
|
-
rebaseLocalInterval(
|
|
393
|
+
rebaseLocalInterval(localOpMetadata: IntervalAddLocalMetadata | IntervalChangeLocalMetadata): SerializedIntervalDelta | undefined;
|
|
395
394
|
private getSlideToSegment;
|
|
396
395
|
private ackInterval;
|
|
397
|
-
ackAdd(serializedInterval: ISerializedInterval, local: boolean, op: ISequencedDocumentMessage, localOpMetadata:
|
|
396
|
+
ackAdd(serializedInterval: ISerializedInterval, local: boolean, op: ISequencedDocumentMessage, localOpMetadata: IntervalAddLocalMetadata | undefined): SequenceIntervalClass | undefined;
|
|
398
397
|
ackDelete(serializedInterval: SerializedIntervalDelta, local: boolean, op: ISequencedDocumentMessage): void;
|
|
399
398
|
serializeInternal(version: "1" | "2"): ISerializedIntervalCollectionV1 | ISerializedIntervalCollectionV2;
|
|
400
399
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"intervalCollection.d.ts","sourceRoot":"","sources":["../src/intervalCollection.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,EAAE,MAAM,EAAE,MAAM,iCAAiC,CAAC;AAEzD,OAAO,EAAE,yBAAyB,EAAE,MAAM,6CAA6C,CAAC;AACxF,OAAO,EACN,MAAM,EAGN,sBAAsB,EACtB,WAAW,EAMX,IAAI,EACJ,aAAa,
|
|
1
|
+
{"version":3,"file":"intervalCollection.d.ts","sourceRoot":"","sources":["../src/intervalCollection.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,EAAE,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G,GAAG,GAChB,+BAA+B,GAAG,+BAA+B;IAQpE;;OAEG;IACI,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,0BAA0B;IAKtD;;OAEG;IACI,sCAAsC,CAC5C,aAAa,EAAE,MAAM,GACnB,0BAA0B;IAK7B;;OAEG;IACI,uCAAuC,CAC7C,aAAa,EAAE,MAAM,GACnB,0BAA0B;IAK7B;;OAEG;IACI,oCAAoC,CAC1C,WAAW,EAAE,MAAM,GACjB,0BAA0B;IAK7B;;OAEG;IACI,qCAAqC,CAC3C,WAAW,EAAE,MAAM,GACjB,0BAA0B;IAK7B;;OAEG;IACI,sBAAsB,CAC5B,OAAO,EAAE,qBAAqB,EAAE,EAChC,eAAe,EAAE,OAAO,EACxB,KAAK,CAAC,EAAE,MAAM,EACd,GAAG,CAAC,EAAE,MAAM;IAcb;;OAEG;IACI,wBAAwB,CAC9B,aAAa,EAAE,MAAM,EACrB,WAAW,EAAE,MAAM,GACjB,gBAAgB,EAAE;IAWrB;;OAEG;IACI,GAAG,CAAC,EAAE,EAAE,CAAC,QAAQ,EAAE,qBAAqB,KAAK,IAAI;IAUxD;;OAEG;IACI,gBAAgB,CAAC,GAAG,EAAE,MAAM,GAAG,gBAAgB,GAAG,SAAS;IAQlE;;OAEG;IACI,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,gBAAgB,GAAG,SAAS;CAO9D;AASD;;;GAGG;AACH,MAAM,WAAW,eAAe;IAC/B;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,QAAQ,EAAE,qBAAqB,CAAC;CAChC;AAED;;;;;;GAMG;AACH,wBAAgB,2BAA2B,CAC1C,iBAAiB,EAAE,sBAAsB,GACvC,eAAe,GAAG,SAAS,CAM7B"}
|
|
@@ -216,6 +216,25 @@ class IntervalCollectionIterator {
|
|
|
216
216
|
};
|
|
217
217
|
}
|
|
218
218
|
}
|
|
219
|
+
function removeMetadataFromPendingChanges(localOpMetadataNode) {
|
|
220
|
+
const acked = localOpMetadataNode?.remove()
|
|
221
|
+
?.data;
|
|
222
|
+
(0, internal_1.assert)(acked !== undefined, "local change must exist");
|
|
223
|
+
acked.endpointChangesNode?.remove();
|
|
224
|
+
return acked;
|
|
225
|
+
}
|
|
226
|
+
function clearEmptyPendingEntry(pendingChanges, id) {
|
|
227
|
+
const pending = pendingChanges[id];
|
|
228
|
+
(0, internal_1.assert)(pending !== undefined, "pending must exist for local process");
|
|
229
|
+
if (pending.local.empty) {
|
|
230
|
+
(0, internal_1.assert)(pending.endpointChanges?.empty !== false, "endpointChanges must be empty if not pending changes");
|
|
231
|
+
// eslint-disable-next-line @typescript-eslint/no-dynamic-delete
|
|
232
|
+
delete pendingChanges[id];
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
function hasEndpointChanges(serialized) {
|
|
236
|
+
return serialized.start !== undefined && serialized.end !== undefined;
|
|
237
|
+
}
|
|
219
238
|
/**
|
|
220
239
|
* {@inheritdoc IIntervalCollection}
|
|
221
240
|
*/
|
|
@@ -225,11 +244,19 @@ class IntervalCollection extends client_utils_1.TypedEventEmitter {
|
|
|
225
244
|
}
|
|
226
245
|
constructor(submitDelta, serializedIntervals, options = {}) {
|
|
227
246
|
super();
|
|
228
|
-
this.submitDelta = submitDelta;
|
|
229
247
|
this.options = options;
|
|
230
|
-
this.
|
|
231
|
-
this.
|
|
232
|
-
|
|
248
|
+
this.pending = {};
|
|
249
|
+
this.submitDelta = (op, md) => {
|
|
250
|
+
const { id } = (0, index_js_2.getSerializedProperties)(op.value);
|
|
251
|
+
const pending = (this.pending[id] ??= {
|
|
252
|
+
local: new internal_2.DoublyLinkedList(),
|
|
253
|
+
});
|
|
254
|
+
if (md.type === "add" || (md.type === "change" && hasEndpointChanges(op.value))) {
|
|
255
|
+
const endpointChanges = (pending.endpointChanges ??= new internal_2.DoublyLinkedList());
|
|
256
|
+
md.endpointChangesNode = endpointChanges.push(md).last;
|
|
257
|
+
}
|
|
258
|
+
submitDelta(op, pending.local.push(md).last);
|
|
259
|
+
};
|
|
233
260
|
this.savedSerializedIntervals = Array.isArray(serializedIntervals)
|
|
234
261
|
? serializedIntervals
|
|
235
262
|
: serializedIntervals.intervals.map((i) => decompressInterval(i, serializedIntervals.label));
|
|
@@ -262,11 +289,12 @@ class IntervalCollection extends client_utils_1.TypedEventEmitter {
|
|
|
262
289
|
}
|
|
263
290
|
return true;
|
|
264
291
|
}
|
|
265
|
-
rollback(op,
|
|
266
|
-
const
|
|
292
|
+
rollback(op, maybeMetadata) {
|
|
293
|
+
const localOpMetadata = removeMetadataFromPendingChanges(maybeMetadata);
|
|
294
|
+
const { value } = op;
|
|
267
295
|
const { id, properties } = (0, index_js_2.getSerializedProperties)(value);
|
|
268
|
-
const {
|
|
269
|
-
switch (
|
|
296
|
+
const { type } = localOpMetadata;
|
|
297
|
+
switch (type) {
|
|
270
298
|
case "add": {
|
|
271
299
|
const interval = this.getIntervalById(id);
|
|
272
300
|
if (interval) {
|
|
@@ -275,8 +303,8 @@ class IntervalCollection extends client_utils_1.TypedEventEmitter {
|
|
|
275
303
|
break;
|
|
276
304
|
}
|
|
277
305
|
case "change": {
|
|
278
|
-
|
|
279
|
-
const endpointsChanged = value
|
|
306
|
+
const { previous } = localOpMetadata;
|
|
307
|
+
const endpointsChanged = hasEndpointChanges(value);
|
|
280
308
|
const start = endpointsChanged
|
|
281
309
|
? toOptionalSequencePlace(previous.start, previous.startSide)
|
|
282
310
|
: undefined;
|
|
@@ -289,14 +317,10 @@ class IntervalCollection extends client_utils_1.TypedEventEmitter {
|
|
|
289
317
|
props: Object.keys(properties).length > 0 ? properties : undefined,
|
|
290
318
|
rollback: true,
|
|
291
319
|
});
|
|
292
|
-
this.localSeqToSerializedInterval.delete(localSeq);
|
|
293
|
-
if (endpointsChanged) {
|
|
294
|
-
this.removePendingChange(value);
|
|
295
|
-
}
|
|
296
320
|
break;
|
|
297
321
|
}
|
|
298
322
|
case "delete": {
|
|
299
|
-
|
|
323
|
+
const { previous } = localOpMetadata;
|
|
300
324
|
this.add({
|
|
301
325
|
id,
|
|
302
326
|
start: toSequencePlace(previous.start, previous.startSide),
|
|
@@ -307,14 +331,22 @@ class IntervalCollection extends client_utils_1.TypedEventEmitter {
|
|
|
307
331
|
break;
|
|
308
332
|
}
|
|
309
333
|
default:
|
|
310
|
-
(0, internal_1.unreachableCase)(
|
|
334
|
+
(0, internal_1.unreachableCase)(type);
|
|
311
335
|
}
|
|
336
|
+
clearEmptyPendingEntry(this.pending, id);
|
|
312
337
|
}
|
|
313
|
-
process(op, local, message,
|
|
338
|
+
process(op, local, message, maybeMetadata) {
|
|
339
|
+
const localOpMetadata = local
|
|
340
|
+
? removeMetadataFromPendingChanges(maybeMetadata)
|
|
341
|
+
: undefined;
|
|
314
342
|
const { opName, value } = op;
|
|
343
|
+
(0, internal_1.assert)((local === false && localOpMetadata === undefined) || opName === localOpMetadata?.type, "must be same type");
|
|
315
344
|
switch (opName) {
|
|
316
345
|
case "add": {
|
|
317
|
-
this.ackAdd(value, local, message,
|
|
346
|
+
this.ackAdd(value, local, message,
|
|
347
|
+
// this cast is safe because of the above assert which
|
|
348
|
+
// validates the op and metadata types match for local changes
|
|
349
|
+
localOpMetadata);
|
|
318
350
|
break;
|
|
319
351
|
}
|
|
320
352
|
case "delete": {
|
|
@@ -322,18 +354,27 @@ class IntervalCollection extends client_utils_1.TypedEventEmitter {
|
|
|
322
354
|
break;
|
|
323
355
|
}
|
|
324
356
|
case "change": {
|
|
325
|
-
this.ackChange(value, local, message
|
|
357
|
+
this.ackChange(value, local, message);
|
|
326
358
|
break;
|
|
327
359
|
}
|
|
328
360
|
default:
|
|
329
361
|
(0, internal_1.unreachableCase)(opName);
|
|
330
362
|
}
|
|
363
|
+
if (local) {
|
|
364
|
+
const { id } = (0, index_js_2.getSerializedProperties)(value);
|
|
365
|
+
clearEmptyPendingEntry(this.pending, id);
|
|
366
|
+
}
|
|
331
367
|
}
|
|
332
|
-
resubmitMessage(op,
|
|
368
|
+
resubmitMessage(op, maybeMetadata) {
|
|
333
369
|
const { opName, value } = op;
|
|
334
|
-
const
|
|
370
|
+
const localOpMetadata = removeMetadataFromPendingChanges(maybeMetadata);
|
|
371
|
+
const rebasedValue = localOpMetadata.endpointChangesNode === undefined
|
|
372
|
+
? value
|
|
373
|
+
: this.rebaseLocalInterval(localOpMetadata);
|
|
335
374
|
if (rebasedValue === undefined) {
|
|
336
|
-
|
|
375
|
+
const { id } = (0, index_js_2.getSerializedProperties)(value);
|
|
376
|
+
clearEmptyPendingEntry(this.pending, id);
|
|
377
|
+
return;
|
|
337
378
|
}
|
|
338
379
|
this.submitDelta({ opName, value: rebasedValue }, localOpMetadata);
|
|
339
380
|
}
|
|
@@ -378,21 +419,20 @@ class IntervalCollection extends client_utils_1.TypedEventEmitter {
|
|
|
378
419
|
const { segment, offset } = this.client.getContainingSegment(pos, {
|
|
379
420
|
referenceSequenceNumber: seqNumberFrom,
|
|
380
421
|
clientId: this.client.getLongClientId(clientId),
|
|
381
|
-
}, localSeq);
|
|
422
|
+
}, localSeq) ?? {};
|
|
382
423
|
// if segment is undefined, it slid off the string
|
|
383
|
-
(0, internal_1.assert)(segment !== undefined, 0x54e /* No segment found */);
|
|
384
|
-
const segoff = (0, internal_2.getSlideToSegoff)({ segment, offset }, undefined, (0, internal_2.createLocalReconnectingPerspective)(this.client.getCurrentSeq(), clientId, localSeq), this.options.mergeTreeReferencesCanSlideToEndpoint)
|
|
424
|
+
(0, internal_1.assert)(segment !== undefined && offset !== undefined, 0x54e /* No segment found */);
|
|
425
|
+
const segoff = (0, internal_2.getSlideToSegoff)({ segment, offset }, undefined, (0, internal_2.createLocalReconnectingPerspective)(this.client.getCurrentSeq(), clientId, localSeq), this.options.mergeTreeReferencesCanSlideToEndpoint);
|
|
385
426
|
// case happens when rebasing op, but concurrently entire string has been deleted
|
|
386
|
-
if (segoff
|
|
427
|
+
if (segoff?.segment === undefined || segoff.offset === undefined) {
|
|
387
428
|
return internal_2.DetachedReferencePosition;
|
|
388
429
|
}
|
|
389
430
|
(0, internal_1.assert)(offset !== undefined && 0 <= offset && offset < segment.cachedLength, 0x54f /* Invalid offset */);
|
|
390
431
|
return this.client.findReconnectionPosition(segoff.segment, localSeq) + segoff.offset;
|
|
391
432
|
}
|
|
392
|
-
computeRebasedPositions(
|
|
433
|
+
computeRebasedPositions(localOpMetadata) {
|
|
393
434
|
(0, internal_1.assert)(this.client !== undefined, 0x550 /* Client should be defined when computing rebased position */);
|
|
394
|
-
const original =
|
|
395
|
-
(0, internal_1.assert)(original !== undefined, 0x551 /* Failed to store pending serialized interval info for this localSeq. */);
|
|
435
|
+
const { localSeq, original } = localOpMetadata;
|
|
396
436
|
const rebased = { ...original };
|
|
397
437
|
const { start, end, sequenceNumber } = original;
|
|
398
438
|
if (start !== undefined) {
|
|
@@ -414,8 +454,12 @@ class IntervalCollection extends client_utils_1.TypedEventEmitter {
|
|
|
414
454
|
this.client = client;
|
|
415
455
|
if (client) {
|
|
416
456
|
client.on("normalize", () => {
|
|
417
|
-
for (const
|
|
418
|
-
|
|
457
|
+
for (const pending of Object.values(this.pending)) {
|
|
458
|
+
if (pending?.endpointChanges !== undefined) {
|
|
459
|
+
for (const local of pending.endpointChanges) {
|
|
460
|
+
local.data.rebased = this.computeRebasedPositions(local.data);
|
|
461
|
+
}
|
|
462
|
+
}
|
|
419
463
|
}
|
|
420
464
|
});
|
|
421
465
|
}
|
|
@@ -496,13 +540,13 @@ class IntervalCollection extends client_utils_1.TypedEventEmitter {
|
|
|
496
540
|
const serializedInterval = interval.serialize();
|
|
497
541
|
const localSeq = this.getNextLocalSeq();
|
|
498
542
|
if (this.isCollaborating && rollback !== true) {
|
|
499
|
-
this.localSeqToSerializedInterval.set(localSeq, serializedInterval);
|
|
500
543
|
this.submitDelta({
|
|
501
544
|
opName: "add",
|
|
502
545
|
value: serializedInterval,
|
|
503
546
|
}, {
|
|
547
|
+
type: "add",
|
|
504
548
|
localSeq,
|
|
505
|
-
|
|
549
|
+
original: serializedInterval,
|
|
506
550
|
});
|
|
507
551
|
}
|
|
508
552
|
}
|
|
@@ -518,13 +562,14 @@ class IntervalCollection extends client_utils_1.TypedEventEmitter {
|
|
|
518
562
|
if (interval) {
|
|
519
563
|
// Local ops get submitted to the server. Remote ops have the deserializer run.
|
|
520
564
|
if (local && rollback !== true) {
|
|
565
|
+
const value = interval.serialize();
|
|
521
566
|
this.submitDelta({
|
|
522
567
|
opName: "delete",
|
|
523
|
-
value
|
|
568
|
+
value,
|
|
524
569
|
}, {
|
|
570
|
+
type: "delete",
|
|
525
571
|
localSeq: this.getNextLocalSeq(),
|
|
526
|
-
previous:
|
|
527
|
-
intervalId: interval.getIntervalId(),
|
|
572
|
+
previous: value,
|
|
528
573
|
});
|
|
529
574
|
}
|
|
530
575
|
else {
|
|
@@ -587,16 +632,16 @@ class IntervalCollection extends client_utils_1.TypedEventEmitter {
|
|
|
587
632
|
// Emit a property bag containing the ID and the other (if any) properties changed
|
|
588
633
|
const serializedInterval = (newInterval ?? interval).serializeDelta({ props, includeEndpoints: changeEndpoints });
|
|
589
634
|
const localSeq = this.getNextLocalSeq();
|
|
590
|
-
|
|
591
|
-
|
|
635
|
+
const metadata = {
|
|
636
|
+
type: "change",
|
|
637
|
+
localSeq,
|
|
638
|
+
previous: interval.serialize(),
|
|
639
|
+
original: serializedInterval,
|
|
640
|
+
};
|
|
592
641
|
this.submitDelta({
|
|
593
642
|
opName: "change",
|
|
594
643
|
value: serializedInterval,
|
|
595
|
-
},
|
|
596
|
-
localSeq,
|
|
597
|
-
previous: interval.serialize(),
|
|
598
|
-
intervalId: id,
|
|
599
|
-
});
|
|
644
|
+
}, metadata);
|
|
600
645
|
}
|
|
601
646
|
if (deltaProps !== undefined) {
|
|
602
647
|
this.emit("propertyChanged", interval, deltaProps, true, undefined);
|
|
@@ -615,39 +660,10 @@ class IntervalCollection extends client_utils_1.TypedEventEmitter {
|
|
|
615
660
|
get isCollaborating() {
|
|
616
661
|
return this.client?.getCollabWindow().collaborating ?? false;
|
|
617
662
|
}
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
return;
|
|
621
|
-
}
|
|
622
|
-
(0, internal_1.assert)((serializedInterval.start === undefined) === (serializedInterval.end === undefined), 0xbb0 /* both start and end must be set or unset */);
|
|
623
|
-
if (serializedInterval.start !== undefined || serializedInterval.end !== undefined) {
|
|
624
|
-
const entries = this.pendingChanges.get(id) ?? [];
|
|
625
|
-
this.pendingChanges.set(id, entries);
|
|
626
|
-
entries.push(serializedInterval);
|
|
627
|
-
}
|
|
663
|
+
hasPendingEndpointChanges(id) {
|
|
664
|
+
return this.pending[id]?.endpointChanges?.empty === false;
|
|
628
665
|
}
|
|
629
|
-
|
|
630
|
-
// Change ops always have an ID.
|
|
631
|
-
const { id } = (0, index_js_2.getSerializedProperties)(serializedInterval);
|
|
632
|
-
if (serializedInterval.start !== undefined) {
|
|
633
|
-
const entries = this.pendingChanges.get(id);
|
|
634
|
-
if (entries) {
|
|
635
|
-
const pendingChange = entries.shift();
|
|
636
|
-
if (entries.length === 0) {
|
|
637
|
-
this.pendingChanges.delete(id);
|
|
638
|
-
}
|
|
639
|
-
if (pendingChange?.start !== serializedInterval.start ||
|
|
640
|
-
pendingChange?.end !== serializedInterval.end) {
|
|
641
|
-
throw new internal_3.LoggingError("Mismatch in pending changes");
|
|
642
|
-
}
|
|
643
|
-
}
|
|
644
|
-
}
|
|
645
|
-
}
|
|
646
|
-
hasPendingChanges(id) {
|
|
647
|
-
const entries = this.pendingChanges.get(id);
|
|
648
|
-
return entries && entries.length !== 0;
|
|
649
|
-
}
|
|
650
|
-
ackChange(serializedInterval, local, op, localOpMetadata) {
|
|
666
|
+
ackChange(serializedInterval, local, op) {
|
|
651
667
|
if (!this.localCollection) {
|
|
652
668
|
throw new internal_3.LoggingError("Attach must be called before accessing intervals");
|
|
653
669
|
}
|
|
@@ -657,12 +673,6 @@ class IntervalCollection extends client_utils_1.TypedEventEmitter {
|
|
|
657
673
|
const { id, properties } = (0, index_js_2.getSerializedProperties)(serializedInterval);
|
|
658
674
|
(0, internal_1.assert)(id !== undefined, 0x3fe /* id must exist on the interval */);
|
|
659
675
|
const interval = this.getIntervalById(id);
|
|
660
|
-
if (local) {
|
|
661
|
-
(0, internal_1.assert)(localOpMetadata !== undefined, 0x552 /* op metadata should be defined for local op */);
|
|
662
|
-
// This is an ack from the server. Remove the pending change.
|
|
663
|
-
this.localSeqToSerializedInterval.delete(localOpMetadata?.localSeq);
|
|
664
|
-
this.removePendingChange(serializedInterval);
|
|
665
|
-
}
|
|
666
676
|
if (!interval) {
|
|
667
677
|
// The interval has been removed locally; no-op.
|
|
668
678
|
return;
|
|
@@ -677,7 +687,7 @@ class IntervalCollection extends client_utils_1.TypedEventEmitter {
|
|
|
677
687
|
let start;
|
|
678
688
|
let end;
|
|
679
689
|
// Track pending start/end independently of one another.
|
|
680
|
-
if (!this.
|
|
690
|
+
if (!this.hasPendingEndpointChanges(id)) {
|
|
681
691
|
start = serializedInterval.start;
|
|
682
692
|
end = serializedInterval.end;
|
|
683
693
|
}
|
|
@@ -723,18 +733,20 @@ class IntervalCollection extends client_utils_1.TypedEventEmitter {
|
|
|
723
733
|
* to a range that no longer exists, and the interval was unable to slide.
|
|
724
734
|
*
|
|
725
735
|
*/
|
|
726
|
-
rebaseLocalInterval(
|
|
736
|
+
rebaseLocalInterval(localOpMetadata) {
|
|
737
|
+
const original = localOpMetadata.original;
|
|
727
738
|
if (!this.client) {
|
|
728
739
|
// If there's no associated mergeTree client, the originally submitted op is still correct.
|
|
729
|
-
return
|
|
740
|
+
return original;
|
|
730
741
|
}
|
|
731
742
|
if (!this.attached) {
|
|
732
743
|
throw new internal_3.LoggingError("attachSequence must be called");
|
|
733
744
|
}
|
|
734
745
|
const { localSeq } = localOpMetadata;
|
|
735
|
-
const { intervalType, properties, stickiness, startSide, endSide } =
|
|
736
|
-
const { id } = (0, index_js_2.getSerializedProperties)(
|
|
737
|
-
const { start: startRebased, end: endRebased } =
|
|
746
|
+
const { intervalType, properties, stickiness, startSide, endSide } = original;
|
|
747
|
+
const { id } = (0, index_js_2.getSerializedProperties)(original);
|
|
748
|
+
const { start: startRebased, end: endRebased } = (localOpMetadata.rebased ??=
|
|
749
|
+
this.computeRebasedPositions(localOpMetadata));
|
|
738
750
|
const localInterval = this.localCollection?.idIntervalIndex.getIntervalById(id);
|
|
739
751
|
const rebased = {
|
|
740
752
|
start: startRebased,
|
|
@@ -746,12 +758,6 @@ class IntervalCollection extends client_utils_1.TypedEventEmitter {
|
|
|
746
758
|
startSide,
|
|
747
759
|
endSide,
|
|
748
760
|
};
|
|
749
|
-
if (opName === "change" &&
|
|
750
|
-
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing -- ?? is not logically equivalent when .hasPendingChangeStart returns false.
|
|
751
|
-
this.hasPendingChanges(id)) {
|
|
752
|
-
this.removePendingChange(serializedInterval);
|
|
753
|
-
this.addPendingChange(id, rebased);
|
|
754
|
-
}
|
|
755
761
|
// if the interval slid off the string, rebase the op to be a noop and delete the interval.
|
|
756
762
|
if (!this.options.mergeTreeReferencesCanSlideToEndpoint &&
|
|
757
763
|
(startRebased === internal_2.DetachedReferencePosition || endRebased === internal_2.DetachedReferencePosition)) {
|
|
@@ -771,18 +777,18 @@ class IntervalCollection extends client_utils_1.TypedEventEmitter {
|
|
|
771
777
|
if (!this.client) {
|
|
772
778
|
throw new internal_3.LoggingError("client does not exist");
|
|
773
779
|
}
|
|
780
|
+
const segment = lref.getSegment();
|
|
781
|
+
if (segment === undefined) {
|
|
782
|
+
return undefined;
|
|
783
|
+
}
|
|
774
784
|
const segoff = {
|
|
775
|
-
segment
|
|
785
|
+
segment,
|
|
776
786
|
offset: lref.getOffset(),
|
|
777
787
|
};
|
|
778
|
-
if (segoff.segment
|
|
788
|
+
if (segoff.segment.localRefs?.has(lref) !== true) {
|
|
779
789
|
return undefined;
|
|
780
790
|
}
|
|
781
|
-
|
|
782
|
-
const value = segoff.segment === newSegoff.segment && segoff.offset === newSegoff.offset
|
|
783
|
-
? undefined
|
|
784
|
-
: newSegoff;
|
|
785
|
-
return value;
|
|
791
|
+
return (0, internal_2.getSlideToSegoff)(segoff, slidingPreference, undefined, this.options.mergeTreeReferencesCanSlideToEndpoint);
|
|
786
792
|
}
|
|
787
793
|
ackInterval(interval, op) {
|
|
788
794
|
if (!(0, internal_2.refTypeIncludesFlag)(interval.start, internal_2.ReferenceType.StayOnRemove) &&
|
|
@@ -792,13 +798,13 @@ class IntervalCollection extends client_utils_1.TypedEventEmitter {
|
|
|
792
798
|
const newStart = this.getSlideToSegment(interval.start, (0, index_js_2.startReferenceSlidingPreference)(interval.stickiness));
|
|
793
799
|
const newEnd = this.getSlideToSegment(interval.end, (0, index_js_2.endReferenceSlidingPreference)(interval.stickiness));
|
|
794
800
|
const id = interval.getIntervalId();
|
|
795
|
-
const hasPendingChange = this.
|
|
801
|
+
const hasPendingChange = this.hasPendingEndpointChanges(id);
|
|
796
802
|
if (!hasPendingChange) {
|
|
797
803
|
setSlideOnRemove(interval.start);
|
|
798
804
|
setSlideOnRemove(interval.end);
|
|
799
805
|
}
|
|
800
|
-
const needsStartUpdate = newStart !==
|
|
801
|
-
const needsEndUpdate = newEnd !==
|
|
806
|
+
const needsStartUpdate = newStart?.segment !== interval.start.getSegment() && !hasPendingChange;
|
|
807
|
+
const needsEndUpdate = newEnd?.segment !== interval.end.getSegment() && !hasPendingChange;
|
|
802
808
|
if (needsStartUpdate || needsEndUpdate) {
|
|
803
809
|
if (!this.localCollection) {
|
|
804
810
|
throw new internal_3.LoggingError("Attach must be called before accessing intervals");
|
|
@@ -844,7 +850,6 @@ class IntervalCollection extends client_utils_1.TypedEventEmitter {
|
|
|
844
850
|
const { id, properties } = (0, index_js_2.getSerializedProperties)(serializedInterval);
|
|
845
851
|
if (local) {
|
|
846
852
|
(0, internal_1.assert)(localOpMetadata !== undefined, 0x553 /* op metadata should be defined for local op */);
|
|
847
|
-
this.localSeqToSerializedInterval.delete(localOpMetadata.localSeq);
|
|
848
853
|
const localInterval = this.getIntervalById(id);
|
|
849
854
|
if (localInterval) {
|
|
850
855
|
this.ackInterval(localInterval, op);
|