@fluidframework/merge-tree 2.12.0 → 2.13.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 (285) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/dist/MergeTreeTextHelper.d.ts.map +1 -1
  3. package/dist/MergeTreeTextHelper.js +0 -2
  4. package/dist/MergeTreeTextHelper.js.map +1 -1
  5. package/dist/attributionPolicy.d.ts.map +1 -1
  6. package/dist/attributionPolicy.js +6 -16
  7. package/dist/attributionPolicy.js.map +1 -1
  8. package/dist/client.d.ts +3 -4
  9. package/dist/client.d.ts.map +1 -1
  10. package/dist/client.js +39 -28
  11. package/dist/client.js.map +1 -1
  12. package/dist/endOfTreeSegment.d.ts +2 -1
  13. package/dist/endOfTreeSegment.d.ts.map +1 -1
  14. package/dist/endOfTreeSegment.js.map +1 -1
  15. package/dist/index.d.ts +2 -1
  16. package/dist/index.d.ts.map +1 -1
  17. package/dist/index.js +2 -4
  18. package/dist/index.js.map +1 -1
  19. package/dist/mergeTree.d.ts +8 -7
  20. package/dist/mergeTree.d.ts.map +1 -1
  21. package/dist/mergeTree.js +190 -216
  22. package/dist/mergeTree.js.map +1 -1
  23. package/dist/mergeTreeNodeWalk.d.ts.map +1 -1
  24. package/dist/mergeTreeNodeWalk.js +3 -2
  25. package/dist/mergeTreeNodeWalk.js.map +1 -1
  26. package/dist/mergeTreeNodes.d.ts +76 -162
  27. package/dist/mergeTreeNodes.d.ts.map +1 -1
  28. package/dist/mergeTreeNodes.js +100 -112
  29. package/dist/mergeTreeNodes.js.map +1 -1
  30. package/dist/mergeTreeTracking.d.ts.map +1 -1
  31. package/dist/mergeTreeTracking.js +0 -2
  32. package/dist/mergeTreeTracking.js.map +1 -1
  33. package/dist/partialLengths.d.ts +2 -2
  34. package/dist/partialLengths.d.ts.map +1 -1
  35. package/dist/partialLengths.js +28 -26
  36. package/dist/partialLengths.js.map +1 -1
  37. package/dist/perspective.d.ts +3 -2
  38. package/dist/perspective.d.ts.map +1 -1
  39. package/dist/perspective.js +11 -4
  40. package/dist/perspective.js.map +1 -1
  41. package/dist/referencePositions.d.ts.map +1 -1
  42. package/dist/referencePositions.js +4 -1
  43. package/dist/referencePositions.js.map +1 -1
  44. package/dist/revertibles.d.ts.map +1 -1
  45. package/dist/revertibles.js +10 -11
  46. package/dist/revertibles.js.map +1 -1
  47. package/dist/segmentGroupCollection.d.ts +4 -4
  48. package/dist/segmentGroupCollection.d.ts.map +1 -1
  49. package/dist/segmentGroupCollection.js +0 -6
  50. package/dist/segmentGroupCollection.js.map +1 -1
  51. package/dist/segmentInfos.d.ts +257 -0
  52. package/dist/segmentInfos.d.ts.map +1 -0
  53. package/dist/segmentInfos.js +166 -0
  54. package/dist/segmentInfos.js.map +1 -0
  55. package/dist/snapshotLoader.d.ts.map +1 -1
  56. package/dist/snapshotLoader.js +38 -44
  57. package/dist/snapshotLoader.js.map +1 -1
  58. package/dist/snapshotV1.d.ts.map +1 -1
  59. package/dist/snapshotV1.js +9 -12
  60. package/dist/snapshotV1.js.map +1 -1
  61. package/dist/snapshotlegacy.d.ts +2 -2
  62. package/dist/snapshotlegacy.d.ts.map +1 -1
  63. package/dist/snapshotlegacy.js +5 -3
  64. package/dist/snapshotlegacy.js.map +1 -1
  65. package/dist/sortedSegmentSet.d.ts.map +1 -1
  66. package/dist/sortedSegmentSet.js +5 -8
  67. package/dist/sortedSegmentSet.js.map +1 -1
  68. package/dist/test/beastTest.spec.d.ts +0 -2
  69. package/dist/test/beastTest.spec.d.ts.map +1 -1
  70. package/dist/test/beastTest.spec.js +1 -5
  71. package/dist/test/beastTest.spec.js.map +1 -1
  72. package/dist/test/client.annotateMarker.spec.js.map +1 -1
  73. package/dist/test/client.applyMsg.spec.js +15 -12
  74. package/dist/test/client.applyMsg.spec.js.map +1 -1
  75. package/dist/test/client.attributionFarm.spec.js.map +1 -1
  76. package/dist/test/client.getPosition.spec.js +3 -2
  77. package/dist/test/client.getPosition.spec.js.map +1 -1
  78. package/dist/test/client.localReference.spec.js +6 -6
  79. package/dist/test/client.localReference.spec.js.map +1 -1
  80. package/dist/test/client.localReferenceFarm.spec.js.map +1 -1
  81. package/dist/test/client.rollback.spec.js.map +1 -1
  82. package/dist/test/dirname.cjs +0 -1
  83. package/dist/test/dirname.cjs.map +1 -1
  84. package/dist/test/index.d.ts +1 -1
  85. package/dist/test/index.d.ts.map +1 -1
  86. package/dist/test/index.js +2 -4
  87. package/dist/test/index.js.map +1 -1
  88. package/dist/test/mergeTree.annotate.spec.js +3 -0
  89. package/dist/test/mergeTree.annotate.spec.js.map +1 -1
  90. package/dist/test/mergeTree.insertingWalk.spec.js +1 -1
  91. package/dist/test/mergeTree.insertingWalk.spec.js.map +1 -1
  92. package/dist/test/mergeTree.markRangeRemoved.spec.js +2 -0
  93. package/dist/test/mergeTree.markRangeRemoved.spec.js.map +1 -1
  94. package/dist/test/mergeTree.walk.spec.js.map +1 -1
  95. package/dist/test/mergeTreeOperationRunner.d.ts.map +1 -1
  96. package/dist/test/mergeTreeOperationRunner.js +2 -3
  97. package/dist/test/mergeTreeOperationRunner.js.map +1 -1
  98. package/dist/test/obliterate.spec.js.map +1 -1
  99. package/dist/test/propertyManager.spec.js.map +1 -1
  100. package/dist/test/reconnectHelper.d.ts +2 -1
  101. package/dist/test/reconnectHelper.d.ts.map +1 -1
  102. package/dist/test/reconnectHelper.js.map +1 -1
  103. package/dist/test/resetPendingSegmentsToOp.spec.js.map +1 -1
  104. package/dist/test/revertibleFarm.spec.js.map +1 -1
  105. package/dist/test/segmentGroupCollection.spec.js +15 -3
  106. package/dist/test/segmentGroupCollection.spec.js.map +1 -1
  107. package/dist/test/snapshot.utils.d.ts +2 -2
  108. package/dist/test/snapshot.utils.d.ts.map +1 -1
  109. package/dist/test/snapshot.utils.js.map +1 -1
  110. package/dist/test/sortedSegmentSet.spec.js +4 -3
  111. package/dist/test/sortedSegmentSet.spec.js.map +1 -1
  112. package/dist/test/testClient.d.ts +8 -6
  113. package/dist/test/testClient.d.ts.map +1 -1
  114. package/dist/test/testClient.js +29 -27
  115. package/dist/test/testClient.js.map +1 -1
  116. package/dist/test/testClientLogger.d.ts.map +1 -1
  117. package/dist/test/testClientLogger.js +6 -4
  118. package/dist/test/testClientLogger.js.map +1 -1
  119. package/dist/test/testUtils.d.ts +2 -2
  120. package/dist/test/testUtils.d.ts.map +1 -1
  121. package/dist/test/testUtils.js +32 -8
  122. package/dist/test/testUtils.js.map +1 -1
  123. package/dist/test/text.d.ts +2 -2
  124. package/dist/test/text.d.ts.map +1 -1
  125. package/dist/test/text.js +12 -6
  126. package/dist/test/text.js.map +1 -1
  127. package/dist/test/tracking.spec.js.map +1 -1
  128. package/dist/test/wordUnitTests.spec.js +1 -1
  129. package/dist/test/wordUnitTests.spec.js.map +1 -1
  130. package/dist/zamboni.d.ts.map +1 -1
  131. package/dist/zamboni.js +8 -7
  132. package/dist/zamboni.js.map +1 -1
  133. package/lib/MergeTreeTextHelper.d.ts.map +1 -1
  134. package/lib/MergeTreeTextHelper.js +0 -2
  135. package/lib/MergeTreeTextHelper.js.map +1 -1
  136. package/lib/attributionPolicy.d.ts.map +1 -1
  137. package/lib/attributionPolicy.js +6 -16
  138. package/lib/attributionPolicy.js.map +1 -1
  139. package/lib/client.d.ts +3 -4
  140. package/lib/client.d.ts.map +1 -1
  141. package/lib/client.js +40 -29
  142. package/lib/client.js.map +1 -1
  143. package/lib/endOfTreeSegment.d.ts +2 -1
  144. package/lib/endOfTreeSegment.d.ts.map +1 -1
  145. package/lib/endOfTreeSegment.js.map +1 -1
  146. package/lib/index.d.ts +2 -1
  147. package/lib/index.d.ts.map +1 -1
  148. package/lib/index.js +1 -1
  149. package/lib/index.js.map +1 -1
  150. package/lib/mergeTree.d.ts +8 -7
  151. package/lib/mergeTree.d.ts.map +1 -1
  152. package/lib/mergeTree.js +177 -205
  153. package/lib/mergeTree.js.map +1 -1
  154. package/lib/mergeTreeNodeWalk.d.ts.map +1 -1
  155. package/lib/mergeTreeNodeWalk.js +3 -2
  156. package/lib/mergeTreeNodeWalk.js.map +1 -1
  157. package/lib/mergeTreeNodes.d.ts +76 -162
  158. package/lib/mergeTreeNodes.d.ts.map +1 -1
  159. package/lib/mergeTreeNodes.js +95 -108
  160. package/lib/mergeTreeNodes.js.map +1 -1
  161. package/lib/mergeTreeTracking.d.ts.map +1 -1
  162. package/lib/mergeTreeTracking.js +0 -2
  163. package/lib/mergeTreeTracking.js.map +1 -1
  164. package/lib/partialLengths.d.ts +2 -2
  165. package/lib/partialLengths.d.ts.map +1 -1
  166. package/lib/partialLengths.js +25 -23
  167. package/lib/partialLengths.js.map +1 -1
  168. package/lib/perspective.d.ts +3 -2
  169. package/lib/perspective.d.ts.map +1 -1
  170. package/lib/perspective.js +11 -4
  171. package/lib/perspective.js.map +1 -1
  172. package/lib/referencePositions.d.ts.map +1 -1
  173. package/lib/referencePositions.js +4 -1
  174. package/lib/referencePositions.js.map +1 -1
  175. package/lib/revertibles.d.ts.map +1 -1
  176. package/lib/revertibles.js +8 -9
  177. package/lib/revertibles.js.map +1 -1
  178. package/lib/segmentGroupCollection.d.ts +4 -4
  179. package/lib/segmentGroupCollection.d.ts.map +1 -1
  180. package/lib/segmentGroupCollection.js +0 -6
  181. package/lib/segmentGroupCollection.js.map +1 -1
  182. package/lib/segmentInfos.d.ts +257 -0
  183. package/lib/segmentInfos.d.ts.map +1 -0
  184. package/lib/segmentInfos.js +145 -0
  185. package/lib/segmentInfos.js.map +1 -0
  186. package/lib/snapshotLoader.d.ts.map +1 -1
  187. package/lib/snapshotLoader.js +38 -44
  188. package/lib/snapshotLoader.js.map +1 -1
  189. package/lib/snapshotV1.d.ts.map +1 -1
  190. package/lib/snapshotV1.js +9 -12
  191. package/lib/snapshotV1.js.map +1 -1
  192. package/lib/snapshotlegacy.d.ts +2 -2
  193. package/lib/snapshotlegacy.d.ts.map +1 -1
  194. package/lib/snapshotlegacy.js +5 -3
  195. package/lib/snapshotlegacy.js.map +1 -1
  196. package/lib/sortedSegmentSet.d.ts.map +1 -1
  197. package/lib/sortedSegmentSet.js +5 -8
  198. package/lib/sortedSegmentSet.js.map +1 -1
  199. package/lib/test/beastTest.spec.d.ts +0 -2
  200. package/lib/test/beastTest.spec.d.ts.map +1 -1
  201. package/lib/test/beastTest.spec.js +0 -3
  202. package/lib/test/beastTest.spec.js.map +1 -1
  203. package/lib/test/client.annotateMarker.spec.js.map +1 -1
  204. package/lib/test/client.applyMsg.spec.js +15 -12
  205. package/lib/test/client.applyMsg.spec.js.map +1 -1
  206. package/lib/test/client.attributionFarm.spec.js.map +1 -1
  207. package/lib/test/client.getPosition.spec.js +3 -2
  208. package/lib/test/client.getPosition.spec.js.map +1 -1
  209. package/lib/test/client.localReference.spec.js +1 -1
  210. package/lib/test/client.localReference.spec.js.map +1 -1
  211. package/lib/test/client.localReferenceFarm.spec.js.map +1 -1
  212. package/lib/test/client.rollback.spec.js +1 -1
  213. package/lib/test/client.rollback.spec.js.map +1 -1
  214. package/lib/test/dirname.cjs +0 -1
  215. package/lib/test/dirname.cjs.map +1 -1
  216. package/lib/test/index.d.ts +1 -1
  217. package/lib/test/index.d.ts.map +1 -1
  218. package/lib/test/index.js +1 -1
  219. package/lib/test/index.js.map +1 -1
  220. package/lib/test/mergeTree.annotate.spec.js +3 -0
  221. package/lib/test/mergeTree.annotate.spec.js.map +1 -1
  222. package/lib/test/mergeTree.insertingWalk.spec.js +2 -2
  223. package/lib/test/mergeTree.insertingWalk.spec.js.map +1 -1
  224. package/lib/test/mergeTree.markRangeRemoved.spec.js +2 -0
  225. package/lib/test/mergeTree.markRangeRemoved.spec.js.map +1 -1
  226. package/lib/test/mergeTree.walk.spec.js.map +1 -1
  227. package/lib/test/mergeTreeOperationRunner.d.ts.map +1 -1
  228. package/lib/test/mergeTreeOperationRunner.js +1 -2
  229. package/lib/test/mergeTreeOperationRunner.js.map +1 -1
  230. package/lib/test/obliterate.spec.js.map +1 -1
  231. package/lib/test/propertyManager.spec.js.map +1 -1
  232. package/lib/test/reconnectHelper.d.ts +2 -1
  233. package/lib/test/reconnectHelper.d.ts.map +1 -1
  234. package/lib/test/reconnectHelper.js.map +1 -1
  235. package/lib/test/resetPendingSegmentsToOp.spec.js.map +1 -1
  236. package/lib/test/revertibleFarm.spec.js.map +1 -1
  237. package/lib/test/segmentGroupCollection.spec.js +15 -3
  238. package/lib/test/segmentGroupCollection.spec.js.map +1 -1
  239. package/lib/test/snapshot.utils.d.ts +2 -2
  240. package/lib/test/snapshot.utils.d.ts.map +1 -1
  241. package/lib/test/snapshot.utils.js.map +1 -1
  242. package/lib/test/sortedSegmentSet.spec.js +4 -3
  243. package/lib/test/sortedSegmentSet.spec.js.map +1 -1
  244. package/lib/test/testClient.d.ts +8 -6
  245. package/lib/test/testClient.d.ts.map +1 -1
  246. package/lib/test/testClient.js +30 -28
  247. package/lib/test/testClient.js.map +1 -1
  248. package/lib/test/testClientLogger.d.ts.map +1 -1
  249. package/lib/test/testClientLogger.js +5 -3
  250. package/lib/test/testClientLogger.js.map +1 -1
  251. package/lib/test/testUtils.d.ts +2 -2
  252. package/lib/test/testUtils.d.ts.map +1 -1
  253. package/lib/test/testUtils.js +9 -8
  254. package/lib/test/testUtils.js.map +1 -1
  255. package/lib/test/text.d.ts +2 -2
  256. package/lib/test/text.d.ts.map +1 -1
  257. package/lib/test/text.js +12 -6
  258. package/lib/test/text.js.map +1 -1
  259. package/lib/test/tracking.spec.js.map +1 -1
  260. package/lib/test/wordUnitTests.spec.js +1 -1
  261. package/lib/test/wordUnitTests.spec.js.map +1 -1
  262. package/lib/zamboni.d.ts.map +1 -1
  263. package/lib/zamboni.js +7 -6
  264. package/lib/zamboni.js.map +1 -1
  265. package/package.json +17 -17
  266. package/src/MergeTreeTextHelper.ts +2 -4
  267. package/src/attributionPolicy.ts +5 -13
  268. package/src/client.ts +55 -44
  269. package/src/endOfTreeSegment.ts +3 -3
  270. package/src/index.ts +4 -6
  271. package/src/mergeTree.ts +245 -282
  272. package/src/mergeTreeNodeWalk.ts +3 -2
  273. package/src/mergeTreeNodes.ts +190 -322
  274. package/src/mergeTreeTracking.ts +0 -3
  275. package/src/partialLengths.ts +42 -27
  276. package/src/perspective.ts +27 -4
  277. package/src/referencePositions.ts +4 -1
  278. package/src/revertibles.ts +19 -13
  279. package/src/segmentGroupCollection.ts +7 -18
  280. package/src/segmentInfos.ts +377 -0
  281. package/src/snapshotLoader.ts +60 -57
  282. package/src/snapshotV1.ts +14 -16
  283. package/src/snapshotlegacy.ts +12 -17
  284. package/src/sortedSegmentSet.ts +6 -8
  285. package/src/zamboni.ts +10 -12
@@ -4,47 +4,46 @@
4
4
  * Licensed under the MIT License.
5
5
  */
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.debugMarkerToString = exports.compareStrings = exports.compareNumbers = exports.CollaborationWindow = exports.Marker = exports.reservedMarkerSimpleTypeKey = exports.reservedMarkerIdKey = exports.BaseSegment = exports.seqLTE = exports.MergeBlock = exports.MaxNodesInBlock = exports.segmentIsRemoved = exports.toMoveInfo = exports.toRemovalInfo = void 0;
8
- /* eslint-disable @typescript-eslint/no-non-null-assertion */
7
+ exports.compareStrings = exports.compareNumbers = exports.CollaborationWindow = exports.Marker = exports.reservedMarkerSimpleTypeKey = exports.reservedMarkerIdKey = exports.BaseSegment = exports.seqLTE = exports.assignChild = exports.MergeBlock = exports.MaxNodesInBlock = exports.segmentIsRemoved = exports.assertSegmentLeaf = exports.toSegmentLeaf = exports.isSegmentLeaf = void 0;
9
8
  const internal_1 = require("@fluidframework/core-utils/internal");
10
9
  const constants_js_1 = require("./constants.js");
11
10
  // eslint-disable-next-line import/no-deprecated
12
11
  const localReference_js_1 = require("./localReference.js");
13
12
  const mergeTreeTracking_js_1 = require("./mergeTreeTracking.js");
14
- const ops_js_1 = require("./ops.js");
15
13
  const ordinal_js_1 = require("./ordinal.js");
16
14
  const properties_js_1 = require("./properties.js");
17
- const referencePositions_js_1 = require("./referencePositions.js");
15
+ const segmentInfos_js_1 = require("./segmentInfos.js");
18
16
  /**
19
- * Returns the removal information for a segment.
17
+ * A type-guard which determines if the segment has segment leaf, and
18
+ * returns true if it does, along with applying strong typing.
19
+ * @param nodeLike - The segment-like object to check.
20
+ * @returns True if the segment is a segment leaf, otherwise false.
21
+ */
22
+ const isSegmentLeaf = (segmentLike) => (0, segmentInfos_js_1.isInserted)(segmentLike) && (0, segmentInfos_js_1.isMergeNodeInfo)(segmentLike);
23
+ exports.isSegmentLeaf = isSegmentLeaf;
24
+ /**
25
+ * Converts a segment-like object to a segment leaf object if possible.
20
26
  *
21
- * @internal
27
+ * @param segmentLike - The segment-like object to convert.
28
+ * @returns The segment leaf if the conversion is possible, otherwise undefined.
22
29
  */
23
- function toRemovalInfo(maybe) {
24
- if (maybe?.removedClientIds !== undefined && maybe?.removedSeq !== undefined) {
25
- return maybe;
26
- }
27
- (0, internal_1.assert)(maybe?.removedClientIds === undefined && maybe?.removedSeq === undefined, 0x2bf /* "both removedClientIds and removedSeq should be set or not set" */);
28
- }
29
- exports.toRemovalInfo = toRemovalInfo;
30
- function toMoveInfo(maybe) {
31
- if (maybe?.movedClientIds !== undefined && maybe?.movedSeq !== undefined) {
32
- return maybe;
33
- }
34
- (0, internal_1.assert)(maybe?.movedClientIds === undefined &&
35
- maybe?.movedSeq === undefined &&
36
- maybe?.movedSeqs === undefined &&
37
- maybe?.wasMovedOnInsert === undefined, 0x86d /* movedClientIds, movedSeq, wasMovedOnInsert, and movedSeqs should all be either set or not set */);
38
- }
39
- exports.toMoveInfo = toMoveInfo;
30
+ const toSegmentLeaf = (segmentLike) => (0, exports.isSegmentLeaf)(segmentLike) ? segmentLike : undefined;
31
+ exports.toSegmentLeaf = toSegmentLeaf;
32
+ /**
33
+ * Asserts that the segment is a segment leaf. Usage of this function should not produce a user facing error.
34
+ *
35
+ * @param segmentLike - The segment-like object to check.
36
+ * @throws Will throw an error if the segment is not a segment leaf.
37
+ */
38
+ const assertSegmentLeaf = (segmentLike) => (0, internal_1.assert)((0, exports.isSegmentLeaf)(segmentLike), 0xaab /* must be segment leaf */);
39
+ exports.assertSegmentLeaf = assertSegmentLeaf;
40
40
  /**
41
41
  * Determine if a segment has been removed.
42
42
  * @legacy
43
43
  * @alpha
44
44
  */
45
45
  function segmentIsRemoved(segment) {
46
- const leaf = segment;
47
- return leaf.removedSeq !== undefined;
46
+ return (0, segmentInfos_js_1.isRemoved)(segment);
48
47
  }
49
48
  exports.segmentIsRemoved = segmentIsRemoved;
50
49
  /**
@@ -52,12 +51,8 @@ exports.segmentIsRemoved = segmentIsRemoved;
52
51
  * the MergeTree always inserts first, then checks for overflow and splits if the child count equals
53
52
  * `MaxNodesInBlock`. (i.e., `MaxNodesInBlock` contains 1 extra slot for temporary storage to
54
53
  * facilitate splits.)
55
- * @internal
56
54
  */
57
55
  exports.MaxNodesInBlock = 8;
58
- /**
59
- * @internal
60
- */
61
56
  class MergeBlock {
62
57
  isLeaf() {
63
58
  return false;
@@ -80,16 +75,20 @@ class MergeBlock {
80
75
  (0, internal_1.assert)(childCount >= 1 && childCount <= exports.MaxNodesInBlock, 0x040 /* "Child count is not within [1,8] range!" */);
81
76
  child.ordinal = (0, ordinal_js_1.computeHierarchicalOrdinal)(exports.MaxNodesInBlock, childCount, this.ordinal, index === 0 ? undefined : this.children[index - 1]?.ordinal);
82
77
  }
83
- assignChild(child, index, updateOrdinal = true) {
84
- child.parent = this;
85
- child.index = index;
86
- if (updateOrdinal) {
87
- this.setOrdinal(child, index);
88
- }
89
- this.children[index] = child;
90
- }
91
78
  }
92
79
  exports.MergeBlock = MergeBlock;
80
+ function assignChild(parent, child, index, updateOrdinal = true) {
81
+ const node = Object.assign(child, {
82
+ parent,
83
+ index,
84
+ ordinal: child.ordinal ?? "",
85
+ });
86
+ if (updateOrdinal) {
87
+ parent.setOrdinal(node, index);
88
+ }
89
+ parent.children[index] = node;
90
+ }
91
+ exports.assignChild = assignChild;
93
92
  function seqLTE(seq, minOrRefSeq) {
94
93
  return seq !== constants_js_1.UnassignedSequenceNumber && seq <= minOrRefSeq;
95
94
  }
@@ -129,18 +128,32 @@ class BaseSegment {
129
128
  return true;
130
129
  }
131
130
  cloneInto(b) {
132
- b.clientId = this.clientId;
131
+ const seg = b;
132
+ if ((0, segmentInfos_js_1.isInserted)(this)) {
133
+ (0, segmentInfos_js_1.overwriteInfo)(seg, {
134
+ clientId: this.clientId,
135
+ seq: this.seq,
136
+ });
137
+ }
133
138
  // TODO: deep clone properties
134
- b.properties = (0, properties_js_1.clone)(this.properties);
135
- b.removedClientIds = this.removedClientIds?.slice();
136
- // TODO: copy removed client overlap and branch removal info
137
- b.removedSeq = this.removedSeq;
138
- b.movedClientIds = this.movedClientIds?.slice();
139
- b.movedSeq = this.movedSeq;
140
- b.movedSeqs = this.movedSeqs;
141
- b.wasMovedOnInsert = this.wasMovedOnInsert;
142
- b.seq = this.seq;
143
- b.attribution = this.attribution?.clone();
139
+ seg.properties = (0, properties_js_1.clone)(this.properties);
140
+ if ((0, segmentInfos_js_1.isRemoved)(this)) {
141
+ // eslint-disable-next-line import/no-deprecated
142
+ (0, segmentInfos_js_1.overwriteInfo)(seg, {
143
+ removedSeq: this.removedSeq,
144
+ removedClientIds: [...this.removedClientIds],
145
+ });
146
+ }
147
+ if ((0, segmentInfos_js_1.isMoved)(this)) {
148
+ // eslint-disable-next-line import/no-deprecated
149
+ (0, segmentInfos_js_1.overwriteInfo)(seg, {
150
+ movedSeq: this.movedSeq,
151
+ movedSeqs: [...this.movedSeqs],
152
+ wasMovedOnInsert: this.wasMovedOnInsert,
153
+ movedClientIds: [...this.movedClientIds],
154
+ });
155
+ }
156
+ seg.attribution = this.attribution?.clone();
144
157
  }
145
158
  canAppend(segment) {
146
159
  return false;
@@ -158,27 +171,44 @@ class BaseSegment {
158
171
  if (!leafSegment) {
159
172
  return undefined;
160
173
  }
161
- // eslint-disable-next-line @typescript-eslint/no-this-alias, unicorn/no-this-assignment
162
- const thisAsMergeSegment = this;
163
- leafSegment.parent = thisAsMergeSegment.parent;
164
- // Give the leaf a temporary yet valid ordinal.
165
- // when this segment is put in the tree, it will get its real ordinal,
166
- // but this ordinal meets all the necessary invariants for now.
167
- // Ordinals exist purely for lexicographical sort order and use a small set of valid bytes for each string character.
168
- // The extra handling fromCodePoint has for things like surrogate pairs is therefore unnecessary.
169
- // eslint-disable-next-line unicorn/prefer-code-point
170
- leafSegment.ordinal = this.ordinal + String.fromCharCode(0);
171
- leafSegment.removedClientIds = this.removedClientIds?.slice();
172
- leafSegment.removedSeq = this.removedSeq;
173
- leafSegment.localRemovedSeq = this.localRemovedSeq;
174
- leafSegment.seq = this.seq;
175
- leafSegment.localSeq = this.localSeq;
176
- leafSegment.clientId = this.clientId;
177
- leafSegment.movedClientIds = this.movedClientIds?.slice();
178
- leafSegment.movedSeq = this.movedSeq;
179
- leafSegment.movedSeqs = this.movedSeqs?.slice();
180
- leafSegment.localMovedSeq = this.localMovedSeq;
181
- leafSegment.wasMovedOnInsert = this.wasMovedOnInsert;
174
+ if ((0, segmentInfos_js_1.isMergeNodeInfo)(this)) {
175
+ (0, segmentInfos_js_1.overwriteInfo)(leafSegment, {
176
+ index: this.index + 1,
177
+ // Give the leaf a temporary yet valid ordinal.
178
+ // when this segment is put in the tree, it will get its real ordinal,
179
+ // but this ordinal meets all the necessary invariants for now.
180
+ // Ordinals exist purely for lexicographical sort order and use a small set of valid bytes for each string character.
181
+ // The extra handling fromCodePoint has for things like surrogate pairs is therefore unnecessary.
182
+ // eslint-disable-next-line unicorn/prefer-code-point
183
+ ordinal: this.ordinal + String.fromCharCode(0),
184
+ parent: this.parent,
185
+ });
186
+ }
187
+ if ((0, segmentInfos_js_1.isInserted)(this)) {
188
+ (0, segmentInfos_js_1.overwriteInfo)(leafSegment, {
189
+ seq: this.seq,
190
+ localSeq: this.localSeq,
191
+ clientId: this.clientId,
192
+ });
193
+ }
194
+ if ((0, segmentInfos_js_1.isRemoved)(this)) {
195
+ // eslint-disable-next-line import/no-deprecated
196
+ (0, segmentInfos_js_1.overwriteInfo)(leafSegment, {
197
+ removedClientIds: [...this.removedClientIds],
198
+ removedSeq: this.removedSeq,
199
+ localRemovedSeq: this.localRemovedSeq,
200
+ });
201
+ }
202
+ if ((0, segmentInfos_js_1.isMoved)(this)) {
203
+ // eslint-disable-next-line import/no-deprecated
204
+ (0, segmentInfos_js_1.overwriteInfo)(leafSegment, {
205
+ movedClientIds: [...this.movedClientIds],
206
+ movedSeq: this.movedSeq,
207
+ movedSeqs: [...this.movedSeqs],
208
+ localMovedSeq: this.localMovedSeq,
209
+ wasMovedOnInsert: this.wasMovedOnInsert,
210
+ });
211
+ }
182
212
  this.trackingCollection.copyTo(leafSegment);
183
213
  if (this.attribution) {
184
214
  leafSegment.attribution = this.attribution.splitAt(pos);
@@ -323,7 +353,7 @@ class CollaborationWindow {
323
353
  * { localSeq: 1, seq: UnassignedSequenceNumber, text: "C" },
324
354
  * ]
325
355
  * ```
326
- * (note that {@link ISegment.localSeq} tracks the localSeq at which a segment was inserted)
356
+ * (note that localSeq tracks the localSeq at which a segment was inserted)
327
357
  *
328
358
  * Suppose the client then disconnects and reconnects before any of its insertions are acked. The reconnect flow will necessitate
329
359
  * that the client regenerates and resubmits ops based on its current segment state as well as the original op that was sent.
@@ -384,46 +414,4 @@ exports.compareNumbers = compareNumbers;
384
414
  */
385
415
  const compareStrings = (a, b) => a.localeCompare(b);
386
416
  exports.compareStrings = compareStrings;
387
- /**
388
- * Get a human-readable string for a given {@link Marker}.
389
- *
390
- * @remarks This function is intended for debugging only. The exact format of
391
- * this string should not be relied upon between versions.
392
- * @internal
393
- */
394
- function debugMarkerToString(marker) {
395
- let bbuf = "";
396
- if ((0, referencePositions_js_1.refTypeIncludesFlag)(marker, ops_js_1.ReferenceType.Tile)) {
397
- bbuf += "Tile";
398
- }
399
- let lbuf = "";
400
- const id = marker.getId();
401
- if (id) {
402
- bbuf += ` (${id}) `;
403
- }
404
- const tileLabels = (0, referencePositions_js_1.refGetTileLabels)(marker);
405
- if (tileLabels) {
406
- lbuf += "tile -- ";
407
- for (let i = 0, len = tileLabels.length; i < len; i++) {
408
- const tileLabel = tileLabels[i];
409
- if (i > 0) {
410
- lbuf += "; ";
411
- }
412
- lbuf += tileLabel;
413
- }
414
- }
415
- let pbuf = "";
416
- if (marker.properties) {
417
- pbuf += JSON.stringify(marker.properties, (key, value) => {
418
- // Avoid circular reference when stringifying makers containing handles.
419
- // (Substitute a debug string instead.)
420
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
421
- const handle = !!value && value.IFluidHandle;
422
- // eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-member-access
423
- return handle ? `#Handle(${handle.routeContext.path}/${handle.path})` : value;
424
- });
425
- }
426
- return `M ${bbuf}: ${lbuf} ${pbuf}`;
427
- }
428
- exports.debugMarkerToString = debugMarkerToString;
429
417
  //# sourceMappingURL=mergeTreeNodes.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"mergeTreeNodes.js","sourceRoot":"","sources":["../src/mergeTreeNodes.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,6DAA6D;AAE7D,kEAA6D;AAI7D,iDAIwB;AACxB,gDAAgD;AAChD,2DAA4F;AAC5F,iEAAiE;AACjE,qCAAmE;AACnE,6CAA0D;AAE1D,mDAA8E;AAC9E,mEAIiC;AA0FjC;;;;GAIG;AACH,SAAgB,aAAa,CAC5B,KAAwC;IAExC,IAAI,KAAK,EAAE,gBAAgB,KAAK,SAAS,IAAI,KAAK,EAAE,UAAU,KAAK,SAAS,EAAE,CAAC;QAC9E,OAAO,KAAqB,CAAC;IAC9B,CAAC;IACD,IAAA,iBAAM,EACL,KAAK,EAAE,gBAAgB,KAAK,SAAS,IAAI,KAAK,EAAE,UAAU,KAAK,SAAS,EACxE,KAAK,CAAC,qEAAqE,CAC3E,CAAC;AACH,CAAC;AAVD,sCAUC;AAsED,SAAgB,UAAU,CAAC,KAAqC;IAC/D,IAA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,EAAE,CAAC;QACR,IAAI,IAAI,KAAK,EAAE,IAAI,CAAC;IACrB,CAAC;IACD,MAAM,UAAU,GAAG,IAAA,wCAAgB,EAAC,MAAM,CAAC,CAAC;IAC5C,IAAI,UAAU,EAAE,CAAC;QAChB,IAAI,IAAI,UAAU,CAAC;QACnB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,GAAG,GAAG,UAAU,CAAC,MAAM,EAAE,CAAC,GAAG,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC;YACvD,MAAM,SAAS,GAAG,UAAU,CAAC,CAAC,CAAC,CAAC;YAChC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;gBACX,IAAI,IAAI,IAAI,CAAC;YACd,CAAC;YACD,IAAI,IAAI,SAAS,CAAC;QACnB,CAAC;IACF,CAAC;IAED,IAAI,IAAI,GAAG,EAAE,CAAC;IACd,IAAI,MAAM,CAAC,UAAU,EAAE,CAAC;QACvB,IAAI,IAAI,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,UAAU,EAAE,CAAC,GAAG,EAAE,KAAK,EAAE,EAAE;YACxD,wEAAwE;YACxE,uCAAuC;YACvC,+GAA+G;YAC/G,MAAM,MAAM,GAAG,CAAC,CAAC,KAAK,IAAI,KAAK,CAAC,YAAY,CAAC;YAE7C,2GAA2G;YAC3G,OAAO,MAAM,CAAC,CAAC,CAAC,WAAW,MAAM,CAAC,YAAY,CAAC,IAAI,IAAI,MAAM,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC;QAC/E,CAAC,CAAC,CAAC;IACJ,CAAC;IACD,OAAO,KAAK,IAAI,KAAK,IAAI,IAAI,IAAI,EAAE,CAAC;AACrC,CAAC;AAnCD,kDAmCC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/* eslint-disable @typescript-eslint/no-non-null-assertion */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport { AttributionKey } from \"@fluidframework/runtime-definitions/internal\";\n\nimport { IAttributionCollection } from \"./attributionCollection.js\";\nimport {\n\tLocalClientId,\n\tUnassignedSequenceNumber,\n\tUniversalSequenceNumber,\n} from \"./constants.js\";\n// eslint-disable-next-line import/no-deprecated\nimport { LocalReferenceCollection, type LocalReferencePosition } from \"./localReference.js\";\nimport { TrackingGroupCollection } from \"./mergeTreeTracking.js\";\nimport { IJSONSegment, IMarkerDef, ReferenceType } from \"./ops.js\";\nimport { computeHierarchicalOrdinal } from \"./ordinal.js\";\nimport type { PartialSequenceLengths } from \"./partialLengths.js\";\nimport { PropertySet, clone, createMap, type MapLike } from \"./properties.js\";\nimport {\n\tReferencePosition,\n\trefGetTileLabels,\n\trefTypeIncludesFlag,\n} from \"./referencePositions.js\";\n// eslint-disable-next-line import/no-deprecated\nimport { SegmentGroupCollection } from \"./segmentGroupCollection.js\";\n// eslint-disable-next-line import/no-deprecated\nimport { PropertiesManager } from \"./segmentPropertiesManager.js\";\n\n/**\n * Common properties for a node in a merge tree.\n * @legacy\n * @alpha\n * @deprecated - This interface will be removed in 2.20 with no replacement.\n */\nexport interface IMergeNodeCommon {\n\t/**\n\t * The index of this node in its parent's list of children.\n\t */\n\tindex: number;\n\t/**\n\t * A string that can be used for comparing the location of this node to other `MergeNode`s in the same tree.\n\t * `a.ordinal < b.ordinal` if and only if `a` comes before `b` in a pre-order traversal of the tree.\n\t */\n\tordinal: string;\n\tisLeaf(): this is ISegment;\n}\n\n/**\n * This interface exposes internal things to dds that leverage merge tree,\n * like sequence and matrix.\n *\n * We use tiered interface to control visibility of segment properties.\n * This sits between ISegment and ISegmentLeaf. It should only expose\n * things tagged internal.\n *\n * @internal\n */\nexport type ISegmentInternal = Omit<ISegment, keyof IRemovalInfo | keyof IMoveInfo> &\n\tPartial<IMergeNodeCommon> &\n\tPartial<IRemovalInfo> &\n\tPartial<IMoveInfo> & {\n\t\t// eslint-disable-next-line import/no-deprecated\n\t\tlocalRefs?: LocalReferenceCollection;\n\t};\n\n/**\n * We use tiered interface to control visibility of segment properties.\n * This is the lowest interface and is not exported, it site below ISegment and ISegmentInternal.\n * It should only expose unexported things.\n *\n * someday we may split tree leaves from segments, but for now they are the same\n * this is just a convenience type that makes it clear that we need something that is both a segment and a leaf node\n */\nexport type ISegmentLeaf = ISegmentInternal & {\n\tparent?: MergeBlock;\n\t// eslint-disable-next-line import/no-deprecated\n\tsegmentGroups?: SegmentGroupCollection;\n\t// eslint-disable-next-line import/no-deprecated\n\tpropertyManager?: PropertiesManager;\n\t/**\n\t * If a segment is inserted into an obliterated range,\n\t * but the newest obliteration of that range was by the inserting client,\n\t * then the segment is not obliterated because it is aware of the latest obliteration.\n\t */\n\tprevObliterateByInserter?: ObliterateInfo;\n};\nexport type IMergeNode = MergeBlock | ISegmentLeaf;\n\n/**\n * Contains removal information associated to an {@link ISegment}.\n * @legacy\n * @alpha\n * @deprecated - This interface will be removed in 2.20 with no replacement.\n */\nexport interface IRemovalInfo {\n\t/**\n\t * Local seq at which this segment was removed, if the removal is yet-to-be acked.\n\t */\n\tlocalRemovedSeq?: number;\n\t/**\n\t * Seq at which this segment was removed.\n\t */\n\tremovedSeq: number;\n\t/**\n\t * List of client IDs that have removed this segment.\n\t * The client that actually removed the segment (i.e. whose removal op was sequenced first) is stored as the first\n\t * client in this list. Other clients in the list have all issued concurrent ops to remove the segment.\n\t * @remarks When this list has length \\> 1, this is referred to as the \"overlapping remove\" case.\n\t */\n\tremovedClientIds: number[];\n}\n\n/**\n * Returns the removal information for a segment.\n *\n * @internal\n */\nexport function toRemovalInfo(\n\tmaybe: Partial<IRemovalInfo> | undefined,\n): IRemovalInfo | undefined {\n\tif (maybe?.removedClientIds !== undefined && maybe?.removedSeq !== undefined) {\n\t\treturn maybe as IRemovalInfo;\n\t}\n\tassert(\n\t\tmaybe?.removedClientIds === undefined && maybe?.removedSeq === undefined,\n\t\t0x2bf /* \"both removedClientIds and removedSeq should be set or not set\" */,\n\t);\n}\n\n/**\n * Tracks information about when and where this segment was moved to.\n *\n * Note that merge-tree does not currently support moving and only supports\n * obliterate. The fields below include \"move\" in their names to avoid renaming\n * in the future, when moves _are_ supported.\n * @legacy\n * @alpha\n * @deprecated - This interface will be removed in 2.20 with no replacement.\n */\nexport interface IMoveInfo {\n\t/**\n\t * Local seq at which this segment was moved if the move is yet-to-be\n\t * acked.\n\t */\n\tlocalMovedSeq?: number;\n\n\t/**\n\t * The first seq at which this segment was moved.\n\t */\n\tmovedSeq: number;\n\n\t/**\n\t * All seqs at which this segment was moved. In the case of overlapping,\n\t * concurrent moves this array will contain multiple seqs.\n\t *\n\t * The seq at `movedSeqs[i]` corresponds to the client id at `movedClientIds[i]`.\n\t *\n\t * The first element corresponds to the seq of the first move\n\t */\n\tmovedSeqs: number[];\n\n\t/**\n\t * A reference to the inserted destination segment corresponding to this\n\t * segment's move.\n\t *\n\t * If undefined, the move was an obliterate.\n\t *\n\t * Currently this field is unused, as we only support obliterate operations\n\t */\n\tmoveDst?: ReferencePosition;\n\n\t/**\n\t * List of client IDs that have moved this segment.\n\t *\n\t * The client that actually moved the segment (i.e. whose move op was sequenced\n\t * first) is stored as the first client in this list. Other clients in the\n\t * list have all issued concurrent ops to move the segment.\n\t */\n\tmovedClientIds: number[];\n\n\t/**\n\t * If this segment was inserted into a concurrently moved range and\n\t * the move op was sequenced before the insertion op. In this case,\n\t * the segment is visible only to the inserting client\n\t *\n\t * `wasMovedOnInsert` only applies for acked obliterates. That is, if\n\t * a segment inserted by a remote client is moved on insertion by a local\n\t * and unacked obliterate, we do not consider it as having been moved\n\t * on insert\n\t *\n\t * If a segment is moved on insertion, its length is only ever visible to\n\t * the client that inserted the segment. This is relevant in partial length\n\t * calculations\n\t */\n\twasMovedOnInsert: boolean;\n}\n\nexport function toMoveInfo(maybe: Partial<IMoveInfo> | undefined): IMoveInfo | undefined {\n\tif (maybe?.movedClientIds !== undefined && maybe?.movedSeq !== undefined) {\n\t\treturn maybe as IMoveInfo;\n\t}\n\tassert(\n\t\tmaybe?.movedClientIds === undefined &&\n\t\t\tmaybe?.movedSeq === undefined &&\n\t\t\tmaybe?.movedSeqs === undefined &&\n\t\t\tmaybe?.wasMovedOnInsert === undefined,\n\t\t0x86d /* movedClientIds, movedSeq, wasMovedOnInsert, and movedSeqs should all be either set or not set */,\n\t);\n}\n\n/**\n * A segment representing a portion of the merge tree.\n * Segments are leaf nodes of the merge tree and contain data.\n * @legacy\n * @alpha\n */\nexport interface ISegment {\n\treadonly type: string;\n\n\treadonly trackingCollection: TrackingGroupCollection;\n\t/**\n\t * Whether or not this segment is a special segment denoting the start or\n\t * end of the tree\n\t *\n\t * Endpoint segments are imaginary segments positioned immediately before or\n\t * after the tree. These segments cannot be referenced by regular operations\n\t * and exist primarily as a bucket for local references to slide onto during\n\t * deletion of regular segments.\n\t * @deprecated - This property will be removed in 2.20 with no replacement.\n\t */\n\treadonly endpointType?: \"start\" | \"end\";\n\n\t/**\n\t * The length of the contents of the node.\n\t */\n\tcachedLength: number;\n\t/**\n\t * Stores attribution keys associated with offsets of this segment.\n\t * This data is only persisted if MergeTree's `attributions.track` flag is set to true.\n\t * Pending segments (i.e. ones that only exist locally and haven't been acked by the server) also have\n\t * `attribution === undefined` until ack.\n\t *\n\t * Keys can be used opaquely with an IAttributor or a container runtime that provides attribution.\n\t * @remarks There are plans to make the shape of the data stored extensible in a couple ways:\n\t *\n\t * 1. Injection of custom attribution information associated with the segment (ex: copy-paste of\n\t * content but keeping the old attribution information).\n\t *\n\t * 2. Storage of multiple \"channels\" of information (ex: track property changes separately from insertion,\n\t * or only attribute certain property modifications, etc.)\n\t */\n\tattribution?: IAttributionCollection<AttributionKey>;\n\n\t/**\n\t * Local seq at which this segment was inserted.\n\t * This is defined if and only if the insertion of the segment is pending ack, i.e. `seq` is UnassignedSequenceNumber.\n\t * Once the segment is acked, this field is cleared.\n\t *\n\t * @privateRemarks\n\t * See {@link CollaborationWindow.localSeq} for more information on the semantics of localSeq.\n\t * @deprecated - This property will be removed in 2.20 with no replacement.\n\t */\n\tlocalSeq?: number;\n\t/**\n\t * Local seq at which this segment was removed. If this is defined, `removedSeq` will initially be set to\n\t * UnassignedSequenceNumber. However, if another client concurrently removes the same segment, `removedSeq`\n\t * will be updated to the seq at which that client removed this segment.\n\t *\n\t * Like {@link ISegment.localSeq}, this field is cleared once the local removal of the segment is acked.\n\t *\n\t * @privateRemarks\n\t * See {@link CollaborationWindow.localSeq} for more information on the semantics of localSeq.\n\t * @deprecated - This property will be removed in 2.20 with no replacement.\n\t */\n\tlocalRemovedSeq?: number;\n\t/**\n\t * Seq at which this segment was inserted.\n\t * If undefined, it is assumed the segment was inserted prior to the collab window's minimum sequence number.\n\t * @deprecated - This property will be removed in 2.20 with no replacement.\n\t */\n\tseq?: number;\n\t/**\n\t * Short clientId for the client that inserted this segment.\n\t * @deprecated - This property will be removed in 2.20 with no replacement.\n\t */\n\tclientId: number;\n\t/**\n\t * Local references added to this segment.\n\t * @deprecated - This property will be removed in 2.20 with no replacement.\n\t */\n\t// eslint-disable-next-line import/no-deprecated\n\tlocalRefs?: LocalReferenceCollection;\n\t/**\n\t * Properties that have been added to this segment via annotation.\n\t */\n\tproperties?: PropertySet;\n\n\tclone(): ISegment;\n\tcanAppend(segment: ISegment): boolean;\n\tappend(segment: ISegment): void;\n\tsplitAt(pos: number): ISegment | undefined;\n\t// Changing this to something other than any would break consumers.\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\ttoJSONObject(): any;\n\tisLeaf(): this is ISegment;\n\n\t/**\n\t * {@inheritDoc @fluidframework/merge-tree#IMergeNodeCommon.index}\n\t * @deprecated - This property will be removed in 2.20 with no replacement.\n\t */\n\tindex: number;\n\t/**\n\t * {@inheritDoc @fluidframework/merge-tree#IMergeNodeCommon.ordinal}\n\t * @deprecated - This property will be removed in 2.20 with no replacement.\n\t */\n\tordinal: string;\n\n\t/**\n\t * {@inheritDoc @fluidframework/merge-tree#IRemovalInfo.removedSeq}\n\t * @deprecated - This property will be removed in 2.20 with no replacement.\n\t */\n\tremovedSeq?: number;\n\t/**\n\t * {@inheritDoc @fluidframework/merge-tree#IRemovalInfo.removedClientIds}\n\t * @deprecated - This property will be removed in 2.20 with no replacement.\n\t */\n\tremovedClientIds?: number[];\n\t/**\n\t * {@inheritDoc @fluidframework/merge-tree#IMoveInfo.localMovedSeq}\n\t * @deprecated - This property will be removed in 2.20 with no replacement.\n\t */\n\tlocalMovedSeq?: number;\n\t/**\n\t * {@inheritDoc @fluidframework/merge-tree#IMoveInfo.movedSeq}\n\t * @deprecated - This property will be removed in 2.20 with no replacement.\n\t */\n\tmovedSeq?: number;\n\n\t/**\n\t * {@inheritDoc @fluidframework/merge-tree#IMoveInfo.movedSeqs}\n\t * @deprecated - This property will be removed in 2.20 with no replacement.\n\t */\n\tmovedSeqs?: number[];\n\t/**\n\t * {@inheritDoc @fluidframework/merge-tree#IMoveInfo.moveDst}\n\t * @deprecated - This property will be removed in 2.20 with no replacement.\n\t */\n\tmoveDst?: ReferencePosition;\n\t/**\n\t * {@inheritDoc @fluidframework/merge-tree#IMoveInfo.movedClientIds}\n\t * @deprecated - This property will be removed in 2.20 with no replacement.\n\t */\n\tmovedClientIds?: number[];\n\t/**\n\t * {@inheritDoc @fluidframework/merge-tree#IMoveInfo.wasMovedOnInsert}\n\t * @deprecated - This property will be removed in 2.20 with no replacement.\n\t */\n\twasMovedOnInsert?: boolean;\n}\n\n/**\n * Determine if a segment has been removed.\n * @legacy\n * @alpha\n */\nexport function segmentIsRemoved(segment: ISegment): boolean {\n\tconst leaf: ISegmentLeaf = segment;\n\treturn leaf.removedSeq !== undefined;\n}\n\n/**\n * @internal\n */\nexport interface IMarkerModifiedAction {\n\t// eslint-disable-next-line @typescript-eslint/prefer-function-type\n\t(marker: Marker): void;\n}\n\n/**\n * @legacy\n * @alpha\n */\nexport interface ISegmentAction<TClientData> {\n\t// eslint-disable-next-line @typescript-eslint/prefer-function-type\n\t(\n\t\tsegment: ISegment,\n\t\tpos: number,\n\t\trefSeq: number,\n\t\tclientId: number,\n\t\tstart: number,\n\t\tend: number,\n\t\taccum: TClientData,\n\t): boolean;\n}\n/**\n * @internal\n */\nexport interface ISegmentChanges {\n\tnext?: ISegmentInternal;\n\treplaceCurrent?: ISegmentInternal;\n}\n/**\n * @internal\n */\nexport interface BlockAction<TClientData> {\n\t// eslint-disable-next-line @typescript-eslint/prefer-function-type\n\t(\n\t\tblock: MergeBlock,\n\t\tpos: number,\n\t\trefSeq: number,\n\t\tclientId: number,\n\t\tstart: number | undefined,\n\t\tend: number | undefined,\n\t\taccum: TClientData,\n\t): boolean;\n}\n\n/**\n * @internal\n */\nexport interface NodeAction<TClientData> {\n\t// eslint-disable-next-line @typescript-eslint/prefer-function-type\n\t(\n\t\tnode: IMergeNode,\n\t\tpos: number,\n\t\trefSeq: number,\n\t\tclientId: number,\n\t\tstart: number | undefined,\n\t\tend: number | undefined,\n\t\tclientData: TClientData,\n\t): boolean;\n}\n\n/**\n * @internal\n */\nexport interface InsertContext {\n\tcandidateSegment?: ISegmentInternal;\n\tleaf: (\n\t\tsegment: ISegmentInternal | undefined,\n\t\tpos: number,\n\t\tic: InsertContext,\n\t) => ISegmentChanges;\n\tcontinuePredicate?: (continueFromBlock: MergeBlock) => boolean;\n}\n\n/**\n * @internal\n */\nexport interface SegmentActions<TClientData> {\n\tleaf?: ISegmentAction<TClientData>;\n\tshift?: NodeAction<TClientData>;\n\tcontains?: NodeAction<TClientData>;\n\tpre?: BlockAction<TClientData>;\n\tpost?: BlockAction<TClientData>;\n}\n\n/**\n * @internal\n */\nexport interface ObliterateInfo {\n\tstart: LocalReferencePosition;\n\tend: LocalReferencePosition;\n\trefSeq: number;\n\tclientId: number;\n\tseq: number;\n\tlocalSeq: number | undefined;\n\tsegmentGroup: SegmentGroup | undefined;\n}\n\n/**\n * @internal\n */\nexport interface SegmentGroup<S extends ISegmentInternal = ISegmentInternal> {\n\tsegments: S[];\n\tpreviousProps?: PropertySet[];\n\tlocalSeq?: number;\n\trefSeq: number;\n\tobliterateInfo?: ObliterateInfo;\n}\n\n/**\n * Note that the actual branching factor of the MergeTree is `MaxNodesInBlock - 1`. This is because\n * the MergeTree always inserts first, then checks for overflow and splits if the child count equals\n * `MaxNodesInBlock`. (i.e., `MaxNodesInBlock` contains 1 extra slot for temporary storage to\n * facilitate splits.)\n * @internal\n */\nexport const MaxNodesInBlock = 8;\n/**\n * @internal\n */\nexport class MergeBlock implements IMergeNodeCommon {\n\tpublic children: IMergeNode[];\n\tpublic needsScour?: boolean;\n\tpublic parent?: MergeBlock;\n\tpublic index: number = 0;\n\tpublic ordinal: string = \"\";\n\tpublic cachedLength: number | undefined = 0;\n\n\t/**\n\t * Maps each tile label in this block to the rightmost (i.e. furthest) marker associated with that tile label.\n\t * When combined with the tree structure of MergeBlocks, this allows accelerated queries for nearest tile\n\t * with a certain label before a given position\n\t */\n\tpublic rightmostTiles: Readonly<MapLike<Marker>>;\n\t/**\n\t * Maps each tile label in this block to the leftmost (i.e. nearest) marker associated with that tile label.\n\t * When combined with the tree structure of MergeBlocks, this allows accelerated queries for nearest tile\n\t * with a certain label before a given position\n\t */\n\tpublic leftmostTiles: Readonly<MapLike<Marker>>;\n\n\tisLeaf(): this is ISegmentInternal {\n\t\treturn false;\n\t}\n\n\t/**\n\t * Supports querying the total length of all descendants of this IMergeBlock from the perspective of any\n\t * (clientId, seq) within the collab window.\n\t *\n\t * @remarks This is only optional for implementation reasons (internal nodes can be created/moved without\n\t * immediately initializing the partial lengths). Aside from mid-update on tree operations, these lengths\n\t * objects are always defined.\n\t */\n\tpartialLengths?: PartialSequenceLengths;\n\n\tpublic constructor(public childCount: number) {\n\t\t// Suppression needed due to the way the merge tree children are initalized - we\n\t\t// allocate 8 children blocks, but any unused blocks are not counted in the childCount.\n\t\t// Using Array.from leads to unused children being undefined, which are counted in childCount.\n\t\t// eslint-disable-next-line unicorn/no-new-array\n\t\tthis.children = new Array<IMergeNode>(MaxNodesInBlock);\n\t\tthis.rightmostTiles = createMap<Marker>();\n\t\tthis.leftmostTiles = createMap<Marker>();\n\t}\n\n\tpublic setOrdinal(child: IMergeNode, index: number): void {\n\t\tconst childCount = this.childCount;\n\t\tassert(\n\t\t\tchildCount >= 1 && childCount <= MaxNodesInBlock,\n\t\t\t0x040 /* \"Child count is not within [1,8] range!\" */,\n\t\t);\n\t\tchild.ordinal = computeHierarchicalOrdinal(\n\t\t\tMaxNodesInBlock,\n\t\t\tchildCount,\n\t\t\tthis.ordinal,\n\t\t\tindex === 0 ? undefined : this.children[index - 1]?.ordinal,\n\t\t);\n\t}\n\n\tpublic assignChild(child: IMergeNode, index: number, updateOrdinal = true): void {\n\t\tchild.parent = this;\n\t\tchild.index = index;\n\t\tif (updateOrdinal) {\n\t\t\tthis.setOrdinal(child, index);\n\t\t}\n\t\tthis.children[index] = child;\n\t}\n}\n\nexport function seqLTE(seq: number, minOrRefSeq: number): boolean {\n\treturn seq !== UnassignedSequenceNumber && seq <= minOrRefSeq;\n}\n\n/**\n * @legacy\n * @alpha\n */\nexport abstract class BaseSegment implements ISegment {\n\t/**\n\t * @deprecated - This property will be removed in 2.20 with no replacement.\n\t */\n\tpublic clientId: number = LocalClientId;\n\t/**\n\t * @deprecated - This property will be removed in 2.20 with no replacement.\n\t */\n\tpublic seq: number = UniversalSequenceNumber;\n\t/**\n\t * @deprecated - This property will be removed in 2.20 with no replacement.\n\t */\n\tpublic removedSeq?: number;\n\t/**\n\t * @deprecated - This property will be removed in 2.20 with no replacement.\n\t */\n\tpublic removedClientIds?: number[];\n\t/**\n\t * @deprecated - This property will be removed in 2.20 with no replacement.\n\t */\n\tpublic movedSeq?: number;\n\t/**\n\t * @deprecated - This property will be removed in 2.20 with no replacement.\n\t */\n\tpublic movedSeqs?: number[];\n\t/**\n\t * @deprecated - This property will be removed in 2.20 with no replacement.\n\t */\n\tpublic movedClientIds?: number[];\n\t/**\n\t * @deprecated - This property will be removed in 2.20 with no replacement.\n\t */\n\tpublic wasMovedOnInsert?: boolean | undefined;\n\t/**\n\t * @deprecated - This property will be removed in 2.20 with no replacement.\n\t */\n\tpublic index: number = 0;\n\t/**\n\t * @deprecated - This property will be removed in 2.20 with no replacement.\n\t */\n\tpublic ordinal: string = \"\";\n\tpublic cachedLength: number = 0;\n\n\tpublic readonly trackingCollection: TrackingGroupCollection = new TrackingGroupCollection(\n\t\tthis,\n\t);\n\t/***/\n\tpublic attribution?: IAttributionCollection<AttributionKey>;\n\n\tpublic properties?: PropertySet;\n\t/**\n\t * @deprecated - This property will be removed in 2.20 with no replacement.\n\t */\n\t// eslint-disable-next-line import/no-deprecated\n\tpublic localRefs?: LocalReferenceCollection;\n\tpublic abstract readonly type: string;\n\t/**\n\t * @deprecated - This property will be removed in 2.20 with no replacement.\n\t */\n\tpublic localSeq?: number;\n\t/**\n\t * @deprecated - This property will be removed in 2.20 with no replacement.\n\t */\n\tpublic localRemovedSeq?: number;\n\t/**\n\t * @deprecated - This property will be removed in 2.20 with no replacement.\n\t */\n\tpublic localMovedSeq?: number;\n\n\tpublic constructor(properties?: PropertySet) {\n\t\tif (properties !== undefined) {\n\t\t\tthis.properties = clone(properties);\n\t\t}\n\t}\n\n\tpublic hasProperty(key: string): boolean {\n\t\treturn !!this.properties && this.properties[key] !== undefined;\n\t}\n\n\tpublic isLeaf(): this is ISegment {\n\t\treturn true;\n\t}\n\n\tprotected cloneInto(b: ISegment): void {\n\t\tb.clientId = this.clientId;\n\t\t// TODO: deep clone properties\n\t\tb.properties = clone(this.properties);\n\t\tb.removedClientIds = this.removedClientIds?.slice();\n\t\t// TODO: copy removed client overlap and branch removal info\n\t\tb.removedSeq = this.removedSeq;\n\t\tb.movedClientIds = this.movedClientIds?.slice();\n\t\tb.movedSeq = this.movedSeq;\n\t\tb.movedSeqs = this.movedSeqs;\n\t\tb.wasMovedOnInsert = this.wasMovedOnInsert;\n\t\tb.seq = this.seq;\n\t\tb.attribution = this.attribution?.clone();\n\t}\n\n\tpublic canAppend(segment: ISegment): boolean {\n\t\treturn false;\n\t}\n\n\tprotected addSerializedProps(jseg: IJSONSegment): void {\n\t\tif (this.properties) {\n\t\t\tjseg.props = { ...this.properties };\n\t\t}\n\t}\n\t// This has to return any type because the return type is different for different segment types.\n\t// TODO: If possible, change the return type to match what should be returned for each segment type.\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tpublic abstract toJSONObject(): any;\n\n\tpublic splitAt(pos: number): ISegment | undefined {\n\t\tif (pos <= 0) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst leafSegment: ISegmentLeaf | undefined = this.createSplitSegmentAt(pos);\n\n\t\tif (!leafSegment) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\t// eslint-disable-next-line @typescript-eslint/no-this-alias, unicorn/no-this-assignment\n\t\tconst thisAsMergeSegment: ISegmentLeaf = this;\n\t\tleafSegment.parent = thisAsMergeSegment.parent;\n\n\t\t// Give the leaf a temporary yet valid ordinal.\n\t\t// when this segment is put in the tree, it will get its real ordinal,\n\t\t// but this ordinal meets all the necessary invariants for now.\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\tleafSegment.ordinal = this.ordinal + String.fromCharCode(0);\n\n\t\tleafSegment.removedClientIds = this.removedClientIds?.slice();\n\t\tleafSegment.removedSeq = this.removedSeq;\n\t\tleafSegment.localRemovedSeq = this.localRemovedSeq;\n\t\tleafSegment.seq = this.seq;\n\t\tleafSegment.localSeq = this.localSeq;\n\t\tleafSegment.clientId = this.clientId;\n\t\tleafSegment.movedClientIds = this.movedClientIds?.slice();\n\t\tleafSegment.movedSeq = this.movedSeq;\n\t\tleafSegment.movedSeqs = this.movedSeqs?.slice();\n\t\tleafSegment.localMovedSeq = this.localMovedSeq;\n\t\tleafSegment.wasMovedOnInsert = this.wasMovedOnInsert;\n\n\t\tthis.trackingCollection.copyTo(leafSegment);\n\t\tif (this.attribution) {\n\t\t\tleafSegment.attribution = this.attribution.splitAt(pos);\n\t\t}\n\n\t\treturn leafSegment;\n\t}\n\n\tpublic abstract clone(): ISegment;\n\n\tpublic append(other: ISegment): void {\n\t\t// Note: Must call 'appendLocalRefs' before modifying this segment's length as\n\t\t// 'this.cachedLength' is used to adjust the offsets of the local refs.\n\t\t// eslint-disable-next-line import/no-deprecated\n\t\tLocalReferenceCollection.append(this, other);\n\t\tif (this.attribution) {\n\t\t\tassert(\n\t\t\t\tother.attribution !== undefined,\n\t\t\t\t0x4bd /* attribution should be set on appendee */,\n\t\t\t);\n\t\t\tthis.attribution.append(other.attribution);\n\t\t} else {\n\t\t\tassert(\n\t\t\t\tother.attribution === undefined,\n\t\t\t\t0x4be /* attribution should not be set on appendee */,\n\t\t\t);\n\t\t}\n\n\t\tthis.cachedLength ??= 0;\n\t\tthis.cachedLength += other.cachedLength;\n\t}\n\n\tprotected abstract createSplitSegmentAt(pos: number): BaseSegment | undefined;\n}\n\n/**\n * The special-cased property key that tracks the id of a {@link Marker}.\n *\n * @remarks In general, marker ids should be accessed using the inherent method\n * {@link Marker.getId}. Marker ids should not be updated after creation.\n * @legacy\n * @alpha\n */\nexport const reservedMarkerIdKey = \"markerId\";\n\n/**\n * @internal\n */\nexport const reservedMarkerSimpleTypeKey = \"markerSimpleType\";\n\n/**\n * @legacy\n * @alpha\n */\nexport interface IJSONMarkerSegment extends IJSONSegment {\n\tmarker: IMarkerDef;\n}\n\n/**\n * Markers are a special kind of segment that do not hold any content.\n *\n * Markers with a reference type of {@link ReferenceType.Tile} support spatially\n * accelerated queries for finding the next marker to the left or right of it in\n * sub-linear time. This is useful, for example, in the case of jumping from the\n * start of a paragraph to the end, assuming a paragraph is bound by markers at\n * the start and end.\n *\n * @legacy\n * @alpha\n */\nexport class Marker extends BaseSegment implements ReferencePosition, ISegment {\n\tpublic static readonly type = \"Marker\";\n\tpublic static is(segment: ISegment): segment is Marker {\n\t\treturn segment.type === Marker.type;\n\t}\n\tpublic readonly type = Marker.type;\n\n\tpublic static make(refType: ReferenceType, props?: PropertySet): Marker {\n\t\treturn new Marker(refType, props);\n\t}\n\n\tconstructor(\n\t\tpublic refType: ReferenceType,\n\t\tprops?: PropertySet,\n\t) {\n\t\tsuper(props);\n\t\tthis.cachedLength = 1;\n\t}\n\n\ttoJSONObject(): IJSONMarkerSegment {\n\t\tconst obj: IJSONMarkerSegment = { marker: { refType: this.refType } };\n\t\tsuper.addSerializedProps(obj);\n\t\treturn obj;\n\t}\n\n\tstatic fromJSONObject(spec: IJSONSegment): Marker | undefined {\n\t\tif (spec && typeof spec === \"object\" && \"marker\" in spec) {\n\t\t\treturn Marker.make((spec.marker as Marker).refType, spec.props as PropertySet);\n\t\t}\n\t\treturn undefined;\n\t}\n\n\tclone(): Marker {\n\t\tconst b = Marker.make(this.refType, this.properties);\n\t\tthis.cloneInto(b);\n\t\treturn b;\n\t}\n\n\tgetSegment(): Marker {\n\t\treturn this;\n\t}\n\n\tgetOffset(): number {\n\t\treturn 0;\n\t}\n\n\tgetProperties(): PropertySet | undefined {\n\t\treturn this.properties;\n\t}\n\n\tgetId(): string | undefined {\n\t\treturn this.properties?.[reservedMarkerIdKey] as string;\n\t}\n\n\ttoString(): string {\n\t\treturn `M${this.getId()}`;\n\t}\n\n\tprotected createSplitSegmentAt(pos: number): undefined {\n\t\treturn undefined;\n\t}\n\n\tcanAppend(segment: ISegment): boolean {\n\t\treturn false;\n\t}\n\n\tappend(): void {\n\t\tthrow new Error(\"Can not append to marker\");\n\t}\n}\n\n/**\n * This class is used to track facts about the current window of collaboration. This window is defined by the server\n * specified minimum sequence number to the last sequence number seen. Additionally, it track state for outstanding\n * local operations.\n * @internal\n */\nexport class CollaborationWindow {\n\tclientId = LocalClientId;\n\tcollaborating = false;\n\n\t/**\n\t * Lowest-numbered segment in window; no client can reference a state before this one\n\t */\n\tminSeq = 0;\n\t/**\n\t * Highest-numbered segment in window and current reference sequence number for this client.\n\t */\n\tcurrentSeq = 0;\n\n\t/**\n\t * Highest-numbered localSeq used for a pending segment.\n\t * Semantically, `localSeq`s provide an ordering on in-flight merge-tree operations:\n\t * for operations stamped with localSeqs `a` and `b`, `a < b` if and only if `a` was submitted before `b`.\n\t *\n\t * @remarks - This field is analogous to the `clientSequenceNumber` field on ops, but it's accessible to merge-tree\n\t * at op submission time rather than only at ack time. This enables more natural state tracking for in-flight ops.\n\t *\n\t * It's useful to stamp ops with such an incrementing counter because it enables reasoning about which segments existed from\n\t * the perspective of the local client at a given point in 'un-acked' time, which is necessary to support the reconnect flow.\n\t *\n\t * For example, imagine a client with initial state \"123456\" submits some ops to create the text \"123456ABC\".\n\t * If they insert the \"C\" first, then \"B\", then \"A\", their local segment state might look like this:\n\t * ```js\n\t * [\n\t * { seq: 0, text: \"1234\" },\n\t * { seq: 5, text: \"56\" },\n\t * { localSeq: 3, seq: UnassignedSequenceNumber, text: \"A\" },\n\t * { localSeq: 2, seq: UnassignedSequenceNumber, text: \"B\" },\n\t * { localSeq: 1, seq: UnassignedSequenceNumber, text: \"C\" },\n\t * ]\n\t * ```\n\t * (note that {@link ISegment.localSeq} tracks the localSeq at which a segment was inserted)\n\t *\n\t * Suppose the client then disconnects and reconnects before any of its insertions are acked. The reconnect flow will necessitate\n\t * that the client regenerates and resubmits ops based on its current segment state as well as the original op that was sent.\n\t *\n\t * It will generate the ops\n\t * 1. \\{ pos: 6, text: \"C\" \\}\n\t * 2. \\{ pos: 6, text: \"B\" \\}\n\t * 3. \\{ pos: 6, text: \"A\" \\}\n\t *\n\t * since when submitting the first op, remote clients don't know that this client is about to submit the \"A\" and \"B\".\n\t *\n\t * On the other hand, imagine if the client had originally submitted the ops in the order \"A\", \"B\", \"C\"\n\t * such that the segments' local state was instead:\n\t *\n\t * ```js\n\t * [\n\t * { seq: 0, text: \"1234\" },\n\t * { seq: 5, text: \"56\" },\n\t * { localSeq: 1, seq: UnassignedSequenceNumber, text: \"A\" },\n\t * { localSeq: 2, seq: UnassignedSequenceNumber, text: \"B\" },\n\t * { localSeq: 3, seq: UnassignedSequenceNumber, text: \"C\" },\n\t * ]\n\t * ```\n\t *\n\t * The resubmitted ops should instead be:\n\t * 1. \\{ pos: 6, text: \"A\" \\}\n\t * 2. \\{ pos: 7, text: \"B\" \\}\n\t * 3. \\{ pos: 8, text: \"C\" \\}\n\t *\n\t * since remote clients will have seen the \"A\" when processing the \"B\" as well as both the \"A\" and \"B\" when processing the \"C\".\n\t * As can be seen, the list of resubmitted ops is different in the two cases despite the merge-tree's segment state only differing\n\t * in `localSeq`.\n\t *\n\t * This example is a bit simplified from the general scenario: since no remote clients modified the merge-tree while the client\n\t * was disconnected, the resubmitted ops end up matching the original ops exactly.\n\t * However, this is not generally true: the production reconnect code takes into account visibility of segments based on both acked\n\t * and local information as appropriate.\n\t * Nonetheless, this simple scenario is enough to understand why it's useful to be able to determine if a segment should be visible\n\t * from a given (seq, localSeq) perspective.\n\t */\n\tlocalSeq = 0;\n\n\tloadFrom(a: CollaborationWindow): void {\n\t\tthis.clientId = a.clientId;\n\t\tthis.collaborating = a.collaborating;\n\t\tthis.minSeq = a.minSeq;\n\t\tthis.currentSeq = a.currentSeq;\n\t}\n}\n\n/**\n * Compares two numbers.\n */\nexport const compareNumbers = (a: number, b: number): number => a - b;\n\n/**\n * Compares two strings.\n */\nexport const compareStrings = (a: string, b: string): number => a.localeCompare(b);\n\n/**\n * Get a human-readable string for a given {@link Marker}.\n *\n * @remarks This function is intended for debugging only. The exact format of\n * this string should not be relied upon between versions.\n * @internal\n */\nexport function debugMarkerToString(marker: Marker): string {\n\tlet bbuf = \"\";\n\tif (refTypeIncludesFlag(marker, ReferenceType.Tile)) {\n\t\tbbuf += \"Tile\";\n\t}\n\tlet lbuf = \"\";\n\tconst id = marker.getId();\n\tif (id) {\n\t\tbbuf += ` (${id}) `;\n\t}\n\tconst tileLabels = refGetTileLabels(marker);\n\tif (tileLabels) {\n\t\tlbuf += \"tile -- \";\n\t\tfor (let i = 0, len = tileLabels.length; i < len; i++) {\n\t\t\tconst tileLabel = tileLabels[i];\n\t\t\tif (i > 0) {\n\t\t\t\tlbuf += \"; \";\n\t\t\t}\n\t\t\tlbuf += tileLabel;\n\t\t}\n\t}\n\n\tlet pbuf = \"\";\n\tif (marker.properties) {\n\t\tpbuf += JSON.stringify(marker.properties, (key, value) => {\n\t\t\t// Avoid circular reference when stringifying makers containing handles.\n\t\t\t// (Substitute a debug string instead.)\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access\n\t\t\tconst handle = !!value && value.IFluidHandle;\n\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-member-access\n\t\t\treturn handle ? `#Handle(${handle.routeContext.path}/${handle.path})` : value;\n\t\t});\n\t}\n\treturn `M ${bbuf}: ${lbuf} ${pbuf}`;\n}\n"]}
1
+ {"version":3,"file":"mergeTreeNodes.js","sourceRoot":"","sources":["../src/mergeTreeNodes.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAA6D;AAI7D,iDAIwB;AACxB,gDAAgD;AAChD,2DAA4F;AAC5F,iEAAiE;AAEjE,6CAA0D;AAE1D,mDAA8E;AAG9E,uDAa2B;AAuF3B;;;;;GAKG;AACI,MAAM,aAAa,GAAG,CAAC,WAAoB,EAA+B,EAAE,CAClF,IAAA,4BAAU,EAAC,WAAW,CAAC,IAAI,IAAA,iCAAW,EAAC,WAAW,CAAC,CAAC;AADxC,QAAA,aAAa,iBAC2B;AAErD;;;;;GAKG;AACI,MAAM,aAAa,GAAG,CAAC,WAAoB,EAA4B,EAAE,CAC/E,IAAA,qBAAa,EAAC,WAAW,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,SAAS,CAAC;AADzC,QAAA,aAAa,iBAC4B;AACtD;;;;;GAKG;AACI,MAAM,iBAAiB,GAC7B,CAAC,WAAW,EAAE,EAAE,CAAC,IAAA,iBAAM,EAAC,IAAA,qBAAa,EAAC,WAAW,C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AC,CAAC,CAAC,CAAC;AAAtE,QAAA,cAAc,kBAAwD","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 { AttributionKey } from \"@fluidframework/runtime-definitions/internal\";\n\nimport { IAttributionCollection } from \"./attributionCollection.js\";\nimport {\n\tLocalClientId,\n\tUnassignedSequenceNumber,\n\tUniversalSequenceNumber,\n} from \"./constants.js\";\n// eslint-disable-next-line import/no-deprecated\nimport { LocalReferenceCollection, type LocalReferencePosition } from \"./localReference.js\";\nimport { TrackingGroupCollection } from \"./mergeTreeTracking.js\";\nimport { IJSONSegment, IMarkerDef, ReferenceType } from \"./ops.js\";\nimport { computeHierarchicalOrdinal } from \"./ordinal.js\";\nimport type { PartialSequenceLengths } from \"./partialLengths.js\";\nimport { PropertySet, clone, createMap, type MapLike } from \"./properties.js\";\nimport { ReferencePosition } from \"./referencePositions.js\";\nimport { SegmentGroupCollection } from \"./segmentGroupCollection.js\";\nimport {\n\tisInserted,\n\tisMergeNodeInfo as isMergeNode,\n\tisMoved,\n\tisRemoved,\n\toverwriteInfo,\n\ttype IInsertionInfo,\n\ttype IMergeNodeInfo,\n\t// eslint-disable-next-line import/no-deprecated\n\ttype IMoveInfo,\n\t// eslint-disable-next-line import/no-deprecated\n\ttype IRemovalInfo,\n\ttype SegmentWithInfo,\n} from \"./segmentInfos.js\";\nimport { PropertiesManager } from \"./segmentPropertiesManager.js\";\n\n/**\n * Common properties for a node in a merge tree.\n * @legacy\n * @alpha\n * @deprecated - This interface will be removed in 2.20 with no replacement.\n */\nexport interface IMergeNodeCommon {\n\t/**\n\t * The index of this node in its parent's list of children.\n\t */\n\tindex: number;\n\t/**\n\t * A string that can be used for comparing the location of this node to other `MergeNode`s in the same tree.\n\t * `a.ordinal < b.ordinal` if and only if `a` comes before `b` in a pre-order traversal of the tree.\n\t */\n\tordinal: string;\n\tisLeaf(): this is ISegment;\n}\n\n/**\n * This interface exposes internal things to dds that leverage merge tree,\n * like sequence and matrix.\n *\n * We use tiered interface to control visibility of segment properties.\n * This sits between ISegment and ISegmentPrivate. It should only expose\n * things tagged internal.\n *\n * Everything added here beyond ISegment should be optional to keep the ability\n * to implicitly convert between the tiered interfaces.\n *\n * @internal\n */\nexport type ISegmentInternal = Omit<\n\tISegment,\n\t// eslint-disable-next-line import/no-deprecated\n\tkeyof IRemovalInfo | keyof IMoveInfo\n> & {\n\t// eslint-disable-next-line import/no-deprecated\n\tlocalRefs?: LocalReferenceCollection;\n};\n\n/**\n * We use tiered interface to control visibility of segment properties.\n * This is the lowest interface and is not exported, it site below ISegment and ISegmentInternal.\n * It should only expose unexported things.\n *\n * Everything added here beyond ISegmentInternal should be optional to keep the ability\n * to implicitly convert between the tiered interfaces.\n *\n * someday we may split tree leaves from segments, but for now they are the same\n * this is just a convenience type that makes it clear that we need something that is both a segment and a leaf node\n */\nexport type ISegmentPrivate = ISegmentInternal & // eslint-disable-next-line import/no-deprecated\n\tPartial<IInsertionInfo & IMergeNodeInfo> & {\n\t\tsegmentGroups?: SegmentGroupCollection;\n\t\tpropertyManager?: PropertiesManager;\n\t\t/**\n\t\t * If a segment is inserted into an obliterated range,\n\t\t * but the newest obliteration of that range was by the inserting client,\n\t\t * then the segment is not obliterated because it is aware of the latest obliteration.\n\t\t */\n\t\tprevObliterateByInserter?: ObliterateInfo;\n\t\t/**\n\t\t * Whether or not this segment is a special segment denoting the start or\n\t\t * end of the tree\n\t\t *\n\t\t * Endpoint segments are imaginary segments positioned immediately before or\n\t\t * after the tree. These segments cannot be referenced by regular operations\n\t\t * and exist primarily as a bucket for local references to slide onto during\n\t\t * deletion of regular segments.\n\t\t */\n\t\treadonly endpointType?: \"start\" | \"end\";\n\t};\n\n/**\n * Segment leafs are segments that have both IMergeNodeInfo and IInsertionInfo. This means they\n * are inserted at a position, and bound via their parent MergeBlock to the merge tree. MergeBlocks'\n * children are either a segment leaf, or another merge block for interior nodes of the tree. When working\n * within the tree it is generally unnecessary to use type coercions methods common to the infos, and segment\n * leafs, as the children of MergeBlocks are already well typed. However, when segments come from outside the\n * merge tree, like via client's public methods, it becomes necessary to use the type coercions methods\n * to ensure the passed in segment objects are correctly bound to the merge tree.\n */\nexport type ISegmentLeaf = SegmentWithInfo<IMergeNodeInfo & IInsertionInfo>;\n/**\n * A type-guard which determines if the segment has segment leaf, and\n * returns true if it does, along with applying strong typing.\n * @param nodeLike - The segment-like object to check.\n * @returns True if the segment is a segment leaf, otherwise false.\n */\nexport const isSegmentLeaf = (segmentLike: unknown): segmentLike is ISegmentLeaf =>\n\tisInserted(segmentLike) && isMergeNode(segmentLike);\n\n/**\n * Converts a segment-like object to a segment leaf object if possible.\n *\n * @param segmentLike - The segment-like object to convert.\n * @returns The segment leaf if the conversion is possible, otherwise undefined.\n */\nexport const toSegmentLeaf = (segmentLike: unknown): ISegmentLeaf | undefined =>\n\tisSegmentLeaf(segmentLike) ? segmentLike : undefined;\n/**\n * Asserts that the segment is a segment leaf. Usage of this function should not produce a user facing error.\n *\n * @param segmentLike - The segment-like object to check.\n * @throws Will throw an error if the segment is not a segment leaf.\n */\nexport const assertSegmentLeaf: (segmentLike: unknown) => asserts segmentLike is ISegmentLeaf =\n\t(segmentLike) => assert(isSegmentLeaf(segmentLike), 0xaab /* must be segment leaf */);\n/**\n * This type is used for building MergeBlocks from segments and other MergeBlocks. We need this\n * type as segments may not yet be bound to the tree, so lack merge node info which is required for\n * segment leafs.\n */\nexport type IMergeNodeBuilder = MergeBlock | SegmentWithInfo<IInsertionInfo>;\n\n/**\n * This type is used by MergeBlocks to define their children, which are either segments or other\n * MergeBlocks.\n */\nexport type IMergeNode = MergeBlock | ISegmentLeaf;\n\n/**\n * A segment representing a portion of the merge tree.\n * Segments are leaf nodes of the merge tree and contain data.\n * @legacy\n * @alpha\n */\nexport interface ISegment {\n\treadonly type: string;\n\n\treadonly trackingCollection: TrackingGroupCollection;\n\t/**\n\t * Whether or not this segment is a special segment denoting the start or\n\t * end of the tree\n\t *\n\t * Endpoint segments are imaginary segments positioned immediately before or\n\t * after the tree. These segments cannot be referenced by regular operations\n\t * and exist primarily as a bucket for local references to slide onto during\n\t * deletion of regular segments.\n\t * @deprecated - This property will be removed in 2.20 with no replacement.\n\t */\n\treadonly endpointType?: \"start\" | \"end\";\n\n\t/**\n\t * The length of the contents of the node.\n\t */\n\tcachedLength: number;\n\t/**\n\t * Stores attribution keys associated with offsets of this segment.\n\t * This data is only persisted if MergeTree's `attributions.track` flag is set to true.\n\t * Pending segments (i.e. ones that only exist locally and haven't been acked by the server) also have\n\t * `attribution === undefined` until ack.\n\t *\n\t * Keys can be used opaquely with an IAttributor or a container runtime that provides attribution.\n\t * @remarks There are plans to make the shape of the data stored extensible in a couple ways:\n\t *\n\t * 1. Injection of custom attribution information associated with the segment (ex: copy-paste of\n\t * content but keeping the old attribution information).\n\t *\n\t * 2. Storage of multiple \"channels\" of information (ex: track property changes separately from insertion,\n\t * or only attribute certain property modifications, etc.)\n\t */\n\tattribution?: IAttributionCollection<AttributionKey>;\n\n\t/**\n\t * Local seq at which this segment was inserted.\n\t * This is defined if and only if the insertion of the segment is pending ack, i.e. `seq` is UnassignedSequenceNumber.\n\t * Once the segment is acked, this field is cleared.\n\t *\n\t * @privateRemarks\n\t * See {@link CollaborationWindow.localSeq} for more information on the semantics of localSeq.\n\t * @deprecated - This property will be removed in 2.20 with no replacement.\n\t */\n\tlocalSeq?: number;\n\t/**\n\t * Seq at which this segment was inserted.\n\t * If undefined, it is assumed the segment was inserted prior to the collab window's minimum sequence number.\n\t * @deprecated - This property will be removed in 2.20 with no replacement.\n\t */\n\tseq?: number;\n\t/**\n\t * Short clientId for the client that inserted this segment.\n\t * @deprecated - This property will be removed in 2.20 with no replacement.\n\t */\n\tclientId: number;\n\t/**\n\t * Local references added to this segment.\n\t * @deprecated - This property will be removed in 2.20 with no replacement.\n\t */\n\t// eslint-disable-next-line import/no-deprecated\n\tlocalRefs?: LocalReferenceCollection;\n\t/**\n\t * Properties that have been added to this segment via annotation.\n\t */\n\tproperties?: PropertySet;\n\n\tclone(): ISegment;\n\tcanAppend(segment: ISegment): boolean;\n\tappend(segment: ISegment): void;\n\tsplitAt(pos: number): ISegment | undefined;\n\t// Changing this to something other than any would break consumers.\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\ttoJSONObject(): any;\n\tisLeaf(): this is ISegment;\n\n\t/**\n\t * {@inheritDoc @fluidframework/merge-tree#IMergeNodeCommon.index}\n\t * @deprecated - This property will be removed in 2.20 with no replacement.\n\t */\n\tindex: number;\n\t/**\n\t * {@inheritDoc @fluidframework/merge-tree#IMergeNodeCommon.ordinal}\n\t * @deprecated - This property will be removed in 2.20 with no replacement.\n\t */\n\tordinal: string;\n\n\t/**\n\t * Local seq at which this segment was removed. If this is defined, `removedSeq` will initially be set to\n\t * UnassignedSequenceNumber. However, if another client concurrently removes the same segment, `removedSeq`\n\t * will be updated to the seq at which that client removed this segment.\n\t *\n\t * Like {@link ISegment.localSeq}, this field is cleared once the local removal of the segment is acked.\n\t *\n\t * @privateRemarks\n\t * See {@link CollaborationWindow.localSeq} for more information on the semantics of localSeq.\n\t * @deprecated - This property will be removed in 2.20 with no replacement.\n\t */\n\tlocalRemovedSeq?: number;\n\t/**\n\t * {@inheritDoc @fluidframework/merge-tree#IRemovalInfo.removedSeq}\n\t * @deprecated - This property will be removed in 2.20 with no replacement.\n\t */\n\tremovedSeq?: number;\n\t/**\n\t * {@inheritDoc @fluidframework/merge-tree#IRemovalInfo.removedClientIds}\n\t * @deprecated - This property will be removed in 2.20 with no replacement.\n\t */\n\tremovedClientIds?: number[];\n\t/**\n\t * {@inheritDoc @fluidframework/merge-tree#IMoveInfo.localMovedSeq}\n\t * @deprecated - This property will be removed in 2.20 with no replacement.\n\t */\n\tlocalMovedSeq?: number;\n\t/**\n\t * {@inheritDoc @fluidframework/merge-tree#IMoveInfo.movedSeq}\n\t * @deprecated - This property will be removed in 2.20 with no replacement.\n\t */\n\tmovedSeq?: number;\n\n\t/**\n\t * {@inheritDoc @fluidframework/merge-tree#IMoveInfo.movedSeqs}\n\t * @deprecated - This property will be removed in 2.20 with no replacement.\n\t */\n\tmovedSeqs?: number[];\n\t/**\n\t * {@inheritDoc @fluidframework/merge-tree#IMoveInfo.moveDst}\n\t * @deprecated - This property will be removed in 2.20 with no replacement.\n\t */\n\tmoveDst?: ReferencePosition;\n\t/**\n\t * {@inheritDoc @fluidframework/merge-tree#IMoveInfo.movedClientIds}\n\t * @deprecated - This property will be removed in 2.20 with no replacement.\n\t */\n\tmovedClientIds?: number[];\n\t/**\n\t * {@inheritDoc @fluidframework/merge-tree#IMoveInfo.wasMovedOnInsert}\n\t * @deprecated - This property will be removed in 2.20 with no replacement.\n\t */\n\twasMovedOnInsert?: boolean;\n}\n\n/**\n * Determine if a segment has been removed.\n * @legacy\n * @alpha\n */\nexport function segmentIsRemoved(segment: ISegment): boolean {\n\treturn isRemoved(segment);\n}\n\n/**\n * @legacy\n * @alpha\n */\nexport interface ISegmentAction<TClientData> {\n\t// eslint-disable-next-line @typescript-eslint/prefer-function-type\n\t(\n\t\tsegment: ISegment,\n\t\tpos: number,\n\t\trefSeq: number,\n\t\tclientId: number,\n\t\tstart: number,\n\t\tend: number,\n\t\taccum: TClientData,\n\t): boolean;\n}\nexport interface ISegmentChanges {\n\tnext?: SegmentWithInfo<IInsertionInfo>;\n\treplaceCurrent?: SegmentWithInfo<IInsertionInfo>;\n}\n\nexport interface InsertContext {\n\tcandidateSegment?: SegmentWithInfo<IInsertionInfo>;\n\tleaf: (segment: ISegmentLeaf | undefined, pos: number, ic: InsertContext) => ISegmentChanges;\n\tcontinuePredicate?: (continueFromBlock: MergeBlock) => boolean;\n}\n\nexport interface ObliterateInfo {\n\tstart: LocalReferencePosition;\n\tend: LocalReferencePosition;\n\trefSeq: number;\n\tclientId: number;\n\tseq: number;\n\tlocalSeq: number | undefined;\n\tsegmentGroup: SegmentGroup | undefined;\n}\n\nexport interface SegmentGroup {\n\tsegments: ISegmentLeaf[];\n\tpreviousProps?: PropertySet[];\n\tlocalSeq?: number;\n\trefSeq: number;\n\tobliterateInfo?: ObliterateInfo;\n}\n\n/**\n * Note that the actual branching factor of the MergeTree is `MaxNodesInBlock - 1`. This is because\n * the MergeTree always inserts first, then checks for overflow and splits if the child count equals\n * `MaxNodesInBlock`. (i.e., `MaxNodesInBlock` contains 1 extra slot for temporary storage to\n * facilitate splits.)\n */\nexport const MaxNodesInBlock = 8;\nexport class MergeBlock implements Partial<IMergeNodeInfo> {\n\tpublic children: IMergeNode[];\n\tpublic needsScour?: boolean;\n\tpublic parent?: MergeBlock;\n\tpublic index: number = 0;\n\tpublic ordinal: string = \"\";\n\tpublic cachedLength: number | undefined = 0;\n\n\t/**\n\t * Maps each tile label in this block to the rightmost (i.e. furthest) marker associated with that tile label.\n\t * When combined with the tree structure of MergeBlocks, this allows accelerated queries for nearest tile\n\t * with a certain label before a given position\n\t */\n\tpublic rightmostTiles: Readonly<MapLike<Marker>>;\n\t/**\n\t * Maps each tile label in this block to the leftmost (i.e. nearest) marker associated with that tile label.\n\t * When combined with the tree structure of MergeBlocks, this allows accelerated queries for nearest tile\n\t * with a certain label before a given position\n\t */\n\tpublic leftmostTiles: Readonly<MapLike<Marker>>;\n\n\tisLeaf(): this is ISegmentInternal {\n\t\treturn false;\n\t}\n\n\t/**\n\t * Supports querying the total length of all descendants of this IMergeBlock from the perspective of any\n\t * (clientId, seq) within the collab window.\n\t *\n\t * @remarks This is only optional for implementation reasons (internal nodes can be created/moved without\n\t * immediately initializing the partial lengths). Aside from mid-update on tree operations, these lengths\n\t * objects are always defined.\n\t */\n\tpartialLengths?: PartialSequenceLengths;\n\n\tpublic constructor(public childCount: number) {\n\t\t// Suppression needed due to the way the merge tree children are initalized - we\n\t\t// allocate 8 children blocks, but any unused blocks are not counted in the childCount.\n\t\t// Using Array.from leads to unused children being undefined, which are counted in childCount.\n\t\t// eslint-disable-next-line unicorn/no-new-array\n\t\tthis.children = new Array<IMergeNode>(MaxNodesInBlock);\n\t\tthis.rightmostTiles = createMap<Marker>();\n\t\tthis.leftmostTiles = createMap<Marker>();\n\t}\n\n\tpublic setOrdinal(child: IMergeNode, index: number): void {\n\t\tconst childCount = this.childCount;\n\t\tassert(\n\t\t\tchildCount >= 1 && childCount <= MaxNodesInBlock,\n\t\t\t0x040 /* \"Child count is not within [1,8] range!\" */,\n\t\t);\n\t\tchild.ordinal = computeHierarchicalOrdinal(\n\t\t\tMaxNodesInBlock,\n\t\t\tchildCount,\n\t\t\tthis.ordinal,\n\t\t\tindex === 0 ? undefined : this.children[index - 1]?.ordinal,\n\t\t);\n\t}\n}\nexport function assignChild<C extends IMergeNodeBuilder>(\n\tparent: MergeBlock,\n\tchild: C,\n\tindex: number,\n\tupdateOrdinal = true,\n): asserts child is C & IMergeNodeInfo {\n\tconst node = Object.assign<C, IMergeNodeInfo>(child, {\n\t\tparent,\n\t\tindex,\n\t\tordinal: child.ordinal ?? \"\",\n\t});\n\tif (updateOrdinal) {\n\t\tparent.setOrdinal(node, index);\n\t}\n\tparent.children[index] = node;\n}\n\nexport function seqLTE(seq: number, minOrRefSeq: number): boolean {\n\treturn seq !== UnassignedSequenceNumber && seq <= minOrRefSeq;\n}\n\n/**\n * @legacy\n * @alpha\n */\nexport abstract class BaseSegment implements ISegment {\n\t/**\n\t * @deprecated - This property will be removed in 2.20 with no replacement.\n\t */\n\tpublic clientId: number = LocalClientId;\n\t/**\n\t * @deprecated - This property will be removed in 2.20 with no replacement.\n\t */\n\tpublic seq: number = UniversalSequenceNumber;\n\t/**\n\t * @deprecated - This property will be removed in 2.20 with no replacement.\n\t */\n\tpublic removedSeq?: number;\n\t/**\n\t * @deprecated - This property will be removed in 2.20 with no replacement.\n\t */\n\tpublic removedClientIds?: number[];\n\t/**\n\t * @deprecated - This property will be removed in 2.20 with no replacement.\n\t */\n\tpublic movedSeq?: number;\n\t/**\n\t * @deprecated - This property will be removed in 2.20 with no replacement.\n\t */\n\tpublic movedSeqs?: number[];\n\t/**\n\t * @deprecated - This property will be removed in 2.20 with no replacement.\n\t */\n\tpublic movedClientIds?: number[];\n\t/**\n\t * @deprecated - This property will be removed in 2.20 with no replacement.\n\t */\n\tpublic wasMovedOnInsert?: boolean | undefined;\n\t/**\n\t * @deprecated - This property will be removed in 2.20 with no replacement.\n\t */\n\tpublic index: number = 0;\n\t/**\n\t * @deprecated - This property will be removed in 2.20 with no replacement.\n\t */\n\tpublic ordinal: string = \"\";\n\tpublic cachedLength: number = 0;\n\n\tpublic readonly trackingCollection: TrackingGroupCollection = new TrackingGroupCollection(\n\t\tthis,\n\t);\n\t/***/\n\tpublic attribution?: IAttributionCollection<AttributionKey>;\n\n\tpublic properties?: PropertySet;\n\t/**\n\t * @deprecated - This property will be removed in 2.20 with no replacement.\n\t */\n\t// eslint-disable-next-line import/no-deprecated\n\tpublic localRefs?: LocalReferenceCollection;\n\tpublic abstract readonly type: string;\n\t/**\n\t * @deprecated - This property will be removed in 2.20 with no replacement.\n\t */\n\tpublic localSeq?: number;\n\t/**\n\t * @deprecated - This property will be removed in 2.20 with no replacement.\n\t */\n\tpublic localRemovedSeq?: number;\n\t/**\n\t * @deprecated - This property will be removed in 2.20 with no replacement.\n\t */\n\tpublic localMovedSeq?: number;\n\n\tpublic constructor(properties?: PropertySet) {\n\t\tif (properties !== undefined) {\n\t\t\tthis.properties = clone(properties);\n\t\t}\n\t}\n\n\tpublic hasProperty(key: string): boolean {\n\t\treturn !!this.properties && this.properties[key] !== undefined;\n\t}\n\n\tpublic isLeaf(): this is ISegment {\n\t\treturn true;\n\t}\n\n\tprotected cloneInto(b: ISegment): void {\n\t\tconst seg: ISegmentPrivate = b;\n\t\tif (isInserted(this)) {\n\t\t\toverwriteInfo<IInsertionInfo>(seg, {\n\t\t\t\tclientId: this.clientId,\n\t\t\t\tseq: this.seq,\n\t\t\t});\n\t\t}\n\t\t// TODO: deep clone properties\n\t\tseg.properties = clone(this.properties);\n\t\tif (isRemoved(this)) {\n\t\t\t// eslint-disable-next-line import/no-deprecated\n\t\t\toverwriteInfo<IRemovalInfo>(seg, {\n\t\t\t\tremovedSeq: this.removedSeq,\n\t\t\t\tremovedClientIds: [...this.removedClientIds],\n\t\t\t});\n\t\t}\n\t\tif (isMoved(this)) {\n\t\t\t// eslint-disable-next-line import/no-deprecated\n\t\t\toverwriteInfo<IMoveInfo>(seg, {\n\t\t\t\tmovedSeq: this.movedSeq,\n\t\t\t\tmovedSeqs: [...this.movedSeqs],\n\t\t\t\twasMovedOnInsert: this.wasMovedOnInsert,\n\t\t\t\tmovedClientIds: [...this.movedClientIds],\n\t\t\t});\n\t\t}\n\t\tseg.attribution = this.attribution?.clone();\n\t}\n\n\tpublic canAppend(segment: ISegment): boolean {\n\t\treturn false;\n\t}\n\n\tprotected addSerializedProps(jseg: IJSONSegment): void {\n\t\tif (this.properties) {\n\t\t\tjseg.props = { ...this.properties };\n\t\t}\n\t}\n\t// This has to return any type because the return type is different for different segment types.\n\t// TODO: If possible, change the return type to match what should be returned for each segment type.\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tpublic abstract toJSONObject(): any;\n\n\tpublic splitAt(pos: number): ISegment | undefined {\n\t\tif (pos <= 0) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst leafSegment: ISegmentPrivate | undefined = this.createSplitSegmentAt(pos);\n\n\t\tif (!leafSegment) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tif (isMergeNode(this)) {\n\t\t\toverwriteInfo<IMergeNodeInfo>(leafSegment, {\n\t\t\t\tindex: this.index + 1,\n\t\t\t\t// Give the leaf a temporary yet valid ordinal.\n\t\t\t\t// when this segment is put in the tree, it will get its real ordinal,\n\t\t\t\t// but this ordinal meets all the necessary invariants for now.\n\t\t\t\t// Ordinals exist purely for lexicographical sort order and use a small set of valid bytes for each string character.\n\t\t\t\t// The extra handling fromCodePoint has for things like surrogate pairs is therefore unnecessary.\n\t\t\t\t// eslint-disable-next-line unicorn/prefer-code-point\n\t\t\t\tordinal: this.ordinal + String.fromCharCode(0),\n\t\t\t\tparent: this.parent,\n\t\t\t});\n\t\t}\n\n\t\tif (isInserted(this)) {\n\t\t\toverwriteInfo<IInsertionInfo>(leafSegment, {\n\t\t\t\tseq: this.seq,\n\t\t\t\tlocalSeq: this.localSeq,\n\t\t\t\tclientId: this.clientId,\n\t\t\t});\n\t\t}\n\t\tif (isRemoved(this)) {\n\t\t\t// eslint-disable-next-line import/no-deprecated\n\t\t\toverwriteInfo<IRemovalInfo>(leafSegment, {\n\t\t\t\tremovedClientIds: [...this.removedClientIds],\n\t\t\t\tremovedSeq: this.removedSeq,\n\t\t\t\tlocalRemovedSeq: this.localRemovedSeq,\n\t\t\t});\n\t\t}\n\t\tif (isMoved(this)) {\n\t\t\t// eslint-disable-next-line import/no-deprecated\n\t\t\toverwriteInfo<IMoveInfo>(leafSegment, {\n\t\t\t\tmovedClientIds: [...this.movedClientIds],\n\t\t\t\tmovedSeq: this.movedSeq,\n\t\t\t\tmovedSeqs: [...this.movedSeqs],\n\t\t\t\tlocalMovedSeq: this.localMovedSeq,\n\t\t\t\twasMovedOnInsert: this.wasMovedOnInsert,\n\t\t\t});\n\t\t}\n\n\t\tthis.trackingCollection.copyTo(leafSegment);\n\t\tif (this.attribution) {\n\t\t\tleafSegment.attribution = this.attribution.splitAt(pos);\n\t\t}\n\n\t\treturn leafSegment;\n\t}\n\n\tpublic abstract clone(): ISegment;\n\n\tpublic append(other: ISegment): void {\n\t\t// Note: Must call 'appendLocalRefs' before modifying this segment's length as\n\t\t// 'this.cachedLength' is used to adjust the offsets of the local refs.\n\t\t// eslint-disable-next-line import/no-deprecated\n\t\tLocalReferenceCollection.append(this, other);\n\t\tif (this.attribution) {\n\t\t\tassert(\n\t\t\t\tother.attribution !== undefined,\n\t\t\t\t0x4bd /* attribution should be set on appendee */,\n\t\t\t);\n\t\t\tthis.attribution.append(other.attribution);\n\t\t} else {\n\t\t\tassert(\n\t\t\t\tother.attribution === undefined,\n\t\t\t\t0x4be /* attribution should not be set on appendee */,\n\t\t\t);\n\t\t}\n\n\t\tthis.cachedLength ??= 0;\n\t\tthis.cachedLength += other.cachedLength;\n\t}\n\n\tprotected abstract createSplitSegmentAt(pos: number): BaseSegment | undefined;\n}\n\n/**\n * The special-cased property key that tracks the id of a {@link Marker}.\n *\n * @remarks In general, marker ids should be accessed using the inherent method\n * {@link Marker.getId}. Marker ids should not be updated after creation.\n * @legacy\n * @alpha\n */\nexport const reservedMarkerIdKey = \"markerId\";\n\n/**\n * @internal\n */\nexport const reservedMarkerSimpleTypeKey = \"markerSimpleType\";\n\n/**\n * @legacy\n * @alpha\n */\nexport interface IJSONMarkerSegment extends IJSONSegment {\n\tmarker: IMarkerDef;\n}\n\n/**\n * Markers are a special kind of segment that do not hold any content.\n *\n * Markers with a reference type of {@link ReferenceType.Tile} support spatially\n * accelerated queries for finding the next marker to the left or right of it in\n * sub-linear time. This is useful, for example, in the case of jumping from the\n * start of a paragraph to the end, assuming a paragraph is bound by markers at\n * the start and end.\n *\n * @legacy\n * @alpha\n */\nexport class Marker extends BaseSegment implements ReferencePosition, ISegment {\n\tpublic static readonly type = \"Marker\";\n\tpublic static is(segment: ISegment): segment is Marker {\n\t\treturn segment.type === Marker.type;\n\t}\n\tpublic readonly type = Marker.type;\n\n\tpublic static make(refType: ReferenceType, props?: PropertySet): Marker {\n\t\treturn new Marker(refType, props);\n\t}\n\n\tconstructor(\n\t\tpublic refType: ReferenceType,\n\t\tprops?: PropertySet,\n\t) {\n\t\tsuper(props);\n\t\tthis.cachedLength = 1;\n\t}\n\n\ttoJSONObject(): IJSONMarkerSegment {\n\t\tconst obj: IJSONMarkerSegment = { marker: { refType: this.refType } };\n\t\tsuper.addSerializedProps(obj);\n\t\treturn obj;\n\t}\n\n\tstatic fromJSONObject(spec: IJSONSegment): Marker | undefined {\n\t\tif (spec && typeof spec === \"object\" && \"marker\" in spec) {\n\t\t\treturn Marker.make((spec.marker as Marker).refType, spec.props as PropertySet);\n\t\t}\n\t\treturn undefined;\n\t}\n\n\tclone(): Marker {\n\t\tconst b = Marker.make(this.refType, this.properties);\n\t\tthis.cloneInto(b);\n\t\treturn b;\n\t}\n\n\tgetSegment(): Marker {\n\t\treturn this;\n\t}\n\n\tgetOffset(): number {\n\t\treturn 0;\n\t}\n\n\tgetProperties(): PropertySet | undefined {\n\t\treturn this.properties;\n\t}\n\n\tgetId(): string | undefined {\n\t\treturn this.properties?.[reservedMarkerIdKey] as string;\n\t}\n\n\ttoString(): string {\n\t\treturn `M${this.getId()}`;\n\t}\n\n\tprotected createSplitSegmentAt(pos: number): undefined {\n\t\treturn undefined;\n\t}\n\n\tcanAppend(segment: ISegment): boolean {\n\t\treturn false;\n\t}\n\n\tappend(): void {\n\t\tthrow new Error(\"Can not append to marker\");\n\t}\n}\n\n/**\n * This class is used to track facts about the current window of collaboration. This window is defined by the server\n * specified minimum sequence number to the last sequence number seen. Additionally, it track state for outstanding\n * local operations.\n * @internal\n */\nexport class CollaborationWindow {\n\tclientId = LocalClientId;\n\tcollaborating = false;\n\n\t/**\n\t * Lowest-numbered segment in window; no client can reference a state before this one\n\t */\n\tminSeq = 0;\n\t/**\n\t * Highest-numbered segment in window and current reference sequence number for this client.\n\t */\n\tcurrentSeq = 0;\n\n\t/**\n\t * Highest-numbered localSeq used for a pending segment.\n\t * Semantically, `localSeq`s provide an ordering on in-flight merge-tree operations:\n\t * for operations stamped with localSeqs `a` and `b`, `a < b` if and only if `a` was submitted before `b`.\n\t *\n\t * @remarks - This field is analogous to the `clientSequenceNumber` field on ops, but it's accessible to merge-tree\n\t * at op submission time rather than only at ack time. This enables more natural state tracking for in-flight ops.\n\t *\n\t * It's useful to stamp ops with such an incrementing counter because it enables reasoning about which segments existed from\n\t * the perspective of the local client at a given point in 'un-acked' time, which is necessary to support the reconnect flow.\n\t *\n\t * For example, imagine a client with initial state \"123456\" submits some ops to create the text \"123456ABC\".\n\t * If they insert the \"C\" first, then \"B\", then \"A\", their local segment state might look like this:\n\t * ```js\n\t * [\n\t * { seq: 0, text: \"1234\" },\n\t * { seq: 5, text: \"56\" },\n\t * { localSeq: 3, seq: UnassignedSequenceNumber, text: \"A\" },\n\t * { localSeq: 2, seq: UnassignedSequenceNumber, text: \"B\" },\n\t * { localSeq: 1, seq: UnassignedSequenceNumber, text: \"C\" },\n\t * ]\n\t * ```\n\t * (note that localSeq tracks the localSeq at which a segment was inserted)\n\t *\n\t * Suppose the client then disconnects and reconnects before any of its insertions are acked. The reconnect flow will necessitate\n\t * that the client regenerates and resubmits ops based on its current segment state as well as the original op that was sent.\n\t *\n\t * It will generate the ops\n\t * 1. \\{ pos: 6, text: \"C\" \\}\n\t * 2. \\{ pos: 6, text: \"B\" \\}\n\t * 3. \\{ pos: 6, text: \"A\" \\}\n\t *\n\t * since when submitting the first op, remote clients don't know that this client is about to submit the \"A\" and \"B\".\n\t *\n\t * On the other hand, imagine if the client had originally submitted the ops in the order \"A\", \"B\", \"C\"\n\t * such that the segments' local state was instead:\n\t *\n\t * ```js\n\t * [\n\t * { seq: 0, text: \"1234\" },\n\t * { seq: 5, text: \"56\" },\n\t * { localSeq: 1, seq: UnassignedSequenceNumber, text: \"A\" },\n\t * { localSeq: 2, seq: UnassignedSequenceNumber, text: \"B\" },\n\t * { localSeq: 3, seq: UnassignedSequenceNumber, text: \"C\" },\n\t * ]\n\t * ```\n\t *\n\t * The resubmitted ops should instead be:\n\t * 1. \\{ pos: 6, text: \"A\" \\}\n\t * 2. \\{ pos: 7, text: \"B\" \\}\n\t * 3. \\{ pos: 8, text: \"C\" \\}\n\t *\n\t * since remote clients will have seen the \"A\" when processing the \"B\" as well as both the \"A\" and \"B\" when processing the \"C\".\n\t * As can be seen, the list of resubmitted ops is different in the two cases despite the merge-tree's segment state only differing\n\t * in `localSeq`.\n\t *\n\t * This example is a bit simplified from the general scenario: since no remote clients modified the merge-tree while the client\n\t * was disconnected, the resubmitted ops end up matching the original ops exactly.\n\t * However, this is not generally true: the production reconnect code takes into account visibility of segments based on both acked\n\t * and local information as appropriate.\n\t * Nonetheless, this simple scenario is enough to understand why it's useful to be able to determine if a segment should be visible\n\t * from a given (seq, localSeq) perspective.\n\t */\n\tlocalSeq = 0;\n\n\tloadFrom(a: CollaborationWindow): void {\n\t\tthis.clientId = a.clientId;\n\t\tthis.collaborating = a.collaborating;\n\t\tthis.minSeq = a.minSeq;\n\t\tthis.currentSeq = a.currentSeq;\n\t}\n}\n\n/**\n * Compares two numbers.\n */\nexport const compareNumbers = (a: number, b: number): number => a - b;\n\n/**\n * Compares two strings.\n */\nexport const compareStrings = (a: string, b: string): number => a.localeCompare(b);\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"mergeTreeTracking.d.ts","sourceRoot":"","sources":["../src/mergeTreeTracking.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAC7D,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAI/C;;;GAGG;AACH,MAAM,MAAM,SAAS,GAAG,QAAQ,GAAG,sBAAsB,CAAC;AAE1D;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC9B,OAAO,EAAE,SAAS,SAAS,EAAE,CAAC;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,SAAS,EAAE,SAAS,GAAG,OAAO,CAAC;IACnC,IAAI,CAAC,SAAS,EAAE,SAAS,GAAG,IAAI,CAAC;IACjC,MAAM,CAAC,SAAS,EAAE,SAAS,GAAG,OAAO,CAAC;CACtC;AAED;;;GAGG;AACH,qBAAa,aAAc,YAAW,cAAc;IAEnD,OAAO,CAAC,QAAQ,CAAC,UAAU,CAA8B;;IAOzD,IAAW,OAAO,IAAI,SAAS,SAAS,EAAE,CAEzC;IAED,IAAW,IAAI,IAAI,MAAM,CAExB;IAEM,GAAG,CAAC,SAAS,EAAE,SAAS,GAAG,OAAO;IAIlC,IAAI,CAAC,SAAS,EAAE,SA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AAO,CAAC,kBAAkB,EAAE,uBAAuB,GAAG,OAAO;CAcpE"}
@@ -5,7 +5,6 @@
5
5
  */
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
7
  exports.TrackingGroupCollection = exports.UnorderedTrackingGroup = exports.TrackingGroup = void 0;
8
- // eslint-disable-next-line import/no-deprecated
9
8
  const sortedSegmentSet_js_1 = require("./sortedSegmentSet.js");
10
9
  /**
11
10
  * @legacy
@@ -13,7 +12,6 @@ const sortedSegmentSet_js_1 = require("./sortedSegmentSet.js");
13
12
  */
14
13
  class TrackingGroup {
15
14
  constructor() {
16
- // eslint-disable-next-line import/no-deprecated
17
15
  this.trackedSet = new sortedSegmentSet_js_1.SortedSegmentSet();
18
16
  }
19
17
  get tracked() {
@@ -1 +1 @@
1
- {"version":3,"file":"mergeTreeTracking.js","sourceRoot":"","sources":["../src/mergeTreeTracking.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAIH,gDAAgD;AAChD,+DAAyD;AAoBzD;;;GAGG;AACH,MAAa,aAAa;IAIzB;QACC,gDAAgD;QAChD,IAAI,CAAC,UAAU,GAAG,IAAI,sCAAgB,EAAa,CAAC;IACrD,CAAC;IAED,IAAW,OAAO;QACjB,OAAO,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC;IAC9B,CAAC;IAED,IAAW,IAAI;QACd,OAAO,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC;IAC7B,CAAC;IAEM,GAAG,CAAC,SAAoB;QAC9B,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;IACvC,CAAC;IAEM,IAAI,CAAC,SAAoB;QAC/B,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE,CAAC;YACrC,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC;YACvC,SAAS,CAAC,kBAAkB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACzC,CAAC;I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,IAAI,CAAC,eAAe,CAAC,IAAI,KAAK,kBAAkB,CAAC,eAAe,CAAC,IAAI,EACpE,CAAC;YACF,OAAO,KAAK,CAAC;QACd,CAAC;QACD,KAAK,MAAM,EAAE,IAAI,IAAI,CAAC,eAAe,CAAC,MAAM,EAAE,EAAE,CAAC;YAChD,IAAI,CAAC,kBAAkB,CAAC,eAAe,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC;gBACjD,OAAO,KAAK,CAAC;YACd,CAAC;QACF,CAAC;QACD,OAAO,IAAI,CAAC;IACb,CAAC;CACD;AA9DD,0DA8DC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { LocalReferencePosition } from \"./localReference.js\";\nimport { ISegment } from \"./mergeTreeNodes.js\";\n// eslint-disable-next-line import/no-deprecated\nimport { SortedSegmentSet } from \"./sortedSegmentSet.js\";\n\n/**\n * @legacy\n * @alpha\n */\nexport type Trackable = ISegment | LocalReferencePosition;\n\n/**\n * @legacy\n * @alpha\n */\nexport interface ITrackingGroup {\n\ttracked: readonly Trackable[];\n\tsize: number;\n\thas(trackable: Trackable): boolean;\n\tlink(trackable: Trackable): void;\n\tunlink(trackable: Trackable): boolean;\n}\n\n/**\n * @legacy\n * @alpha\n */\nexport class TrackingGroup implements ITrackingGroup {\n\t// eslint-disable-next-line import/no-deprecated\n\tprivate readonly trackedSet: SortedSegmentSet<Trackable>;\n\n\tconstructor() {\n\t\t// eslint-disable-next-line import/no-deprecated\n\t\tthis.trackedSet = new SortedSegmentSet<Trackable>();\n\t}\n\n\tpublic get tracked(): readonly Trackable[] {\n\t\treturn this.trackedSet.items;\n\t}\n\n\tpublic get size(): number {\n\t\treturn this.trackedSet.size;\n\t}\n\n\tpublic has(trackable: Trackable): boolean {\n\t\treturn this.trackedSet.has(trackable);\n\t}\n\n\tpublic link(trackable: Trackable): void {\n\t\tif (!this.trackedSet.has(trackable)) {\n\t\t\tthis.trackedSet.addOrUpdate(trackable);\n\t\t\ttrackable.trackingCollection.link(this);\n\t\t}\n\t}\n\n\tpublic unlink(trackable: Trackable): boolean {\n\t\tif (this.trackedSet.remove(trackable)) {\n\t\t\ttrackable.trackingCollection.unlink(this);\n\t\t\treturn true;\n\t\t}\n\t\treturn false;\n\t}\n}\n\n/**\n * Tracking group backed by an unordered set. Lookup, insertion, and deletion are O(1)\n */\nexport class UnorderedTrackingGroup implements ITrackingGroup {\n\tprivate readonly trackedSet: Set<Trackable>;\n\n\tconstructor() {\n\t\tthis.trackedSet = new Set<Trackable>();\n\t}\n\n\tpublic get tracked(): readonly Trackable[] {\n\t\treturn [...this.trackedSet];\n\t}\n\n\tpublic get size(): number {\n\t\treturn this.trackedSet.size;\n\t}\n\n\tpublic has(trackable: Trackable): boolean {\n\t\treturn this.trackedSet.has(trackable);\n\t}\n\n\tpublic link(trackable: Trackable): void {\n\t\tif (!this.trackedSet.has(trackable)) {\n\t\t\tthis.trackedSet.add(trackable);\n\t\t\ttrackable.trackingCollection.link(this);\n\t\t}\n\t}\n\n\tpublic unlink(trackable: Trackable): boolean {\n\t\tif (this.trackedSet.delete(trackable)) {\n\t\t\ttrackable.trackingCollection.unlink(this);\n\t\t\treturn true;\n\t\t}\n\t\treturn false;\n\t}\n}\n\n/**\n * A collection of {@link ITrackingGroup}.\n * @legacy\n * @alpha\n */\nexport class TrackingGroupCollection {\n\tprivate readonly _trackingGroups: Set<ITrackingGroup>;\n\n\tpublic get trackingGroups(): Set<TrackingGroup> {\n\t\t// Cast here is necessary to avoid a breaking change to\n\t\t// `TrackingGroupCollection`. Ideally we could just return\n\t\t// `Set<ITrackingGroup>`\n\t\treturn this._trackingGroups as Set<TrackingGroup>;\n\t}\n\n\tconstructor(private readonly trackable: Trackable) {\n\t\tthis._trackingGroups = new Set<ITrackingGroup>();\n\t}\n\n\tpublic link(trackingGroup: ITrackingGroup): void {\n\t\tif (trackingGroup) {\n\t\t\tif (!this._trackingGroups.has(trackingGroup)) {\n\t\t\t\tthis._trackingGroups.add(trackingGroup);\n\t\t\t}\n\n\t\t\tif (!trackingGroup.has(this.trackable)) {\n\t\t\t\ttrackingGroup.link(this.trackable);\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic unlink(trackingGroup: ITrackingGroup): boolean {\n\t\tif (this._trackingGroups.has(trackingGroup)) {\n\t\t\tif (trackingGroup.has(this.trackable)) {\n\t\t\t\ttrackingGroup.unlink(this.trackable);\n\t\t\t}\n\t\t\tthis._trackingGroups.delete(trackingGroup);\n\t\t\treturn true;\n\t\t}\n\n\t\treturn false;\n\t}\n\n\tpublic copyTo(trackable: Trackable): void {\n\t\tfor (const sg of this._trackingGroups) {\n\t\t\ttrackable.trackingCollection.link(sg);\n\t\t}\n\t}\n\n\tpublic get empty(): boolean {\n\t\treturn this._trackingGroups.size === 0;\n\t}\n\n\tpublic matches(trackingCollection: TrackingGroupCollection): boolean {\n\t\tif (\n\t\t\t!trackingCollection ||\n\t\t\tthis._trackingGroups.size !== trackingCollection._trackingGroups.size\n\t\t) {\n\t\t\treturn false;\n\t\t}\n\t\tfor (const tg of this._trackingGroups.values()) {\n\t\t\tif (!trackingCollection._trackingGroups.has(tg)) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\t\treturn true;\n\t}\n}\n"]}
1
+ {"version":3,"file":"mergeTreeTracking.js","sourceRoot":"","sources":["../src/mergeTreeTracking.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAIH,+DAAyD;AAoBzD;;;GAGG;AACH,MAAa,aAAa;IAGzB;QACC,IAAI,CAAC,UAAU,GAAG,IAAI,sCAAgB,EAAa,CAAC;IACrD,CAAC;IAED,IAAW,OAAO;QACjB,OAAO,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC;IAC9B,CAAC;IAED,IAAW,IAAI;QACd,OAAO,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC;IAC7B,CAAC;IAEM,GAAG,CAAC,SAAoB;QAC9B,OAAO,IAAI,CAAC,U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oB;QACjC,KAAK,MAAM,EAAE,IAAI,IAAI,CAAC,eAAe,EAAE,CAAC;YACvC,SAAS,CAAC,kBAAkB,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACvC,CAAC;IACF,CAAC;IAED,IAAW,KAAK;QACf,OAAO,IAAI,CAAC,eAAe,CAAC,IAAI,KAAK,CAAC,CAAC;IACxC,CAAC;IAEM,OAAO,CAAC,kBAA2C;QACzD,IACC,CAAC,kBAAkB;YACnB,IAAI,CAAC,eAAe,CAAC,IAAI,KAAK,kBAAkB,CAAC,eAAe,CAAC,IAAI,EACpE,CAAC;YACF,OAAO,KAAK,CAAC;QACd,CAAC;QACD,KAAK,MAAM,EAAE,IAAI,IAAI,CAAC,eAAe,CAAC,MAAM,EAAE,EAAE,CAAC;YAChD,IAAI,CAAC,kBAAkB,CAAC,eAAe,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC;gBACjD,OAAO,KAAK,CAAC;YACd,CAAC;QACF,CAAC;QACD,OAAO,IAAI,CAAC;IACb,CAAC;CACD;AA9DD,0DA8DC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { LocalReferencePosition } from \"./localReference.js\";\nimport { ISegment } from \"./mergeTreeNodes.js\";\nimport { SortedSegmentSet } from \"./sortedSegmentSet.js\";\n\n/**\n * @legacy\n * @alpha\n */\nexport type Trackable = ISegment | LocalReferencePosition;\n\n/**\n * @legacy\n * @alpha\n */\nexport interface ITrackingGroup {\n\ttracked: readonly Trackable[];\n\tsize: number;\n\thas(trackable: Trackable): boolean;\n\tlink(trackable: Trackable): void;\n\tunlink(trackable: Trackable): boolean;\n}\n\n/**\n * @legacy\n * @alpha\n */\nexport class TrackingGroup implements ITrackingGroup {\n\tprivate readonly trackedSet: SortedSegmentSet<Trackable>;\n\n\tconstructor() {\n\t\tthis.trackedSet = new SortedSegmentSet<Trackable>();\n\t}\n\n\tpublic get tracked(): readonly Trackable[] {\n\t\treturn this.trackedSet.items;\n\t}\n\n\tpublic get size(): number {\n\t\treturn this.trackedSet.size;\n\t}\n\n\tpublic has(trackable: Trackable): boolean {\n\t\treturn this.trackedSet.has(trackable);\n\t}\n\n\tpublic link(trackable: Trackable): void {\n\t\tif (!this.trackedSet.has(trackable)) {\n\t\t\tthis.trackedSet.addOrUpdate(trackable);\n\t\t\ttrackable.trackingCollection.link(this);\n\t\t}\n\t}\n\n\tpublic unlink(trackable: Trackable): boolean {\n\t\tif (this.trackedSet.remove(trackable)) {\n\t\t\ttrackable.trackingCollection.unlink(this);\n\t\t\treturn true;\n\t\t}\n\t\treturn false;\n\t}\n}\n\n/**\n * Tracking group backed by an unordered set. Lookup, insertion, and deletion are O(1)\n */\nexport class UnorderedTrackingGroup implements ITrackingGroup {\n\tprivate readonly trackedSet: Set<Trackable>;\n\n\tconstructor() {\n\t\tthis.trackedSet = new Set<Trackable>();\n\t}\n\n\tpublic get tracked(): readonly Trackable[] {\n\t\treturn [...this.trackedSet];\n\t}\n\n\tpublic get size(): number {\n\t\treturn this.trackedSet.size;\n\t}\n\n\tpublic has(trackable: Trackable): boolean {\n\t\treturn this.trackedSet.has(trackable);\n\t}\n\n\tpublic link(trackable: Trackable): void {\n\t\tif (!this.trackedSet.has(trackable)) {\n\t\t\tthis.trackedSet.add(trackable);\n\t\t\ttrackable.trackingCollection.link(this);\n\t\t}\n\t}\n\n\tpublic unlink(trackable: Trackable): boolean {\n\t\tif (this.trackedSet.delete(trackable)) {\n\t\t\ttrackable.trackingCollection.unlink(this);\n\t\t\treturn true;\n\t\t}\n\t\treturn false;\n\t}\n}\n\n/**\n * A collection of {@link ITrackingGroup}.\n * @legacy\n * @alpha\n */\nexport class TrackingGroupCollection {\n\tprivate readonly _trackingGroups: Set<ITrackingGroup>;\n\n\tpublic get trackingGroups(): Set<TrackingGroup> {\n\t\t// Cast here is necessary to avoid a breaking change to\n\t\t// `TrackingGroupCollection`. Ideally we could just return\n\t\t// `Set<ITrackingGroup>`\n\t\treturn this._trackingGroups as Set<TrackingGroup>;\n\t}\n\n\tconstructor(private readonly trackable: Trackable) {\n\t\tthis._trackingGroups = new Set<ITrackingGroup>();\n\t}\n\n\tpublic link(trackingGroup: ITrackingGroup): void {\n\t\tif (trackingGroup) {\n\t\t\tif (!this._trackingGroups.has(trackingGroup)) {\n\t\t\t\tthis._trackingGroups.add(trackingGroup);\n\t\t\t}\n\n\t\t\tif (!trackingGroup.has(this.trackable)) {\n\t\t\t\ttrackingGroup.link(this.trackable);\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic unlink(trackingGroup: ITrackingGroup): boolean {\n\t\tif (this._trackingGroups.has(trackingGroup)) {\n\t\t\tif (trackingGroup.has(this.trackable)) {\n\t\t\t\ttrackingGroup.unlink(this.trackable);\n\t\t\t}\n\t\t\tthis._trackingGroups.delete(trackingGroup);\n\t\t\treturn true;\n\t\t}\n\n\t\treturn false;\n\t}\n\n\tpublic copyTo(trackable: Trackable): void {\n\t\tfor (const sg of this._trackingGroups) {\n\t\t\ttrackable.trackingCollection.link(sg);\n\t\t}\n\t}\n\n\tpublic get empty(): boolean {\n\t\treturn this._trackingGroups.size === 0;\n\t}\n\n\tpublic matches(trackingCollection: TrackingGroupCollection): boolean {\n\t\tif (\n\t\t\t!trackingCollection ||\n\t\t\tthis._trackingGroups.size !== trackingCollection._trackingGroups.size\n\t\t) {\n\t\t\treturn false;\n\t\t}\n\t\tfor (const tg of this._trackingGroups.values()) {\n\t\t\tif (!trackingCollection._trackingGroups.has(tg)) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\t\treturn true;\n\t}\n}\n"]}
@@ -4,7 +4,7 @@
4
4
  */
5
5
  import { RedBlackTree } from "./collections/index.js";
6
6
  import { MergeTree } from "./mergeTree.js";
7
- import { CollaborationWindow, ISegmentLeaf, type MergeBlock } from "./mergeTreeNodes.js";
7
+ import { CollaborationWindow, ISegmentPrivate, type MergeBlock } from "./mergeTreeNodes.js";
8
8
  interface IOverlapClient {
9
9
  clientId: number;
10
10
  seglen: number;
@@ -155,7 +155,7 @@ export declare class PartialSequenceLengths {
155
155
  * @param firstGte - Existing partial length entry
156
156
  * @param clientIds - Ids of clients that concurrently obliterated this segment
157
157
  */
158
- static accumulateMoveOverlapForExisting(segmentLen: number, segment: ISegmentLeaf, firstGte: PartialSequenceLength, clientIds: number[]): void;
158
+ static accumulateMoveOverlapForExisting(segmentLen: number, segment: ISegmentPrivate, firstGte: PartialSequenceLength, clientIds: number[]): void;
159
159
  /**
160
160
  * Tracks which clients have made concurrent obliterates.
161
161
  *
@@ -1 +1 @@
1
- {"version":3,"file":"partialLengths.d.ts","sourceRoot":"","sources":["../src/partialLengths.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAY,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAEhE,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAEN,mBAAmB,EAMnB,YAAY,EAKZ,KAAK,UAAU,EACf,MAAM,qBAAqB,CAAC;AAyF7B,UAAU,cAAc;IACvB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;CACf;AAED;;;GAGG;AACH,MAAM,WAAW,qBAAqB;IACrC;;OAEG;IACH,GAAG,EAAE,MAAM,CAAC;IACZ;;OAEG;IACH,GAAG,EAAE,MAAM,CAAC;IACZ;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;OAGG;IACH,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B;;;;;;;;;;;;;;;;;;;;;;;;;OAyBG;IACH,oBAAoB,CAAC,EAAE,YAAY,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;IAC5D;;;OAGG;IACH,wBAAwB,CAAC,EAAE,YAAY,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;CAChE;AAuCD,MAAM,WAAW,6BAA6B;I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