@fluidframework/merge-tree 2.30.0 → 2.31.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 (308) hide show
  1. package/CHANGELOG.md +403 -399
  2. package/api-report/merge-tree.legacy.alpha.api.md +1 -0
  3. package/dist/MergeTreeTextHelper.d.ts +9 -3
  4. package/dist/MergeTreeTextHelper.d.ts.map +1 -1
  5. package/dist/MergeTreeTextHelper.js +5 -5
  6. package/dist/MergeTreeTextHelper.js.map +1 -1
  7. package/dist/client.d.ts +7 -13
  8. package/dist/client.d.ts.map +1 -1
  9. package/dist/client.js +136 -110
  10. package/dist/client.js.map +1 -1
  11. package/dist/endOfTreeSegment.d.ts +12 -8
  12. package/dist/endOfTreeSegment.d.ts.map +1 -1
  13. package/dist/endOfTreeSegment.js +2 -4
  14. package/dist/endOfTreeSegment.js.map +1 -1
  15. package/dist/index.d.ts +6 -3
  16. package/dist/index.d.ts.map +1 -1
  17. package/dist/index.js +2 -3
  18. package/dist/index.js.map +1 -1
  19. package/dist/mergeTree.d.ts +37 -23
  20. package/dist/mergeTree.d.ts.map +1 -1
  21. package/dist/mergeTree.js +400 -483
  22. package/dist/mergeTree.js.map +1 -1
  23. package/dist/mergeTreeDeltaCallback.d.ts +4 -8
  24. package/dist/mergeTreeDeltaCallback.d.ts.map +1 -1
  25. package/dist/mergeTreeDeltaCallback.js.map +1 -1
  26. package/dist/mergeTreeNodes.d.ts +32 -10
  27. package/dist/mergeTreeNodes.d.ts.map +1 -1
  28. package/dist/mergeTreeNodes.js +43 -28
  29. package/dist/mergeTreeNodes.js.map +1 -1
  30. package/dist/partialLengths.d.ts +2 -2
  31. package/dist/partialLengths.d.ts.map +1 -1
  32. package/dist/partialLengths.js +181 -109
  33. package/dist/partialLengths.js.map +1 -1
  34. package/dist/perspective.d.ts +8 -27
  35. package/dist/perspective.d.ts.map +1 -1
  36. package/dist/perspective.js +7 -67
  37. package/dist/perspective.js.map +1 -1
  38. package/dist/revertibles.d.ts.map +1 -1
  39. package/dist/revertibles.js +2 -2
  40. package/dist/revertibles.js.map +1 -1
  41. package/dist/segmentInfos.d.ts +20 -106
  42. package/dist/segmentInfos.d.ts.map +1 -1
  43. package/dist/segmentInfos.js +28 -42
  44. package/dist/segmentInfos.js.map +1 -1
  45. package/dist/segmentPropertiesManager.d.ts +1 -14
  46. package/dist/segmentPropertiesManager.d.ts.map +1 -1
  47. package/dist/segmentPropertiesManager.js +3 -17
  48. package/dist/segmentPropertiesManager.js.map +1 -1
  49. package/dist/snapshotLoader.d.ts.map +1 -1
  50. package/dist/snapshotLoader.js +62 -19
  51. package/dist/snapshotLoader.js.map +1 -1
  52. package/dist/snapshotV1.d.ts.map +1 -1
  53. package/dist/snapshotV1.js +55 -24
  54. package/dist/snapshotV1.js.map +1 -1
  55. package/dist/snapshotlegacy.d.ts.map +1 -1
  56. package/dist/snapshotlegacy.js +6 -9
  57. package/dist/snapshotlegacy.js.map +1 -1
  58. package/dist/stamps.d.ts +1 -1
  59. package/dist/stamps.js +1 -1
  60. package/dist/stamps.js.map +1 -1
  61. package/dist/test/Insertion.perf.spec.js +6 -51
  62. package/dist/test/Insertion.perf.spec.js.map +1 -1
  63. package/dist/test/PartialLengths.perf.spec.js +18 -25
  64. package/dist/test/PartialLengths.perf.spec.js.map +1 -1
  65. package/dist/test/Removal.perf.spec.js +13 -41
  66. package/dist/test/Removal.perf.spec.js.map +1 -1
  67. package/dist/test/beastTest.spec.d.ts.map +1 -1
  68. package/dist/test/beastTest.spec.js +41 -66
  69. package/dist/test/beastTest.spec.js.map +1 -1
  70. package/dist/test/client.annotateMarker.spec.js +1 -11
  71. package/dist/test/client.annotateMarker.spec.js.map +1 -1
  72. package/dist/test/client.applyMsg.spec.js +14 -14
  73. package/dist/test/client.applyMsg.spec.js.map +1 -1
  74. package/dist/test/client.getPosition.spec.js +1 -1
  75. package/dist/test/client.getPosition.spec.js.map +1 -1
  76. package/dist/test/client.localReference.spec.js +1 -1
  77. package/dist/test/client.localReference.spec.js.map +1 -1
  78. package/dist/test/client.rollback.spec.js +49 -58
  79. package/dist/test/client.rollback.spec.js.map +1 -1
  80. package/dist/test/client.rollbackFarm.spec.js +1 -1
  81. package/dist/test/client.rollbackFarm.spec.js.map +1 -1
  82. package/dist/test/client.searchForMarker.spec.js +4 -21
  83. package/dist/test/client.searchForMarker.spec.js.map +1 -1
  84. package/dist/test/index.d.ts +2 -2
  85. package/dist/test/index.d.ts.map +1 -1
  86. package/dist/test/index.js +2 -6
  87. package/dist/test/index.js.map +1 -1
  88. package/dist/test/mergeTree.annotate.deltaCallback.spec.js +14 -59
  89. package/dist/test/mergeTree.annotate.deltaCallback.spec.js.map +1 -1
  90. package/dist/test/mergeTree.annotate.spec.js +47 -63
  91. package/dist/test/mergeTree.annotate.spec.js.map +1 -1
  92. package/dist/test/mergeTree.insert.deltaCallback.spec.js +9 -62
  93. package/dist/test/mergeTree.insert.deltaCallback.spec.js.map +1 -1
  94. package/dist/test/mergeTree.insertingWalk.spec.js +59 -125
  95. package/dist/test/mergeTree.insertingWalk.spec.js.map +1 -1
  96. package/dist/test/mergeTree.markRangeRemoved.deltaCallback.spec.js +12 -93
  97. package/dist/test/mergeTree.markRangeRemoved.deltaCallback.spec.js.map +1 -1
  98. package/dist/test/mergeTree.markRangeRemoved.spec.js +10 -7
  99. package/dist/test/mergeTree.markRangeRemoved.spec.js.map +1 -1
  100. package/dist/test/mergeTree.walk.spec.js +2 -14
  101. package/dist/test/mergeTree.walk.spec.js.map +1 -1
  102. package/dist/test/mergeTreeOperationRunner.js +2 -2
  103. package/dist/test/mergeTreeOperationRunner.js.map +1 -1
  104. package/dist/test/obliterate.concurrent.spec.js +18 -23
  105. package/dist/test/obliterate.concurrent.spec.js.map +1 -1
  106. package/dist/test/obliterate.partialLength.spec.js +166 -136
  107. package/dist/test/obliterate.partialLength.spec.js.map +1 -1
  108. package/dist/test/obliterate.spec.js +16 -126
  109. package/dist/test/obliterate.spec.js.map +1 -1
  110. package/dist/test/partialLength.spec.js +28 -196
  111. package/dist/test/partialLength.spec.js.map +1 -1
  112. package/dist/test/perspective.spec.js +34 -0
  113. package/dist/test/perspective.spec.js.map +1 -1
  114. package/dist/test/propertyManager.spec.js +1 -1
  115. package/dist/test/propertyManager.spec.js.map +1 -1
  116. package/dist/test/resetPendingSegmentsToOp.spec.js +0 -2
  117. package/dist/test/resetPendingSegmentsToOp.spec.js.map +1 -1
  118. package/dist/test/segmentGroupCollection.spec.js +10 -4
  119. package/dist/test/segmentGroupCollection.spec.js.map +1 -1
  120. package/dist/test/testClient.d.ts +1 -0
  121. package/dist/test/testClient.d.ts.map +1 -1
  122. package/dist/test/testClient.js +16 -26
  123. package/dist/test/testClient.js.map +1 -1
  124. package/dist/test/testClientLogger.d.ts.map +1 -1
  125. package/dist/test/testClientLogger.js +3 -10
  126. package/dist/test/testClientLogger.js.map +1 -1
  127. package/dist/test/testServer.d.ts +2 -1
  128. package/dist/test/testServer.d.ts.map +1 -1
  129. package/dist/test/testServer.js +7 -5
  130. package/dist/test/testServer.js.map +1 -1
  131. package/dist/test/testUtils.d.ts +36 -56
  132. package/dist/test/testUtils.d.ts.map +1 -1
  133. package/dist/test/testUtils.js +68 -77
  134. package/dist/test/testUtils.js.map +1 -1
  135. package/dist/test/text.d.ts +2 -2
  136. package/dist/test/text.d.ts.map +1 -1
  137. package/dist/test/text.js +5 -2
  138. package/dist/test/text.js.map +1 -1
  139. package/dist/textSegment.d.ts +0 -6
  140. package/dist/textSegment.d.ts.map +1 -1
  141. package/dist/textSegment.js.map +1 -1
  142. package/dist/zamboni.d.ts.map +1 -1
  143. package/dist/zamboni.js +53 -26
  144. package/dist/zamboni.js.map +1 -1
  145. package/lib/MergeTreeTextHelper.d.ts +9 -3
  146. package/lib/MergeTreeTextHelper.d.ts.map +1 -1
  147. package/lib/MergeTreeTextHelper.js +5 -5
  148. package/lib/MergeTreeTextHelper.js.map +1 -1
  149. package/lib/client.d.ts +7 -13
  150. package/lib/client.d.ts.map +1 -1
  151. package/lib/client.js +117 -116
  152. package/lib/client.js.map +1 -1
  153. package/lib/endOfTreeSegment.d.ts +12 -8
  154. package/lib/endOfTreeSegment.d.ts.map +1 -1
  155. package/lib/endOfTreeSegment.js +2 -4
  156. package/lib/endOfTreeSegment.js.map +1 -1
  157. package/lib/index.d.ts +6 -3
  158. package/lib/index.d.ts.map +1 -1
  159. package/lib/index.js +1 -1
  160. package/lib/index.js.map +1 -1
  161. package/lib/mergeTree.d.ts +37 -23
  162. package/lib/mergeTree.d.ts.map +1 -1
  163. package/lib/mergeTree.js +381 -488
  164. package/lib/mergeTree.js.map +1 -1
  165. package/lib/mergeTreeDeltaCallback.d.ts +4 -8
  166. package/lib/mergeTreeDeltaCallback.d.ts.map +1 -1
  167. package/lib/mergeTreeDeltaCallback.js.map +1 -1
  168. package/lib/mergeTreeNodes.d.ts +32 -10
  169. package/lib/mergeTreeNodes.d.ts.map +1 -1
  170. package/lib/mergeTreeNodes.js +42 -29
  171. package/lib/mergeTreeNodes.js.map +1 -1
  172. package/lib/partialLengths.d.ts +2 -2
  173. package/lib/partialLengths.d.ts.map +1 -1
  174. package/lib/partialLengths.js +160 -111
  175. package/lib/partialLengths.js.map +1 -1
  176. package/lib/perspective.d.ts +8 -27
  177. package/lib/perspective.d.ts.map +1 -1
  178. package/lib/perspective.js +8 -68
  179. package/lib/perspective.js.map +1 -1
  180. package/lib/revertibles.d.ts.map +1 -1
  181. package/lib/revertibles.js +2 -2
  182. package/lib/revertibles.js.map +1 -1
  183. package/lib/segmentInfos.d.ts +20 -106
  184. package/lib/segmentInfos.d.ts.map +1 -1
  185. package/lib/segmentInfos.js +26 -37
  186. package/lib/segmentInfos.js.map +1 -1
  187. package/lib/segmentPropertiesManager.d.ts +1 -14
  188. package/lib/segmentPropertiesManager.d.ts.map +1 -1
  189. package/lib/segmentPropertiesManager.js +2 -16
  190. package/lib/segmentPropertiesManager.js.map +1 -1
  191. package/lib/snapshotLoader.d.ts.map +1 -1
  192. package/lib/snapshotLoader.js +39 -19
  193. package/lib/snapshotLoader.js.map +1 -1
  194. package/lib/snapshotV1.d.ts.map +1 -1
  195. package/lib/snapshotV1.js +34 -26
  196. package/lib/snapshotV1.js.map +1 -1
  197. package/lib/snapshotlegacy.d.ts.map +1 -1
  198. package/lib/snapshotlegacy.js +7 -10
  199. package/lib/snapshotlegacy.js.map +1 -1
  200. package/lib/stamps.d.ts +1 -1
  201. package/lib/stamps.js +1 -1
  202. package/lib/stamps.js.map +1 -1
  203. package/lib/test/Insertion.perf.spec.js +6 -51
  204. package/lib/test/Insertion.perf.spec.js.map +1 -1
  205. package/lib/test/PartialLengths.perf.spec.js +18 -25
  206. package/lib/test/PartialLengths.perf.spec.js.map +1 -1
  207. package/lib/test/Removal.perf.spec.js +13 -41
  208. package/lib/test/Removal.perf.spec.js.map +1 -1
  209. package/lib/test/beastTest.spec.d.ts.map +1 -1
  210. package/lib/test/beastTest.spec.js +42 -67
  211. package/lib/test/beastTest.spec.js.map +1 -1
  212. package/lib/test/client.annotateMarker.spec.js +1 -11
  213. package/lib/test/client.annotateMarker.spec.js.map +1 -1
  214. package/lib/test/client.applyMsg.spec.js +14 -14
  215. package/lib/test/client.applyMsg.spec.js.map +1 -1
  216. package/lib/test/client.getPosition.spec.js +1 -1
  217. package/lib/test/client.getPosition.spec.js.map +1 -1
  218. package/lib/test/client.localReference.spec.js +1 -1
  219. package/lib/test/client.localReference.spec.js.map +1 -1
  220. package/lib/test/client.rollback.spec.js +50 -59
  221. package/lib/test/client.rollback.spec.js.map +1 -1
  222. package/lib/test/client.rollbackFarm.spec.js +1 -1
  223. package/lib/test/client.rollbackFarm.spec.js.map +1 -1
  224. package/lib/test/client.searchForMarker.spec.js +4 -21
  225. package/lib/test/client.searchForMarker.spec.js.map +1 -1
  226. package/lib/test/index.d.ts +2 -2
  227. package/lib/test/index.d.ts.map +1 -1
  228. package/lib/test/index.js +1 -1
  229. package/lib/test/index.js.map +1 -1
  230. package/lib/test/mergeTree.annotate.deltaCallback.spec.js +15 -60
  231. package/lib/test/mergeTree.annotate.deltaCallback.spec.js.map +1 -1
  232. package/lib/test/mergeTree.annotate.spec.js +48 -64
  233. package/lib/test/mergeTree.annotate.spec.js.map +1 -1
  234. package/lib/test/mergeTree.insert.deltaCallback.spec.js +10 -63
  235. package/lib/test/mergeTree.insert.deltaCallback.spec.js.map +1 -1
  236. package/lib/test/mergeTree.insertingWalk.spec.js +61 -127
  237. package/lib/test/mergeTree.insertingWalk.spec.js.map +1 -1
  238. package/lib/test/mergeTree.markRangeRemoved.deltaCallback.spec.js +13 -94
  239. package/lib/test/mergeTree.markRangeRemoved.deltaCallback.spec.js.map +1 -1
  240. package/lib/test/mergeTree.markRangeRemoved.spec.js +10 -7
  241. package/lib/test/mergeTree.markRangeRemoved.spec.js.map +1 -1
  242. package/lib/test/mergeTree.walk.spec.js +2 -14
  243. package/lib/test/mergeTree.walk.spec.js.map +1 -1
  244. package/lib/test/mergeTreeOperationRunner.js +3 -3
  245. package/lib/test/mergeTreeOperationRunner.js.map +1 -1
  246. package/lib/test/obliterate.concurrent.spec.js +18 -23
  247. package/lib/test/obliterate.concurrent.spec.js.map +1 -1
  248. package/lib/test/obliterate.partialLength.spec.js +167 -137
  249. package/lib/test/obliterate.partialLength.spec.js.map +1 -1
  250. package/lib/test/obliterate.spec.js +17 -127
  251. package/lib/test/obliterate.spec.js.map +1 -1
  252. package/lib/test/partialLength.spec.js +29 -197
  253. package/lib/test/partialLength.spec.js.map +1 -1
  254. package/lib/test/perspective.spec.js +34 -0
  255. package/lib/test/perspective.spec.js.map +1 -1
  256. package/lib/test/propertyManager.spec.js +2 -2
  257. package/lib/test/propertyManager.spec.js.map +1 -1
  258. package/lib/test/resetPendingSegmentsToOp.spec.js +0 -2
  259. package/lib/test/resetPendingSegmentsToOp.spec.js.map +1 -1
  260. package/lib/test/segmentGroupCollection.spec.js +10 -4
  261. package/lib/test/segmentGroupCollection.spec.js.map +1 -1
  262. package/lib/test/testClient.d.ts +1 -0
  263. package/lib/test/testClient.d.ts.map +1 -1
  264. package/lib/test/testClient.js +18 -28
  265. package/lib/test/testClient.js.map +1 -1
  266. package/lib/test/testClientLogger.d.ts.map +1 -1
  267. package/lib/test/testClientLogger.js +3 -10
  268. package/lib/test/testClientLogger.js.map +1 -1
  269. package/lib/test/testServer.d.ts +2 -1
  270. package/lib/test/testServer.d.ts.map +1 -1
  271. package/lib/test/testServer.js +7 -5
  272. package/lib/test/testServer.js.map +1 -1
  273. package/lib/test/testUtils.d.ts +36 -56
  274. package/lib/test/testUtils.d.ts.map +1 -1
  275. package/lib/test/testUtils.js +66 -48
  276. package/lib/test/testUtils.js.map +1 -1
  277. package/lib/test/text.d.ts +2 -2
  278. package/lib/test/text.d.ts.map +1 -1
  279. package/lib/test/text.js +6 -3
  280. package/lib/test/text.js.map +1 -1
  281. package/lib/textSegment.d.ts +0 -6
  282. package/lib/textSegment.d.ts.map +1 -1
  283. package/lib/textSegment.js.map +1 -1
  284. package/lib/tsdoc-metadata.json +1 -1
  285. package/lib/zamboni.d.ts.map +1 -1
  286. package/lib/zamboni.js +32 -28
  287. package/lib/zamboni.js.map +1 -1
  288. package/package.json +17 -20
  289. package/src/MergeTreeTextHelper.ts +17 -12
  290. package/src/client.ts +141 -197
  291. package/src/endOfTreeSegment.ts +11 -8
  292. package/src/index.ts +4 -3
  293. package/src/mergeTree.ts +482 -633
  294. package/src/mergeTreeDeltaCallback.ts +4 -8
  295. package/src/mergeTreeNodes.ts +66 -45
  296. package/src/partialLengths.ts +181 -137
  297. package/src/perspective.ts +17 -95
  298. package/src/revertibles.ts +2 -7
  299. package/src/segmentInfos.ts +48 -141
  300. package/src/segmentPropertiesManager.ts +2 -16
  301. package/src/snapshotLoader.ts +62 -30
  302. package/src/snapshotV1.ts +36 -28
  303. package/src/snapshotlegacy.ts +7 -16
  304. package/src/stamps.ts +1 -1
  305. package/src/textSegment.ts +0 -13
  306. package/src/zamboni.ts +38 -32
  307. package/tsconfig.json +1 -0
  308. package/prettier.config.cjs +0 -8
@@ -117,14 +117,10 @@ export interface IMergeTreeDeltaOpArgs {
117
117
  * This field is omitted for deltas corresponding to unacknowledged changes.
118
118
  */
119
119
  readonly sequencedMessage?: ISequencedDocumentMessage;
120
- }
121
- /**
122
- * @internal
123
- */
124
- export interface IMergeTreeClientSequenceArgs {
125
- readonly clientId: number;
126
- readonly referenceSequenceNumber: number;
127
- readonly sequenceNumber: number;
120
+ /**
121
+ * Set to true if this delta is being performed as part of a rollback of unsent local changes.
122
+ */
123
+ readonly rollback?: true;
128
124
  }
129
125
  /**
130
126
  * @internal
@@ -1 +1 @@
1
- {"version":3,"file":"mergeTreeDeltaCallback.d.ts","sourceRoot":"","sources":["../src/mergeTreeDeltaCallback.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,yBAAyB,EAAE,MAAM,6CAA6C,CAAC;AAExF,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAE/C,OAAO,EAAE,kBAAkB,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAChF,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAE9C;;;GAGG;AACH,MAAM,MAAM,2BAA2B,GACpC,OAAO,kBAAkB,CAAC,QAAQ,GAClC,OAAO,kBAAkB,CAAC,MAAM,GAChC,OAAO,kBAAkB,CAAC,MAAM,GAChC,OAAO,kBAAkB,CAAC,UAAU,CAAC;AAExC;;;;;;;GAOG;AACH,eAAO,MAAM,wBAAwB;IACpC;;;;;;OAMG;;IAEH;;;OAGG;;IAEH;;;;;OAKG;;IAEH;;;OAGG;;CAEM,CAAC;AACX;;;GAGG;AACH,MAAM,MAAM,wBAAwB,GACnC,CAAC,OAAO,wBAAwB,CAAC,CAAC,MAAM,OAAO,wBAAwB,CAAC,CAAC;AAE1E;;;GAGG;AACH,MAAM,MAAM,4BAA4B,GACrC,2BAA2B,GAC3B,wBAAwB,CAAC;AAE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E1B;;;;OAIG;IACH,QAAQ,CAAC,gBAAgB,CAAC,EAAE,yBAAyB,CAAC;IAEtD;;OAEG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,IAAI,CAAC;CACzB;AAED;;GAEG;AACH,MAAM,MAAM,sBAAsB,GAAG,CACpC,MAAM,EAAE,qBAAqB,EAC7B,SAAS,EAAE,2BAA2B,KAClC,IAAI,CAAC;AAEV;;;GAGG;AAEH,MAAM,WAAW,iCAChB,SAAQ,2BAA2B,CAAC,wBAAwB,CAAC;CAAG;AAEjE;;GAEG;AACH,MAAM,MAAM,4BAA4B,GAAG,CAC1C,eAAe,EAAE,iCAAiC,EAClD,MAAM,EAAE,qBAAqB,GAAG,SAAS,KACrC,IAAI,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"mergeTreeDeltaCallback.js","sourceRoot":"","sources":["../src/mergeTreeDeltaCallback.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAmBH;;;;;;;GAOG;AACU,QAAA,wBAAwB,GAAG;IACvC;;;;;;OAMG;IACH,MAAM,EAAE,CAAC,CAAC;IACV;;;OAGG;IACH,KAAK,EAAE,CAAC,CAAC;IACT;;;;;OAKG;IACH,MAAM,EAAE,CAAC,CAAC;IACV;;;OAGG;IACH,YAAY,EAAE,CAAC,CAAC;CACP,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ISequencedDocumentMessage } from \"@fluidframework/driver-definitions/internal\";\n\nimport { ISegment } from \"./mergeTreeNodes.js\";\n// eslint-disable-next-line import/no-deprecated\nimport { IMergeTreeGroupMsg, IMergeTreeOp, MergeTreeDeltaType } from \"./ops.js\";\nimport { PropertySet } from \"./properties.js\";\n\n/**\n * @legacy\n * @alpha\n */\nexport type MergeTreeDeltaOperationType =\n\t| typeof MergeTreeDeltaType.ANNOTATE\n\t| typeof MergeTreeDeltaType.INSERT\n\t| typeof MergeTreeDeltaType.REMOVE\n\t| typeof MergeTreeDeltaType.OBLITERATE;\n\n/**\n * Enum-like constant defining the types of \"maintenance\" events on a merge tree.\n * Maintenance events correspond to structural segment changes or acks of pending segments.\n *\n * Note: these values are assigned negative integers to avoid clashing with `MergeTreeDeltaType`.\n * @legacy\n * @alpha\n */\nexport const MergeTreeMaintenanceType = {\n\t/**\n\t * Notification that a segment \"append\" has occurred, i.e. two adjacent segments have been merged.\n\t * BEWARE: `deltaSegments` on the corresponding event will contain both the merged segment and the latter\n\t * segment, pre-merge.\n\t * For example, if the merge tree originally had two adjacent segments [A][B] and called A.append(B) to get\n\t * segment [AB], `deltaSegments` would contain [AB] and [B].\n\t */\n\tAPPEND: -1,\n\t/**\n\t * Notification that a segment has been split in two.\n\t * `deltaSegments` on the corresponding event will contain the resulting two segments.\n\t */\n\tSPLIT: -2,\n\t/**\n\t * Notification that a segment has been unlinked (i.e. removed) from the MergeTree.\n\t * This occurs on leaf segments during Zamboni when the segment's tracking collection is empty\n\t * (e.g., not being tracked for undo/redo).\n\t * It also occurs on internal merge tree segments when re-packing children to maintain tree balancing invariants.\n\t */\n\tUNLINK: -3,\n\t/**\n\t * Notification that a local change has been acknowledged by the server.\n\t * This means that it has made the round trip to the server and has had a sequence number assigned.\n\t */\n\tACKNOWLEDGED: -4,\n} as const;\n/**\n * @legacy\n * @alpha\n */\nexport type MergeTreeMaintenanceType =\n\t(typeof MergeTreeMaintenanceType)[keyof typeof MergeTreeMaintenanceType];\n\n/**\n * @legacy\n * @alpha\n */\nexport type MergeTreeDeltaOperationTypes =\n\t| MergeTreeDeltaOperationType\n\t| MergeTreeMaintenanceType;\n\n/**\n * @legacy\n * @alpha\n */\nexport interface IMergeTreeDeltaCallbackArgs<\n\tTOperationType extends MergeTreeDeltaOperationTypes = MergeTreeDeltaOperationType,\n> {\n\t/**\n\t * The type of operation that affected segments in the merge-tree.\n\t * The affected segments can be accessed via {@link IMergeTreeDeltaCallbackArgs.deltaSegments|deltaSegments}.\n\t *\n\t * See {@link MergeTreeDeltaOperationType} and {@link (MergeTreeMaintenanceType:type)} for possible values.\n\t */\n\treadonly operation: TOperationType;\n\n\t/**\n\t * A list of deltas describing actions taken on segments.\n\t *\n\t * Deltas are not guaranteed to be in any particular order.\n\t */\n\treadonly deltaSegments: IMergeTreeSegmentDelta[];\n}\n\n/**\n * @legacy\n * @alpha\n */\nexport interface IMergeTreeSegmentDelta {\n\t/**\n\t * The segment this delta affected.\n\t */\n\tsegment: ISegment;\n\n\t/**\n\t * A property set containing changes to properties on this segment.\n\t *\n\t * @remarks - Deleting a property is represented using `null` as the value.\n\t * @example\n\t *\n\t * An annotation change which deleted the property \"foo\" and set \"bar\" to 5 would be represented as:\n\t * `{ foo: null, bar: 5 }`.\n\t */\n\tpropertyDeltas?: PropertySet;\n}\n\n/**\n * @legacy\n * @alpha\n */\nexport interface IMergeTreeDeltaOpArgs {\n\t/**\n\t * The group op which contains the operation\n\t * if there operation is part of a group op.\n\t */\n\t// eslint-disable-next-line import/no-deprecated\n\treadonly groupOp?: IMergeTreeGroupMsg;\n\n\t/**\n\t * The {@link IMergeTreeOp} corresponding to the delta.\n\t *\n\t * @remarks - This is useful for determining the type of change (see {@link (MergeTreeDeltaType:type)}).\n\t */\n\treadonly op: IMergeTreeOp;\n\n\t/**\n\t * The {@link @fluidframework/protocol-definitions#ISequencedDocumentMessage} corresponding to this acknowledged change.\n\t *\n\t * This field is omitted for deltas corresponding to unacknowledged changes.\n\t */\n\treadonly sequencedMessage?: ISequencedDocumentMessage;\n}\n\n/**\n * @internal\n */\nexport interface IMergeTreeClientSequenceArgs {\n\treadonly clientId: number;\n\treadonly referenceSequenceNumber: number;\n\treadonly sequenceNumber: number;\n}\n\n/**\n * @internal\n */\nexport type MergeTreeDeltaCallback = (\n\topArgs: IMergeTreeDeltaOpArgs,\n\tdeltaArgs: IMergeTreeDeltaCallbackArgs,\n) => void;\n\n/**\n * @legacy\n * @alpha\n */\n// eslint-disable-next-line @typescript-eslint/no-empty-interface\nexport interface IMergeTreeMaintenanceCallbackArgs\n\textends IMergeTreeDeltaCallbackArgs<MergeTreeMaintenanceType> {}\n\n/**\n * @internal\n */\nexport type MergeTreeMaintenanceCallback = (\n\tMaintenanceArgs: IMergeTreeMaintenanceCallbackArgs,\n\topArgs: IMergeTreeDeltaOpArgs | undefined,\n) => void;\n"]}
1
+ {"version":3,"file":"mergeTreeDeltaCallback.js","sourceRoot":"","sources":["../src/mergeTreeDeltaCallback.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAmBH;;;;;;;GAOG;AACU,QAAA,wBAAwB,GAAG;IACvC;;;;;;OAMG;IACH,MAAM,EAAE,CAAC,CAAC;IACV;;;OAGG;IACH,KAAK,EAAE,CAAC,CAAC;IACT;;;;;OAKG;IACH,MAAM,EAAE,CAAC,CAAC;IACV;;;OAGG;IACH,YAAY,EAAE,CAAC,CAAC;CACP,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ISequencedDocumentMessage } from \"@fluidframework/driver-definitions/internal\";\n\nimport { ISegment } from \"./mergeTreeNodes.js\";\n// eslint-disable-next-line import/no-deprecated\nimport { IMergeTreeGroupMsg, IMergeTreeOp, MergeTreeDeltaType } from \"./ops.js\";\nimport { PropertySet } from \"./properties.js\";\n\n/**\n * @legacy\n * @alpha\n */\nexport type MergeTreeDeltaOperationType =\n\t| typeof MergeTreeDeltaType.ANNOTATE\n\t| typeof MergeTreeDeltaType.INSERT\n\t| typeof MergeTreeDeltaType.REMOVE\n\t| typeof MergeTreeDeltaType.OBLITERATE;\n\n/**\n * Enum-like constant defining the types of \"maintenance\" events on a merge tree.\n * Maintenance events correspond to structural segment changes or acks of pending segments.\n *\n * Note: these values are assigned negative integers to avoid clashing with `MergeTreeDeltaType`.\n * @legacy\n * @alpha\n */\nexport const MergeTreeMaintenanceType = {\n\t/**\n\t * Notification that a segment \"append\" has occurred, i.e. two adjacent segments have been merged.\n\t * BEWARE: `deltaSegments` on the corresponding event will contain both the merged segment and the latter\n\t * segment, pre-merge.\n\t * For example, if the merge tree originally had two adjacent segments [A][B] and called A.append(B) to get\n\t * segment [AB], `deltaSegments` would contain [AB] and [B].\n\t */\n\tAPPEND: -1,\n\t/**\n\t * Notification that a segment has been split in two.\n\t * `deltaSegments` on the corresponding event will contain the resulting two segments.\n\t */\n\tSPLIT: -2,\n\t/**\n\t * Notification that a segment has been unlinked (i.e. removed) from the MergeTree.\n\t * This occurs on leaf segments during Zamboni when the segment's tracking collection is empty\n\t * (e.g., not being tracked for undo/redo).\n\t * It also occurs on internal merge tree segments when re-packing children to maintain tree balancing invariants.\n\t */\n\tUNLINK: -3,\n\t/**\n\t * Notification that a local change has been acknowledged by the server.\n\t * This means that it has made the round trip to the server and has had a sequence number assigned.\n\t */\n\tACKNOWLEDGED: -4,\n} as const;\n/**\n * @legacy\n * @alpha\n */\nexport type MergeTreeMaintenanceType =\n\t(typeof MergeTreeMaintenanceType)[keyof typeof MergeTreeMaintenanceType];\n\n/**\n * @legacy\n * @alpha\n */\nexport type MergeTreeDeltaOperationTypes =\n\t| MergeTreeDeltaOperationType\n\t| MergeTreeMaintenanceType;\n\n/**\n * @legacy\n * @alpha\n */\nexport interface IMergeTreeDeltaCallbackArgs<\n\tTOperationType extends MergeTreeDeltaOperationTypes = MergeTreeDeltaOperationType,\n> {\n\t/**\n\t * The type of operation that affected segments in the merge-tree.\n\t * The affected segments can be accessed via {@link IMergeTreeDeltaCallbackArgs.deltaSegments|deltaSegments}.\n\t *\n\t * See {@link MergeTreeDeltaOperationType} and {@link (MergeTreeMaintenanceType:type)} for possible values.\n\t */\n\treadonly operation: TOperationType;\n\n\t/**\n\t * A list of deltas describing actions taken on segments.\n\t *\n\t * Deltas are not guaranteed to be in any particular order.\n\t */\n\treadonly deltaSegments: IMergeTreeSegmentDelta[];\n}\n\n/**\n * @legacy\n * @alpha\n */\nexport interface IMergeTreeSegmentDelta {\n\t/**\n\t * The segment this delta affected.\n\t */\n\tsegment: ISegment;\n\n\t/**\n\t * A property set containing changes to properties on this segment.\n\t *\n\t * @remarks - Deleting a property is represented using `null` as the value.\n\t * @example\n\t *\n\t * An annotation change which deleted the property \"foo\" and set \"bar\" to 5 would be represented as:\n\t * `{ foo: null, bar: 5 }`.\n\t */\n\tpropertyDeltas?: PropertySet;\n}\n\n/**\n * @legacy\n * @alpha\n */\nexport interface IMergeTreeDeltaOpArgs {\n\t/**\n\t * The group op which contains the operation\n\t * if there operation is part of a group op.\n\t */\n\t// eslint-disable-next-line import/no-deprecated\n\treadonly groupOp?: IMergeTreeGroupMsg;\n\n\t/**\n\t * The {@link IMergeTreeOp} corresponding to the delta.\n\t *\n\t * @remarks - This is useful for determining the type of change (see {@link (MergeTreeDeltaType:type)}).\n\t */\n\treadonly op: IMergeTreeOp;\n\n\t/**\n\t * The {@link @fluidframework/protocol-definitions#ISequencedDocumentMessage} corresponding to this acknowledged change.\n\t *\n\t * This field is omitted for deltas corresponding to unacknowledged changes.\n\t */\n\treadonly sequencedMessage?: ISequencedDocumentMessage;\n\n\t/**\n\t * Set to true if this delta is being performed as part of a rollback of unsent local changes.\n\t */\n\treadonly rollback?: true;\n}\n\n/**\n * @internal\n */\nexport type MergeTreeDeltaCallback = (\n\topArgs: IMergeTreeDeltaOpArgs,\n\tdeltaArgs: IMergeTreeDeltaCallbackArgs,\n) => void;\n\n/**\n * @legacy\n * @alpha\n */\n// eslint-disable-next-line @typescript-eslint/no-empty-interface\nexport interface IMergeTreeMaintenanceCallbackArgs\n\textends IMergeTreeDeltaCallbackArgs<MergeTreeMaintenanceType> {}\n\n/**\n * @internal\n */\nexport type MergeTreeMaintenanceCallback = (\n\tMaintenanceArgs: IMergeTreeMaintenanceCallbackArgs,\n\topArgs: IMergeTreeDeltaOpArgs | undefined,\n) => void;\n"]}
@@ -8,11 +8,13 @@ import { LocalReferenceCollection, type LocalReferencePosition } from "./localRe
8
8
  import { TrackingGroupCollection } from "./mergeTreeTracking.js";
9
9
  import { IJSONSegment, IMarkerDef, ReferenceType } from "./ops.js";
10
10
  import type { PartialSequenceLengths } from "./partialLengths.js";
11
+ import { type Perspective } from "./perspective.js";
11
12
  import { PropertySet, type MapLike } from "./properties.js";
12
13
  import { ReferencePosition } from "./referencePositions.js";
13
14
  import { SegmentGroupCollection } from "./segmentGroupCollection.js";
14
- import { type IInsertionInfo, type IMergeNodeInfo, type SegmentWithInfo } from "./segmentInfos.js";
15
+ import { type IHasInsertionInfo, type IMergeNodeInfo, type SegmentWithInfo } from "./segmentInfos.js";
15
16
  import { PropertiesManager } from "./segmentPropertiesManager.js";
17
+ import type { OperationStamp, SliceRemoveOperationStamp } from "./stamps.js";
16
18
  /**
17
19
  * This interface exposes internal things to dds that leverage merge tree,
18
20
  * like sequence and matrix.
@@ -72,7 +74,7 @@ export interface ISegmentPrivate extends ISegmentInternal {
72
74
  obliteratePrecedingInsertion?: ObliterateInfo;
73
75
  }
74
76
  /**
75
- * Segment leafs are segments that have both IMergeNodeInfo and IInsertionInfo. This means they
77
+ * Segment leafs are segments that have both IMergeNodeInfo and IHasInsertionInfo. This means they
76
78
  * are inserted at a position, and bound via their parent MergeBlock to the merge tree. MergeBlocks'
77
79
  * children are either a segment leaf, or another merge block for interior nodes of the tree. When working
78
80
  * within the tree it is generally unnecessary to use type coercions methods common to the infos, and segment
@@ -80,7 +82,7 @@ export interface ISegmentPrivate extends ISegmentInternal {
80
82
  * merge tree, like via client's public methods, it becomes necessary to use the type coercions methods
81
83
  * to ensure the passed in segment objects are correctly bound to the merge tree.
82
84
  */
83
- export type ISegmentLeaf = SegmentWithInfo<IMergeNodeInfo & IInsertionInfo>;
85
+ export type ISegmentLeaf = SegmentWithInfo<IMergeNodeInfo & IHasInsertionInfo>;
84
86
  /**
85
87
  * A type-guard which determines if the segment has segment leaf, and
86
88
  * returns true if it does, along with applying strong typing.
@@ -107,7 +109,7 @@ export declare const assertSegmentLeaf: (segmentLike: unknown) => asserts segmen
107
109
  * type as segments may not yet be bound to the tree, so lack merge node info which is required for
108
110
  * segment leafs.
109
111
  */
110
- export type IMergeNodeBuilder = MergeBlock | SegmentWithInfo<IInsertionInfo>;
112
+ export type IMergeNodeBuilder = MergeBlock | SegmentWithInfo<IHasInsertionInfo>;
111
113
  /**
112
114
  * This type is used by MergeBlocks to define their children, which are either segments or other
113
115
  * MergeBlocks.
@@ -167,11 +169,11 @@ export interface ISegmentAction<TClientData> {
167
169
  (segment: ISegment, pos: number, refSeq: number, clientId: number, start: number, end: number, accum: TClientData): boolean;
168
170
  }
169
171
  export interface ISegmentChanges {
170
- next?: SegmentWithInfo<IInsertionInfo>;
171
- replaceCurrent?: SegmentWithInfo<IInsertionInfo>;
172
+ next?: SegmentWithInfo<IHasInsertionInfo>;
173
+ replaceCurrent?: SegmentWithInfo<IHasInsertionInfo>;
172
174
  }
173
175
  export interface InsertContext {
174
- candidateSegment?: SegmentWithInfo<IInsertionInfo>;
176
+ candidateSegment?: SegmentWithInfo<IHasInsertionInfo>;
175
177
  leaf: (segment: ISegmentLeaf | undefined, pos: number, ic: InsertContext) => ISegmentChanges;
176
178
  continuePredicate?: (continueFromBlock: MergeBlock) => boolean;
177
179
  }
@@ -179,9 +181,7 @@ export interface ObliterateInfo {
179
181
  start: LocalReferencePosition;
180
182
  end: LocalReferencePosition;
181
183
  refSeq: number;
182
- clientId: number;
183
- seq: number;
184
- localSeq: number | undefined;
184
+ stamp: SliceRemoveOperationStamp;
185
185
  segmentGroup: SegmentGroup | undefined;
186
186
  }
187
187
  export interface SegmentGroup {
@@ -307,6 +307,26 @@ export declare class Marker extends BaseSegment implements ReferencePosition, IS
307
307
  canAppend(segment: ISegment): boolean;
308
308
  append(): void;
309
309
  }
310
+ /**
311
+ * Returns a stamp that occurs at the minimum sequence number.
312
+ * @privateRemarks
313
+ * This is a free function over something obtainable on CollaborationWindow to avoid exposing Perspective
314
+ * and OperationStamp from the package (even internally), at least for now.
315
+ * If/when `Client`'s API is refactored to be structured similarly to MergeTree (so that SharedString passes in
316
+ * things closer to `Perspective`s when calling methods on `Client` rather than refSeq/localSeq/clientId etc),
317
+ * it may be more reasonable to expose this more directly on `CollaborationWindow`.
318
+ */
319
+ export declare function getMinSeqStamp(collabWindow: CollaborationWindow): OperationStamp;
320
+ /**
321
+ * Returns a perspective representing a readonly client's view of the tree at the minimum sequence number.
322
+ * @privateRemarks
323
+ * This is a free function over something obtainable on CollaborationWindow to avoid exposing Perspective
324
+ * and OperationStamp from the package (even internally), at least for now.
325
+ * If/when `Client`'s API is refactored to be structured similarly to MergeTree (so that SharedString passes in
326
+ * things closer to `Perspective`s when calling methods on `Client` rather than refSeq/localSeq/clientId etc),
327
+ * it may be more reasonable to expose this more directly on `CollaborationWindow`.
328
+ */
329
+ export declare function getMinSeqPerspective(collabWindow: CollaborationWindow): Perspective;
310
330
  /**
311
331
  * This class is used to track facts about the current window of collaboration. This window is defined by the server
312
332
  * specified minimum sequence number to the last sequence number seen. Additionally, it track state for outstanding
@@ -388,7 +408,9 @@ export declare class CollaborationWindow {
388
408
  * from a given (seq, localSeq) perspective.
389
409
  */
390
410
  localSeq: number;
411
+ localPerspective: Perspective;
391
412
  loadFrom(a: CollaborationWindow): void;
413
+ mintNextLocalOperationStamp(): OperationStamp;
392
414
  }
393
415
  /**
394
416
  * Compares two numbers.
@@ -1 +1 @@
1
- {"version":3,"file":"mergeTreeNodes.d.ts","sourceRoot":"","sources":["../src/mergeTreeNodes.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,cAAc,EAAE,MAAM,8CAA8C,CAAC;AAE9E,OAAO,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AAEpE,OAAO,EAAE,wBAAwB,EAAE,KAAK,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAC5F,OAAO,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AACjE,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEnE,OAAO,KAA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AW;IAMpB,YAAY,IAAI,kBAAkB;IAMlC,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,YAAY,GAAG,MAAM,GAAG,SAAS;IAO7D,KAAK,IAAI,MAAM;IAMf,UAAU,IAAI,MAAM;IAIpB,SAAS,IAAI,MAAM;IAInB,aAAa,IAAI,WAAW,GAAG,SAAS;IAIxC,KAAK,IAAI,MAAM,GAAG,SAAS;IAI3B,QAAQ,IAAI,MAAM;IAIlB,SAAS,CAAC,oBAAoB,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS;IAItD,SAAS,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO;IAIrC,MAAM,IAAI,IAAI;CAGd;AAED;;;;;;;;GAQG;AACH,wBAAgB,cAAc,CAAC,YAAY,EAAE,mBAAmB,GAAG,cAAc,CAEhF;AAED;;;;;;;;GAQG;AACH,wBAAgB,oBAAoB,CAAC,YAAY,EAAE,mBAAmB,GAAG,WAAW,CAEnF;AAED;;;;;GAKG;AACH,qBAAa,mBAAmB;IAC/B,QAAQ,SAAiB;IACzB,aAAa,UAAS;IAEtB;;OAEG;IACH,MAAM,SAAK;IACX;;OAEG;IACH,UAAU,SAAK;IAEf;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA8DG;IACH,QAAQ,SAAK;IAEN,gBAAgB,EAAE,WAAW,CAA8C;IAE3E,QAAQ,CAAC,CAAC,EAAE,mBAAmB,GAAG,IAAI;IAOtC,2BAA2B,IAAI,cAAc;CAWpD;AAED;;GAEG;AACH,eAAO,MAAM,cAAc,MAAO,MAAM,KAAK,MAAM,KAAG,MAAe,CAAC;AAEtE;;GAEG;AACH,eAAO,MAAM,cAAc,MAAO,MAAM,KAAK,MAAM,KAAG,MAA4B,CAAC"}
@@ -4,12 +4,13 @@
4
4
  * Licensed under the MIT License.
5
5
  */
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
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;
7
+ exports.compareStrings = exports.compareNumbers = exports.CollaborationWindow = exports.getMinSeqPerspective = exports.getMinSeqStamp = 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;
8
8
  const internal_1 = require("@fluidframework/core-utils/internal");
9
9
  const constants_js_1 = require("./constants.js");
10
10
  const localReference_js_1 = require("./localReference.js");
11
11
  const mergeTreeTracking_js_1 = require("./mergeTreeTracking.js");
12
12
  const ordinal_js_1 = require("./ordinal.js");
13
+ const perspective_js_1 = require("./perspective.js");
13
14
  const properties_js_1 = require("./properties.js");
14
15
  const segmentInfos_js_1 = require("./segmentInfos.js");
15
16
  /**
@@ -114,23 +115,14 @@ class BaseSegment {
114
115
  const seg = b;
115
116
  if ((0, segmentInfos_js_1.isInserted)(this)) {
116
117
  (0, segmentInfos_js_1.overwriteInfo)(seg, {
117
- clientId: this.clientId,
118
- seq: this.seq,
118
+ insert: this.insert,
119
119
  });
120
120
  }
121
121
  // TODO: deep clone properties
122
122
  seg.properties = (0, properties_js_1.clone)(this.properties);
123
123
  if ((0, segmentInfos_js_1.isRemoved)(this)) {
124
124
  (0, segmentInfos_js_1.overwriteInfo)(seg, {
125
- removedSeq: this.removedSeq,
126
- removedClientIds: [...this.removedClientIds],
127
- });
128
- }
129
- if ((0, segmentInfos_js_1.isMoved)(this)) {
130
- (0, segmentInfos_js_1.overwriteInfo)(seg, {
131
- movedSeq: this.movedSeq,
132
- movedSeqs: [...this.movedSeqs],
133
- movedClientIds: [...this.movedClientIds],
125
+ removes: [...this.removes],
134
126
  });
135
127
  }
136
128
  seg.attribution = this.attribution?.clone();
@@ -165,25 +157,11 @@ class BaseSegment {
165
157
  });
166
158
  }
167
159
  if ((0, segmentInfos_js_1.isInserted)(this)) {
168
- (0, segmentInfos_js_1.overwriteInfo)(leafSegment, {
169
- seq: this.seq,
170
- localSeq: this.localSeq,
171
- clientId: this.clientId,
172
- });
160
+ (0, segmentInfos_js_1.overwriteInfo)(leafSegment, { insert: this.insert });
173
161
  }
174
162
  if ((0, segmentInfos_js_1.isRemoved)(this)) {
175
163
  (0, segmentInfos_js_1.overwriteInfo)(leafSegment, {
176
- removedClientIds: [...this.removedClientIds],
177
- removedSeq: this.removedSeq,
178
- localRemovedSeq: this.localRemovedSeq,
179
- });
180
- }
181
- if ((0, segmentInfos_js_1.isMoved)(this)) {
182
- (0, segmentInfos_js_1.overwriteInfo)(leafSegment, {
183
- movedClientIds: [...this.movedClientIds],
184
- movedSeq: this.movedSeq,
185
- movedSeqs: [...this.movedSeqs],
186
- localMovedSeq: this.localMovedSeq,
164
+ removes: [...this.removes],
187
165
  });
188
166
  }
189
167
  this.trackingCollection.copyTo(leafSegment);
@@ -289,6 +267,32 @@ class Marker extends BaseSegment {
289
267
  }
290
268
  exports.Marker = Marker;
291
269
  Marker.type = "Marker";
270
+ /**
271
+ * Returns a stamp that occurs at the minimum sequence number.
272
+ * @privateRemarks
273
+ * This is a free function over something obtainable on CollaborationWindow to avoid exposing Perspective
274
+ * and OperationStamp from the package (even internally), at least for now.
275
+ * If/when `Client`'s API is refactored to be structured similarly to MergeTree (so that SharedString passes in
276
+ * things closer to `Perspective`s when calling methods on `Client` rather than refSeq/localSeq/clientId etc),
277
+ * it may be more reasonable to expose this more directly on `CollaborationWindow`.
278
+ */
279
+ function getMinSeqStamp(collabWindow) {
280
+ return { seq: collabWindow.minSeq, clientId: constants_js_1.NonCollabClient };
281
+ }
282
+ exports.getMinSeqStamp = getMinSeqStamp;
283
+ /**
284
+ * Returns a perspective representing a readonly client's view of the tree at the minimum sequence number.
285
+ * @privateRemarks
286
+ * This is a free function over something obtainable on CollaborationWindow to avoid exposing Perspective
287
+ * and OperationStamp from the package (even internally), at least for now.
288
+ * If/when `Client`'s API is refactored to be structured similarly to MergeTree (so that SharedString passes in
289
+ * things closer to `Perspective`s when calling methods on `Client` rather than refSeq/localSeq/clientId etc),
290
+ * it may be more reasonable to expose this more directly on `CollaborationWindow`.
291
+ */
292
+ function getMinSeqPerspective(collabWindow) {
293
+ return new perspective_js_1.PriorPerspective(collabWindow.minSeq, constants_js_1.NonCollabClient);
294
+ }
295
+ exports.getMinSeqPerspective = getMinSeqPerspective;
292
296
  /**
293
297
  * This class is used to track facts about the current window of collaboration. This window is defined by the server
294
298
  * specified minimum sequence number to the last sequence number seen. Additionally, it track state for outstanding
@@ -371,6 +375,7 @@ class CollaborationWindow {
371
375
  * from a given (seq, localSeq) perspective.
372
376
  */
373
377
  this.localSeq = 0;
378
+ this.localPerspective = new perspective_js_1.LocalDefaultPerspective(this.clientId);
374
379
  }
375
380
  loadFrom(a) {
376
381
  this.clientId = a.clientId;
@@ -378,6 +383,16 @@ class CollaborationWindow {
378
383
  this.minSeq = a.minSeq;
379
384
  this.currentSeq = a.currentSeq;
380
385
  }
386
+ mintNextLocalOperationStamp() {
387
+ if (this.collaborating) {
388
+ this.localSeq++;
389
+ }
390
+ return {
391
+ seq: this.collaborating ? constants_js_1.UnassignedSequenceNumber : constants_js_1.UniversalSequenceNumber,
392
+ clientId: this.clientId,
393
+ localSeq: this.localSeq,
394
+ };
395
+ }
381
396
  }
382
397
  exports.CollaborationWindow = CollaborationWindow;
383
398
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"mergeTreeNodes.js","sourceRoot":"","sources":["../src/mergeTreeNodes.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAA6D;AAI7D,iDAAyE;AACzE,2DAA4F;AAC5F,iEAAiE;AAEjE,6CAA0D;AA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DAoFC;AAED;;GAEG;AACI,MAAM,cAAc,GAAG,CAAC,CAAS,EAAE,CAAS,EAAU,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC;AAAzD,QAAA,cAAc,kBAA2C;AAEtE;;GAEG;AACI,MAAM,cAAc,GAAG,CAAC,CAAS,EAAE,CAAS,EAAU,EAAE,CAAC,CAAC,CAAC,aAAa,CAAC,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 { LocalClientId, UnassignedSequenceNumber } from \"./constants.js\";\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\thasProp,\n\tisInserted,\n\tisMergeNodeInfo as isMergeNode,\n\tisMoved,\n\tisRemoved,\n\toverwriteInfo,\n\ttype IInsertionInfo,\n\ttype IMergeNodeInfo,\n\ttype IMoveInfo,\n\ttype IRemovalInfo,\n\ttype SegmentWithInfo,\n} from \"./segmentInfos.js\";\nimport { PropertiesManager } from \"./segmentPropertiesManager.js\";\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 interface ISegmentInternal extends ISegment {\n\tlocalRefs?: LocalReferenceCollection;\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 */\n\treadonly endpointType?: \"start\" | \"end\";\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 interface ISegmentPrivate extends ISegmentInternal {\n\tsegmentGroups?: SegmentGroupCollection;\n\tpropertyManager?: PropertiesManager;\n\t/**\n\t * Populated iff this segment was inserted into a range affected by concurrent obliterates at the time of its insertion.\n\t * Contains information about the 'most recent' (i.e. 'winning' in the sense below) obliterate.\n\t *\n\t * BEWARE: We have opted for a certain form of last-write wins (LWW) semantics for obliterates:\n\t * the client which last obliterated a range is considered to have \"won ownership\" of that range and may insert into it\n\t * without that insertion being obliterated by other clients' concurrent obliterates.\n\t *\n\t * Therefore, this field can be populated even if the segment has not been obliterated (i.e. is still visible).\n\t * This happens precisely when the segment was inserted by the same client that 'won' the obliterate (in a scenario where\n\t * a client first issues a sided obliterate impacting a range, then inserts into that range before the server has acked the obliterate).\n\t *\n\t * See the test case \"obliterate with mismatched final states\" for an example of such a scenario.\n\t *\n\t * TODO:AB#29553: This property is not persisted in the summary, but it should be.\n\t */\n\tobliteratePrecedingInsertion?: ObliterateInfo;\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\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 * 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\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: hasProp(child, \"ordinal\", \"string\") ? 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\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\tpublic abstract readonly type: string;\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\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\toverwriteInfo<IMoveInfo>(seg, {\n\t\t\t\tmovedSeq: this.movedSeq,\n\t\t\t\tmovedSeqs: [...this.movedSeqs],\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\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\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});\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\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
+ {"version":3,"file":"mergeTreeNodes.js","sourceRoot":"","sources":["../src/mergeTreeNodes.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAA6D;AAI7D,iDAKwB;AACxB,2DAA4F;AAC5F,iEAAiE;AAEjE,6CAA0D;AAE1D,qDAA+F;AAC/F,mDAA8E;AAG9E,uDAU2B;AAyE3B;;;;;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,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EN,qBAAgB,GAAgB,IAAI,wCAAuB,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IAoBnF,CAAC;IAlBO,QAAQ,CAAC,CAAsB;QACrC,IAAI,CAAC,QAAQ,GAAG,CAAC,CAAC,QAAQ,CAAC;QAC3B,IAAI,CAAC,aAAa,GAAG,CAAC,CAAC,aAAa,CAAC;QACrC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,MAAM,CAAC;QACvB,IAAI,CAAC,UAAU,GAAG,CAAC,CAAC,UAAU,CAAC;IAChC,CAAC;IAEM,2BAA2B;QACjC,IAAI,IAAI,CAAC,aAAa,EAAE,CAAC;YACxB,IAAI,CAAC,QAAQ,EAAE,CAAC;QACjB,CAAC;QAED,OAAO;YACN,GAAG,EAAE,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,uCAAwB,CAAC,CAAC,CAAC,sCAAuB;YAC5E,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,QAAQ,EAAE,IAAI,CAAC,QAAQ;SACvB,CAAC;IACH,CAAC;CACD;AAlGD,kDAkGC;AAED;;GAEG;AACI,MAAM,cAAc,GAAG,CAAC,CAAS,EAAE,CAAS,EAAU,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC;AAAzD,QAAA,cAAc,kBAA2C;AAEtE;;GAEG;AACI,MAAM,cAAc,GAAG,CAAC,CAAS,EAAE,CAAS,EAAU,EAAE,CAAC,CAAC,CAAC,aAAa,CAAC,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\tNonCollabClient,\n\tUnassignedSequenceNumber,\n\tUniversalSequenceNumber,\n} from \"./constants.js\";\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 { LocalDefaultPerspective, PriorPerspective, type Perspective } from \"./perspective.js\";\nimport { PropertySet, clone, createMap, type MapLike } from \"./properties.js\";\nimport { ReferencePosition } from \"./referencePositions.js\";\nimport { SegmentGroupCollection } from \"./segmentGroupCollection.js\";\nimport {\n\thasProp,\n\tisInserted,\n\tisMergeNodeInfo as isMergeNode,\n\tisRemoved,\n\toverwriteInfo,\n\ttype IHasInsertionInfo,\n\ttype IMergeNodeInfo,\n\ttype IHasRemovalInfo,\n\ttype SegmentWithInfo,\n} from \"./segmentInfos.js\";\nimport { PropertiesManager } from \"./segmentPropertiesManager.js\";\nimport type { OperationStamp, SliceRemoveOperationStamp } from \"./stamps.js\";\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 interface ISegmentInternal extends ISegment {\n\tlocalRefs?: LocalReferenceCollection;\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 */\n\treadonly endpointType?: \"start\" | \"end\";\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 interface ISegmentPrivate extends ISegmentInternal {\n\tsegmentGroups?: SegmentGroupCollection;\n\tpropertyManager?: PropertiesManager;\n\t/**\n\t * Populated iff this segment was inserted into a range affected by concurrent obliterates at the time of its insertion.\n\t * Contains information about the 'most recent' (i.e. 'winning' in the sense below) obliterate.\n\t *\n\t * BEWARE: We have opted for a certain form of last-write wins (LWW) semantics for obliterates:\n\t * the client which last obliterated a range is considered to have \"won ownership\" of that range and may insert into it\n\t * without that insertion being obliterated by other clients' concurrent obliterates.\n\t *\n\t * Therefore, this field can be populated even if the segment has not been obliterated (i.e. is still visible).\n\t * This happens precisely when the segment was inserted by the same client that 'won' the obliterate (in a scenario where\n\t * a client first issues a sided obliterate impacting a range, then inserts into that range before the server has acked the obliterate).\n\t *\n\t * See the test case \"obliterate with mismatched final states\" for an example of such a scenario.\n\t *\n\t * TODO:AB#29553: This property is not persisted in the summary, but it should be.\n\t */\n\tobliteratePrecedingInsertion?: ObliterateInfo;\n}\n/**\n * Segment leafs are segments that have both IMergeNodeInfo and IHasInsertionInfo. 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 & IHasInsertionInfo>;\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<IHasInsertionInfo>;\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\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 * 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\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<IHasInsertionInfo>;\n\treplaceCurrent?: SegmentWithInfo<IHasInsertionInfo>;\n}\n\nexport interface InsertContext {\n\tcandidateSegment?: SegmentWithInfo<IHasInsertionInfo>;\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\tstamp: SliceRemoveOperationStamp;\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: hasProp(child, \"ordinal\", \"string\") ? 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\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\tpublic abstract readonly type: string;\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<IHasInsertionInfo>(seg, {\n\t\t\t\tinsert: this.insert,\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\toverwriteInfo<IHasRemovalInfo>(seg, {\n\t\t\t\tremoves: [...this.removes],\n\t\t\t});\n\t\t}\n\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<IHasInsertionInfo>(leafSegment, { insert: this.insert });\n\t\t}\n\t\tif (isRemoved(this)) {\n\t\t\toverwriteInfo<IHasRemovalInfo>(leafSegment, {\n\t\t\t\tremoves: [...this.removes],\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\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 * Returns a stamp that occurs at the minimum sequence number.\n * @privateRemarks\n * This is a free function over something obtainable on CollaborationWindow to avoid exposing Perspective\n * and OperationStamp from the package (even internally), at least for now.\n * If/when `Client`'s API is refactored to be structured similarly to MergeTree (so that SharedString passes in\n * things closer to `Perspective`s when calling methods on `Client` rather than refSeq/localSeq/clientId etc),\n * it may be more reasonable to expose this more directly on `CollaborationWindow`.\n */\nexport function getMinSeqStamp(collabWindow: CollaborationWindow): OperationStamp {\n\treturn { seq: collabWindow.minSeq, clientId: NonCollabClient };\n}\n\n/**\n * Returns a perspective representing a readonly client's view of the tree at the minimum sequence number.\n * @privateRemarks\n * This is a free function over something obtainable on CollaborationWindow to avoid exposing Perspective\n * and OperationStamp from the package (even internally), at least for now.\n * If/when `Client`'s API is refactored to be structured similarly to MergeTree (so that SharedString passes in\n * things closer to `Perspective`s when calling methods on `Client` rather than refSeq/localSeq/clientId etc),\n * it may be more reasonable to expose this more directly on `CollaborationWindow`.\n */\nexport function getMinSeqPerspective(collabWindow: CollaborationWindow): Perspective {\n\treturn new PriorPerspective(collabWindow.minSeq, NonCollabClient);\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\tpublic localPerspective: Perspective = new LocalDefaultPerspective(this.clientId);\n\n\tpublic loadFrom(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\tpublic mintNextLocalOperationStamp(): OperationStamp {\n\t\tif (this.collaborating) {\n\t\t\tthis.localSeq++;\n\t\t}\n\n\t\treturn {\n\t\t\tseq: this.collaborating ? UnassignedSequenceNumber : UniversalSequenceNumber,\n\t\t\tclientId: this.clientId,\n\t\t\tlocalSeq: this.localSeq,\n\t\t};\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"]}
@@ -185,11 +185,11 @@ export declare class PartialSequenceLengths {
185
185
  */
186
186
  private static fromLeaves;
187
187
  /**
188
- * Assuming this segment was moved on insertion, inserts length information about that operation
188
+ * Assuming this segment was removed on insertion, inserts length information about that operation
189
189
  * into the appropriate per-client adjustments (the overall view needs no such adjustment since
190
190
  * from an observing client's perspective, the segment never exists).
191
191
  */
192
- private static accountForMoveOnInsert;
192
+ private static accountForRemoveOnInsert;
193
193
  /**
194
194
  * Inserts length information about the insertion of `segment` into
195
195
  * `combinedPartialLengths.partialLengths` and the appropriate per-client adjustments.
@@ -1 +1 @@
1
- {"version":3,"file":"partialLengths.d.ts","sourceRoot":"","sources":["../src/partialLengths.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EACN,mBAAmB,EAInB,KAAK,UAAU,EACf,MAAM,qBAAqB,CAAC;AA8F7B;;;GAGG;AACH,MAAM,WAAW,qBAAqB;IACrC;;OAEG;IACH,GAAG,EAAE,MAAM,CAAC;IACZ;;OAEG;IACH,GAAG,EAAE,MAAM,CAAC;IACZ;;OAEG;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