@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
|
@@ -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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
7
|
import { assert, unreachableCase } from "@fluidframework/core-utils/internal";
|
|
8
|
-
import { DetachedReferencePosition, ReferenceType, SlidingPreference, getSlideToSegoff, refTypeIncludesFlag, reservedRangeLabelsKey, Side, endpointPosAndSide, createLocalReconnectingPerspective, } from "@fluidframework/merge-tree/internal";
|
|
8
|
+
import { DetachedReferencePosition, ReferenceType, SlidingPreference, getSlideToSegoff, refTypeIncludesFlag, reservedRangeLabelsKey, Side, endpointPosAndSide, createLocalReconnectingPerspective, DoublyLinkedList, } from "@fluidframework/merge-tree/internal";
|
|
9
9
|
import { LoggingError, UsageError } from "@fluidframework/telemetry-utils/internal";
|
|
10
10
|
import { v4 as uuid } from "uuid";
|
|
11
11
|
import { createIdIntervalIndex, EndpointIndex, OverlappingIntervalsIndex, } from "./intervalIndex/index.js";
|
|
@@ -208,6 +208,25 @@ class IntervalCollectionIterator {
|
|
|
208
208
|
};
|
|
209
209
|
}
|
|
210
210
|
}
|
|
211
|
+
function removeMetadataFromPendingChanges(localOpMetadataNode) {
|
|
212
|
+
const acked = localOpMetadataNode?.remove()
|
|
213
|
+
?.data;
|
|
214
|
+
assert(acked !== undefined, "local change must exist");
|
|
215
|
+
acked.endpointChangesNode?.remove();
|
|
216
|
+
return acked;
|
|
217
|
+
}
|
|
218
|
+
function clearEmptyPendingEntry(pendingChanges, id) {
|
|
219
|
+
const pending = pendingChanges[id];
|
|
220
|
+
assert(pending !== undefined, "pending must exist for local process");
|
|
221
|
+
if (pending.local.empty) {
|
|
222
|
+
assert(pending.endpointChanges?.empty !== false, "endpointChanges must be empty if not pending changes");
|
|
223
|
+
// eslint-disable-next-line @typescript-eslint/no-dynamic-delete
|
|
224
|
+
delete pendingChanges[id];
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
function hasEndpointChanges(serialized) {
|
|
228
|
+
return serialized.start !== undefined && serialized.end !== undefined;
|
|
229
|
+
}
|
|
211
230
|
/**
|
|
212
231
|
* {@inheritdoc IIntervalCollection}
|
|
213
232
|
*/
|
|
@@ -217,11 +236,19 @@ export class IntervalCollection extends TypedEventEmitter {
|
|
|
217
236
|
}
|
|
218
237
|
constructor(submitDelta, serializedIntervals, options = {}) {
|
|
219
238
|
super();
|
|
220
|
-
this.submitDelta = submitDelta;
|
|
221
239
|
this.options = options;
|
|
222
|
-
this.
|
|
223
|
-
this.
|
|
224
|
-
|
|
240
|
+
this.pending = {};
|
|
241
|
+
this.submitDelta = (op, md) => {
|
|
242
|
+
const { id } = getSerializedProperties(op.value);
|
|
243
|
+
const pending = (this.pending[id] ??= {
|
|
244
|
+
local: new DoublyLinkedList(),
|
|
245
|
+
});
|
|
246
|
+
if (md.type === "add" || (md.type === "change" && hasEndpointChanges(op.value))) {
|
|
247
|
+
const endpointChanges = (pending.endpointChanges ??= new DoublyLinkedList());
|
|
248
|
+
md.endpointChangesNode = endpointChanges.push(md).last;
|
|
249
|
+
}
|
|
250
|
+
submitDelta(op, pending.local.push(md).last);
|
|
251
|
+
};
|
|
225
252
|
this.savedSerializedIntervals = Array.isArray(serializedIntervals)
|
|
226
253
|
? serializedIntervals
|
|
227
254
|
: serializedIntervals.intervals.map((i) => decompressInterval(i, serializedIntervals.label));
|
|
@@ -254,11 +281,12 @@ export class IntervalCollection extends TypedEventEmitter {
|
|
|
254
281
|
}
|
|
255
282
|
return true;
|
|
256
283
|
}
|
|
257
|
-
rollback(op,
|
|
258
|
-
const
|
|
284
|
+
rollback(op, maybeMetadata) {
|
|
285
|
+
const localOpMetadata = removeMetadataFromPendingChanges(maybeMetadata);
|
|
286
|
+
const { value } = op;
|
|
259
287
|
const { id, properties } = getSerializedProperties(value);
|
|
260
|
-
const {
|
|
261
|
-
switch (
|
|
288
|
+
const { type } = localOpMetadata;
|
|
289
|
+
switch (type) {
|
|
262
290
|
case "add": {
|
|
263
291
|
const interval = this.getIntervalById(id);
|
|
264
292
|
if (interval) {
|
|
@@ -267,8 +295,8 @@ export class IntervalCollection extends TypedEventEmitter {
|
|
|
267
295
|
break;
|
|
268
296
|
}
|
|
269
297
|
case "change": {
|
|
270
|
-
|
|
271
|
-
const endpointsChanged = value
|
|
298
|
+
const { previous } = localOpMetadata;
|
|
299
|
+
const endpointsChanged = hasEndpointChanges(value);
|
|
272
300
|
const start = endpointsChanged
|
|
273
301
|
? toOptionalSequencePlace(previous.start, previous.startSide)
|
|
274
302
|
: undefined;
|
|
@@ -281,14 +309,10 @@ export class IntervalCollection extends TypedEventEmitter {
|
|
|
281
309
|
props: Object.keys(properties).length > 0 ? properties : undefined,
|
|
282
310
|
rollback: true,
|
|
283
311
|
});
|
|
284
|
-
this.localSeqToSerializedInterval.delete(localSeq);
|
|
285
|
-
if (endpointsChanged) {
|
|
286
|
-
this.removePendingChange(value);
|
|
287
|
-
}
|
|
288
312
|
break;
|
|
289
313
|
}
|
|
290
314
|
case "delete": {
|
|
291
|
-
|
|
315
|
+
const { previous } = localOpMetadata;
|
|
292
316
|
this.add({
|
|
293
317
|
id,
|
|
294
318
|
start: toSequencePlace(previous.start, previous.startSide),
|
|
@@ -299,14 +323,22 @@ export class IntervalCollection extends TypedEventEmitter {
|
|
|
299
323
|
break;
|
|
300
324
|
}
|
|
301
325
|
default:
|
|
302
|
-
unreachableCase(
|
|
326
|
+
unreachableCase(type);
|
|
303
327
|
}
|
|
328
|
+
clearEmptyPendingEntry(this.pending, id);
|
|
304
329
|
}
|
|
305
|
-
process(op, local, message,
|
|
330
|
+
process(op, local, message, maybeMetadata) {
|
|
331
|
+
const localOpMetadata = local
|
|
332
|
+
? removeMetadataFromPendingChanges(maybeMetadata)
|
|
333
|
+
: undefined;
|
|
306
334
|
const { opName, value } = op;
|
|
335
|
+
assert((local === false && localOpMetadata === undefined) || opName === localOpMetadata?.type, "must be same type");
|
|
307
336
|
switch (opName) {
|
|
308
337
|
case "add": {
|
|
309
|
-
this.ackAdd(value, local, message,
|
|
338
|
+
this.ackAdd(value, local, message,
|
|
339
|
+
// this cast is safe because of the above assert which
|
|
340
|
+
// validates the op and metadata types match for local changes
|
|
341
|
+
localOpMetadata);
|
|
310
342
|
break;
|
|
311
343
|
}
|
|
312
344
|
case "delete": {
|
|
@@ -314,18 +346,27 @@ export class IntervalCollection extends TypedEventEmitter {
|
|
|
314
346
|
break;
|
|
315
347
|
}
|
|
316
348
|
case "change": {
|
|
317
|
-
this.ackChange(value, local, message
|
|
349
|
+
this.ackChange(value, local, message);
|
|
318
350
|
break;
|
|
319
351
|
}
|
|
320
352
|
default:
|
|
321
353
|
unreachableCase(opName);
|
|
322
354
|
}
|
|
355
|
+
if (local) {
|
|
356
|
+
const { id } = getSerializedProperties(value);
|
|
357
|
+
clearEmptyPendingEntry(this.pending, id);
|
|
358
|
+
}
|
|
323
359
|
}
|
|
324
|
-
resubmitMessage(op,
|
|
360
|
+
resubmitMessage(op, maybeMetadata) {
|
|
325
361
|
const { opName, value } = op;
|
|
326
|
-
const
|
|
362
|
+
const localOpMetadata = removeMetadataFromPendingChanges(maybeMetadata);
|
|
363
|
+
const rebasedValue = localOpMetadata.endpointChangesNode === undefined
|
|
364
|
+
? value
|
|
365
|
+
: this.rebaseLocalInterval(localOpMetadata);
|
|
327
366
|
if (rebasedValue === undefined) {
|
|
328
|
-
|
|
367
|
+
const { id } = getSerializedProperties(value);
|
|
368
|
+
clearEmptyPendingEntry(this.pending, id);
|
|
369
|
+
return;
|
|
329
370
|
}
|
|
330
371
|
this.submitDelta({ opName, value: rebasedValue }, localOpMetadata);
|
|
331
372
|
}
|
|
@@ -370,21 +411,20 @@ export class IntervalCollection extends TypedEventEmitter {
|
|
|
370
411
|
const { segment, offset } = this.client.getContainingSegment(pos, {
|
|
371
412
|
referenceSequenceNumber: seqNumberFrom,
|
|
372
413
|
clientId: this.client.getLongClientId(clientId),
|
|
373
|
-
}, localSeq);
|
|
414
|
+
}, localSeq) ?? {};
|
|
374
415
|
// if segment is undefined, it slid off the string
|
|
375
|
-
assert(segment !== undefined, 0x54e /* No segment found */);
|
|
376
|
-
const segoff = getSlideToSegoff({ segment, offset }, undefined, createLocalReconnectingPerspective(this.client.getCurrentSeq(), clientId, localSeq), this.options.mergeTreeReferencesCanSlideToEndpoint)
|
|
416
|
+
assert(segment !== undefined && offset !== undefined, 0x54e /* No segment found */);
|
|
417
|
+
const segoff = getSlideToSegoff({ segment, offset }, undefined, createLocalReconnectingPerspective(this.client.getCurrentSeq(), clientId, localSeq), this.options.mergeTreeReferencesCanSlideToEndpoint);
|
|
377
418
|
// case happens when rebasing op, but concurrently entire string has been deleted
|
|
378
|
-
if (segoff
|
|
419
|
+
if (segoff?.segment === undefined || segoff.offset === undefined) {
|
|
379
420
|
return DetachedReferencePosition;
|
|
380
421
|
}
|
|
381
422
|
assert(offset !== undefined && 0 <= offset && offset < segment.cachedLength, 0x54f /* Invalid offset */);
|
|
382
423
|
return this.client.findReconnectionPosition(segoff.segment, localSeq) + segoff.offset;
|
|
383
424
|
}
|
|
384
|
-
computeRebasedPositions(
|
|
425
|
+
computeRebasedPositions(localOpMetadata) {
|
|
385
426
|
assert(this.client !== undefined, 0x550 /* Client should be defined when computing rebased position */);
|
|
386
|
-
const original =
|
|
387
|
-
assert(original !== undefined, 0x551 /* Failed to store pending serialized interval info for this localSeq. */);
|
|
427
|
+
const { localSeq, original } = localOpMetadata;
|
|
388
428
|
const rebased = { ...original };
|
|
389
429
|
const { start, end, sequenceNumber } = original;
|
|
390
430
|
if (start !== undefined) {
|
|
@@ -406,8 +446,12 @@ export class IntervalCollection extends TypedEventEmitter {
|
|
|
406
446
|
this.client = client;
|
|
407
447
|
if (client) {
|
|
408
448
|
client.on("normalize", () => {
|
|
409
|
-
for (const
|
|
410
|
-
|
|
449
|
+
for (const pending of Object.values(this.pending)) {
|
|
450
|
+
if (pending?.endpointChanges !== undefined) {
|
|
451
|
+
for (const local of pending.endpointChanges) {
|
|
452
|
+
local.data.rebased = this.computeRebasedPositions(local.data);
|
|
453
|
+
}
|
|
454
|
+
}
|
|
411
455
|
}
|
|
412
456
|
});
|
|
413
457
|
}
|
|
@@ -488,13 +532,13 @@ export class IntervalCollection extends TypedEventEmitter {
|
|
|
488
532
|
const serializedInterval = interval.serialize();
|
|
489
533
|
const localSeq = this.getNextLocalSeq();
|
|
490
534
|
if (this.isCollaborating && rollback !== true) {
|
|
491
|
-
this.localSeqToSerializedInterval.set(localSeq, serializedInterval);
|
|
492
535
|
this.submitDelta({
|
|
493
536
|
opName: "add",
|
|
494
537
|
value: serializedInterval,
|
|
495
538
|
}, {
|
|
539
|
+
type: "add",
|
|
496
540
|
localSeq,
|
|
497
|
-
|
|
541
|
+
original: serializedInterval,
|
|
498
542
|
});
|
|
499
543
|
}
|
|
500
544
|
}
|
|
@@ -510,13 +554,14 @@ export class IntervalCollection extends TypedEventEmitter {
|
|
|
510
554
|
if (interval) {
|
|
511
555
|
// Local ops get submitted to the server. Remote ops have the deserializer run.
|
|
512
556
|
if (local && rollback !== true) {
|
|
557
|
+
const value = interval.serialize();
|
|
513
558
|
this.submitDelta({
|
|
514
559
|
opName: "delete",
|
|
515
|
-
value
|
|
560
|
+
value,
|
|
516
561
|
}, {
|
|
562
|
+
type: "delete",
|
|
517
563
|
localSeq: this.getNextLocalSeq(),
|
|
518
|
-
previous:
|
|
519
|
-
intervalId: interval.getIntervalId(),
|
|
564
|
+
previous: value,
|
|
520
565
|
});
|
|
521
566
|
}
|
|
522
567
|
else {
|
|
@@ -579,16 +624,16 @@ export class IntervalCollection extends TypedEventEmitter {
|
|
|
579
624
|
// Emit a property bag containing the ID and the other (if any) properties changed
|
|
580
625
|
const serializedInterval = (newInterval ?? interval).serializeDelta({ props, includeEndpoints: changeEndpoints });
|
|
581
626
|
const localSeq = this.getNextLocalSeq();
|
|
582
|
-
|
|
583
|
-
|
|
627
|
+
const metadata = {
|
|
628
|
+
type: "change",
|
|
629
|
+
localSeq,
|
|
630
|
+
previous: interval.serialize(),
|
|
631
|
+
original: serializedInterval,
|
|
632
|
+
};
|
|
584
633
|
this.submitDelta({
|
|
585
634
|
opName: "change",
|
|
586
635
|
value: serializedInterval,
|
|
587
|
-
},
|
|
588
|
-
localSeq,
|
|
589
|
-
previous: interval.serialize(),
|
|
590
|
-
intervalId: id,
|
|
591
|
-
});
|
|
636
|
+
}, metadata);
|
|
592
637
|
}
|
|
593
638
|
if (deltaProps !== undefined) {
|
|
594
639
|
this.emit("propertyChanged", interval, deltaProps, true, undefined);
|
|
@@ -607,39 +652,10 @@ export class IntervalCollection extends TypedEventEmitter {
|
|
|
607
652
|
get isCollaborating() {
|
|
608
653
|
return this.client?.getCollabWindow().collaborating ?? false;
|
|
609
654
|
}
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
return;
|
|
613
|
-
}
|
|
614
|
-
assert((serializedInterval.start === undefined) === (serializedInterval.end === undefined), 0xbb0 /* both start and end must be set or unset */);
|
|
615
|
-
if (serializedInterval.start !== undefined || serializedInterval.end !== undefined) {
|
|
616
|
-
const entries = this.pendingChanges.get(id) ?? [];
|
|
617
|
-
this.pendingChanges.set(id, entries);
|
|
618
|
-
entries.push(serializedInterval);
|
|
619
|
-
}
|
|
655
|
+
hasPendingEndpointChanges(id) {
|
|
656
|
+
return this.pending[id]?.endpointChanges?.empty === false;
|
|
620
657
|
}
|
|
621
|
-
|
|
622
|
-
// Change ops always have an ID.
|
|
623
|
-
const { id } = getSerializedProperties(serializedInterval);
|
|
624
|
-
if (serializedInterval.start !== undefined) {
|
|
625
|
-
const entries = this.pendingChanges.get(id);
|
|
626
|
-
if (entries) {
|
|
627
|
-
const pendingChange = entries.shift();
|
|
628
|
-
if (entries.length === 0) {
|
|
629
|
-
this.pendingChanges.delete(id);
|
|
630
|
-
}
|
|
631
|
-
if (pendingChange?.start !== serializedInterval.start ||
|
|
632
|
-
pendingChange?.end !== serializedInterval.end) {
|
|
633
|
-
throw new LoggingError("Mismatch in pending changes");
|
|
634
|
-
}
|
|
635
|
-
}
|
|
636
|
-
}
|
|
637
|
-
}
|
|
638
|
-
hasPendingChanges(id) {
|
|
639
|
-
const entries = this.pendingChanges.get(id);
|
|
640
|
-
return entries && entries.length !== 0;
|
|
641
|
-
}
|
|
642
|
-
ackChange(serializedInterval, local, op, localOpMetadata) {
|
|
658
|
+
ackChange(serializedInterval, local, op) {
|
|
643
659
|
if (!this.localCollection) {
|
|
644
660
|
throw new LoggingError("Attach must be called before accessing intervals");
|
|
645
661
|
}
|
|
@@ -649,12 +665,6 @@ export class IntervalCollection extends TypedEventEmitter {
|
|
|
649
665
|
const { id, properties } = getSerializedProperties(serializedInterval);
|
|
650
666
|
assert(id !== undefined, 0x3fe /* id must exist on the interval */);
|
|
651
667
|
const interval = this.getIntervalById(id);
|
|
652
|
-
if (local) {
|
|
653
|
-
assert(localOpMetadata !== undefined, 0x552 /* op metadata should be defined for local op */);
|
|
654
|
-
// This is an ack from the server. Remove the pending change.
|
|
655
|
-
this.localSeqToSerializedInterval.delete(localOpMetadata?.localSeq);
|
|
656
|
-
this.removePendingChange(serializedInterval);
|
|
657
|
-
}
|
|
658
668
|
if (!interval) {
|
|
659
669
|
// The interval has been removed locally; no-op.
|
|
660
670
|
return;
|
|
@@ -669,7 +679,7 @@ export class IntervalCollection extends TypedEventEmitter {
|
|
|
669
679
|
let start;
|
|
670
680
|
let end;
|
|
671
681
|
// Track pending start/end independently of one another.
|
|
672
|
-
if (!this.
|
|
682
|
+
if (!this.hasPendingEndpointChanges(id)) {
|
|
673
683
|
start = serializedInterval.start;
|
|
674
684
|
end = serializedInterval.end;
|
|
675
685
|
}
|
|
@@ -715,18 +725,20 @@ export class IntervalCollection extends TypedEventEmitter {
|
|
|
715
725
|
* to a range that no longer exists, and the interval was unable to slide.
|
|
716
726
|
*
|
|
717
727
|
*/
|
|
718
|
-
rebaseLocalInterval(
|
|
728
|
+
rebaseLocalInterval(localOpMetadata) {
|
|
729
|
+
const original = localOpMetadata.original;
|
|
719
730
|
if (!this.client) {
|
|
720
731
|
// If there's no associated mergeTree client, the originally submitted op is still correct.
|
|
721
|
-
return
|
|
732
|
+
return original;
|
|
722
733
|
}
|
|
723
734
|
if (!this.attached) {
|
|
724
735
|
throw new LoggingError("attachSequence must be called");
|
|
725
736
|
}
|
|
726
737
|
const { localSeq } = localOpMetadata;
|
|
727
|
-
const { intervalType, properties, stickiness, startSide, endSide } =
|
|
728
|
-
const { id } = getSerializedProperties(
|
|
729
|
-
const { start: startRebased, end: endRebased } =
|
|
738
|
+
const { intervalType, properties, stickiness, startSide, endSide } = original;
|
|
739
|
+
const { id } = getSerializedProperties(original);
|
|
740
|
+
const { start: startRebased, end: endRebased } = (localOpMetadata.rebased ??=
|
|
741
|
+
this.computeRebasedPositions(localOpMetadata));
|
|
730
742
|
const localInterval = this.localCollection?.idIntervalIndex.getIntervalById(id);
|
|
731
743
|
const rebased = {
|
|
732
744
|
start: startRebased,
|
|
@@ -738,12 +750,6 @@ export class IntervalCollection extends TypedEventEmitter {
|
|
|
738
750
|
startSide,
|
|
739
751
|
endSide,
|
|
740
752
|
};
|
|
741
|
-
if (opName === "change" &&
|
|
742
|
-
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing -- ?? is not logically equivalent when .hasPendingChangeStart returns false.
|
|
743
|
-
this.hasPendingChanges(id)) {
|
|
744
|
-
this.removePendingChange(serializedInterval);
|
|
745
|
-
this.addPendingChange(id, rebased);
|
|
746
|
-
}
|
|
747
753
|
// if the interval slid off the string, rebase the op to be a noop and delete the interval.
|
|
748
754
|
if (!this.options.mergeTreeReferencesCanSlideToEndpoint &&
|
|
749
755
|
(startRebased === DetachedReferencePosition || endRebased === DetachedReferencePosition)) {
|
|
@@ -763,18 +769,18 @@ export class IntervalCollection extends TypedEventEmitter {
|
|
|
763
769
|
if (!this.client) {
|
|
764
770
|
throw new LoggingError("client does not exist");
|
|
765
771
|
}
|
|
772
|
+
const segment = lref.getSegment();
|
|
773
|
+
if (segment === undefined) {
|
|
774
|
+
return undefined;
|
|
775
|
+
}
|
|
766
776
|
const segoff = {
|
|
767
|
-
segment
|
|
777
|
+
segment,
|
|
768
778
|
offset: lref.getOffset(),
|
|
769
779
|
};
|
|
770
|
-
if (segoff.segment
|
|
780
|
+
if (segoff.segment.localRefs?.has(lref) !== true) {
|
|
771
781
|
return undefined;
|
|
772
782
|
}
|
|
773
|
-
|
|
774
|
-
const value = segoff.segment === newSegoff.segment && segoff.offset === newSegoff.offset
|
|
775
|
-
? undefined
|
|
776
|
-
: newSegoff;
|
|
777
|
-
return value;
|
|
783
|
+
return getSlideToSegoff(segoff, slidingPreference, undefined, this.options.mergeTreeReferencesCanSlideToEndpoint);
|
|
778
784
|
}
|
|
779
785
|
ackInterval(interval, op) {
|
|
780
786
|
if (!refTypeIncludesFlag(interval.start, ReferenceType.StayOnRemove) &&
|
|
@@ -784,13 +790,13 @@ export class IntervalCollection extends TypedEventEmitter {
|
|
|
784
790
|
const newStart = this.getSlideToSegment(interval.start, startReferenceSlidingPreference(interval.stickiness));
|
|
785
791
|
const newEnd = this.getSlideToSegment(interval.end, endReferenceSlidingPreference(interval.stickiness));
|
|
786
792
|
const id = interval.getIntervalId();
|
|
787
|
-
const hasPendingChange = this.
|
|
793
|
+
const hasPendingChange = this.hasPendingEndpointChanges(id);
|
|
788
794
|
if (!hasPendingChange) {
|
|
789
795
|
setSlideOnRemove(interval.start);
|
|
790
796
|
setSlideOnRemove(interval.end);
|
|
791
797
|
}
|
|
792
|
-
const needsStartUpdate = newStart !==
|
|
793
|
-
const needsEndUpdate = newEnd !==
|
|
798
|
+
const needsStartUpdate = newStart?.segment !== interval.start.getSegment() && !hasPendingChange;
|
|
799
|
+
const needsEndUpdate = newEnd?.segment !== interval.end.getSegment() && !hasPendingChange;
|
|
794
800
|
if (needsStartUpdate || needsEndUpdate) {
|
|
795
801
|
if (!this.localCollection) {
|
|
796
802
|
throw new LoggingError("Attach must be called before accessing intervals");
|
|
@@ -836,7 +842,6 @@ export class IntervalCollection extends TypedEventEmitter {
|
|
|
836
842
|
const { id, properties } = getSerializedProperties(serializedInterval);
|
|
837
843
|
if (local) {
|
|
838
844
|
assert(localOpMetadata !== undefined, 0x553 /* op metadata should be defined for local op */);
|
|
839
|
-
this.localSeqToSerializedInterval.delete(localOpMetadata.localSeq);
|
|
840
845
|
const localInterval = this.getIntervalById(id);
|
|
841
846
|
if (localInterval) {
|
|
842
847
|
this.ackInterval(localInterval, op);
|