@fluidframework/sequence 2.41.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/CHANGELOG.md +4 -0
- package/api-report/sequence.legacy.alpha.api.md +13 -5
- package/dist/intervalCollection.d.ts +14 -19
- package/dist/intervalCollection.d.ts.map +1 -1
- package/dist/intervalCollection.js +113 -128
- 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 -4
- 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 +2 -1
- package/dist/sequence.d.ts.map +1 -1
- package/dist/sequence.js +6 -3
- package/dist/sequence.js.map +1 -1
- package/lib/intervalCollection.d.ts +14 -19
- package/lib/intervalCollection.d.ts.map +1 -1
- package/lib/intervalCollection.js +114 -129
- 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 -4
- 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 +2 -1
- package/lib/sequence.d.ts.map +1 -1
- package/lib/sequence.js +6 -3
- package/lib/sequence.js.map +1 -1
- package/package.json +17 -17
- package/src/intervalCollection.ts +191 -195
- package/src/intervalCollectionMap.ts +4 -11
- package/src/intervalCollectionMapInterfaces.ts +25 -5
- 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 +11 -13
package/CHANGELOG.md
CHANGED
|
@@ -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,18 +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 pendingChangesStart;
|
|
328
|
-
private readonly pendingChangesEnd;
|
|
327
|
+
private readonly pending;
|
|
329
328
|
get attached(): boolean;
|
|
330
|
-
|
|
329
|
+
private readonly submitDelta;
|
|
330
|
+
constructor(submitDelta: (op: IIntervalCollectionTypeOperationValue, md: unknown) => void, serializedIntervals: ISerializedIntervalCollectionV1 | ISerializedIntervalCollectionV2, options?: Partial<SequenceOptions>);
|
|
331
331
|
/**
|
|
332
332
|
* {@inheritdoc IIntervalCollection.attachIndex}
|
|
333
333
|
*/
|
|
@@ -336,9 +336,9 @@ export declare class IntervalCollection extends TypedEventEmitter<ISequenceInter
|
|
|
336
336
|
* {@inheritdoc IIntervalCollection.detachIndex}
|
|
337
337
|
*/
|
|
338
338
|
detachIndex(index: SequenceIntervalIndex): boolean;
|
|
339
|
-
rollback(op: IIntervalCollectionTypeOperationValue,
|
|
340
|
-
process(op: IIntervalCollectionTypeOperationValue, local: boolean, message: ISequencedDocumentMessage,
|
|
341
|
-
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;
|
|
342
342
|
applyStashedOp(op: IIntervalCollectionTypeOperationValue): void;
|
|
343
343
|
private rebasePositionWithSegmentSlide;
|
|
344
344
|
private computeRebasedPositions;
|
|
@@ -378,13 +378,8 @@ export declare class IntervalCollection extends TypedEventEmitter<ISequenceInter
|
|
|
378
378
|
rollback?: boolean;
|
|
379
379
|
}): SequenceIntervalClass | undefined;
|
|
380
380
|
private get isCollaborating();
|
|
381
|
-
private
|
|
382
|
-
|
|
383
|
-
private removePendingChange;
|
|
384
|
-
private removePendingChangeHelper;
|
|
385
|
-
private hasPendingChangeStart;
|
|
386
|
-
private hasPendingChangeEnd;
|
|
387
|
-
ackChange(serializedInterval: SerializedIntervalDelta, local: boolean, op: ISequencedDocumentMessage, localOpMetadata: IMapMessageLocalMetadata | undefined): void;
|
|
381
|
+
private hasPendingEndpointChanges;
|
|
382
|
+
ackChange(serializedInterval: SerializedIntervalDelta, local: boolean, op: ISequencedDocumentMessage): void;
|
|
388
383
|
/**
|
|
389
384
|
* {@inheritdoc IIntervalCollection.attachDeserializer}
|
|
390
385
|
*/
|
|
@@ -395,10 +390,10 @@ export declare class IntervalCollection extends TypedEventEmitter<ISequenceInter
|
|
|
395
390
|
* to a range that no longer exists, and the interval was unable to slide.
|
|
396
391
|
*
|
|
397
392
|
*/
|
|
398
|
-
rebaseLocalInterval(
|
|
393
|
+
rebaseLocalInterval(localOpMetadata: IntervalAddLocalMetadata | IntervalChangeLocalMetadata): SerializedIntervalDelta | undefined;
|
|
399
394
|
private getSlideToSegment;
|
|
400
395
|
private ackInterval;
|
|
401
|
-
ackAdd(serializedInterval: ISerializedInterval, local: boolean, op: ISequencedDocumentMessage, localOpMetadata:
|
|
396
|
+
ackAdd(serializedInterval: ISerializedInterval, local: boolean, op: ISequencedDocumentMessage, localOpMetadata: IntervalAddLocalMetadata | undefined): SequenceIntervalClass | undefined;
|
|
402
397
|
ackDelete(serializedInterval: SerializedIntervalDelta, local: boolean, op: ISequencedDocumentMessage): void;
|
|
403
398
|
serializeInternal(version: "1" | "2"): ISerializedIntervalCollectionV1 | ISerializedIntervalCollectionV2;
|
|
404
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,E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AC1C,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,12 +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
|
-
|
|
233
|
-
|
|
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
|
+
};
|
|
234
260
|
this.savedSerializedIntervals = Array.isArray(serializedIntervals)
|
|
235
261
|
? serializedIntervals
|
|
236
262
|
: serializedIntervals.intervals.map((i) => decompressInterval(i, serializedIntervals.label));
|
|
@@ -263,11 +289,12 @@ class IntervalCollection extends client_utils_1.TypedEventEmitter {
|
|
|
263
289
|
}
|
|
264
290
|
return true;
|
|
265
291
|
}
|
|
266
|
-
rollback(op,
|
|
267
|
-
const
|
|
292
|
+
rollback(op, maybeMetadata) {
|
|
293
|
+
const localOpMetadata = removeMetadataFromPendingChanges(maybeMetadata);
|
|
294
|
+
const { value } = op;
|
|
268
295
|
const { id, properties } = (0, index_js_2.getSerializedProperties)(value);
|
|
269
|
-
const {
|
|
270
|
-
switch (
|
|
296
|
+
const { type } = localOpMetadata;
|
|
297
|
+
switch (type) {
|
|
271
298
|
case "add": {
|
|
272
299
|
const interval = this.getIntervalById(id);
|
|
273
300
|
if (interval) {
|
|
@@ -276,8 +303,8 @@ class IntervalCollection extends client_utils_1.TypedEventEmitter {
|
|
|
276
303
|
break;
|
|
277
304
|
}
|
|
278
305
|
case "change": {
|
|
279
|
-
|
|
280
|
-
const endpointsChanged = value
|
|
306
|
+
const { previous } = localOpMetadata;
|
|
307
|
+
const endpointsChanged = hasEndpointChanges(value);
|
|
281
308
|
const start = endpointsChanged
|
|
282
309
|
? toOptionalSequencePlace(previous.start, previous.startSide)
|
|
283
310
|
: undefined;
|
|
@@ -290,14 +317,10 @@ class IntervalCollection extends client_utils_1.TypedEventEmitter {
|
|
|
290
317
|
props: Object.keys(properties).length > 0 ? properties : undefined,
|
|
291
318
|
rollback: true,
|
|
292
319
|
});
|
|
293
|
-
this.localSeqToSerializedInterval.delete(localSeq);
|
|
294
|
-
if (endpointsChanged) {
|
|
295
|
-
this.removePendingChange(value);
|
|
296
|
-
}
|
|
297
320
|
break;
|
|
298
321
|
}
|
|
299
322
|
case "delete": {
|
|
300
|
-
|
|
323
|
+
const { previous } = localOpMetadata;
|
|
301
324
|
this.add({
|
|
302
325
|
id,
|
|
303
326
|
start: toSequencePlace(previous.start, previous.startSide),
|
|
@@ -308,14 +331,22 @@ class IntervalCollection extends client_utils_1.TypedEventEmitter {
|
|
|
308
331
|
break;
|
|
309
332
|
}
|
|
310
333
|
default:
|
|
311
|
-
(0, internal_1.unreachableCase)(
|
|
334
|
+
(0, internal_1.unreachableCase)(type);
|
|
312
335
|
}
|
|
336
|
+
clearEmptyPendingEntry(this.pending, id);
|
|
313
337
|
}
|
|
314
|
-
process(op, local, message,
|
|
338
|
+
process(op, local, message, maybeMetadata) {
|
|
339
|
+
const localOpMetadata = local
|
|
340
|
+
? removeMetadataFromPendingChanges(maybeMetadata)
|
|
341
|
+
: undefined;
|
|
315
342
|
const { opName, value } = op;
|
|
343
|
+
(0, internal_1.assert)((local === false && localOpMetadata === undefined) || opName === localOpMetadata?.type, "must be same type");
|
|
316
344
|
switch (opName) {
|
|
317
345
|
case "add": {
|
|
318
|
-
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);
|
|
319
350
|
break;
|
|
320
351
|
}
|
|
321
352
|
case "delete": {
|
|
@@ -323,19 +354,27 @@ class IntervalCollection extends client_utils_1.TypedEventEmitter {
|
|
|
323
354
|
break;
|
|
324
355
|
}
|
|
325
356
|
case "change": {
|
|
326
|
-
this.ackChange(value, local, message
|
|
357
|
+
this.ackChange(value, local, message);
|
|
327
358
|
break;
|
|
328
359
|
}
|
|
329
360
|
default:
|
|
330
361
|
(0, internal_1.unreachableCase)(opName);
|
|
331
362
|
}
|
|
363
|
+
if (local) {
|
|
364
|
+
const { id } = (0, index_js_2.getSerializedProperties)(value);
|
|
365
|
+
clearEmptyPendingEntry(this.pending, id);
|
|
366
|
+
}
|
|
332
367
|
}
|
|
333
|
-
resubmitMessage(op,
|
|
368
|
+
resubmitMessage(op, maybeMetadata) {
|
|
334
369
|
const { opName, value } = op;
|
|
335
|
-
const
|
|
336
|
-
const rebasedValue =
|
|
370
|
+
const localOpMetadata = removeMetadataFromPendingChanges(maybeMetadata);
|
|
371
|
+
const rebasedValue = localOpMetadata.endpointChangesNode === undefined
|
|
372
|
+
? value
|
|
373
|
+
: this.rebaseLocalInterval(localOpMetadata);
|
|
337
374
|
if (rebasedValue === undefined) {
|
|
338
|
-
|
|
375
|
+
const { id } = (0, index_js_2.getSerializedProperties)(value);
|
|
376
|
+
clearEmptyPendingEntry(this.pending, id);
|
|
377
|
+
return;
|
|
339
378
|
}
|
|
340
379
|
this.submitDelta({ opName, value: rebasedValue }, localOpMetadata);
|
|
341
380
|
}
|
|
@@ -380,21 +419,20 @@ class IntervalCollection extends client_utils_1.TypedEventEmitter {
|
|
|
380
419
|
const { segment, offset } = this.client.getContainingSegment(pos, {
|
|
381
420
|
referenceSequenceNumber: seqNumberFrom,
|
|
382
421
|
clientId: this.client.getLongClientId(clientId),
|
|
383
|
-
}, localSeq);
|
|
422
|
+
}, localSeq) ?? {};
|
|
384
423
|
// if segment is undefined, it slid off the string
|
|
385
|
-
(0, internal_1.assert)(segment !== undefined, 0x54e /* No segment found */);
|
|
386
|
-
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);
|
|
387
426
|
// case happens when rebasing op, but concurrently entire string has been deleted
|
|
388
|
-
if (segoff
|
|
427
|
+
if (segoff?.segment === undefined || segoff.offset === undefined) {
|
|
389
428
|
return internal_2.DetachedReferencePosition;
|
|
390
429
|
}
|
|
391
430
|
(0, internal_1.assert)(offset !== undefined && 0 <= offset && offset < segment.cachedLength, 0x54f /* Invalid offset */);
|
|
392
431
|
return this.client.findReconnectionPosition(segoff.segment, localSeq) + segoff.offset;
|
|
393
432
|
}
|
|
394
|
-
computeRebasedPositions(
|
|
433
|
+
computeRebasedPositions(localOpMetadata) {
|
|
395
434
|
(0, internal_1.assert)(this.client !== undefined, 0x550 /* Client should be defined when computing rebased position */);
|
|
396
|
-
const original =
|
|
397
|
-
(0, internal_1.assert)(original !== undefined, 0x551 /* Failed to store pending serialized interval info for this localSeq. */);
|
|
435
|
+
const { localSeq, original } = localOpMetadata;
|
|
398
436
|
const rebased = { ...original };
|
|
399
437
|
const { start, end, sequenceNumber } = original;
|
|
400
438
|
if (start !== undefined) {
|
|
@@ -416,8 +454,12 @@ class IntervalCollection extends client_utils_1.TypedEventEmitter {
|
|
|
416
454
|
this.client = client;
|
|
417
455
|
if (client) {
|
|
418
456
|
client.on("normalize", () => {
|
|
419
|
-
for (const
|
|
420
|
-
|
|
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
|
+
}
|
|
421
463
|
}
|
|
422
464
|
});
|
|
423
465
|
}
|
|
@@ -488,7 +530,8 @@ class IntervalCollection extends client_utils_1.TypedEventEmitter {
|
|
|
488
530
|
startSide !== undefined &&
|
|
489
531
|
endSide !== undefined, 0x793 /* start and end cannot be undefined because they were not passed in as undefined */);
|
|
490
532
|
this.assertStickinessEnabled(start, end);
|
|
491
|
-
const
|
|
533
|
+
const intervalId = id ?? (0, uuid_1.v4)();
|
|
534
|
+
const interval = this.localCollection.addInterval(intervalId, toSequencePlace(startPos, startSide), toSequencePlace(endPos, endSide), props, undefined, rollback);
|
|
492
535
|
if (interval) {
|
|
493
536
|
if (!this.isCollaborating) {
|
|
494
537
|
setSlideOnRemove(interval.start);
|
|
@@ -497,12 +540,13 @@ class IntervalCollection extends client_utils_1.TypedEventEmitter {
|
|
|
497
540
|
const serializedInterval = interval.serialize();
|
|
498
541
|
const localSeq = this.getNextLocalSeq();
|
|
499
542
|
if (this.isCollaborating && rollback !== true) {
|
|
500
|
-
this.localSeqToSerializedInterval.set(localSeq, serializedInterval);
|
|
501
543
|
this.submitDelta({
|
|
502
544
|
opName: "add",
|
|
503
545
|
value: serializedInterval,
|
|
504
546
|
}, {
|
|
547
|
+
type: "add",
|
|
505
548
|
localSeq,
|
|
549
|
+
original: serializedInterval,
|
|
506
550
|
});
|
|
507
551
|
}
|
|
508
552
|
}
|
|
@@ -518,12 +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:
|
|
572
|
+
previous: value,
|
|
527
573
|
});
|
|
528
574
|
}
|
|
529
575
|
else {
|
|
@@ -586,15 +632,16 @@ class IntervalCollection extends client_utils_1.TypedEventEmitter {
|
|
|
586
632
|
// Emit a property bag containing the ID and the other (if any) properties changed
|
|
587
633
|
const serializedInterval = (newInterval ?? interval).serializeDelta({ props, includeEndpoints: changeEndpoints });
|
|
588
634
|
const localSeq = this.getNextLocalSeq();
|
|
589
|
-
|
|
590
|
-
|
|
635
|
+
const metadata = {
|
|
636
|
+
type: "change",
|
|
637
|
+
localSeq,
|
|
638
|
+
previous: interval.serialize(),
|
|
639
|
+
original: serializedInterval,
|
|
640
|
+
};
|
|
591
641
|
this.submitDelta({
|
|
592
642
|
opName: "change",
|
|
593
643
|
value: serializedInterval,
|
|
594
|
-
},
|
|
595
|
-
localSeq,
|
|
596
|
-
previous: interval.serialize(),
|
|
597
|
-
});
|
|
644
|
+
}, metadata);
|
|
598
645
|
}
|
|
599
646
|
if (deltaProps !== undefined) {
|
|
600
647
|
this.emit("propertyChanged", interval, deltaProps, true, undefined);
|
|
@@ -613,66 +660,13 @@ class IntervalCollection extends client_utils_1.TypedEventEmitter {
|
|
|
613
660
|
get isCollaborating() {
|
|
614
661
|
return this.client?.getCollabWindow().collaborating ?? false;
|
|
615
662
|
}
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
return;
|
|
619
|
-
}
|
|
620
|
-
if (serializedInterval.start !== undefined) {
|
|
621
|
-
this.addPendingChangeHelper(id, this.pendingChangesStart, serializedInterval);
|
|
622
|
-
}
|
|
623
|
-
if (serializedInterval.end !== undefined) {
|
|
624
|
-
this.addPendingChangeHelper(id, this.pendingChangesEnd, serializedInterval);
|
|
625
|
-
}
|
|
626
|
-
}
|
|
627
|
-
addPendingChangeHelper(id, pendingChanges, serializedInterval) {
|
|
628
|
-
let entries = pendingChanges.get(id);
|
|
629
|
-
if (!entries) {
|
|
630
|
-
entries = [];
|
|
631
|
-
pendingChanges.set(id, entries);
|
|
632
|
-
}
|
|
633
|
-
entries.push(serializedInterval);
|
|
634
|
-
}
|
|
635
|
-
removePendingChange(serializedInterval) {
|
|
636
|
-
// Change ops always have an ID.
|
|
637
|
-
const { id } = (0, index_js_2.getSerializedProperties)(serializedInterval);
|
|
638
|
-
if (serializedInterval.start !== undefined) {
|
|
639
|
-
this.removePendingChangeHelper(id, this.pendingChangesStart, serializedInterval);
|
|
640
|
-
}
|
|
641
|
-
if (serializedInterval.end !== undefined) {
|
|
642
|
-
this.removePendingChangeHelper(id, this.pendingChangesEnd, serializedInterval);
|
|
643
|
-
}
|
|
644
|
-
}
|
|
645
|
-
removePendingChangeHelper(id, pendingChanges, serializedInterval) {
|
|
646
|
-
const entries = pendingChanges.get(id);
|
|
647
|
-
if (entries) {
|
|
648
|
-
const pendingChange = entries.shift();
|
|
649
|
-
if (entries.length === 0) {
|
|
650
|
-
pendingChanges.delete(id);
|
|
651
|
-
}
|
|
652
|
-
if (pendingChange?.start !== serializedInterval.start ||
|
|
653
|
-
pendingChange?.end !== serializedInterval.end) {
|
|
654
|
-
throw new internal_3.LoggingError("Mismatch in pending changes");
|
|
655
|
-
}
|
|
656
|
-
}
|
|
657
|
-
}
|
|
658
|
-
hasPendingChangeStart(id) {
|
|
659
|
-
const entries = this.pendingChangesStart.get(id);
|
|
660
|
-
return entries && entries.length !== 0;
|
|
661
|
-
}
|
|
662
|
-
hasPendingChangeEnd(id) {
|
|
663
|
-
const entries = this.pendingChangesEnd.get(id);
|
|
664
|
-
return entries && entries.length !== 0;
|
|
663
|
+
hasPendingEndpointChanges(id) {
|
|
664
|
+
return this.pending[id]?.endpointChanges?.empty === false;
|
|
665
665
|
}
|
|
666
|
-
ackChange(serializedInterval, local, op
|
|
666
|
+
ackChange(serializedInterval, local, op) {
|
|
667
667
|
if (!this.localCollection) {
|
|
668
668
|
throw new internal_3.LoggingError("Attach must be called before accessing intervals");
|
|
669
669
|
}
|
|
670
|
-
if (local) {
|
|
671
|
-
(0, internal_1.assert)(localOpMetadata !== undefined, 0x552 /* op metadata should be defined for local op */);
|
|
672
|
-
this.localSeqToSerializedInterval.delete(localOpMetadata?.localSeq);
|
|
673
|
-
// This is an ack from the server. Remove the pending change.
|
|
674
|
-
this.removePendingChange(serializedInterval);
|
|
675
|
-
}
|
|
676
670
|
// Note that the ID is in the property bag only to allow us to find the interval.
|
|
677
671
|
// This API cannot change the ID, and writing to the ID property will result in an exception. So we
|
|
678
672
|
// strip it out of the properties here.
|
|
@@ -693,10 +687,8 @@ class IntervalCollection extends client_utils_1.TypedEventEmitter {
|
|
|
693
687
|
let start;
|
|
694
688
|
let end;
|
|
695
689
|
// Track pending start/end independently of one another.
|
|
696
|
-
if (!this.
|
|
690
|
+
if (!this.hasPendingEndpointChanges(id)) {
|
|
697
691
|
start = serializedInterval.start;
|
|
698
|
-
}
|
|
699
|
-
if (!this.hasPendingChangeEnd(id)) {
|
|
700
692
|
end = serializedInterval.end;
|
|
701
693
|
}
|
|
702
694
|
let newInterval = interval;
|
|
@@ -741,17 +733,20 @@ class IntervalCollection extends client_utils_1.TypedEventEmitter {
|
|
|
741
733
|
* to a range that no longer exists, and the interval was unable to slide.
|
|
742
734
|
*
|
|
743
735
|
*/
|
|
744
|
-
rebaseLocalInterval(
|
|
736
|
+
rebaseLocalInterval(localOpMetadata) {
|
|
737
|
+
const original = localOpMetadata.original;
|
|
745
738
|
if (!this.client) {
|
|
746
739
|
// If there's no associated mergeTree client, the originally submitted op is still correct.
|
|
747
|
-
return
|
|
740
|
+
return original;
|
|
748
741
|
}
|
|
749
742
|
if (!this.attached) {
|
|
750
743
|
throw new internal_3.LoggingError("attachSequence must be called");
|
|
751
744
|
}
|
|
752
|
-
const {
|
|
753
|
-
const {
|
|
754
|
-
const {
|
|
745
|
+
const { localSeq } = localOpMetadata;
|
|
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));
|
|
755
750
|
const localInterval = this.localCollection?.idIntervalIndex.getIntervalById(id);
|
|
756
751
|
const rebased = {
|
|
757
752
|
start: startRebased,
|
|
@@ -763,12 +758,6 @@ class IntervalCollection extends client_utils_1.TypedEventEmitter {
|
|
|
763
758
|
startSide,
|
|
764
759
|
endSide,
|
|
765
760
|
};
|
|
766
|
-
if (opName === "change" &&
|
|
767
|
-
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing -- ?? is not logically equivalent when .hasPendingChangeStart returns false.
|
|
768
|
-
(this.hasPendingChangeStart(id) || this.hasPendingChangeEnd(id))) {
|
|
769
|
-
this.removePendingChange(serializedInterval);
|
|
770
|
-
this.addPendingChange(id, rebased);
|
|
771
|
-
}
|
|
772
761
|
// if the interval slid off the string, rebase the op to be a noop and delete the interval.
|
|
773
762
|
if (!this.options.mergeTreeReferencesCanSlideToEndpoint &&
|
|
774
763
|
(startRebased === internal_2.DetachedReferencePosition || endRebased === internal_2.DetachedReferencePosition)) {
|
|
@@ -788,18 +777,18 @@ class IntervalCollection extends client_utils_1.TypedEventEmitter {
|
|
|
788
777
|
if (!this.client) {
|
|
789
778
|
throw new internal_3.LoggingError("client does not exist");
|
|
790
779
|
}
|
|
780
|
+
const segment = lref.getSegment();
|
|
781
|
+
if (segment === undefined) {
|
|
782
|
+
return undefined;
|
|
783
|
+
}
|
|
791
784
|
const segoff = {
|
|
792
|
-
segment
|
|
785
|
+
segment,
|
|
793
786
|
offset: lref.getOffset(),
|
|
794
787
|
};
|
|
795
|
-
if (segoff.segment
|
|
788
|
+
if (segoff.segment.localRefs?.has(lref) !== true) {
|
|
796
789
|
return undefined;
|
|
797
790
|
}
|
|
798
|
-
|
|
799
|
-
const value = segoff.segment === newSegoff.segment && segoff.offset === newSegoff.offset
|
|
800
|
-
? undefined
|
|
801
|
-
: newSegoff;
|
|
802
|
-
return value;
|
|
791
|
+
return (0, internal_2.getSlideToSegoff)(segoff, slidingPreference, undefined, this.options.mergeTreeReferencesCanSlideToEndpoint);
|
|
803
792
|
}
|
|
804
793
|
ackInterval(interval, op) {
|
|
805
794
|
if (!(0, internal_2.refTypeIncludesFlag)(interval.start, internal_2.ReferenceType.StayOnRemove) &&
|
|
@@ -809,16 +798,13 @@ class IntervalCollection extends client_utils_1.TypedEventEmitter {
|
|
|
809
798
|
const newStart = this.getSlideToSegment(interval.start, (0, index_js_2.startReferenceSlidingPreference)(interval.stickiness));
|
|
810
799
|
const newEnd = this.getSlideToSegment(interval.end, (0, index_js_2.endReferenceSlidingPreference)(interval.stickiness));
|
|
811
800
|
const id = interval.getIntervalId();
|
|
812
|
-
const
|
|
813
|
-
|
|
814
|
-
if (!hasPendingStartChange) {
|
|
801
|
+
const hasPendingChange = this.hasPendingEndpointChanges(id);
|
|
802
|
+
if (!hasPendingChange) {
|
|
815
803
|
setSlideOnRemove(interval.start);
|
|
816
|
-
}
|
|
817
|
-
if (!hasPendingEndChange) {
|
|
818
804
|
setSlideOnRemove(interval.end);
|
|
819
805
|
}
|
|
820
|
-
const needsStartUpdate = newStart !==
|
|
821
|
-
const needsEndUpdate = newEnd !==
|
|
806
|
+
const needsStartUpdate = newStart?.segment !== interval.start.getSegment() && !hasPendingChange;
|
|
807
|
+
const needsEndUpdate = newEnd?.segment !== interval.end.getSegment() && !hasPendingChange;
|
|
822
808
|
if (needsStartUpdate || needsEndUpdate) {
|
|
823
809
|
if (!this.localCollection) {
|
|
824
810
|
throw new internal_3.LoggingError("Attach must be called before accessing intervals");
|
|
@@ -864,7 +850,6 @@ class IntervalCollection extends client_utils_1.TypedEventEmitter {
|
|
|
864
850
|
const { id, properties } = (0, index_js_2.getSerializedProperties)(serializedInterval);
|
|
865
851
|
if (local) {
|
|
866
852
|
(0, internal_1.assert)(localOpMetadata !== undefined, 0x553 /* op metadata should be defined for local op */);
|
|
867
|
-
this.localSeqToSerializedInterval.delete(localOpMetadata.localSeq);
|
|
868
853
|
const localInterval = this.getIntervalById(id);
|
|
869
854
|
if (localInterval) {
|
|
870
855
|
this.ackInterval(localInterval, op);
|