@fluidframework/merge-tree 2.117.0 → 3.0.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 (184) hide show
  1. package/CHANGELOG.md +36 -2
  2. package/README.md +53 -50
  3. package/{api-extractor.json → api-extractor/api-extractor-model.json} +1 -1
  4. package/dist/MergeTreeTextHelper.js +1 -0
  5. package/dist/MergeTreeTextHelper.js.map +1 -1
  6. package/dist/attributionCollection.js +6 -4
  7. package/dist/attributionCollection.js.map +1 -1
  8. package/dist/attributionPolicy.js +3 -4
  9. package/dist/attributionPolicy.js.map +1 -1
  10. package/dist/client.js +27 -10
  11. package/dist/client.js.map +1 -1
  12. package/dist/collections/rbTree.d.ts.map +1 -1
  13. package/dist/collections/rbTree.js +3 -0
  14. package/dist/collections/rbTree.js.map +1 -1
  15. package/dist/endOfTreeSegment.d.ts.map +1 -1
  16. package/dist/endOfTreeSegment.js +25 -26
  17. package/dist/endOfTreeSegment.js.map +1 -1
  18. package/dist/localReference.js +17 -7
  19. package/dist/localReference.js.map +1 -1
  20. package/dist/mergeTree.d.ts.map +1 -1
  21. package/dist/mergeTree.js +90 -74
  22. package/dist/mergeTree.js.map +1 -1
  23. package/dist/mergeTreeNodeWalk.js +5 -5
  24. package/dist/mergeTreeNodeWalk.js.map +1 -1
  25. package/dist/mergeTreeNodes.d.ts.map +1 -1
  26. package/dist/mergeTreeNodes.js +117 -90
  27. package/dist/mergeTreeNodes.js.map +1 -1
  28. package/dist/mergeTreeTracking.js +4 -0
  29. package/dist/mergeTreeTracking.js.map +1 -1
  30. package/dist/opBuilder.js +9 -10
  31. package/dist/opBuilder.js.map +1 -1
  32. package/dist/ordinal.js +1 -2
  33. package/dist/ordinal.js.map +1 -1
  34. package/dist/partialLengths.js +109 -73
  35. package/dist/partialLengths.js.map +1 -1
  36. package/dist/perspective.js +31 -11
  37. package/dist/perspective.js.map +1 -1
  38. package/dist/properties.js +6 -7
  39. package/dist/properties.js.map +1 -1
  40. package/dist/referencePositions.d.ts.map +1 -1
  41. package/dist/referencePositions.js +7 -7
  42. package/dist/referencePositions.js.map +1 -1
  43. package/dist/revertibles.js +4 -5
  44. package/dist/revertibles.js.map +1 -1
  45. package/dist/segmentGroupCollection.js +2 -0
  46. package/dist/segmentGroupCollection.js.map +1 -1
  47. package/dist/segmentInfos.d.ts.map +1 -1
  48. package/dist/segmentInfos.js +5 -5
  49. package/dist/segmentInfos.js.map +1 -1
  50. package/dist/segmentPropertiesManager.js +3 -5
  51. package/dist/segmentPropertiesManager.js.map +1 -1
  52. package/dist/sequencePlace.js +3 -3
  53. package/dist/sequencePlace.js.map +1 -1
  54. package/dist/snapshotChunks.d.ts.map +1 -1
  55. package/dist/snapshotChunks.js +6 -6
  56. package/dist/snapshotChunks.js.map +1 -1
  57. package/dist/snapshotLoader.js +85 -70
  58. package/dist/snapshotLoader.js.map +1 -1
  59. package/dist/snapshotV1.d.ts.map +1 -1
  60. package/dist/snapshotV1.js +34 -14
  61. package/dist/snapshotV1.js.map +1 -1
  62. package/dist/snapshotlegacy.d.ts.map +1 -1
  63. package/dist/snapshotlegacy.js +18 -10
  64. package/dist/snapshotlegacy.js.map +1 -1
  65. package/dist/sortedSet.js +1 -3
  66. package/dist/sortedSet.js.map +1 -1
  67. package/dist/stamps.js +11 -12
  68. package/dist/stamps.js.map +1 -1
  69. package/dist/test/attributionCollection.spec.js +1 -1
  70. package/dist/test/attributionCollection.spec.js.map +1 -1
  71. package/dist/test/beastTest.spec.js +15 -11
  72. package/dist/test/beastTest.spec.js.map +1 -1
  73. package/dist/test/client.apis.spec.js +2 -3
  74. package/dist/test/client.apis.spec.js.map +1 -1
  75. package/dist/test/client.replay.spec.js +17 -7
  76. package/dist/test/client.replay.spec.js.map +1 -1
  77. package/dist/test/clientTestHelper.js +7 -4
  78. package/dist/test/clientTestHelper.js.map +1 -1
  79. package/dist/test/mergeTreeOperationRunner.js +26 -16
  80. package/dist/test/mergeTreeOperationRunner.js.map +1 -1
  81. package/dist/test/obliterateOperations.d.ts.map +1 -1
  82. package/dist/test/revertibles.spec.js +1 -2
  83. package/dist/test/revertibles.spec.js.map +1 -1
  84. package/dist/test/snapshot.utils.d.ts.map +1 -1
  85. package/dist/test/snapshot.utils.js +7 -5
  86. package/dist/test/snapshot.utils.js.map +1 -1
  87. package/dist/test/stamps.spec.js +17 -7
  88. package/dist/test/stamps.spec.js.map +1 -1
  89. package/dist/test/testClient.d.ts.map +1 -1
  90. package/dist/test/testClient.js +19 -17
  91. package/dist/test/testClient.js.map +1 -1
  92. package/dist/test/testClientLogger.d.ts.map +1 -1
  93. package/dist/test/testClientLogger.js +12 -8
  94. package/dist/test/testClientLogger.js.map +1 -1
  95. package/dist/test/testServer.js +7 -7
  96. package/dist/test/testServer.js.map +1 -1
  97. package/dist/test/testUtils.d.ts +0 -1
  98. package/dist/test/testUtils.d.ts.map +1 -1
  99. package/dist/test/testUtils.js +9 -10
  100. package/dist/test/testUtils.js.map +1 -1
  101. package/dist/test/text.js +2 -3
  102. package/dist/test/text.js.map +1 -1
  103. package/dist/test/wordUnitTests.spec.js +1 -2
  104. package/dist/test/wordUnitTests.spec.js.map +1 -1
  105. package/dist/textSegment.js +3 -2
  106. package/dist/textSegment.js.map +1 -1
  107. package/dist/zamboni.js +20 -10
  108. package/dist/zamboni.js.map +1 -1
  109. package/lib/MergeTreeTextHelper.js +1 -0
  110. package/lib/MergeTreeTextHelper.js.map +1 -1
  111. package/lib/attributionCollection.js +4 -2
  112. package/lib/attributionCollection.js.map +1 -1
  113. package/lib/client.js +10 -3
  114. package/lib/client.js.map +1 -1
  115. package/lib/collections/rbTree.d.ts.map +1 -1
  116. package/lib/collections/rbTree.js +3 -0
  117. package/lib/collections/rbTree.js.map +1 -1
  118. package/lib/endOfTreeSegment.d.ts.map +1 -1
  119. package/lib/endOfTreeSegment.js +25 -26
  120. package/lib/endOfTreeSegment.js.map +1 -1
  121. package/lib/legacy.d.ts +1 -1
  122. package/lib/localReference.js +12 -2
  123. package/lib/localReference.js.map +1 -1
  124. package/lib/mergeTree.d.ts.map +1 -1
  125. package/lib/mergeTree.js +68 -62
  126. package/lib/mergeTree.js.map +1 -1
  127. package/lib/mergeTreeNodes.d.ts.map +1 -1
  128. package/lib/mergeTreeNodes.js +111 -84
  129. package/lib/mergeTreeNodes.js.map +1 -1
  130. package/lib/mergeTreeTracking.js +4 -0
  131. package/lib/mergeTreeTracking.js.map +1 -1
  132. package/lib/partialLengths.js +89 -63
  133. package/lib/partialLengths.js.map +1 -1
  134. package/lib/perspective.js +12 -2
  135. package/lib/perspective.js.map +1 -1
  136. package/lib/public.d.ts +1 -1
  137. package/lib/referencePositions.d.ts.map +1 -1
  138. package/lib/segmentGroupCollection.js +2 -0
  139. package/lib/segmentGroupCollection.js.map +1 -1
  140. package/lib/segmentInfos.d.ts.map +1 -1
  141. package/lib/segmentPropertiesManager.js +1 -3
  142. package/lib/segmentPropertiesManager.js.map +1 -1
  143. package/lib/snapshotChunks.d.ts.map +1 -1
  144. package/lib/snapshotChunks.js +2 -1
  145. package/lib/snapshotChunks.js.map +1 -1
  146. package/lib/snapshotLoader.js +68 -63
  147. package/lib/snapshotLoader.js.map +1 -1
  148. package/lib/snapshotV1.d.ts.map +1 -1
  149. package/lib/snapshotV1.js +17 -7
  150. package/lib/snapshotV1.js.map +1 -1
  151. package/lib/snapshotlegacy.d.ts.map +1 -1
  152. package/lib/snapshotlegacy.js +18 -10
  153. package/lib/snapshotlegacy.js.map +1 -1
  154. package/lib/sortedSet.js +1 -3
  155. package/lib/sortedSet.js.map +1 -1
  156. package/lib/test/attributionCollection.spec.js +1 -1
  157. package/lib/test/attributionCollection.spec.js.map +1 -1
  158. package/lib/test/beastTest.spec.js +7 -3
  159. package/lib/test/beastTest.spec.js.map +1 -1
  160. package/lib/test/clientTestHelper.js +7 -4
  161. package/lib/test/clientTestHelper.js.map +1 -1
  162. package/lib/test/obliterateOperations.d.ts.map +1 -1
  163. package/lib/test/snapshot.utils.d.ts.map +1 -1
  164. package/lib/test/snapshot.utils.js +5 -3
  165. package/lib/test/snapshot.utils.js.map +1 -1
  166. package/lib/test/testClient.d.ts.map +1 -1
  167. package/lib/test/testClient.js +16 -14
  168. package/lib/test/testClient.js.map +1 -1
  169. package/lib/test/testClientLogger.d.ts.map +1 -1
  170. package/lib/test/testClientLogger.js +10 -6
  171. package/lib/test/testClientLogger.js.map +1 -1
  172. package/lib/test/testServer.js +5 -5
  173. package/lib/test/testServer.js.map +1 -1
  174. package/lib/test/testUtils.d.ts +0 -1
  175. package/lib/test/testUtils.d.ts.map +1 -1
  176. package/lib/textSegment.js +3 -2
  177. package/lib/textSegment.js.map +1 -1
  178. package/package.json +39 -58
  179. package/src/snapshotChunks.ts +10 -6
  180. package/tsconfig.json +1 -1
  181. package/internal.d.ts +0 -11
  182. package/legacy.d.ts +0 -11
  183. /package/api-extractor/{api-extractor.current.json → api-extractor-report.current.json} +0 -0
  184. /package/api-extractor/{api-extractor.legacy.json → api-extractor-report.legacy.json} +0 -0
@@ -1 +1 @@
1
- {"version":3,"file":"properties.js","sourceRoot":"","sources":["../src/properties.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAuBH;;;;GAIG;AACH,SAAgB,eAAe,CAC9B,CAA0B,EAC1B,CAA0B;IAE1B,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC;QACd,OAAO,IAAI,CAAC;IACb,CAAC;IAED,MAAM,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;IACtC,MAAM,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;IAEtC,IAAI,KAAK,CAAC,MAAM,KAAK,KAAK,CAAC,MAAM,EAAE,CAAC;QACnC,OAAO,KAAK,CAAC;IACd,CAAC;IAED,KAAK,MAAM,GAAG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CAAC;IAChC,OAAO,MAAM,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC;AACpC,CAAC;AAND,sBAMC;AAED;;;;;GAKG;AACH,SAAgB,aAAa,CAC5B,QAAiC,EACjC,QAAqB;IAErB,OAAO,MAAM,CAAC,QAAQ,IAAI,SAAS,EAAW,EAAE,QAAQ,CAAC,CAAC;AAC3D,CAAC;AALD,sCAKC;AAED;;;;GAIG;AACH,SAAgB,iBAAiB,CAChC,IAAgB,EAChB,SAAiC;IAEjC,IAAI,SAAS,KAAK,SAAS,EAAE,CAAC;QAC7B,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE,CAAC;YACtD,6HAA6H;YAC7H,IAAI,IAAI,CAAC,GAAG,CAAC,KAAK,SAAS,EAAE,CAAC;gBAC7B,IAAI,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;YACnB,CAAC;QACF,CAAC;IACF,CAAC;IACD,OAAO,IAAI,CAAC;AACb,CAAC;AAbD,8CAaC;AAED;;;;GAIG;AACH,SAAgB,SAAS;IACxB,OAAO,MAAM,CAAC,MAAM,CAAC,IAAI,CAAe,CAAC;AAC1C,CAAC;AAFD,8BAEC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/**\n * Any mapping from a string to values of type `T`\n * @legacy @beta\n */\nexport interface MapLike<T> {\n\t[index: string]: T;\n}\n\n/**\n * A loosely-typed mapping from strings to any value.\n *\n * @remarks Property sets are expected to be JSON-stringify-able.\n *\n * @privateRemarks PropertySet is typed using `any` because when you include\n * custom methods such as toJSON(), JSON.stringify accepts most types other than\n * functions\n * @legacy @beta\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type PropertySet = MapLike<any>;\n\n/**\n * Compares two PropertySets for equality.\n *\n * @internal\n */\nexport function matchProperties(\n\ta: PropertySet | undefined,\n\tb: PropertySet | undefined,\n): boolean {\n\tif (!a && !b) {\n\t\treturn true;\n\t}\n\n\tconst keysA = a ? Object.keys(a) : [];\n\tconst keysB = b ? Object.keys(b) : [];\n\n\tif (keysA.length !== keysB.length) {\n\t\treturn false;\n\t}\n\n\tfor (const key of keysA) {\n\t\tif (b?.[key] === undefined) {\n\t\t\treturn false;\n\t\t} else if (typeof b[key] === \"object\") {\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n\t\t\tif (!matchProperties(a?.[key], b[key])) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t} else if (b[key] !== a?.[key]) {\n\t\t\treturn false;\n\t\t}\n\t}\n\n\treturn true;\n}\n\n/**\n * Adds properties from one PropertySet to another.\n *\n * @internal\n */\nexport function extend<T>(base: MapLike<T>, extension: MapLike<T> | undefined): MapLike<T> {\n\tif (extension !== undefined) {\n\t\tfor (const [key, v] of Object.entries(extension)) {\n\t\t\tif (v === undefined) {\n\t\t\t\tcontinue;\n\t\t\t} else if (v === null) {\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-dynamic-delete\n\t\t\t\tdelete base[key];\n\t\t\t} else {\n\t\t\t\tbase[key] = v;\n\t\t\t}\n\t\t}\n\t}\n\treturn base;\n}\n\n/**\n * Clones properties in a given PropertySet into a new PropertySet.\n *\n * @internal\n */\nexport function clone<T>(extension: MapLike<T> | undefined): MapLike<T> | undefined {\n\tif (extension === undefined) {\n\t\treturn undefined;\n\t}\n\tconst cloneMap = createMap<T>();\n\treturn extend(cloneMap, extension);\n}\n\n/**\n * Add properties in one PropertySet to another PropertySet. If the PropertySet we are adding\n * to does not exist, create one.\n *\n * @internal\n */\nexport function addProperties(\n\toldProps: PropertySet | undefined,\n\tnewProps: PropertySet,\n): PropertySet {\n\treturn extend(oldProps ?? createMap<unknown>(), newProps);\n}\n\n/**\n * Replace values of undefined in one PropertySet with values for the same key from another PropertySet.\n *\n * @internal\n */\nexport function extendIfUndefined<T>(\n\tbase: MapLike<T>,\n\textension: MapLike<T> | undefined,\n): MapLike<T> {\n\tif (extension !== undefined) {\n\t\tfor (const [key, value] of Object.entries(extension)) {\n\t\t\t// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing -- using ??= could change behavior if value is falsy\n\t\t\tif (base[key] === undefined) {\n\t\t\t\tbase[key] = value;\n\t\t\t}\n\t\t}\n\t}\n\treturn base;\n}\n\n/**\n * Create a MapLike with good performance.\n *\n * @internal\n */\nexport function createMap<T>(): MapLike<T> {\n\treturn Object.create(null) as MapLike<T>;\n}\n"]}
1
+ {"version":3,"file":"properties.js","sourceRoot":"","sources":["../src/properties.ts"],"names":[],"mappings":";AAAA;;;GAGG;;AA4BH,0CA6BC;AAOD,wBAcC;AAOD,sBAMC;AAQD,sCAKC;AAOD,8CAaC;AAOD,8BAEC;AA9GD;;;;GAIG;AACH,SAAgB,eAAe,CAC9B,CAA0B,EAC1B,CAA0B;IAE1B,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC;QACd,OAAO,IAAI,CAAC;IACb,CAAC;IAED,MAAM,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;IACtC,MAAM,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;IAEtC,IAAI,KAAK,CAAC,MAAM,KAAK,KAAK,CAAC,MAAM,EAAE,CAAC;QACnC,OAAO,KAAK,CAAC;IACd,CAAC;IAED,KAAK,MAAM,GAAG,IAAI,KAAK,EAAE,CAAC;QACzB,IAAI,CAAC,EAAE,CAAC,GAAG,CAAC,KAAK,SAAS,EAAE,CAAC;YAC5B,OAAO,KAAK,CAAC;QACd,CAAC;aAAM,IAAI,OAAO,CAAC,CAAC,GAAG,CAAC,KAAK,QAAQ,EAAE,CAAC;YACvC,iEAAiE;YACjE,IAAI,CAAC,eAAe,CA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AAgB,EAChB,SAAiC;IAEjC,IAAI,SAAS,KAAK,SAAS,EAAE,CAAC;QAC7B,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE,CAAC;YACtD,6HAA6H;YAC7H,IAAI,IAAI,CAAC,GAAG,CAAC,KAAK,SAAS,EAAE,CAAC;gBAC7B,IAAI,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;YACnB,CAAC;QACF,CAAC;IACF,CAAC;IACD,OAAO,IAAI,CAAC;AACb,CAAC;AAED;;;;GAIG;AACH,SAAgB,SAAS;IACxB,OAAO,MAAM,CAAC,MAAM,CAAC,IAAI,CAAe,CAAC;AAC1C,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/**\n * Any mapping from a string to values of type `T`\n * @legacy @beta\n */\nexport interface MapLike<T> {\n\t[index: string]: T;\n}\n\n/**\n * A loosely-typed mapping from strings to any value.\n *\n * @remarks Property sets are expected to be JSON-stringify-able.\n *\n * @privateRemarks PropertySet is typed using `any` because when you include\n * custom methods such as toJSON(), JSON.stringify accepts most types other than\n * functions\n * @legacy @beta\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type PropertySet = MapLike<any>;\n\n/**\n * Compares two PropertySets for equality.\n *\n * @internal\n */\nexport function matchProperties(\n\ta: PropertySet | undefined,\n\tb: PropertySet | undefined,\n): boolean {\n\tif (!a && !b) {\n\t\treturn true;\n\t}\n\n\tconst keysA = a ? Object.keys(a) : [];\n\tconst keysB = b ? Object.keys(b) : [];\n\n\tif (keysA.length !== keysB.length) {\n\t\treturn false;\n\t}\n\n\tfor (const key of keysA) {\n\t\tif (b?.[key] === undefined) {\n\t\t\treturn false;\n\t\t} else if (typeof b[key] === \"object\") {\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n\t\t\tif (!matchProperties(a?.[key], b[key])) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t} else if (b[key] !== a?.[key]) {\n\t\t\treturn false;\n\t\t}\n\t}\n\n\treturn true;\n}\n\n/**\n * Adds properties from one PropertySet to another.\n *\n * @internal\n */\nexport function extend<T>(base: MapLike<T>, extension: MapLike<T> | undefined): MapLike<T> {\n\tif (extension !== undefined) {\n\t\tfor (const [key, v] of Object.entries(extension)) {\n\t\t\tif (v === undefined) {\n\t\t\t\tcontinue;\n\t\t\t} else if (v === null) {\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-dynamic-delete\n\t\t\t\tdelete base[key];\n\t\t\t} else {\n\t\t\t\tbase[key] = v;\n\t\t\t}\n\t\t}\n\t}\n\treturn base;\n}\n\n/**\n * Clones properties in a given PropertySet into a new PropertySet.\n *\n * @internal\n */\nexport function clone<T>(extension: MapLike<T> | undefined): MapLike<T> | undefined {\n\tif (extension === undefined) {\n\t\treturn undefined;\n\t}\n\tconst cloneMap = createMap<T>();\n\treturn extend(cloneMap, extension);\n}\n\n/**\n * Add properties in one PropertySet to another PropertySet. If the PropertySet we are adding\n * to does not exist, create one.\n *\n * @internal\n */\nexport function addProperties(\n\toldProps: PropertySet | undefined,\n\tnewProps: PropertySet,\n): PropertySet {\n\treturn extend(oldProps ?? createMap<unknown>(), newProps);\n}\n\n/**\n * Replace values of undefined in one PropertySet with values for the same key from another PropertySet.\n *\n * @internal\n */\nexport function extendIfUndefined<T>(\n\tbase: MapLike<T>,\n\textension: MapLike<T> | undefined,\n): MapLike<T> {\n\tif (extension !== undefined) {\n\t\tfor (const [key, value] of Object.entries(extension)) {\n\t\t\t// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing -- using ??= could change behavior if value is falsy\n\t\t\tif (base[key] === undefined) {\n\t\t\t\tbase[key] = value;\n\t\t\t}\n\t\t}\n\t}\n\treturn base;\n}\n\n/**\n * Create a MapLike with good performance.\n *\n * @internal\n */\nexport function createMap<T>(): MapLike<T> {\n\treturn Object.create(null) as MapLike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;;OAEG;IACH,UAAU,CAAC,EAAE,WAAW,CAAC;IAEzB;;;;;OAKG;IACH,iBAAiB,CAAC,EAAE,iBAAiB,CAAC;IAEtC,OAAO,EAAE,aAAa,CAAC;IAEvB;;;OAGG;IACH,UAAU,IAAI,QAAQ,GAAG,SAAS,CAAC;IAEnC;;;;;;;OAOG;IACH,SAAS,IAAI,MAAM,CAAC;IAEpB,MAAM,IAAI,IAAI,IAAI,QAAQ,CAAC;CAC3B;AAED;;GAEG;AACH,eAAO,MAAM,yBAAyB,KAAK,CAAC;AAE5C;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,CAAC,SAAS,iBAAiB,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,GAAG,CAAC,CAE/E;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,CAAC,SAAS,iBAAiB,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,GAAG,CAAC,CAE/E;AAED;;;GAGG;AACH,wBAAgB,yBAAyB,CAAC,CAAC,EAAE,iBAAiB,EAAE,CAAC,EAAE,iBAAiB,GAAG,MAAM,CAU5F"}
@@ -4,7 +4,13 @@
4
4
  * Licensed under the MIT License.
5
5
  */
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.compareReferencePositions = exports.maxReferencePosition = exports.minReferencePosition = exports.DetachedReferencePosition = exports.refHasTileLabels = exports.refHasTileLabel = exports.refGetTileLabels = exports.refTypeIncludesFlag = exports.reservedRangeLabelsKey = exports.reservedTileLabelsKey = void 0;
7
+ exports.DetachedReferencePosition = exports.refGetTileLabels = exports.reservedRangeLabelsKey = exports.reservedTileLabelsKey = void 0;
8
+ exports.refTypeIncludesFlag = refTypeIncludesFlag;
9
+ exports.refHasTileLabel = refHasTileLabel;
10
+ exports.refHasTileLabels = refHasTileLabels;
11
+ exports.minReferencePosition = minReferencePosition;
12
+ exports.maxReferencePosition = maxReferencePosition;
13
+ exports.compareReferencePositions = compareReferencePositions;
8
14
  const ops_js_1 = require("./ops.js");
9
15
  const segmentInfos_js_1 = require("./segmentInfos.js");
10
16
  /**
@@ -24,7 +30,6 @@ function refTypeIncludesFlag(refPosOrType, flags) {
24
30
  // eslint-disable-next-line no-bitwise
25
31
  return (refType & flags) !== 0;
26
32
  }
27
- exports.refTypeIncludesFlag = refTypeIncludesFlag;
28
33
  /**
29
34
  * Gets the tile labels stored in the given reference position.
30
35
  * @legacy @beta
@@ -41,7 +46,6 @@ function refHasTileLabel(refPos, label) {
41
46
  const tileLabels = (0, exports.refGetTileLabels)(refPos);
42
47
  return tileLabels?.includes(label) ?? false;
43
48
  }
44
- exports.refHasTileLabel = refHasTileLabel;
45
49
  /**
46
50
  * Determines if a reference position has any tile labels.
47
51
  * @internal
@@ -49,7 +53,6 @@ exports.refHasTileLabel = refHasTileLabel;
49
53
  function refHasTileLabels(refPos) {
50
54
  return (0, exports.refGetTileLabels)(refPos) !== undefined;
51
55
  }
52
- exports.refHasTileLabels = refHasTileLabels;
53
56
  /**
54
57
  * @internal
55
58
  */
@@ -61,7 +64,6 @@ exports.DetachedReferencePosition = -1;
61
64
  function minReferencePosition(a, b) {
62
65
  return compareReferencePositions(a, b) < 0 ? a : b;
63
66
  }
64
- exports.minReferencePosition = minReferencePosition;
65
67
  /**
66
68
  * Finds the maximum reference position.
67
69
  * @internal
@@ -69,7 +71,6 @@ exports.minReferencePosition = minReferencePosition;
69
71
  function maxReferencePosition(a, b) {
70
72
  return compareReferencePositions(a, b) > 0 ? a : b;
71
73
  }
72
- exports.maxReferencePosition = maxReferencePosition;
73
74
  /**
74
75
  * Compares two reference positions.
75
76
  * @internal
@@ -86,5 +87,4 @@ function compareReferencePositions(a, b) {
86
87
  : 1;
87
88
  }
88
89
  }
89
- exports.compareReferencePositions = compareReferencePositions;
90
90
  //# sourceMappingURL=referencePositions.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"referencePositions.js","sourceRoot":"","sources":["../src/referencePositions.ts"],"names":[],"mappings":";AA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C,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AACpD,CAAC;AAFD,oDAEC;AAED;;;GAGG;AACH,SAAgB,oBAAoB,CAA8B,CAAI,EAAE,CAAI;IAC3E,OAAO,yBAAyB,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AACpD,CAAC;AAFD,oDAEC;AAED;;;GAGG;AACH,SAAgB,yBAAyB,CAAC,CAAoB,EAAE,CAAoB;IACnF,MAAM,IAAI,GAAG,CAAC,CAAC,UAAU,EAAE,CAAC;IAC5B,MAAM,IAAI,GAAG,CAAC,CAAC,UAAU,EAAE,CAAC;IAC5B,IAAI,IAAI,KAAK,IAAI,EAAE,CAAC;QACnB,OAAO,CAAC,CAAC,SAAS,EAAE,GAAG,CAAC,CAAC,SAAS,EAAE,CAAC;IACtC,CAAC;SAAM,CAAC;QACP,OAAO,CAAC,IAAA,iCAAe,EAAC,IAAI,CAAC,IAAI,CAAC,IAAA,iCAAe,EAAC,IAAI,CAAC,IAAI,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC;YACtF,CAAC,CAAC,CAAC,CAAC;YACJ,CAAC,CAAC,CAAC,CAAC;IACN,CAAC;AACF,CAAC;AAVD,8DAUC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { SlidingPreference } from \"./localReference.js\";\nimport type { ISegment } from \"./mergeTreeNodes.js\";\nimport { ReferenceType } from \"./ops.js\";\nimport type { PropertySet } from \"./properties.js\";\nimport { isMergeNodeInfo } from \"./segmentInfos.js\";\n\n/**\n * @internal\n */\nexport const reservedTileLabelsKey = \"referenceTileLabels\";\n/**\n * @internal\n */\nexport const reservedRangeLabelsKey = \"referenceRangeLabels\";\n\n/**\n * Determines if the given reference type includes the given flags.\n * @internal\n */\nexport function refTypeIncludesFlag(\n\trefPosOrType: ReferencePosition | ReferenceType,\n\tflags: ReferenceType,\n): boolean {\n\tconst refType = typeof refPosOrType === \"number\" ? refPosOrType : refPosOrType.refType;\n\t// eslint-disable-next-line no-bitwise\n\treturn (refType & flags) !== 0;\n}\n\n/**\n * Gets the tile labels stored in the given reference position.\n * @legacy @beta\n */\nexport const refGetTileLabels = (refPos: ReferencePosition): string[] | undefined =>\n\trefTypeIncludesFlag(refPos, ReferenceType.Tile) && refPos.properties\n\t\t? (refPos.properties[reservedTileLabelsKey] as string[])\n\t\t: undefined;\n\n/**\n * Determines if a reference position has the given tile label.\n * @legacy @beta\n */\nexport function refHasTileLabel(refPos: ReferencePosition, label: string): boolean {\n\tconst tileLabels = refGetTileLabels(refPos);\n\treturn tileLabels?.includes(label) ?? false;\n}\n\n/**\n * Determines if a reference position has any tile labels.\n * @internal\n */\nexport function refHasTileLabels(refPos: ReferencePosition): boolean {\n\treturn refGetTileLabels(refPos) !== undefined;\n}\n\n/**\n * Represents a reference to a place within a merge tree. This place conceptually remains stable over time\n * by referring to a particular segment and offset within that segment.\n * Thus, this reference's character position changes as the tree is edited.\n * @legacy @beta\n */\nexport interface ReferencePosition {\n\t/**\n\t * Properties associated with this reference\n\t */\n\tproperties?: PropertySet;\n\n\t/**\n\t * The direction for this reference position to slide when the segment it\n\t * points to is removed. See {@link (SlidingPreference:type)} for additional context.\n\t *\n\t * Defaults to SlidingPreference.Forward\n\t */\n\tslidingPreference?: SlidingPreference;\n\n\trefType: ReferenceType;\n\n\t/**\n\t * Gets the segment that this reference position is semantically associated with. Returns undefined iff the\n\t * reference became detached from the string.\n\t */\n\tgetSegment(): ISegment | undefined;\n\n\t/**\n\t * Gets the offset for this reference position within its associated segment.\n\t *\n\t * @example\n\t *\n\t * If a merge-tree has 3 leaf segments [\"hello\", \" \", \"world\"] and a ReferencePosition refers to the \"l\"\n\t * in \"world\", that reference's offset would be 3 as \"l\" is the character at index 3 within \"world\".\n\t */\n\tgetOffset(): number;\n\n\tisLeaf(): this is ISegment;\n}\n\n/**\n * @internal\n */\nexport const DetachedReferencePosition = -1;\n\n/**\n * Finds the minimum reference position.\n * @internal\n */\nexport function minReferencePosition<T extends ReferencePosition>(a: T, b: T): T {\n\treturn compareReferencePositions(a, b) < 0 ? a : b;\n}\n\n/**\n * Finds the maximum reference position.\n * @internal\n */\nexport function maxReferencePosition<T extends ReferencePosition>(a: T, b: T): T {\n\treturn compareReferencePositions(a, b) > 0 ? a : b;\n}\n\n/**\n * Compares two reference positions.\n * @internal\n */\nexport function compareReferencePositions(a: ReferencePosition, b: ReferencePosition): number {\n\tconst aSeg = a.getSegment();\n\tconst bSeg = b.getSegment();\n\tif (aSeg === bSeg) {\n\t\treturn a.getOffset() - b.getOffset();\n\t} else {\n\t\treturn !isMergeNodeInfo(aSeg) || (isMergeNodeInfo(bSeg) && aSeg.ordinal < bSeg.ordinal)\n\t\t\t? -1\n\t\t\t: 1;\n\t}\n}\n"]}
1
+ {"version":3,"file":"referencePositions.js","sourceRoot":"","sources":["../src/referencePositions.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAqBH,kDAOC;AAeD,0CAGC;AAMD,4CAEC;AAoDD,oDAEC;AAMD,oDAEC;AAMD,8DAUC;AAhID,qCAAyC;AAEzC,uDAAoD;AAEpD;;GAEG;AACU,QAAA,qBAAqB,GAAG,qBAAqB,CAAC;AAC3D;;GAEG;AACU,QAAA,sBAAsB,GAAG,sBAAsB,CAAC;AAE7D;;;GAGG;AACH,SAAgB,mBAAmB,CAClC,YAA+C,EAC/C,KAAoB;IAEpB,MAAM,OAAO,GAAG,OAAO,YAAY,KAAK,QAAQ,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,YAAY,CAAC,OAAO,CAAC;IACvF,sCAAsC;IACtC,OAAO,CAAC,OAAO,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC;AAChC,CAAC;AAED;;;GAGG;AACI,MAAM,gBAAgB,GAAG,CAAC,MAAyB,EAAwB,EAAE,CACnF,mBAA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;IACtC,CAAC;SAAM,CAAC;QACP,OAAO,CAAC,IAAA,iCAAe,EAAC,IAAI,CAAC,IAAI,CAAC,IAAA,iCAAe,EAAC,IAAI,CAAC,IAAI,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC;YACtF,CAAC,CAAC,CAAC,CAAC;YACJ,CAAC,CAAC,CAAC,CAAC;IACN,CAAC;AACF,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { SlidingPreference } from \"./localReference.js\";\nimport type { ISegment } from \"./mergeTreeNodes.js\";\nimport { ReferenceType } from \"./ops.js\";\nimport type { PropertySet } from \"./properties.js\";\nimport { isMergeNodeInfo } from \"./segmentInfos.js\";\n\n/**\n * @internal\n */\nexport const reservedTileLabelsKey = \"referenceTileLabels\";\n/**\n * @internal\n */\nexport const reservedRangeLabelsKey = \"referenceRangeLabels\";\n\n/**\n * Determines if the given reference type includes the given flags.\n * @internal\n */\nexport function refTypeIncludesFlag(\n\trefPosOrType: ReferencePosition | ReferenceType,\n\tflags: ReferenceType,\n): boolean {\n\tconst refType = typeof refPosOrType === \"number\" ? refPosOrType : refPosOrType.refType;\n\t// eslint-disable-next-line no-bitwise\n\treturn (refType & flags) !== 0;\n}\n\n/**\n * Gets the tile labels stored in the given reference position.\n * @legacy @beta\n */\nexport const refGetTileLabels = (refPos: ReferencePosition): string[] | undefined =>\n\trefTypeIncludesFlag(refPos, ReferenceType.Tile) && refPos.properties\n\t\t? (refPos.properties[reservedTileLabelsKey] as string[])\n\t\t: undefined;\n\n/**\n * Determines if a reference position has the given tile label.\n * @legacy @beta\n */\nexport function refHasTileLabel(refPos: ReferencePosition, label: string): boolean {\n\tconst tileLabels = refGetTileLabels(refPos);\n\treturn tileLabels?.includes(label) ?? false;\n}\n\n/**\n * Determines if a reference position has any tile labels.\n * @internal\n */\nexport function refHasTileLabels(refPos: ReferencePosition): boolean {\n\treturn refGetTileLabels(refPos) !== undefined;\n}\n\n/**\n * Represents a reference to a place within a merge tree. This place conceptually remains stable over time\n * by referring to a particular segment and offset within that segment.\n * Thus, this reference's character position changes as the tree is edited.\n * @legacy @beta\n */\nexport interface ReferencePosition {\n\t/**\n\t * Properties associated with this reference\n\t */\n\tproperties?: PropertySet;\n\n\t/**\n\t * The direction for this reference position to slide when the segment it\n\t * points to is removed. See {@link (SlidingPreference:type)} for additional context.\n\t *\n\t * Defaults to SlidingPreference.Forward\n\t */\n\tslidingPreference?: SlidingPreference;\n\n\trefType: ReferenceType;\n\n\t/**\n\t * Gets the segment that this reference position is semantically associated with. Returns undefined iff the\n\t * reference became detached from the string.\n\t */\n\tgetSegment(): ISegment | undefined;\n\n\t/**\n\t * Gets the offset for this reference position within its associated segment.\n\t *\n\t * @example\n\t *\n\t * If a merge-tree has 3 leaf segments [\"hello\", \" \", \"world\"] and a ReferencePosition refers to the \"l\"\n\t * in \"world\", that reference's offset would be 3 as \"l\" is the character at index 3 within \"world\".\n\t */\n\tgetOffset(): number;\n\n\tisLeaf(): this is ISegment;\n}\n\n/**\n * @internal\n */\nexport const DetachedReferencePosition = -1;\n\n/**\n * Finds the minimum reference position.\n * @internal\n */\nexport function minReferencePosition<T extends ReferencePosition>(a: T, b: T): T {\n\treturn compareReferencePositions(a, b) < 0 ? a : b;\n}\n\n/**\n * Finds the maximum reference position.\n * @internal\n */\nexport function maxReferencePosition<T extends ReferencePosition>(a: T, b: T): T {\n\treturn compareReferencePositions(a, b) > 0 ? a : b;\n}\n\n/**\n * Compares two reference positions.\n * @internal\n */\nexport function compareReferencePositions(a: ReferencePosition, b: ReferencePosition): number {\n\tconst aSeg = a.getSegment();\n\tconst bSeg = b.getSegment();\n\tif (aSeg === bSeg) {\n\t\treturn a.getOffset() - b.getOffset();\n\t} else {\n\t\treturn !isMergeNodeInfo(aSeg) || (isMergeNodeInfo(bSeg) && aSeg.ordinal < bSeg.ordinal)\n\t\t\t? -1\n\t\t\t: 1;\n\t}\n}\n"]}
@@ -4,7 +4,10 @@
4
4
  * Licensed under the MIT License.
5
5
  */
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.revertMergeTreeDeltaRevertibles = exports.discardMergeTreeDeltaRevertible = exports.appendToMergeTreeDeltaRevertibles = exports.isMergeTreeDeltaRevertible = void 0;
7
+ exports.isMergeTreeDeltaRevertible = isMergeTreeDeltaRevertible;
8
+ exports.appendToMergeTreeDeltaRevertibles = appendToMergeTreeDeltaRevertibles;
9
+ exports.discardMergeTreeDeltaRevertible = discardMergeTreeDeltaRevertible;
10
+ exports.revertMergeTreeDeltaRevertibles = revertMergeTreeDeltaRevertibles;
8
11
  const internal_1 = require("@fluidframework/core-utils/internal");
9
12
  const internal_2 = require("@fluidframework/telemetry-utils/internal");
10
13
  const endOfTreeSegment_js_1 = require("./endOfTreeSegment.js");
@@ -24,7 +27,6 @@ const segmentInfos_js_1 = require("./segmentInfos.js");
24
27
  function isMergeTreeDeltaRevertible(x) {
25
28
  return !!x && typeof x === "object" && "operation" in x && "trackingGroup" in x;
26
29
  }
27
- exports.isMergeTreeDeltaRevertible = isMergeTreeDeltaRevertible;
28
30
  function findMergeTreeWithRevert(trackable) {
29
31
  const segmentOrNode = trackable.isLeaf() ? trackable : trackable.getSegment();
30
32
  const maybeRoot = (0, mergeTree_js_1.findRootMergeBlock)((0, mergeTreeNodes_js_1.toSegmentLeaf)(segmentOrNode));
@@ -134,7 +136,6 @@ function appendToMergeTreeDeltaRevertibles(deltaArgs, revertibles) {
134
136
  }
135
137
  }
136
138
  }
137
- exports.appendToMergeTreeDeltaRevertibles = appendToMergeTreeDeltaRevertibles;
138
139
  /**
139
140
  * Removes all revertibles from the list of revertibles.
140
141
  *
@@ -152,7 +153,6 @@ function discardMergeTreeDeltaRevertible(revertibles) {
152
153
  }
153
154
  }
154
155
  }
155
- exports.discardMergeTreeDeltaRevertible = discardMergeTreeDeltaRevertible;
156
156
  function revertLocalInsert(driver, mergeTreeWithRevert, revertible) {
157
157
  while (revertible.trackingGroup.size > 0) {
158
158
  const tracked = revertible.trackingGroup.tracked[0];
@@ -280,5 +280,4 @@ function revertMergeTreeDeltaRevertibles(driver, revertibles) {
280
280
  }
281
281
  }
282
282
  }
283
- exports.revertMergeTreeDeltaRevertibles = revertMergeTreeDeltaRevertibles;
284
283
  //# sourceMappingURL=revertibles.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"revertibles.js","sourceRoot":"","sources":["../src/revertibles.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAI6C;AAC7C,uEAAsE;AAEtE,+DAAyD;AACzD,2DAA4F;AAC5F,iDAAoE;AAEpE,iEAA4D;AAC5D,2DAM6B;AAC7B,iEAIgC;AAChC,qCAAgF;AAChF,mDAAoE;AACpE,mEAAoE;AACpE,uDAAkD;AAoBlD;;;GAGG;AACH,SAAgB,0BAA0B,CAAC,CAAU;IACpD,OAAO,CAAC,CAAC,CAAC,IAAI,OAAO,CAAC,KAAK,QAAQ,IAAI,WAAW,IAAI,CAAC,IAAI,eAAe,IAAI,CAAC,CAAC;AACjF,CAAC;AAFD,gEAEC;AAuCD,SAAS,uBAAuB,CAAC,SAAoB;IACpD,MAAM,aAAa,GAAG,SAAS,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,UAAU,EAAE,CAAC;IAC9E,MAAM,SAAS,GAAG,IAAA,iCAAkB,EAAC,IAAA,iCAAa,EAAC,aAAa,CAAC,CAAC,CAAC;IACnE,IAAA,iBAAM,EACL,SAAS,EAAE,SAAS,KAAK,SAAS,EAClC,KAAK,CAAC,+DAA+D,CACrE,CAAC;IACF,MAAM,SAAS,GACd,SAAS,CAAC,SAAS,CAAC;IAErB,IAAI,SAAS,CAAC,qBAAqB,KAAK,SAAS,EAAE,CAAC;QACnD,MAAM,kBAAkB,GAAG,IAAI,sCAAgB,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;QACrE,MAAM,YAAY,GAAiE;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AAiB,CAAC,MAAM,EAAE,mBAAmB,EAAE,CAAC,CAAC,CAAC;oBAClD,MAAM;gBACP,CAAC;gBACD,KAAK,2BAAkB,CAAC,QAAQ,CAAC,CAAC,CAAC;oBAClC,mBAAmB,CAAC,MAAM,EAAE,mBAAmB,EAAE,CAAC,CAAC,CAAC;oBACpD,MAAM;gBACP,CAAC;gBACD,OAAO,CAAC,CAAC,CAAC;oBACT,IAAA,0BAAe,EAAC,SAAS,CAAC,CAAC;gBAC5B,CAAC;YACF,CAAC;QACF,CAAC;IACF,CAAC;AACF,CAAC;AA/BD,0EA+BC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\tassert,\n\tunreachableCase,\n\tDoublyLinkedList,\n} from \"@fluidframework/core-utils/internal\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\n\nimport { EndOfTreeSegment } from \"./endOfTreeSegment.js\";\nimport { LocalReferenceCollection, type LocalReferencePosition } from \"./localReference.js\";\nimport { type MergeTree, findRootMergeBlock } from \"./mergeTree.js\";\nimport type { IMergeTreeDeltaCallbackArgs } from \"./mergeTreeDeltaCallback.js\";\nimport { depthFirstNodeWalk } from \"./mergeTreeNodeWalk.js\";\nimport {\n\tassertSegmentLeaf,\n\tisSegmentLeaf,\n\ttoSegmentLeaf,\n\ttype ISegmentLeaf,\n\ttype ISegmentPrivate,\n} from \"./mergeTreeNodes.js\";\nimport {\n\ttype ITrackingGroup,\n\ttype Trackable,\n\tUnorderedTrackingGroup,\n} from \"./mergeTreeTracking.js\";\nimport { type IJSONSegment, MergeTreeDeltaType, ReferenceType } from \"./ops.js\";\nimport { type PropertySet, matchProperties } from \"./properties.js\";\nimport { DetachedReferencePosition } from \"./referencePositions.js\";\nimport { toRemovalInfo } from \"./segmentInfos.js\";\n\n/**\n * @legacy @beta\n */\nexport type MergeTreeDeltaRevertible =\n\t| {\n\t\t\toperation: typeof MergeTreeDeltaType.INSERT;\n\t\t\ttrackingGroup: ITrackingGroup;\n\t }\n\t| {\n\t\t\toperation: typeof MergeTreeDeltaType.REMOVE;\n\t\t\ttrackingGroup: ITrackingGroup;\n\t }\n\t| {\n\t\t\toperation: typeof MergeTreeDeltaType.ANNOTATE;\n\t\t\ttrackingGroup: ITrackingGroup;\n\t\t\tpropertyDeltas: PropertySet;\n\t };\n\n/**\n * Tests whether x is a MergeTreeDeltaRevertible\n * @internal\n */\nexport function isMergeTreeDeltaRevertible(x: unknown): x is MergeTreeDeltaRevertible {\n\treturn !!x && typeof x === \"object\" && \"operation\" in x && \"trackingGroup\" in x;\n}\n\ntype TypedRevertible<T extends MergeTreeDeltaRevertible[\"operation\"]> =\n\tMergeTreeDeltaRevertible & {\n\t\toperation: T;\n\t};\n\ninterface RemoveSegmentRefProperties {\n\t/**\n\t * the serialized form of the segment, so it can be re-inserted\n\t */\n\tsegSpec: IJSONSegment;\n\t/**\n\t * a tag so the reference can be identified as being created for revert\n\t */\n\treferenceSpace: \"mergeTreeDeltaRevertible\";\n}\n\n/**\n * @legacy @beta\n */\nexport interface MergeTreeRevertibleDriver {\n\tinsertFromSpec(pos: number, spec: IJSONSegment): void;\n\tremoveRange(start: number, end: number): void;\n\tannotateRange(start: number, end: number, props: PropertySet): void;\n}\n\n/**\n * exported for test only. should not be exported out the the package\n * @internal\n */\nexport interface MergeTreeWithRevert extends MergeTree {\n\t__mergeTreeRevertible: {\n\t\tdetachedReferences: EndOfTreeSegment;\n\t\trefCallbacks: LocalReferencePosition[\"callbacks\"];\n\t};\n}\n\nexport type PickPartial<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;\nfunction findMergeTreeWithRevert(trackable: Trackable): MergeTreeWithRevert {\n\tconst segmentOrNode = trackable.isLeaf() ? trackable : trackable.getSegment();\n\tconst maybeRoot = findRootMergeBlock(toSegmentLeaf(segmentOrNode));\n\tassert(\n\t\tmaybeRoot?.mergeTree !== undefined,\n\t\t0x5c2 /* trackable is invalid as it is not in a rooted merge tree. */,\n\t);\n\tconst mergeTree: PickPartial<MergeTreeWithRevert, \"__mergeTreeRevertible\"> =\n\t\tmaybeRoot.mergeTree;\n\n\tif (mergeTree.__mergeTreeRevertible === undefined) {\n\t\tconst detachedReferences = new EndOfTreeSegment(maybeRoot.mergeTree);\n\t\tconst refCallbacks: MergeTreeWithRevert[\"__mergeTreeRevertible\"][\"refCallbacks\"] = {\n\t\t\tafterSlide: (r: LocalReferencePosition) => {\n\t\t\t\tif (mergeTree.referencePositionToLocalPosition(r) === DetachedReferencePosition) {\n\t\t\t\t\tconst refs = LocalReferenceCollection.setOrGet(detachedReferences);\n\t\t\t\t\trefs.addAfterTombstones([r]);\n\t\t\t\t}\n\t\t\t},\n\t\t};\n\t\tmergeTree.__mergeTreeRevertible = {\n\t\t\trefCallbacks,\n\t\t\tdetachedReferences,\n\t\t};\n\t}\n\treturn mergeTree as MergeTreeWithRevert;\n}\n\nfunction appendLocalInsertToRevertibles(\n\tdeltaArgs: IMergeTreeDeltaCallbackArgs,\n\trevertibles: MergeTreeDeltaRevertible[],\n): MergeTreeDeltaRevertible[] {\n\tif (revertibles[revertibles.length - 1]?.operation !== MergeTreeDeltaType.INSERT) {\n\t\trevertibles.push({\n\t\t\toperation: MergeTreeDeltaType.INSERT,\n\t\t\ttrackingGroup: new UnorderedTrackingGroup(),\n\t\t});\n\t}\n\tconst last = revertibles[revertibles.length - 1];\n\tfor (const t of deltaArgs.deltaSegments) last.trackingGroup.link(t.segment);\n\n\treturn revertibles;\n}\n\nfunction appendLocalRemoveToRevertibles(\n\tdeltaArgs: IMergeTreeDeltaCallbackArgs,\n\trevertibles: MergeTreeDeltaRevertible[],\n): MergeTreeDeltaRevertible[] {\n\tif (revertibles[revertibles.length - 1]?.operation !== MergeTreeDeltaType.REMOVE) {\n\t\trevertibles.push({\n\t\t\toperation: MergeTreeDeltaType.REMOVE,\n\t\t\ttrackingGroup: new UnorderedTrackingGroup(),\n\t\t});\n\t}\n\tconst last = revertibles[revertibles.length - 1];\n\n\tconst mergeTreeWithRevert = findMergeTreeWithRevert(deltaArgs.deltaSegments[0].segment);\n\n\tfor (const t of deltaArgs.deltaSegments) {\n\t\tconst props: RemoveSegmentRefProperties = {\n\t\t\tsegSpec: t.segment.toJSONObject() as IJSONSegment,\n\t\t\treferenceSpace: \"mergeTreeDeltaRevertible\",\n\t\t};\n\t\tconst ref = mergeTreeWithRevert.createLocalReferencePosition(\n\t\t\tt.segment,\n\t\t\t0,\n\t\t\tReferenceType.SlideOnRemove,\n\t\t\tprops,\n\t\t);\n\t\tref.callbacks = mergeTreeWithRevert.__mergeTreeRevertible.refCallbacks;\n\t\tfor (const tg of t.segment.trackingCollection.trackingGroups) {\n\t\t\ttg.link(ref);\n\t\t\ttg.unlink(t.segment);\n\t\t}\n\n\t\tlast.trackingGroup.link(ref);\n\t}\n\treturn revertibles;\n}\n\nfunction appendLocalAnnotateToRevertibles(\n\tdeltaArgs: IMergeTreeDeltaCallbackArgs,\n\trevertibles: MergeTreeDeltaRevertible[],\n): MergeTreeDeltaRevertible[] {\n\tlet last = revertibles[revertibles.length - 1];\n\tfor (const ds of deltaArgs.deltaSegments) {\n\t\tconst propertyDeltas = ds.propertyDeltas;\n\t\tif (propertyDeltas) {\n\t\t\tif (\n\t\t\t\tlast?.operation === MergeTreeDeltaType.ANNOTATE &&\n\t\t\t\tmatchProperties(last?.propertyDeltas, propertyDeltas)\n\t\t\t) {\n\t\t\t\tlast.trackingGroup.link(ds.segment);\n\t\t\t} else {\n\t\t\t\tlast = {\n\t\t\t\t\toperation: MergeTreeDeltaType.ANNOTATE,\n\t\t\t\t\tpropertyDeltas,\n\t\t\t\t\ttrackingGroup: new UnorderedTrackingGroup(),\n\t\t\t\t};\n\t\t\t\tlast.trackingGroup.link(ds.segment);\n\t\t\t\trevertibles.push(last);\n\t\t\t}\n\t\t}\n\t}\n\treturn revertibles;\n}\n\n/**\n * Appends a merge tree delta to the list of revertibles.\n *\n * @legacy @beta\n */\nexport function appendToMergeTreeDeltaRevertibles(\n\tdeltaArgs: IMergeTreeDeltaCallbackArgs,\n\trevertibles: MergeTreeDeltaRevertible[],\n): void {\n\tif (deltaArgs.deltaSegments.length === 0) {\n\t\treturn;\n\t}\n\tswitch (deltaArgs.operation) {\n\t\tcase MergeTreeDeltaType.INSERT: {\n\t\t\tappendLocalInsertToRevertibles(deltaArgs, revertibles);\n\t\t\tbreak;\n\t\t}\n\n\t\tcase MergeTreeDeltaType.REMOVE: {\n\t\t\tappendLocalRemoveToRevertibles(deltaArgs, revertibles);\n\t\t\tbreak;\n\t\t}\n\n\t\tcase MergeTreeDeltaType.ANNOTATE: {\n\t\t\tappendLocalAnnotateToRevertibles(deltaArgs, revertibles);\n\t\t\tbreak;\n\t\t}\n\n\t\tdefault: {\n\t\t\tthrow new UsageError(\"Unsupported event delta type\", {\n\t\t\t\toperation: deltaArgs.operation,\n\t\t\t});\n\t\t}\n\t}\n}\n\n/**\n * Removes all revertibles from the list of revertibles.\n *\n * @legacy @beta\n */\nexport function discardMergeTreeDeltaRevertible(\n\trevertibles: MergeTreeDeltaRevertible[],\n): void {\n\tfor (const r of revertibles) {\n\t\tfor (const t of r.trackingGroup.tracked) {\n\t\t\tt.trackingCollection.unlink(r.trackingGroup);\n\t\t\t// remove untracked local references\n\t\t\tif (t.trackingCollection.empty && !t.isLeaf()) {\n\t\t\t\tconst segment: ISegmentPrivate | undefined = t.getSegment();\n\t\t\t\tsegment?.localRefs?.removeLocalRef(t);\n\t\t\t}\n\t\t}\n\t}\n}\n\nfunction revertLocalInsert(\n\tdriver: MergeTreeRevertibleDriver,\n\tmergeTreeWithRevert: MergeTreeWithRevert,\n\trevertible: TypedRevertible<typeof MergeTreeDeltaType.INSERT>,\n): void {\n\twhile (revertible.trackingGroup.size > 0) {\n\t\tconst tracked = revertible.trackingGroup.tracked[0];\n\t\tassert(\n\t\t\ttracked.trackingCollection.unlink(revertible.trackingGroup),\n\t\t\t0x3f1 /* tracking group removed */,\n\t\t);\n\t\tassert(isSegmentLeaf(tracked), 0x3f2 /* inserts must track segments */);\n\t\tif (toRemovalInfo(tracked) === undefined) {\n\t\t\tconst start = getPosition(mergeTreeWithRevert, tracked);\n\t\t\tdriver.removeRange(start, start + tracked.cachedLength);\n\t\t}\n\t}\n}\n\nfunction revertLocalRemove(\n\tdriver: MergeTreeRevertibleDriver,\n\tmergeTreeWithRevert: MergeTreeWithRevert,\n\trevertible: TypedRevertible<typeof MergeTreeDeltaType.REMOVE>,\n): void {\n\twhile (revertible.trackingGroup.size > 0) {\n\t\tconst tracked = revertible.trackingGroup.tracked[0];\n\n\t\tassert(\n\t\t\ttracked.trackingCollection.unlink(revertible.trackingGroup),\n\t\t\t0x3f3 /* tracking group removed */,\n\t\t);\n\n\t\tassert(!tracked.isLeaf(), 0x3f4 /* removes must track local refs */);\n\n\t\tconst refSeg = tracked.getSegment();\n\t\tlet realPos = mergeTreeWithRevert.referencePositionToLocalPosition(tracked);\n\n\t\t// References which are on EndOfStringSegment don't return detached for pos,\n\t\t// they will return the length of the merge-tree. this case just catches\n\t\t// random references, likely not created in the revertible flow,\n\t\t// that are tying to be reverted for some reason.\n\t\tif (realPos === DetachedReferencePosition || !isSegmentLeaf(refSeg)) {\n\t\t\tthrow new UsageError(\"Cannot insert at detached references position\");\n\t\t}\n\n\t\tif (toRemovalInfo(refSeg) === undefined && refSeg.localRefs?.isAfterTombstone(tracked)) {\n\t\t\trealPos++;\n\t\t}\n\n\t\tconst props = tracked.properties as RemoveSegmentRefProperties;\n\t\tdriver.insertFromSpec(realPos, props.segSpec);\n\t\tconst insertSegment = mergeTreeWithRevert.getContainingSegment(\n\t\t\trealPos,\n\t\t\tmergeTreeWithRevert.localPerspective,\n\t\t)?.segment;\n\t\tassertSegmentLeaf(insertSegment);\n\n\t\tconst localSlideFilter = (lref: LocalReferencePosition): boolean =>\n\t\t\t(lref.properties as Partial<RemoveSegmentRefProperties>)?.referenceSpace ===\n\t\t\t\"mergeTreeDeltaRevertible\";\n\n\t\tconst insertRef: Partial<\n\t\t\tRecord<\"before\" | \"after\", DoublyLinkedList<LocalReferencePosition>>\n\t\t> = {};\n\t\tconst forward = insertSegment.ordinal < refSeg.ordinal;\n\t\tconst refHandler = (lref: LocalReferencePosition): false | undefined => {\n\t\t\t// once we reach it keep the original reference where it is\n\t\t\t// we'll move tracking groups, and remove it as a last step.\n\t\t\tif (tracked === lref) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tif (localSlideFilter(lref)) {\n\t\t\t\tif (forward) {\n\t\t\t\t\tconst before = (insertRef.before ??= new DoublyLinkedList());\n\t\t\t\t\tbefore.push(lref);\n\t\t\t\t} else {\n\t\t\t\t\tconst after = (insertRef.after ??= new DoublyLinkedList());\n\t\t\t\t\tafter.unshift(lref);\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\t\tdepthFirstNodeWalk(\n\t\t\tinsertSegment.parent,\n\t\t\tinsertSegment,\n\t\t\tundefined,\n\t\t\t(seg: ISegmentPrivate) => {\n\t\t\t\tif (seg.localRefs?.empty === false) {\n\t\t\t\t\treturn seg.localRefs.walkReferences(refHandler, undefined, forward);\n\t\t\t\t}\n\t\t\t\treturn true;\n\t\t\t},\n\t\t\tundefined,\n\t\t\tforward,\n\t\t);\n\t\tif (\n\t\t\tmergeTreeWithRevert?.__mergeTreeRevertible?.detachedReferences?.localRefs?.has(tracked)\n\t\t) {\n\t\t\tassert(forward, 0x3f6 /* forward should always be true when detached */);\n\t\t\tmergeTreeWithRevert?.__mergeTreeRevertible.detachedReferences.localRefs.walkReferences(\n\t\t\t\trefHandler,\n\t\t\t);\n\t\t}\n\n\t\tif (insertRef !== undefined) {\n\t\t\tconst localRefs = LocalReferenceCollection.setOrGet(insertSegment);\n\t\t\tif (insertRef.before?.empty === false) {\n\t\t\t\tlocalRefs.addBeforeTombstones(insertRef.before.map((n) => n.data));\n\t\t\t}\n\t\t\tif (insertRef.after?.empty === false) {\n\t\t\t\tlocalRefs.addAfterTombstones(insertRef.after.map((n) => n.data));\n\t\t\t}\n\t\t}\n\n\t\tfor (const tg of tracked.trackingCollection.trackingGroups) {\n\t\t\ttg.link(insertSegment);\n\t\t\ttg.unlink(tracked);\n\t\t}\n\t\tconst segment: ISegmentPrivate | undefined = tracked.getSegment();\n\t\tsegment?.localRefs?.removeLocalRef(tracked);\n\t}\n}\n\nfunction revertLocalAnnotate(\n\tdriver: MergeTreeRevertibleDriver,\n\tmergeTreeWithRevert: MergeTreeWithRevert,\n\trevertible: TypedRevertible<typeof MergeTreeDeltaType.ANNOTATE>,\n): void {\n\twhile (revertible.trackingGroup.size > 0) {\n\t\tconst tracked = revertible.trackingGroup.tracked[0];\n\t\tconst unlinked = tracked.trackingCollection.unlink(revertible.trackingGroup);\n\t\tassert(unlinked && isSegmentLeaf(tracked), 0x3f7 /* annotates must track segments */);\n\t\tif (toRemovalInfo(tracked) === undefined) {\n\t\t\tconst start = getPosition(mergeTreeWithRevert, tracked);\n\t\t\tdriver.annotateRange(start, start + tracked.cachedLength, revertible.propertyDeltas);\n\t\t}\n\t}\n}\n\nfunction getPosition(mergeTreeWithRevert: MergeTreeWithRevert, segment: ISegmentLeaf): number {\n\treturn mergeTreeWithRevert.getPosition(segment, mergeTreeWithRevert.localPerspective);\n}\n\n/**\n * Reverts all operations in the list of revertibles.\n *\n * @legacy @beta\n */\nexport function revertMergeTreeDeltaRevertibles(\n\tdriver: MergeTreeRevertibleDriver,\n\trevertibles: MergeTreeDeltaRevertible[],\n): void {\n\tlet mergeTreeWithRevert: MergeTreeWithRevert | undefined;\n\n\twhile (revertibles.length > 0) {\n\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\tconst r = revertibles.pop()!;\n\t\tconst operation = r.operation;\n\t\tif (r.trackingGroup.size > 0) {\n\t\t\tmergeTreeWithRevert ??= findMergeTreeWithRevert(r.trackingGroup.tracked[0]);\n\t\t\tswitch (operation) {\n\t\t\t\tcase MergeTreeDeltaType.INSERT: {\n\t\t\t\t\trevertLocalInsert(driver, mergeTreeWithRevert, r);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcase MergeTreeDeltaType.REMOVE: {\n\t\t\t\t\trevertLocalRemove(driver, mergeTreeWithRevert, r);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcase MergeTreeDeltaType.ANNOTATE: {\n\t\t\t\t\trevertLocalAnnotate(driver, mergeTreeWithRevert, r);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tdefault: {\n\t\t\t\t\tunreachableCase(operation);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n"]}
1
+ {"version":3,"file":"revertibles.js","sourceRoot":"","sources":["../src/revertibles.ts"],"names":[],"mappings":";AAAA;;;GAGG;;AAqDH,gEAEC;AAuJD,8EA6BC;AAOD,0EAaC;AAqJD,0EA+BC;AAjbD,kEAI6C;AAC7C,uEAAsE;AAEtE,+DAAyD;AACzD,2DAA4F;AAC5F,iDAAoE;AAEpE,iEAA4D;AAC5D,2DAM6B;AAC7B,iEAIgC;AAChC,qCAAgF;AAChF,mDAAoE;AACpE,mEAAoE;AACpE,uDAAkD;AAoBlD;;;GAGG;AACH,SAAgB,0BAA0B,CAAC,CAAU;IACpD,OAAO,CAAC,CAAC,CAAC,IAAI,OAAO,CAAC,KAAK,QAAQ,IAAI,WAAW,IAAI,CAAC,IAAI,eAAe,IAAI,CAAC,CAAC;AACjF,CAAC;AAuCD,SAAS,uBAAuB,CAAC,SAAoB;IACpD,MAAM,aAAa,GAAG,SAAS,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,UAAU,EAAE,CAAC;IAC9E,MAAM,SAAS,GAAG,IAAA,iCAAkB,EAAC,IAAA,iCAAa,EAAC,aAAa,CAAC,CAAC,CAAC;IACnE,IAAA,iBAAM,EACL,SAAS,EAAE,SAAS,KAAK,SAAS,EAClC,KAAK,CAAC,+DAA+D,CACrE,CAAC;IACF,MAAM,S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CAAC,CAAC;oBAChC,iBAAiB,CAAC,MAAM,EAAE,mBAAmB,EAAE,CAAC,CAAC,CAAC;oBAClD,MAAM;gBACP,CAAC;gBACD,KAAK,2BAAkB,CAAC,MAAM,CAAC,CAAC,CAAC;oBAChC,iBAAiB,CAAC,MAAM,EAAE,mBAAmB,EAAE,CAAC,CAAC,CAAC;oBAClD,MAAM;gBACP,CAAC;gBACD,KAAK,2BAAkB,CAAC,QAAQ,CAAC,CAAC,CAAC;oBAClC,mBAAmB,CAAC,MAAM,EAAE,mBAAmB,EAAE,CAAC,CAAC,CAAC;oBACpD,MAAM;gBACP,CAAC;gBACD,OAAO,CAAC,CAAC,CAAC;oBACT,IAAA,0BAAe,EAAC,SAAS,CAAC,CAAC;gBAC5B,CAAC;YACF,CAAC;QACF,CAAC;IACF,CAAC;AACF,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\tassert,\n\tunreachableCase,\n\tDoublyLinkedList,\n} from \"@fluidframework/core-utils/internal\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\n\nimport { EndOfTreeSegment } from \"./endOfTreeSegment.js\";\nimport { LocalReferenceCollection, type LocalReferencePosition } from \"./localReference.js\";\nimport { type MergeTree, findRootMergeBlock } from \"./mergeTree.js\";\nimport type { IMergeTreeDeltaCallbackArgs } from \"./mergeTreeDeltaCallback.js\";\nimport { depthFirstNodeWalk } from \"./mergeTreeNodeWalk.js\";\nimport {\n\tassertSegmentLeaf,\n\tisSegmentLeaf,\n\ttoSegmentLeaf,\n\ttype ISegmentLeaf,\n\ttype ISegmentPrivate,\n} from \"./mergeTreeNodes.js\";\nimport {\n\ttype ITrackingGroup,\n\ttype Trackable,\n\tUnorderedTrackingGroup,\n} from \"./mergeTreeTracking.js\";\nimport { type IJSONSegment, MergeTreeDeltaType, ReferenceType } from \"./ops.js\";\nimport { type PropertySet, matchProperties } from \"./properties.js\";\nimport { DetachedReferencePosition } from \"./referencePositions.js\";\nimport { toRemovalInfo } from \"./segmentInfos.js\";\n\n/**\n * @legacy @beta\n */\nexport type MergeTreeDeltaRevertible =\n\t| {\n\t\t\toperation: typeof MergeTreeDeltaType.INSERT;\n\t\t\ttrackingGroup: ITrackingGroup;\n\t }\n\t| {\n\t\t\toperation: typeof MergeTreeDeltaType.REMOVE;\n\t\t\ttrackingGroup: ITrackingGroup;\n\t }\n\t| {\n\t\t\toperation: typeof MergeTreeDeltaType.ANNOTATE;\n\t\t\ttrackingGroup: ITrackingGroup;\n\t\t\tpropertyDeltas: PropertySet;\n\t };\n\n/**\n * Tests whether x is a MergeTreeDeltaRevertible\n * @internal\n */\nexport function isMergeTreeDeltaRevertible(x: unknown): x is MergeTreeDeltaRevertible {\n\treturn !!x && typeof x === \"object\" && \"operation\" in x && \"trackingGroup\" in x;\n}\n\ntype TypedRevertible<T extends MergeTreeDeltaRevertible[\"operation\"]> =\n\tMergeTreeDeltaRevertible & {\n\t\toperation: T;\n\t};\n\ninterface RemoveSegmentRefProperties {\n\t/**\n\t * the serialized form of the segment, so it can be re-inserted\n\t */\n\tsegSpec: IJSONSegment;\n\t/**\n\t * a tag so the reference can be identified as being created for revert\n\t */\n\treferenceSpace: \"mergeTreeDeltaRevertible\";\n}\n\n/**\n * @legacy @beta\n */\nexport interface MergeTreeRevertibleDriver {\n\tinsertFromSpec(pos: number, spec: IJSONSegment): void;\n\tremoveRange(start: number, end: number): void;\n\tannotateRange(start: number, end: number, props: PropertySet): void;\n}\n\n/**\n * exported for test only. should not be exported out the the package\n * @internal\n */\nexport interface MergeTreeWithRevert extends MergeTree {\n\t__mergeTreeRevertible: {\n\t\tdetachedReferences: EndOfTreeSegment;\n\t\trefCallbacks: LocalReferencePosition[\"callbacks\"];\n\t};\n}\n\nexport type PickPartial<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;\nfunction findMergeTreeWithRevert(trackable: Trackable): MergeTreeWithRevert {\n\tconst segmentOrNode = trackable.isLeaf() ? trackable : trackable.getSegment();\n\tconst maybeRoot = findRootMergeBlock(toSegmentLeaf(segmentOrNode));\n\tassert(\n\t\tmaybeRoot?.mergeTree !== undefined,\n\t\t0x5c2 /* trackable is invalid as it is not in a rooted merge tree. */,\n\t);\n\tconst mergeTree: PickPartial<MergeTreeWithRevert, \"__mergeTreeRevertible\"> =\n\t\tmaybeRoot.mergeTree;\n\n\tif (mergeTree.__mergeTreeRevertible === undefined) {\n\t\tconst detachedReferences = new EndOfTreeSegment(maybeRoot.mergeTree);\n\t\tconst refCallbacks: MergeTreeWithRevert[\"__mergeTreeRevertible\"][\"refCallbacks\"] = {\n\t\t\tafterSlide: (r: LocalReferencePosition) => {\n\t\t\t\tif (mergeTree.referencePositionToLocalPosition(r) === DetachedReferencePosition) {\n\t\t\t\t\tconst refs = LocalReferenceCollection.setOrGet(detachedReferences);\n\t\t\t\t\trefs.addAfterTombstones([r]);\n\t\t\t\t}\n\t\t\t},\n\t\t};\n\t\tmergeTree.__mergeTreeRevertible = {\n\t\t\trefCallbacks,\n\t\t\tdetachedReferences,\n\t\t};\n\t}\n\treturn mergeTree as MergeTreeWithRevert;\n}\n\nfunction appendLocalInsertToRevertibles(\n\tdeltaArgs: IMergeTreeDeltaCallbackArgs,\n\trevertibles: MergeTreeDeltaRevertible[],\n): MergeTreeDeltaRevertible[] {\n\tif (revertibles[revertibles.length - 1]?.operation !== MergeTreeDeltaType.INSERT) {\n\t\trevertibles.push({\n\t\t\toperation: MergeTreeDeltaType.INSERT,\n\t\t\ttrackingGroup: new UnorderedTrackingGroup(),\n\t\t});\n\t}\n\tconst last = revertibles[revertibles.length - 1];\n\tfor (const t of deltaArgs.deltaSegments) last.trackingGroup.link(t.segment);\n\n\treturn revertibles;\n}\n\nfunction appendLocalRemoveToRevertibles(\n\tdeltaArgs: IMergeTreeDeltaCallbackArgs,\n\trevertibles: MergeTreeDeltaRevertible[],\n): MergeTreeDeltaRevertible[] {\n\tif (revertibles[revertibles.length - 1]?.operation !== MergeTreeDeltaType.REMOVE) {\n\t\trevertibles.push({\n\t\t\toperation: MergeTreeDeltaType.REMOVE,\n\t\t\ttrackingGroup: new UnorderedTrackingGroup(),\n\t\t});\n\t}\n\tconst last = revertibles[revertibles.length - 1];\n\n\tconst mergeTreeWithRevert = findMergeTreeWithRevert(deltaArgs.deltaSegments[0].segment);\n\n\tfor (const t of deltaArgs.deltaSegments) {\n\t\tconst props: RemoveSegmentRefProperties = {\n\t\t\tsegSpec: t.segment.toJSONObject() as IJSONSegment,\n\t\t\treferenceSpace: \"mergeTreeDeltaRevertible\",\n\t\t};\n\t\tconst ref = mergeTreeWithRevert.createLocalReferencePosition(\n\t\t\tt.segment,\n\t\t\t0,\n\t\t\tReferenceType.SlideOnRemove,\n\t\t\tprops,\n\t\t);\n\t\tref.callbacks = mergeTreeWithRevert.__mergeTreeRevertible.refCallbacks;\n\t\tfor (const tg of t.segment.trackingCollection.trackingGroups) {\n\t\t\ttg.link(ref);\n\t\t\ttg.unlink(t.segment);\n\t\t}\n\n\t\tlast.trackingGroup.link(ref);\n\t}\n\treturn revertibles;\n}\n\nfunction appendLocalAnnotateToRevertibles(\n\tdeltaArgs: IMergeTreeDeltaCallbackArgs,\n\trevertibles: MergeTreeDeltaRevertible[],\n): MergeTreeDeltaRevertible[] {\n\tlet last = revertibles[revertibles.length - 1];\n\tfor (const ds of deltaArgs.deltaSegments) {\n\t\tconst propertyDeltas = ds.propertyDeltas;\n\t\tif (propertyDeltas) {\n\t\t\tif (\n\t\t\t\tlast?.operation === MergeTreeDeltaType.ANNOTATE &&\n\t\t\t\tmatchProperties(last?.propertyDeltas, propertyDeltas)\n\t\t\t) {\n\t\t\t\tlast.trackingGroup.link(ds.segment);\n\t\t\t} else {\n\t\t\t\tlast = {\n\t\t\t\t\toperation: MergeTreeDeltaType.ANNOTATE,\n\t\t\t\t\tpropertyDeltas,\n\t\t\t\t\ttrackingGroup: new UnorderedTrackingGroup(),\n\t\t\t\t};\n\t\t\t\tlast.trackingGroup.link(ds.segment);\n\t\t\t\trevertibles.push(last);\n\t\t\t}\n\t\t}\n\t}\n\treturn revertibles;\n}\n\n/**\n * Appends a merge tree delta to the list of revertibles.\n *\n * @legacy @beta\n */\nexport function appendToMergeTreeDeltaRevertibles(\n\tdeltaArgs: IMergeTreeDeltaCallbackArgs,\n\trevertibles: MergeTreeDeltaRevertible[],\n): void {\n\tif (deltaArgs.deltaSegments.length === 0) {\n\t\treturn;\n\t}\n\tswitch (deltaArgs.operation) {\n\t\tcase MergeTreeDeltaType.INSERT: {\n\t\t\tappendLocalInsertToRevertibles(deltaArgs, revertibles);\n\t\t\tbreak;\n\t\t}\n\n\t\tcase MergeTreeDeltaType.REMOVE: {\n\t\t\tappendLocalRemoveToRevertibles(deltaArgs, revertibles);\n\t\t\tbreak;\n\t\t}\n\n\t\tcase MergeTreeDeltaType.ANNOTATE: {\n\t\t\tappendLocalAnnotateToRevertibles(deltaArgs, revertibles);\n\t\t\tbreak;\n\t\t}\n\n\t\tdefault: {\n\t\t\tthrow new UsageError(\"Unsupported event delta type\", {\n\t\t\t\toperation: deltaArgs.operation,\n\t\t\t});\n\t\t}\n\t}\n}\n\n/**\n * Removes all revertibles from the list of revertibles.\n *\n * @legacy @beta\n */\nexport function discardMergeTreeDeltaRevertible(\n\trevertibles: MergeTreeDeltaRevertible[],\n): void {\n\tfor (const r of revertibles) {\n\t\tfor (const t of r.trackingGroup.tracked) {\n\t\t\tt.trackingCollection.unlink(r.trackingGroup);\n\t\t\t// remove untracked local references\n\t\t\tif (t.trackingCollection.empty && !t.isLeaf()) {\n\t\t\t\tconst segment: ISegmentPrivate | undefined = t.getSegment();\n\t\t\t\tsegment?.localRefs?.removeLocalRef(t);\n\t\t\t}\n\t\t}\n\t}\n}\n\nfunction revertLocalInsert(\n\tdriver: MergeTreeRevertibleDriver,\n\tmergeTreeWithRevert: MergeTreeWithRevert,\n\trevertible: TypedRevertible<typeof MergeTreeDeltaType.INSERT>,\n): void {\n\twhile (revertible.trackingGroup.size > 0) {\n\t\tconst tracked = revertible.trackingGroup.tracked[0];\n\t\tassert(\n\t\t\ttracked.trackingCollection.unlink(revertible.trackingGroup),\n\t\t\t0x3f1 /* tracking group removed */,\n\t\t);\n\t\tassert(isSegmentLeaf(tracked), 0x3f2 /* inserts must track segments */);\n\t\tif (toRemovalInfo(tracked) === undefined) {\n\t\t\tconst start = getPosition(mergeTreeWithRevert, tracked);\n\t\t\tdriver.removeRange(start, start + tracked.cachedLength);\n\t\t}\n\t}\n}\n\nfunction revertLocalRemove(\n\tdriver: MergeTreeRevertibleDriver,\n\tmergeTreeWithRevert: MergeTreeWithRevert,\n\trevertible: TypedRevertible<typeof MergeTreeDeltaType.REMOVE>,\n): void {\n\twhile (revertible.trackingGroup.size > 0) {\n\t\tconst tracked = revertible.trackingGroup.tracked[0];\n\n\t\tassert(\n\t\t\ttracked.trackingCollection.unlink(revertible.trackingGroup),\n\t\t\t0x3f3 /* tracking group removed */,\n\t\t);\n\n\t\tassert(!tracked.isLeaf(), 0x3f4 /* removes must track local refs */);\n\n\t\tconst refSeg = tracked.getSegment();\n\t\tlet realPos = mergeTreeWithRevert.referencePositionToLocalPosition(tracked);\n\n\t\t// References which are on EndOfStringSegment don't return detached for pos,\n\t\t// they will return the length of the merge-tree. this case just catches\n\t\t// random references, likely not created in the revertible flow,\n\t\t// that are tying to be reverted for some reason.\n\t\tif (realPos === DetachedReferencePosition || !isSegmentLeaf(refSeg)) {\n\t\t\tthrow new UsageError(\"Cannot insert at detached references position\");\n\t\t}\n\n\t\tif (toRemovalInfo(refSeg) === undefined && refSeg.localRefs?.isAfterTombstone(tracked)) {\n\t\t\trealPos++;\n\t\t}\n\n\t\tconst props = tracked.properties as RemoveSegmentRefProperties;\n\t\tdriver.insertFromSpec(realPos, props.segSpec);\n\t\tconst insertSegment = mergeTreeWithRevert.getContainingSegment(\n\t\t\trealPos,\n\t\t\tmergeTreeWithRevert.localPerspective,\n\t\t)?.segment;\n\t\tassertSegmentLeaf(insertSegment);\n\n\t\tconst localSlideFilter = (lref: LocalReferencePosition): boolean =>\n\t\t\t(lref.properties as Partial<RemoveSegmentRefProperties>)?.referenceSpace ===\n\t\t\t\"mergeTreeDeltaRevertible\";\n\n\t\tconst insertRef: Partial<\n\t\t\tRecord<\"before\" | \"after\", DoublyLinkedList<LocalReferencePosition>>\n\t\t> = {};\n\t\tconst forward = insertSegment.ordinal < refSeg.ordinal;\n\t\tconst refHandler = (lref: LocalReferencePosition): false | undefined => {\n\t\t\t// once we reach it keep the original reference where it is\n\t\t\t// we'll move tracking groups, and remove it as a last step.\n\t\t\tif (tracked === lref) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tif (localSlideFilter(lref)) {\n\t\t\t\tif (forward) {\n\t\t\t\t\tconst before = (insertRef.before ??= new DoublyLinkedList());\n\t\t\t\t\tbefore.push(lref);\n\t\t\t\t} else {\n\t\t\t\t\tconst after = (insertRef.after ??= new DoublyLinkedList());\n\t\t\t\t\tafter.unshift(lref);\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\t\tdepthFirstNodeWalk(\n\t\t\tinsertSegment.parent,\n\t\t\tinsertSegment,\n\t\t\tundefined,\n\t\t\t(seg: ISegmentPrivate) => {\n\t\t\t\tif (seg.localRefs?.empty === false) {\n\t\t\t\t\treturn seg.localRefs.walkReferences(refHandler, undefined, forward);\n\t\t\t\t}\n\t\t\t\treturn true;\n\t\t\t},\n\t\t\tundefined,\n\t\t\tforward,\n\t\t);\n\t\tif (\n\t\t\tmergeTreeWithRevert?.__mergeTreeRevertible?.detachedReferences?.localRefs?.has(tracked)\n\t\t) {\n\t\t\tassert(forward, 0x3f6 /* forward should always be true when detached */);\n\t\t\tmergeTreeWithRevert?.__mergeTreeRevertible.detachedReferences.localRefs.walkReferences(\n\t\t\t\trefHandler,\n\t\t\t);\n\t\t}\n\n\t\tif (insertRef !== undefined) {\n\t\t\tconst localRefs = LocalReferenceCollection.setOrGet(insertSegment);\n\t\t\tif (insertRef.before?.empty === false) {\n\t\t\t\tlocalRefs.addBeforeTombstones(insertRef.before.map((n) => n.data));\n\t\t\t}\n\t\t\tif (insertRef.after?.empty === false) {\n\t\t\t\tlocalRefs.addAfterTombstones(insertRef.after.map((n) => n.data));\n\t\t\t}\n\t\t}\n\n\t\tfor (const tg of tracked.trackingCollection.trackingGroups) {\n\t\t\ttg.link(insertSegment);\n\t\t\ttg.unlink(tracked);\n\t\t}\n\t\tconst segment: ISegmentPrivate | undefined = tracked.getSegment();\n\t\tsegment?.localRefs?.removeLocalRef(tracked);\n\t}\n}\n\nfunction revertLocalAnnotate(\n\tdriver: MergeTreeRevertibleDriver,\n\tmergeTreeWithRevert: MergeTreeWithRevert,\n\trevertible: TypedRevertible<typeof MergeTreeDeltaType.ANNOTATE>,\n): void {\n\twhile (revertible.trackingGroup.size > 0) {\n\t\tconst tracked = revertible.trackingGroup.tracked[0];\n\t\tconst unlinked = tracked.trackingCollection.unlink(revertible.trackingGroup);\n\t\tassert(unlinked && isSegmentLeaf(tracked), 0x3f7 /* annotates must track segments */);\n\t\tif (toRemovalInfo(tracked) === undefined) {\n\t\t\tconst start = getPosition(mergeTreeWithRevert, tracked);\n\t\t\tdriver.annotateRange(start, start + tracked.cachedLength, revertible.propertyDeltas);\n\t\t}\n\t}\n}\n\nfunction getPosition(mergeTreeWithRevert: MergeTreeWithRevert, segment: ISegmentLeaf): number {\n\treturn mergeTreeWithRevert.getPosition(segment, mergeTreeWithRevert.localPerspective);\n}\n\n/**\n * Reverts all operations in the list of revertibles.\n *\n * @legacy @beta\n */\nexport function revertMergeTreeDeltaRevertibles(\n\tdriver: MergeTreeRevertibleDriver,\n\trevertibles: MergeTreeDeltaRevertible[],\n): void {\n\tlet mergeTreeWithRevert: MergeTreeWithRevert | undefined;\n\n\twhile (revertibles.length > 0) {\n\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\tconst r = revertibles.pop()!;\n\t\tconst operation = r.operation;\n\t\tif (r.trackingGroup.size > 0) {\n\t\t\tmergeTreeWithRevert ??= findMergeTreeWithRevert(r.trackingGroup.tracked[0]);\n\t\t\tswitch (operation) {\n\t\t\t\tcase MergeTreeDeltaType.INSERT: {\n\t\t\t\t\trevertLocalInsert(driver, mergeTreeWithRevert, r);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcase MergeTreeDeltaType.REMOVE: {\n\t\t\t\t\trevertLocalRemove(driver, mergeTreeWithRevert, r);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcase MergeTreeDeltaType.ANNOTATE: {\n\t\t\t\t\trevertLocalAnnotate(driver, mergeTreeWithRevert, r);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tdefault: {\n\t\t\t\t\tunreachableCase(operation);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n"]}
@@ -7,6 +7,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
7
7
  exports.SegmentGroupCollection = void 0;
8
8
  const internal_1 = require("@fluidframework/core-utils/internal");
9
9
  class SegmentGroupCollection {
10
+ segment;
11
+ segmentGroups;
10
12
  constructor(segment) {
11
13
  this.segment = segment;
12
14
  this.segmentGroups = new internal_1.DoublyLinkedList();
@@ -1 +1 @@
1
- {"version":3,"file":"segmentGroupCollection.js","sourceRoot":"","sources":["../src/segmentGroupCollection.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAAiF;AAIjF,MAAa,sBAAsB;IAGlC,YAA6B,OAAqB;QAArB,YAAO,GAAP,OAAO,CAAc;QACjD,IAAI,CAAC,aAAa,GAAG,IAAI,2BAAgB,EAAgB,CAAC;IAC3D,CAAC;IAED,IAAW,IAAI;QACd,OAAO,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC;IAClC,CAAC;IAED,IAAW,KAAK;QACf,OAAO,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC;IACjC,CAAC;IAEM,OAAO,CAAC,YAA0B;QACxC,IAAI,CAAC,aAAa,CA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C,aAAa,CAAC,KAAK,CAAC,CAAC,CAAC;YACpE,CAAC;QACF,CAAC;IACF,CAAC;CACD;AAnDD,wDAmDC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { DoublyLinkedList, walkList } from \"@fluidframework/core-utils/internal\";\n\nimport type { SegmentGroup, ISegmentLeaf } from \"./mergeTreeNodes.js\";\n\nexport class SegmentGroupCollection {\n\tprivate readonly segmentGroups: DoublyLinkedList<SegmentGroup>;\n\n\tconstructor(private readonly segment: ISegmentLeaf) {\n\t\tthis.segmentGroups = new DoublyLinkedList<SegmentGroup>();\n\t}\n\n\tpublic get size(): number {\n\t\treturn this.segmentGroups.length;\n\t}\n\n\tpublic get empty(): boolean {\n\t\treturn this.segmentGroups.empty;\n\t}\n\n\tpublic enqueue(segmentGroup: SegmentGroup): void {\n\t\tthis.segmentGroups.push(segmentGroup);\n\t\tsegmentGroup.segments.push(this.segment);\n\t}\n\n\tpublic dequeue(): SegmentGroup | undefined {\n\t\treturn this.segmentGroups.shift()?.data;\n\t}\n\n\tpublic remove(segmentGroup: SegmentGroup): boolean {\n\t\tconst found = this.segmentGroups.find((v) => v.data === segmentGroup);\n\t\tif (found === undefined) {\n\t\t\treturn false;\n\t\t}\n\t\tthis.segmentGroups.remove(found);\n\t\treturn true;\n\t}\n\n\tpublic pop(): SegmentGroup | undefined {\n\t\treturn this.segmentGroups.pop ? this.segmentGroups.pop()?.data : undefined;\n\t}\n\n\tpublic copyTo(segmentGroups: SegmentGroupCollection): void {\n\t\twalkList(this.segmentGroups, (sg) => segmentGroups.enqueueOnCopy(sg.data, this.segment));\n\t}\n\n\tprivate enqueueOnCopy(segmentGroup: SegmentGroup, sourceSegment: ISegmentLeaf): void {\n\t\tthis.enqueue(segmentGroup);\n\t\tif (segmentGroup.previousProps) {\n\t\t\t// duplicate the previousProps for this segment\n\t\t\tconst index = segmentGroup.segments.indexOf(sourceSegment);\n\t\t\tif (index !== -1) {\n\t\t\t\tsegmentGroup.previousProps.push(segmentGroup.previousProps[index]);\n\t\t\t}\n\t\t}\n\t}\n}\n"]}
1
+ {"version":3,"file":"segmentGroupCollection.js","sourceRoot":"","sources":["../src/segmentGroupCollection.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAAiF;AAIjF,MAAa,sBAAsB;IAGL;IAFZ,aAAa,CAAiC;IAE/D,YAA6B,OAAqB;QAArB,YAAO,GAAP,OAAO,CAAc;QACjD,IAAI,CAAC,aAAa,GAAG,IAAI,2BAAgB,EAAgB,CAAC;IAC3D,CAAC;IAED,IAAW,IAAI;QACd,OAAO,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC;IAClC,CAAC;IAED,IAAW,KAAK;QACf,OAAO,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC;IACjC,CAAC;IAEM,OAAO,CAAC,YAA0B;QACxC,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;QACtC,YAAY,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAC1C,CAAC;IAEM,OAAO;QACb,OAAO,IAAI,CAAC,aAAa,CAAC,KAAK,EAAE,EAAE,IAAI,CAAC;IACzC,CAAC;IAEM,MAAM,CAAC,YAA0B;QACvC,MAAM,KAAK,GAAG,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,YAAY,CAAC,CAAC;QACtE,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;YACzB,OAAO,KAAK,CAAC;QACd,CAAC;QACD,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QACjC,OAAO,IAAI,CAAC;IACb,CAAC;IAEM,GAAG;QACT,OAAO,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,GAAG,EAAE,EAAE,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC;IAC5E,CAAC;IAEM,MAAM,CAAC,aAAqC;QAClD,IAAA,mBAAQ,EAAC,IAAI,CAAC,aAAa,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,aAAa,CAAC,aAAa,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;IAC1F,CAAC;IAEO,aAAa,CAAC,YAA0B,EAAE,aAA2B;QAC5E,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;QAC3B,IAAI,YAAY,CAAC,aAAa,EAAE,CAAC;YAChC,+CAA+C;YAC/C,MAAM,KAAK,GAAG,YAAY,CAAC,QAAQ,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC;YAC3D,IAAI,KAAK,KAAK,CAAC,CAAC,EAAE,CAAC;gBAClB,YAAY,CAAC,aAAa,CAAC,IAAI,CAAC,YAAY,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC,CAAC;YACpE,CAAC;QACF,CAAC;IACF,CAAC;CACD;AAnDD,wDAmDC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { DoublyLinkedList, walkList } from \"@fluidframework/core-utils/internal\";\n\nimport type { SegmentGroup, ISegmentLeaf } from \"./mergeTreeNodes.js\";\n\nexport class SegmentGroupCollection {\n\tprivate readonly segmentGroups: DoublyLinkedList<SegmentGroup>;\n\n\tconstructor(private readonly segment: ISegmentLeaf) {\n\t\tthis.segmentGroups = new DoublyLinkedList<SegmentGroup>();\n\t}\n\n\tpublic get size(): number {\n\t\treturn this.segmentGroups.length;\n\t}\n\n\tpublic get empty(): boolean {\n\t\treturn this.segmentGroups.empty;\n\t}\n\n\tpublic enqueue(segmentGroup: SegmentGroup): void {\n\t\tthis.segmentGroups.push(segmentGroup);\n\t\tsegmentGroup.segments.push(this.segment);\n\t}\n\n\tpublic dequeue(): SegmentGroup | undefined {\n\t\treturn this.segmentGroups.shift()?.data;\n\t}\n\n\tpublic remove(segmentGroup: SegmentGroup): boolean {\n\t\tconst found = this.segmentGroups.find((v) => v.data === segmentGroup);\n\t\tif (found === undefined) {\n\t\t\treturn false;\n\t\t}\n\t\tthis.segmentGroups.remove(found);\n\t\treturn true;\n\t}\n\n\tpublic pop(): SegmentGroup | undefined {\n\t\treturn this.segmentGroups.pop ? this.segmentGroups.pop()?.data : undefined;\n\t}\n\n\tpublic copyTo(segmentGroups: SegmentGroupCollection): void {\n\t\twalkList(this.segmentGroups, (sg) => segmentGroups.enqueueOnCopy(sg.data, this.segment));\n\t}\n\n\tprivate enqueueOnCopy(segmentGroup: SegmentGroup, sourceSegment: ISegmentLeaf): void {\n\t\tthis.enqueue(segmentGroup);\n\t\tif (segmentGroup.previousProps) {\n\t\t\t// duplicate the previousProps for this segment\n\t\t\tconst index = segmentGroup.segments.indexOf(sourceSegment);\n\t\t\tif (index !== -1) {\n\t\t\t\tsegmentGroup.previousProps.push(segmentGroup.previousProps[index]);\n\t\t\t}\n\t\t}\n\t}\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"segmentInfos.d.ts","sourceRoot":"","sources":["../src/segmentInfos.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,EACN,KAAK,gBAAgB,EACrB,KAAK,eAAe,EACpB,UAAU,EACV,KAAK,cAAc,EACnB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EAAE,oBAAoB,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAE9F,MAAM,WAAW,YAAY;IAC5B,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,OAAO,EAAE,CAAC;IACnB,SAAS,EAAE,OAAO,CAAC;CACnB;AAED,wBAAgB,UAAU,CAAC,CAAC,SAAS,MAAM,EAC1C,KAAK,EAAE,OAAO,EACd,I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CAAC,KACxD,OAAO,CAAC,WAAW,IAAI,eAAe,GAAG,OAAO,CAAC,CAAC,EAAE,OAAO,CAAC,eAAe,CAAC,CAGY,CAAC;AAE9F;;;;;;GAMG;AACH,eAAO,MAAM,iBAAiB,EAAE,CAC/B,QAAQ,EAAE,eAAe,KACrB,OAAO,CAAC,QAAQ,IAAI,MAAM,CAAC,MAAM,eAAe,EAAE,KAAK,CAGzD,CAAC;AAEJ;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,iBAAiB,GAAG,eAAe,GAAG,OAAO,CASxF;AAED;;GAEG;AACH,MAAM,MAAM,WAAW,GACpB,cAAc,GACd,iBAAiB,GACjB,eAAe,GACf,4BAA4B,CAAC;AAEhC;;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,GACzB,CAAC,SAAS,WAAW,EACrB,CAAC,SAAS,eAAe,GAAG,eAAe,EAE3C,aAAa,CAAC,EACd,MAAM,CAAC,KACL,eAAe,CAAC,CAAC,EAAE,CAAC,CAAqC,CAAC"}
@@ -4,23 +4,24 @@
4
4
  * Licensed under the MIT License.
5
5
  */
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.overwriteInfo = exports.wasRemovedOnInsert = exports.removeRemovalInfo = exports.assertRemoved = exports.isRemoved = exports.toRemovalInfo = exports.removeMergeNodeInfo = exports.assertMergeNode = exports.isMergeNodeInfo = exports.toMergeNodeInfo = exports.assertInserted = exports.isInsideObliterate = exports.isInserted = exports.toInsertionInfo = exports.propInstanceOf = exports.hasProp = exports.propExists = void 0;
7
+ exports.overwriteInfo = exports.removeRemovalInfo = exports.assertRemoved = exports.isRemoved = exports.toRemovalInfo = exports.removeMergeNodeInfo = exports.assertMergeNode = exports.isMergeNodeInfo = exports.toMergeNodeInfo = exports.assertInserted = exports.isInsideObliterate = exports.isInserted = exports.toInsertionInfo = void 0;
8
+ exports.propExists = propExists;
9
+ exports.hasProp = hasProp;
10
+ exports.propInstanceOf = propInstanceOf;
11
+ exports.wasRemovedOnInsert = wasRemovedOnInsert;
8
12
  const internal_1 = require("@fluidframework/core-utils/internal");
9
13
  const constants_js_1 = require("./constants.js");
10
14
  const mergeTreeNodes_js_1 = require("./mergeTreeNodes.js");
11
15
  function propExists(thing, prop) {
12
16
  return (0, internal_1.isObject)(thing) && prop in thing;
13
17
  }
14
- exports.propExists = propExists;
15
18
  function hasProp(thing, prop, type) {
16
19
  return (propExists(thing, prop) &&
17
20
  (type === "array" ? Array.isArray(thing[prop]) : typeof thing[prop] === type));
18
21
  }
19
- exports.hasProp = hasProp;
20
22
  function propInstanceOf(thing, prop, type) {
21
23
  return propExists(thing, prop) && thing[prop] instanceof type;
22
24
  }
23
- exports.propInstanceOf = propInstanceOf;
24
25
  /**
25
26
  * Converts a segment-like object to an insertion info object if possible.
26
27
  *
@@ -160,7 +161,6 @@ function wasRemovedOnInsert(segment) {
160
161
  const insertSeq = segment.insert.seq;
161
162
  return insertSeq === constants_js_1.UnassignedSequenceNumber || insertSeq > removedSeq;
162
163
  }
163
- exports.wasRemovedOnInsert = wasRemovedOnInsert;
164
164
  /**
165
165
  * Overwrites the segment info on a segment-like object.
166
166
  *
@@ -1 +1 @@
1
- {"version":3,"file":"segmentInfos.js","sourceRoot":"","sources":["../src/segmentInfos.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAAuE;AAEvE,iDAA0D;AAC1D,2DAK6B;AAW7B,SAAgB,UAAU,CACzB,KAAc,EACd,IAAO;IAEP,OAAO,IAAA,mBAAQ,EAAC,KAAK,CAAC,IAAI,IAAI,IAAI,KAAK,CAAC;AACzC,CAAC;AALD,gCAKC;AAED,SAAgB,OAAO,CACtB,KAAc,EACd,IAAO,EACP,IAAO;IAEP,OAAO,CACN,UAAU,CAAC,KAAK,EAA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;;GAMG;AACI,MAAM,aAAa,GAAG,CAI5B,WAAc,EACd,IAAO,EACiB,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,WAAW,EAAE,IAAI,CAAC,CAAC;AANhD,QAAA,aAAa,iBAMmC","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 {\n\ttype ISegmentInternal,\n\ttype ISegmentPrivate,\n\tMergeBlock,\n\ttype ObliterateInfo,\n} from \"./mergeTreeNodes.js\";\nimport type { InsertOperationStamp, OperationStamp, 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\nexport interface ISegmentInsideObliterateInfo {\n\t/**\n\t * Populated iff this segment was inserted into a range affected by concurrent obliterates at the time of its insertion.\n\t * Contains information about the 'most recent' (i.e. 'winning' in the sense below) obliterate.\n\t *\n\t * BEWARE: We have opted for a certain form of last-write wins (LWW) semantics for obliterates:\n\t * the client which last obliterated a range is considered to have \"won ownership\" of that range and may insert into it\n\t * without that insertion being obliterated by other clients' concurrent obliterates.\n\t *\n\t * Therefore, this field can be populated even if the segment has not been obliterated (i.e. is still visible).\n\t * This happens precisely when the segment was inserted by the same client that 'won' the obliterate (in a scenario where\n\t * a client first issues a sided obliterate impacting a range, then inserts into that range before the server has acked the obliterate).\n\t *\n\t * See the test case \"obliterate with mismatched final states\" for an example of such a scenario.\n\t *\n\t * TODO:AB#29553: This property is not persisted in the V1 summary, but it should be.\n\t */\n\tobliteratePrecedingInsertion?: ObliterateInfo;\n\t/**\n\t * Populated iff this segment was inserted into a range concurrently removed by a local obliterate operation.\n\t * This field is unset once the newest such overlapping obliterate is acked, and allows recomputing {@link obliteratePrecedingInsertion}\n\t * if that local obliterate is resubmitted.\n\t *\n\t * TODO:AB#29553: This property is not persisted in the V1 summary, but it should be.\n\t */\n\tinsertionRefSeqStamp?: OperationStamp;\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\nexport const isInsideObliterate = (\n\tsegmentLike: unknown,\n): segmentLike is ISegmentInsideObliterateInfo =>\n\tsegmentLike !== undefined && hasProp(segmentLike, \"obliteratePrecedingInsertion\", \"object\");\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: (\n\tnodeLike: IHasRemovalInfo,\n) => asserts nodeLike is Record<keyof IHasRemovalInfo, never> = (nodeLike) =>\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 =\n\t| IMergeNodeInfo\n\t| IHasInsertionInfo\n\t| IHasRemovalInfo\n\t| ISegmentInsideObliterateInfo;\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;;;AAqBH,gCAKC;AAED,0BASC;AAED,wCAMC;AA2OD,gDASC;AA/RD,kEAAuE;AAEvE,iDAA0D;AAC1D,2DAK6B;AAW7B,SAAgB,UAAU,CACzB,KAAc,EACd,IAAO;IAEP,OAAO,IAAA,mBAAQ,EAAC,KAAK,CAAC,IAAI,IAAI,IAAI,KAAK,CAAC;AACzC,CAAC;AAED,SAAgB,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,IAAI,CAAC,KAAK,IAAI,CAAC,CAC7E,CAAC;AACH,CAAC;AAED,SAAgB,cAAc,CAC7B,KAAc,EACd,IAAO,EACP,IAA+B;IAE/B,OAAO,UAAU,CAAC,KAA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AAa,EAAC,WAAW,CAAC,KAAK,SAAS,CAAC;AAD7B,QAAA,SAAS,aACoB;AAE1C;;;;;GAKG;AACI,MAAM,aAAa,GAE2D,CACpF,WAAW,EACV,EAAE,CACH,IAAA,iBAAM,EAAC,WAAW,KAAK,SAAS,IAAI,IAAA,iBAAS,EAAC,WAAW,CAAC,EAAE,KAAK,CAAC,yBAAyB,CAAC,CAAC;AALjF,QAAA,aAAa,iBAKoE;AAE9F;;;;;;GAMG;AACI,MAAM,iBAAiB,GAEkC,CAAC,QAAQ,EAAE,EAAE,CAC5E,MAAM,CAAC,MAAM,CAA4D,QAAQ,EAAE;IAClF,OAAO,EAAE,SAAS;CAClB,CAAC,CAAC;AALS,QAAA,iBAAiB,qBAK1B;AAEJ;;;;;;;;GAQG;AACH,SAAgB,kBAAkB,CAAC,OAA4C;IAC9E,MAAM,UAAU,GAAG,IAAA,qBAAa,EAAC,OAAO,CAAC,CAAC;IAC1C,MAAM,UAAU,GAAG,UAAU,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC;IAC9C,IAAI,UAAU,KAAK,SAAS,IAAI,UAAU,KAAK,uCAAwB,EAAE,CAAC;QACzE,OAAO,KAAK,CAAC;IACd,CAAC;IAED,MAAM,SAAS,GAAG,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC;IACrC,OAAO,SAAS,KAAK,uCAAwB,IAAI,SAAS,GAAG,UAAU,CAAC;AACzE,CAAC;AAmBD;;;;;;GAMG;AACI,MAAM,aAAa,GAAG,CAI5B,WAAc,EACd,IAAO,EACiB,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,WAAW,EAAE,IAAI,CAAC,CAAC;AANhD,QAAA,aAAa,iBAMmC","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 {\n\ttype ISegmentInternal,\n\ttype ISegmentPrivate,\n\tMergeBlock,\n\ttype ObliterateInfo,\n} from \"./mergeTreeNodes.js\";\nimport type { InsertOperationStamp, OperationStamp, 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\nexport interface ISegmentInsideObliterateInfo {\n\t/**\n\t * Populated iff this segment was inserted into a range affected by concurrent obliterates at the time of its insertion.\n\t * Contains information about the 'most recent' (i.e. 'winning' in the sense below) obliterate.\n\t *\n\t * BEWARE: We have opted for a certain form of last-write wins (LWW) semantics for obliterates:\n\t * the client which last obliterated a range is considered to have \"won ownership\" of that range and may insert into it\n\t * without that insertion being obliterated by other clients' concurrent obliterates.\n\t *\n\t * Therefore, this field can be populated even if the segment has not been obliterated (i.e. is still visible).\n\t * This happens precisely when the segment was inserted by the same client that 'won' the obliterate (in a scenario where\n\t * a client first issues a sided obliterate impacting a range, then inserts into that range before the server has acked the obliterate).\n\t *\n\t * See the test case \"obliterate with mismatched final states\" for an example of such a scenario.\n\t *\n\t * TODO:AB#29553: This property is not persisted in the V1 summary, but it should be.\n\t */\n\tobliteratePrecedingInsertion?: ObliterateInfo;\n\t/**\n\t * Populated iff this segment was inserted into a range concurrently removed by a local obliterate operation.\n\t * This field is unset once the newest such overlapping obliterate is acked, and allows recomputing {@link obliteratePrecedingInsertion}\n\t * if that local obliterate is resubmitted.\n\t *\n\t * TODO:AB#29553: This property is not persisted in the V1 summary, but it should be.\n\t */\n\tinsertionRefSeqStamp?: OperationStamp;\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\nexport const isInsideObliterate = (\n\tsegmentLike: unknown,\n): segmentLike is ISegmentInsideObliterateInfo =>\n\tsegmentLike !== undefined && hasProp(segmentLike, \"obliteratePrecedingInsertion\", \"object\");\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: (\n\tnodeLike: IHasRemovalInfo,\n) => asserts nodeLike is Record<keyof IHasRemovalInfo, never> = (nodeLike) =>\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 =\n\t| IMergeNodeInfo\n\t| IHasInsertionInfo\n\t| IHasRemovalInfo\n\t| ISegmentInsideObliterateInfo;\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,7 +4,8 @@
4
4
  * Licensed under the MIT License.
5
5
  */
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.PropertiesManager = exports.copyPropertiesAndManager = void 0;
7
+ exports.PropertiesManager = void 0;
8
+ exports.copyPropertiesAndManager = copyPropertiesAndManager;
8
9
  const internal_1 = require("@fluidframework/core-utils/internal");
9
10
  const constants_js_1 = require("./constants.js");
10
11
  const properties_js_1 = require("./properties.js");
@@ -23,7 +24,6 @@ function copyPropertiesAndManager(source, destination) {
23
24
  }
24
25
  }
25
26
  }
26
- exports.copyPropertiesAndManager = copyPropertiesAndManager;
27
27
  function computePropertyValue(consensus, ...changes) {
28
28
  let computedValue = consensus;
29
29
  for (const change of changes) {
@@ -77,9 +77,7 @@ function applyChanges(op, seg, seq, run) {
77
77
  * @internal
78
78
  */
79
79
  class PropertiesManager {
80
- constructor() {
81
- this.changes = new Map();
82
- }
80
+ changes = new Map();
83
81
  /**
84
82
  * Rolls back local property changes.
85
83
  * This method reverts property changes based on the provided operation and segment.
@@ -1 +1 @@
1
- {"version":3,"file":"segmentPropertiesManager.js","sourceRoot":"","sources":["../src/segmentPropertiesManager.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAI6C;AAE7C,iDAAmF;AAMnF,mDAAmF;AAEnF;;;GAGG;AACH,SAAgB,wBAAwB,CACvC,MAGC,EACD,WAGC;IAED,IAAI,MAAM,CAAC,UAAU,EAAE,CAAC;QACvB,IAAI,MAAM,CAAC,eAAe,KAAK,SAAS,EAAE,CAAC;YAC1C,WAAW,CAAC,UAAU,GAAG,IAAA,qBAAK,EAAC,MAAM,CAAC,UAAU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C;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;AAzOD,8CAyOC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\tassert,\n\tDoublyLinkedList,\n\titerateListValuesWhile,\n} from \"@fluidframework/core-utils/internal\";\n\nimport { UnassignedSequenceNumber, UniversalSequenceNumber } from \"./constants.js\";\nimport type {\n\tAdjustParams,\n\tIMergeTreeAnnotateAdjustMsg,\n\tIMergeTreeAnnotateMsg,\n} from \"./ops.js\";\nimport { type MapLike, type 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.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
+ {"version":3,"file":"segmentPropertiesManager.js","sourceRoot":"","sources":["../src/segmentPropertiesManager.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAoBH,4DAkBC;AApCD,kEAI6C;AAE7C,iDAAmF;AAMnF,mDAAmF;AAEnF;;;GAGG;AACH,SAAgB,wBAAwB,CACvC,MAGC,EACD,WAGC;IAED,IAAI,MAAM,CAAC,UAAU,EAAE,CAAC;QACvB,IAAI,MAAM,CAAC,eAAe,KAAK,SAAS,EAAE,CAAC;YAC1C,WAAW,CAAC,UAAU,GAAG,IAAA,qBAAK,EAAC,MAAM,CAAC,UAAU,CAAC,CAAC;QACn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AK,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;AAzOD,8CAyOC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\tassert,\n\tDoublyLinkedList,\n\titerateListValuesWhile,\n} from \"@fluidframework/core-utils/internal\";\n\nimport { UnassignedSequenceNumber, UniversalSequenceNumber } from \"./constants.js\";\nimport type {\n\tAdjustParams,\n\tIMergeTreeAnnotateAdjustMsg,\n\tIMergeTreeAnnotateMsg,\n} from \"./ops.js\";\nimport { type MapLike, type 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.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"]}