@fluidframework/merge-tree 2.23.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 (323) hide show
  1. package/CHANGELOG.md +407 -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 +38 -22
  20. package/dist/mergeTree.d.ts.map +1 -1
  21. package/dist/mergeTree.js +408 -486
  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 +84 -65
  35. package/dist/perspective.d.ts.map +1 -1
  36. package/dist/perspective.js +109 -108
  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 +90 -0
  59. package/dist/stamps.d.ts.map +1 -0
  60. package/dist/stamps.js +90 -0
  61. package/dist/stamps.js.map +1 -0
  62. package/dist/test/Insertion.perf.spec.js +6 -51
  63. package/dist/test/Insertion.perf.spec.js.map +1 -1
  64. package/dist/test/PartialLengths.perf.spec.js +18 -25
  65. package/dist/test/PartialLengths.perf.spec.js.map +1 -1
  66. package/dist/test/Removal.perf.spec.js +13 -41
  67. package/dist/test/Removal.perf.spec.js.map +1 -1
  68. package/dist/test/beastTest.spec.d.ts.map +1 -1
  69. package/dist/test/beastTest.spec.js +41 -66
  70. package/dist/test/beastTest.spec.js.map +1 -1
  71. package/dist/test/client.annotateMarker.spec.js +1 -11
  72. package/dist/test/client.annotateMarker.spec.js.map +1 -1
  73. package/dist/test/client.applyMsg.spec.js +14 -14
  74. package/dist/test/client.applyMsg.spec.js.map +1 -1
  75. package/dist/test/client.getPosition.spec.js +1 -1
  76. package/dist/test/client.getPosition.spec.js.map +1 -1
  77. package/dist/test/client.localReference.spec.js +1 -1
  78. package/dist/test/client.localReference.spec.js.map +1 -1
  79. package/dist/test/client.rollback.spec.js +49 -58
  80. package/dist/test/client.rollback.spec.js.map +1 -1
  81. package/dist/test/client.rollbackFarm.spec.js +1 -1
  82. package/dist/test/client.rollbackFarm.spec.js.map +1 -1
  83. package/dist/test/client.searchForMarker.spec.js +4 -21
  84. package/dist/test/client.searchForMarker.spec.js.map +1 -1
  85. package/dist/test/index.d.ts +2 -2
  86. package/dist/test/index.d.ts.map +1 -1
  87. package/dist/test/index.js +2 -6
  88. package/dist/test/index.js.map +1 -1
  89. package/dist/test/mergeTree.annotate.deltaCallback.spec.js +14 -59
  90. package/dist/test/mergeTree.annotate.deltaCallback.spec.js.map +1 -1
  91. package/dist/test/mergeTree.annotate.spec.js +47 -63
  92. package/dist/test/mergeTree.annotate.spec.js.map +1 -1
  93. package/dist/test/mergeTree.insert.deltaCallback.spec.js +9 -62
  94. package/dist/test/mergeTree.insert.deltaCallback.spec.js.map +1 -1
  95. package/dist/test/mergeTree.insertingWalk.spec.js +59 -125
  96. package/dist/test/mergeTree.insertingWalk.spec.js.map +1 -1
  97. package/dist/test/mergeTree.markRangeRemoved.deltaCallback.spec.js +12 -93
  98. package/dist/test/mergeTree.markRangeRemoved.deltaCallback.spec.js.map +1 -1
  99. package/dist/test/mergeTree.markRangeRemoved.spec.js +10 -7
  100. package/dist/test/mergeTree.markRangeRemoved.spec.js.map +1 -1
  101. package/dist/test/mergeTree.walk.spec.js +2 -14
  102. package/dist/test/mergeTree.walk.spec.js.map +1 -1
  103. package/dist/test/mergeTreeOperationRunner.js +2 -2
  104. package/dist/test/mergeTreeOperationRunner.js.map +1 -1
  105. package/dist/test/obliterate.concurrent.spec.js +18 -23
  106. package/dist/test/obliterate.concurrent.spec.js.map +1 -1
  107. package/dist/test/obliterate.partialLength.spec.js +166 -136
  108. package/dist/test/obliterate.partialLength.spec.js.map +1 -1
  109. package/dist/test/obliterate.spec.js +16 -126
  110. package/dist/test/obliterate.spec.js.map +1 -1
  111. package/dist/test/partialLength.spec.js +28 -196
  112. package/dist/test/partialLength.spec.js.map +1 -1
  113. package/{prettier.config.cjs → dist/test/perspective.spec.d.ts} +2 -4
  114. package/dist/test/perspective.spec.d.ts.map +1 -0
  115. package/dist/test/perspective.spec.js +153 -0
  116. package/dist/test/perspective.spec.js.map +1 -0
  117. package/dist/test/propertyManager.spec.js +1 -1
  118. package/dist/test/propertyManager.spec.js.map +1 -1
  119. package/dist/test/resetPendingSegmentsToOp.spec.js +0 -2
  120. package/dist/test/resetPendingSegmentsToOp.spec.js.map +1 -1
  121. package/dist/test/segmentGroupCollection.spec.js +10 -4
  122. package/dist/test/segmentGroupCollection.spec.js.map +1 -1
  123. package/dist/test/stamps.spec.d.ts +6 -0
  124. package/dist/test/stamps.spec.d.ts.map +1 -0
  125. package/dist/test/stamps.spec.js +130 -0
  126. package/dist/test/stamps.spec.js.map +1 -0
  127. package/dist/test/testClient.d.ts +1 -0
  128. package/dist/test/testClient.d.ts.map +1 -1
  129. package/dist/test/testClient.js +16 -26
  130. package/dist/test/testClient.js.map +1 -1
  131. package/dist/test/testClientLogger.d.ts +9 -0
  132. package/dist/test/testClientLogger.d.ts.map +1 -1
  133. package/dist/test/testClientLogger.js +59 -47
  134. package/dist/test/testClientLogger.js.map +1 -1
  135. package/dist/test/testServer.d.ts +2 -1
  136. package/dist/test/testServer.d.ts.map +1 -1
  137. package/dist/test/testServer.js +7 -5
  138. package/dist/test/testServer.js.map +1 -1
  139. package/dist/test/testUtils.d.ts +36 -56
  140. package/dist/test/testUtils.d.ts.map +1 -1
  141. package/dist/test/testUtils.js +68 -77
  142. package/dist/test/testUtils.js.map +1 -1
  143. package/dist/test/text.d.ts +2 -2
  144. package/dist/test/text.d.ts.map +1 -1
  145. package/dist/test/text.js +5 -2
  146. package/dist/test/text.js.map +1 -1
  147. package/dist/textSegment.d.ts +0 -6
  148. package/dist/textSegment.d.ts.map +1 -1
  149. package/dist/textSegment.js.map +1 -1
  150. package/dist/zamboni.d.ts.map +1 -1
  151. package/dist/zamboni.js +53 -26
  152. package/dist/zamboni.js.map +1 -1
  153. package/lib/MergeTreeTextHelper.d.ts +9 -3
  154. package/lib/MergeTreeTextHelper.d.ts.map +1 -1
  155. package/lib/MergeTreeTextHelper.js +5 -5
  156. package/lib/MergeTreeTextHelper.js.map +1 -1
  157. package/lib/client.d.ts +7 -13
  158. package/lib/client.d.ts.map +1 -1
  159. package/lib/client.js +117 -116
  160. package/lib/client.js.map +1 -1
  161. package/lib/endOfTreeSegment.d.ts +12 -8
  162. package/lib/endOfTreeSegment.d.ts.map +1 -1
  163. package/lib/endOfTreeSegment.js +2 -4
  164. package/lib/endOfTreeSegment.js.map +1 -1
  165. package/lib/index.d.ts +6 -3
  166. package/lib/index.d.ts.map +1 -1
  167. package/lib/index.js +1 -1
  168. package/lib/index.js.map +1 -1
  169. package/lib/mergeTree.d.ts +38 -22
  170. package/lib/mergeTree.d.ts.map +1 -1
  171. package/lib/mergeTree.js +389 -491
  172. package/lib/mergeTree.js.map +1 -1
  173. package/lib/mergeTreeDeltaCallback.d.ts +4 -8
  174. package/lib/mergeTreeDeltaCallback.d.ts.map +1 -1
  175. package/lib/mergeTreeDeltaCallback.js.map +1 -1
  176. package/lib/mergeTreeNodes.d.ts +32 -10
  177. package/lib/mergeTreeNodes.d.ts.map +1 -1
  178. package/lib/mergeTreeNodes.js +42 -29
  179. package/lib/mergeTreeNodes.js.map +1 -1
  180. package/lib/partialLengths.d.ts +2 -2
  181. package/lib/partialLengths.d.ts.map +1 -1
  182. package/lib/partialLengths.js +160 -111
  183. package/lib/partialLengths.js.map +1 -1
  184. package/lib/perspective.d.ts +84 -65
  185. package/lib/perspective.d.ts.map +1 -1
  186. package/lib/perspective.js +82 -103
  187. package/lib/perspective.js.map +1 -1
  188. package/lib/revertibles.d.ts.map +1 -1
  189. package/lib/revertibles.js +2 -2
  190. package/lib/revertibles.js.map +1 -1
  191. package/lib/segmentInfos.d.ts +20 -106
  192. package/lib/segmentInfos.d.ts.map +1 -1
  193. package/lib/segmentInfos.js +26 -37
  194. package/lib/segmentInfos.js.map +1 -1
  195. package/lib/segmentPropertiesManager.d.ts +1 -14
  196. package/lib/segmentPropertiesManager.d.ts.map +1 -1
  197. package/lib/segmentPropertiesManager.js +2 -16
  198. package/lib/segmentPropertiesManager.js.map +1 -1
  199. package/lib/snapshotLoader.d.ts.map +1 -1
  200. package/lib/snapshotLoader.js +39 -19
  201. package/lib/snapshotLoader.js.map +1 -1
  202. package/lib/snapshotV1.d.ts.map +1 -1
  203. package/lib/snapshotV1.js +34 -26
  204. package/lib/snapshotV1.js.map +1 -1
  205. package/lib/snapshotlegacy.d.ts.map +1 -1
  206. package/lib/snapshotlegacy.js +7 -10
  207. package/lib/snapshotlegacy.js.map +1 -1
  208. package/lib/stamps.d.ts +90 -0
  209. package/lib/stamps.d.ts.map +1 -0
  210. package/lib/stamps.js +77 -0
  211. package/lib/stamps.js.map +1 -0
  212. package/lib/test/Insertion.perf.spec.js +6 -51
  213. package/lib/test/Insertion.perf.spec.js.map +1 -1
  214. package/lib/test/PartialLengths.perf.spec.js +18 -25
  215. package/lib/test/PartialLengths.perf.spec.js.map +1 -1
  216. package/lib/test/Removal.perf.spec.js +13 -41
  217. package/lib/test/Removal.perf.spec.js.map +1 -1
  218. package/lib/test/beastTest.spec.d.ts.map +1 -1
  219. package/lib/test/beastTest.spec.js +42 -67
  220. package/lib/test/beastTest.spec.js.map +1 -1
  221. package/lib/test/client.annotateMarker.spec.js +1 -11
  222. package/lib/test/client.annotateMarker.spec.js.map +1 -1
  223. package/lib/test/client.applyMsg.spec.js +14 -14
  224. package/lib/test/client.applyMsg.spec.js.map +1 -1
  225. package/lib/test/client.getPosition.spec.js +1 -1
  226. package/lib/test/client.getPosition.spec.js.map +1 -1
  227. package/lib/test/client.localReference.spec.js +1 -1
  228. package/lib/test/client.localReference.spec.js.map +1 -1
  229. package/lib/test/client.rollback.spec.js +50 -59
  230. package/lib/test/client.rollback.spec.js.map +1 -1
  231. package/lib/test/client.rollbackFarm.spec.js +1 -1
  232. package/lib/test/client.rollbackFarm.spec.js.map +1 -1
  233. package/lib/test/client.searchForMarker.spec.js +4 -21
  234. package/lib/test/client.searchForMarker.spec.js.map +1 -1
  235. package/lib/test/index.d.ts +2 -2
  236. package/lib/test/index.d.ts.map +1 -1
  237. package/lib/test/index.js +1 -1
  238. package/lib/test/index.js.map +1 -1
  239. package/lib/test/mergeTree.annotate.deltaCallback.spec.js +15 -60
  240. package/lib/test/mergeTree.annotate.deltaCallback.spec.js.map +1 -1
  241. package/lib/test/mergeTree.annotate.spec.js +48 -64
  242. package/lib/test/mergeTree.annotate.spec.js.map +1 -1
  243. package/lib/test/mergeTree.insert.deltaCallback.spec.js +10 -63
  244. package/lib/test/mergeTree.insert.deltaCallback.spec.js.map +1 -1
  245. package/lib/test/mergeTree.insertingWalk.spec.js +61 -127
  246. package/lib/test/mergeTree.insertingWalk.spec.js.map +1 -1
  247. package/lib/test/mergeTree.markRangeRemoved.deltaCallback.spec.js +13 -94
  248. package/lib/test/mergeTree.markRangeRemoved.deltaCallback.spec.js.map +1 -1
  249. package/lib/test/mergeTree.markRangeRemoved.spec.js +10 -7
  250. package/lib/test/mergeTree.markRangeRemoved.spec.js.map +1 -1
  251. package/lib/test/mergeTree.walk.spec.js +2 -14
  252. package/lib/test/mergeTree.walk.spec.js.map +1 -1
  253. package/lib/test/mergeTreeOperationRunner.js +3 -3
  254. package/lib/test/mergeTreeOperationRunner.js.map +1 -1
  255. package/lib/test/obliterate.concurrent.spec.js +18 -23
  256. package/lib/test/obliterate.concurrent.spec.js.map +1 -1
  257. package/lib/test/obliterate.partialLength.spec.js +167 -137
  258. package/lib/test/obliterate.partialLength.spec.js.map +1 -1
  259. package/lib/test/obliterate.spec.js +17 -127
  260. package/lib/test/obliterate.spec.js.map +1 -1
  261. package/lib/test/partialLength.spec.js +29 -197
  262. package/lib/test/partialLength.spec.js.map +1 -1
  263. package/lib/test/perspective.spec.d.ts +6 -0
  264. package/lib/test/perspective.spec.d.ts.map +1 -0
  265. package/lib/test/perspective.spec.js +151 -0
  266. package/lib/test/perspective.spec.js.map +1 -0
  267. package/lib/test/propertyManager.spec.js +2 -2
  268. package/lib/test/propertyManager.spec.js.map +1 -1
  269. package/lib/test/resetPendingSegmentsToOp.spec.js +0 -2
  270. package/lib/test/resetPendingSegmentsToOp.spec.js.map +1 -1
  271. package/lib/test/segmentGroupCollection.spec.js +10 -4
  272. package/lib/test/segmentGroupCollection.spec.js.map +1 -1
  273. package/lib/test/stamps.spec.d.ts +6 -0
  274. package/lib/test/stamps.spec.d.ts.map +1 -0
  275. package/lib/test/stamps.spec.js +105 -0
  276. package/lib/test/stamps.spec.js.map +1 -0
  277. package/lib/test/testClient.d.ts +1 -0
  278. package/lib/test/testClient.d.ts.map +1 -1
  279. package/lib/test/testClient.js +18 -28
  280. package/lib/test/testClient.js.map +1 -1
  281. package/lib/test/testClientLogger.d.ts +9 -0
  282. package/lib/test/testClientLogger.d.ts.map +1 -1
  283. package/lib/test/testClientLogger.js +60 -48
  284. package/lib/test/testClientLogger.js.map +1 -1
  285. package/lib/test/testServer.d.ts +2 -1
  286. package/lib/test/testServer.d.ts.map +1 -1
  287. package/lib/test/testServer.js +7 -5
  288. package/lib/test/testServer.js.map +1 -1
  289. package/lib/test/testUtils.d.ts +36 -56
  290. package/lib/test/testUtils.d.ts.map +1 -1
  291. package/lib/test/testUtils.js +66 -48
  292. package/lib/test/testUtils.js.map +1 -1
  293. package/lib/test/text.d.ts +2 -2
  294. package/lib/test/text.d.ts.map +1 -1
  295. package/lib/test/text.js +6 -3
  296. package/lib/test/text.js.map +1 -1
  297. package/lib/textSegment.d.ts +0 -6
  298. package/lib/textSegment.d.ts.map +1 -1
  299. package/lib/textSegment.js.map +1 -1
  300. package/lib/tsdoc-metadata.json +1 -1
  301. package/lib/zamboni.d.ts.map +1 -1
  302. package/lib/zamboni.js +32 -28
  303. package/lib/zamboni.js.map +1 -1
  304. package/package.json +18 -21
  305. package/src/MergeTreeTextHelper.ts +17 -12
  306. package/src/client.ts +141 -197
  307. package/src/endOfTreeSegment.ts +11 -8
  308. package/src/index.ts +4 -3
  309. package/src/mergeTree.ts +501 -631
  310. package/src/mergeTreeDeltaCallback.ts +4 -8
  311. package/src/mergeTreeNodes.ts +66 -45
  312. package/src/partialLengths.ts +181 -137
  313. package/src/perspective.ts +127 -129
  314. package/src/revertibles.ts +2 -7
  315. package/src/segmentInfos.ts +48 -141
  316. package/src/segmentPropertiesManager.ts +2 -16
  317. package/src/snapshotLoader.ts +62 -30
  318. package/src/snapshotV1.ts +36 -28
  319. package/src/snapshotlegacy.ts +7 -16
  320. package/src/stamps.ts +164 -0
  321. package/src/textSegment.ts +0 -13
  322. package/src/zamboni.ts +38 -32
  323. package/tsconfig.json +1 -0
@@ -3,12 +3,12 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
  import { ISegmentInternal, ISegmentPrivate, MergeBlock } from "./mergeTreeNodes.js";
6
- import type { ReferencePosition } from "./referencePositions.js";
6
+ import type { InsertOperationStamp, RemoveOperationStamp } from "./stamps.js";
7
7
  export interface StringToType {
8
8
  "string": string;
9
9
  "number": number;
10
10
  "object": object;
11
- "array": [];
11
+ "array": unknown[];
12
12
  "boolean": boolean;
13
13
  }
14
14
  export declare function propExists<P extends string>(thing: unknown, prop: P): thing is Record<P, unknown>;
@@ -17,25 +17,8 @@ export declare function propInstanceOf<P extends string, T>(thing: unknown, prop
17
17
  /**
18
18
  * Contains insertion information associated to an {@link ISegment}.
19
19
  */
20
- export interface IInsertionInfo {
21
- /**
22
- * Short clientId for the client that inserted this segment.
23
- */
24
- clientId: number;
25
- /**
26
- * Local seq at which this segment was inserted.
27
- * This is defined if and only if the insertion of the segment is pending ack, i.e. `seq` is UnassignedSequenceNumber.
28
- * Once the segment is acked, this field is cleared.
29
- *
30
- * @privateRemarks
31
- * See {@link CollaborationWindow.localSeq} for more information on the semantics of localSeq.
32
- */
33
- localSeq?: number;
34
- /**
35
- * Seq at which this segment was inserted.
36
- * If undefined, it is assumed the segment was inserted prior to the collab window's minimum sequence number.
37
- */
38
- seq: number;
20
+ export interface IHasInsertionInfo {
21
+ insert: InsertOperationStamp;
39
22
  }
40
23
  /**
41
24
  * Converts a segment-like object to an insertion info object if possible.
@@ -43,7 +26,7 @@ export interface IInsertionInfo {
43
26
  * @param segmentLike - The segment-like object to convert.
44
27
  * @returns The insertion info object if the conversion is possible, otherwise undefined.
45
28
  */
46
- export declare const toInsertionInfo: (segmentLike: unknown) => IInsertionInfo | undefined;
29
+ export declare const toInsertionInfo: (segmentLike: unknown) => IHasInsertionInfo | undefined;
47
30
  /**
48
31
  * A type-guard which determines if the segment has insertion info, and
49
32
  * returns true if it does, along with applying strong typing.
@@ -51,14 +34,14 @@ export declare const toInsertionInfo: (segmentLike: unknown) => IInsertionInfo |
51
34
  * @param segmentLike - The segment-like object to check.
52
35
  * @returns True if the segment has insertion info, otherwise false.
53
36
  */
54
- export declare const isInserted: (segmentLike: unknown) => segmentLike is IInsertionInfo;
37
+ export declare const isInserted: (segmentLike: unknown) => segmentLike is IHasInsertionInfo;
55
38
  /**
56
39
  * Asserts that the segment has insertion info. Usage of this function should not produce a user facing error.
57
40
  *
58
41
  * @param segmentLike - The segment-like object to check.
59
42
  * @throws Will throw an error if the segment does not have insertion info.
60
43
  */
61
- export declare const assertInserted: <T extends Partial<IInsertionInfo> | undefined>(segmentLike: ISegmentInternal | Partial<IInsertionInfo> | T) => asserts segmentLike is IInsertionInfo | Exclude<T, Partial<IInsertionInfo>>;
44
+ export declare const assertInserted: <T extends Partial<IHasInsertionInfo> | undefined>(segmentLike: ISegmentInternal | Partial<IHasInsertionInfo> | T) => asserts segmentLike is IHasInsertionInfo | Exclude<T, Partial<IHasInsertionInfo>>;
62
45
  /**
63
46
  * Common properties for a node in a merge tree.
64
47
  */
@@ -108,24 +91,15 @@ export declare const assertMergeNode: <T extends Partial<IMergeNodeInfo> | undef
108
91
  */
109
92
  export declare const removeMergeNodeInfo: (nodeLike: IMergeNodeInfo) => asserts nodeLike is never;
110
93
  /**
111
- * Contains removal information associated to an {@link ISegment}.
94
+ * Contains removal information associated with an {@link ISegment}.
95
+ *
96
+ * Segments can be removed concurrently by multiple clients.
112
97
  */
113
- export interface IRemovalInfo {
114
- /**
115
- * Local seq at which this segment was removed, if the removal is yet-to-be acked.
116
- */
117
- localRemovedSeq?: number;
98
+ export interface IHasRemovalInfo {
118
99
  /**
119
- * Seq at which this segment was removed.
100
+ * Operation stamps which have removed this segment. This list is sorted by stamp order, where removes[0] is the earliest removal.
120
101
  */
121
- removedSeq: number;
122
- /**
123
- * List of client IDs that have removed this segment.
124
- * The client that actually removed the segment (i.e. whose removal op was sequenced first) is stored as the first
125
- * client in this list. Other clients in the list have all issued concurrent ops to remove the segment.
126
- * @remarks When this list has length \> 1, this is referred to as the "overlapping remove" case.
127
- */
128
- removedClientIds: number[];
102
+ removes: RemoveOperationStamp[];
129
103
  }
130
104
  /**
131
105
  * Converts a segment-like object to a removal info object if possible.
@@ -133,7 +107,7 @@ export interface IRemovalInfo {
133
107
  * @param segmentLike - The segment-like object to convert.
134
108
  * @returns The removal info object if the conversion is possible, otherwise undefined.
135
109
  */
136
- export declare const toRemovalInfo: (segmentLike: unknown) => IRemovalInfo | undefined;
110
+ export declare const toRemovalInfo: (segmentLike: unknown) => IHasRemovalInfo | undefined;
137
111
  /**
138
112
  * A type-guard which determines if the segment has removal info, and
139
113
  * returns true if it does, along with applying strong typing.
@@ -141,14 +115,14 @@ export declare const toRemovalInfo: (segmentLike: unknown) => IRemovalInfo | und
141
115
  * @param segmentLike - The segment-like object to check.
142
116
  * @returns True if the segment has removal info, otherwise false.
143
117
  */
144
- export declare const isRemoved: (segmentLike: unknown) => segmentLike is IRemovalInfo;
118
+ export declare const isRemoved: (segmentLike: unknown) => segmentLike is IHasRemovalInfo;
145
119
  /**
146
120
  * Asserts that the segment has removal info. Usage of this function should not produce a user facing error.
147
121
  *
148
122
  * @param segmentLike - The segment-like object to check.
149
123
  * @throws Will throw an error if the segment does not have removal info.
150
124
  */
151
- export declare const assertRemoved: <T extends Partial<IRemovalInfo> | undefined>(segmentLike: ISegmentInternal | Partial<IRemovalInfo> | T) => asserts segmentLike is IRemovalInfo | Exclude<T, Partial<IRemovalInfo>>;
125
+ export declare const assertRemoved: <T extends Partial<IHasRemovalInfo> | undefined>(segmentLike: ISegmentInternal | Partial<IHasRemovalInfo> | T) => asserts segmentLike is IHasRemovalInfo | Exclude<T, Partial<IHasRemovalInfo>>;
152
126
  /**
153
127
  * Removes the removal info. This is used in rollback.
154
128
  * @param segmentLike - The segment-like object to check.
@@ -156,62 +130,9 @@ export declare const assertRemoved: <T extends Partial<IRemovalInfo> | undefined
156
130
  * ensures no further usage of the removed removal info is allowed. if continued use is required other
157
131
  * type coercion methods should be use to correctly re-type the variable.
158
132
  */
159
- export declare const removeRemovalInfo: (nodeLike: IRemovalInfo) => asserts nodeLike is never;
160
- /**
161
- * Tracks information about when and where this segment was moved to.
162
- *
163
- * Note that merge-tree does not currently support moving and only supports
164
- * obliterate. The fields below include "move" in their names to avoid renaming
165
- * in the future, when moves _are_ supported.
166
- */
167
- export interface IMoveInfo {
168
- /**
169
- * Local seq at which this segment was moved if the move is yet-to-be
170
- * acked.
171
- */
172
- localMovedSeq?: number;
173
- /**
174
- * The first seq at which this segment was moved.
175
- */
176
- movedSeq: number;
177
- /**
178
- * All seqs at which this segment was moved. In the case of overlapping,
179
- * concurrent moves this array will contain multiple seqs.
180
- *
181
- * The seq at `movedSeqs[i]` corresponds to the client id at `movedClientIds[i]`.
182
- *
183
- * The first element corresponds to the seq of the first move
184
- */
185
- movedSeqs: number[];
186
- /**
187
- * A reference to the inserted destination segment corresponding to this
188
- * segment's move.
189
- *
190
- * If undefined, the move was an obliterate.
191
- *
192
- * Currently this field is unused, as we only support obliterate operations
193
- */
194
- moveDst?: ReferencePosition;
195
- /**
196
- * List of client IDs that have moved this segment.
197
- *
198
- * The client that actually moved the segment (i.e. whose move op was sequenced
199
- * first) is stored as the first client in this list. Other clients in the
200
- * list have all issued concurrent ops to move the segment.
201
- */
202
- movedClientIds: number[];
203
- }
204
- export declare const toMoveInfo: (segmentLike: unknown) => IMoveInfo | undefined;
205
- /**
206
- * A type-guard which determines if the segment has move info, and
207
- * returns true if it does, along with applying strong typing.
208
- *
209
- * @param segmentLike - The segment-like object to check.
210
- * @returns True if the segment has move info, otherwise false.
211
- */
212
- export declare const isMoved: (segmentLike: unknown) => segmentLike is IMoveInfo;
133
+ export declare const removeRemovalInfo: (nodeLike: IHasRemovalInfo) => asserts nodeLike is never;
213
134
  /**
214
- * Returns whether this segment was marked moved as soon as its insertion was acked.
135
+ * Returns whether this segment was marked removed as soon as its insertion was acked.
215
136
  *
216
137
  * This can happen when an an insert occurs concurrent to an obliterate over the range the segment was inserted into,
217
138
  * and the obliterate was sequenced first.
@@ -219,18 +140,11 @@ export declare const isMoved: (segmentLike: unknown) => segmentLike is IMoveInfo
219
140
  * When this happens, the segment is only ever visible to the client that inserted the segment
220
141
  * (and only until that client has seen the obliterate which removed their segment).
221
142
  */
222
- export declare function wasMovedOnInsert(segment: IInsertionInfo & ISegmentPrivate): boolean;
223
- /**
224
- * Asserts that the segment has move info. Usage of this function should not produce a user facing error.
225
- *
226
- * @param segmentLike - The segment-like object to check.
227
- * @throws Will throw an error if the segment does not have move info.
228
- */
229
- export declare const assertMoved: <T extends Partial<IMoveInfo> | undefined>(segmentLike: ISegmentInternal | Partial<IMoveInfo> | T) => asserts segmentLike is IMoveInfo | Exclude<T, Partial<IMoveInfo>>;
143
+ export declare function wasRemovedOnInsert(segment: IHasInsertionInfo & ISegmentPrivate): boolean;
230
144
  /**
231
145
  * A union type representing any segment info.
232
146
  */
233
- export type SegmentInfo = IMergeNodeInfo | IInsertionInfo | IMoveInfo | IRemovalInfo;
147
+ export type SegmentInfo = IMergeNodeInfo | IHasInsertionInfo | IHasRemovalInfo;
234
148
  /**
235
149
  * A type representing a segment with additional info.
236
150
  */
@@ -1 +1 @@
1
- {"version":3,"file":"segmentInfos.d.ts","sourceRoot":"","sources":["../src/segmentInfos.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACpF,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAEjE,MAAM,WAAW,YAAY;IAC5B,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,EAAE,CAAC;IACZ,SAAS,EAAE,OAAO,CAAC;CACnB;AAED,wBAAgB,UAAU,CAAC,CAAC,SAAS,MAAM,EAC1C,KAAK,EAAE,OAAO,EACd,IAAI,EAAE,CAAC,GACL,KAAK,IAAI,MAAM,CAAC,CAAC,EAAE,OAAO,CAAC,CAE7B;AAED,wBAAgB,OAAO,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,SAAS,MAAM,YAAY,EACrE,KAAK,EAAE,OAAO,EACd,IAAI,EAAE,CAAC,EACP,IAAI,EAAE,CAAC,GACL,KAAK,IAAI,MAAM,CAAC,CAAC,EAAE,YAAY,CAAC,OAAO,IAAI,CAAC,CAAC,CAK/C;AAED,wBAAgB,cAAc,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,EACjD,KAAK,EAAE,OAAO,EACd,IAAI,EAAE,CAAC,EACP,IAAI,EAAE,KAAK,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,CAAC,GAC7B,KAAK,IAAI,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAEvB;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC9B;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAC;IACjB;;;;;;;OAOG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;OAGG;IACH,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Ae,CAAC;AAE/E;;GAEG;AACH,MAAM,MAAM,eAAe,CAC1B,CAAC,SAAS,WAAW,EACrB,CAAC,SAAS,eAAe,GAAG,eAAe,IACxC,CAAC,GAAG,CAAC,CAAC;AAEV;;;;;;GAMG;AACH,eAAO,MAAM,aAAa,oFAIZ,CAAC,QACR,CAAC,KACL,gBAAgB,CAAC,EAAE,CAAC,CAAqC,CAAC"}
@@ -21,9 +21,14 @@ export function propInstanceOf(thing, prop, type) {
21
21
  * @param segmentLike - The segment-like object to convert.
22
22
  * @returns The insertion info object if the conversion is possible, otherwise undefined.
23
23
  */
24
- export const toInsertionInfo = (segmentLike) => hasProp(segmentLike, "clientId", "number") && hasProp(segmentLike, "seq", "number")
25
- ? segmentLike
26
- : undefined;
24
+ export const toInsertionInfo = (segmentLike) => {
25
+ return segmentLike !== undefined &&
26
+ hasProp(segmentLike, "insert", "object") &&
27
+ hasProp(segmentLike.insert, "clientId", "number") &&
28
+ hasProp(segmentLike.insert, "seq", "number")
29
+ ? segmentLike
30
+ : undefined;
31
+ };
27
32
  /**
28
33
  * A type-guard which determines if the segment has insertion info, and
29
34
  * returns true if it does, along with applying strong typing.
@@ -83,10 +88,14 @@ export const removeMergeNodeInfo = (nodeLike) => Object.assign(nodeLike, {
83
88
  * @param segmentLike - The segment-like object to convert.
84
89
  * @returns The removal info object if the conversion is possible, otherwise undefined.
85
90
  */
86
- export const toRemovalInfo = (segmentLike) => hasProp(segmentLike, "removedClientIds", "array") &&
87
- hasProp(segmentLike, "removedSeq", "number")
88
- ? segmentLike
89
- : undefined;
91
+ export const toRemovalInfo = (segmentLike) => {
92
+ return hasProp(segmentLike, "removes", "array") &&
93
+ segmentLike.removes.length > 0 &&
94
+ hasProp(segmentLike.removes[0], "clientId", "number") &&
95
+ hasProp(segmentLike.removes[0], "seq", "number")
96
+ ? segmentLike
97
+ : undefined;
98
+ };
90
99
  /**
91
100
  * A type-guard which determines if the segment has removal info, and
92
101
  * returns true if it does, along with applying strong typing.
@@ -94,6 +103,8 @@ export const toRemovalInfo = (segmentLike) => hasProp(segmentLike, "removedClien
94
103
  * @param segmentLike - The segment-like object to check.
95
104
  * @returns True if the segment has removal info, otherwise false.
96
105
  */
106
+ // export const isRemoved = (segmentLike: unknown): segmentLike is IHasRemovalInfo =>
107
+ // toRemovalInfo(segmentLike) !== undefined;
97
108
  export const isRemoved = (segmentLike) => toRemovalInfo(segmentLike) !== undefined;
98
109
  /**
99
110
  * Asserts that the segment has removal info. Usage of this function should not produce a user facing error.
@@ -110,25 +121,10 @@ export const assertRemoved = (segmentLike) => assert(segmentLike === undefined |
110
121
  * type coercion methods should be use to correctly re-type the variable.
111
122
  */
112
123
  export const removeRemovalInfo = (nodeLike) => Object.assign(nodeLike, {
113
- localRemovedSeq: undefined,
114
- removedClientIds: undefined,
115
- removedSeq: undefined,
124
+ removes: undefined,
116
125
  });
117
- export const toMoveInfo = (segmentLike) => hasProp(segmentLike, "movedClientIds", "array") &&
118
- hasProp(segmentLike, "movedSeq", "number") &&
119
- hasProp(segmentLike, "movedSeqs", "array")
120
- ? segmentLike
121
- : undefined;
122
- /**
123
- * A type-guard which determines if the segment has move info, and
124
- * returns true if it does, along with applying strong typing.
125
- *
126
- * @param segmentLike - The segment-like object to check.
127
- * @returns True if the segment has move info, otherwise false.
128
- */
129
- export const isMoved = (segmentLike) => toMoveInfo(segmentLike) !== undefined;
130
126
  /**
131
- * Returns whether this segment was marked moved as soon as its insertion was acked.
127
+ * Returns whether this segment was marked removed as soon as its insertion was acked.
132
128
  *
133
129
  * This can happen when an an insert occurs concurrent to an obliterate over the range the segment was inserted into,
134
130
  * and the obliterate was sequenced first.
@@ -136,22 +132,15 @@ export const isMoved = (segmentLike) => toMoveInfo(segmentLike) !== undefined;
136
132
  * When this happens, the segment is only ever visible to the client that inserted the segment
137
133
  * (and only until that client has seen the obliterate which removed their segment).
138
134
  */
139
- export function wasMovedOnInsert(segment) {
140
- const moveInfo = toMoveInfo(segment);
141
- const movedSeq = moveInfo?.movedSeq;
142
- if (movedSeq === undefined || movedSeq === UnassignedSequenceNumber) {
135
+ export function wasRemovedOnInsert(segment) {
136
+ const removeInfo = toRemovalInfo(segment);
137
+ const removedSeq = removeInfo?.removes[0].seq;
138
+ if (removedSeq === undefined || removedSeq === UnassignedSequenceNumber) {
143
139
  return false;
144
140
  }
145
- const insertSeq = segment.seq;
146
- return insertSeq === UnassignedSequenceNumber || insertSeq > movedSeq;
141
+ const insertSeq = segment.insert.seq;
142
+ return insertSeq === UnassignedSequenceNumber || insertSeq > removedSeq;
147
143
  }
148
- /**
149
- * Asserts that the segment has move info. Usage of this function should not produce a user facing error.
150
- *
151
- * @param segmentLike - The segment-like object to check.
152
- * @throws Will throw an error if the segment does not have move info.
153
- */
154
- export const assertMoved = (segmentLike) => assert(segmentLike === undefined || isMoved(segmentLike), 0xaa3 /* must be moveInfo */);
155
144
  /**
156
145
  * Overwrites the segment info on a segment-like object.
157
146
  *
@@ -1 +1 @@
1
- {"version":3,"file":"segmentInfos.js","sourceRoot":"","sources":["../src/segmentInfos.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,qCAAqC,CAAC;AAEvE,OAAO,EAAE,wBAAwB,EAAE,MAAM,gBAAgB,CAAC;AAC1D,OAAO,EAAqC,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAWpF,MAAM,UAAU,UAAU,CACzB,KAAc,EACd,IAAO;IAEP,OAAO,QAAQ,CAAC,KAAK,CAAC,IAAI,IAAI,IAAI,KAAK,CAAC;AACzC,CAAC;AAED,MAAM,UAAU,OAAO,CACtB,KAAc,EACd,IAAO,EACP,IAAO;IAEP,OAAO,CACN,UAAU,CAAC,KAAK,EAAE,IAAI,CAAC;QACvB,CAAC,IAAI,KAAK,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,KAAK,CAAC,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AC,WAAW,EAAE,gBAAgB,EAAE,OAAO,CAAC;IAC/C,OAAO,CAAC,WAAW,EAAE,UAAU,EAAE,QAAQ,CAAC;IAC1C,OAAO,CAAC,WAAW,EAAE,WAAW,EAAE,OAAO,CAAC;IACzC,CAAC,CAAC,WAAW;IACb,CAAC,CAAC,SAAS,CAAC;AAEd;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG,CAAC,WAAoB,EAA4B,EAAE,CACzE,UAAU,CAAC,WAAW,CAAC,KAAK,SAAS,CAAC;AAEvC;;;;;;;;GAQG;AACH,MAAM,UAAU,gBAAgB,CAAC,OAAyC;IACzE,MAAM,QAAQ,GAAG,UAAU,CAAC,OAAO,CAAC,CAAC;IACrC,MAAM,QAAQ,GAAG,QAAQ,EAAE,QAAQ,CAAC;IACpC,IAAI,QAAQ,KAAK,SAAS,IAAI,QAAQ,KAAK,wBAAwB,EAAE,CAAC;QACrE,OAAO,KAAK,CAAC;IACd,CAAC;IAED,MAAM,SAAS,GAAG,OAAO,CAAC,GAAG,CAAC;IAC9B,OAAO,SAAS,KAAK,wBAAwB,IAAI,SAAS,GAAG,QAAQ,CAAC;AACvE,CAAC;AAED;;;;;GAKG;AACH,MAAM,CAAC,MAAM,WAAW,GAEiD,CAAC,WAAW,EAAE,EAAE,CACxF,MAAM,CAAC,WAAW,KAAK,SAAS,IAAI,OAAO,CAAC,WAAW,CAAC,EAAE,KAAK,CAAC,sBAAsB,CAAC,CAAC;AAezF;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,CAI5B,WAAc,EACd,IAAO,EACiB,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,WAAW,EAAE,IAAI,CAAC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, isObject } from \"@fluidframework/core-utils/internal\";\n\nimport { UnassignedSequenceNumber } from \"./constants.js\";\nimport { ISegmentInternal, ISegmentPrivate, MergeBlock } from \"./mergeTreeNodes.js\";\nimport type { ReferencePosition } from \"./referencePositions.js\";\n\nexport interface StringToType {\n\t\"string\": string;\n\t\"number\": number;\n\t\"object\": object;\n\t\"array\": [];\n\t\"boolean\": boolean;\n}\n\nexport function propExists<P extends string>(\n\tthing: unknown,\n\tprop: P,\n): thing is Record<P, unknown> {\n\treturn isObject(thing) && prop in thing;\n}\n\nexport function hasProp<P extends string, T extends keyof StringToType>(\n\tthing: unknown,\n\tprop: P,\n\ttype: T,\n): thing is Record<P, StringToType[typeof type]> {\n\treturn (\n\t\tpropExists(thing, prop) &&\n\t\t(type === \"array\" ? Array.isArray(thing[prop]) : typeof thing[prop] === type)\n\t);\n}\n\nexport function propInstanceOf<P extends string, T>(\n\tthing: unknown,\n\tprop: P,\n\ttype: new (...args: any[]) => T,\n): thing is Record<P, T> {\n\treturn propExists(thing, prop) && thing[prop] instanceof type;\n}\n\n/**\n * Contains insertion information associated to an {@link ISegment}.\n */\nexport interface IInsertionInfo {\n\t/**\n\t * Short clientId for the client that inserted this segment.\n\t */\n\tclientId: number;\n\t/**\n\t * Local seq at which this segment was inserted.\n\t * This is defined if and only if the insertion of the segment is pending ack, i.e. `seq` is UnassignedSequenceNumber.\n\t * Once the segment is acked, this field is cleared.\n\t *\n\t * @privateRemarks\n\t * See {@link CollaborationWindow.localSeq} for more information on the semantics of localSeq.\n\t */\n\tlocalSeq?: number;\n\t/**\n\t * Seq at which this segment was inserted.\n\t * If undefined, it is assumed the segment was inserted prior to the collab window's minimum sequence number.\n\t */\n\tseq: number;\n}\n\n/**\n * Converts a segment-like object to an insertion info object if possible.\n *\n * @param segmentLike - The segment-like object to convert.\n * @returns The insertion info object if the conversion is possible, otherwise undefined.\n */\nexport const toInsertionInfo = (segmentLike: unknown): IInsertionInfo | undefined =>\n\thasProp(segmentLike, \"clientId\", \"number\") && hasProp(segmentLike, \"seq\", \"number\")\n\t\t? segmentLike\n\t\t: undefined;\n\n/**\n * A type-guard which determines if the segment has insertion info, and\n * returns true if it does, along with applying strong typing.\n *\n * @param segmentLike - The segment-like object to check.\n * @returns True if the segment has insertion info, otherwise false.\n */\nexport const isInserted = (segmentLike: unknown): segmentLike is IInsertionInfo =>\n\ttoInsertionInfo(segmentLike) !== undefined;\n\n/**\n * Asserts that the segment has insertion info. 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 does not have insertion info.\n */\nexport const assertInserted: <T extends Partial<IInsertionInfo> | undefined>(\n\tsegmentLike: ISegmentInternal | Partial<IInsertionInfo> | T,\n) => asserts segmentLike is IInsertionInfo | Exclude<T, Partial<IInsertionInfo>> = (\n\tsegmentLike,\n) =>\n\tassert(\n\t\tsegmentLike === undefined || isInserted(segmentLike),\n\t\t0xaa0 /* must be insertionInfo */,\n\t);\n\n/**\n * Common properties for a node in a merge tree.\n */\nexport interface IMergeNodeInfo {\n\t/**\n\t * The parent merge block if the node is parented\n\t */\n\tparent: MergeBlock;\n\n\t/**\n\t * The index of this node in its parent's list of children.\n\t */\n\tindex: number;\n\n\t/**\n\t * A string that can be used for comparing the location of this node to other `MergeNode`s in the same tree.\n\t * `a.ordinal < b.ordinal` if and only if `a` comes before `b` in a pre-order traversal of the tree.\n\t */\n\tordinal: string;\n}\n\n/**\n * Converts a segment-like object to a merge node info object if possible.\n *\n * @param segmentLike - The segment-like object to convert.\n * @returns The merge node info object if the conversion is possible, otherwise undefined.\n */\nexport const toMergeNodeInfo = (nodeLike: unknown): IMergeNodeInfo | undefined =>\n\tpropInstanceOf(nodeLike, \"parent\", MergeBlock) &&\n\thasProp(nodeLike, \"ordinal\", \"string\") &&\n\thasProp(nodeLike, \"index\", \"number\")\n\t\t? nodeLike\n\t\t: undefined;\n\n/**\n * A type-guard which determines if the segment has merge node info, and\n * returns true if it does, along with applying strong typing.\n *\n * @param nodeLike - The segment-like object to check.\n * @returns True if the segment has merge node info, otherwise false.\n */\nexport const isMergeNodeInfo = (nodeLike: unknown): nodeLike is IMergeNodeInfo =>\n\ttoMergeNodeInfo(nodeLike) !== undefined;\n\n/**\n * Asserts that the segment has merge node info. 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 does not have merge node info.\n */\nexport const assertMergeNode: <T extends Partial<IMergeNodeInfo> | undefined>(\n\tnodeLike: ISegmentInternal | ISegmentPrivate | Partial<IMergeNodeInfo> | T,\n) => asserts nodeLike is IMergeNodeInfo | Exclude<T, Partial<IMergeNodeInfo>> = (\n\tsegmentLike,\n) =>\n\tassert(\n\t\tsegmentLike === undefined || isMergeNodeInfo(segmentLike),\n\t\t0xaa1 /* must be MergeNodeInfo */,\n\t);\n\n/**\n * Removes the merge node info. This is used to remove nodes from the merge-tree.\n * @param segmentLike - The segment-like object to check.\n * @returns This function will change the type of the provided node like to never via an assertion. This\n * ensures no further usage of the removed merge node info is allowed. if continued use is required other\n * type coercion methods should be used to correctly re-type the variable.\n */\nexport const removeMergeNodeInfo: (nodeLike: IMergeNodeInfo) => asserts nodeLike is never = (\n\tnodeLike,\n) =>\n\tObject.assign<IMergeNodeInfo, Record<keyof IMergeNodeInfo, undefined>>(nodeLike, {\n\t\tparent: undefined,\n\t\tindex: undefined,\n\t\tordinal: undefined,\n\t});\n\n/**\n * Contains removal information associated to an {@link ISegment}.\n */\nexport interface IRemovalInfo {\n\t/**\n\t * Local seq at which this segment was removed, if the removal is yet-to-be acked.\n\t */\n\tlocalRemovedSeq?: number;\n\t/**\n\t * Seq at which this segment was removed.\n\t */\n\tremovedSeq: number;\n\t/**\n\t * List of client IDs that have removed this segment.\n\t * The client that actually removed the segment (i.e. whose removal op was sequenced first) is stored as the first\n\t * client in this list. Other clients in the list have all issued concurrent ops to remove the segment.\n\t * @remarks When this list has length \\> 1, this is referred to as the \"overlapping remove\" case.\n\t */\n\tremovedClientIds: number[];\n}\n\n/**\n * Converts a segment-like object to a removal info object if possible.\n *\n * @param segmentLike - The segment-like object to convert.\n * @returns The removal info object if the conversion is possible, otherwise undefined.\n */\nexport const toRemovalInfo = (segmentLike: unknown): IRemovalInfo | undefined =>\n\thasProp(segmentLike, \"removedClientIds\", \"array\") &&\n\thasProp(segmentLike, \"removedSeq\", \"number\")\n\t\t? segmentLike\n\t\t: undefined;\n\n/**\n * A type-guard which determines if the segment has removal info, and\n * returns true if it does, along with applying strong typing.\n *\n * @param segmentLike - The segment-like object to check.\n * @returns True if the segment has removal info, otherwise false.\n */\nexport const isRemoved = (segmentLike: unknown): segmentLike is IRemovalInfo =>\n\ttoRemovalInfo(segmentLike) !== undefined;\n\n/**\n * Asserts that the segment has removal info. 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 does not have removal info.\n */\nexport const assertRemoved: <T extends Partial<IRemovalInfo> | undefined>(\n\tsegmentLike: ISegmentInternal | Partial<IRemovalInfo> | T,\n) => asserts segmentLike is IRemovalInfo | Exclude<T, Partial<IRemovalInfo>> = (segmentLike) =>\n\tassert(segmentLike === undefined || isRemoved(segmentLike), 0xaa2 /* must be removalInfo */);\n\n/**\n * Removes the removal info. This is used in rollback.\n * @param segmentLike - The segment-like object to check.\n * @returns This function will change the type of the provided node like to never via an assertion. This\n * ensures no further usage of the removed removal info is allowed. if continued use is required other\n * type coercion methods should be use to correctly re-type the variable.\n */\nexport const removeRemovalInfo: (nodeLike: IRemovalInfo) => asserts nodeLike is never = (\n\tnodeLike,\n) =>\n\tObject.assign<IRemovalInfo, Record<keyof IRemovalInfo, undefined>>(nodeLike, {\n\t\tlocalRemovedSeq: undefined,\n\t\tremovedClientIds: undefined,\n\t\tremovedSeq: undefined,\n\t});\n\n/**\n * Tracks information about when and where this segment was moved to.\n *\n * Note that merge-tree does not currently support moving and only supports\n * obliterate. The fields below include \"move\" in their names to avoid renaming\n * in the future, when moves _are_ supported.\n */\nexport interface IMoveInfo {\n\t/**\n\t * Local seq at which this segment was moved if the move is yet-to-be\n\t * acked.\n\t */\n\tlocalMovedSeq?: number;\n\n\t/**\n\t * The first seq at which this segment was moved.\n\t */\n\tmovedSeq: number;\n\n\t/**\n\t * All seqs at which this segment was moved. In the case of overlapping,\n\t * concurrent moves this array will contain multiple seqs.\n\t *\n\t * The seq at `movedSeqs[i]` corresponds to the client id at `movedClientIds[i]`.\n\t *\n\t * The first element corresponds to the seq of the first move\n\t */\n\tmovedSeqs: number[];\n\n\t/**\n\t * A reference to the inserted destination segment corresponding to this\n\t * segment's move.\n\t *\n\t * If undefined, the move was an obliterate.\n\t *\n\t * Currently this field is unused, as we only support obliterate operations\n\t */\n\tmoveDst?: ReferencePosition;\n\n\t/**\n\t * List of client IDs that have moved this segment.\n\t *\n\t * The client that actually moved the segment (i.e. whose move op was sequenced\n\t * first) is stored as the first client in this list. Other clients in the\n\t * list have all issued concurrent ops to move the segment.\n\t */\n\tmovedClientIds: number[];\n}\n\nexport const toMoveInfo = (segmentLike: unknown): IMoveInfo | undefined =>\n\thasProp(segmentLike, \"movedClientIds\", \"array\") &&\n\thasProp(segmentLike, \"movedSeq\", \"number\") &&\n\thasProp(segmentLike, \"movedSeqs\", \"array\")\n\t\t? segmentLike\n\t\t: undefined;\n\n/**\n * A type-guard which determines if the segment has move info, and\n * returns true if it does, along with applying strong typing.\n *\n * @param segmentLike - The segment-like object to check.\n * @returns True if the segment has move info, otherwise false.\n */\nexport const isMoved = (segmentLike: unknown): segmentLike is IMoveInfo =>\n\ttoMoveInfo(segmentLike) !== undefined;\n\n/**\n * Returns whether this segment was marked moved as soon as its insertion was acked.\n *\n * This can happen when an an insert occurs concurrent to an obliterate over the range the segment was inserted into,\n * and the obliterate was sequenced first.\n *\n * When this happens, the segment is only ever visible to the client that inserted the segment\n * (and only until that client has seen the obliterate which removed their segment).\n */\nexport function wasMovedOnInsert(segment: IInsertionInfo & ISegmentPrivate): boolean {\n\tconst moveInfo = toMoveInfo(segment);\n\tconst movedSeq = moveInfo?.movedSeq;\n\tif (movedSeq === undefined || movedSeq === UnassignedSequenceNumber) {\n\t\treturn false;\n\t}\n\n\tconst insertSeq = segment.seq;\n\treturn insertSeq === UnassignedSequenceNumber || insertSeq > movedSeq;\n}\n\n/**\n * Asserts that the segment has move info. 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 does not have move info.\n */\nexport const assertMoved: <T extends Partial<IMoveInfo> | undefined>(\n\tsegmentLike: ISegmentInternal | Partial<IMoveInfo> | T,\n) => asserts segmentLike is IMoveInfo | Exclude<T, Partial<IMoveInfo>> = (segmentLike) =>\n\tassert(segmentLike === undefined || isMoved(segmentLike), 0xaa3 /* must be moveInfo */);\n\n/**\n * A union type representing any segment info.\n */\nexport type SegmentInfo = IMergeNodeInfo | IInsertionInfo | IMoveInfo | IRemovalInfo;\n\n/**\n * A type representing a segment with additional info.\n */\nexport type SegmentWithInfo<\n\tT extends SegmentInfo,\n\tS extends ISegmentPrivate = ISegmentPrivate,\n> = S & T;\n\n/**\n * Overwrites the segment info on a segment-like object.\n *\n * @param segmentLike - The segment-like object to set the info on.\n * @param info - The segment info to overwrite.\n * @returns The segment-like object with the info set.\n */\nexport const overwriteInfo = <\n\tT extends SegmentInfo,\n\tS extends ISegmentPrivate = ISegmentPrivate,\n>(\n\tsegmentLike: S,\n\tinfo: T,\n): SegmentWithInfo<T, S> => Object.assign(segmentLike, info);\n"]}
1
+ {"version":3,"file":"segmentInfos.js","sourceRoot":"","sources":["../src/segmentInfos.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,qCAAqC,CAAC;AAEvE,OAAO,EAAE,wBAAwB,EAAE,MAAM,gBAAgB,CAAC;AAC1D,OAAO,EAAqC,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAWpF,MAAM,UAAU,UAAU,CACzB,KAAc,EACd,IAAO;IAEP,OAAO,QAAQ,CAAC,KAAK,CAAC,IAAI,IAAI,IAAI,KAAK,CAAC;AACzC,CAAC;AAED,MAAM,UAAU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AAM,SAAS,GAAG,CAAC,WAAoB,EAAkC,EAAE,CACjF,aAAa,CAAC,WAAW,CAAC,KAAK,SAAS,CAAC;AAE1C;;;;;GAKG;AACH,MAAM,CAAC,MAAM,aAAa,GAE2D,CACpF,WAAW,EACV,EAAE,CACH,MAAM,CAAC,WAAW,KAAK,SAAS,IAAI,SAAS,CAAC,WAAW,CAAC,EAAE,KAAK,CAAC,yBAAyB,CAAC,CAAC;AAE9F;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAA6D,CAC1F,QAAQ,EACP,EAAE,CACH,MAAM,CAAC,MAAM,CAA4D,QAAQ,EAAE;IAClF,OAAO,EAAE,SAAS;CAClB,CAAC,CAAC;AAEJ;;;;;;;;GAQG;AACH,MAAM,UAAU,kBAAkB,CAAC,OAA4C;IAC9E,MAAM,UAAU,GAAG,aAAa,CAAC,OAAO,CAAC,CAAC;IAC1C,MAAM,UAAU,GAAG,UAAU,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC;IAC9C,IAAI,UAAU,KAAK,SAAS,IAAI,UAAU,KAAK,wBAAwB,EAAE,CAAC;QACzE,OAAO,KAAK,CAAC;IACd,CAAC;IAED,MAAM,SAAS,GAAG,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC;IACrC,OAAO,SAAS,KAAK,wBAAwB,IAAI,SAAS,GAAG,UAAU,CAAC;AACzE,CAAC;AAeD;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,CAI5B,WAAc,EACd,IAAO,EACiB,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,WAAW,EAAE,IAAI,CAAC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, isObject } from \"@fluidframework/core-utils/internal\";\n\nimport { UnassignedSequenceNumber } from \"./constants.js\";\nimport { ISegmentInternal, ISegmentPrivate, MergeBlock } from \"./mergeTreeNodes.js\";\nimport type { InsertOperationStamp, RemoveOperationStamp } from \"./stamps.js\";\n\nexport interface StringToType {\n\t\"string\": string;\n\t\"number\": number;\n\t\"object\": object;\n\t\"array\": unknown[];\n\t\"boolean\": boolean;\n}\n\nexport function propExists<P extends string>(\n\tthing: unknown,\n\tprop: P,\n): thing is Record<P, unknown> {\n\treturn isObject(thing) && prop in thing;\n}\n\nexport function hasProp<P extends string, T extends keyof StringToType>(\n\tthing: unknown,\n\tprop: P,\n\ttype: T,\n): thing is Record<P, StringToType[typeof type]> {\n\treturn (\n\t\tpropExists(thing, prop) &&\n\t\t(type === \"array\" ? Array.isArray(thing[prop]) : typeof thing[prop] === type)\n\t);\n}\n\nexport function propInstanceOf<P extends string, T>(\n\tthing: unknown,\n\tprop: P,\n\ttype: new (...args: any[]) => T,\n): thing is Record<P, T> {\n\treturn propExists(thing, prop) && thing[prop] instanceof type;\n}\n\n/**\n * Contains insertion information associated to an {@link ISegment}.\n */\nexport interface IHasInsertionInfo {\n\tinsert: InsertOperationStamp;\n}\n\n/**\n * Converts a segment-like object to an insertion info object if possible.\n *\n * @param segmentLike - The segment-like object to convert.\n * @returns The insertion info object if the conversion is possible, otherwise undefined.\n */\nexport const toInsertionInfo = (segmentLike: unknown): IHasInsertionInfo | undefined => {\n\treturn segmentLike !== undefined &&\n\t\thasProp(segmentLike, \"insert\", \"object\") &&\n\t\thasProp(segmentLike.insert, \"clientId\", \"number\") &&\n\t\thasProp(segmentLike.insert, \"seq\", \"number\")\n\t\t? (segmentLike as IHasInsertionInfo)\n\t\t: undefined;\n};\n\n/**\n * A type-guard which determines if the segment has insertion info, and\n * returns true if it does, along with applying strong typing.\n *\n * @param segmentLike - The segment-like object to check.\n * @returns True if the segment has insertion info, otherwise false.\n */\nexport const isInserted = (segmentLike: unknown): segmentLike is IHasInsertionInfo =>\n\ttoInsertionInfo(segmentLike) !== undefined;\n\n/**\n * Asserts that the segment has insertion info. 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 does not have insertion info.\n */\nexport const assertInserted: <T extends Partial<IHasInsertionInfo> | undefined>(\n\tsegmentLike: ISegmentInternal | Partial<IHasInsertionInfo> | T,\n) => asserts segmentLike is IHasInsertionInfo | Exclude<T, Partial<IHasInsertionInfo>> = (\n\tsegmentLike,\n) =>\n\tassert(\n\t\tsegmentLike === undefined || isInserted(segmentLike),\n\t\t0xaa0 /* must be insertionInfo */,\n\t);\n\n/**\n * Common properties for a node in a merge tree.\n */\nexport interface IMergeNodeInfo {\n\t/**\n\t * The parent merge block if the node is parented\n\t */\n\tparent: MergeBlock;\n\n\t/**\n\t * The index of this node in its parent's list of children.\n\t */\n\tindex: number;\n\n\t/**\n\t * A string that can be used for comparing the location of this node to other `MergeNode`s in the same tree.\n\t * `a.ordinal < b.ordinal` if and only if `a` comes before `b` in a pre-order traversal of the tree.\n\t */\n\tordinal: string;\n}\n\n/**\n * Converts a segment-like object to a merge node info object if possible.\n *\n * @param segmentLike - The segment-like object to convert.\n * @returns The merge node info object if the conversion is possible, otherwise undefined.\n */\nexport const toMergeNodeInfo = (nodeLike: unknown): IMergeNodeInfo | undefined =>\n\tpropInstanceOf(nodeLike, \"parent\", MergeBlock) &&\n\thasProp(nodeLike, \"ordinal\", \"string\") &&\n\thasProp(nodeLike, \"index\", \"number\")\n\t\t? nodeLike\n\t\t: undefined;\n\n/**\n * A type-guard which determines if the segment has merge node info, and\n * returns true if it does, along with applying strong typing.\n *\n * @param nodeLike - The segment-like object to check.\n * @returns True if the segment has merge node info, otherwise false.\n */\nexport const isMergeNodeInfo = (nodeLike: unknown): nodeLike is IMergeNodeInfo =>\n\ttoMergeNodeInfo(nodeLike) !== undefined;\n\n/**\n * Asserts that the segment has merge node info. 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 does not have merge node info.\n */\nexport const assertMergeNode: <T extends Partial<IMergeNodeInfo> | undefined>(\n\tnodeLike: ISegmentInternal | ISegmentPrivate | Partial<IMergeNodeInfo> | T,\n) => asserts nodeLike is IMergeNodeInfo | Exclude<T, Partial<IMergeNodeInfo>> = (\n\tsegmentLike,\n) =>\n\tassert(\n\t\tsegmentLike === undefined || isMergeNodeInfo(segmentLike),\n\t\t0xaa1 /* must be MergeNodeInfo */,\n\t);\n\n/**\n * Removes the merge node info. This is used to remove nodes from the merge-tree.\n * @param segmentLike - The segment-like object to check.\n * @returns This function will change the type of the provided node like to never via an assertion. This\n * ensures no further usage of the removed merge node info is allowed. if continued use is required other\n * type coercion methods should be used to correctly re-type the variable.\n */\nexport const removeMergeNodeInfo: (nodeLike: IMergeNodeInfo) => asserts nodeLike is never = (\n\tnodeLike,\n) =>\n\tObject.assign<IMergeNodeInfo, Record<keyof IMergeNodeInfo, undefined>>(nodeLike, {\n\t\tparent: undefined,\n\t\tindex: undefined,\n\t\tordinal: undefined,\n\t});\n\n/**\n * Contains removal information associated with an {@link ISegment}.\n *\n * Segments can be removed concurrently by multiple clients.\n */\nexport interface IHasRemovalInfo {\n\t/**\n\t * Operation stamps which have removed this segment. This list is sorted by stamp order, where removes[0] is the earliest removal.\n\t */\n\tremoves: RemoveOperationStamp[];\n}\n\n/**\n * Converts a segment-like object to a removal info object if possible.\n *\n * @param segmentLike - The segment-like object to convert.\n * @returns The removal info object if the conversion is possible, otherwise undefined.\n */\nexport const toRemovalInfo = (segmentLike: unknown): IHasRemovalInfo | undefined => {\n\treturn hasProp(segmentLike, \"removes\", \"array\") &&\n\t\tsegmentLike.removes.length > 0 &&\n\t\thasProp(segmentLike.removes[0], \"clientId\", \"number\") &&\n\t\thasProp(segmentLike.removes[0], \"seq\", \"number\")\n\t\t? (segmentLike as IHasRemovalInfo)\n\t\t: undefined;\n};\n\n/**\n * A type-guard which determines if the segment has removal info, and\n * returns true if it does, along with applying strong typing.\n *\n * @param segmentLike - The segment-like object to check.\n * @returns True if the segment has removal info, otherwise false.\n */\n// export const isRemoved = (segmentLike: unknown): segmentLike is IHasRemovalInfo =>\n// \ttoRemovalInfo(segmentLike) !== undefined;\n\nexport const isRemoved = (segmentLike: unknown): segmentLike is IHasRemovalInfo =>\n\ttoRemovalInfo(segmentLike) !== undefined;\n\n/**\n * Asserts that the segment has removal info. 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 does not have removal info.\n */\nexport const assertRemoved: <T extends Partial<IHasRemovalInfo> | undefined>(\n\tsegmentLike: ISegmentInternal | Partial<IHasRemovalInfo> | T,\n) => asserts segmentLike is IHasRemovalInfo | Exclude<T, Partial<IHasRemovalInfo>> = (\n\tsegmentLike,\n) =>\n\tassert(segmentLike === undefined || isRemoved(segmentLike), 0xaa2 /* must be removalInfo */);\n\n/**\n * Removes the removal info. This is used in rollback.\n * @param segmentLike - The segment-like object to check.\n * @returns This function will change the type of the provided node like to never via an assertion. This\n * ensures no further usage of the removed removal info is allowed. if continued use is required other\n * type coercion methods should be use to correctly re-type the variable.\n */\nexport const removeRemovalInfo: (nodeLike: IHasRemovalInfo) => asserts nodeLike is never = (\n\tnodeLike,\n) =>\n\tObject.assign<IHasRemovalInfo, Record<keyof IHasRemovalInfo, undefined>>(nodeLike, {\n\t\tremoves: undefined,\n\t});\n\n/**\n * Returns whether this segment was marked removed as soon as its insertion was acked.\n *\n * This can happen when an an insert occurs concurrent to an obliterate over the range the segment was inserted into,\n * and the obliterate was sequenced first.\n *\n * When this happens, the segment is only ever visible to the client that inserted the segment\n * (and only until that client has seen the obliterate which removed their segment).\n */\nexport function wasRemovedOnInsert(segment: IHasInsertionInfo & ISegmentPrivate): boolean {\n\tconst removeInfo = toRemovalInfo(segment);\n\tconst removedSeq = removeInfo?.removes[0].seq;\n\tif (removedSeq === undefined || removedSeq === UnassignedSequenceNumber) {\n\t\treturn false;\n\t}\n\n\tconst insertSeq = segment.insert.seq;\n\treturn insertSeq === UnassignedSequenceNumber || insertSeq > removedSeq;\n}\n\n/**\n * A union type representing any segment info.\n */\nexport type SegmentInfo = IMergeNodeInfo | IHasInsertionInfo | IHasRemovalInfo;\n\n/**\n * A type representing a segment with additional info.\n */\nexport type SegmentWithInfo<\n\tT extends SegmentInfo,\n\tS extends ISegmentPrivate = ISegmentPrivate,\n> = S & T;\n\n/**\n * Overwrites the segment info on a segment-like object.\n *\n * @param segmentLike - The segment-like object to set the info on.\n * @param info - The segment info to overwrite.\n * @returns The segment-like object with the info set.\n */\nexport const overwriteInfo = <\n\tT extends SegmentInfo,\n\tS extends ISegmentPrivate = ISegmentPrivate,\n>(\n\tsegmentLike: S,\n\tinfo: T,\n): SegmentWithInfo<T, S> => Object.assign(segmentLike, info);\n"]}
@@ -4,19 +4,6 @@
4
4
  */
5
5
  import type { IMergeTreeAnnotateAdjustMsg, IMergeTreeAnnotateMsg } from "./ops.js";
6
6
  import { MapLike, PropertySet } from "./properties.js";
7
- /**
8
- * @internal
9
- */
10
- export declare enum PropertiesRollback {
11
- /**
12
- * Not in a rollback
13
- */
14
- None = 0,
15
- /**
16
- * Rollback
17
- */
18
- Rollback = 1
19
- }
20
7
  /**
21
8
  * Minimally copies properties and the property manager from source to destination.
22
9
  * @internal
@@ -69,7 +56,7 @@ export declare class PropertiesManager {
69
56
  */
70
57
  handleProperties(op: PropsOrAdjust, seg: {
71
58
  properties?: MapLike<unknown>;
72
- }, seq: number, msn: number, collaborating?: boolean, rollback?: PropertiesRollback): MapLike<unknown>;
59
+ }, seq: number, msn: number, collaborating?: boolean, rollback?: boolean): MapLike<unknown>;
73
60
  /**
74
61
  * Acknowledges property changes.
75
62
  * This method acknowledges the property changes based on the provided sequence number and operation.
@@ -1 +1 @@
1
- {"version":3,"file":"segmentPropertiesManager.d.ts","sourceRoot":"","sources":["../src/segmentPropertiesManager.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAMH,OAAO,KAAK,EAEX,2BAA2B,EAC3B,qBAAqB,EACrB,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,OAAO,EAAE,WAAW,EAAoB,MAAM,iBAAiB,CAAC;AA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OAAO,CAAC,OAAO,CAAC,CAAA;KAAE,EACtC,aAAa,GAAE,OAAe,GAC5B,OAAO,CAAC,OAAO,CAAC;IA+BnB;;;;;;;;;;;;OAYG;IACI,gBAAgB,CACtB,EAAE,EAAE,aAAa,EACjB,GAAG,EAAE;QAAE,UAAU,CAAC,EAAE,OAAO,CAAC,OAAO,CAAC,CAAA;KAAE,EACtC,GAAG,EAAE,MAAM,EACX,GAAG,EAAE,MAAM,EACX,aAAa,GAAE,OAAe,EAC9B,QAAQ,GAAE,OAAe,GACvB,OAAO,CAAC,OAAO,CAAC;IA6CnB;;;;;;;OAOG;IACI,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,EAAE,EAAE,aAAa,GAAG,IAAI;IAqB7D;;;;;OAKG;IACI,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;IAkBnC;;;;;;OAMG;IACI,MAAM,CACZ,QAAQ,EAAE,WAAW,GAAG,SAAS,EACjC,IAAI,EAAE;QACL,UAAU,CAAC,EAAE,WAAW,CAAC;QACzB,eAAe,CAAC,EAAE,iBAAiB,CAAC;KACpC,GACC,IAAI;IAYP;;;;;;;;;OASG;IACI,QAAQ,CACd,QAAQ,EAAE,OAAO,CAAC,OAAO,CAAC,GAAG,SAAS,EACtC,cAAc,EAAE,MAAM,GACpB,OAAO,CAAC,OAAO,CAAC;IAenB;;;;;OAKG;IACI,oBAAoB,CAAC,KAAK,EAAE,WAAW,GAAG,OAAO;CAQxD"}
@@ -6,20 +6,6 @@ import { assert } from "@fluidframework/core-utils/internal";
6
6
  import { DoublyLinkedList, iterateListValuesWhile } from "./collections/index.js";
7
7
  import { UnassignedSequenceNumber, UniversalSequenceNumber } from "./constants.js";
8
8
  import { clone, createMap } from "./properties.js";
9
- /**
10
- * @internal
11
- */
12
- export var PropertiesRollback;
13
- (function (PropertiesRollback) {
14
- /**
15
- * Not in a rollback
16
- */
17
- PropertiesRollback[PropertiesRollback["None"] = 0] = "None";
18
- /**
19
- * Rollback
20
- */
21
- PropertiesRollback[PropertiesRollback["Rollback"] = 1] = "Rollback";
22
- })(PropertiesRollback || (PropertiesRollback = {}));
23
9
  /**
24
10
  * Minimally copies properties and the property manager from source to destination.
25
11
  * @internal
@@ -135,8 +121,8 @@ export class PropertiesManager {
135
121
  * @param rollback - Specifies if the changes should be rolled back. Defaults to PropertiesRollback.None.
136
122
  * @returns The deltas of the applied or rolled-back properties. This is a map-like object representing the changes.
137
123
  */
138
- handleProperties(op, seg, seq, msn, collaborating = false, rollback = PropertiesRollback.None) {
139
- if (rollback === PropertiesRollback.Rollback) {
124
+ handleProperties(op, seg, seq, msn, collaborating = false, rollback = false) {
125
+ if (rollback) {
140
126
  return this.rollbackProperties(op, seg, collaborating);
141
127
  }
142
128
  const rtn = applyChanges(op, seg, seq, (properties, deltas, key, value) => {
@@ -1 +1 @@
1
- {"version":3,"file":"segmentPropertiesManager.js","sourceRoot":"","sources":["../src/segmentPropertiesManager.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAE7D,OAAO,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AAClF,OAAO,EAAE,wBAAwB,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAC;AAMnF,OAAO,EAAwB,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAEzE;;GAEG;AACH,MAAM,CAAN,IAAY,kBAUX;AAVD,WAAY,kBAAkB;IAC7B;;OAEG;IACH,2DAAI,CAAA;IAEJ;;OAEG;IACH,mEAAQ,CAAA;AACT,CAAC,EAVW,kBAAkB,KAAlB,kBAAkB,QAU7B;AACD;;;GAGG;AACH,MAAM,UAAU,wBAAwB,CACvC,MAGC,EACD,WAGC;IAED,IAAI,MAAM,CAAC,UAAU,EAAE,CAAC;QACvB,IAAI,MAAM,CAAC,eAAe,KAAK,SAAS,EAAE,CAAC;Y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AC;YACxB,CAAC;QACF,CAAC;QACD,OAAO,UAAU,CAAC;IACnB,CAAC;IAED;;;;;OAKG;IACI,oBAAoB,CAAC,KAAkB;QAC7C,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;YAClD,IAAI,KAAK,KAAK,SAAS,IAAI,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,KAAK,CAAC,KAAK,KAAK,KAAK,EAAE,CAAC;gBACzE,OAAO,KAAK,CAAC;YACd,CAAC;QACF,CAAC;QACD,OAAO,IAAI,CAAC;IACb,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\n\nimport { DoublyLinkedList, iterateListValuesWhile } from \"./collections/index.js\";\nimport { UnassignedSequenceNumber, UniversalSequenceNumber } from \"./constants.js\";\nimport type {\n\tAdjustParams,\n\tIMergeTreeAnnotateAdjustMsg,\n\tIMergeTreeAnnotateMsg,\n} from \"./ops.js\";\nimport { MapLike, PropertySet, clone, createMap } from \"./properties.js\";\n\n/**\n * @internal\n */\nexport enum PropertiesRollback {\n\t/**\n\t * Not in a rollback\n\t */\n\tNone,\n\n\t/**\n\t * Rollback\n\t */\n\tRollback,\n}\n/**\n * Minimally copies properties and the property manager from source to destination.\n * @internal\n */\nexport function copyPropertiesAndManager(\n\tsource: {\n\t\tproperties?: PropertySet;\n\t\tpropertyManager?: PropertiesManager;\n\t},\n\tdestination: {\n\t\tproperties?: PropertySet;\n\t\tpropertyManager?: PropertiesManager;\n\t},\n): void {\n\tif (source.properties) {\n\t\tif (source.propertyManager === undefined) {\n\t\t\tdestination.properties = clone(source.properties);\n\t\t} else {\n\t\t\tdestination.propertyManager ??= new PropertiesManager();\n\t\t\tsource.propertyManager.copyTo(source.properties, destination);\n\t\t}\n\t}\n}\n\ntype PropertyChange = {\n\tseq: number;\n} & ({ adjust: AdjustParams; raw?: undefined } | { raw: unknown; adjust?: undefined });\n\ninterface PropertyChanges {\n\tmsnConsensus: unknown;\n\tremote: DoublyLinkedList<PropertyChange>;\n\tlocal: DoublyLinkedList<PropertyChange>;\n}\n\nfunction computePropertyValue(\n\tconsensus: unknown,\n\t...changes: Iterable<PropertyChange>[]\n): unknown {\n\tlet computedValue: unknown = consensus;\n\tfor (const change of changes) {\n\t\tfor (const op of change) {\n\t\t\tconst { raw, adjust } = op;\n\t\t\tif (adjust === undefined) {\n\t\t\t\tcomputedValue = raw;\n\t\t\t} else {\n\t\t\t\tconst adjusted =\n\t\t\t\t\t(typeof computedValue === \"number\" ? computedValue : 0) + adjust.delta;\n\t\t\t\tif (adjust.max !== undefined && adjusted > adjust.max) {\n\t\t\t\t\tcomputedValue = adjust.max;\n\t\t\t\t} else if (adjust.min !== undefined && adjusted < adjust.min) {\n\t\t\t\t\tcomputedValue = adjust.min;\n\t\t\t\t} else {\n\t\t\t\t\tcomputedValue = adjusted;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn computedValue;\n}\n\n/**\n * @internal\n */\nexport type PropsOrAdjust =\n\t| Pick<IMergeTreeAnnotateAdjustMsg, \"props\" | \"adjust\">\n\t| Pick<IMergeTreeAnnotateMsg, \"props\" | \"adjust\">;\n\nconst opToChanges = (op: PropsOrAdjust, seq: number): [string, PropertyChange][] => [\n\t...Object.entries(op.props ?? {})\n\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n\t\t.map<[string, PropertyChange]>(([k, raw]) => [k, { raw, seq }])\n\t\t.filter(([_, v]) => v.raw !== undefined),\n\t...Object.entries(op.adjust ?? {}).map<[string, PropertyChange]>(([k, adjust]) => [\n\t\tk,\n\t\t{ adjust, seq },\n\t]),\n];\n\nfunction applyChanges(\n\top: PropsOrAdjust,\n\tseg: { properties?: MapLike<unknown> },\n\tseq: number,\n\trun: (\n\t\tproperties: MapLike<unknown>,\n\t\tdeltas: MapLike<unknown>,\n\t\tkey: string,\n\t\tvalue: PropertyChange,\n\t) => void,\n): MapLike<unknown> {\n\tconst properties = (seg.properties ??= createMap<unknown>());\n\tconst deltas: MapLike<unknown> = {};\n\tfor (const [key, value] of opToChanges(op, seq)) {\n\t\trun(properties, deltas, key, value);\n\t\tif (properties[key] === null) {\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-dynamic-delete\n\t\t\tdelete properties[key];\n\t\t}\n\t}\n\treturn deltas;\n}\n\n/**\n * The PropertiesManager class handles changes to properties, both remote and local.\n * It manages the lifecycle for local property changes, ensures all property changes are eventually consistent,\n * and provides methods to acknowledge changes, update the minimum sequence number (msn), and copy properties to another manager.\n * This class is essential for maintaining the integrity and consistency of property changes in collaborative environments.\n * @internal\n */\nexport class PropertiesManager {\n\tprivate readonly changes = new Map<string, PropertyChanges>();\n\n\t/**\n\t * Rolls back local property changes.\n\t * This method reverts property changes based on the provided operation and segment.\n\t * If the operation is part of a collaborative session, it ensures that the changes are consistent with the remote state.\n\t *\n\t * @param op - The operation containing property changes. This can be an adjustment or a set of properties.\n\t * @param seg - The segment containing properties. This object may have a properties map that will be modified.\n\t * @param collaborating - Indicates if the operation is part of a collaborative session. Defaults to false.\n\t * @returns The deltas of the rolled-back properties. This is a map-like object representing the changes that were reverted.\n\t */\n\tpublic rollbackProperties(\n\t\top: PropsOrAdjust,\n\t\tseg: { properties?: MapLike<unknown> },\n\t\tcollaborating: boolean = false,\n\t): MapLike<unknown> {\n\t\treturn applyChanges(op, seg, UniversalSequenceNumber, (properties, deltas, key, value) => {\n\t\t\t// eslint-disable-next-line unicorn/no-null\n\t\t\tconst previousValue = properties[key] ?? null;\n\n\t\t\tconst pending = this.changes.get(key);\n\t\t\tif (collaborating) {\n\t\t\t\tassert(\n\t\t\t\t\tpending !== undefined,\n\t\t\t\t\t0xa6f /* Pending changes must exist for rollback when collaborating */,\n\t\t\t\t);\n\t\t\t\tpending.local.pop();\n\t\t\t\tproperties[key] = computePropertyValue(\n\t\t\t\t\tpending.msnConsensus,\n\t\t\t\t\tpending.remote.map((n) => n.data),\n\t\t\t\t\tpending.local.map((n) => n.data),\n\t\t\t\t);\n\t\t\t\tif (pending.local.empty && pending.remote.empty) {\n\t\t\t\t\tthis.changes.delete(key);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tassert(\n\t\t\t\t\tpending === undefined,\n\t\t\t\t\t0xa70 /* Pending changes must not exist when not collaborating */,\n\t\t\t\t);\n\t\t\t\tproperties[key] = computePropertyValue(previousValue, [value]);\n\t\t\t}\n\t\t\tdeltas[key] = previousValue;\n\t\t});\n\t}\n\n\t/**\n\t * Handles property changes.\n\t * This method applies property changes based on the provided operation, segment, sequence number, and collaboration state.\n\t * It also handles rolling back changes if specified.\n\t *\n\t * @param op - The operation containing property changes.\n\t * @param seg - The segment containing properties.\n\t * @param seq - The sequence number for the operation.\n\t * @param msn - The minimum sequence number for the operation.\n\t * @param collaborating - Indicates if the operation is part of a collaborative session. Defaults to false.\n\t * @param rollback - Specifies if the changes should be rolled back. Defaults to PropertiesRollback.None.\n\t * @returns The deltas of the applied or rolled-back properties. This is a map-like object representing the changes.\n\t */\n\tpublic handleProperties(\n\t\top: PropsOrAdjust,\n\t\tseg: { properties?: MapLike<unknown> },\n\t\tseq: number,\n\t\tmsn: number,\n\t\tcollaborating: boolean = false,\n\t\trollback: PropertiesRollback = PropertiesRollback.None,\n\t): MapLike<unknown> {\n\t\tif (rollback === PropertiesRollback.Rollback) {\n\t\t\treturn this.rollbackProperties(op, seg, collaborating);\n\t\t}\n\t\tconst rtn = applyChanges(op, seg, seq, (properties, deltas, key, value) => {\n\t\t\t// eslint-disable-next-line unicorn/no-null\n\t\t\tconst previousValue = properties[key] ?? null;\n\t\t\tif (collaborating) {\n\t\t\t\tconst pending: PropertyChanges | undefined = this.changes.get(key) ?? {\n\t\t\t\t\tmsnConsensus: previousValue,\n\t\t\t\t\tremote: new DoublyLinkedList(),\n\t\t\t\t\tlocal: new DoublyLinkedList(),\n\t\t\t\t};\n\t\t\t\tthis.changes.set(key, pending);\n\t\t\t\tconst local = seq === UnassignedSequenceNumber;\n\t\t\t\tif (local) {\n\t\t\t\t\tpending.local.push(value);\n\t\t\t\t} else {\n\t\t\t\t\t// we only track remotes if there are adjusts, as only adjusts make application anti-commutative\n\t\t\t\t\t// this will limit the impact of this change to only those using adjusts. Additionally, we only\n\t\t\t\t\t// need to track remotes at all to support emitting the legacy snapshot format, which only sharedstring\n\t\t\t\t\t// uses. when we remove the ability to emit that format, we can remove all remote op tracking\n\t\t\t\t\tif (value.raw !== undefined && pending.remote.empty) {\n\t\t\t\t\t\tpending.msnConsensus = computePropertyValue(pending.msnConsensus, [value]);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tpending.remote.push(value);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tproperties[key] = computePropertyValue(\n\t\t\t\t\tpending.msnConsensus,\n\t\t\t\t\tpending.remote.map((n) => n.data),\n\t\t\t\t\tpending.local.map((n) => n.data),\n\t\t\t\t);\n\t\t\t\tif (local || pending.local.empty || properties[key] !== previousValue) {\n\t\t\t\t\tdeltas[key] = previousValue;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tproperties[key] = computePropertyValue(previousValue, [value]);\n\t\t\t\tdeltas[key] = previousValue;\n\t\t\t}\n\t\t});\n\t\tthis.updateMsn(msn);\n\t\treturn rtn;\n\t}\n\n\t/**\n\t * Acknowledges property changes.\n\t * This method acknowledges the property changes based on the provided sequence number and operation.\n\t *\n\t * @param seq - The sequence number for the operation.\n\t * @param msn - The minimum sequence number for the operation.\n\t * @param op - The operation containing property changes.\n\t */\n\tpublic ack(seq: number, msn: number, op: PropsOrAdjust): void {\n\t\tfor (const [key, value] of opToChanges(op, seq)) {\n\t\t\tconst change = this.changes.get(key);\n\t\t\tconst acked = change?.local?.shift();\n\t\t\tassert(\n\t\t\t\tchange !== undefined && acked !== undefined,\n\t\t\t\t0xa71 /* must have local change to ack */,\n\t\t\t);\n\t\t\t// we only track remotes if there are adjusts, as only adjusts make application anti-commutative\n\t\t\t// this will limit the impact of this change to only those using adjusts. Additionally, we only\n\t\t\t// need to track remotes at all to support emitting the legacy snapshot format, which only sharedstring\n\t\t\t// uses. when we remove the ability to emit that format, we can remove all remote op tracking\n\t\t\tif (value.raw !== undefined && change.remote.empty) {\n\t\t\t\tchange.msnConsensus = computePropertyValue(change.msnConsensus, [value]);\n\t\t\t} else {\n\t\t\t\tchange.remote.push(value);\n\t\t\t}\n\t\t}\n\t\tthis.updateMsn(msn);\n\t}\n\n\t/**\n\t * Updates the minimum sequence number (msn).\n\t * This method updates the minimum sequence number and removes any changes that have been acknowledged.\n\t *\n\t * @param msn - The minimum sequence number to update.\n\t */\n\tpublic updateMsn(msn: number): void {\n\t\tfor (const [key, pending] of this.changes) {\n\t\t\tpending.msnConsensus = computePropertyValue(\n\t\t\t\tpending.msnConsensus,\n\t\t\t\titerateListValuesWhile(pending.remote.first, (n) => {\n\t\t\t\t\tif (n.data.seq <= msn) {\n\t\t\t\t\t\tn.list?.remove(n);\n\t\t\t\t\t\treturn true;\n\t\t\t\t\t}\n\t\t\t\t\treturn false;\n\t\t\t\t}),\n\t\t\t);\n\t\t\tif (pending.local.empty && pending.remote.empty) {\n\t\t\t\tthis.changes.delete(key);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Copies properties to another manager.\n\t * This method copies the properties and their changes from the current manager to the destination manager.\n\t *\n\t * @param oldProps - The old properties to be copied.\n\t * @param dest - The destination object containing properties and property manager.\n\t */\n\tpublic copyTo(\n\t\toldProps: PropertySet | undefined,\n\t\tdest: {\n\t\t\tproperties?: PropertySet;\n\t\t\tpropertyManager?: PropertiesManager;\n\t\t},\n\t): void {\n\t\tconst newManager = (dest.propertyManager ??= new PropertiesManager());\n\t\tdest.properties = clone(oldProps);\n\t\tfor (const [key, { local, remote, msnConsensus }] of this.changes.entries()) {\n\t\t\tnewManager.changes.set(key, {\n\t\t\t\tmsnConsensus,\n\t\t\t\tremote: new DoublyLinkedList(remote.empty ? undefined : remote.map((c) => c.data)),\n\t\t\t\tlocal: new DoublyLinkedList(local.empty ? undefined : local.map((c) => c.data)),\n\t\t\t});\n\t\t}\n\t}\n\n\t/**\n\t * Gets properties at a specific sequence number.\n\t * This method retrieves the properties at the given sequence number.\n\t * This is only needed to support emitting snapshots in the legacy format.\n\t * If we remove the ability to emit the legacy format, we can remove this method, along with the need to track remote changes at all.\n\t *\n\t * @param oldProps - The old properties to be retrieved.\n\t * @param sequenceNumber - The sequence number to get properties at.\n\t * @returns The properties at the given sequence number.\n\t */\n\tpublic getAtSeq(\n\t\toldProps: MapLike<unknown> | undefined,\n\t\tsequenceNumber: number,\n\t): MapLike<unknown> {\n\t\tconst properties: MapLike<unknown> = { ...oldProps };\n\t\tfor (const [key, changes] of this.changes) {\n\t\t\tproperties[key] = computePropertyValue(\n\t\t\t\tchanges.msnConsensus,\n\t\t\t\titerateListValuesWhile(changes.remote.first, (c) => c.data.seq <= sequenceNumber),\n\t\t\t);\n\t\t\tif (properties[key] === null) {\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-dynamic-delete\n\t\t\t\tdelete properties[key];\n\t\t\t}\n\t\t}\n\t\treturn properties;\n\t}\n\n\t/**\n\t * Determines if all of the defined properties in a given property set are pending.\n\t *\n\t * @param props - The properties to check.\n\t * @returns True if all the properties are pending, false otherwise.\n\t */\n\tpublic hasPendingProperties(props: PropertySet): boolean {\n\t\tfor (const [key, value] of Object.entries(props)) {\n\t\t\tif (value !== undefined && this.changes.get(key)?.local.empty !== false) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\t\treturn true;\n\t}\n}\n"]}
1
+ {"version":3,"file":"segmentPropertiesManager.js","sourceRoot":"","sources":["../src/segmentPropertiesManager.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAE7D,OAAO,EAAE,g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,oBAAoB,CACrC,OAAO,CAAC,YAAY,EACpB,sBAAsB,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,IAAI,cAAc,CAAC,CACjF,CAAC;YACF,IAAI,UAAU,CAAC,GAAG,CAAC,KAAK,IAAI,EAAE,CAAC;gBAC9B,gEAAgE;gBAChE,OAAO,UAAU,CAAC,GAAG,CAAC,CAAC;YACxB,CAAC;QACF,CAAC;QACD,OAAO,UAAU,CAAC;IACnB,CAAC;IAED;;;;;OAKG;IACI,oBAAoB,CAAC,KAAkB;QAC7C,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;YAClD,IAAI,KAAK,KAAK,SAAS,IAAI,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,KAAK,CAAC,KAAK,KAAK,KAAK,EAAE,CAAC;gBACzE,OAAO,KAAK,CAAC;YACd,CAAC;QACF,CAAC;QACD,OAAO,IAAI,CAAC;IACb,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\n\nimport { DoublyLinkedList, iterateListValuesWhile } from \"./collections/index.js\";\nimport { UnassignedSequenceNumber, UniversalSequenceNumber } from \"./constants.js\";\nimport type {\n\tAdjustParams,\n\tIMergeTreeAnnotateAdjustMsg,\n\tIMergeTreeAnnotateMsg,\n} from \"./ops.js\";\nimport { MapLike, PropertySet, clone, createMap } from \"./properties.js\";\n\n/**\n * Minimally copies properties and the property manager from source to destination.\n * @internal\n */\nexport function copyPropertiesAndManager(\n\tsource: {\n\t\tproperties?: PropertySet;\n\t\tpropertyManager?: PropertiesManager;\n\t},\n\tdestination: {\n\t\tproperties?: PropertySet;\n\t\tpropertyManager?: PropertiesManager;\n\t},\n): void {\n\tif (source.properties) {\n\t\tif (source.propertyManager === undefined) {\n\t\t\tdestination.properties = clone(source.properties);\n\t\t} else {\n\t\t\tdestination.propertyManager ??= new PropertiesManager();\n\t\t\tsource.propertyManager.copyTo(source.properties, destination);\n\t\t}\n\t}\n}\n\ntype PropertyChange = {\n\tseq: number;\n} & ({ adjust: AdjustParams; raw?: undefined } | { raw: unknown; adjust?: undefined });\n\ninterface PropertyChanges {\n\tmsnConsensus: unknown;\n\tremote: DoublyLinkedList<PropertyChange>;\n\tlocal: DoublyLinkedList<PropertyChange>;\n}\n\nfunction computePropertyValue(\n\tconsensus: unknown,\n\t...changes: Iterable<PropertyChange>[]\n): unknown {\n\tlet computedValue: unknown = consensus;\n\tfor (const change of changes) {\n\t\tfor (const op of change) {\n\t\t\tconst { raw, adjust } = op;\n\t\t\tif (adjust === undefined) {\n\t\t\t\tcomputedValue = raw;\n\t\t\t} else {\n\t\t\t\tconst adjusted =\n\t\t\t\t\t(typeof computedValue === \"number\" ? computedValue : 0) + adjust.delta;\n\t\t\t\tif (adjust.max !== undefined && adjusted > adjust.max) {\n\t\t\t\t\tcomputedValue = adjust.max;\n\t\t\t\t} else if (adjust.min !== undefined && adjusted < adjust.min) {\n\t\t\t\t\tcomputedValue = adjust.min;\n\t\t\t\t} else {\n\t\t\t\t\tcomputedValue = adjusted;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn computedValue;\n}\n\n/**\n * @internal\n */\nexport type PropsOrAdjust =\n\t| Pick<IMergeTreeAnnotateAdjustMsg, \"props\" | \"adjust\">\n\t| Pick<IMergeTreeAnnotateMsg, \"props\" | \"adjust\">;\n\nconst opToChanges = (op: PropsOrAdjust, seq: number): [string, PropertyChange][] => [\n\t...Object.entries(op.props ?? {})\n\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n\t\t.map<[string, PropertyChange]>(([k, raw]) => [k, { raw, seq }])\n\t\t.filter(([_, v]) => v.raw !== undefined),\n\t...Object.entries(op.adjust ?? {}).map<[string, PropertyChange]>(([k, adjust]) => [\n\t\tk,\n\t\t{ adjust, seq },\n\t]),\n];\n\nfunction applyChanges(\n\top: PropsOrAdjust,\n\tseg: { properties?: MapLike<unknown> },\n\tseq: number,\n\trun: (\n\t\tproperties: MapLike<unknown>,\n\t\tdeltas: MapLike<unknown>,\n\t\tkey: string,\n\t\tvalue: PropertyChange,\n\t) => void,\n): MapLike<unknown> {\n\tconst properties = (seg.properties ??= createMap<unknown>());\n\tconst deltas: MapLike<unknown> = {};\n\tfor (const [key, value] of opToChanges(op, seq)) {\n\t\trun(properties, deltas, key, value);\n\t\tif (properties[key] === null) {\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-dynamic-delete\n\t\t\tdelete properties[key];\n\t\t}\n\t}\n\treturn deltas;\n}\n\n/**\n * The PropertiesManager class handles changes to properties, both remote and local.\n * It manages the lifecycle for local property changes, ensures all property changes are eventually consistent,\n * and provides methods to acknowledge changes, update the minimum sequence number (msn), and copy properties to another manager.\n * This class is essential for maintaining the integrity and consistency of property changes in collaborative environments.\n * @internal\n */\nexport class PropertiesManager {\n\tprivate readonly changes = new Map<string, PropertyChanges>();\n\n\t/**\n\t * Rolls back local property changes.\n\t * This method reverts property changes based on the provided operation and segment.\n\t * If the operation is part of a collaborative session, it ensures that the changes are consistent with the remote state.\n\t *\n\t * @param op - The operation containing property changes. This can be an adjustment or a set of properties.\n\t * @param seg - The segment containing properties. This object may have a properties map that will be modified.\n\t * @param collaborating - Indicates if the operation is part of a collaborative session. Defaults to false.\n\t * @returns The deltas of the rolled-back properties. This is a map-like object representing the changes that were reverted.\n\t */\n\tpublic rollbackProperties(\n\t\top: PropsOrAdjust,\n\t\tseg: { properties?: MapLike<unknown> },\n\t\tcollaborating: boolean = false,\n\t): MapLike<unknown> {\n\t\treturn applyChanges(op, seg, UniversalSequenceNumber, (properties, deltas, key, value) => {\n\t\t\t// eslint-disable-next-line unicorn/no-null\n\t\t\tconst previousValue = properties[key] ?? null;\n\n\t\t\tconst pending = this.changes.get(key);\n\t\t\tif (collaborating) {\n\t\t\t\tassert(\n\t\t\t\t\tpending !== undefined,\n\t\t\t\t\t0xa6f /* Pending changes must exist for rollback when collaborating */,\n\t\t\t\t);\n\t\t\t\tpending.local.pop();\n\t\t\t\tproperties[key] = computePropertyValue(\n\t\t\t\t\tpending.msnConsensus,\n\t\t\t\t\tpending.remote.map((n) => n.data),\n\t\t\t\t\tpending.local.map((n) => n.data),\n\t\t\t\t);\n\t\t\t\tif (pending.local.empty && pending.remote.empty) {\n\t\t\t\t\tthis.changes.delete(key);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tassert(\n\t\t\t\t\tpending === undefined,\n\t\t\t\t\t0xa70 /* Pending changes must not exist when not collaborating */,\n\t\t\t\t);\n\t\t\t\tproperties[key] = computePropertyValue(previousValue, [value]);\n\t\t\t}\n\t\t\tdeltas[key] = previousValue;\n\t\t});\n\t}\n\n\t/**\n\t * Handles property changes.\n\t * This method applies property changes based on the provided operation, segment, sequence number, and collaboration state.\n\t * It also handles rolling back changes if specified.\n\t *\n\t * @param op - The operation containing property changes.\n\t * @param seg - The segment containing properties.\n\t * @param seq - The sequence number for the operation.\n\t * @param msn - The minimum sequence number for the operation.\n\t * @param collaborating - Indicates if the operation is part of a collaborative session. Defaults to false.\n\t * @param rollback - Specifies if the changes should be rolled back. Defaults to PropertiesRollback.None.\n\t * @returns The deltas of the applied or rolled-back properties. This is a map-like object representing the changes.\n\t */\n\tpublic handleProperties(\n\t\top: PropsOrAdjust,\n\t\tseg: { properties?: MapLike<unknown> },\n\t\tseq: number,\n\t\tmsn: number,\n\t\tcollaborating: boolean = false,\n\t\trollback: boolean = false,\n\t): MapLike<unknown> {\n\t\tif (rollback) {\n\t\t\treturn this.rollbackProperties(op, seg, collaborating);\n\t\t}\n\t\tconst rtn = applyChanges(op, seg, seq, (properties, deltas, key, value) => {\n\t\t\t// eslint-disable-next-line unicorn/no-null\n\t\t\tconst previousValue = properties[key] ?? null;\n\t\t\tif (collaborating) {\n\t\t\t\tconst pending: PropertyChanges | undefined = this.changes.get(key) ?? {\n\t\t\t\t\tmsnConsensus: previousValue,\n\t\t\t\t\tremote: new DoublyLinkedList(),\n\t\t\t\t\tlocal: new DoublyLinkedList(),\n\t\t\t\t};\n\t\t\t\tthis.changes.set(key, pending);\n\t\t\t\tconst local = seq === UnassignedSequenceNumber;\n\t\t\t\tif (local) {\n\t\t\t\t\tpending.local.push(value);\n\t\t\t\t} else {\n\t\t\t\t\t// we only track remotes if there are adjusts, as only adjusts make application anti-commutative\n\t\t\t\t\t// this will limit the impact of this change to only those using adjusts. Additionally, we only\n\t\t\t\t\t// need to track remotes at all to support emitting the legacy snapshot format, which only sharedstring\n\t\t\t\t\t// uses. when we remove the ability to emit that format, we can remove all remote op tracking\n\t\t\t\t\tif (value.raw !== undefined && pending.remote.empty) {\n\t\t\t\t\t\tpending.msnConsensus = computePropertyValue(pending.msnConsensus, [value]);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tpending.remote.push(value);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tproperties[key] = computePropertyValue(\n\t\t\t\t\tpending.msnConsensus,\n\t\t\t\t\tpending.remote.map((n) => n.data),\n\t\t\t\t\tpending.local.map((n) => n.data),\n\t\t\t\t);\n\t\t\t\tif (local || pending.local.empty || properties[key] !== previousValue) {\n\t\t\t\t\tdeltas[key] = previousValue;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tproperties[key] = computePropertyValue(previousValue, [value]);\n\t\t\t\tdeltas[key] = previousValue;\n\t\t\t}\n\t\t});\n\t\tthis.updateMsn(msn);\n\t\treturn rtn;\n\t}\n\n\t/**\n\t * Acknowledges property changes.\n\t * This method acknowledges the property changes based on the provided sequence number and operation.\n\t *\n\t * @param seq - The sequence number for the operation.\n\t * @param msn - The minimum sequence number for the operation.\n\t * @param op - The operation containing property changes.\n\t */\n\tpublic ack(seq: number, msn: number, op: PropsOrAdjust): void {\n\t\tfor (const [key, value] of opToChanges(op, seq)) {\n\t\t\tconst change = this.changes.get(key);\n\t\t\tconst acked = change?.local?.shift();\n\t\t\tassert(\n\t\t\t\tchange !== undefined && acked !== undefined,\n\t\t\t\t0xa71 /* must have local change to ack */,\n\t\t\t);\n\t\t\t// we only track remotes if there are adjusts, as only adjusts make application anti-commutative\n\t\t\t// this will limit the impact of this change to only those using adjusts. Additionally, we only\n\t\t\t// need to track remotes at all to support emitting the legacy snapshot format, which only sharedstring\n\t\t\t// uses. when we remove the ability to emit that format, we can remove all remote op tracking\n\t\t\tif (value.raw !== undefined && change.remote.empty) {\n\t\t\t\tchange.msnConsensus = computePropertyValue(change.msnConsensus, [value]);\n\t\t\t} else {\n\t\t\t\tchange.remote.push(value);\n\t\t\t}\n\t\t}\n\t\tthis.updateMsn(msn);\n\t}\n\n\t/**\n\t * Updates the minimum sequence number (msn).\n\t * This method updates the minimum sequence number and removes any changes that have been acknowledged.\n\t *\n\t * @param msn - The minimum sequence number to update.\n\t */\n\tpublic updateMsn(msn: number): void {\n\t\tfor (const [key, pending] of this.changes) {\n\t\t\tpending.msnConsensus = computePropertyValue(\n\t\t\t\tpending.msnConsensus,\n\t\t\t\titerateListValuesWhile(pending.remote.first, (n) => {\n\t\t\t\t\tif (n.data.seq <= msn) {\n\t\t\t\t\t\tn.list?.remove(n);\n\t\t\t\t\t\treturn true;\n\t\t\t\t\t}\n\t\t\t\t\treturn false;\n\t\t\t\t}),\n\t\t\t);\n\t\t\tif (pending.local.empty && pending.remote.empty) {\n\t\t\t\tthis.changes.delete(key);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Copies properties to another manager.\n\t * This method copies the properties and their changes from the current manager to the destination manager.\n\t *\n\t * @param oldProps - The old properties to be copied.\n\t * @param dest - The destination object containing properties and property manager.\n\t */\n\tpublic copyTo(\n\t\toldProps: PropertySet | undefined,\n\t\tdest: {\n\t\t\tproperties?: PropertySet;\n\t\t\tpropertyManager?: PropertiesManager;\n\t\t},\n\t): void {\n\t\tconst newManager = (dest.propertyManager ??= new PropertiesManager());\n\t\tdest.properties = clone(oldProps);\n\t\tfor (const [key, { local, remote, msnConsensus }] of this.changes.entries()) {\n\t\t\tnewManager.changes.set(key, {\n\t\t\t\tmsnConsensus,\n\t\t\t\tremote: new DoublyLinkedList(remote.empty ? undefined : remote.map((c) => c.data)),\n\t\t\t\tlocal: new DoublyLinkedList(local.empty ? undefined : local.map((c) => c.data)),\n\t\t\t});\n\t\t}\n\t}\n\n\t/**\n\t * Gets properties at a specific sequence number.\n\t * This method retrieves the properties at the given sequence number.\n\t * This is only needed to support emitting snapshots in the legacy format.\n\t * If we remove the ability to emit the legacy format, we can remove this method, along with the need to track remote changes at all.\n\t *\n\t * @param oldProps - The old properties to be retrieved.\n\t * @param sequenceNumber - The sequence number to get properties at.\n\t * @returns The properties at the given sequence number.\n\t */\n\tpublic getAtSeq(\n\t\toldProps: MapLike<unknown> | undefined,\n\t\tsequenceNumber: number,\n\t): MapLike<unknown> {\n\t\tconst properties: MapLike<unknown> = { ...oldProps };\n\t\tfor (const [key, changes] of this.changes) {\n\t\t\tproperties[key] = computePropertyValue(\n\t\t\t\tchanges.msnConsensus,\n\t\t\t\titerateListValuesWhile(changes.remote.first, (c) => c.data.seq <= sequenceNumber),\n\t\t\t);\n\t\t\tif (properties[key] === null) {\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-dynamic-delete\n\t\t\t\tdelete properties[key];\n\t\t\t}\n\t\t}\n\t\treturn properties;\n\t}\n\n\t/**\n\t * Determines if all of the defined properties in a given property set are pending.\n\t *\n\t * @param props - The properties to check.\n\t * @returns True if all the properties are pending, false otherwise.\n\t */\n\tpublic hasPendingProperties(props: PropertySet): boolean {\n\t\tfor (const [key, value] of Object.entries(props)) {\n\t\t\tif (value !== undefined && this.changes.get(key)?.local.empty !== false) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\t\treturn true;\n\t}\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"snapshotLoader.d.ts","sourceRoot":"","sources":["../src/snapshotLoader.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAOH,OAAO,EACN,sBAAsB,EACtB,sBAAsB,EACtB,MAAM,gDAAgD,CAAC;AACxD,OAAO,EAAE,yBAAyB,EAAE,MAAM,6CAA6C,CAAC;AACxF,OAAO,EAAE,gBAAgB,EAAE,MAAM,6CAA6C,CAAC;AAC/E,OAAO,EACN,mBAAmB,EAGnB,MAAM,0CAA0C,CAAC;AAElD,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAkB3C,qBAAa,cAAc;IAIzB,OAAO,CAAC,QAAQ,CAAC,OAAO;IAExB,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,SAAS;IAE1B,OAAO,CAAC,QAAQ,CAAC,UAAU;IAR5B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAsB;gBAG3B,OAAO,EAAE,sBAAsB,EAE/B,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,SAAS,EACrC,MAAM,EAAE,mBAAmB,EACV,UAAU,EAAE,gBAAgB;IAKjC,UAAU,CACtB,QAAQ,EAAE,sBAAsB,GAC9B,OAAO,CAAC;QAAE,WAAW,EAAE,OAAO,CAAC,yBAAyB,EAAE,CAAC,CAAA;KAAE,CAAC;YAiBnD,qBAAqB;IA2BnC,OAAO,CAAC,QAAQ,CAAC,aAAa,CAiD5B;IAEF,OAAO,CAAC,UAAU;YAsCJ,QAAQ;IAwFtB,OAAO,CAAC,kBAAkB;IAsB1B;;;;;OAKG;YACW,cAAc;CAQ5B"}
1
+ {"version":3,"file":"snapshotLoader.d.ts","sourceRoot":"","sources":["../src/snapshotLoader.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAOH,OAAO,EACN,sBAAsB,EACtB,sBAAsB,EACtB,MAAM,gDAAgD,CAAC;AACxD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