@fluidframework/merge-tree 2.5.0 → 2.10.0-304831
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/merge-tree.legacy.alpha.api.md +0 -230
- package/dist/client.d.ts +9 -8
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +7 -6
- package/dist/client.js.map +1 -1
- package/dist/index.d.ts +3 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -5
- package/dist/index.js.map +1 -1
- package/dist/legacy.d.ts +0 -12
- package/dist/mergeTree.d.ts +14 -13
- package/dist/mergeTree.d.ts.map +1 -1
- package/dist/mergeTree.js +51 -20
- package/dist/mergeTree.js.map +1 -1
- package/dist/mergeTreeNodes.d.ts +13 -79
- package/dist/mergeTreeNodes.d.ts.map +1 -1
- package/dist/mergeTreeNodes.js +5 -95
- package/dist/mergeTreeNodes.js.map +1 -1
- package/dist/referencePositions.d.ts +0 -12
- package/dist/referencePositions.d.ts.map +1 -1
- package/dist/referencePositions.js.map +1 -1
- package/dist/segmentGroupCollection.d.ts +7 -14
- package/dist/segmentGroupCollection.d.ts.map +1 -1
- package/dist/segmentGroupCollection.js +2 -9
- package/dist/segmentGroupCollection.js.map +1 -1
- package/dist/segmentPropertiesManager.d.ts +13 -12
- package/dist/segmentPropertiesManager.d.ts.map +1 -1
- package/dist/segmentPropertiesManager.js +19 -13
- package/dist/segmentPropertiesManager.js.map +1 -1
- package/dist/sortedSegmentSet.d.ts +0 -1
- package/dist/sortedSegmentSet.d.ts.map +1 -1
- package/dist/sortedSegmentSet.js.map +1 -1
- package/dist/sortedSet.d.ts +0 -1
- package/dist/sortedSet.d.ts.map +1 -1
- package/dist/sortedSet.js +0 -1
- package/dist/sortedSet.js.map +1 -1
- package/dist/test/index.d.ts +2 -2
- package/dist/test/index.d.ts.map +1 -1
- package/dist/test/index.js +2 -4
- package/dist/test/index.js.map +1 -1
- package/dist/test/mergeTree.annotate.spec.js +4 -4
- package/dist/test/mergeTree.annotate.spec.js.map +1 -1
- package/dist/test/segmentGroupCollection.spec.js +22 -18
- package/dist/test/segmentGroupCollection.spec.js.map +1 -1
- package/dist/test/snapshot.spec.js.map +1 -1
- package/dist/test/snapshot.utils.d.ts +4 -4
- package/dist/test/snapshot.utils.d.ts.map +1 -1
- package/dist/test/snapshot.utils.js.map +1 -1
- package/dist/textSegment.d.ts +1 -3
- package/dist/textSegment.d.ts.map +1 -1
- package/dist/textSegment.js.map +1 -1
- package/lib/client.d.ts +9 -8
- package/lib/client.d.ts.map +1 -1
- package/lib/client.js +8 -7
- package/lib/client.js.map +1 -1
- package/lib/index.d.ts +3 -4
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +2 -3
- package/lib/index.js.map +1 -1
- package/lib/legacy.d.ts +0 -12
- package/lib/mergeTree.d.ts +14 -13
- package/lib/mergeTree.d.ts.map +1 -1
- package/lib/mergeTree.js +53 -22
- package/lib/mergeTree.js.map +1 -1
- package/lib/mergeTreeNodes.d.ts +13 -79
- package/lib/mergeTreeNodes.d.ts.map +1 -1
- package/lib/mergeTreeNodes.js +5 -94
- package/lib/mergeTreeNodes.js.map +1 -1
- package/lib/referencePositions.d.ts +0 -12
- package/lib/referencePositions.d.ts.map +1 -1
- package/lib/referencePositions.js.map +1 -1
- package/lib/segmentGroupCollection.d.ts +7 -14
- package/lib/segmentGroupCollection.d.ts.map +1 -1
- package/lib/segmentGroupCollection.js +2 -9
- package/lib/segmentGroupCollection.js.map +1 -1
- package/lib/segmentPropertiesManager.d.ts +13 -12
- package/lib/segmentPropertiesManager.d.ts.map +1 -1
- package/lib/segmentPropertiesManager.js +17 -12
- package/lib/segmentPropertiesManager.js.map +1 -1
- package/lib/sortedSegmentSet.d.ts +0 -1
- package/lib/sortedSegmentSet.d.ts.map +1 -1
- package/lib/sortedSegmentSet.js.map +1 -1
- package/lib/sortedSet.d.ts +0 -1
- package/lib/sortedSet.d.ts.map +1 -1
- package/lib/sortedSet.js +0 -1
- package/lib/sortedSet.js.map +1 -1
- package/lib/test/index.d.ts +2 -2
- package/lib/test/index.d.ts.map +1 -1
- package/lib/test/index.js +2 -2
- package/lib/test/index.js.map +1 -1
- package/lib/test/mergeTree.annotate.spec.js +4 -4
- package/lib/test/mergeTree.annotate.spec.js.map +1 -1
- package/lib/test/segmentGroupCollection.spec.js +22 -18
- package/lib/test/segmentGroupCollection.spec.js.map +1 -1
- package/lib/test/snapshot.spec.js.map +1 -1
- package/lib/test/snapshot.utils.d.ts +4 -4
- package/lib/test/snapshot.utils.d.ts.map +1 -1
- package/lib/test/snapshot.utils.js.map +1 -1
- package/lib/textSegment.d.ts +1 -3
- package/lib/textSegment.d.ts.map +1 -1
- package/lib/textSegment.js.map +1 -1
- package/package.json +91 -19
- package/src/client.ts +15 -12
- package/src/index.ts +6 -3
- package/src/mergeTree.ts +87 -38
- package/src/mergeTreeNodes.ts +16 -177
- package/src/referencePositions.ts +0 -12
- package/src/segmentGroupCollection.ts +14 -20
- package/src/segmentPropertiesManager.ts +30 -12
- package/src/sortedSegmentSet.ts +0 -1
- package/src/sortedSet.ts +0 -1
- package/src/textSegment.ts +1 -3
package/src/mergeTreeNodes.ts
CHANGED
|
@@ -15,9 +15,8 @@ import {
|
|
|
15
15
|
UniversalSequenceNumber,
|
|
16
16
|
} from "./constants.js";
|
|
17
17
|
import { LocalReferenceCollection, type LocalReferencePosition } from "./localReference.js";
|
|
18
|
-
import { IMergeTreeDeltaOpArgs } from "./mergeTreeDeltaCallback.js";
|
|
19
18
|
import { TrackingGroupCollection } from "./mergeTreeTracking.js";
|
|
20
|
-
import { IJSONSegment, IMarkerDef,
|
|
19
|
+
import { IJSONSegment, IMarkerDef, ReferenceType } from "./ops.js";
|
|
21
20
|
import { computeHierarchicalOrdinal } from "./ordinal.js";
|
|
22
21
|
import type { PartialSequenceLengths } from "./partialLengths.js";
|
|
23
22
|
import { PropertySet, clone, createMap, type MapLike } from "./properties.js";
|
|
@@ -29,7 +28,7 @@ import {
|
|
|
29
28
|
// eslint-disable-next-line import/no-deprecated
|
|
30
29
|
import { SegmentGroupCollection } from "./segmentGroupCollection.js";
|
|
31
30
|
// eslint-disable-next-line import/no-deprecated
|
|
32
|
-
import { PropertiesManager
|
|
31
|
+
import { PropertiesManager } from "./segmentPropertiesManager.js";
|
|
33
32
|
|
|
34
33
|
/**
|
|
35
34
|
* Common properties for a node in a merge tree.
|
|
@@ -77,7 +76,6 @@ export type ISegmentLeaf = ISegmentInternal & {
|
|
|
77
76
|
segmentGroups?: SegmentGroupCollection;
|
|
78
77
|
// eslint-disable-next-line import/no-deprecated
|
|
79
78
|
propertyManager?: PropertiesManager;
|
|
80
|
-
|
|
81
79
|
/**
|
|
82
80
|
* If a segment is inserted into an obliterated range,
|
|
83
81
|
* but the newest obliteration of that range was by the inserting client,
|
|
@@ -215,11 +213,7 @@ export function toMoveInfo(maybe: Partial<IMoveInfo> | undefined): IMoveInfo | u
|
|
|
215
213
|
*/
|
|
216
214
|
export interface ISegment extends IMergeNodeCommon, Partial<IRemovalInfo>, Partial<IMoveInfo> {
|
|
217
215
|
readonly type: string;
|
|
218
|
-
|
|
219
|
-
* @deprecated - This property should not be used externally and will be removed in a subsequent release.
|
|
220
|
-
*/
|
|
221
|
-
// eslint-disable-next-line import/no-deprecated
|
|
222
|
-
readonly segmentGroups: SegmentGroupCollection;
|
|
216
|
+
|
|
223
217
|
readonly trackingCollection: TrackingGroupCollection;
|
|
224
218
|
/**
|
|
225
219
|
* Whether or not this segment is a special segment denoting the start or
|
|
@@ -253,18 +247,12 @@ export interface ISegment extends IMergeNodeCommon, Partial<IRemovalInfo>, Parti
|
|
|
253
247
|
*/
|
|
254
248
|
attribution?: IAttributionCollection<AttributionKey>;
|
|
255
249
|
|
|
256
|
-
/**
|
|
257
|
-
* Manages pending local state for properties on this segment.
|
|
258
|
-
*
|
|
259
|
-
* @deprecated - This property should not be used externally and will be removed in a subsequent release.
|
|
260
|
-
*/
|
|
261
|
-
// eslint-disable-next-line import/no-deprecated
|
|
262
|
-
propertyManager?: PropertiesManager;
|
|
263
250
|
/**
|
|
264
251
|
* Local seq at which this segment was inserted.
|
|
265
252
|
* This is defined if and only if the insertion of the segment is pending ack, i.e. `seq` is UnassignedSequenceNumber.
|
|
266
253
|
* Once the segment is acked, this field is cleared.
|
|
267
254
|
*
|
|
255
|
+
* @privateRemarks
|
|
268
256
|
* See {@link CollaborationWindow.localSeq} for more information on the semantics of localSeq.
|
|
269
257
|
*/
|
|
270
258
|
localSeq?: number;
|
|
@@ -274,6 +262,8 @@ export interface ISegment extends IMergeNodeCommon, Partial<IRemovalInfo>, Parti
|
|
|
274
262
|
* will be updated to the seq at which that client removed this segment.
|
|
275
263
|
*
|
|
276
264
|
* Like {@link ISegment.localSeq}, this field is cleared once the local removal of the segment is acked.
|
|
265
|
+
*
|
|
266
|
+
* @privateRemarks
|
|
277
267
|
* See {@link CollaborationWindow.localSeq} for more information on the semantics of localSeq.
|
|
278
268
|
*/
|
|
279
269
|
localRemovedSeq?: number;
|
|
@@ -295,21 +285,6 @@ export interface ISegment extends IMergeNodeCommon, Partial<IRemovalInfo>, Parti
|
|
|
295
285
|
*/
|
|
296
286
|
properties?: PropertySet;
|
|
297
287
|
|
|
298
|
-
/**
|
|
299
|
-
* Add properties to this segment via annotation.
|
|
300
|
-
*
|
|
301
|
-
* @deprecated - This function should not be used externally and will be removed in a subsequent release.
|
|
302
|
-
*
|
|
303
|
-
* @remarks This function should not be called directly. Properties should
|
|
304
|
-
* be added through the `annotateRange` functions.
|
|
305
|
-
*/
|
|
306
|
-
addProperties(
|
|
307
|
-
newProps: PropertySet,
|
|
308
|
-
seq?: number,
|
|
309
|
-
collaborating?: boolean,
|
|
310
|
-
// eslint-disable-next-line import/no-deprecated
|
|
311
|
-
rollback?: PropertiesRollback,
|
|
312
|
-
): PropertySet;
|
|
313
288
|
clone(): ISegment;
|
|
314
289
|
canAppend(segment: ISegment): boolean;
|
|
315
290
|
append(segment: ISegment): void;
|
|
@@ -317,20 +292,6 @@ export interface ISegment extends IMergeNodeCommon, Partial<IRemovalInfo>, Parti
|
|
|
317
292
|
// Changing this to something other than any would break consumers.
|
|
318
293
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
319
294
|
toJSONObject(): any;
|
|
320
|
-
/**
|
|
321
|
-
* @deprecated - This function should not be used externally and will be removed in a subsequent release.
|
|
322
|
-
* Acks the current segment against the segment group, op, and merge tree.
|
|
323
|
-
*
|
|
324
|
-
* @param segmentGroup - Pending segment group associated with this op.
|
|
325
|
-
* @param opArgs - Information about the op that was acked
|
|
326
|
-
* @returns `true` if the op modifies the segment, otherwise `false`.
|
|
327
|
-
* The only current false case is overlapping remove, where a segment is removed
|
|
328
|
-
* by a previously sequenced operation before the current operation is acked.
|
|
329
|
-
* @throws - error if the segment state doesn't match segment group or op.
|
|
330
|
-
* E.g. if the segment group is not first in the pending queue, or
|
|
331
|
-
* an inserted segment does not have unassigned sequence number.
|
|
332
|
-
*/
|
|
333
|
-
ack(segmentGroup: SegmentGroup, opArgs: IMergeTreeDeltaOpArgs): boolean;
|
|
334
295
|
}
|
|
335
296
|
|
|
336
297
|
/**
|
|
@@ -386,7 +347,7 @@ export interface BlockAction<TClientData> {
|
|
|
386
347
|
export interface NodeAction<TClientData> {
|
|
387
348
|
// eslint-disable-next-line @typescript-eslint/prefer-function-type
|
|
388
349
|
(
|
|
389
|
-
node:
|
|
350
|
+
node: IMergeNode,
|
|
390
351
|
pos: number,
|
|
391
352
|
refSeq: number,
|
|
392
353
|
clientId: number,
|
|
@@ -417,10 +378,7 @@ export interface SegmentActions<TClientData> {
|
|
|
417
378
|
}
|
|
418
379
|
|
|
419
380
|
/**
|
|
420
|
-
* @
|
|
421
|
-
* @legacy
|
|
422
|
-
* @alpha
|
|
423
|
-
* @privateRemarks After deprecation period this interface should be made internal
|
|
381
|
+
* @internal
|
|
424
382
|
*/
|
|
425
383
|
export interface ObliterateInfo {
|
|
426
384
|
start: LocalReferencePosition;
|
|
@@ -433,33 +391,16 @@ export interface ObliterateInfo {
|
|
|
433
391
|
}
|
|
434
392
|
|
|
435
393
|
/**
|
|
436
|
-
* @
|
|
437
|
-
* @legacy
|
|
438
|
-
* @alpha
|
|
394
|
+
* @internal
|
|
439
395
|
*/
|
|
440
|
-
export interface SegmentGroup {
|
|
441
|
-
segments:
|
|
396
|
+
export interface SegmentGroup<S extends ISegmentInternal = ISegmentInternal> {
|
|
397
|
+
segments: S[];
|
|
442
398
|
previousProps?: PropertySet[];
|
|
443
399
|
localSeq?: number;
|
|
444
400
|
refSeq: number;
|
|
445
401
|
obliterateInfo?: ObliterateInfo;
|
|
446
402
|
}
|
|
447
403
|
|
|
448
|
-
/**
|
|
449
|
-
* @legacy
|
|
450
|
-
* @alpha
|
|
451
|
-
* @deprecated - unused and will be removed
|
|
452
|
-
*/
|
|
453
|
-
export class MergeNode implements IMergeNodeCommon {
|
|
454
|
-
index: number = 0;
|
|
455
|
-
ordinal: string = "";
|
|
456
|
-
cachedLength: number = 0;
|
|
457
|
-
|
|
458
|
-
isLeaf(): this is ISegment {
|
|
459
|
-
return false;
|
|
460
|
-
}
|
|
461
|
-
}
|
|
462
|
-
|
|
463
404
|
/**
|
|
464
405
|
* Note that the actual branching factor of the MergeTree is `MaxNodesInBlock - 1`. This is because
|
|
465
406
|
* the MergeTree always inserts first, then checks for overflow and splits if the child count equals
|
|
@@ -561,23 +502,12 @@ export abstract class BaseSegment implements ISegment {
|
|
|
561
502
|
public ordinal: string = "";
|
|
562
503
|
public cachedLength: number = 0;
|
|
563
504
|
|
|
564
|
-
/**
|
|
565
|
-
* {@inheritdoc ISegment.segmentGroups}
|
|
566
|
-
* @deprecated - This property should not be used externally and will be removed in a subsequent release.
|
|
567
|
-
*/
|
|
568
|
-
// eslint-disable-next-line import/no-deprecated
|
|
569
|
-
public readonly segmentGroups: SegmentGroupCollection = new SegmentGroupCollection(this);
|
|
570
505
|
public readonly trackingCollection: TrackingGroupCollection = new TrackingGroupCollection(
|
|
571
506
|
this,
|
|
572
507
|
);
|
|
573
508
|
/***/
|
|
574
509
|
public attribution?: IAttributionCollection<AttributionKey>;
|
|
575
|
-
|
|
576
|
-
* {@inheritdoc ISegment.propertyManager}
|
|
577
|
-
* @deprecated - This property should not be used externally and will be removed in a subsequent release.
|
|
578
|
-
*/
|
|
579
|
-
// eslint-disable-next-line import/no-deprecated
|
|
580
|
-
public propertyManager?: PropertiesManager;
|
|
510
|
+
|
|
581
511
|
public properties?: PropertySet;
|
|
582
512
|
public localRefs?: LocalReferenceCollection;
|
|
583
513
|
public abstract readonly type: string;
|
|
@@ -591,31 +521,6 @@ export abstract class BaseSegment implements ISegment {
|
|
|
591
521
|
}
|
|
592
522
|
}
|
|
593
523
|
|
|
594
|
-
/**
|
|
595
|
-
* {@inheritdoc ISegment.addProperties}
|
|
596
|
-
* @deprecated - This function should not be used externally and will be removed in a subsequent release.
|
|
597
|
-
*/
|
|
598
|
-
public addProperties(
|
|
599
|
-
newProps: PropertySet,
|
|
600
|
-
seq?: number,
|
|
601
|
-
collaborating?: boolean,
|
|
602
|
-
// eslint-disable-next-line import/no-deprecated
|
|
603
|
-
rollback: PropertiesRollback = PropertiesRollback.None,
|
|
604
|
-
): PropertySet {
|
|
605
|
-
// eslint-disable-next-line import/no-deprecated
|
|
606
|
-
this.propertyManager ??= new PropertiesManager();
|
|
607
|
-
// A property set must be able to hold properties of any type, so the any is needed.
|
|
608
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
609
|
-
this.properties ??= createMap<any>();
|
|
610
|
-
return this.propertyManager.addProperties(
|
|
611
|
-
this.properties,
|
|
612
|
-
newProps,
|
|
613
|
-
seq,
|
|
614
|
-
collaborating,
|
|
615
|
-
rollback,
|
|
616
|
-
);
|
|
617
|
-
}
|
|
618
|
-
|
|
619
524
|
public hasProperty(key: string): boolean {
|
|
620
525
|
return !!this.properties && this.properties[key] !== undefined;
|
|
621
526
|
}
|
|
@@ -653,73 +558,6 @@ export abstract class BaseSegment implements ISegment {
|
|
|
653
558
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
654
559
|
public abstract toJSONObject(): any;
|
|
655
560
|
|
|
656
|
-
/**
|
|
657
|
-
* {@inheritdoc ISegment.ack}
|
|
658
|
-
* @deprecated - This function should not be used externally and will be removed in a subsequent release.
|
|
659
|
-
*/
|
|
660
|
-
public ack(segmentGroup: SegmentGroup, opArgs: IMergeTreeDeltaOpArgs): boolean {
|
|
661
|
-
const currentSegmentGroup = this.segmentGroups.dequeue();
|
|
662
|
-
assert(
|
|
663
|
-
currentSegmentGroup === segmentGroup,
|
|
664
|
-
0x043 /* "On ack, unexpected segmentGroup!" */,
|
|
665
|
-
);
|
|
666
|
-
switch (opArgs.op.type) {
|
|
667
|
-
case MergeTreeDeltaType.ANNOTATE: {
|
|
668
|
-
assert(
|
|
669
|
-
!!this.propertyManager,
|
|
670
|
-
0x044 /* "On annotate ack, missing segment property manager!" */,
|
|
671
|
-
);
|
|
672
|
-
this.propertyManager.ackPendingProperties(opArgs.op);
|
|
673
|
-
return true;
|
|
674
|
-
}
|
|
675
|
-
|
|
676
|
-
case MergeTreeDeltaType.INSERT: {
|
|
677
|
-
assert(
|
|
678
|
-
this.seq === UnassignedSequenceNumber,
|
|
679
|
-
0x045 /* "On insert, seq number already assigned!" */,
|
|
680
|
-
);
|
|
681
|
-
this.seq = opArgs.sequencedMessage!.sequenceNumber;
|
|
682
|
-
this.localSeq = undefined;
|
|
683
|
-
return true;
|
|
684
|
-
}
|
|
685
|
-
|
|
686
|
-
case MergeTreeDeltaType.REMOVE: {
|
|
687
|
-
const removalInfo: IRemovalInfo | undefined = toRemovalInfo(this);
|
|
688
|
-
assert(removalInfo !== undefined, 0x046 /* "On remove ack, missing removal info!" */);
|
|
689
|
-
this.localRemovedSeq = undefined;
|
|
690
|
-
if (removalInfo.removedSeq === UnassignedSequenceNumber) {
|
|
691
|
-
removalInfo.removedSeq = opArgs.sequencedMessage!.sequenceNumber;
|
|
692
|
-
return true;
|
|
693
|
-
}
|
|
694
|
-
return false;
|
|
695
|
-
}
|
|
696
|
-
|
|
697
|
-
case MergeTreeDeltaType.OBLITERATE:
|
|
698
|
-
case MergeTreeDeltaType.OBLITERATE_SIDED: {
|
|
699
|
-
const moveInfo: IMoveInfo | undefined = toMoveInfo(this);
|
|
700
|
-
assert(moveInfo !== undefined, 0x86e /* On obliterate ack, missing move info! */);
|
|
701
|
-
const obliterateInfo = segmentGroup.obliterateInfo;
|
|
702
|
-
assert(obliterateInfo !== undefined, 0xa40 /* must have obliterate info */);
|
|
703
|
-
this.localMovedSeq = obliterateInfo.localSeq = undefined;
|
|
704
|
-
const seqIdx = moveInfo.movedSeqs.indexOf(UnassignedSequenceNumber);
|
|
705
|
-
assert(seqIdx !== -1, 0x86f /* expected movedSeqs to contain unacked seq */);
|
|
706
|
-
moveInfo.movedSeqs[seqIdx] = obliterateInfo.seq =
|
|
707
|
-
opArgs.sequencedMessage!.sequenceNumber;
|
|
708
|
-
|
|
709
|
-
if (moveInfo.movedSeq === UnassignedSequenceNumber) {
|
|
710
|
-
moveInfo.movedSeq = opArgs.sequencedMessage!.sequenceNumber;
|
|
711
|
-
return true;
|
|
712
|
-
}
|
|
713
|
-
|
|
714
|
-
return false;
|
|
715
|
-
}
|
|
716
|
-
|
|
717
|
-
default: {
|
|
718
|
-
throw new Error(`${opArgs.op.type} is in unrecognized operation type`);
|
|
719
|
-
}
|
|
720
|
-
}
|
|
721
|
-
}
|
|
722
|
-
|
|
723
561
|
public splitAt(pos: number): ISegment | undefined {
|
|
724
562
|
if (pos <= 0) {
|
|
725
563
|
return undefined;
|
|
@@ -896,9 +734,10 @@ export class Marker extends BaseSegment implements ReferencePosition, ISegment {
|
|
|
896
734
|
}
|
|
897
735
|
|
|
898
736
|
/**
|
|
899
|
-
*
|
|
900
|
-
*
|
|
901
|
-
*
|
|
737
|
+
* This class is used to track facts about the current window of collaboration. This window is defined by the server
|
|
738
|
+
* specified minimum sequence number to the last sequence number seen. Additionally, it track state for outstanding
|
|
739
|
+
* local operations.
|
|
740
|
+
* @internal
|
|
902
741
|
*/
|
|
903
742
|
export class CollaborationWindow {
|
|
904
743
|
clientId = LocalClientId;
|
|
@@ -97,18 +97,6 @@ export interface ReferencePosition {
|
|
|
97
97
|
*/
|
|
98
98
|
getOffset(): number;
|
|
99
99
|
|
|
100
|
-
/**
|
|
101
|
-
* @param newProps - Properties to add to this reference.
|
|
102
|
-
* @remarks Note that merge-tree does not broadcast changes to other clients. It is up to the consumer
|
|
103
|
-
* to ensure broadcast happens if that is desired.
|
|
104
|
-
*
|
|
105
|
-
* @deprecated - This function should not be used externally and will be removed in a subsequent release.
|
|
106
|
-
*
|
|
107
|
-
* @privateRemarks This interface is used by both marker segments and local reference positions. We will remove
|
|
108
|
-
* this function from segments, but keep it on local reference positions for now. So it has been added to local reference
|
|
109
|
-
* positions, and must be removed here to not apply to marker segments.
|
|
110
|
-
*/
|
|
111
|
-
addProperties(newProps: PropertySet): void;
|
|
112
100
|
isLeaf(): this is ISegment;
|
|
113
101
|
}
|
|
114
102
|
|
|
@@ -5,22 +5,15 @@
|
|
|
5
5
|
|
|
6
6
|
import { DoublyLinkedList, walkList } from "./collections/index.js";
|
|
7
7
|
// eslint-disable-next-line import/no-deprecated
|
|
8
|
-
import {
|
|
8
|
+
import { SegmentGroup, type ISegmentLeaf } from "./mergeTreeNodes.js";
|
|
9
9
|
|
|
10
|
-
/**
|
|
11
|
-
* @deprecated - This class should not be used externally and will be removed in a subsequent release.
|
|
12
|
-
* @legacy
|
|
13
|
-
* @alpha
|
|
14
|
-
*
|
|
15
|
-
* @privateRemarks After the deprecation period this class should be remove from this package's exports, and only be used internally
|
|
16
|
-
*/
|
|
17
10
|
export class SegmentGroupCollection {
|
|
18
11
|
// eslint-disable-next-line import/no-deprecated
|
|
19
|
-
private readonly segmentGroups: DoublyLinkedList<SegmentGroup
|
|
12
|
+
private readonly segmentGroups: DoublyLinkedList<SegmentGroup<ISegmentLeaf>>;
|
|
20
13
|
|
|
21
|
-
constructor(private readonly segment:
|
|
14
|
+
constructor(private readonly segment: ISegmentLeaf) {
|
|
22
15
|
// eslint-disable-next-line import/no-deprecated
|
|
23
|
-
this.segmentGroups = new DoublyLinkedList<SegmentGroup
|
|
16
|
+
this.segmentGroups = new DoublyLinkedList<SegmentGroup<ISegmentLeaf>>();
|
|
24
17
|
}
|
|
25
18
|
|
|
26
19
|
public get size(): number {
|
|
@@ -32,18 +25,18 @@ export class SegmentGroupCollection {
|
|
|
32
25
|
}
|
|
33
26
|
|
|
34
27
|
// eslint-disable-next-line import/no-deprecated
|
|
35
|
-
public enqueue(segmentGroup: SegmentGroup): void {
|
|
28
|
+
public enqueue(segmentGroup: SegmentGroup<ISegmentLeaf>): void {
|
|
36
29
|
this.segmentGroups.push(segmentGroup);
|
|
37
30
|
segmentGroup.segments.push(this.segment);
|
|
38
31
|
}
|
|
39
32
|
|
|
40
33
|
// eslint-disable-next-line import/no-deprecated
|
|
41
|
-
public dequeue(): SegmentGroup | undefined {
|
|
34
|
+
public dequeue(): SegmentGroup<ISegmentLeaf> | undefined {
|
|
42
35
|
return this.segmentGroups.shift()?.data;
|
|
43
36
|
}
|
|
44
37
|
|
|
45
38
|
// eslint-disable-next-line import/no-deprecated
|
|
46
|
-
public remove?(segmentGroup: SegmentGroup): boolean {
|
|
39
|
+
public remove?(segmentGroup: SegmentGroup<ISegmentLeaf>): boolean {
|
|
47
40
|
const found = this.segmentGroups.find((v) => v.data === segmentGroup);
|
|
48
41
|
if (found === undefined) {
|
|
49
42
|
return false;
|
|
@@ -53,18 +46,19 @@ export class SegmentGroupCollection {
|
|
|
53
46
|
}
|
|
54
47
|
|
|
55
48
|
// eslint-disable-next-line import/no-deprecated
|
|
56
|
-
public pop?(): SegmentGroup | undefined {
|
|
49
|
+
public pop?(): SegmentGroup<ISegmentLeaf> | undefined {
|
|
57
50
|
return this.segmentGroups.pop ? this.segmentGroups.pop()?.data : undefined;
|
|
58
51
|
}
|
|
59
52
|
|
|
60
|
-
public copyTo(
|
|
61
|
-
walkList(this.segmentGroups, (sg) =>
|
|
62
|
-
segment.segmentGroups.enqueueOnCopy(sg.data, this.segment),
|
|
63
|
-
);
|
|
53
|
+
public copyTo(segmentGroups: SegmentGroupCollection): void {
|
|
54
|
+
walkList(this.segmentGroups, (sg) => segmentGroups.enqueueOnCopy(sg.data, this.segment));
|
|
64
55
|
}
|
|
65
56
|
|
|
66
57
|
// eslint-disable-next-line import/no-deprecated
|
|
67
|
-
private enqueueOnCopy(
|
|
58
|
+
private enqueueOnCopy(
|
|
59
|
+
segmentGroup: SegmentGroup<ISegmentLeaf>,
|
|
60
|
+
sourceSegment: ISegmentLeaf,
|
|
61
|
+
): void {
|
|
68
62
|
this.enqueue(segmentGroup);
|
|
69
63
|
if (segmentGroup.previousProps) {
|
|
70
64
|
// duplicate the previousProps for this segment
|
|
@@ -12,12 +12,7 @@ import { IMergeTreeAnnotateMsg } from "./ops.js";
|
|
|
12
12
|
import { MapLike, PropertySet, clone, createMap, extend } from "./properties.js";
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
|
-
* @
|
|
16
|
-
* @alpha
|
|
17
|
-
*
|
|
18
|
-
* @deprecated - This enum should not be used externally and will be removed in a subsequent release.
|
|
19
|
-
*
|
|
20
|
-
* @privateRemarks This enum should be made internal after the deprecation period
|
|
15
|
+
* @internal
|
|
21
16
|
*/
|
|
22
17
|
export enum PropertiesRollback {
|
|
23
18
|
/**
|
|
@@ -32,12 +27,35 @@ export enum PropertiesRollback {
|
|
|
32
27
|
}
|
|
33
28
|
|
|
34
29
|
/**
|
|
35
|
-
*
|
|
36
|
-
* @
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
30
|
+
* Minimally copies properties and the property manager from source to destination.
|
|
31
|
+
* @internal
|
|
32
|
+
*/
|
|
33
|
+
export function copyPropertiesAndManager(
|
|
34
|
+
source: {
|
|
35
|
+
properties?: PropertySet;
|
|
36
|
+
propertyManager?: PropertiesManager;
|
|
37
|
+
},
|
|
38
|
+
destination: {
|
|
39
|
+
properties?: PropertySet;
|
|
40
|
+
propertyManager?: PropertiesManager;
|
|
41
|
+
},
|
|
42
|
+
): void {
|
|
43
|
+
if (source.properties) {
|
|
44
|
+
if (source.propertyManager === undefined) {
|
|
45
|
+
destination.properties = clone(source.properties);
|
|
46
|
+
} else {
|
|
47
|
+
destination.propertyManager ??= new PropertiesManager();
|
|
48
|
+
destination.properties = source.propertyManager.copyTo(
|
|
49
|
+
source.properties,
|
|
50
|
+
destination.properties,
|
|
51
|
+
destination.propertyManager,
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* @internal
|
|
41
59
|
*/
|
|
42
60
|
export class PropertiesManager {
|
|
43
61
|
private pendingKeyUpdateCount: MapLike<number> | undefined;
|
package/src/sortedSegmentSet.ts
CHANGED
|
@@ -9,7 +9,6 @@ import { ISegment } from "./mergeTreeNodes.js";
|
|
|
9
9
|
import { SortedSet } from "./sortedSet.js";
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
|
-
* @deprecated This functionality was not meant to be exported and will be removed in a future release
|
|
13
12
|
* @internal
|
|
14
13
|
*/
|
|
15
14
|
export type SortedSegmentSetItem =
|
package/src/sortedSet.ts
CHANGED
package/src/textSegment.ts
CHANGED
|
@@ -106,9 +106,7 @@ export class TextSegment extends BaseSegment {
|
|
|
106
106
|
}
|
|
107
107
|
|
|
108
108
|
/**
|
|
109
|
-
* @
|
|
110
|
-
* @legacy
|
|
111
|
-
* @alpha
|
|
109
|
+
* @internal
|
|
112
110
|
*/
|
|
113
111
|
export interface IMergeTreeTextHelper {
|
|
114
112
|
getText(
|