@fluidframework/merge-tree 2.13.0 → 2.21.0

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.
Files changed (123) hide show
  1. package/CHANGELOG.md +46 -0
  2. package/api-report/merge-tree.legacy.alpha.api.md +0 -108
  3. package/dist/endOfTreeSegment.d.ts.map +1 -1
  4. package/dist/endOfTreeSegment.js.map +1 -1
  5. package/dist/index.d.ts +1 -2
  6. package/dist/index.d.ts.map +1 -1
  7. package/dist/index.js.map +1 -1
  8. package/dist/legacy.d.ts +0 -4
  9. package/dist/localReference.d.ts +5 -7
  10. package/dist/localReference.d.ts.map +1 -1
  11. package/dist/localReference.js +1 -3
  12. package/dist/localReference.js.map +1 -1
  13. package/dist/mergeTree.d.ts.map +1 -1
  14. package/dist/mergeTree.js +2 -17
  15. package/dist/mergeTree.js.map +1 -1
  16. package/dist/mergeTreeNodes.d.ts +15 -189
  17. package/dist/mergeTreeNodes.d.ts.map +1 -1
  18. package/dist/mergeTreeNodes.js +1 -23
  19. package/dist/mergeTreeNodes.js.map +1 -1
  20. package/dist/opBuilder.d.ts +0 -5
  21. package/dist/opBuilder.d.ts.map +1 -1
  22. package/dist/opBuilder.js +0 -5
  23. package/dist/opBuilder.js.map +1 -1
  24. package/dist/package.json +2 -1
  25. package/dist/partialLengths.d.ts.map +1 -1
  26. package/dist/partialLengths.js +1 -5
  27. package/dist/partialLengths.js.map +1 -1
  28. package/dist/perspective.d.ts.map +1 -1
  29. package/dist/perspective.js +2 -6
  30. package/dist/perspective.js.map +1 -1
  31. package/dist/revertibles.d.ts.map +1 -1
  32. package/dist/revertibles.js +0 -3
  33. package/dist/revertibles.js.map +1 -1
  34. package/dist/segmentInfos.d.ts +0 -6
  35. package/dist/segmentInfos.d.ts.map +1 -1
  36. package/dist/segmentInfos.js.map +1 -1
  37. package/dist/snapshotLoader.d.ts.map +1 -1
  38. package/dist/snapshotLoader.js +1 -3
  39. package/dist/snapshotLoader.js.map +1 -1
  40. package/dist/test/client.obliterateFarm.spec.d.ts +12 -0
  41. package/dist/test/client.obliterateFarm.spec.d.ts.map +1 -0
  42. package/dist/test/client.obliterateFarm.spec.js +80 -0
  43. package/dist/test/client.obliterateFarm.spec.js.map +1 -0
  44. package/dist/test/index.d.ts +1 -1
  45. package/dist/test/index.d.ts.map +1 -1
  46. package/dist/test/index.js.map +1 -1
  47. package/dist/test/mergeTreeOperationRunner.d.ts +6 -1
  48. package/dist/test/mergeTreeOperationRunner.d.ts.map +1 -1
  49. package/dist/test/mergeTreeOperationRunner.js +9 -4
  50. package/dist/test/mergeTreeOperationRunner.js.map +1 -1
  51. package/dist/test/obliterateOperations.d.ts +15 -0
  52. package/dist/test/obliterateOperations.d.ts.map +1 -0
  53. package/dist/test/obliterateOperations.js +121 -0
  54. package/dist/test/obliterateOperations.js.map +1 -0
  55. package/dist/test/testClient.d.ts.map +1 -1
  56. package/dist/test/testClient.js +0 -1
  57. package/dist/test/testClient.js.map +1 -1
  58. package/lib/endOfTreeSegment.d.ts.map +1 -1
  59. package/lib/endOfTreeSegment.js.map +1 -1
  60. package/lib/index.d.ts +1 -2
  61. package/lib/index.d.ts.map +1 -1
  62. package/lib/index.js.map +1 -1
  63. package/lib/legacy.d.ts +0 -4
  64. package/lib/localReference.d.ts +5 -7
  65. package/lib/localReference.d.ts.map +1 -1
  66. package/lib/localReference.js +1 -3
  67. package/lib/localReference.js.map +1 -1
  68. package/lib/mergeTree.d.ts.map +1 -1
  69. package/lib/mergeTree.js +3 -20
  70. package/lib/mergeTree.js.map +1 -1
  71. package/lib/mergeTreeNodes.d.ts +15 -189
  72. package/lib/mergeTreeNodes.d.ts.map +1 -1
  73. package/lib/mergeTreeNodes.js +3 -25
  74. package/lib/mergeTreeNodes.js.map +1 -1
  75. package/lib/opBuilder.d.ts +0 -5
  76. package/lib/opBuilder.d.ts.map +1 -1
  77. package/lib/opBuilder.js +0 -5
  78. package/lib/opBuilder.js.map +1 -1
  79. package/lib/partialLengths.d.ts.map +1 -1
  80. package/lib/partialLengths.js +1 -5
  81. package/lib/partialLengths.js.map +1 -1
  82. package/lib/perspective.d.ts.map +1 -1
  83. package/lib/perspective.js +2 -6
  84. package/lib/perspective.js.map +1 -1
  85. package/lib/revertibles.d.ts.map +1 -1
  86. package/lib/revertibles.js +0 -3
  87. package/lib/revertibles.js.map +1 -1
  88. package/lib/segmentInfos.d.ts +0 -6
  89. package/lib/segmentInfos.d.ts.map +1 -1
  90. package/lib/segmentInfos.js.map +1 -1
  91. package/lib/snapshotLoader.d.ts.map +1 -1
  92. package/lib/snapshotLoader.js +1 -3
  93. package/lib/snapshotLoader.js.map +1 -1
  94. package/lib/test/client.obliterateFarm.spec.d.ts +12 -0
  95. package/lib/test/client.obliterateFarm.spec.d.ts.map +1 -0
  96. package/lib/test/client.obliterateFarm.spec.js +77 -0
  97. package/lib/test/client.obliterateFarm.spec.js.map +1 -0
  98. package/lib/test/index.d.ts +1 -1
  99. package/lib/test/index.d.ts.map +1 -1
  100. package/lib/test/index.js.map +1 -1
  101. package/lib/test/mergeTreeOperationRunner.d.ts +6 -1
  102. package/lib/test/mergeTreeOperationRunner.d.ts.map +1 -1
  103. package/lib/test/mergeTreeOperationRunner.js +9 -4
  104. package/lib/test/mergeTreeOperationRunner.js.map +1 -1
  105. package/lib/test/obliterateOperations.d.ts +15 -0
  106. package/lib/test/obliterateOperations.d.ts.map +1 -0
  107. package/lib/test/obliterateOperations.js +112 -0
  108. package/lib/test/obliterateOperations.js.map +1 -0
  109. package/lib/test/testClient.d.ts.map +1 -1
  110. package/lib/test/testClient.js +0 -1
  111. package/lib/test/testClient.js.map +1 -1
  112. package/package.json +19 -19
  113. package/src/endOfTreeSegment.ts +0 -2
  114. package/src/index.ts +0 -5
  115. package/src/localReference.ts +6 -8
  116. package/src/mergeTree.ts +1 -21
  117. package/src/mergeTreeNodes.ts +25 -223
  118. package/src/opBuilder.ts +0 -5
  119. package/src/partialLengths.ts +0 -4
  120. package/src/perspective.ts +0 -4
  121. package/src/revertibles.ts +0 -3
  122. package/src/segmentInfos.ts +0 -6
  123. package/src/snapshotLoader.ts +1 -5
package/CHANGELOG.md CHANGED
@@ -1,5 +1,51 @@
1
1
  # @fluidframework/merge-tree
2
2
 
3
+ ## 2.21.0
4
+
5
+ Dependency updates only.
6
+
7
+ ## 2.20.0
8
+
9
+ ### Minor Changes
10
+
11
+ - Previously deprecated Merge-Tree and SharedString ISegment members have been removed ([#23448](https://github.com/microsoft/FluidFramework/pull/23448)) [e98574fc62](https://github.com/microsoft/FluidFramework/commit/e98574fc625bea7ebce6d79284f32556aaec1c50)
12
+
13
+ The current `ISegment` interface over-exposes a number of properties which do not have an external use case, and any external usage could result in damage to the underlying merge-tree including data corruption.
14
+ [In Fluid Framework release 2.12.0 these properties and associated types were deprecated.](https://github.com/microsoft/FluidFramework/releases/tag/client_v2.12.0#user-content-merge-tree-and-sharedstring-isegment-deprecations-23323)
15
+
16
+ The only use case that will continue to be supported is determining if a segment is removed. For this purpose we've added the free function `segmentIsRemoved(segment: ISegment): boolean`.
17
+
18
+ For example, checking if a segment is not removed would change as follows:
19
+
20
+ ```diff
21
+ - if(segment.removedSeq === undefined){
22
+ + if(!segmentIsRemoved(segment)){
23
+ ```
24
+
25
+ The following properties are removed from `ISegment` and its implementations:
26
+
27
+ - clientId
28
+ - index
29
+ - localMovedSeq
30
+ - localRefs
31
+ - localRemovedSeq
32
+ - localSeq
33
+ - movedClientsIds
34
+ - movedSeq
35
+ - movedSeqs
36
+ - ordinal
37
+ - removedClientIds
38
+ - removedSeq
39
+ - seq
40
+ - wasMovedOnInsert
41
+
42
+ Additionally, the following types are also removed:
43
+
44
+ - IMergeNodeCommon
45
+ - IMoveInfo
46
+ - IRemovalInfo
47
+ - LocalReferenceCollection
48
+
3
49
  ## 2.13.0
4
50
 
5
51
  Dependency updates only.
@@ -27,8 +27,6 @@ export abstract class BaseSegment implements ISegment {
27
27
  cachedLength: number;
28
28
  // (undocumented)
29
29
  canAppend(segment: ISegment): boolean;
30
- // @deprecated (undocumented)
31
- clientId: number;
32
30
  // (undocumented)
33
31
  abstract clone(): ISegment;
34
32
  // (undocumented)
@@ -37,34 +35,10 @@ export abstract class BaseSegment implements ISegment {
37
35
  protected abstract createSplitSegmentAt(pos: number): BaseSegment | undefined;
38
36
  // (undocumented)
39
37
  hasProperty(key: string): boolean;
40
- // @deprecated (undocumented)
41
- index: number;
42
38
  // (undocumented)
43
39
  isLeaf(): this is ISegment;
44
- // @deprecated (undocumented)
45
- localMovedSeq?: number;
46
- // @deprecated (undocumented)
47
- localRefs?: LocalReferenceCollection;
48
- // @deprecated (undocumented)
49
- localRemovedSeq?: number;
50
- // @deprecated (undocumented)
51
- localSeq?: number;
52
- // @deprecated (undocumented)
53
- movedClientIds?: number[];
54
- // @deprecated (undocumented)
55
- movedSeq?: number;
56
- // @deprecated (undocumented)
57
- movedSeqs?: number[];
58
- // @deprecated (undocumented)
59
- ordinal: string;
60
40
  // (undocumented)
61
41
  properties?: PropertySet;
62
- // @deprecated (undocumented)
63
- removedClientIds?: number[];
64
- // @deprecated (undocumented)
65
- removedSeq?: number;
66
- // @deprecated (undocumented)
67
- seq: number;
68
42
  // (undocumented)
69
43
  splitAt(pos: number): ISegment | undefined;
70
44
  // (undocumented)
@@ -73,8 +47,6 @@ export abstract class BaseSegment implements ISegment {
73
47
  readonly trackingCollection: TrackingGroupCollection;
74
48
  // (undocumented)
75
49
  abstract readonly type: string;
76
- // @deprecated (undocumented)
77
- wasMovedOnInsert?: boolean | undefined;
78
50
  }
79
51
 
80
52
  // @alpha
@@ -160,14 +132,6 @@ export interface IMarkerDef {
160
132
  refType?: ReferenceType;
161
133
  }
162
134
 
163
- // @alpha @deprecated
164
- export interface IMergeNodeCommon {
165
- index: number;
166
- // (undocumented)
167
- isLeaf(): this is ISegment;
168
- ordinal: string;
169
- }
170
-
171
135
  // @alpha (undocumented)
172
136
  export interface IMergeTreeAnnotateAdjustMsg extends IMergeTreeDelta {
173
137
  // (undocumented)
@@ -320,16 +284,6 @@ export interface IMergeTreeSegmentDelta {
320
284
  segment: ISegment;
321
285
  }
322
286
 
323
- // @alpha @deprecated
324
- export interface IMoveInfo {
325
- localMovedSeq?: number;
326
- movedClientIds: number[];
327
- movedSeq: number;
328
- movedSeqs: number[];
329
- moveDst?: ReferencePosition;
330
- wasMovedOnInsert: boolean;
331
- }
332
-
333
287
  // @alpha
334
288
  export interface InteriorSequencePlace {
335
289
  // (undocumented)
@@ -345,13 +299,6 @@ export interface IRelativePosition {
345
299
  offset?: number;
346
300
  }
347
301
 
348
- // @alpha @deprecated
349
- export interface IRemovalInfo {
350
- localRemovedSeq?: number;
351
- removedClientIds: number[];
352
- removedSeq: number;
353
- }
354
-
355
302
  // @alpha
356
303
  export interface ISegment {
357
304
  // (undocumented)
@@ -360,41 +307,11 @@ export interface ISegment {
360
307
  cachedLength: number;
361
308
  // (undocumented)
362
309
  canAppend(segment: ISegment): boolean;
363
- // @deprecated
364
- clientId: number;
365
310
  // (undocumented)
366
311
  clone(): ISegment;
367
- // @deprecated
368
- readonly endpointType?: "start" | "end";
369
- // @deprecated
370
- index: number;
371
312
  // (undocumented)
372
313
  isLeaf(): this is ISegment;
373
- // @deprecated
374
- localMovedSeq?: number;
375
- // @deprecated
376
- localRefs?: LocalReferenceCollection;
377
- // @deprecated
378
- localRemovedSeq?: number;
379
- // @deprecated
380
- localSeq?: number;
381
- // @deprecated
382
- movedClientIds?: number[];
383
- // @deprecated
384
- movedSeq?: number;
385
- // @deprecated
386
- movedSeqs?: number[];
387
- // @deprecated
388
- moveDst?: ReferencePosition;
389
- // @deprecated
390
- ordinal: string;
391
314
  properties?: PropertySet;
392
- // @deprecated
393
- removedClientIds?: number[];
394
- // @deprecated
395
- removedSeq?: number;
396
- // @deprecated
397
- seq?: number;
398
315
  // (undocumented)
399
316
  splitAt(pos: number): ISegment | undefined;
400
317
  // (undocumented)
@@ -403,8 +320,6 @@ export interface ISegment {
403
320
  readonly trackingCollection: TrackingGroupCollection;
404
321
  // (undocumented)
405
322
  readonly type: string;
406
- // @deprecated
407
- wasMovedOnInsert?: boolean;
408
323
  }
409
324
 
410
325
  // @alpha (undocumented)
@@ -427,29 +342,6 @@ export interface ITrackingGroup {
427
342
  unlink(trackable: Trackable): boolean;
428
343
  }
429
344
 
430
- // @alpha @sealed @deprecated
431
- export class LocalReferenceCollection {
432
- [Symbol.iterator](): {
433
- next(): IteratorResult<LocalReferencePosition>;
434
- [Symbol.iterator](): IterableIterator<LocalReferencePosition>;
435
- };
436
- addAfterTombstones(...refs: Iterable<LocalReferencePosition>[]): void;
437
- addBeforeTombstones(...refs: Iterable<LocalReferencePosition>[]): void;
438
- addLocalRef(lref: LocalReferencePosition, offset: number): void;
439
- // (undocumented)
440
- static append(seg1: ISegment, seg2: ISegment): void;
441
- append(other: LocalReferenceCollection): void;
442
- createLocalRef(offset: number, refType: ReferenceType, properties: PropertySet | undefined, slidingPreference?: SlidingPreference, canSlideToEndpoint?: boolean): LocalReferencePosition;
443
- get empty(): boolean;
444
- has(lref: ReferencePosition): boolean;
445
- isAfterTombstone(lref: LocalReferencePosition): boolean;
446
- removeLocalRef(lref: LocalReferencePosition): LocalReferencePosition | undefined;
447
- // (undocumented)
448
- static setOrGet(segment: ISegment): LocalReferenceCollection;
449
- split(offset: number, splitSeg: ISegment): void;
450
- walkReferences(visitor: (lref: LocalReferencePosition) => boolean | void | undefined, start?: LocalReferencePosition, forward?: boolean): boolean;
451
- }
452
-
453
345
  // @alpha @sealed (undocumented)
454
346
  export interface LocalReferencePosition extends ReferencePosition {
455
347
  // (undocumented)
@@ -1 +1 @@
1
- {"version":3,"file":"endOfTreeSegment.d.ts","sourceRoot":"","sources":["../src/endOfTreeSegment.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAMH,OAAO,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAC;AAC/D,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE3C,OAAO,EAAE,QAAQ,EA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E,MAAM,EAAE,EAAE,CAAC;gBACpB,WAAW,GAAG,IAAI,CAAC;gBACnB,OAAO,iCAAU,CAAC,IAAI,CAAC;YACxB,CAAC;QACF,CAAC,EACD,SAAS,EACT,SAAS,EACT,KAAK,CACL,CAAC;QACF,MAAM,MAAM,GAAG,WAAW,EAAE,MAAM,IAAI,IAAI,CAAC;QAC3C,MAAM,KAAK,GAAG,MAAM,CAAC,UAAU,CAAC;QAChC,OAAO;YACN,MAAM;YACN,KAAK;YACL,KAAK;SACL,CAAC;IACH,CAAC;IAED,IAAI,OAAO;QACV,0CAA0C;QAC1C,sCAAsC;QACtC,8CAA8C;QAC9C,kDAAkD;QAClD,OAAO,MAAM,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,oBAAoB,EAAE,CAAC,KAAK,CAAC,CAAC;IAC/E,CAAC;CACD;AA9CD,4CA8CC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\n\nimport { LocalClientId } from \"./constants.js\";\n// eslint-disable-next-line import/no-deprecated\nimport { LocalReferenceCollection } from \"./localReference.js\";\nimport { MergeTree } from \"./mergeTree.js\";\nimport { NodeAction, depthFirstNodeWalk } from \"./mergeTreeNodeWalk.js\";\nimport { ISegment, type ISegmentLeaf, type MergeBlock } from \"./mergeTreeNodes.js\";\nimport { type IMergeNodeInfo } from \"./segmentInfos.js\";\n\n/**\n * This is a special segment that is not bound or known by the merge tree itself,\n * but the segment itself pretends to be a removed segment at an endpoint of the\n * tree. It is removed so it appears as a undefined/0 length segment. This segment\n * adds the capability to hold local references that have been detached from the\n * real merge tree, and give the appearance that they exist at an endpoint of the\n * tree.\n *\n * This is useful today in 2 cases: detached references and interval stickiness.\n *\n * In general, local references only become detached when the tree becomes empty\n * and the EndOfTreeSegment allows us to gracefully handle that case by giving\n * those references a place to live.\n *\n * In the case of interval stickiness, it is desirable to be able to refer to\n * the position immediately after or before a segment, in order for the endpoint\n * of an interval to be exclusive. This means that in order to support intervals\n * that are exclusive and also include the first or last segment of the tree, it\n * must be possible in some way to refer to a position before or after the tree\n * respectively. The endpoint segments allow us to support such behavior.\n */\nabstract class BaseEndpointSegment implements IMergeNodeInfo {\n\tconstructor(protected readonly mergeTree: MergeTree) {}\n\t/*\n\t * segments must be of at least length one, but\n\t * removed segments will have a calculated length\n\t * of undefined/0. we leverage this to create\n\t * a 0 length segment for an endpoint of the tree\n\t */\n\tremovedSeq: number = 0;\n\tremovedClientIds: number[] = [LocalClientId];\n\tattribution: undefined;\n\tpropertyManager: undefined;\n\tlocalSeq: undefined;\n\tlocalRemovedSeq: undefined;\n\tproperties: undefined;\n\tseq = 0;\n\tclientId = LocalClientId;\n\tcachedLength = 1;\n\n\tisLeaf(): this is ISegment {\n\t\treturn true;\n\t}\n\n\tprotected abstract endpointSegmentProps(): {\n\t\tparent: MergeBlock;\n\t\tindex: number;\n\t\tdepth: number;\n\t};\n\n\tget parent(): MergeBlock {\n\t\treturn this.endpointSegmentProps().parent;\n\t}\n\n\tget index(): number {\n\t\treturn this.endpointSegmentProps().index;\n\t}\n\n\tabstract get ordinal(): string;\n\n\t// eslint-disable-next-line import/no-deprecated\n\tlocalRefs?: LocalReferenceCollection;\n\n\t/*\n\t * since this segment isn't real, throw on any segment\n\t * operation that isn't expected\n\t */\n\tget segmentGroups(): never {\n\t\treturn notSupported();\n\t}\n\tget trackingCollection(): never {\n\t\treturn notSupported();\n\t}\n\taddProperties = notSupported;\n\tclone = notSupported;\n\tcanAppend = notSupported;\n\tappend = notSupported;\n\tsplitAt = notSupported;\n\ttoJSONObject = notSupported;\n\tack = notSupported;\n}\n\nconst notSupported = (): never => {\n\tassert(false, 0x3ed /* operation not supported */);\n};\n\n/**\n * The position immediately prior to the start of the tree\n */\nexport class StartOfTreeSegment extends BaseEndpointSegment implements ISegment {\n\ttype: string = \"StartOfTreeSegment\";\n\treadonly endpointType = \"start\";\n\n\t/**\n\t * this segment pretends to be a sibling of the first real segment.\n\t * so compute the necessary properties to pretend to be that segment.\n\t */\n\tprotected endpointSegmentProps(): {\n\t\tparent: MergeBlock;\n\t\tindex: number;\n\t\tdepth: number;\n\t} {\n\t\tlet firstSegment: ISegmentLeaf | undefined;\n\t\tlet depth = 1;\n\t\tconst root = this.mergeTree.root;\n\t\tdepthFirstNodeWalk(\n\t\t\troot,\n\t\t\troot.children[0],\n\t\t\t(node) => {\n\t\t\t\tdepth++;\n\t\t\t\tif (node?.isLeaf()) {\n\t\t\t\t\tfirstSegment = node;\n\t\t\t\t\treturn NodeAction.Exit;\n\t\t\t\t}\n\t\t\t},\n\t\t\tundefined,\n\t\t\tundefined,\n\t\t\tfalse,\n\t\t);\n\t\tconst parent = firstSegment?.parent ?? root;\n\t\tconst index = 0;\n\t\treturn {\n\t\t\tparent,\n\t\t\tindex,\n\t\t\tdepth,\n\t\t};\n\t}\n\n\tget ordinal(): string {\n\t\t// Ordinals exist purely for lexicographical sort order and use a small set of valid bytes for each string character.\n\t\t// The extra handling fromCodePoint has for things like surrogate pairs is therefore unnecessary.\n\t\t// eslint-disable-next-line unicorn/prefer-code-point\n\t\treturn String.fromCharCode(0x00);\n\t}\n}\n\n/**\n * The position immediately after the end of the tree\n */\nexport class EndOfTreeSegment extends BaseEndpointSegment implements ISegment {\n\ttype: string = \"EndOfTreeSegment\";\n\treadonly endpointType = \"end\";\n\n\t/**\n\t * this segment pretends to be a sibling of the last real segment.\n\t * so compute the necessary properties to pretend to be that segment.\n\t */\n\tprotected endpointSegmentProps(): {\n\t\tparent: MergeBlock;\n\t\tindex: number;\n\t\tdepth: number;\n\t} {\n\t\tlet lastSegment: ISegmentLeaf | undefined;\n\t\tlet depth = 1;\n\t\tconst root = this.mergeTree.root;\n\t\tdepthFirstNodeWalk(\n\t\t\troot,\n\t\t\troot.children[root.childCount - 1],\n\t\t\t(node) => {\n\t\t\t\tdepth++;\n\t\t\t\tif (node?.isLeaf()) {\n\t\t\t\t\tlastSegment = node;\n\t\t\t\t\treturn NodeAction.Exit;\n\t\t\t\t}\n\t\t\t},\n\t\t\tundefined,\n\t\t\tundefined,\n\t\t\tfalse,\n\t\t);\n\t\tconst parent = lastSegment?.parent ?? root;\n\t\tconst index = parent.childCount;\n\t\treturn {\n\t\t\tparent,\n\t\t\tindex,\n\t\t\tdepth,\n\t\t};\n\t}\n\n\tget ordinal(): string {\n\t\t// just compute an arbitrarily big ordinal\n\t\t// we base it on the depth of the tree\n\t\t// to ensure it is bigger than all ordinals in\n\t\t// the tree, as each layer appends to the previous\n\t\treturn String.fromCodePoint(0xffff).repeat(this.endpointSegmentProps().depth);\n\t}\n}\n"]}
1
+ {"version":3,"file":"endOfTreeSegment.js","sourceRoot":"","sources":["../src/endOfTreeSegment.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAA6D;AAE7D,iDAA+C;AAG/C,iEAAwE;AAIxE;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAe,mBAAmB;IACjC,YAA+B,SAAoB;QAApB,cAAS,GAAT,SAAS,CAAW;QACnD;;;;;WAKG;QACH,eAAU,GAAW,CAAC,CAAC;QACvB,qBAAgB,GAAa,CAAC,4BAAa,CAAC,CAAC;QAM7C,QAAG,GAAG,CAAC,CAAC;QACR,aAAQ,GAAG,4BAAa,CAAC;QACzB,iBAAY,GAAG,CAAC,CAAC;QAkCjB,kBAAa,GAAG,YAAY,CAAC;QAC7B,UAAK,GAAG,YAAY,CAAC;QACrB,cAAS,GAAG,YAAY,CAAC;QACzB,WAAM,GAAG,YAAY,CAAC;QACtB,YAAO,GAAG,YAAY,CAAC;QACvB,iBAAY,GAAG,YAAY,CAAC;QAC5B,QAAG,GAAG,YAAY,CAAC;IAxDmC,CAAC;IAkBvD,MAAM;QACL,OAAO,IAAI,CAAC;IACb,CAAC;IAQD,IAAI,MAAM;QACT,OAAO,IAAI,CAAC,oBAAoB,EAAE,CAAC,MAAM,CAAC;IAC3C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ClC,CAAC;CACD;AA7CD,gDA6CC;AAED;;GAEG;AACH,MAAa,gBAAiB,SAAQ,mBAAmB;IAAzD;;QACC,SAAI,GAAW,kBAAkB,CAAC;QACzB,iBAAY,GAAG,KAAK,CAAC;IA4C/B,CAAC;IA1CA;;;OAGG;IACO,oBAAoB;QAK7B,IAAI,WAAqC,CAAC;QAC1C,IAAI,KAAK,GAAG,CAAC,CAAC;QACd,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC;QACjC,IAAA,yCAAkB,EACjB,IAAI,EACJ,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,UAAU,GAAG,CAAC,CAAC,EAClC,CAAC,IAAI,EAAE,EAAE;YACR,KAAK,EAAE,CAAC;YACR,IAAI,IAAI,EAAE,MAAM,EAAE,EAAE,CAAC;gBACpB,WAAW,GAAG,IAAI,CAAC;gBACnB,OAAO,iCAAU,CAAC,IAAI,CAAC;YACxB,CAAC;QACF,CAAC,EACD,SAAS,EACT,SAAS,EACT,KAAK,CACL,CAAC;QACF,MAAM,MAAM,GAAG,WAAW,EAAE,MAAM,IAAI,IAAI,CAAC;QAC3C,MAAM,KAAK,GAAG,MAAM,CAAC,UAAU,CAAC;QAChC,OAAO;YACN,MAAM;YACN,KAAK;YACL,KAAK;SACL,CAAC;IACH,CAAC;IAED,IAAI,OAAO;QACV,0CAA0C;QAC1C,sCAAsC;QACtC,8CAA8C;QAC9C,kDAAkD;QAClD,OAAO,MAAM,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,oBAAoB,EAAE,CAAC,KAAK,CAAC,CAAC;IAC/E,CAAC;CACD;AA9CD,4CA8CC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\n\nimport { LocalClientId } from \"./constants.js\";\nimport { LocalReferenceCollection } from \"./localReference.js\";\nimport { MergeTree } from \"./mergeTree.js\";\nimport { NodeAction, depthFirstNodeWalk } from \"./mergeTreeNodeWalk.js\";\nimport { ISegment, type ISegmentLeaf, type MergeBlock } from \"./mergeTreeNodes.js\";\nimport { type IMergeNodeInfo } from \"./segmentInfos.js\";\n\n/**\n * This is a special segment that is not bound or known by the merge tree itself,\n * but the segment itself pretends to be a removed segment at an endpoint of the\n * tree. It is removed so it appears as a undefined/0 length segment. This segment\n * adds the capability to hold local references that have been detached from the\n * real merge tree, and give the appearance that they exist at an endpoint of the\n * tree.\n *\n * This is useful today in 2 cases: detached references and interval stickiness.\n *\n * In general, local references only become detached when the tree becomes empty\n * and the EndOfTreeSegment allows us to gracefully handle that case by giving\n * those references a place to live.\n *\n * In the case of interval stickiness, it is desirable to be able to refer to\n * the position immediately after or before a segment, in order for the endpoint\n * of an interval to be exclusive. This means that in order to support intervals\n * that are exclusive and also include the first or last segment of the tree, it\n * must be possible in some way to refer to a position before or after the tree\n * respectively. The endpoint segments allow us to support such behavior.\n */\nabstract class BaseEndpointSegment implements IMergeNodeInfo {\n\tconstructor(protected readonly mergeTree: MergeTree) {}\n\t/*\n\t * segments must be of at least length one, but\n\t * removed segments will have a calculated length\n\t * of undefined/0. we leverage this to create\n\t * a 0 length segment for an endpoint of the tree\n\t */\n\tremovedSeq: number = 0;\n\tremovedClientIds: number[] = [LocalClientId];\n\tattribution: undefined;\n\tpropertyManager: undefined;\n\tlocalSeq: undefined;\n\tlocalRemovedSeq: undefined;\n\tproperties: undefined;\n\tseq = 0;\n\tclientId = LocalClientId;\n\tcachedLength = 1;\n\n\tisLeaf(): this is ISegment {\n\t\treturn true;\n\t}\n\n\tprotected abstract endpointSegmentProps(): {\n\t\tparent: MergeBlock;\n\t\tindex: number;\n\t\tdepth: number;\n\t};\n\n\tget parent(): MergeBlock {\n\t\treturn this.endpointSegmentProps().parent;\n\t}\n\n\tget index(): number {\n\t\treturn this.endpointSegmentProps().index;\n\t}\n\n\tabstract get ordinal(): string;\n\n\tlocalRefs?: LocalReferenceCollection;\n\n\t/*\n\t * since this segment isn't real, throw on any segment\n\t * operation that isn't expected\n\t */\n\tget segmentGroups(): never {\n\t\treturn notSupported();\n\t}\n\tget trackingCollection(): never {\n\t\treturn notSupported();\n\t}\n\taddProperties = notSupported;\n\tclone = notSupported;\n\tcanAppend = notSupported;\n\tappend = notSupported;\n\tsplitAt = notSupported;\n\ttoJSONObject = notSupported;\n\tack = notSupported;\n}\n\nconst notSupported = (): never => {\n\tassert(false, 0x3ed /* operation not supported */);\n};\n\n/**\n * The position immediately prior to the start of the tree\n */\nexport class StartOfTreeSegment extends BaseEndpointSegment implements ISegment {\n\ttype: string = \"StartOfTreeSegment\";\n\treadonly endpointType = \"start\";\n\n\t/**\n\t * this segment pretends to be a sibling of the first real segment.\n\t * so compute the necessary properties to pretend to be that segment.\n\t */\n\tprotected endpointSegmentProps(): {\n\t\tparent: MergeBlock;\n\t\tindex: number;\n\t\tdepth: number;\n\t} {\n\t\tlet firstSegment: ISegmentLeaf | undefined;\n\t\tlet depth = 1;\n\t\tconst root = this.mergeTree.root;\n\t\tdepthFirstNodeWalk(\n\t\t\troot,\n\t\t\troot.children[0],\n\t\t\t(node) => {\n\t\t\t\tdepth++;\n\t\t\t\tif (node?.isLeaf()) {\n\t\t\t\t\tfirstSegment = node;\n\t\t\t\t\treturn NodeAction.Exit;\n\t\t\t\t}\n\t\t\t},\n\t\t\tundefined,\n\t\t\tundefined,\n\t\t\tfalse,\n\t\t);\n\t\tconst parent = firstSegment?.parent ?? root;\n\t\tconst index = 0;\n\t\treturn {\n\t\t\tparent,\n\t\t\tindex,\n\t\t\tdepth,\n\t\t};\n\t}\n\n\tget ordinal(): string {\n\t\t// Ordinals exist purely for lexicographical sort order and use a small set of valid bytes for each string character.\n\t\t// The extra handling fromCodePoint has for things like surrogate pairs is therefore unnecessary.\n\t\t// eslint-disable-next-line unicorn/prefer-code-point\n\t\treturn String.fromCharCode(0x00);\n\t}\n}\n\n/**\n * The position immediately after the end of the tree\n */\nexport class EndOfTreeSegment extends BaseEndpointSegment implements ISegment {\n\ttype: string = \"EndOfTreeSegment\";\n\treadonly endpointType = \"end\";\n\n\t/**\n\t * this segment pretends to be a sibling of the last real segment.\n\t * so compute the necessary properties to pretend to be that segment.\n\t */\n\tprotected endpointSegmentProps(): {\n\t\tparent: MergeBlock;\n\t\tindex: number;\n\t\tdepth: number;\n\t} {\n\t\tlet lastSegment: ISegmentLeaf | undefined;\n\t\tlet depth = 1;\n\t\tconst root = this.mergeTree.root;\n\t\tdepthFirstNodeWalk(\n\t\t\troot,\n\t\t\troot.children[root.childCount - 1],\n\t\t\t(node) => {\n\t\t\t\tdepth++;\n\t\t\t\tif (node?.isLeaf()) {\n\t\t\t\t\tlastSegment = node;\n\t\t\t\t\treturn NodeAction.Exit;\n\t\t\t\t}\n\t\t\t},\n\t\t\tundefined,\n\t\t\tundefined,\n\t\t\tfalse,\n\t\t);\n\t\tconst parent = lastSegment?.parent ?? root;\n\t\tconst index = parent.childCount;\n\t\treturn {\n\t\t\tparent,\n\t\t\tindex,\n\t\t\tdepth,\n\t\t};\n\t}\n\n\tget ordinal(): string {\n\t\t// just compute an arbitrarily big ordinal\n\t\t// we base it on the depth of the tree\n\t\t// to ensure it is bigger than all ordinals in\n\t\t// the tree, as each layer appends to the previous\n\t\treturn String.fromCodePoint(0xffff).repeat(this.endpointSegmentProps().depth);\n\t}\n}\n"]}
package/dist/index.d.ts CHANGED
@@ -10,13 +10,12 @@ export { UnassignedSequenceNumber, UniversalSequenceNumber } from "./constants.j
10
10
  export { createDetachedLocalReferencePosition, LocalReferenceCollection, LocalReferencePosition, SlidingPreference, } from "./localReference.js";
11
11
  export { AttributionPolicy, IMergeTreeAttributionOptions, IMergeTreeOptions, IMergeTreeOptionsInternal, getSlideToSegoff, } from "./mergeTree.js";
12
12
  export { IMergeTreeClientSequenceArgs, IMergeTreeDeltaCallbackArgs, IMergeTreeDeltaOpArgs, IMergeTreeMaintenanceCallbackArgs, IMergeTreeSegmentDelta, MergeTreeDeltaOperationType, MergeTreeDeltaOperationTypes, MergeTreeMaintenanceType, } from "./mergeTreeDeltaCallback.js";
13
- export { BaseSegment, CollaborationWindow, IJSONMarkerSegment, IMergeNodeCommon, segmentIsRemoved, ISegment, ISegmentAction, Marker, reservedMarkerIdKey, reservedMarkerSimpleTypeKey, ISegmentInternal, } from "./mergeTreeNodes.js";
13
+ export { BaseSegment, CollaborationWindow, IJSONMarkerSegment, segmentIsRemoved, ISegment, ISegmentAction, Marker, reservedMarkerIdKey, reservedMarkerSimpleTypeKey, ISegmentInternal, } from "./mergeTreeNodes.js";
14
14
  export { Trackable, TrackingGroup, ITrackingGroup, TrackingGroupCollection, } from "./mergeTreeTracking.js";
15
15
  export { createAnnotateRangeOp, createGroupOp, createInsertOp, createInsertSegmentOp, createRemoveRangeOp, createObliterateRangeOp, } from "./opBuilder.js";
16
16
  export { AdjustParams, IJSONSegment, IMarkerDef, IMergeTreeAnnotateMsg, IMergeTreeDelta, IMergeTreeDeltaOp, IMergeTreeGroupMsg, IMergeTreeInsertMsg, IMergeTreeOp, IMergeTreeRemoveMsg, IMergeTreeAnnotateAdjustMsg, IRelativePosition, MergeTreeDeltaType, ReferenceType, IMergeTreeObliterateMsg, IMergeTreeObliterateSidedMsg, } from "./ops.js";
17
17
  export { addProperties, createMap, MapLike, matchProperties, PropertySet, } from "./properties.js";
18
18
  export { compareReferencePositions, DetachedReferencePosition, maxReferencePosition, minReferencePosition, ReferencePosition, refGetTileLabels, refHasTileLabel, refHasTileLabels, refTypeIncludesFlag, reservedRangeLabelsKey, reservedTileLabelsKey, } from "./referencePositions.js";
19
- export { IMoveInfo, IRemovalInfo, } from "./segmentInfos.js";
20
19
  export { PropsOrAdjust, copyPropertiesAndManager, PropertiesManager, PropertiesRollback, } from "./segmentPropertiesManager.js";
21
20
  export { InteriorSequencePlace, Side, SequencePlace, endpointPosAndSide, } from "./sequencePlace.js";
22
21
  export { SortedSet } from "./sortedSet.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,sBAAsB,EACtB,gCAAgC,EAChC,0BAA0B,EAC1B,+BAA+B,EAC/B,eAAe,GACf,MAAM,4BAA4B,CAAC;AACpC,OAAO,EACN,iCAAiC,EACjC,8CAA8C,EAC9C,0DAA0D,GAC1D,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,EACN,cAAc,EACd,UAAU,EACV,eAAe,EACf,UAAU,EACV,WAAW,EACX,QAAQ,EACR,cAAc,EACd,SAAS,EACT,OAAO,EACP,MAAM,EACN,aAAa,EACb,YAAY,EACZ,gBAAgB,GAChB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,wBAAwB,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAC;AACnF,OAAO,EACN,oCAAoC,EACpC,wBAAwB,EACxB,sBAAsB,EACtB,iBAAiB,GACjB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACN,iBAAiB,EACjB,4BAA4B,EAC5B,iBAAiB,EACjB,yBAAyB,EACzB,gBAAgB,GAChB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACN,4BAA4B,EAC5B,2BAA2B,EAC3B,qBAAqB,EACrB,iCAAiC,EACjC,sBAAsB,EACtB,2BAA2B,EAC3B,4BAA4B,EAC5B,wBAAwB,GACxB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EACN,WAAW,EACX,mBAAmB,EACnB,kBAAkB,EAClB,gBAAgB,EAChB,gBAAgB,EAChB,QAAQ,EACR,cAAc,EACd,MAAM,EACN,mBAAmB,EACnB,2BAA2B,EAC3B,gBAAgB,GAChB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACN,SAAS,EACT,aAAa,EACb,cAAc,EACd,uBAAuB,GACvB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAC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qBAAqB,EACrB,mBAAmB,EACnB,uBAAuB,GACvB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACN,YAAY,EACZ,YAAY,EACZ,UAAU,EACV,qBAAqB,EACrB,eAAe,EACf,iBAAiB,EACjB,kBAAkB,EAClB,mBAAmB,EACnB,YAAY,EACZ,mBAAmB,EACnB,2BAA2B,EAC3B,iBAAiB,EACjB,kBAAkB,EAClB,aAAa,EACb,uBAAuB,EACvB,4BAA4B,GAC5B,MAAM,UAAU,CAAC;AAClB,OAAO,EACN,aAAa,EACb,SAAS,EACT,OAAO,EACP,eAAe,EACf,WAAW,GACX,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACN,yBAAyB,EACzB,yBAAyB,EACzB,oBAAoB,EACpB,oBAAoB,EACpB,iBAAiB,EACjB,gBAAgB,EAChB,eAAe,EACf,gBAAgB,EAChB,mBAAmB,EACnB,sBAAsB,EACtB,qBAAqB,GACrB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACN,aAAa,EACb,wBAAwB,EACxB,iBAAiB,EACjB,kBAAkB,GAClB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACN,qBAAqB,EACrB,IAAI,EACJ,aAAa,EACb,kBAAkB,GAClB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAC/E,OAAO,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AACvF,OAAO,EACN,iCAAiC,EACjC,+BAA+B,EAC/B,0BAA0B,EAC1B,wBAAwB,EACxB,yBAAyB,EACzB,+BAA+B,GAC/B,MAAM,kBAAkB,CAAC"}
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;AASH,+DAIg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AAA;AAChB,4HAAA,mBAAmB,OAAA;AACnB,+HAAA,sBAAsB,OAAA;AACtB,8HAAA,qBAAqB,OAAA;AAMtB,6EAKuC;AAHtC,uIAAA,wBAAwB,OAAA;AACxB,gIAAA,iBAAiB,OAAA;AACjB,iIAAA,kBAAkB,OAAA;AAEnB,uDAK4B;AAH3B,wGAAA,IAAI,OAAA;AAEJ,sHAAA,kBAAkB,OAAA;AAEnB,+CAA2C;AAAlC,yGAAA,SAAS,OAAA;AAClB,6DAA+E;AAAtE,uHAAA,gBAAgB,OAAA;AACzB,mDAAuF;AAAtC,6GAAA,WAAW,OAAA;AAC5D,mDAO0B;AANzB,mIAAA,iCAAiC,OAAA;AACjC,iIAAA,+BAA+B,OAAA;AAC/B,4HAAA,0BAA0B,OAAA;AAG1B,iIAAA,+BAA+B,OAAA","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport {\n\tIAttributionCollection,\n\tIAttributionCollectionSerializer,\n\tIAttributionCollectionSpec,\n\tSerializedAttributionCollection,\n\tSequenceOffsets,\n} from \"./attributionCollection.js\";\nexport {\n\tcreateInsertOnlyAttributionPolicy,\n\tcreatePropertyTrackingAttributionPolicyFactory,\n\tcreatePropertyTrackingAndInsertionAttributionPolicyFactory,\n} from \"./attributionPolicy.js\";\nexport { Client, IClientEvents } from \"./client.js\";\nexport {\n\tConflictAction,\n\tDictionary,\n\tIRBAugmentation,\n\tIRBMatcher,\n\tKeyComparer,\n\tProperty,\n\tPropertyAction,\n\tQProperty,\n\tRBColor,\n\tRBNode,\n\tRBNodeActions,\n\tRedBlackTree,\n\tSortedDictionary,\n} from \"./collections/index.js\";\nexport { UnassignedSequenceNumber, UniversalSequenceNumber } from \"./constants.js\";\nexport {\n\tcreateDetachedLocalReferencePosition,\n\tLocalReferenceCollection,\n\tLocalReferencePosition,\n\tSlidingPreference,\n} from \"./localReference.js\";\nexport {\n\tAttributionPolicy,\n\tIMergeTreeAttributionOptions,\n\tIMergeTreeOptions,\n\tIMergeTreeOptionsInternal,\n\tgetSlideToSegoff,\n} from \"./mergeTree.js\";\nexport {\n\tIMergeTreeClientSequenceArgs,\n\tIMergeTreeDeltaCallbackArgs,\n\tIMergeTreeDeltaOpArgs,\n\tIMergeTreeMaintenanceCallbackArgs,\n\tIMergeTreeSegmentDelta,\n\tMergeTreeDeltaOperationType,\n\tMergeTreeDeltaOperationTypes,\n\tMergeTreeMaintenanceType,\n} from \"./mergeTreeDeltaCallback.js\";\nexport {\n\tBaseSegment,\n\tCollaborationWindow,\n\tIJSONMarkerSegment,\n\tIMergeNodeCommon,\n\tsegmentIsRemoved,\n\tISegment,\n\tISegmentAction,\n\tMarker,\n\treservedMarkerIdKey,\n\treservedMarkerSimpleTypeKey,\n\tISegmentInternal,\n} from \"./mergeTreeNodes.js\";\nexport {\n\tTrackable,\n\tTrackingGroup,\n\tITrackingGroup,\n\tTrackingGroupCollection,\n} from \"./mergeTreeTracking.js\";\nexport {\n\tcreateAnnotateRangeOp,\n\tcreateGroupOp,\n\tcreateInsertOp,\n\tcreateInsertSegmentOp,\n\tcreateRemoveRangeOp,\n\tcreateObliterateRangeOp,\n} from \"./opBuilder.js\";\nexport {\n\tAdjustParams,\n\tIJSONSegment,\n\tIMarkerDef,\n\tIMergeTreeAnnotateMsg,\n\tIMergeTreeDelta,\n\tIMergeTreeDeltaOp,\n\tIMergeTreeGroupMsg,\n\tIMergeTreeInsertMsg,\n\tIMergeTreeOp,\n\tIMergeTreeRemoveMsg,\n\tIMergeTreeAnnotateAdjustMsg,\n\tIRelativePosition,\n\tMergeTreeDeltaType,\n\tReferenceType,\n\tIMergeTreeObliterateMsg,\n\tIMergeTreeObliterateSidedMsg,\n} from \"./ops.js\";\nexport {\n\taddProperties,\n\tcreateMap,\n\tMapLike,\n\tmatchProperties,\n\tPropertySet,\n} from \"./properties.js\";\nexport {\n\tcompareReferencePositions,\n\tDetachedReferencePosition,\n\tmaxReferencePosition,\n\tminReferencePosition,\n\tReferencePosition,\n\trefGetTileLabels,\n\trefHasTileLabel,\n\trefHasTileLabels,\n\trefTypeIncludesFlag,\n\treservedRangeLabelsKey,\n\treservedTileLabelsKey,\n} from \"./referencePositions.js\";\nexport {\n\tIMoveInfo,\n\tIRemovalInfo,\n} from \"./segmentInfos.js\";\nexport {\n\tPropsOrAdjust,\n\tcopyPropertiesAndManager,\n\tPropertiesManager,\n\tPropertiesRollback,\n} from \"./segmentPropertiesManager.js\";\nexport {\n\tInteriorSequencePlace,\n\tSide,\n\tSequencePlace,\n\tendpointPosAndSide,\n} from \"./sequencePlace.js\";\nexport { SortedSet } from \"./sortedSet.js\";\nexport { SortedSegmentSet, SortedSegmentSetItem } from \"./sortedSegmentSet.js\";\nexport { IJSONTextSegment, IMergeTreeTextHelper, TextSegment } from \"./textSegment.js\";\nexport {\n\tappendToMergeTreeDeltaRevertibles,\n\tdiscardMergeTreeDeltaRevertible,\n\tisMergeTreeDeltaRevertible,\n\tMergeTreeDeltaRevertible,\n\tMergeTreeRevertibleDriver,\n\trevertMergeTreeDeltaRevertibles,\n} from \"./revertibles.js\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;AASH,+DAIgC;AAH/B,yIAAA,iCAAiC,OAAA;AACjC,sJAAA,8CAA8C,OAAA;AAC9C,kKAAA,0DAA0D,OAAA;AAE3D,yCAAoD;AAA3C,mGAAA,MAAM,OAAA;AACf,mDAcgC;AAL/B,mGAAA,OAAO,OAAA;AAGP,wGAAA,YAAY,OAAA;AAGb,+CAAmF;AAA1E,wHAAA,wBAAwB,OAAA;AAAE,uHAAA,uBAAuB,OAAA;AAC1D,yDAK6B;AAJ5B,yIAAA,oCAAoC,OAAA;AACpC,6HAAA,wBAAwB,OAAA;AAExB,sHAAA,iBAAiB,OAAA;AAElB,+CAMwB;AADvB,gHAAA,gBAAgB,OAAA;AAEjB,yEASqC;AADpC,qIAAA,w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AA,+BAA+B,OAAA;AAC/B,4HAAA,0BAA0B,OAAA;AAG1B,iIAAA,+BAA+B,OAAA","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport {\n\tIAttributionCollection,\n\tIAttributionCollectionSerializer,\n\tIAttributionCollectionSpec,\n\tSerializedAttributionCollection,\n\tSequenceOffsets,\n} from \"./attributionCollection.js\";\nexport {\n\tcreateInsertOnlyAttributionPolicy,\n\tcreatePropertyTrackingAttributionPolicyFactory,\n\tcreatePropertyTrackingAndInsertionAttributionPolicyFactory,\n} from \"./attributionPolicy.js\";\nexport { Client, IClientEvents } from \"./client.js\";\nexport {\n\tConflictAction,\n\tDictionary,\n\tIRBAugmentation,\n\tIRBMatcher,\n\tKeyComparer,\n\tProperty,\n\tPropertyAction,\n\tQProperty,\n\tRBColor,\n\tRBNode,\n\tRBNodeActions,\n\tRedBlackTree,\n\tSortedDictionary,\n} from \"./collections/index.js\";\nexport { UnassignedSequenceNumber, UniversalSequenceNumber } from \"./constants.js\";\nexport {\n\tcreateDetachedLocalReferencePosition,\n\tLocalReferenceCollection,\n\tLocalReferencePosition,\n\tSlidingPreference,\n} from \"./localReference.js\";\nexport {\n\tAttributionPolicy,\n\tIMergeTreeAttributionOptions,\n\tIMergeTreeOptions,\n\tIMergeTreeOptionsInternal,\n\tgetSlideToSegoff,\n} from \"./mergeTree.js\";\nexport {\n\tIMergeTreeClientSequenceArgs,\n\tIMergeTreeDeltaCallbackArgs,\n\tIMergeTreeDeltaOpArgs,\n\tIMergeTreeMaintenanceCallbackArgs,\n\tIMergeTreeSegmentDelta,\n\tMergeTreeDeltaOperationType,\n\tMergeTreeDeltaOperationTypes,\n\tMergeTreeMaintenanceType,\n} from \"./mergeTreeDeltaCallback.js\";\nexport {\n\tBaseSegment,\n\tCollaborationWindow,\n\tIJSONMarkerSegment,\n\tsegmentIsRemoved,\n\tISegment,\n\tISegmentAction,\n\tMarker,\n\treservedMarkerIdKey,\n\treservedMarkerSimpleTypeKey,\n\tISegmentInternal,\n} from \"./mergeTreeNodes.js\";\nexport {\n\tTrackable,\n\tTrackingGroup,\n\tITrackingGroup,\n\tTrackingGroupCollection,\n} from \"./mergeTreeTracking.js\";\nexport {\n\tcreateAnnotateRangeOp,\n\tcreateGroupOp,\n\tcreateInsertOp,\n\tcreateInsertSegmentOp,\n\tcreateRemoveRangeOp,\n\tcreateObliterateRangeOp,\n} from \"./opBuilder.js\";\nexport {\n\tAdjustParams,\n\tIJSONSegment,\n\tIMarkerDef,\n\tIMergeTreeAnnotateMsg,\n\tIMergeTreeDelta,\n\tIMergeTreeDeltaOp,\n\tIMergeTreeGroupMsg,\n\tIMergeTreeInsertMsg,\n\tIMergeTreeOp,\n\tIMergeTreeRemoveMsg,\n\tIMergeTreeAnnotateAdjustMsg,\n\tIRelativePosition,\n\tMergeTreeDeltaType,\n\tReferenceType,\n\tIMergeTreeObliterateMsg,\n\tIMergeTreeObliterateSidedMsg,\n} from \"./ops.js\";\nexport {\n\taddProperties,\n\tcreateMap,\n\tMapLike,\n\tmatchProperties,\n\tPropertySet,\n} from \"./properties.js\";\nexport {\n\tcompareReferencePositions,\n\tDetachedReferencePosition,\n\tmaxReferencePosition,\n\tminReferencePosition,\n\tReferencePosition,\n\trefGetTileLabels,\n\trefHasTileLabel,\n\trefHasTileLabels,\n\trefTypeIncludesFlag,\n\treservedRangeLabelsKey,\n\treservedTileLabelsKey,\n} from \"./referencePositions.js\";\nexport {\n\tPropsOrAdjust,\n\tcopyPropertiesAndManager,\n\tPropertiesManager,\n\tPropertiesRollback,\n} from \"./segmentPropertiesManager.js\";\nexport {\n\tInteriorSequencePlace,\n\tSide,\n\tSequencePlace,\n\tendpointPosAndSide,\n} from \"./sequencePlace.js\";\nexport { SortedSet } from \"./sortedSet.js\";\nexport { SortedSegmentSet, SortedSegmentSetItem } from \"./sortedSegmentSet.js\";\nexport { IJSONTextSegment, IMergeTreeTextHelper, TextSegment } from \"./textSegment.js\";\nexport {\n\tappendToMergeTreeDeltaRevertibles,\n\tdiscardMergeTreeDeltaRevertible,\n\tisMergeTreeDeltaRevertible,\n\tMergeTreeDeltaRevertible,\n\tMergeTreeRevertibleDriver,\n\trevertMergeTreeDeltaRevertibles,\n} from \"./revertibles.js\";\n"]}
package/dist/legacy.d.ts CHANGED
@@ -19,7 +19,6 @@ export {
19
19
  IJSONSegment,
20
20
  IJSONTextSegment,
21
21
  IMarkerDef,
22
- IMergeNodeCommon,
23
22
  IMergeTreeAnnotateAdjustMsg,
24
23
  IMergeTreeAnnotateMsg,
25
24
  IMergeTreeDelta,
@@ -35,14 +34,11 @@ export {
35
34
  IMergeTreeOptions,
36
35
  IMergeTreeRemoveMsg,
37
36
  IMergeTreeSegmentDelta,
38
- IMoveInfo,
39
37
  IRelativePosition,
40
- IRemovalInfo,
41
38
  ISegment,
42
39
  ISegmentAction,
43
40
  ITrackingGroup,
44
41
  InteriorSequencePlace,
45
- LocalReferenceCollection,
46
42
  LocalReferencePosition,
47
43
  MapLike,
48
44
  Marker,
@@ -2,7 +2,7 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
- import { type ISegment } from "./mergeTreeNodes.js";
5
+ import { type ISegmentInternal } from "./mergeTreeNodes.js";
6
6
  import { TrackingGroupCollection } from "./mergeTreeTracking.js";
7
7
  import { ReferenceType } from "./ops.js";
8
8
  import { PropertySet } from "./properties.js";
@@ -70,17 +70,15 @@ export declare function setValidateRefCount(cb?: (collection?: LocalReferenceCol
70
70
  * Represents a collection of {@link LocalReferencePosition}s associated with one segment in a merge-tree.
71
71
  * @sealed
72
72
  *
73
- * @legacy
74
- * @alpha
75
- * @deprecated - This class will be removed in 2.20 with no replacement.
73
+ * @internal
76
74
  */
77
75
  export declare class LocalReferenceCollection {
78
76
  /**
79
77
  * The segment this `LocalReferenceCollection` is associated with.
80
78
  */
81
79
  private readonly segment;
82
- static append(seg1: ISegment, seg2: ISegment): void;
83
- static setOrGet(segment: ISegment): LocalReferenceCollection;
80
+ static append(seg1: ISegmentInternal, seg2: ISegmentInternal): void;
81
+ static setOrGet(segment: ISegmentInternal): LocalReferenceCollection;
84
82
  private readonly refsByOffset;
85
83
  private refCount;
86
84
  private constructor();
@@ -141,7 +139,7 @@ export declare class LocalReferenceCollection {
141
139
  *
142
140
  * @remarks This method should only be called by mergeTree.
143
141
  */
144
- split(offset: number, splitSeg: ISegment): void;
142
+ split(offset: number, splitSeg: ISegmentInternal): void;
145
143
  /**
146
144
  * Insert a reference before tombstoned references.
147
145
  * @remarks This method should only be called by mergeTree.
@@ -1 +1 @@
1
- {"version":3,"file":"localReference.d.ts","sourceRoot":"","sources":["../src/localReference.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAMH,OAAO,EAAoB,KAAK,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AACtE,OAAO,EAAiB,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AAChF,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,WAAW,EAAiB,MAAM,iBAAiB,CAAC;AAC7D,OAAO,EAAE,iBAAiB,EAAuB,MAAM,yBAAyB,CAAC;AAEjF;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB;IAC7B;;OAEG;;IAEH;;OAEG;;CAEM,CAAC;AAEX;;;;;GAKG;AACH,MAAM,MAAM,iBAAiB,GAAG,CAAC,OAAO,iBAAiB,CAAC,CAAC,MAAM,OAAO,iBAAiB,CAAC,CAAC;AAmB3F;;;;GAIG;AACH,MAAM,WAAW,sBAAuB,SAAQ,iBAAiB;IAChE,SAAS,CAAC,EAAE,OAAO,CAClB,MAAM,CAAC,aAAa,GAAG,YAAY,EAAE,CAAC,GAAG,EAAE,sBAAsB,KAAK,IAAI,CAAC,CAC3E,CAAC;IACF,QAAQ,CAAC,kBAAkB,EAAE,uBAAuB,CAAC;IACrD;;;OAGG;IACH,QAAQ,CAAC,kBAA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,QAAQ,CAAC,sBAAsB,CAAC,EAAE,GAAG,IAAI;IA8B7E;;;OAGG;IACI,kBAAkB,CAAC,GAAG,IAAI,EAAE,QAAQ,CAAC,sBAAsB,CAAC,EAAE,GAAG,IAAI;IA4B5E;;;OAGG;IACI,gBAAgB,CAAC,IAAI,EAAE,sBAAsB,GAAG,OAAO;IAS9D;;;OAGG;IACI,cAAc,CACpB,OAAO,EAAE,CAAC,IAAI,EAAE,sBAAsB,KAAK,OAAO,GAAG,IAAI,GAAG,SAAS,EACrE,KAAK,CAAC,EAAE,sBAAsB,EAC9B,OAAO,GAAE,OAAc,GACrB,OAAO;CAyDV"}
@@ -144,9 +144,7 @@ exports.setValidateRefCount = setValidateRefCount;
144
144
  * Represents a collection of {@link LocalReferencePosition}s associated with one segment in a merge-tree.
145
145
  * @sealed
146
146
  *
147
- * @legacy
148
- * @alpha
149
- * @deprecated - This class will be removed in 2.20 with no replacement.
147
+ * @internal
150
148
  */
151
149
  class LocalReferenceCollection {
152
150
  static append(seg1, seg2) {
@@ -1 +1 @@
1
- {"version":3,"file":"localReference.js","sourceRoot":"","sources":["../src/localReference.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAA6D;AAC7D,uEAAsE;AAEtE,qDAA8E;AAE9E,iEAAgF;AAChF,qCAAyC;AACzC,mDAA6D;AAC7D,mEAAiF;AAEjF;;;;;GAKG;AACU,QAAA,iBAAiB,GAAG;IAChC;;OAEG;IACH,QAAQ,EAAE,CAAC;IACX;;OAEG;IACH,OAAO,EAAE,CAAC;CACD,CAAC;AAUX,SAAS,sBAAsB,CAAC,OAAsB;IACrD,IAAI,cAAc,GAAG,CAAC,CAAC;IACvB,IAAI,IAAA,2CAAmB,EAAC,OAAO,EAAE,sBAAa,CAAC,SAAS,CAAC,EAAE,CAAC;QAC3D,EAAE,cAAc,CAAC;IAClB,CAAC;IACD,IAAI,IAAA,2CAAmB,EAAC,OAAO,EAAE,sBAAa,CAAC,aAAa,CAAC,EAAE,C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AO,KAAK,CAAC;gBACd,CAAC;YACF,CAAC;YACD,MAAM,IAAI,SAAS,CAAC;YACpB,eAAe,CAAC,IAAI,CACnB,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,EAAE,MAAM,EACjC,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,EAAE,EAAE,EAC7B,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,EAAE,KAAK,CAChC,CAAC;QACH,CAAC;QACD,OAAO,IAAI,CAAC;IACb,CAAC;CACD;AA5YD,4DA4YC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\n\nimport { DoublyLinkedList, ListNode, walkList } from \"./collections/index.js\";\nimport { ISegmentInternal, type ISegment } from \"./mergeTreeNodes.js\";\nimport { TrackingGroup, TrackingGroupCollection } from \"./mergeTreeTracking.js\";\nimport { ReferenceType } from \"./ops.js\";\nimport { PropertySet, addProperties } from \"./properties.js\";\nimport { ReferencePosition, refTypeIncludesFlag } from \"./referencePositions.js\";\n\n/**\n * Dictates the preferential direction for a {@link ReferencePosition} to slide\n * in a merge-tree\n * @legacy\n * @alpha\n */\nexport const SlidingPreference = {\n\t/**\n\t * Prefer sliding towards the start of the tree\n\t */\n\tBACKWARD: 0,\n\t/**\n\t * Prefer sliding towards the end of the tree\n\t */\n\tFORWARD: 1,\n} as const;\n\n/**\n * Dictates the preferential direction for a {@link ReferencePosition} to slide\n * in a merge-tree\n * @legacy\n * @alpha\n */\nexport type SlidingPreference = (typeof SlidingPreference)[keyof typeof SlidingPreference];\n\nfunction _validateReferenceType(refType: ReferenceType): void {\n\tlet exclusiveCount = 0;\n\tif (refTypeIncludesFlag(refType, ReferenceType.Transient)) {\n\t\t++exclusiveCount;\n\t}\n\tif (refTypeIncludesFlag(refType, ReferenceType.SlideOnRemove)) {\n\t\t++exclusiveCount;\n\t}\n\tif (refTypeIncludesFlag(refType, ReferenceType.StayOnRemove)) {\n\t\t++exclusiveCount;\n\t}\n\tif (exclusiveCount > 1) {\n\t\tthrow new UsageError(\n\t\t\t\"Reference types can only be one of Transient, SlideOnRemove, and StayOnRemove\",\n\t\t);\n\t}\n}\n/**\n * @sealed\n * @legacy\n * @alpha\n */\nexport interface LocalReferencePosition extends ReferencePosition {\n\tcallbacks?: Partial<\n\t\tRecord<\"beforeSlide\" | \"afterSlide\", (ref: LocalReferencePosition) => void>\n\t>;\n\treadonly trackingCollection: TrackingGroupCollection;\n\t/**\n\t * Whether or not this reference position can slide onto one of the two\n\t * special segments representing the position before or after the tree\n\t */\n\treadonly canSlideToEndpoint?: boolean;\n\n\t/**\n\t * @param newProps - Properties to add to this reference.\n\t * @remarks Note that merge-tree does not broadcast changes to other clients. It is up to the consumer\n\t * to ensure broadcast happens if that is desired.\n\t */\n\taddProperties(newProps: PropertySet): void;\n}\n\n/**\n * @privateRemarks This should not be exported outside merge tree.\n * @internal\n */\nclass LocalReference implements LocalReferencePosition {\n\tpublic properties: PropertySet | undefined;\n\n\tprivate segment: ISegmentInternal | undefined;\n\tprivate offset: number = 0;\n\tprivate listNode: ListNode<LocalReference> | undefined;\n\n\tpublic callbacks?:\n\t\t| Partial<Record<\"beforeSlide\" | \"afterSlide\", (ref: LocalReferencePosition) => void>>\n\t\t| undefined;\n\tprivate _trackingCollection?: TrackingGroupCollection;\n\tpublic get trackingCollection(): TrackingGroupCollection {\n\t\treturn (this._trackingCollection ??= new TrackingGroupCollection(this));\n\t}\n\n\tconstructor(\n\t\tpublic refType = ReferenceType.Simple,\n\t\tproperties?: PropertySet,\n\t\tpublic readonly slidingPreference: SlidingPreference = SlidingPreference.FORWARD,\n\t\tpublic readonly canSlideToEndpoint?: boolean,\n\t) {\n\t\t_validateReferenceType(refType);\n\t\tthis.properties = properties;\n\t}\n\n\tpublic link(\n\t\tsegment: ISegmentInternal | undefined,\n\t\toffset: number,\n\t\tlistNode: ListNode<LocalReference> | undefined,\n\t): void {\n\t\tif (listNode !== this.listNode && this.listNode !== undefined) {\n\t\t\tthis.segment?.localRefs?.removeLocalRef(this);\n\t\t}\n\t\tthis.listNode = listNode;\n\n\t\tif (segment !== this.segment) {\n\t\t\tconst groups: TrackingGroup[] = [];\n\t\t\tfor (const tg of this.trackingCollection.trackingGroups) {\n\t\t\t\ttg.unlink(this);\n\t\t\t\tgroups.push(tg);\n\t\t\t}\n\n\t\t\tthis.segment = segment;\n\n\t\t\tfor (const tg of groups) tg.link(this);\n\t\t}\n\t\tthis.offset = offset;\n\t}\n\n\tpublic isLeaf(): this is ISegmentInternal {\n\t\treturn false;\n\t}\n\n\tpublic addProperties(newProps: PropertySet): void {\n\t\tthis.properties = addProperties(this.properties, newProps);\n\t}\n\n\tpublic getSegment(): ISegmentInternal | undefined {\n\t\treturn this.segment;\n\t}\n\n\tpublic getOffset(): number {\n\t\treturn this.offset;\n\t}\n\n\tpublic getListNode(): ListNode<LocalReference> | undefined {\n\t\treturn this.listNode;\n\t}\n\n\tpublic getProperties(): PropertySet | undefined {\n\t\treturn this.properties;\n\t}\n}\n\n/**\n * Creates a new detached local reference.\n * @internal\n */\nexport function createDetachedLocalReferencePosition(\n\tslidingPreference: SlidingPreference | undefined,\n\trefType?: ReferenceType,\n): LocalReferencePosition {\n\treturn new LocalReference(refType, undefined, slidingPreference);\n}\n\ninterface IRefsAtOffset {\n\tbefore?: DoublyLinkedList<LocalReference>;\n\tat?: DoublyLinkedList<LocalReference>;\n\tafter?: DoublyLinkedList<LocalReference>;\n}\n\nfunction assertLocalReferences(lref: unknown): asserts lref is LocalReference {\n\tassert(lref instanceof LocalReference, 0x2e0 /* \"lref not a Local Reference\" */);\n}\n\n/**\n * Determines if the given function is true for any position within the collection.\n */\nexport function anyLocalReferencePosition(\n\tcollection: LocalReferenceCollection,\n\tfunc: (pos: LocalReferencePosition) => boolean,\n): boolean {\n\tfor (const pos of collection) {\n\t\tif (func(pos)) {\n\t\t\treturn true;\n\t\t}\n\t}\n\n\treturn false;\n}\n\n/**\n * Finds the local reference positions that satisfy the given predicate.\n */\nexport function* filterLocalReferencePositions(\n\tcollection: LocalReferenceCollection,\n\tpredicate: (pos: LocalReferencePosition) => boolean,\n): Generator<LocalReferencePosition> {\n\tfor (const pos of collection) {\n\t\tif (predicate(pos)) {\n\t\t\tyield pos;\n\t\t}\n\t}\n}\n\n/**\n * Injectable hook for validating that the refCount property matches the\n * expected value\n */\nlet validateRefCount: ((collection?: LocalReferenceCollection) => void) | undefined;\n\nexport function setValidateRefCount(\n\tcb?: (collection?: LocalReferenceCollection) => void,\n): void {\n\tvalidateRefCount = cb;\n}\n\n/**\n * Represents a collection of {@link LocalReferencePosition}s associated with\n * one segment in a merge-tree.\n * Represents a collection of {@link LocalReferencePosition}s associated with one segment in a merge-tree.\n * @sealed\n *\n * @legacy\n * @alpha\n * @deprecated - This class will be removed in 2.20 with no replacement.\n */\nexport class LocalReferenceCollection {\n\tpublic static append(seg1: ISegment, seg2: ISegment): void {\n\t\tif (seg2.localRefs && !seg2.localRefs.empty) {\n\t\t\tif (!seg1.localRefs) {\n\t\t\t\tseg1.localRefs = new LocalReferenceCollection(seg1);\n\t\t\t}\n\t\t\tassert(\n\t\t\t\tseg1.localRefs.refsByOffset.length === seg1.cachedLength,\n\t\t\t\t0x2be /* \"LocalReferences array contains a gap\" */,\n\t\t\t);\n\t\t\tseg1.localRefs.append(seg2.localRefs);\n\t\t} else if (seg1.localRefs) {\n\t\t\t// Since creating the LocalReferenceCollection, we may have appended\n\t\t\t// segments that had no local references. Account for them now by padding the array.\n\t\t\tseg1.localRefs.refsByOffset.length += seg2.cachedLength;\n\t\t}\n\t\tvalidateRefCount?.(seg1.localRefs);\n\t\tvalidateRefCount?.(seg2.localRefs);\n\t}\n\n\tpublic static setOrGet(segment: ISegment): LocalReferenceCollection {\n\t\treturn (segment.localRefs ??= new LocalReferenceCollection(segment));\n\t}\n\n\tprivate readonly refsByOffset: (IRefsAtOffset | undefined)[];\n\tprivate refCount: number = 0;\n\n\tprivate constructor(\n\t\t/**\n\t\t * The segment this `LocalReferenceCollection` is associated with.\n\t\t */\n\t\tprivate readonly segment: ISegment,\n\t\tinitialRefsByfOffset: (IRefsAtOffset | undefined)[] = Array.from({\n\t\t\tlength: segment.cachedLength,\n\t\t}),\n\t) {\n\t\t// Since javascript arrays are sparse the above won't populate any of the\n\t\t// indices, but it will ensure the length property of the array matches\n\t\t// the length of the segment.\n\t\tthis.refsByOffset = initialRefsByfOffset;\n\t}\n\n\t/**\n\t * Returns an iterator over this LocalReferenceCollection.\n\t * @remarks This method should only be called by mergeTree.\n\t */\n\tpublic [Symbol.iterator](): {\n\t\tnext(): IteratorResult<LocalReferencePosition>;\n\t\t[Symbol.iterator](): IterableIterator<LocalReferencePosition>;\n\t} {\n\t\tconst subiterators: IterableIterator<ListNode<LocalReferencePosition>>[] = [];\n\t\tfor (const refs of this.refsByOffset) {\n\t\t\tif (refs) {\n\t\t\t\tif (refs.before) {\n\t\t\t\t\tsubiterators.push(refs.before[Symbol.iterator]());\n\t\t\t\t}\n\t\t\t\tif (refs.at) {\n\t\t\t\t\tsubiterators.push(refs.at[Symbol.iterator]());\n\t\t\t\t}\n\t\t\t\tif (refs.after) {\n\t\t\t\t\tsubiterators.push(refs.after[Symbol.iterator]());\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tconst iterator = {\n\t\t\tnext(): IteratorResult<LocalReferencePosition> {\n\t\t\t\twhile (subiterators.length > 0) {\n\t\t\t\t\tconst next = subiterators[0].next();\n\t\t\t\t\tif (next.done === true) {\n\t\t\t\t\t\tsubiterators.shift();\n\t\t\t\t\t} else {\n\t\t\t\t\t\treturn { done: next.done, value: next.value.data };\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn { value: undefined, done: true };\n\t\t\t},\n\t\t\t[Symbol.iterator](): {\n\t\t\t\tnext(): IteratorResult<LocalReferencePosition>;\n\t\t\t\t[Symbol.iterator](): IterableIterator<LocalReferencePosition>;\n\t\t\t} {\n\t\t\t\treturn this;\n\t\t\t},\n\t\t};\n\t\treturn iterator;\n\t}\n\n\t/**\n\t * Determines if the collection has no references in it.\n\t * @remarks This method should only be called by mergeTree.\n\t */\n\tpublic get empty(): boolean {\n\t\tvalidateRefCount?.(this);\n\t\treturn this.refCount === 0;\n\t}\n\n\t/**\n\t * Creates a new local reference.\n\t * @remarks This method should only be called by mergeTree.\n\t */\n\tpublic createLocalRef(\n\t\toffset: number,\n\t\trefType: ReferenceType,\n\t\tproperties: PropertySet | undefined,\n\t\tslidingPreference?: SlidingPreference,\n\t\tcanSlideToEndpoint?: boolean,\n\t): LocalReferencePosition {\n\t\tconst ref = new LocalReference(refType, properties, slidingPreference, canSlideToEndpoint);\n\t\tref.link(this.segment, offset, undefined);\n\t\tif (!refTypeIncludesFlag(ref, ReferenceType.Transient)) {\n\t\t\tthis.addLocalRef(ref, offset);\n\t\t}\n\t\tvalidateRefCount?.(this);\n\t\treturn ref;\n\t}\n\n\t/**\n\t * Adds a local reference to the collection.\n\t * @remarks This method should only be called by mergeTree.\n\t */\n\tpublic addLocalRef(lref: LocalReferencePosition, offset: number): void {\n\t\tassertLocalReferences(lref);\n\t\tassert(\n\t\t\toffset < this.segment.cachedLength,\n\t\t\t0x348 /* offset cannot be beyond segment length */,\n\t\t);\n\t\tif (refTypeIncludesFlag(lref, ReferenceType.Transient)) {\n\t\t\tlref.link(this.segment, offset, undefined);\n\t\t} else {\n\t\t\tconst refsAtOffset = (this.refsByOffset[offset] = this.refsByOffset[offset] ?? {\n\t\t\t\tat: new DoublyLinkedList(),\n\t\t\t});\n\t\t\tconst atRefs = (refsAtOffset.at = refsAtOffset.at ?? new DoublyLinkedList());\n\n\t\t\tlref.link(this.segment, offset, atRefs.push(lref).last);\n\n\t\t\tthis.refCount++;\n\t\t}\n\t\tvalidateRefCount?.(this);\n\t}\n\n\t/**\n\t * Removes a local reference from the collection.\n\t * @remarks This method should only be called by mergeTree.\n\t */\n\tpublic removeLocalRef(lref: LocalReferencePosition): LocalReferencePosition | undefined {\n\t\tif (this.has(lref)) {\n\t\t\tassertLocalReferences(lref);\n\n\t\t\tconst node = lref.getListNode();\n\t\t\tnode?.list?.remove(node);\n\n\t\t\tlref.link(undefined, 0, undefined);\n\n\t\t\tthis.refCount--;\n\t\t\tvalidateRefCount?.(this);\n\t\t\treturn lref;\n\t\t}\n\t}\n\n\t/**\n\t *\n\t * Called by 'append()' implementations to append local refs from the given 'other' segment to the\n\t * end of 'this' segment.\n\t *\n\t * Note: This method should be invoked after the caller has ensured that segments can be merged,\n\t * but before 'this' segment's cachedLength has changed, or the adjustment to the local refs\n\t * will be incorrect.\n\t *\n\t * @remarks This method should only be called by mergeTree.\n\t */\n\tpublic append(other: LocalReferenceCollection): void {\n\t\tif (!other || other.empty) {\n\t\t\treturn;\n\t\t}\n\t\tthis.refCount += other.refCount;\n\t\tother.refCount = 0;\n\t\tfor (const lref of other) {\n\t\t\tassertLocalReferences(lref);\n\t\t\tlref.link(this.segment, lref.getOffset() + this.refsByOffset.length, lref.getListNode());\n\t\t}\n\n\t\tthis.refsByOffset.push(...other.refsByOffset);\n\t\tother.refsByOffset.length = 0;\n\t}\n\t/**\n\t * Returns true of the local reference is in the collection, otherwise false.\n\t *\n\t * @remarks This method should only be called by mergeTree.\n\t */\n\tpublic has(lref: ReferencePosition): boolean {\n\t\tif (\n\t\t\t!(lref instanceof LocalReference) ||\n\t\t\trefTypeIncludesFlag(lref, ReferenceType.Transient)\n\t\t) {\n\t\t\treturn false;\n\t\t}\n\t\tconst seg = lref.getSegment();\n\t\tif (seg !== this.segment) {\n\t\t\treturn false;\n\t\t}\n\t\t// we should be able to optimize finding the\n\t\t// list head\n\t\tconst listNode = lref.getListNode();\n\t\tif (listNode === undefined) {\n\t\t\treturn false;\n\t\t}\n\t\tconst offset = lref.getOffset();\n\t\tconst refsAtOffset = this.refsByOffset[offset];\n\t\tif (\n\t\t\t!!refsAtOffset?.before?.includes(listNode) ||\n\t\t\t!!refsAtOffset?.at?.includes(listNode) ||\n\t\t\t!!refsAtOffset?.after?.includes(listNode)\n\t\t) {\n\t\t\treturn true;\n\t\t}\n\t\treturn false;\n\t}\n\n\t/**\n\t * Splits this `LocalReferenceCollection` into the intervals [0, offset) and [offset, originalLength).\n\t * Local references in the former half of this split will remain associated with the segment used on construction.\n\t * Local references in the latter half of this split will be transferred to `splitSeg`,\n\t * and its `localRefs` field will be set.\n\t * @param offset - Offset into the original segment at which the collection should be split\n\t * @param splitSeg - Split segment which originally corresponded to the indices [offset, originalLength)\n\t * before splitting.\n\t *\n\t * @remarks This method should only be called by mergeTree.\n\t */\n\tpublic split(offset: number, splitSeg: ISegment): void {\n\t\tif (this.empty) {\n\t\t\t// shrink the offset array when empty and splitting\n\t\t\tthis.refsByOffset.length = offset;\n\t\t} else {\n\t\t\tconst localRefs = new LocalReferenceCollection(\n\t\t\t\tsplitSeg,\n\t\t\t\tthis.refsByOffset.splice(offset, this.refsByOffset.length - offset),\n\t\t\t);\n\n\t\t\tsplitSeg.localRefs = localRefs;\n\t\t\tfor (const lref of localRefs) {\n\t\t\t\tassertLocalReferences(lref);\n\t\t\t\tlref.link(splitSeg, lref.getOffset() - offset, lref.getListNode());\n\t\t\t\tthis.refCount--;\n\t\t\t\tlocalRefs.refCount++;\n\t\t\t}\n\t\t}\n\t\tvalidateRefCount?.(this);\n\t}\n\n\t/**\n\t * Insert a reference before tombstoned references.\n\t * @remarks This method should only be called by mergeTree.\n\t */\n\tpublic addBeforeTombstones(...refs: Iterable<LocalReferencePosition>[]): void {\n\t\tconst beforeRefs = this.refsByOffset[0]?.before ?? new DoublyLinkedList();\n\n\t\tif (this.refsByOffset[0]?.before === undefined) {\n\t\t\tconst refsAtOffset = (this.refsByOffset[0] ??= { before: beforeRefs });\n\t\t\trefsAtOffset.before ??= beforeRefs;\n\t\t}\n\n\t\tlet precedingRef: ListNode<LocalReference> | undefined;\n\t\tfor (const iterable of refs) {\n\t\t\tfor (const lref of iterable) {\n\t\t\t\tassertLocalReferences(lref);\n\t\t\t\tif (refTypeIncludesFlag(lref, ReferenceType.StayOnRemove)) {\n\t\t\t\t\tcontinue;\n\t\t\t\t} else if (refTypeIncludesFlag(lref, ReferenceType.SlideOnRemove)) {\n\t\t\t\t\tlref.callbacks?.beforeSlide?.(lref);\n\t\t\t\t\tprecedingRef =\n\t\t\t\t\t\tprecedingRef === undefined\n\t\t\t\t\t\t\t? beforeRefs.unshift(lref)?.first\n\t\t\t\t\t\t\t: beforeRefs.insertAfter(precedingRef, lref)?.first;\n\t\t\t\t\tlref.link(this.segment, 0, precedingRef);\n\t\t\t\t\tthis.refCount++;\n\t\t\t\t\tlref.callbacks?.afterSlide?.(lref);\n\t\t\t\t} else {\n\t\t\t\t\tlref.link(undefined, 0, undefined);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tvalidateRefCount?.(this);\n\t}\n\t/**\n\t * Insert a reference after tombstoned references.\n\t * @remarks This method should only be called by mergeTree.\n\t */\n\tpublic addAfterTombstones(...refs: Iterable<LocalReferencePosition>[]): void {\n\t\tconst lastOffset = this.segment.cachedLength - 1;\n\t\tconst afterRefs = this.refsByOffset[lastOffset]?.after ?? new DoublyLinkedList();\n\n\t\tif (this.refsByOffset[lastOffset]?.after === undefined) {\n\t\t\tconst refsAtOffset = (this.refsByOffset[lastOffset] ??= { after: afterRefs });\n\t\t\trefsAtOffset.after ??= afterRefs;\n\t\t}\n\n\t\tfor (const iterable of refs) {\n\t\t\tfor (const lref of iterable) {\n\t\t\t\tassertLocalReferences(lref);\n\t\t\t\tif (refTypeIncludesFlag(lref, ReferenceType.StayOnRemove)) {\n\t\t\t\t\tcontinue;\n\t\t\t\t} else if (refTypeIncludesFlag(lref, ReferenceType.SlideOnRemove)) {\n\t\t\t\t\tlref.callbacks?.beforeSlide?.(lref);\n\t\t\t\t\tafterRefs.push(lref);\n\t\t\t\t\tlref.link(this.segment, lastOffset, afterRefs.last);\n\t\t\t\t\tthis.refCount++;\n\t\t\t\t\tlref.callbacks?.afterSlide?.(lref);\n\t\t\t\t} else {\n\t\t\t\t\tlref.link(undefined, 0, undefined);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tvalidateRefCount?.(this);\n\t}\n\n\t/**\n\t * Determines if a reference is after tombstoned references.\n\t * @remarks This method should only be called by mergeTree.\n\t */\n\tpublic isAfterTombstone(lref: LocalReferencePosition): boolean {\n\t\tconst after = this.refsByOffset[lref.getOffset()]?.after;\n\t\tif (after) {\n\t\t\tassertLocalReferences(lref);\n\t\t\treturn after.includes(lref.getListNode());\n\t\t}\n\t\treturn false;\n\t}\n\n\t/**\n\t * Walks all of the references in a collection.\n\t * @remarks This method should only be called by mergeTree.\n\t */\n\tpublic walkReferences(\n\t\tvisitor: (lref: LocalReferencePosition) => boolean | void | undefined,\n\t\tstart?: LocalReferencePosition,\n\t\tforward: boolean = true,\n\t): boolean {\n\t\tif (start !== undefined) {\n\t\t\tif (!this.has(start)) {\n\t\t\t\tthrow new UsageError(\"start must be in collection\");\n\t\t\t}\n\t\t\tassertLocalReferences(start);\n\t\t}\n\t\tlet offset = start?.getOffset() ?? (forward ? 0 : this.segment.cachedLength - 1);\n\n\t\tconst offsetPositions: DoublyLinkedList<IRefsAtOffset[keyof IRefsAtOffset]> =\n\t\t\tnew DoublyLinkedList();\n\t\toffsetPositions.push(\n\t\t\tthis.refsByOffset[offset]?.before,\n\t\t\tthis.refsByOffset[offset]?.at,\n\t\t\tthis.refsByOffset[offset]?.after,\n\t\t);\n\n\t\tconst startNode = start?.getListNode();\n\t\tconst startList = startNode?.list;\n\n\t\tif (startList !== undefined) {\n\t\t\tif (forward) {\n\t\t\t\twhile (!offsetPositions.empty && offsetPositions.first !== startNode) {\n\t\t\t\t\toffsetPositions.shift();\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\twhile (!offsetPositions.empty && offsetPositions.last !== startNode) {\n\t\t\t\t\toffsetPositions.pop();\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tconst listWalker = (pos: DoublyLinkedList<LocalReference>): boolean => {\n\t\t\treturn walkList(\n\t\t\t\tpos,\n\t\t\t\t(node) => visitor(node.data),\n\t\t\t\tstartList === pos ? startNode : undefined,\n\t\t\t\tforward,\n\t\t\t);\n\t\t};\n\t\tconst increment = forward ? 1 : -1;\n\t\twhile (offset >= 0 && offset < this.refsByOffset.length) {\n\t\t\twhile (offsetPositions.length > 0) {\n\t\t\t\tconst offsetPos = forward ? offsetPositions.shift() : offsetPositions.pop();\n\t\t\t\tif (offsetPos?.data !== undefined && listWalker(offsetPos.data) === false) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t}\n\t\t\toffset += increment;\n\t\t\toffsetPositions.push(\n\t\t\t\tthis.refsByOffset[offset]?.before,\n\t\t\t\tthis.refsByOffset[offset]?.at,\n\t\t\t\tthis.refsByOffset[offset]?.after,\n\t\t\t);\n\t\t}\n\t\treturn true;\n\t}\n}\n"]}
1
+ {"version":3,"file":"localReference.js","sourceRoot":"","sources":["../src/localReference.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAA6D;AAC7D,uEAAsE;AAEtE,qDAA8E;AAE9E,iEAAgF;AAChF,qCAAyC;AACzC,mDAA6D;AAC7D,mEAAiF;AAEjF;;;;;GAKG;AACU,QAAA,iBAAiB,GAAG;IAChC;;OAEG;IACH,QAAQ,EAAE,CAAC;IACX;;OAEG;IACH,OAAO,EAAE,CAAC;CACD,CAAC;AAUX,SAAS,sBAAsB,CAAC,OAAsB;IACrD,IAAI,cAAc,GAAG,CAAC,CAAC;IACvB,IAAI,IAAA,2CAAmB,EAAC,OAAO,EAAE,sBAAa,CAAC,SAAS,CAAC,EAAE,CAAC;QAC3D,EAAE,cAAc,CAAC;IAClB,CAAC;IACD,IAAI,IAAA,2CAAmB,EAAC,OAAO,EAAE,sBAAa,CAAC,aAAa,CAAC,EAAE,CAAC;QAC/D,EAAE,cAAc,CAAC;IAClB,CAAC;I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D,MAAM,IAAI,SAAS,CAAC;YACpB,eAAe,CAAC,IAAI,CACnB,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,EAAE,MAAM,EACjC,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,EAAE,EAAE,EAC7B,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,EAAE,KAAK,CAChC,CAAC;QACH,CAAC;QACD,OAAO,IAAI,CAAC;IACb,CAAC;CACD;AA5YD,4DA4YC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\n\nimport { DoublyLinkedList, ListNode, walkList } from \"./collections/index.js\";\nimport { type ISegmentInternal } from \"./mergeTreeNodes.js\";\nimport { TrackingGroup, TrackingGroupCollection } from \"./mergeTreeTracking.js\";\nimport { ReferenceType } from \"./ops.js\";\nimport { PropertySet, addProperties } from \"./properties.js\";\nimport { ReferencePosition, refTypeIncludesFlag } from \"./referencePositions.js\";\n\n/**\n * Dictates the preferential direction for a {@link ReferencePosition} to slide\n * in a merge-tree\n * @legacy\n * @alpha\n */\nexport const SlidingPreference = {\n\t/**\n\t * Prefer sliding towards the start of the tree\n\t */\n\tBACKWARD: 0,\n\t/**\n\t * Prefer sliding towards the end of the tree\n\t */\n\tFORWARD: 1,\n} as const;\n\n/**\n * Dictates the preferential direction for a {@link ReferencePosition} to slide\n * in a merge-tree\n * @legacy\n * @alpha\n */\nexport type SlidingPreference = (typeof SlidingPreference)[keyof typeof SlidingPreference];\n\nfunction _validateReferenceType(refType: ReferenceType): void {\n\tlet exclusiveCount = 0;\n\tif (refTypeIncludesFlag(refType, ReferenceType.Transient)) {\n\t\t++exclusiveCount;\n\t}\n\tif (refTypeIncludesFlag(refType, ReferenceType.SlideOnRemove)) {\n\t\t++exclusiveCount;\n\t}\n\tif (refTypeIncludesFlag(refType, ReferenceType.StayOnRemove)) {\n\t\t++exclusiveCount;\n\t}\n\tif (exclusiveCount > 1) {\n\t\tthrow new UsageError(\n\t\t\t\"Reference types can only be one of Transient, SlideOnRemove, and StayOnRemove\",\n\t\t);\n\t}\n}\n/**\n * @sealed\n * @legacy\n * @alpha\n */\nexport interface LocalReferencePosition extends ReferencePosition {\n\tcallbacks?: Partial<\n\t\tRecord<\"beforeSlide\" | \"afterSlide\", (ref: LocalReferencePosition) => void>\n\t>;\n\treadonly trackingCollection: TrackingGroupCollection;\n\t/**\n\t * Whether or not this reference position can slide onto one of the two\n\t * special segments representing the position before or after the tree\n\t */\n\treadonly canSlideToEndpoint?: boolean;\n\n\t/**\n\t * @param newProps - Properties to add to this reference.\n\t * @remarks Note that merge-tree does not broadcast changes to other clients. It is up to the consumer\n\t * to ensure broadcast happens if that is desired.\n\t */\n\taddProperties(newProps: PropertySet): void;\n}\n\n/**\n * @privateRemarks This should not be exported outside merge tree.\n * @internal\n */\nclass LocalReference implements LocalReferencePosition {\n\tpublic properties: PropertySet | undefined;\n\n\tprivate segment: ISegmentInternal | undefined;\n\tprivate offset: number = 0;\n\tprivate listNode: ListNode<LocalReference> | undefined;\n\n\tpublic callbacks?:\n\t\t| Partial<Record<\"beforeSlide\" | \"afterSlide\", (ref: LocalReferencePosition) => void>>\n\t\t| undefined;\n\tprivate _trackingCollection?: TrackingGroupCollection;\n\tpublic get trackingCollection(): TrackingGroupCollection {\n\t\treturn (this._trackingCollection ??= new TrackingGroupCollection(this));\n\t}\n\n\tconstructor(\n\t\tpublic refType = ReferenceType.Simple,\n\t\tproperties?: PropertySet,\n\t\tpublic readonly slidingPreference: SlidingPreference = SlidingPreference.FORWARD,\n\t\tpublic readonly canSlideToEndpoint?: boolean,\n\t) {\n\t\t_validateReferenceType(refType);\n\t\tthis.properties = properties;\n\t}\n\n\tpublic link(\n\t\tsegment: ISegmentInternal | undefined,\n\t\toffset: number,\n\t\tlistNode: ListNode<LocalReference> | undefined,\n\t): void {\n\t\tif (listNode !== this.listNode && this.listNode !== undefined) {\n\t\t\tthis.segment?.localRefs?.removeLocalRef(this);\n\t\t}\n\t\tthis.listNode = listNode;\n\n\t\tif (segment !== this.segment) {\n\t\t\tconst groups: TrackingGroup[] = [];\n\t\t\tfor (const tg of this.trackingCollection.trackingGroups) {\n\t\t\t\ttg.unlink(this);\n\t\t\t\tgroups.push(tg);\n\t\t\t}\n\n\t\t\tthis.segment = segment;\n\n\t\t\tfor (const tg of groups) tg.link(this);\n\t\t}\n\t\tthis.offset = offset;\n\t}\n\n\tpublic isLeaf(): this is ISegmentInternal {\n\t\treturn false;\n\t}\n\n\tpublic addProperties(newProps: PropertySet): void {\n\t\tthis.properties = addProperties(this.properties, newProps);\n\t}\n\n\tpublic getSegment(): ISegmentInternal | undefined {\n\t\treturn this.segment;\n\t}\n\n\tpublic getOffset(): number {\n\t\treturn this.offset;\n\t}\n\n\tpublic getListNode(): ListNode<LocalReference> | undefined {\n\t\treturn this.listNode;\n\t}\n\n\tpublic getProperties(): PropertySet | undefined {\n\t\treturn this.properties;\n\t}\n}\n\n/**\n * Creates a new detached local reference.\n * @internal\n */\nexport function createDetachedLocalReferencePosition(\n\tslidingPreference: SlidingPreference | undefined,\n\trefType?: ReferenceType,\n): LocalReferencePosition {\n\treturn new LocalReference(refType, undefined, slidingPreference);\n}\n\ninterface IRefsAtOffset {\n\tbefore?: DoublyLinkedList<LocalReference>;\n\tat?: DoublyLinkedList<LocalReference>;\n\tafter?: DoublyLinkedList<LocalReference>;\n}\n\nfunction assertLocalReferences(lref: unknown): asserts lref is LocalReference {\n\tassert(lref instanceof LocalReference, 0x2e0 /* \"lref not a Local Reference\" */);\n}\n\n/**\n * Determines if the given function is true for any position within the collection.\n */\nexport function anyLocalReferencePosition(\n\tcollection: LocalReferenceCollection,\n\tfunc: (pos: LocalReferencePosition) => boolean,\n): boolean {\n\tfor (const pos of collection) {\n\t\tif (func(pos)) {\n\t\t\treturn true;\n\t\t}\n\t}\n\n\treturn false;\n}\n\n/**\n * Finds the local reference positions that satisfy the given predicate.\n */\nexport function* filterLocalReferencePositions(\n\tcollection: LocalReferenceCollection,\n\tpredicate: (pos: LocalReferencePosition) => boolean,\n): Generator<LocalReferencePosition> {\n\tfor (const pos of collection) {\n\t\tif (predicate(pos)) {\n\t\t\tyield pos;\n\t\t}\n\t}\n}\n\n/**\n * Injectable hook for validating that the refCount property matches the\n * expected value\n */\nlet validateRefCount: ((collection?: LocalReferenceCollection) => void) | undefined;\n\nexport function setValidateRefCount(\n\tcb?: (collection?: LocalReferenceCollection) => void,\n): void {\n\tvalidateRefCount = cb;\n}\n\n/**\n * Represents a collection of {@link LocalReferencePosition}s associated with\n * one segment in a merge-tree.\n * Represents a collection of {@link LocalReferencePosition}s associated with one segment in a merge-tree.\n * @sealed\n *\n * @internal\n */\nexport class LocalReferenceCollection {\n\tpublic static append(seg1: ISegmentInternal, seg2: ISegmentInternal): void {\n\t\tif (seg2.localRefs && !seg2.localRefs.empty) {\n\t\t\tif (!seg1.localRefs) {\n\t\t\t\tseg1.localRefs = new LocalReferenceCollection(seg1);\n\t\t\t}\n\t\t\tassert(\n\t\t\t\tseg1.localRefs.refsByOffset.length === seg1.cachedLength,\n\t\t\t\t0x2be /* \"LocalReferences array contains a gap\" */,\n\t\t\t);\n\t\t\tseg1.localRefs.append(seg2.localRefs);\n\t\t} else if (seg1.localRefs) {\n\t\t\t// Since creating the LocalReferenceCollection, we may have appended\n\t\t\t// segments that had no local references. Account for them now by padding the array.\n\t\t\tseg1.localRefs.refsByOffset.length += seg2.cachedLength;\n\t\t}\n\t\tvalidateRefCount?.(seg1.localRefs);\n\t\tvalidateRefCount?.(seg2.localRefs);\n\t}\n\n\tpublic static setOrGet(segment: ISegmentInternal): LocalReferenceCollection {\n\t\treturn (segment.localRefs ??= new LocalReferenceCollection(segment));\n\t}\n\n\tprivate readonly refsByOffset: (IRefsAtOffset | undefined)[];\n\tprivate refCount: number = 0;\n\n\tprivate constructor(\n\t\t/**\n\t\t * The segment this `LocalReferenceCollection` is associated with.\n\t\t */\n\t\tprivate readonly segment: ISegmentInternal,\n\t\tinitialRefsByfOffset: (IRefsAtOffset | undefined)[] = Array.from({\n\t\t\tlength: segment.cachedLength,\n\t\t}),\n\t) {\n\t\t// Since javascript arrays are sparse the above won't populate any of the\n\t\t// indices, but it will ensure the length property of the array matches\n\t\t// the length of the segment.\n\t\tthis.refsByOffset = initialRefsByfOffset;\n\t}\n\n\t/**\n\t * Returns an iterator over this LocalReferenceCollection.\n\t * @remarks This method should only be called by mergeTree.\n\t */\n\tpublic [Symbol.iterator](): {\n\t\tnext(): IteratorResult<LocalReferencePosition>;\n\t\t[Symbol.iterator](): IterableIterator<LocalReferencePosition>;\n\t} {\n\t\tconst subiterators: IterableIterator<ListNode<LocalReferencePosition>>[] = [];\n\t\tfor (const refs of this.refsByOffset) {\n\t\t\tif (refs) {\n\t\t\t\tif (refs.before) {\n\t\t\t\t\tsubiterators.push(refs.before[Symbol.iterator]());\n\t\t\t\t}\n\t\t\t\tif (refs.at) {\n\t\t\t\t\tsubiterators.push(refs.at[Symbol.iterator]());\n\t\t\t\t}\n\t\t\t\tif (refs.after) {\n\t\t\t\t\tsubiterators.push(refs.after[Symbol.iterator]());\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tconst iterator = {\n\t\t\tnext(): IteratorResult<LocalReferencePosition> {\n\t\t\t\twhile (subiterators.length > 0) {\n\t\t\t\t\tconst next = subiterators[0].next();\n\t\t\t\t\tif (next.done === true) {\n\t\t\t\t\t\tsubiterators.shift();\n\t\t\t\t\t} else {\n\t\t\t\t\t\treturn { done: next.done, value: next.value.data };\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn { value: undefined, done: true };\n\t\t\t},\n\t\t\t[Symbol.iterator](): {\n\t\t\t\tnext(): IteratorResult<LocalReferencePosition>;\n\t\t\t\t[Symbol.iterator](): IterableIterator<LocalReferencePosition>;\n\t\t\t} {\n\t\t\t\treturn this;\n\t\t\t},\n\t\t};\n\t\treturn iterator;\n\t}\n\n\t/**\n\t * Determines if the collection has no references in it.\n\t * @remarks This method should only be called by mergeTree.\n\t */\n\tpublic get empty(): boolean {\n\t\tvalidateRefCount?.(this);\n\t\treturn this.refCount === 0;\n\t}\n\n\t/**\n\t * Creates a new local reference.\n\t * @remarks This method should only be called by mergeTree.\n\t */\n\tpublic createLocalRef(\n\t\toffset: number,\n\t\trefType: ReferenceType,\n\t\tproperties: PropertySet | undefined,\n\t\tslidingPreference?: SlidingPreference,\n\t\tcanSlideToEndpoint?: boolean,\n\t): LocalReferencePosition {\n\t\tconst ref = new LocalReference(refType, properties, slidingPreference, canSlideToEndpoint);\n\t\tref.link(this.segment, offset, undefined);\n\t\tif (!refTypeIncludesFlag(ref, ReferenceType.Transient)) {\n\t\t\tthis.addLocalRef(ref, offset);\n\t\t}\n\t\tvalidateRefCount?.(this);\n\t\treturn ref;\n\t}\n\n\t/**\n\t * Adds a local reference to the collection.\n\t * @remarks This method should only be called by mergeTree.\n\t */\n\tpublic addLocalRef(lref: LocalReferencePosition, offset: number): void {\n\t\tassertLocalReferences(lref);\n\t\tassert(\n\t\t\toffset < this.segment.cachedLength,\n\t\t\t0x348 /* offset cannot be beyond segment length */,\n\t\t);\n\t\tif (refTypeIncludesFlag(lref, ReferenceType.Transient)) {\n\t\t\tlref.link(this.segment, offset, undefined);\n\t\t} else {\n\t\t\tconst refsAtOffset = (this.refsByOffset[offset] = this.refsByOffset[offset] ?? {\n\t\t\t\tat: new DoublyLinkedList(),\n\t\t\t});\n\t\t\tconst atRefs = (refsAtOffset.at = refsAtOffset.at ?? new DoublyLinkedList());\n\n\t\t\tlref.link(this.segment, offset, atRefs.push(lref).last);\n\n\t\t\tthis.refCount++;\n\t\t}\n\t\tvalidateRefCount?.(this);\n\t}\n\n\t/**\n\t * Removes a local reference from the collection.\n\t * @remarks This method should only be called by mergeTree.\n\t */\n\tpublic removeLocalRef(lref: LocalReferencePosition): LocalReferencePosition | undefined {\n\t\tif (this.has(lref)) {\n\t\t\tassertLocalReferences(lref);\n\n\t\t\tconst node = lref.getListNode();\n\t\t\tnode?.list?.remove(node);\n\n\t\t\tlref.link(undefined, 0, undefined);\n\n\t\t\tthis.refCount--;\n\t\t\tvalidateRefCount?.(this);\n\t\t\treturn lref;\n\t\t}\n\t}\n\n\t/**\n\t *\n\t * Called by 'append()' implementations to append local refs from the given 'other' segment to the\n\t * end of 'this' segment.\n\t *\n\t * Note: This method should be invoked after the caller has ensured that segments can be merged,\n\t * but before 'this' segment's cachedLength has changed, or the adjustment to the local refs\n\t * will be incorrect.\n\t *\n\t * @remarks This method should only be called by mergeTree.\n\t */\n\tpublic append(other: LocalReferenceCollection): void {\n\t\tif (!other || other.empty) {\n\t\t\treturn;\n\t\t}\n\t\tthis.refCount += other.refCount;\n\t\tother.refCount = 0;\n\t\tfor (const lref of other) {\n\t\t\tassertLocalReferences(lref);\n\t\t\tlref.link(this.segment, lref.getOffset() + this.refsByOffset.length, lref.getListNode());\n\t\t}\n\n\t\tthis.refsByOffset.push(...other.refsByOffset);\n\t\tother.refsByOffset.length = 0;\n\t}\n\t/**\n\t * Returns true of the local reference is in the collection, otherwise false.\n\t *\n\t * @remarks This method should only be called by mergeTree.\n\t */\n\tpublic has(lref: ReferencePosition): boolean {\n\t\tif (\n\t\t\t!(lref instanceof LocalReference) ||\n\t\t\trefTypeIncludesFlag(lref, ReferenceType.Transient)\n\t\t) {\n\t\t\treturn false;\n\t\t}\n\t\tconst seg = lref.getSegment();\n\t\tif (seg !== this.segment) {\n\t\t\treturn false;\n\t\t}\n\t\t// we should be able to optimize finding the\n\t\t// list head\n\t\tconst listNode = lref.getListNode();\n\t\tif (listNode === undefined) {\n\t\t\treturn false;\n\t\t}\n\t\tconst offset = lref.getOffset();\n\t\tconst refsAtOffset = this.refsByOffset[offset];\n\t\tif (\n\t\t\t!!refsAtOffset?.before?.includes(listNode) ||\n\t\t\t!!refsAtOffset?.at?.includes(listNode) ||\n\t\t\t!!refsAtOffset?.after?.includes(listNode)\n\t\t) {\n\t\t\treturn true;\n\t\t}\n\t\treturn false;\n\t}\n\n\t/**\n\t * Splits this `LocalReferenceCollection` into the intervals [0, offset) and [offset, originalLength).\n\t * Local references in the former half of this split will remain associated with the segment used on construction.\n\t * Local references in the latter half of this split will be transferred to `splitSeg`,\n\t * and its `localRefs` field will be set.\n\t * @param offset - Offset into the original segment at which the collection should be split\n\t * @param splitSeg - Split segment which originally corresponded to the indices [offset, originalLength)\n\t * before splitting.\n\t *\n\t * @remarks This method should only be called by mergeTree.\n\t */\n\tpublic split(offset: number, splitSeg: ISegmentInternal): void {\n\t\tif (this.empty) {\n\t\t\t// shrink the offset array when empty and splitting\n\t\t\tthis.refsByOffset.length = offset;\n\t\t} else {\n\t\t\tconst localRefs = new LocalReferenceCollection(\n\t\t\t\tsplitSeg,\n\t\t\t\tthis.refsByOffset.splice(offset, this.refsByOffset.length - offset),\n\t\t\t);\n\n\t\t\tsplitSeg.localRefs = localRefs;\n\t\t\tfor (const lref of localRefs) {\n\t\t\t\tassertLocalReferences(lref);\n\t\t\t\tlref.link(splitSeg, lref.getOffset() - offset, lref.getListNode());\n\t\t\t\tthis.refCount--;\n\t\t\t\tlocalRefs.refCount++;\n\t\t\t}\n\t\t}\n\t\tvalidateRefCount?.(this);\n\t}\n\n\t/**\n\t * Insert a reference before tombstoned references.\n\t * @remarks This method should only be called by mergeTree.\n\t */\n\tpublic addBeforeTombstones(...refs: Iterable<LocalReferencePosition>[]): void {\n\t\tconst beforeRefs = this.refsByOffset[0]?.before ?? new DoublyLinkedList();\n\n\t\tif (this.refsByOffset[0]?.before === undefined) {\n\t\t\tconst refsAtOffset = (this.refsByOffset[0] ??= { before: beforeRefs });\n\t\t\trefsAtOffset.before ??= beforeRefs;\n\t\t}\n\n\t\tlet precedingRef: ListNode<LocalReference> | undefined;\n\t\tfor (const iterable of refs) {\n\t\t\tfor (const lref of iterable) {\n\t\t\t\tassertLocalReferences(lref);\n\t\t\t\tif (refTypeIncludesFlag(lref, ReferenceType.StayOnRemove)) {\n\t\t\t\t\tcontinue;\n\t\t\t\t} else if (refTypeIncludesFlag(lref, ReferenceType.SlideOnRemove)) {\n\t\t\t\t\tlref.callbacks?.beforeSlide?.(lref);\n\t\t\t\t\tprecedingRef =\n\t\t\t\t\t\tprecedingRef === undefined\n\t\t\t\t\t\t\t? beforeRefs.unshift(lref)?.first\n\t\t\t\t\t\t\t: beforeRefs.insertAfter(precedingRef, lref)?.first;\n\t\t\t\t\tlref.link(this.segment, 0, precedingRef);\n\t\t\t\t\tthis.refCount++;\n\t\t\t\t\tlref.callbacks?.afterSlide?.(lref);\n\t\t\t\t} else {\n\t\t\t\t\tlref.link(undefined, 0, undefined);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tvalidateRefCount?.(this);\n\t}\n\t/**\n\t * Insert a reference after tombstoned references.\n\t * @remarks This method should only be called by mergeTree.\n\t */\n\tpublic addAfterTombstones(...refs: Iterable<LocalReferencePosition>[]): void {\n\t\tconst lastOffset = this.segment.cachedLength - 1;\n\t\tconst afterRefs = this.refsByOffset[lastOffset]?.after ?? new DoublyLinkedList();\n\n\t\tif (this.refsByOffset[lastOffset]?.after === undefined) {\n\t\t\tconst refsAtOffset = (this.refsByOffset[lastOffset] ??= { after: afterRefs });\n\t\t\trefsAtOffset.after ??= afterRefs;\n\t\t}\n\n\t\tfor (const iterable of refs) {\n\t\t\tfor (const lref of iterable) {\n\t\t\t\tassertLocalReferences(lref);\n\t\t\t\tif (refTypeIncludesFlag(lref, ReferenceType.StayOnRemove)) {\n\t\t\t\t\tcontinue;\n\t\t\t\t} else if (refTypeIncludesFlag(lref, ReferenceType.SlideOnRemove)) {\n\t\t\t\t\tlref.callbacks?.beforeSlide?.(lref);\n\t\t\t\t\tafterRefs.push(lref);\n\t\t\t\t\tlref.link(this.segment, lastOffset, afterRefs.last);\n\t\t\t\t\tthis.refCount++;\n\t\t\t\t\tlref.callbacks?.afterSlide?.(lref);\n\t\t\t\t} else {\n\t\t\t\t\tlref.link(undefined, 0, undefined);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tvalidateRefCount?.(this);\n\t}\n\n\t/**\n\t * Determines if a reference is after tombstoned references.\n\t * @remarks This method should only be called by mergeTree.\n\t */\n\tpublic isAfterTombstone(lref: LocalReferencePosition): boolean {\n\t\tconst after = this.refsByOffset[lref.getOffset()]?.after;\n\t\tif (after) {\n\t\t\tassertLocalReferences(lref);\n\t\t\treturn after.includes(lref.getListNode());\n\t\t}\n\t\treturn false;\n\t}\n\n\t/**\n\t * Walks all of the references in a collection.\n\t * @remarks This method should only be called by mergeTree.\n\t */\n\tpublic walkReferences(\n\t\tvisitor: (lref: LocalReferencePosition) => boolean | void | undefined,\n\t\tstart?: LocalReferencePosition,\n\t\tforward: boolean = true,\n\t): boolean {\n\t\tif (start !== undefined) {\n\t\t\tif (!this.has(start)) {\n\t\t\t\tthrow new UsageError(\"start must be in collection\");\n\t\t\t}\n\t\t\tassertLocalReferences(start);\n\t\t}\n\t\tlet offset = start?.getOffset() ?? (forward ? 0 : this.segment.cachedLength - 1);\n\n\t\tconst offsetPositions: DoublyLinkedList<IRefsAtOffset[keyof IRefsAtOffset]> =\n\t\t\tnew DoublyLinkedList();\n\t\toffsetPositions.push(\n\t\t\tthis.refsByOffset[offset]?.before,\n\t\t\tthis.refsByOffset[offset]?.at,\n\t\t\tthis.refsByOffset[offset]?.after,\n\t\t);\n\n\t\tconst startNode = start?.getListNode();\n\t\tconst startList = startNode?.list;\n\n\t\tif (startList !== undefined) {\n\t\t\tif (forward) {\n\t\t\t\twhile (!offsetPositions.empty && offsetPositions.first !== startNode) {\n\t\t\t\t\toffsetPositions.shift();\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\twhile (!offsetPositions.empty && offsetPositions.last !== startNode) {\n\t\t\t\t\toffsetPositions.pop();\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tconst listWalker = (pos: DoublyLinkedList<LocalReference>): boolean => {\n\t\t\treturn walkList(\n\t\t\t\tpos,\n\t\t\t\t(node) => visitor(node.data),\n\t\t\t\tstartList === pos ? startNode : undefined,\n\t\t\t\tforward,\n\t\t\t);\n\t\t};\n\t\tconst increment = forward ? 1 : -1;\n\t\twhile (offset >= 0 && offset < this.refsByOffset.length) {\n\t\t\twhile (offsetPositions.length > 0) {\n\t\t\t\tconst offsetPos = forward ? offsetPositions.shift() : offsetPositions.pop();\n\t\t\t\tif (offsetPos?.data !== undefined && listWalker(offsetPos.data) === false) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t}\n\t\t\toffset += increment;\n\t\t\toffsetPositions.push(\n\t\t\t\tthis.refsByOffset[offset]?.before,\n\t\t\t\tthis.refsByOffset[offset]?.at,\n\t\t\t\tthis.refsByOffset[offset]?.after,\n\t\t\t);\n\t\t}\n\t\treturn true;\n\t}\n}\n"]}