@fluidframework/tree 2.74.0 → 2.81.0-374083

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 (1318) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/api-report/tree.alpha.api.md +63 -9
  3. package/dist/alpha.d.ts +9 -0
  4. package/dist/codec/codec.d.ts +31 -3
  5. package/dist/codec/codec.d.ts.map +1 -1
  6. package/dist/codec/codec.js +10 -0
  7. package/dist/codec/codec.js.map +1 -1
  8. package/dist/codec/index.d.ts +2 -2
  9. package/dist/codec/index.d.ts.map +1 -1
  10. package/dist/codec/index.js +2 -2
  11. package/dist/codec/index.js.map +1 -1
  12. package/dist/codec/versioned/codec.d.ts +80 -22
  13. package/dist/codec/versioned/codec.d.ts.map +1 -1
  14. package/dist/codec/versioned/codec.js +137 -15
  15. package/dist/codec/versioned/codec.js.map +1 -1
  16. package/dist/codec/versioned/index.d.ts +1 -1
  17. package/dist/codec/versioned/index.d.ts.map +1 -1
  18. package/dist/codec/versioned/index.js +2 -2
  19. package/dist/codec/versioned/index.js.map +1 -1
  20. package/dist/core/change-family/changeFamily.d.ts +4 -1
  21. package/dist/core/change-family/changeFamily.d.ts.map +1 -1
  22. package/dist/core/change-family/changeFamily.js.map +1 -1
  23. package/dist/core/change-family/index.d.ts +1 -1
  24. package/dist/core/change-family/index.d.ts.map +1 -1
  25. package/dist/core/change-family/index.js.map +1 -1
  26. package/dist/core/index.d.ts +3 -3
  27. package/dist/core/index.d.ts.map +1 -1
  28. package/dist/core/index.js +7 -6
  29. package/dist/core/index.js.map +1 -1
  30. package/dist/core/rebase/changeRebaser.d.ts +42 -3
  31. package/dist/core/rebase/changeRebaser.d.ts.map +1 -1
  32. package/dist/core/rebase/changeRebaser.js.map +1 -1
  33. package/dist/core/rebase/index.d.ts +2 -2
  34. package/dist/core/rebase/index.d.ts.map +1 -1
  35. package/dist/core/rebase/index.js +2 -2
  36. package/dist/core/rebase/index.js.map +1 -1
  37. package/dist/core/rebase/types.d.ts +52 -10
  38. package/dist/core/rebase/types.d.ts.map +1 -1
  39. package/dist/core/rebase/types.js +5 -12
  40. package/dist/core/rebase/types.js.map +1 -1
  41. package/dist/core/rebase/utils.d.ts.map +1 -1
  42. package/dist/core/rebase/utils.js +33 -11
  43. package/dist/core/rebase/utils.js.map +1 -1
  44. package/dist/core/schema-stored/schema.js +3 -3
  45. package/dist/core/schema-stored/schema.js.map +1 -1
  46. package/dist/core/tree/anchorSet.d.ts.map +1 -1
  47. package/dist/core/tree/anchorSet.js +4 -4
  48. package/dist/core/tree/anchorSet.js.map +1 -1
  49. package/dist/core/tree/detachedFieldIndex.d.ts +7 -2
  50. package/dist/core/tree/detachedFieldIndex.d.ts.map +1 -1
  51. package/dist/core/tree/detachedFieldIndex.js +21 -56
  52. package/dist/core/tree/detachedFieldIndex.js.map +1 -1
  53. package/dist/core/tree/detachedFieldIndexCodecCommon.d.ts +18 -10
  54. package/dist/core/tree/detachedFieldIndexCodecCommon.d.ts.map +1 -1
  55. package/dist/core/tree/detachedFieldIndexCodecCommon.js +6 -6
  56. package/dist/core/tree/detachedFieldIndexCodecCommon.js.map +1 -1
  57. package/dist/core/tree/detachedFieldIndexCodecV1.d.ts +2 -3
  58. package/dist/core/tree/detachedFieldIndexCodecV1.d.ts.map +1 -1
  59. package/dist/core/tree/detachedFieldIndexCodecV1.js +4 -5
  60. package/dist/core/tree/detachedFieldIndexCodecV1.js.map +1 -1
  61. package/dist/core/tree/detachedFieldIndexCodecV2.d.ts +2 -3
  62. package/dist/core/tree/detachedFieldIndexCodecV2.d.ts.map +1 -1
  63. package/dist/core/tree/detachedFieldIndexCodecV2.js +4 -6
  64. package/dist/core/tree/detachedFieldIndexCodecV2.js.map +1 -1
  65. package/dist/core/tree/detachedFieldIndexCodecs.d.ts +5 -6
  66. package/dist/core/tree/detachedFieldIndexCodecs.d.ts.map +1 -1
  67. package/dist/core/tree/detachedFieldIndexCodecs.js +11 -41
  68. package/dist/core/tree/detachedFieldIndexCodecs.js.map +1 -1
  69. package/dist/core/tree/index.d.ts +2 -2
  70. package/dist/core/tree/index.d.ts.map +1 -1
  71. package/dist/core/tree/index.js +5 -4
  72. package/dist/core/tree/index.js.map +1 -1
  73. package/dist/core/tree/mapTree.js +1 -1
  74. package/dist/core/tree/mapTree.js.map +1 -1
  75. package/dist/core/tree/pathTree.d.ts +11 -3
  76. package/dist/core/tree/pathTree.d.ts.map +1 -1
  77. package/dist/core/tree/pathTree.js +14 -2
  78. package/dist/core/tree/pathTree.js.map +1 -1
  79. package/dist/core/tree/sparseTree.d.ts.map +1 -1
  80. package/dist/core/tree/sparseTree.js +1 -0
  81. package/dist/core/tree/sparseTree.js.map +1 -1
  82. package/dist/core/tree/treeTextFormat.d.ts.map +1 -1
  83. package/dist/core/tree/treeTextFormat.js +5 -9
  84. package/dist/core/tree/treeTextFormat.js.map +1 -1
  85. package/dist/core/tree/visitDelta.d.ts.map +1 -1
  86. package/dist/core/tree/visitDelta.js +3 -2
  87. package/dist/core/tree/visitDelta.js.map +1 -1
  88. package/dist/core/tree/visitorUtils.d.ts.map +1 -1
  89. package/dist/core/tree/visitorUtils.js +58 -18
  90. package/dist/core/tree/visitorUtils.js.map +1 -1
  91. package/dist/feature-libraries/changeAtomIdBTree.d.ts +16 -0
  92. package/dist/feature-libraries/changeAtomIdBTree.d.ts.map +1 -0
  93. package/dist/feature-libraries/changeAtomIdBTree.js +30 -0
  94. package/dist/feature-libraries/changeAtomIdBTree.js.map +1 -0
  95. package/dist/feature-libraries/chunked-forest/basicChunk.d.ts.map +1 -1
  96. package/dist/feature-libraries/chunked-forest/basicChunk.js +8 -1
  97. package/dist/feature-libraries/chunked-forest/basicChunk.js.map +1 -1
  98. package/dist/feature-libraries/chunked-forest/chunkTree.d.ts.map +1 -1
  99. package/dist/feature-libraries/chunked-forest/chunkTree.js +4 -1
  100. package/dist/feature-libraries/chunked-forest/chunkTree.js.map +1 -1
  101. package/dist/feature-libraries/chunked-forest/chunkedForest.d.ts.map +1 -1
  102. package/dist/feature-libraries/chunked-forest/chunkedForest.js +9 -7
  103. package/dist/feature-libraries/chunked-forest/chunkedForest.js.map +1 -1
  104. package/dist/feature-libraries/chunked-forest/codec/chunkDecoding.d.ts.map +1 -1
  105. package/dist/feature-libraries/chunked-forest/codec/chunkDecoding.js +7 -4
  106. package/dist/feature-libraries/chunked-forest/codec/chunkDecoding.js.map +1 -1
  107. package/dist/feature-libraries/chunked-forest/codec/codecs.d.ts.map +1 -1
  108. package/dist/feature-libraries/chunked-forest/codec/codecs.js +19 -11
  109. package/dist/feature-libraries/chunked-forest/codec/codecs.js.map +1 -1
  110. package/dist/feature-libraries/chunked-forest/codec/compressedEncode.js +4 -3
  111. package/dist/feature-libraries/chunked-forest/codec/compressedEncode.js.map +1 -1
  112. package/dist/feature-libraries/chunked-forest/codec/schemaBasedEncode.js +9 -5
  113. package/dist/feature-libraries/chunked-forest/codec/schemaBasedEncode.js.map +1 -1
  114. package/dist/feature-libraries/chunked-forest/uniformChunk.js +1 -1
  115. package/dist/feature-libraries/chunked-forest/uniformChunk.js.map +1 -1
  116. package/dist/feature-libraries/default-schema/defaultEditBuilder.d.ts +103 -44
  117. package/dist/feature-libraries/default-schema/defaultEditBuilder.d.ts.map +1 -1
  118. package/dist/feature-libraries/default-schema/defaultEditBuilder.js +251 -77
  119. package/dist/feature-libraries/default-schema/defaultEditBuilder.js.map +1 -1
  120. package/dist/feature-libraries/default-schema/defaultFieldKinds.d.ts +1 -1
  121. package/dist/feature-libraries/default-schema/defaultFieldKinds.d.ts.map +1 -1
  122. package/dist/feature-libraries/default-schema/defaultFieldKinds.js +22 -3
  123. package/dist/feature-libraries/default-schema/defaultFieldKinds.js.map +1 -1
  124. package/dist/feature-libraries/default-schema/index.d.ts +2 -1
  125. package/dist/feature-libraries/default-schema/index.d.ts.map +1 -1
  126. package/dist/feature-libraries/default-schema/index.js +5 -2
  127. package/dist/feature-libraries/default-schema/index.js.map +1 -1
  128. package/dist/feature-libraries/default-schema/locationBasedEditBuilder.d.ts +38 -0
  129. package/dist/feature-libraries/default-schema/locationBasedEditBuilder.d.ts.map +1 -0
  130. package/dist/feature-libraries/default-schema/locationBasedEditBuilder.js +132 -0
  131. package/dist/feature-libraries/default-schema/locationBasedEditBuilder.js.map +1 -0
  132. package/dist/feature-libraries/default-schema/mappedEditBuilder.d.ts +9 -6
  133. package/dist/feature-libraries/default-schema/mappedEditBuilder.d.ts.map +1 -1
  134. package/dist/feature-libraries/default-schema/mappedEditBuilder.js +21 -0
  135. package/dist/feature-libraries/default-schema/mappedEditBuilder.js.map +1 -1
  136. package/dist/feature-libraries/deltaUtils.d.ts +1 -0
  137. package/dist/feature-libraries/deltaUtils.d.ts.map +1 -1
  138. package/dist/feature-libraries/deltaUtils.js +6 -1
  139. package/dist/feature-libraries/deltaUtils.js.map +1 -1
  140. package/dist/feature-libraries/flex-tree/context.d.ts +9 -0
  141. package/dist/feature-libraries/flex-tree/context.d.ts.map +1 -1
  142. package/dist/feature-libraries/flex-tree/context.js +6 -0
  143. package/dist/feature-libraries/flex-tree/context.js.map +1 -1
  144. package/dist/feature-libraries/flex-tree/flexTreeTypes.d.ts +6 -6
  145. package/dist/feature-libraries/flex-tree/flexTreeTypes.d.ts.map +1 -1
  146. package/dist/feature-libraries/flex-tree/flexTreeTypes.js.map +1 -1
  147. package/dist/feature-libraries/flex-tree/lazyField.d.ts +8 -7
  148. package/dist/feature-libraries/flex-tree/lazyField.d.ts.map +1 -1
  149. package/dist/feature-libraries/flex-tree/lazyField.js +44 -15
  150. package/dist/feature-libraries/flex-tree/lazyField.js.map +1 -1
  151. package/dist/feature-libraries/forest-summary/forestSummarizer.d.ts.map +1 -1
  152. package/dist/feature-libraries/forest-summary/forestSummarizer.js +3 -1
  153. package/dist/feature-libraries/forest-summary/forestSummarizer.js.map +1 -1
  154. package/dist/feature-libraries/index.d.ts +5 -4
  155. package/dist/feature-libraries/index.d.ts.map +1 -1
  156. package/dist/feature-libraries/index.js +15 -8
  157. package/dist/feature-libraries/index.js.map +1 -1
  158. package/dist/feature-libraries/indexing/anchorTreeIndex.js +6 -6
  159. package/dist/feature-libraries/indexing/anchorTreeIndex.js.map +1 -1
  160. package/dist/feature-libraries/mapTreeCursor.d.ts.map +1 -1
  161. package/dist/feature-libraries/mapTreeCursor.js +1 -0
  162. package/dist/feature-libraries/mapTreeCursor.js.map +1 -1
  163. package/dist/feature-libraries/mitigatedChangeFamily.d.ts.map +1 -1
  164. package/dist/feature-libraries/mitigatedChangeFamily.js +12 -3
  165. package/dist/feature-libraries/mitigatedChangeFamily.js.map +1 -1
  166. package/dist/feature-libraries/modular-schema/comparison.d.ts.map +1 -1
  167. package/dist/feature-libraries/modular-schema/comparison.js +12 -9
  168. package/dist/feature-libraries/modular-schema/comparison.js.map +1 -1
  169. package/dist/feature-libraries/modular-schema/crossFieldQueries.d.ts +97 -21
  170. package/dist/feature-libraries/modular-schema/crossFieldQueries.d.ts.map +1 -1
  171. package/dist/feature-libraries/modular-schema/crossFieldQueries.js +4 -7
  172. package/dist/feature-libraries/modular-schema/crossFieldQueries.js.map +1 -1
  173. package/dist/feature-libraries/modular-schema/defaultRevisionReplacer.d.ts +25 -0
  174. package/dist/feature-libraries/modular-schema/defaultRevisionReplacer.d.ts.map +1 -0
  175. package/dist/feature-libraries/modular-schema/defaultRevisionReplacer.js +59 -0
  176. package/dist/feature-libraries/modular-schema/defaultRevisionReplacer.js.map +1 -0
  177. package/dist/feature-libraries/modular-schema/fieldChangeHandler.d.ts +22 -53
  178. package/dist/feature-libraries/modular-schema/fieldChangeHandler.d.ts.map +1 -1
  179. package/dist/feature-libraries/modular-schema/fieldChangeHandler.js.map +1 -1
  180. package/dist/feature-libraries/modular-schema/genericFieldKind.d.ts.map +1 -1
  181. package/dist/feature-libraries/modular-schema/genericFieldKind.js +7 -13
  182. package/dist/feature-libraries/modular-schema/genericFieldKind.js.map +1 -1
  183. package/dist/feature-libraries/modular-schema/genericFieldKindCodecs.js +2 -2
  184. package/dist/feature-libraries/modular-schema/genericFieldKindCodecs.js.map +1 -1
  185. package/dist/feature-libraries/modular-schema/index.d.ts +7 -5
  186. package/dist/feature-libraries/modular-schema/index.d.ts.map +1 -1
  187. package/dist/feature-libraries/modular-schema/index.js +12 -8
  188. package/dist/feature-libraries/modular-schema/index.js.map +1 -1
  189. package/dist/feature-libraries/modular-schema/modularChangeCodecV1.d.ts +32 -0
  190. package/dist/feature-libraries/modular-schema/modularChangeCodecV1.d.ts.map +1 -0
  191. package/dist/feature-libraries/modular-schema/modularChangeCodecV1.js +409 -0
  192. package/dist/feature-libraries/modular-schema/modularChangeCodecV1.js.map +1 -0
  193. package/dist/feature-libraries/modular-schema/modularChangeCodecV2.d.ts +15 -0
  194. package/dist/feature-libraries/modular-schema/modularChangeCodecV2.d.ts.map +1 -0
  195. package/dist/feature-libraries/modular-schema/modularChangeCodecV2.js +31 -0
  196. package/dist/feature-libraries/modular-schema/modularChangeCodecV2.js.map +1 -0
  197. package/dist/feature-libraries/modular-schema/modularChangeCodecV3.d.ts +15 -0
  198. package/dist/feature-libraries/modular-schema/modularChangeCodecV3.d.ts.map +1 -0
  199. package/dist/feature-libraries/modular-schema/modularChangeCodecV3.js +393 -0
  200. package/dist/feature-libraries/modular-schema/modularChangeCodecV3.js.map +1 -0
  201. package/dist/feature-libraries/modular-schema/modularChangeCodecs.d.ts +2 -2
  202. package/dist/feature-libraries/modular-schema/modularChangeCodecs.d.ts.map +1 -1
  203. package/dist/feature-libraries/modular-schema/modularChangeCodecs.js +32 -288
  204. package/dist/feature-libraries/modular-schema/modularChangeCodecs.js.map +1 -1
  205. package/dist/feature-libraries/modular-schema/modularChangeFamily.d.ts +60 -26
  206. package/dist/feature-libraries/modular-schema/modularChangeFamily.d.ts.map +1 -1
  207. package/dist/feature-libraries/modular-schema/modularChangeFamily.js +1519 -615
  208. package/dist/feature-libraries/modular-schema/modularChangeFamily.js.map +1 -1
  209. package/{lib/feature-libraries/modular-schema/modularChangeFormat.d.ts → dist/feature-libraries/modular-schema/modularChangeFormatV1.d.ts} +5 -6
  210. package/dist/feature-libraries/modular-schema/modularChangeFormatV1.d.ts.map +1 -0
  211. package/dist/feature-libraries/modular-schema/{modularChangeFormat.js → modularChangeFormatV1.js} +7 -7
  212. package/dist/feature-libraries/modular-schema/modularChangeFormatV1.js.map +1 -0
  213. package/dist/feature-libraries/modular-schema/modularChangeFormatV2.d.ts +112 -0
  214. package/dist/feature-libraries/modular-schema/modularChangeFormatV2.d.ts.map +1 -0
  215. package/dist/feature-libraries/modular-schema/modularChangeFormatV2.js +21 -0
  216. package/dist/feature-libraries/modular-schema/modularChangeFormatV2.js.map +1 -0
  217. package/dist/feature-libraries/modular-schema/modularChangeFormatV3.d.ts +146 -0
  218. package/dist/feature-libraries/modular-schema/modularChangeFormatV3.d.ts.map +1 -0
  219. package/dist/feature-libraries/modular-schema/modularChangeFormatV3.js +32 -0
  220. package/dist/feature-libraries/modular-schema/modularChangeFormatV3.js.map +1 -0
  221. package/dist/feature-libraries/modular-schema/modularChangeTypes.d.ts +59 -13
  222. package/dist/feature-libraries/modular-schema/modularChangeTypes.d.ts.map +1 -1
  223. package/dist/feature-libraries/modular-schema/modularChangeTypes.js +3 -3
  224. package/dist/feature-libraries/modular-schema/modularChangeTypes.js.map +1 -1
  225. package/dist/feature-libraries/node-identifier/mockNodeIdentifierManager.js +1 -1
  226. package/dist/feature-libraries/node-identifier/mockNodeIdentifierManager.js.map +1 -1
  227. package/dist/feature-libraries/object-forest/objectForest.d.ts.map +1 -1
  228. package/dist/feature-libraries/object-forest/objectForest.js +7 -5
  229. package/dist/feature-libraries/object-forest/objectForest.js.map +1 -1
  230. package/dist/feature-libraries/optional-field/index.d.ts +2 -2
  231. package/dist/feature-libraries/optional-field/index.d.ts.map +1 -1
  232. package/dist/feature-libraries/optional-field/index.js +1 -2
  233. package/dist/feature-libraries/optional-field/index.js.map +1 -1
  234. package/dist/feature-libraries/optional-field/optionalField.d.ts +5 -26
  235. package/dist/feature-libraries/optional-field/optionalField.d.ts.map +1 -1
  236. package/dist/feature-libraries/optional-field/optionalField.js +223 -450
  237. package/dist/feature-libraries/optional-field/optionalField.js.map +1 -1
  238. package/dist/feature-libraries/optional-field/optionalFieldChangeFormatV3.d.ts +23 -0
  239. package/dist/feature-libraries/optional-field/optionalFieldChangeFormatV3.d.ts.map +1 -0
  240. package/dist/feature-libraries/optional-field/optionalFieldChangeFormatV3.js +31 -0
  241. package/dist/feature-libraries/optional-field/optionalFieldChangeFormatV3.js.map +1 -0
  242. package/dist/feature-libraries/optional-field/optionalFieldChangeTypes.d.ts +24 -33
  243. package/dist/feature-libraries/optional-field/optionalFieldChangeTypes.d.ts.map +1 -1
  244. package/dist/feature-libraries/optional-field/optionalFieldChangeTypes.js.map +1 -1
  245. package/dist/feature-libraries/optional-field/optionalFieldCodecV2.d.ts +1 -1
  246. package/dist/feature-libraries/optional-field/optionalFieldCodecV2.d.ts.map +1 -1
  247. package/dist/feature-libraries/optional-field/optionalFieldCodecV2.js +57 -28
  248. package/dist/feature-libraries/optional-field/optionalFieldCodecV2.js.map +1 -1
  249. package/dist/feature-libraries/optional-field/optionalFieldCodecV3.d.ts +12 -0
  250. package/dist/feature-libraries/optional-field/optionalFieldCodecV3.d.ts.map +1 -0
  251. package/dist/feature-libraries/optional-field/optionalFieldCodecV3.js +57 -0
  252. package/dist/feature-libraries/optional-field/optionalFieldCodecV3.js.map +1 -0
  253. package/dist/feature-libraries/optional-field/optionalFieldCodecs.d.ts.map +1 -1
  254. package/dist/feature-libraries/optional-field/optionalFieldCodecs.js +5 -1
  255. package/dist/feature-libraries/optional-field/optionalFieldCodecs.js.map +1 -1
  256. package/dist/feature-libraries/schema-edits/schemaChangeCodecs.d.ts.map +1 -1
  257. package/dist/feature-libraries/schema-edits/schemaChangeCodecs.js +14 -2
  258. package/dist/feature-libraries/schema-edits/schemaChangeCodecs.js.map +1 -1
  259. package/dist/feature-libraries/schema-index/codec.d.ts +7 -21
  260. package/dist/feature-libraries/schema-index/codec.d.ts.map +1 -1
  261. package/dist/feature-libraries/schema-index/codec.js +28 -70
  262. package/dist/feature-libraries/schema-index/codec.js.map +1 -1
  263. package/dist/feature-libraries/schema-index/index.d.ts +2 -2
  264. package/dist/feature-libraries/schema-index/index.d.ts.map +1 -1
  265. package/dist/feature-libraries/schema-index/index.js +2 -5
  266. package/dist/feature-libraries/schema-index/index.js.map +1 -1
  267. package/dist/feature-libraries/schema-index/schemaSummarizer.d.ts +1 -9
  268. package/dist/feature-libraries/schema-index/schemaSummarizer.d.ts.map +1 -1
  269. package/dist/feature-libraries/schema-index/schemaSummarizer.js +1 -12
  270. package/dist/feature-libraries/schema-index/schemaSummarizer.js.map +1 -1
  271. package/dist/feature-libraries/schemaChecker.d.ts.map +1 -1
  272. package/dist/feature-libraries/schemaChecker.js +11 -6
  273. package/dist/feature-libraries/schemaChecker.js.map +1 -1
  274. package/dist/feature-libraries/sequence-field/compose.d.ts +6 -7
  275. package/dist/feature-libraries/sequence-field/compose.d.ts.map +1 -1
  276. package/dist/feature-libraries/sequence-field/compose.js +91 -263
  277. package/dist/feature-libraries/sequence-field/compose.js.map +1 -1
  278. package/dist/feature-libraries/sequence-field/helperTypes.d.ts +14 -10
  279. package/dist/feature-libraries/sequence-field/helperTypes.d.ts.map +1 -1
  280. package/dist/feature-libraries/sequence-field/helperTypes.js.map +1 -1
  281. package/dist/feature-libraries/sequence-field/index.d.ts +2 -3
  282. package/dist/feature-libraries/sequence-field/index.d.ts.map +1 -1
  283. package/dist/feature-libraries/sequence-field/index.js +1 -3
  284. package/dist/feature-libraries/sequence-field/index.js.map +1 -1
  285. package/dist/feature-libraries/sequence-field/invert.d.ts +3 -3
  286. package/dist/feature-libraries/sequence-field/invert.d.ts.map +1 -1
  287. package/dist/feature-libraries/sequence-field/invert.js +67 -168
  288. package/dist/feature-libraries/sequence-field/invert.js.map +1 -1
  289. package/dist/feature-libraries/sequence-field/markQueue.d.ts +2 -2
  290. package/dist/feature-libraries/sequence-field/markQueue.d.ts.map +1 -1
  291. package/dist/feature-libraries/sequence-field/markQueue.js.map +1 -1
  292. package/dist/feature-libraries/sequence-field/moveEffectTable.d.ts +4 -56
  293. package/dist/feature-libraries/sequence-field/moveEffectTable.d.ts.map +1 -1
  294. package/dist/feature-libraries/sequence-field/moveEffectTable.js +10 -87
  295. package/dist/feature-libraries/sequence-field/moveEffectTable.js.map +1 -1
  296. package/dist/feature-libraries/sequence-field/rebase.d.ts +3 -3
  297. package/dist/feature-libraries/sequence-field/rebase.d.ts.map +1 -1
  298. package/dist/feature-libraries/sequence-field/rebase.js +120 -119
  299. package/dist/feature-libraries/sequence-field/rebase.js.map +1 -1
  300. package/dist/feature-libraries/sequence-field/replaceRevisions.d.ts +2 -2
  301. package/dist/feature-libraries/sequence-field/replaceRevisions.d.ts.map +1 -1
  302. package/dist/feature-libraries/sequence-field/replaceRevisions.js +35 -43
  303. package/dist/feature-libraries/sequence-field/replaceRevisions.js.map +1 -1
  304. package/dist/feature-libraries/sequence-field/sequenceFieldChangeHandler.d.ts.map +1 -1
  305. package/dist/feature-libraries/sequence-field/sequenceFieldChangeHandler.js +0 -2
  306. package/dist/feature-libraries/sequence-field/sequenceFieldChangeHandler.js.map +1 -1
  307. package/dist/feature-libraries/sequence-field/sequenceFieldCodecV2.d.ts +22 -4
  308. package/dist/feature-libraries/sequence-field/sequenceFieldCodecV2.d.ts.map +1 -1
  309. package/dist/feature-libraries/sequence-field/sequenceFieldCodecV2.js +365 -179
  310. package/dist/feature-libraries/sequence-field/sequenceFieldCodecV2.js.map +1 -1
  311. package/dist/feature-libraries/sequence-field/sequenceFieldCodecV3.d.ts.map +1 -1
  312. package/dist/feature-libraries/sequence-field/sequenceFieldCodecV3.js +20 -60
  313. package/dist/feature-libraries/sequence-field/sequenceFieldCodecV3.js.map +1 -1
  314. package/dist/feature-libraries/sequence-field/sequenceFieldEditor.d.ts +2 -2
  315. package/dist/feature-libraries/sequence-field/sequenceFieldEditor.d.ts.map +1 -1
  316. package/dist/feature-libraries/sequence-field/sequenceFieldEditor.js +10 -10
  317. package/dist/feature-libraries/sequence-field/sequenceFieldEditor.js.map +1 -1
  318. package/dist/feature-libraries/sequence-field/sequenceFieldToDelta.d.ts +3 -2
  319. package/dist/feature-libraries/sequence-field/sequenceFieldToDelta.d.ts.map +1 -1
  320. package/dist/feature-libraries/sequence-field/sequenceFieldToDelta.js +20 -112
  321. package/dist/feature-libraries/sequence-field/sequenceFieldToDelta.js.map +1 -1
  322. package/dist/feature-libraries/sequence-field/types.d.ts +30 -59
  323. package/dist/feature-libraries/sequence-field/types.d.ts.map +1 -1
  324. package/dist/feature-libraries/sequence-field/types.js.map +1 -1
  325. package/dist/feature-libraries/sequence-field/utils.d.ts +15 -24
  326. package/dist/feature-libraries/sequence-field/utils.d.ts.map +1 -1
  327. package/dist/feature-libraries/sequence-field/utils.js +148 -318
  328. package/dist/feature-libraries/sequence-field/utils.js.map +1 -1
  329. package/dist/feature-libraries/treeCursorUtils.js +7 -7
  330. package/dist/feature-libraries/treeCursorUtils.js.map +1 -1
  331. package/dist/feature-libraries/treeTextCursor.js +2 -2
  332. package/dist/feature-libraries/treeTextCursor.js.map +1 -1
  333. package/dist/feature-libraries/valueUtilities.d.ts.map +1 -1
  334. package/dist/feature-libraries/valueUtilities.js +16 -8
  335. package/dist/feature-libraries/valueUtilities.js.map +1 -1
  336. package/dist/index.d.ts +4 -3
  337. package/dist/index.d.ts.map +1 -1
  338. package/dist/index.js +4 -1
  339. package/dist/index.js.map +1 -1
  340. package/dist/packageVersion.d.ts +1 -1
  341. package/dist/packageVersion.d.ts.map +1 -1
  342. package/dist/packageVersion.js +1 -1
  343. package/dist/packageVersion.js.map +1 -1
  344. package/dist/shared-tree/index.d.ts +1 -1
  345. package/dist/shared-tree/index.d.ts.map +1 -1
  346. package/dist/shared-tree/index.js.map +1 -1
  347. package/dist/shared-tree/schematizeTree.d.ts +4 -4
  348. package/dist/shared-tree/schematizeTree.d.ts.map +1 -1
  349. package/dist/shared-tree/schematizeTree.js +2 -1
  350. package/dist/shared-tree/schematizeTree.js.map +1 -1
  351. package/dist/shared-tree/schematizingTreeView.d.ts +3 -8
  352. package/dist/shared-tree/schematizingTreeView.d.ts.map +1 -1
  353. package/dist/shared-tree/schematizingTreeView.js +58 -44
  354. package/dist/shared-tree/schematizingTreeView.js.map +1 -1
  355. package/dist/shared-tree/sharedTree.d.ts +9 -3
  356. package/dist/shared-tree/sharedTree.d.ts.map +1 -1
  357. package/dist/shared-tree/sharedTree.js +72 -44
  358. package/dist/shared-tree/sharedTree.js.map +1 -1
  359. package/dist/shared-tree/sharedTreeChangeCodecs.d.ts +1 -1
  360. package/dist/shared-tree/sharedTreeChangeCodecs.d.ts.map +1 -1
  361. package/dist/shared-tree/sharedTreeChangeCodecs.js +10 -8
  362. package/dist/shared-tree/sharedTreeChangeCodecs.js.map +1 -1
  363. package/dist/shared-tree/sharedTreeChangeEnricher.d.ts.map +1 -1
  364. package/dist/shared-tree/sharedTreeChangeEnricher.js +5 -3
  365. package/dist/shared-tree/sharedTreeChangeEnricher.js.map +1 -1
  366. package/dist/shared-tree/sharedTreeChangeFamily.d.ts +7 -6
  367. package/dist/shared-tree/sharedTreeChangeFamily.d.ts.map +1 -1
  368. package/dist/shared-tree/sharedTreeChangeFamily.js +29 -18
  369. package/dist/shared-tree/sharedTreeChangeFamily.js.map +1 -1
  370. package/dist/shared-tree/sharedTreeEditBuilder.d.ts +16 -6
  371. package/dist/shared-tree/sharedTreeEditBuilder.d.ts.map +1 -1
  372. package/dist/shared-tree/sharedTreeEditBuilder.js +14 -7
  373. package/dist/shared-tree/sharedTreeEditBuilder.js.map +1 -1
  374. package/dist/shared-tree/treeAlpha.d.ts +35 -29
  375. package/dist/shared-tree/treeAlpha.d.ts.map +1 -1
  376. package/dist/shared-tree/treeAlpha.js +21 -23
  377. package/dist/shared-tree/treeAlpha.js.map +1 -1
  378. package/dist/shared-tree/treeCheckout.d.ts +11 -10
  379. package/dist/shared-tree/treeCheckout.d.ts.map +1 -1
  380. package/dist/shared-tree/treeCheckout.js +93 -25
  381. package/dist/shared-tree/treeCheckout.js.map +1 -1
  382. package/dist/shared-tree-core/branch.d.ts +6 -3
  383. package/dist/shared-tree-core/branch.d.ts.map +1 -1
  384. package/dist/shared-tree-core/branch.js +13 -6
  385. package/dist/shared-tree-core/branch.js.map +1 -1
  386. package/dist/shared-tree-core/branchCommitEnricher.d.ts.map +1 -1
  387. package/dist/shared-tree-core/branchCommitEnricher.js +1 -1
  388. package/dist/shared-tree-core/branchCommitEnricher.js.map +1 -1
  389. package/dist/shared-tree-core/editManager.d.ts +2 -2
  390. package/dist/shared-tree-core/editManager.d.ts.map +1 -1
  391. package/dist/shared-tree-core/editManager.js +21 -15
  392. package/dist/shared-tree-core/editManager.js.map +1 -1
  393. package/dist/shared-tree-core/editManagerCodecs.d.ts +4 -0
  394. package/dist/shared-tree-core/editManagerCodecs.d.ts.map +1 -1
  395. package/dist/shared-tree-core/editManagerCodecs.js +18 -5
  396. package/dist/shared-tree-core/editManagerCodecs.js.map +1 -1
  397. package/dist/shared-tree-core/editManagerFormatCommons.d.ts +2 -0
  398. package/dist/shared-tree-core/editManagerFormatCommons.d.ts.map +1 -1
  399. package/dist/shared-tree-core/editManagerFormatCommons.js +12 -0
  400. package/dist/shared-tree-core/editManagerFormatCommons.js.map +1 -1
  401. package/dist/shared-tree-core/editManagerFormatV1toV4.d.ts +2 -2
  402. package/dist/shared-tree-core/editManagerFormatV1toV4.d.ts.map +1 -1
  403. package/dist/shared-tree-core/editManagerFormatV1toV4.js +2 -0
  404. package/dist/shared-tree-core/editManagerFormatV1toV4.js.map +1 -1
  405. package/dist/shared-tree-core/editManagerSummarizer.js +3 -3
  406. package/dist/shared-tree-core/editManagerSummarizer.js.map +1 -1
  407. package/dist/shared-tree-core/index.d.ts +2 -2
  408. package/dist/shared-tree-core/index.d.ts.map +1 -1
  409. package/dist/shared-tree-core/index.js +3 -1
  410. package/dist/shared-tree-core/index.js.map +1 -1
  411. package/dist/shared-tree-core/messageCodecV1ToV4.d.ts +1 -1
  412. package/dist/shared-tree-core/messageCodecV1ToV4.d.ts.map +1 -1
  413. package/dist/shared-tree-core/messageCodecV1ToV4.js.map +1 -1
  414. package/dist/shared-tree-core/messageCodecVSharedBranches.d.ts.map +1 -1
  415. package/dist/shared-tree-core/messageCodecVSharedBranches.js +2 -1
  416. package/dist/shared-tree-core/messageCodecVSharedBranches.js.map +1 -1
  417. package/dist/shared-tree-core/messageCodecs.d.ts +4 -0
  418. package/dist/shared-tree-core/messageCodecs.d.ts.map +1 -1
  419. package/dist/shared-tree-core/messageCodecs.js +17 -5
  420. package/dist/shared-tree-core/messageCodecs.js.map +1 -1
  421. package/dist/shared-tree-core/messageFormat.d.ts +2 -0
  422. package/dist/shared-tree-core/messageFormat.d.ts.map +1 -1
  423. package/dist/shared-tree-core/messageFormat.js +12 -0
  424. package/dist/shared-tree-core/messageFormat.js.map +1 -1
  425. package/dist/shared-tree-core/messageFormatV1ToV4.d.ts +3 -2
  426. package/dist/shared-tree-core/messageFormatV1ToV4.d.ts.map +1 -1
  427. package/dist/shared-tree-core/messageFormatV1ToV4.js +9 -1
  428. package/dist/shared-tree-core/messageFormatV1ToV4.js.map +1 -1
  429. package/dist/shared-tree-core/sequenceIdUtils.d.ts.map +1 -1
  430. package/dist/shared-tree-core/sequenceIdUtils.js +4 -4
  431. package/dist/shared-tree-core/sequenceIdUtils.js.map +1 -1
  432. package/dist/shared-tree-core/sharedTreeCore.d.ts +1 -0
  433. package/dist/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
  434. package/dist/shared-tree-core/sharedTreeCore.js +13 -9
  435. package/dist/shared-tree-core/sharedTreeCore.js.map +1 -1
  436. package/dist/shared-tree-core/transaction.d.ts +25 -8
  437. package/dist/shared-tree-core/transaction.d.ts.map +1 -1
  438. package/dist/shared-tree-core/transaction.js +65 -30
  439. package/dist/shared-tree-core/transaction.js.map +1 -1
  440. package/dist/shared-tree-core/transactionEnricher.d.ts +2 -2
  441. package/dist/shared-tree-core/transactionEnricher.d.ts.map +1 -1
  442. package/dist/shared-tree-core/transactionEnricher.js +3 -3
  443. package/dist/shared-tree-core/transactionEnricher.js.map +1 -1
  444. package/dist/simple-tree/api/configuration.js +1 -1
  445. package/dist/simple-tree/api/configuration.js.map +1 -1
  446. package/dist/simple-tree/api/customTree.d.ts.map +1 -1
  447. package/dist/simple-tree/api/customTree.js +13 -9
  448. package/dist/simple-tree/api/customTree.js.map +1 -1
  449. package/dist/simple-tree/api/discrepancies.d.ts.map +1 -1
  450. package/dist/simple-tree/api/discrepancies.js +21 -17
  451. package/dist/simple-tree/api/discrepancies.js.map +1 -1
  452. package/dist/simple-tree/api/index.d.ts +2 -2
  453. package/dist/simple-tree/api/index.d.ts.map +1 -1
  454. package/dist/simple-tree/api/index.js +2 -1
  455. package/dist/simple-tree/api/index.js.map +1 -1
  456. package/dist/simple-tree/api/schemaFactory.d.ts.map +1 -1
  457. package/dist/simple-tree/api/schemaFactory.js +12 -8
  458. package/dist/simple-tree/api/schemaFactory.js.map +1 -1
  459. package/dist/simple-tree/api/schemaFactoryAlpha.js +1 -1
  460. package/dist/simple-tree/api/schemaFactoryAlpha.js.map +1 -1
  461. package/dist/simple-tree/api/schemaFactoryBeta.js +1 -1
  462. package/dist/simple-tree/api/schemaFactoryBeta.js.map +1 -1
  463. package/dist/simple-tree/api/schemaFromSimple.js +18 -9
  464. package/dist/simple-tree/api/schemaFromSimple.js.map +1 -1
  465. package/dist/simple-tree/api/simpleSchemaCodec.js +10 -5
  466. package/dist/simple-tree/api/simpleSchemaCodec.js.map +1 -1
  467. package/dist/simple-tree/api/simpleSchemaToJsonSchema.d.ts.map +1 -1
  468. package/dist/simple-tree/api/simpleSchemaToJsonSchema.js +19 -15
  469. package/dist/simple-tree/api/simpleSchemaToJsonSchema.js.map +1 -1
  470. package/dist/simple-tree/api/simpleTreeIndex.js +10 -10
  471. package/dist/simple-tree/api/simpleTreeIndex.js.map +1 -1
  472. package/dist/simple-tree/api/snapshotCompatibilityChecker.d.ts +244 -0
  473. package/dist/simple-tree/api/snapshotCompatibilityChecker.d.ts.map +1 -1
  474. package/dist/simple-tree/api/snapshotCompatibilityChecker.js +297 -1
  475. package/dist/simple-tree/api/snapshotCompatibilityChecker.js.map +1 -1
  476. package/dist/simple-tree/api/storedSchema.d.ts.map +1 -1
  477. package/dist/simple-tree/api/storedSchema.js +2 -3
  478. package/dist/simple-tree/api/storedSchema.js.map +1 -1
  479. package/dist/simple-tree/api/transactionTypes.d.ts +17 -4
  480. package/dist/simple-tree/api/transactionTypes.d.ts.map +1 -1
  481. package/dist/simple-tree/api/transactionTypes.js.map +1 -1
  482. package/dist/simple-tree/api/tree.d.ts +3 -1
  483. package/dist/simple-tree/api/tree.d.ts.map +1 -1
  484. package/dist/simple-tree/api/tree.js.map +1 -1
  485. package/dist/simple-tree/api/treeNodeApi.d.ts.map +1 -1
  486. package/dist/simple-tree/api/treeNodeApi.js +21 -13
  487. package/dist/simple-tree/api/treeNodeApi.js.map +1 -1
  488. package/dist/simple-tree/api/verboseTree.d.ts.map +1 -1
  489. package/dist/simple-tree/api/verboseTree.js +14 -9
  490. package/dist/simple-tree/api/verboseTree.js.map +1 -1
  491. package/dist/simple-tree/core/treeNodeKernel.d.ts.map +1 -1
  492. package/dist/simple-tree/core/treeNodeKernel.js +12 -5
  493. package/dist/simple-tree/core/treeNodeKernel.js.map +1 -1
  494. package/dist/simple-tree/core/unhydratedFlexTree.d.ts +15 -15
  495. package/dist/simple-tree/core/unhydratedFlexTree.d.ts.map +1 -1
  496. package/dist/simple-tree/core/unhydratedFlexTree.js +79 -23
  497. package/dist/simple-tree/core/unhydratedFlexTree.js.map +1 -1
  498. package/dist/simple-tree/fieldSchema.d.ts +4 -4
  499. package/dist/simple-tree/fieldSchema.d.ts.map +1 -1
  500. package/dist/simple-tree/fieldSchema.js.map +1 -1
  501. package/dist/simple-tree/getTreeNodeForField.d.ts.map +1 -1
  502. package/dist/simple-tree/getTreeNodeForField.js +2 -1
  503. package/dist/simple-tree/getTreeNodeForField.js.map +1 -1
  504. package/dist/simple-tree/index.d.ts +3 -3
  505. package/dist/simple-tree/index.d.ts.map +1 -1
  506. package/dist/simple-tree/index.js +4 -3
  507. package/dist/simple-tree/index.js.map +1 -1
  508. package/dist/simple-tree/leafNodeSchema.js +9 -6
  509. package/dist/simple-tree/leafNodeSchema.js.map +1 -1
  510. package/dist/simple-tree/node-kinds/array/arrayNode.d.ts.map +1 -1
  511. package/dist/simple-tree/node-kinds/array/arrayNode.js +22 -20
  512. package/dist/simple-tree/node-kinds/array/arrayNode.js.map +1 -1
  513. package/dist/simple-tree/node-kinds/common.d.ts.map +1 -1
  514. package/dist/simple-tree/node-kinds/common.js +1 -1
  515. package/dist/simple-tree/node-kinds/common.js.map +1 -1
  516. package/dist/simple-tree/node-kinds/map/mapNode.js +2 -2
  517. package/dist/simple-tree/node-kinds/map/mapNode.js.map +1 -1
  518. package/dist/simple-tree/node-kinds/object/objectNode.d.ts.map +1 -1
  519. package/dist/simple-tree/node-kinds/object/objectNode.js +21 -22
  520. package/dist/simple-tree/node-kinds/object/objectNode.js.map +1 -1
  521. package/dist/simple-tree/node-kinds/record/recordNode.js +6 -5
  522. package/dist/simple-tree/node-kinds/record/recordNode.js.map +1 -1
  523. package/dist/simple-tree/prepareForInsertion.d.ts +54 -47
  524. package/dist/simple-tree/prepareForInsertion.d.ts.map +1 -1
  525. package/dist/simple-tree/prepareForInsertion.js +184 -126
  526. package/dist/simple-tree/prepareForInsertion.js.map +1 -1
  527. package/dist/simple-tree/toStoredSchema.d.ts.map +1 -1
  528. package/dist/simple-tree/toStoredSchema.js +9 -5
  529. package/dist/simple-tree/toStoredSchema.js.map +1 -1
  530. package/dist/simple-tree/unhydratedFlexTreeFromInsertable.d.ts +13 -4
  531. package/dist/simple-tree/unhydratedFlexTreeFromInsertable.d.ts.map +1 -1
  532. package/dist/simple-tree/unhydratedFlexTreeFromInsertable.js +31 -13
  533. package/dist/simple-tree/unhydratedFlexTreeFromInsertable.js.map +1 -1
  534. package/dist/text/index.d.ts +6 -0
  535. package/dist/text/index.d.ts.map +1 -0
  536. package/dist/text/index.js +10 -0
  537. package/dist/text/index.js.map +1 -0
  538. package/dist/text/textDomain.d.ts +138 -0
  539. package/dist/text/textDomain.d.ts.map +1 -0
  540. package/dist/text/textDomain.js +121 -0
  541. package/dist/text/textDomain.js.map +1 -0
  542. package/dist/treeFactory.d.ts.map +1 -1
  543. package/dist/treeFactory.js +17 -3
  544. package/dist/treeFactory.js.map +1 -1
  545. package/dist/util/bTreeUtils.d.ts +12 -4
  546. package/dist/util/bTreeUtils.d.ts.map +1 -1
  547. package/dist/util/bTreeUtils.js +15 -19
  548. package/dist/util/bTreeUtils.js.map +1 -1
  549. package/dist/util/breakable.js +7 -9
  550. package/dist/util/breakable.js.map +1 -1
  551. package/dist/util/idAllocator.d.ts.map +1 -1
  552. package/dist/util/idAllocator.js +1 -2
  553. package/dist/util/idAllocator.js.map +1 -1
  554. package/dist/util/index.d.ts +1 -1
  555. package/dist/util/index.d.ts.map +1 -1
  556. package/dist/util/index.js +2 -1
  557. package/dist/util/index.js.map +1 -1
  558. package/dist/util/nestedMap.d.ts.map +1 -1
  559. package/dist/util/nestedMap.js +13 -13
  560. package/dist/util/nestedMap.js.map +1 -1
  561. package/dist/util/rangeMap.d.ts +24 -12
  562. package/dist/util/rangeMap.d.ts.map +1 -1
  563. package/dist/util/rangeMap.js +46 -6
  564. package/dist/util/rangeMap.js.map +1 -1
  565. package/dist/util/utils.d.ts.map +1 -1
  566. package/dist/util/utils.js +16 -15
  567. package/dist/util/utils.js.map +1 -1
  568. package/docs/user-facing/merge-semantics.md +3 -2
  569. package/eslint.config.mts +5 -48
  570. package/lib/alpha.d.ts +9 -0
  571. package/lib/codec/codec.d.ts +31 -3
  572. package/lib/codec/codec.d.ts.map +1 -1
  573. package/lib/codec/codec.js +10 -0
  574. package/lib/codec/codec.js.map +1 -1
  575. package/lib/codec/index.d.ts +2 -2
  576. package/lib/codec/index.d.ts.map +1 -1
  577. package/lib/codec/index.js +1 -1
  578. package/lib/codec/index.js.map +1 -1
  579. package/lib/codec/versioned/codec.d.ts +80 -22
  580. package/lib/codec/versioned/codec.d.ts.map +1 -1
  581. package/lib/codec/versioned/codec.js +138 -15
  582. package/lib/codec/versioned/codec.js.map +1 -1
  583. package/lib/codec/versioned/index.d.ts +1 -1
  584. package/lib/codec/versioned/index.d.ts.map +1 -1
  585. package/lib/codec/versioned/index.js +1 -1
  586. package/lib/codec/versioned/index.js.map +1 -1
  587. package/lib/core/change-family/changeFamily.d.ts +4 -1
  588. package/lib/core/change-family/changeFamily.d.ts.map +1 -1
  589. package/lib/core/change-family/changeFamily.js.map +1 -1
  590. package/lib/core/change-family/index.d.ts +1 -1
  591. package/lib/core/change-family/index.d.ts.map +1 -1
  592. package/lib/core/change-family/index.js.map +1 -1
  593. package/lib/core/index.d.ts +3 -3
  594. package/lib/core/index.d.ts.map +1 -1
  595. package/lib/core/index.js +2 -2
  596. package/lib/core/index.js.map +1 -1
  597. package/lib/core/rebase/changeRebaser.d.ts +42 -3
  598. package/lib/core/rebase/changeRebaser.d.ts.map +1 -1
  599. package/lib/core/rebase/changeRebaser.js.map +1 -1
  600. package/lib/core/rebase/index.d.ts +2 -2
  601. package/lib/core/rebase/index.d.ts.map +1 -1
  602. package/lib/core/rebase/index.js +1 -1
  603. package/lib/core/rebase/index.js.map +1 -1
  604. package/lib/core/rebase/types.d.ts +52 -10
  605. package/lib/core/rebase/types.d.ts.map +1 -1
  606. package/lib/core/rebase/types.js +3 -10
  607. package/lib/core/rebase/types.js.map +1 -1
  608. package/lib/core/rebase/utils.d.ts.map +1 -1
  609. package/lib/core/rebase/utils.js +33 -11
  610. package/lib/core/rebase/utils.js.map +1 -1
  611. package/lib/core/schema-stored/schema.js +3 -3
  612. package/lib/core/schema-stored/schema.js.map +1 -1
  613. package/lib/core/tree/anchorSet.d.ts.map +1 -1
  614. package/lib/core/tree/anchorSet.js +4 -4
  615. package/lib/core/tree/anchorSet.js.map +1 -1
  616. package/lib/core/tree/detachedFieldIndex.d.ts +7 -2
  617. package/lib/core/tree/detachedFieldIndex.d.ts.map +1 -1
  618. package/lib/core/tree/detachedFieldIndex.js +23 -58
  619. package/lib/core/tree/detachedFieldIndex.js.map +1 -1
  620. package/lib/core/tree/detachedFieldIndexCodecCommon.d.ts +18 -10
  621. package/lib/core/tree/detachedFieldIndexCodecCommon.d.ts.map +1 -1
  622. package/lib/core/tree/detachedFieldIndexCodecCommon.js +4 -4
  623. package/lib/core/tree/detachedFieldIndexCodecCommon.js.map +1 -1
  624. package/lib/core/tree/detachedFieldIndexCodecV1.d.ts +2 -3
  625. package/lib/core/tree/detachedFieldIndexCodecV1.d.ts.map +1 -1
  626. package/lib/core/tree/detachedFieldIndexCodecV1.js +4 -5
  627. package/lib/core/tree/detachedFieldIndexCodecV1.js.map +1 -1
  628. package/lib/core/tree/detachedFieldIndexCodecV2.d.ts +2 -3
  629. package/lib/core/tree/detachedFieldIndexCodecV2.d.ts.map +1 -1
  630. package/lib/core/tree/detachedFieldIndexCodecV2.js +4 -6
  631. package/lib/core/tree/detachedFieldIndexCodecV2.js.map +1 -1
  632. package/lib/core/tree/detachedFieldIndexCodecs.d.ts +5 -6
  633. package/lib/core/tree/detachedFieldIndexCodecs.d.ts.map +1 -1
  634. package/lib/core/tree/detachedFieldIndexCodecs.js +12 -39
  635. package/lib/core/tree/detachedFieldIndexCodecs.js.map +1 -1
  636. package/lib/core/tree/index.d.ts +2 -2
  637. package/lib/core/tree/index.d.ts.map +1 -1
  638. package/lib/core/tree/index.js +2 -2
  639. package/lib/core/tree/index.js.map +1 -1
  640. package/lib/core/tree/mapTree.js +1 -1
  641. package/lib/core/tree/mapTree.js.map +1 -1
  642. package/lib/core/tree/pathTree.d.ts +11 -3
  643. package/lib/core/tree/pathTree.d.ts.map +1 -1
  644. package/lib/core/tree/pathTree.js +12 -1
  645. package/lib/core/tree/pathTree.js.map +1 -1
  646. package/lib/core/tree/sparseTree.d.ts.map +1 -1
  647. package/lib/core/tree/sparseTree.js +1 -0
  648. package/lib/core/tree/sparseTree.js.map +1 -1
  649. package/lib/core/tree/treeTextFormat.d.ts.map +1 -1
  650. package/lib/core/tree/treeTextFormat.js +5 -9
  651. package/lib/core/tree/treeTextFormat.js.map +1 -1
  652. package/lib/core/tree/visitDelta.d.ts.map +1 -1
  653. package/lib/core/tree/visitDelta.js +3 -2
  654. package/lib/core/tree/visitDelta.js.map +1 -1
  655. package/lib/core/tree/visitorUtils.d.ts.map +1 -1
  656. package/lib/core/tree/visitorUtils.js +58 -18
  657. package/lib/core/tree/visitorUtils.js.map +1 -1
  658. package/lib/feature-libraries/changeAtomIdBTree.d.ts +16 -0
  659. package/lib/feature-libraries/changeAtomIdBTree.d.ts.map +1 -0
  660. package/lib/feature-libraries/changeAtomIdBTree.js +24 -0
  661. package/lib/feature-libraries/changeAtomIdBTree.js.map +1 -0
  662. package/lib/feature-libraries/chunked-forest/basicChunk.d.ts.map +1 -1
  663. package/lib/feature-libraries/chunked-forest/basicChunk.js +9 -2
  664. package/lib/feature-libraries/chunked-forest/basicChunk.js.map +1 -1
  665. package/lib/feature-libraries/chunked-forest/chunkTree.d.ts.map +1 -1
  666. package/lib/feature-libraries/chunked-forest/chunkTree.js +4 -1
  667. package/lib/feature-libraries/chunked-forest/chunkTree.js.map +1 -1
  668. package/lib/feature-libraries/chunked-forest/chunkedForest.d.ts.map +1 -1
  669. package/lib/feature-libraries/chunked-forest/chunkedForest.js +9 -7
  670. package/lib/feature-libraries/chunked-forest/chunkedForest.js.map +1 -1
  671. package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.d.ts.map +1 -1
  672. package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.js +7 -4
  673. package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.js.map +1 -1
  674. package/lib/feature-libraries/chunked-forest/codec/codecs.d.ts.map +1 -1
  675. package/lib/feature-libraries/chunked-forest/codec/codecs.js +19 -11
  676. package/lib/feature-libraries/chunked-forest/codec/codecs.js.map +1 -1
  677. package/lib/feature-libraries/chunked-forest/codec/compressedEncode.js +4 -3
  678. package/lib/feature-libraries/chunked-forest/codec/compressedEncode.js.map +1 -1
  679. package/lib/feature-libraries/chunked-forest/codec/schemaBasedEncode.js +9 -5
  680. package/lib/feature-libraries/chunked-forest/codec/schemaBasedEncode.js.map +1 -1
  681. package/lib/feature-libraries/chunked-forest/uniformChunk.js +1 -1
  682. package/lib/feature-libraries/chunked-forest/uniformChunk.js.map +1 -1
  683. package/lib/feature-libraries/default-schema/defaultEditBuilder.d.ts +103 -44
  684. package/lib/feature-libraries/default-schema/defaultEditBuilder.d.ts.map +1 -1
  685. package/lib/feature-libraries/default-schema/defaultEditBuilder.js +249 -78
  686. package/lib/feature-libraries/default-schema/defaultEditBuilder.js.map +1 -1
  687. package/lib/feature-libraries/default-schema/defaultFieldKinds.d.ts +1 -1
  688. package/lib/feature-libraries/default-schema/defaultFieldKinds.d.ts.map +1 -1
  689. package/lib/feature-libraries/default-schema/defaultFieldKinds.js +22 -3
  690. package/lib/feature-libraries/default-schema/defaultFieldKinds.js.map +1 -1
  691. package/lib/feature-libraries/default-schema/index.d.ts +2 -1
  692. package/lib/feature-libraries/default-schema/index.d.ts.map +1 -1
  693. package/lib/feature-libraries/default-schema/index.js +2 -1
  694. package/lib/feature-libraries/default-schema/index.js.map +1 -1
  695. package/lib/feature-libraries/default-schema/locationBasedEditBuilder.d.ts +38 -0
  696. package/lib/feature-libraries/default-schema/locationBasedEditBuilder.d.ts.map +1 -0
  697. package/lib/feature-libraries/default-schema/locationBasedEditBuilder.js +128 -0
  698. package/lib/feature-libraries/default-schema/locationBasedEditBuilder.js.map +1 -0
  699. package/lib/feature-libraries/default-schema/mappedEditBuilder.d.ts +9 -6
  700. package/lib/feature-libraries/default-schema/mappedEditBuilder.d.ts.map +1 -1
  701. package/lib/feature-libraries/default-schema/mappedEditBuilder.js +21 -0
  702. package/lib/feature-libraries/default-schema/mappedEditBuilder.js.map +1 -1
  703. package/lib/feature-libraries/deltaUtils.d.ts +1 -0
  704. package/lib/feature-libraries/deltaUtils.d.ts.map +1 -1
  705. package/lib/feature-libraries/deltaUtils.js +5 -1
  706. package/lib/feature-libraries/deltaUtils.js.map +1 -1
  707. package/lib/feature-libraries/flex-tree/context.d.ts +9 -0
  708. package/lib/feature-libraries/flex-tree/context.d.ts.map +1 -1
  709. package/lib/feature-libraries/flex-tree/context.js +6 -0
  710. package/lib/feature-libraries/flex-tree/context.js.map +1 -1
  711. package/lib/feature-libraries/flex-tree/flexTreeTypes.d.ts +6 -6
  712. package/lib/feature-libraries/flex-tree/flexTreeTypes.d.ts.map +1 -1
  713. package/lib/feature-libraries/flex-tree/flexTreeTypes.js.map +1 -1
  714. package/lib/feature-libraries/flex-tree/lazyField.d.ts +8 -7
  715. package/lib/feature-libraries/flex-tree/lazyField.d.ts.map +1 -1
  716. package/lib/feature-libraries/flex-tree/lazyField.js +45 -16
  717. package/lib/feature-libraries/flex-tree/lazyField.js.map +1 -1
  718. package/lib/feature-libraries/forest-summary/forestSummarizer.d.ts.map +1 -1
  719. package/lib/feature-libraries/forest-summary/forestSummarizer.js +3 -1
  720. package/lib/feature-libraries/forest-summary/forestSummarizer.js.map +1 -1
  721. package/lib/feature-libraries/index.d.ts +5 -4
  722. package/lib/feature-libraries/index.d.ts.map +1 -1
  723. package/lib/feature-libraries/index.js +5 -4
  724. package/lib/feature-libraries/index.js.map +1 -1
  725. package/lib/feature-libraries/indexing/anchorTreeIndex.js +6 -6
  726. package/lib/feature-libraries/indexing/anchorTreeIndex.js.map +1 -1
  727. package/lib/feature-libraries/mapTreeCursor.d.ts.map +1 -1
  728. package/lib/feature-libraries/mapTreeCursor.js +2 -1
  729. package/lib/feature-libraries/mapTreeCursor.js.map +1 -1
  730. package/lib/feature-libraries/mitigatedChangeFamily.d.ts.map +1 -1
  731. package/lib/feature-libraries/mitigatedChangeFamily.js +12 -3
  732. package/lib/feature-libraries/mitigatedChangeFamily.js.map +1 -1
  733. package/lib/feature-libraries/modular-schema/comparison.d.ts.map +1 -1
  734. package/lib/feature-libraries/modular-schema/comparison.js +12 -9
  735. package/lib/feature-libraries/modular-schema/comparison.js.map +1 -1
  736. package/lib/feature-libraries/modular-schema/crossFieldQueries.d.ts +97 -21
  737. package/lib/feature-libraries/modular-schema/crossFieldQueries.d.ts.map +1 -1
  738. package/lib/feature-libraries/modular-schema/crossFieldQueries.js +3 -5
  739. package/lib/feature-libraries/modular-schema/crossFieldQueries.js.map +1 -1
  740. package/lib/feature-libraries/modular-schema/defaultRevisionReplacer.d.ts +25 -0
  741. package/lib/feature-libraries/modular-schema/defaultRevisionReplacer.d.ts.map +1 -0
  742. package/lib/feature-libraries/modular-schema/defaultRevisionReplacer.js +55 -0
  743. package/lib/feature-libraries/modular-schema/defaultRevisionReplacer.js.map +1 -0
  744. package/lib/feature-libraries/modular-schema/fieldChangeHandler.d.ts +22 -53
  745. package/lib/feature-libraries/modular-schema/fieldChangeHandler.d.ts.map +1 -1
  746. package/lib/feature-libraries/modular-schema/fieldChangeHandler.js.map +1 -1
  747. package/lib/feature-libraries/modular-schema/genericFieldKind.d.ts.map +1 -1
  748. package/lib/feature-libraries/modular-schema/genericFieldKind.js +8 -14
  749. package/lib/feature-libraries/modular-schema/genericFieldKind.js.map +1 -1
  750. package/lib/feature-libraries/modular-schema/genericFieldKindCodecs.js +1 -1
  751. package/lib/feature-libraries/modular-schema/genericFieldKindCodecs.js.map +1 -1
  752. package/lib/feature-libraries/modular-schema/index.d.ts +7 -5
  753. package/lib/feature-libraries/modular-schema/index.d.ts.map +1 -1
  754. package/lib/feature-libraries/modular-schema/index.js +5 -3
  755. package/lib/feature-libraries/modular-schema/index.js.map +1 -1
  756. package/lib/feature-libraries/modular-schema/modularChangeCodecV1.d.ts +32 -0
  757. package/lib/feature-libraries/modular-schema/modularChangeCodecV1.d.ts.map +1 -0
  758. package/lib/feature-libraries/modular-schema/modularChangeCodecV1.js +402 -0
  759. package/lib/feature-libraries/modular-schema/modularChangeCodecV1.js.map +1 -0
  760. package/lib/feature-libraries/modular-schema/modularChangeCodecV2.d.ts +15 -0
  761. package/lib/feature-libraries/modular-schema/modularChangeCodecV2.d.ts.map +1 -0
  762. package/lib/feature-libraries/modular-schema/modularChangeCodecV2.js +27 -0
  763. package/lib/feature-libraries/modular-schema/modularChangeCodecV2.js.map +1 -0
  764. package/lib/feature-libraries/modular-schema/modularChangeCodecV3.d.ts +15 -0
  765. package/lib/feature-libraries/modular-schema/modularChangeCodecV3.d.ts.map +1 -0
  766. package/lib/feature-libraries/modular-schema/modularChangeCodecV3.js +389 -0
  767. package/lib/feature-libraries/modular-schema/modularChangeCodecV3.js.map +1 -0
  768. package/lib/feature-libraries/modular-schema/modularChangeCodecs.d.ts +2 -2
  769. package/lib/feature-libraries/modular-schema/modularChangeCodecs.d.ts.map +1 -1
  770. package/lib/feature-libraries/modular-schema/modularChangeCodecs.js +34 -290
  771. package/lib/feature-libraries/modular-schema/modularChangeCodecs.js.map +1 -1
  772. package/lib/feature-libraries/modular-schema/modularChangeFamily.d.ts +60 -26
  773. package/lib/feature-libraries/modular-schema/modularChangeFamily.d.ts.map +1 -1
  774. package/lib/feature-libraries/modular-schema/modularChangeFamily.js +1441 -546
  775. package/lib/feature-libraries/modular-schema/modularChangeFamily.js.map +1 -1
  776. package/{dist/feature-libraries/modular-schema/modularChangeFormat.d.ts → lib/feature-libraries/modular-schema/modularChangeFormatV1.d.ts} +5 -6
  777. package/lib/feature-libraries/modular-schema/modularChangeFormatV1.d.ts.map +1 -0
  778. package/lib/feature-libraries/modular-schema/{modularChangeFormat.js → modularChangeFormatV1.js} +4 -4
  779. package/lib/feature-libraries/modular-schema/modularChangeFormatV1.js.map +1 -0
  780. package/lib/feature-libraries/modular-schema/modularChangeFormatV2.d.ts +112 -0
  781. package/lib/feature-libraries/modular-schema/modularChangeFormatV2.d.ts.map +1 -0
  782. package/lib/feature-libraries/modular-schema/modularChangeFormatV2.js +18 -0
  783. package/lib/feature-libraries/modular-schema/modularChangeFormatV2.js.map +1 -0
  784. package/lib/feature-libraries/modular-schema/modularChangeFormatV3.d.ts +146 -0
  785. package/lib/feature-libraries/modular-schema/modularChangeFormatV3.d.ts.map +1 -0
  786. package/lib/feature-libraries/modular-schema/modularChangeFormatV3.js +29 -0
  787. package/lib/feature-libraries/modular-schema/modularChangeFormatV3.js.map +1 -0
  788. package/lib/feature-libraries/modular-schema/modularChangeTypes.d.ts +59 -13
  789. package/lib/feature-libraries/modular-schema/modularChangeTypes.d.ts.map +1 -1
  790. package/lib/feature-libraries/modular-schema/modularChangeTypes.js +1 -1
  791. package/lib/feature-libraries/modular-schema/modularChangeTypes.js.map +1 -1
  792. package/lib/feature-libraries/node-identifier/mockNodeIdentifierManager.js +1 -1
  793. package/lib/feature-libraries/node-identifier/mockNodeIdentifierManager.js.map +1 -1
  794. package/lib/feature-libraries/object-forest/objectForest.d.ts.map +1 -1
  795. package/lib/feature-libraries/object-forest/objectForest.js +7 -5
  796. package/lib/feature-libraries/object-forest/objectForest.js.map +1 -1
  797. package/lib/feature-libraries/optional-field/index.d.ts +2 -2
  798. package/lib/feature-libraries/optional-field/index.d.ts.map +1 -1
  799. package/lib/feature-libraries/optional-field/index.js +1 -1
  800. package/lib/feature-libraries/optional-field/index.js.map +1 -1
  801. package/lib/feature-libraries/optional-field/optionalField.d.ts +5 -26
  802. package/lib/feature-libraries/optional-field/optionalField.d.ts.map +1 -1
  803. package/lib/feature-libraries/optional-field/optionalField.js +223 -448
  804. package/lib/feature-libraries/optional-field/optionalField.js.map +1 -1
  805. package/lib/feature-libraries/optional-field/optionalFieldChangeFormatV3.d.ts +23 -0
  806. package/lib/feature-libraries/optional-field/optionalFieldChangeFormatV3.d.ts.map +1 -0
  807. package/lib/feature-libraries/optional-field/optionalFieldChangeFormatV3.js +27 -0
  808. package/lib/feature-libraries/optional-field/optionalFieldChangeFormatV3.js.map +1 -0
  809. package/lib/feature-libraries/optional-field/optionalFieldChangeTypes.d.ts +24 -33
  810. package/lib/feature-libraries/optional-field/optionalFieldChangeTypes.d.ts.map +1 -1
  811. package/lib/feature-libraries/optional-field/optionalFieldChangeTypes.js.map +1 -1
  812. package/lib/feature-libraries/optional-field/optionalFieldCodecV2.d.ts +1 -1
  813. package/lib/feature-libraries/optional-field/optionalFieldCodecV2.d.ts.map +1 -1
  814. package/lib/feature-libraries/optional-field/optionalFieldCodecV2.js +55 -26
  815. package/lib/feature-libraries/optional-field/optionalFieldCodecV2.js.map +1 -1
  816. package/lib/feature-libraries/optional-field/optionalFieldCodecV3.d.ts +12 -0
  817. package/lib/feature-libraries/optional-field/optionalFieldCodecV3.d.ts.map +1 -0
  818. package/lib/feature-libraries/optional-field/optionalFieldCodecV3.js +53 -0
  819. package/lib/feature-libraries/optional-field/optionalFieldCodecV3.js.map +1 -0
  820. package/lib/feature-libraries/optional-field/optionalFieldCodecs.d.ts.map +1 -1
  821. package/lib/feature-libraries/optional-field/optionalFieldCodecs.js +5 -1
  822. package/lib/feature-libraries/optional-field/optionalFieldCodecs.js.map +1 -1
  823. package/lib/feature-libraries/schema-edits/schemaChangeCodecs.d.ts.map +1 -1
  824. package/lib/feature-libraries/schema-edits/schemaChangeCodecs.js +15 -3
  825. package/lib/feature-libraries/schema-edits/schemaChangeCodecs.js.map +1 -1
  826. package/lib/feature-libraries/schema-index/codec.d.ts +7 -21
  827. package/lib/feature-libraries/schema-index/codec.d.ts.map +1 -1
  828. package/lib/feature-libraries/schema-index/codec.js +30 -68
  829. package/lib/feature-libraries/schema-index/codec.js.map +1 -1
  830. package/lib/feature-libraries/schema-index/index.d.ts +2 -2
  831. package/lib/feature-libraries/schema-index/index.d.ts.map +1 -1
  832. package/lib/feature-libraries/schema-index/index.js +2 -2
  833. package/lib/feature-libraries/schema-index/index.js.map +1 -1
  834. package/lib/feature-libraries/schema-index/schemaSummarizer.d.ts +1 -9
  835. package/lib/feature-libraries/schema-index/schemaSummarizer.d.ts.map +1 -1
  836. package/lib/feature-libraries/schema-index/schemaSummarizer.js +0 -10
  837. package/lib/feature-libraries/schema-index/schemaSummarizer.js.map +1 -1
  838. package/lib/feature-libraries/schemaChecker.d.ts.map +1 -1
  839. package/lib/feature-libraries/schemaChecker.js +11 -6
  840. package/lib/feature-libraries/schemaChecker.js.map +1 -1
  841. package/lib/feature-libraries/sequence-field/compose.d.ts +6 -7
  842. package/lib/feature-libraries/sequence-field/compose.d.ts.map +1 -1
  843. package/lib/feature-libraries/sequence-field/compose.js +93 -265
  844. package/lib/feature-libraries/sequence-field/compose.js.map +1 -1
  845. package/lib/feature-libraries/sequence-field/helperTypes.d.ts +14 -10
  846. package/lib/feature-libraries/sequence-field/helperTypes.d.ts.map +1 -1
  847. package/lib/feature-libraries/sequence-field/helperTypes.js.map +1 -1
  848. package/lib/feature-libraries/sequence-field/index.d.ts +2 -3
  849. package/lib/feature-libraries/sequence-field/index.d.ts.map +1 -1
  850. package/lib/feature-libraries/sequence-field/index.js +0 -1
  851. package/lib/feature-libraries/sequence-field/index.js.map +1 -1
  852. package/lib/feature-libraries/sequence-field/invert.d.ts +3 -3
  853. package/lib/feature-libraries/sequence-field/invert.d.ts.map +1 -1
  854. package/lib/feature-libraries/sequence-field/invert.js +69 -170
  855. package/lib/feature-libraries/sequence-field/invert.js.map +1 -1
  856. package/lib/feature-libraries/sequence-field/markQueue.d.ts +2 -2
  857. package/lib/feature-libraries/sequence-field/markQueue.d.ts.map +1 -1
  858. package/lib/feature-libraries/sequence-field/markQueue.js.map +1 -1
  859. package/lib/feature-libraries/sequence-field/moveEffectTable.d.ts +4 -56
  860. package/lib/feature-libraries/sequence-field/moveEffectTable.d.ts.map +1 -1
  861. package/lib/feature-libraries/sequence-field/moveEffectTable.js +9 -81
  862. package/lib/feature-libraries/sequence-field/moveEffectTable.js.map +1 -1
  863. package/lib/feature-libraries/sequence-field/rebase.d.ts +3 -3
  864. package/lib/feature-libraries/sequence-field/rebase.d.ts.map +1 -1
  865. package/lib/feature-libraries/sequence-field/rebase.js +122 -121
  866. package/lib/feature-libraries/sequence-field/rebase.js.map +1 -1
  867. package/lib/feature-libraries/sequence-field/replaceRevisions.d.ts +2 -2
  868. package/lib/feature-libraries/sequence-field/replaceRevisions.d.ts.map +1 -1
  869. package/lib/feature-libraries/sequence-field/replaceRevisions.js +36 -44
  870. package/lib/feature-libraries/sequence-field/replaceRevisions.js.map +1 -1
  871. package/lib/feature-libraries/sequence-field/sequenceFieldChangeHandler.d.ts.map +1 -1
  872. package/lib/feature-libraries/sequence-field/sequenceFieldChangeHandler.js +0 -2
  873. package/lib/feature-libraries/sequence-field/sequenceFieldChangeHandler.js.map +1 -1
  874. package/lib/feature-libraries/sequence-field/sequenceFieldCodecV2.d.ts +22 -4
  875. package/lib/feature-libraries/sequence-field/sequenceFieldCodecV2.d.ts.map +1 -1
  876. package/lib/feature-libraries/sequence-field/sequenceFieldCodecV2.js +356 -174
  877. package/lib/feature-libraries/sequence-field/sequenceFieldCodecV2.js.map +1 -1
  878. package/lib/feature-libraries/sequence-field/sequenceFieldCodecV3.d.ts.map +1 -1
  879. package/lib/feature-libraries/sequence-field/sequenceFieldCodecV3.js +21 -61
  880. package/lib/feature-libraries/sequence-field/sequenceFieldCodecV3.js.map +1 -1
  881. package/lib/feature-libraries/sequence-field/sequenceFieldEditor.d.ts +2 -2
  882. package/lib/feature-libraries/sequence-field/sequenceFieldEditor.d.ts.map +1 -1
  883. package/lib/feature-libraries/sequence-field/sequenceFieldEditor.js +10 -10
  884. package/lib/feature-libraries/sequence-field/sequenceFieldEditor.js.map +1 -1
  885. package/lib/feature-libraries/sequence-field/sequenceFieldToDelta.d.ts +3 -2
  886. package/lib/feature-libraries/sequence-field/sequenceFieldToDelta.d.ts.map +1 -1
  887. package/lib/feature-libraries/sequence-field/sequenceFieldToDelta.js +20 -112
  888. package/lib/feature-libraries/sequence-field/sequenceFieldToDelta.js.map +1 -1
  889. package/lib/feature-libraries/sequence-field/types.d.ts +30 -59
  890. package/lib/feature-libraries/sequence-field/types.d.ts.map +1 -1
  891. package/lib/feature-libraries/sequence-field/types.js.map +1 -1
  892. package/lib/feature-libraries/sequence-field/utils.d.ts +15 -24
  893. package/lib/feature-libraries/sequence-field/utils.d.ts.map +1 -1
  894. package/lib/feature-libraries/sequence-field/utils.js +144 -311
  895. package/lib/feature-libraries/sequence-field/utils.js.map +1 -1
  896. package/lib/feature-libraries/treeCursorUtils.js +7 -7
  897. package/lib/feature-libraries/treeCursorUtils.js.map +1 -1
  898. package/lib/feature-libraries/treeTextCursor.js +2 -2
  899. package/lib/feature-libraries/treeTextCursor.js.map +1 -1
  900. package/lib/feature-libraries/valueUtilities.d.ts.map +1 -1
  901. package/lib/feature-libraries/valueUtilities.js +16 -8
  902. package/lib/feature-libraries/valueUtilities.js.map +1 -1
  903. package/lib/index.d.ts +4 -3
  904. package/lib/index.d.ts.map +1 -1
  905. package/lib/index.js +2 -1
  906. package/lib/index.js.map +1 -1
  907. package/lib/packageVersion.d.ts +1 -1
  908. package/lib/packageVersion.d.ts.map +1 -1
  909. package/lib/packageVersion.js +1 -1
  910. package/lib/packageVersion.js.map +1 -1
  911. package/lib/shared-tree/index.d.ts +1 -1
  912. package/lib/shared-tree/index.d.ts.map +1 -1
  913. package/lib/shared-tree/index.js.map +1 -1
  914. package/lib/shared-tree/schematizeTree.d.ts +4 -4
  915. package/lib/shared-tree/schematizeTree.d.ts.map +1 -1
  916. package/lib/shared-tree/schematizeTree.js +3 -2
  917. package/lib/shared-tree/schematizeTree.js.map +1 -1
  918. package/lib/shared-tree/schematizingTreeView.d.ts +3 -8
  919. package/lib/shared-tree/schematizingTreeView.d.ts.map +1 -1
  920. package/lib/shared-tree/schematizingTreeView.js +61 -47
  921. package/lib/shared-tree/schematizingTreeView.js.map +1 -1
  922. package/lib/shared-tree/sharedTree.d.ts +9 -3
  923. package/lib/shared-tree/sharedTree.d.ts.map +1 -1
  924. package/lib/shared-tree/sharedTree.js +41 -13
  925. package/lib/shared-tree/sharedTree.js.map +1 -1
  926. package/lib/shared-tree/sharedTreeChangeCodecs.d.ts +1 -1
  927. package/lib/shared-tree/sharedTreeChangeCodecs.d.ts.map +1 -1
  928. package/lib/shared-tree/sharedTreeChangeCodecs.js +10 -8
  929. package/lib/shared-tree/sharedTreeChangeCodecs.js.map +1 -1
  930. package/lib/shared-tree/sharedTreeChangeEnricher.d.ts.map +1 -1
  931. package/lib/shared-tree/sharedTreeChangeEnricher.js +6 -4
  932. package/lib/shared-tree/sharedTreeChangeEnricher.js.map +1 -1
  933. package/lib/shared-tree/sharedTreeChangeFamily.d.ts +7 -6
  934. package/lib/shared-tree/sharedTreeChangeFamily.d.ts.map +1 -1
  935. package/lib/shared-tree/sharedTreeChangeFamily.js +30 -19
  936. package/lib/shared-tree/sharedTreeChangeFamily.js.map +1 -1
  937. package/lib/shared-tree/sharedTreeEditBuilder.d.ts +16 -6
  938. package/lib/shared-tree/sharedTreeEditBuilder.d.ts.map +1 -1
  939. package/lib/shared-tree/sharedTreeEditBuilder.js +12 -6
  940. package/lib/shared-tree/sharedTreeEditBuilder.js.map +1 -1
  941. package/lib/shared-tree/treeAlpha.d.ts +35 -29
  942. package/lib/shared-tree/treeAlpha.d.ts.map +1 -1
  943. package/lib/shared-tree/treeAlpha.js +21 -23
  944. package/lib/shared-tree/treeAlpha.js.map +1 -1
  945. package/lib/shared-tree/treeCheckout.d.ts +11 -10
  946. package/lib/shared-tree/treeCheckout.d.ts.map +1 -1
  947. package/lib/shared-tree/treeCheckout.js +97 -29
  948. package/lib/shared-tree/treeCheckout.js.map +1 -1
  949. package/lib/shared-tree-core/branch.d.ts +6 -3
  950. package/lib/shared-tree-core/branch.d.ts.map +1 -1
  951. package/lib/shared-tree-core/branch.js +13 -6
  952. package/lib/shared-tree-core/branch.js.map +1 -1
  953. package/lib/shared-tree-core/branchCommitEnricher.d.ts.map +1 -1
  954. package/lib/shared-tree-core/branchCommitEnricher.js +2 -2
  955. package/lib/shared-tree-core/branchCommitEnricher.js.map +1 -1
  956. package/lib/shared-tree-core/editManager.d.ts +2 -2
  957. package/lib/shared-tree-core/editManager.d.ts.map +1 -1
  958. package/lib/shared-tree-core/editManager.js +21 -15
  959. package/lib/shared-tree-core/editManager.js.map +1 -1
  960. package/lib/shared-tree-core/editManagerCodecs.d.ts +4 -0
  961. package/lib/shared-tree-core/editManagerCodecs.d.ts.map +1 -1
  962. package/lib/shared-tree-core/editManagerCodecs.js +16 -4
  963. package/lib/shared-tree-core/editManagerCodecs.js.map +1 -1
  964. package/lib/shared-tree-core/editManagerFormatCommons.d.ts +2 -0
  965. package/lib/shared-tree-core/editManagerFormatCommons.d.ts.map +1 -1
  966. package/lib/shared-tree-core/editManagerFormatCommons.js +12 -0
  967. package/lib/shared-tree-core/editManagerFormatCommons.js.map +1 -1
  968. package/lib/shared-tree-core/editManagerFormatV1toV4.d.ts +2 -2
  969. package/lib/shared-tree-core/editManagerFormatV1toV4.d.ts.map +1 -1
  970. package/lib/shared-tree-core/editManagerFormatV1toV4.js +2 -0
  971. package/lib/shared-tree-core/editManagerFormatV1toV4.js.map +1 -1
  972. package/lib/shared-tree-core/editManagerSummarizer.js +3 -3
  973. package/lib/shared-tree-core/editManagerSummarizer.js.map +1 -1
  974. package/lib/shared-tree-core/index.d.ts +2 -2
  975. package/lib/shared-tree-core/index.d.ts.map +1 -1
  976. package/lib/shared-tree-core/index.js +2 -2
  977. package/lib/shared-tree-core/index.js.map +1 -1
  978. package/lib/shared-tree-core/messageCodecV1ToV4.d.ts +1 -1
  979. package/lib/shared-tree-core/messageCodecV1ToV4.d.ts.map +1 -1
  980. package/lib/shared-tree-core/messageCodecV1ToV4.js.map +1 -1
  981. package/lib/shared-tree-core/messageCodecVSharedBranches.d.ts.map +1 -1
  982. package/lib/shared-tree-core/messageCodecVSharedBranches.js +2 -1
  983. package/lib/shared-tree-core/messageCodecVSharedBranches.js.map +1 -1
  984. package/lib/shared-tree-core/messageCodecs.d.ts +4 -0
  985. package/lib/shared-tree-core/messageCodecs.d.ts.map +1 -1
  986. package/lib/shared-tree-core/messageCodecs.js +15 -4
  987. package/lib/shared-tree-core/messageCodecs.js.map +1 -1
  988. package/lib/shared-tree-core/messageFormat.d.ts +2 -0
  989. package/lib/shared-tree-core/messageFormat.d.ts.map +1 -1
  990. package/lib/shared-tree-core/messageFormat.js +12 -0
  991. package/lib/shared-tree-core/messageFormat.js.map +1 -1
  992. package/lib/shared-tree-core/messageFormatV1ToV4.d.ts +3 -2
  993. package/lib/shared-tree-core/messageFormatV1ToV4.d.ts.map +1 -1
  994. package/lib/shared-tree-core/messageFormatV1ToV4.js +9 -1
  995. package/lib/shared-tree-core/messageFormatV1ToV4.js.map +1 -1
  996. package/lib/shared-tree-core/sequenceIdUtils.d.ts.map +1 -1
  997. package/lib/shared-tree-core/sequenceIdUtils.js +4 -4
  998. package/lib/shared-tree-core/sequenceIdUtils.js.map +1 -1
  999. package/lib/shared-tree-core/sharedTreeCore.d.ts +1 -0
  1000. package/lib/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
  1001. package/lib/shared-tree-core/sharedTreeCore.js +13 -9
  1002. package/lib/shared-tree-core/sharedTreeCore.js.map +1 -1
  1003. package/lib/shared-tree-core/transaction.d.ts +25 -8
  1004. package/lib/shared-tree-core/transaction.d.ts.map +1 -1
  1005. package/lib/shared-tree-core/transaction.js +67 -32
  1006. package/lib/shared-tree-core/transaction.js.map +1 -1
  1007. package/lib/shared-tree-core/transactionEnricher.d.ts +2 -2
  1008. package/lib/shared-tree-core/transactionEnricher.d.ts.map +1 -1
  1009. package/lib/shared-tree-core/transactionEnricher.js +3 -3
  1010. package/lib/shared-tree-core/transactionEnricher.js.map +1 -1
  1011. package/lib/simple-tree/api/configuration.js +1 -1
  1012. package/lib/simple-tree/api/configuration.js.map +1 -1
  1013. package/lib/simple-tree/api/customTree.d.ts.map +1 -1
  1014. package/lib/simple-tree/api/customTree.js +13 -9
  1015. package/lib/simple-tree/api/customTree.js.map +1 -1
  1016. package/lib/simple-tree/api/discrepancies.d.ts.map +1 -1
  1017. package/lib/simple-tree/api/discrepancies.js +21 -17
  1018. package/lib/simple-tree/api/discrepancies.js.map +1 -1
  1019. package/lib/simple-tree/api/index.d.ts +2 -2
  1020. package/lib/simple-tree/api/index.d.ts.map +1 -1
  1021. package/lib/simple-tree/api/index.js +1 -1
  1022. package/lib/simple-tree/api/index.js.map +1 -1
  1023. package/lib/simple-tree/api/schemaFactory.d.ts.map +1 -1
  1024. package/lib/simple-tree/api/schemaFactory.js +12 -8
  1025. package/lib/simple-tree/api/schemaFactory.js.map +1 -1
  1026. package/lib/simple-tree/api/schemaFactoryAlpha.js +1 -1
  1027. package/lib/simple-tree/api/schemaFactoryAlpha.js.map +1 -1
  1028. package/lib/simple-tree/api/schemaFactoryBeta.js +1 -1
  1029. package/lib/simple-tree/api/schemaFactoryBeta.js.map +1 -1
  1030. package/lib/simple-tree/api/schemaFromSimple.js +18 -9
  1031. package/lib/simple-tree/api/schemaFromSimple.js.map +1 -1
  1032. package/lib/simple-tree/api/simpleSchemaCodec.js +10 -5
  1033. package/lib/simple-tree/api/simpleSchemaCodec.js.map +1 -1
  1034. package/lib/simple-tree/api/simpleSchemaToJsonSchema.d.ts.map +1 -1
  1035. package/lib/simple-tree/api/simpleSchemaToJsonSchema.js +19 -15
  1036. package/lib/simple-tree/api/simpleSchemaToJsonSchema.js.map +1 -1
  1037. package/lib/simple-tree/api/simpleTreeIndex.js +10 -10
  1038. package/lib/simple-tree/api/simpleTreeIndex.js.map +1 -1
  1039. package/lib/simple-tree/api/snapshotCompatibilityChecker.d.ts +244 -0
  1040. package/lib/simple-tree/api/snapshotCompatibilityChecker.d.ts.map +1 -1
  1041. package/lib/simple-tree/api/snapshotCompatibilityChecker.js +270 -0
  1042. package/lib/simple-tree/api/snapshotCompatibilityChecker.js.map +1 -1
  1043. package/lib/simple-tree/api/storedSchema.d.ts.map +1 -1
  1044. package/lib/simple-tree/api/storedSchema.js +4 -7
  1045. package/lib/simple-tree/api/storedSchema.js.map +1 -1
  1046. package/lib/simple-tree/api/transactionTypes.d.ts +17 -4
  1047. package/lib/simple-tree/api/transactionTypes.d.ts.map +1 -1
  1048. package/lib/simple-tree/api/transactionTypes.js.map +1 -1
  1049. package/lib/simple-tree/api/tree.d.ts +3 -1
  1050. package/lib/simple-tree/api/tree.d.ts.map +1 -1
  1051. package/lib/simple-tree/api/tree.js.map +1 -1
  1052. package/lib/simple-tree/api/treeNodeApi.d.ts.map +1 -1
  1053. package/lib/simple-tree/api/treeNodeApi.js +21 -13
  1054. package/lib/simple-tree/api/treeNodeApi.js.map +1 -1
  1055. package/lib/simple-tree/api/verboseTree.d.ts.map +1 -1
  1056. package/lib/simple-tree/api/verboseTree.js +14 -9
  1057. package/lib/simple-tree/api/verboseTree.js.map +1 -1
  1058. package/lib/simple-tree/core/treeNodeKernel.d.ts.map +1 -1
  1059. package/lib/simple-tree/core/treeNodeKernel.js +12 -5
  1060. package/lib/simple-tree/core/treeNodeKernel.js.map +1 -1
  1061. package/lib/simple-tree/core/unhydratedFlexTree.d.ts +15 -15
  1062. package/lib/simple-tree/core/unhydratedFlexTree.d.ts.map +1 -1
  1063. package/lib/simple-tree/core/unhydratedFlexTree.js +78 -23
  1064. package/lib/simple-tree/core/unhydratedFlexTree.js.map +1 -1
  1065. package/lib/simple-tree/fieldSchema.d.ts +4 -4
  1066. package/lib/simple-tree/fieldSchema.d.ts.map +1 -1
  1067. package/lib/simple-tree/fieldSchema.js.map +1 -1
  1068. package/lib/simple-tree/getTreeNodeForField.d.ts.map +1 -1
  1069. package/lib/simple-tree/getTreeNodeForField.js +2 -1
  1070. package/lib/simple-tree/getTreeNodeForField.js.map +1 -1
  1071. package/lib/simple-tree/index.d.ts +3 -3
  1072. package/lib/simple-tree/index.d.ts.map +1 -1
  1073. package/lib/simple-tree/index.js +2 -2
  1074. package/lib/simple-tree/index.js.map +1 -1
  1075. package/lib/simple-tree/leafNodeSchema.js +9 -6
  1076. package/lib/simple-tree/leafNodeSchema.js.map +1 -1
  1077. package/lib/simple-tree/node-kinds/array/arrayNode.d.ts.map +1 -1
  1078. package/lib/simple-tree/node-kinds/array/arrayNode.js +23 -21
  1079. package/lib/simple-tree/node-kinds/array/arrayNode.js.map +1 -1
  1080. package/lib/simple-tree/node-kinds/common.d.ts.map +1 -1
  1081. package/lib/simple-tree/node-kinds/common.js +2 -2
  1082. package/lib/simple-tree/node-kinds/common.js.map +1 -1
  1083. package/lib/simple-tree/node-kinds/map/mapNode.js +2 -2
  1084. package/lib/simple-tree/node-kinds/map/mapNode.js.map +1 -1
  1085. package/lib/simple-tree/node-kinds/object/objectNode.d.ts.map +1 -1
  1086. package/lib/simple-tree/node-kinds/object/objectNode.js +22 -23
  1087. package/lib/simple-tree/node-kinds/object/objectNode.js.map +1 -1
  1088. package/lib/simple-tree/node-kinds/record/recordNode.js +6 -5
  1089. package/lib/simple-tree/node-kinds/record/recordNode.js.map +1 -1
  1090. package/lib/simple-tree/prepareForInsertion.d.ts +54 -47
  1091. package/lib/simple-tree/prepareForInsertion.d.ts.map +1 -1
  1092. package/lib/simple-tree/prepareForInsertion.js +184 -125
  1093. package/lib/simple-tree/prepareForInsertion.js.map +1 -1
  1094. package/lib/simple-tree/toStoredSchema.d.ts.map +1 -1
  1095. package/lib/simple-tree/toStoredSchema.js +9 -5
  1096. package/lib/simple-tree/toStoredSchema.js.map +1 -1
  1097. package/lib/simple-tree/unhydratedFlexTreeFromInsertable.d.ts +13 -4
  1098. package/lib/simple-tree/unhydratedFlexTreeFromInsertable.d.ts.map +1 -1
  1099. package/lib/simple-tree/unhydratedFlexTreeFromInsertable.js +28 -11
  1100. package/lib/simple-tree/unhydratedFlexTreeFromInsertable.js.map +1 -1
  1101. package/lib/text/index.d.ts +6 -0
  1102. package/lib/text/index.d.ts.map +1 -0
  1103. package/lib/text/index.js +6 -0
  1104. package/lib/text/index.js.map +1 -0
  1105. package/lib/text/textDomain.d.ts +138 -0
  1106. package/lib/text/textDomain.d.ts.map +1 -0
  1107. package/lib/text/textDomain.js +118 -0
  1108. package/lib/text/textDomain.js.map +1 -0
  1109. package/lib/treeFactory.d.ts.map +1 -1
  1110. package/lib/treeFactory.js +18 -4
  1111. package/lib/treeFactory.js.map +1 -1
  1112. package/lib/util/bTreeUtils.d.ts +12 -4
  1113. package/lib/util/bTreeUtils.d.ts.map +1 -1
  1114. package/lib/util/bTreeUtils.js +16 -20
  1115. package/lib/util/bTreeUtils.js.map +1 -1
  1116. package/lib/util/breakable.js +7 -9
  1117. package/lib/util/breakable.js.map +1 -1
  1118. package/lib/util/idAllocator.d.ts.map +1 -1
  1119. package/lib/util/idAllocator.js +1 -2
  1120. package/lib/util/idAllocator.js.map +1 -1
  1121. package/lib/util/index.d.ts +1 -1
  1122. package/lib/util/index.d.ts.map +1 -1
  1123. package/lib/util/index.js +1 -1
  1124. package/lib/util/index.js.map +1 -1
  1125. package/lib/util/nestedMap.d.ts.map +1 -1
  1126. package/lib/util/nestedMap.js +13 -13
  1127. package/lib/util/nestedMap.js.map +1 -1
  1128. package/lib/util/rangeMap.d.ts +24 -12
  1129. package/lib/util/rangeMap.d.ts.map +1 -1
  1130. package/lib/util/rangeMap.js +44 -5
  1131. package/lib/util/rangeMap.js.map +1 -1
  1132. package/lib/util/utils.d.ts.map +1 -1
  1133. package/lib/util/utils.js +16 -15
  1134. package/lib/util/utils.js.map +1 -1
  1135. package/package.json +33 -33
  1136. package/src/codec/codec.ts +48 -8
  1137. package/src/codec/index.ts +4 -1
  1138. package/src/codec/versioned/codec.ts +340 -22
  1139. package/src/codec/versioned/index.ts +3 -1
  1140. package/src/core/change-family/changeFamily.ts +5 -0
  1141. package/src/core/change-family/index.ts +1 -0
  1142. package/src/core/index.ts +8 -3
  1143. package/src/core/rebase/changeRebaser.ts +46 -7
  1144. package/src/core/rebase/index.ts +4 -1
  1145. package/src/core/rebase/types.ts +71 -39
  1146. package/src/core/rebase/utils.ts +42 -14
  1147. package/src/core/schema-stored/schema.ts +3 -3
  1148. package/src/core/tree/anchorSet.ts +4 -4
  1149. package/src/core/tree/detachedFieldIndex.ts +29 -74
  1150. package/src/core/tree/detachedFieldIndexCodecCommon.ts +4 -8
  1151. package/src/core/tree/detachedFieldIndexCodecV1.ts +3 -7
  1152. package/src/core/tree/detachedFieldIndexCodecV2.ts +5 -9
  1153. package/src/core/tree/detachedFieldIndexCodecs.ts +21 -64
  1154. package/src/core/tree/index.ts +3 -2
  1155. package/src/core/tree/mapTree.ts +1 -1
  1156. package/src/core/tree/pathTree.ts +16 -4
  1157. package/src/core/tree/sparseTree.ts +1 -0
  1158. package/src/core/tree/treeTextFormat.ts +5 -9
  1159. package/src/core/tree/visitDelta.ts +6 -2
  1160. package/src/core/tree/visitorUtils.ts +55 -19
  1161. package/src/feature-libraries/changeAtomIdBTree.ts +56 -0
  1162. package/src/feature-libraries/chunked-forest/basicChunk.ts +8 -2
  1163. package/src/feature-libraries/chunked-forest/chunkTree.ts +6 -1
  1164. package/src/feature-libraries/chunked-forest/chunkedForest.ts +8 -6
  1165. package/src/feature-libraries/chunked-forest/codec/chunkDecoding.ts +7 -4
  1166. package/src/feature-libraries/chunked-forest/codec/codecs.ts +19 -11
  1167. package/src/feature-libraries/chunked-forest/codec/compressedEncode.ts +4 -3
  1168. package/src/feature-libraries/chunked-forest/codec/schemaBasedEncode.ts +9 -5
  1169. package/src/feature-libraries/chunked-forest/uniformChunk.ts +1 -1
  1170. package/src/feature-libraries/default-schema/defaultEditBuilder.ts +442 -139
  1171. package/src/feature-libraries/default-schema/defaultFieldKinds.ts +24 -6
  1172. package/src/feature-libraries/default-schema/index.ts +17 -5
  1173. package/src/feature-libraries/default-schema/locationBasedEditBuilder.ts +188 -0
  1174. package/src/feature-libraries/default-schema/mappedEditBuilder.ts +41 -9
  1175. package/src/feature-libraries/deltaUtils.ts +6 -1
  1176. package/src/feature-libraries/flex-tree/context.ts +17 -0
  1177. package/src/feature-libraries/flex-tree/flexTreeTypes.ts +7 -8
  1178. package/src/feature-libraries/flex-tree/lazyField.ts +72 -30
  1179. package/src/feature-libraries/forest-summary/forestSummarizer.ts +3 -1
  1180. package/src/feature-libraries/index.ts +32 -13
  1181. package/src/feature-libraries/indexing/anchorTreeIndex.ts +5 -5
  1182. package/src/feature-libraries/mapTreeCursor.ts +2 -1
  1183. package/src/feature-libraries/mitigatedChangeFamily.ts +14 -7
  1184. package/src/feature-libraries/modular-schema/comparison.ts +12 -9
  1185. package/src/feature-libraries/modular-schema/crossFieldQueries.ts +142 -44
  1186. package/src/feature-libraries/modular-schema/defaultRevisionReplacer.ts +70 -0
  1187. package/src/feature-libraries/modular-schema/fieldChangeHandler.ts +35 -64
  1188. package/src/feature-libraries/modular-schema/genericFieldKind.ts +11 -25
  1189. package/src/feature-libraries/modular-schema/genericFieldKindCodecs.ts +1 -1
  1190. package/src/feature-libraries/modular-schema/index.ts +20 -16
  1191. package/src/feature-libraries/modular-schema/modularChangeCodecV1.ts +912 -0
  1192. package/src/feature-libraries/modular-schema/modularChangeCodecV2.ts +89 -0
  1193. package/src/feature-libraries/modular-schema/modularChangeCodecV3.ts +760 -0
  1194. package/src/feature-libraries/modular-schema/modularChangeCodecs.ts +52 -523
  1195. package/src/feature-libraries/modular-schema/modularChangeFamily.ts +2756 -884
  1196. package/src/feature-libraries/modular-schema/{modularChangeFormat.ts → modularChangeFormatV1.ts} +5 -4
  1197. package/src/feature-libraries/modular-schema/modularChangeFormatV2.ts +34 -0
  1198. package/src/feature-libraries/modular-schema/modularChangeFormatV3.ts +62 -0
  1199. package/src/feature-libraries/modular-schema/modularChangeTypes.ts +70 -14
  1200. package/src/feature-libraries/node-identifier/mockNodeIdentifierManager.ts +1 -1
  1201. package/src/feature-libraries/object-forest/objectForest.ts +7 -5
  1202. package/src/feature-libraries/optional-field/index.ts +1 -3
  1203. package/src/feature-libraries/optional-field/optionalField.ts +320 -576
  1204. package/src/feature-libraries/optional-field/optionalFieldChangeFormatV3.ts +45 -0
  1205. package/src/feature-libraries/optional-field/optionalFieldChangeTypes.ts +24 -38
  1206. package/src/feature-libraries/optional-field/optionalFieldCodecV2.ts +89 -35
  1207. package/src/feature-libraries/optional-field/optionalFieldCodecV3.ts +94 -0
  1208. package/src/feature-libraries/optional-field/optionalFieldCodecs.ts +5 -1
  1209. package/src/feature-libraries/schema-edits/schemaChangeCodecs.ts +18 -3
  1210. package/src/feature-libraries/schema-index/codec.ts +30 -90
  1211. package/src/feature-libraries/schema-index/index.ts +2 -4
  1212. package/src/feature-libraries/schema-index/schemaSummarizer.ts +0 -17
  1213. package/src/feature-libraries/schemaChecker.ts +11 -6
  1214. package/src/feature-libraries/sequence-field/compose.ts +147 -526
  1215. package/src/feature-libraries/sequence-field/helperTypes.ts +34 -19
  1216. package/src/feature-libraries/sequence-field/index.ts +0 -9
  1217. package/src/feature-libraries/sequence-field/invert.ts +103 -227
  1218. package/src/feature-libraries/sequence-field/markQueue.ts +2 -2
  1219. package/src/feature-libraries/sequence-field/moveEffectTable.ts +11 -192
  1220. package/src/feature-libraries/sequence-field/rebase.ts +182 -210
  1221. package/src/feature-libraries/sequence-field/replaceRevisions.ts +54 -80
  1222. package/src/feature-libraries/sequence-field/sequenceFieldChangeHandler.ts +0 -2
  1223. package/src/feature-libraries/sequence-field/sequenceFieldCodecV2.ts +648 -220
  1224. package/src/feature-libraries/sequence-field/sequenceFieldCodecV3.ts +56 -68
  1225. package/src/feature-libraries/sequence-field/sequenceFieldEditor.ts +25 -27
  1226. package/src/feature-libraries/sequence-field/sequenceFieldToDelta.ts +25 -132
  1227. package/src/feature-libraries/sequence-field/types.ts +34 -64
  1228. package/src/feature-libraries/sequence-field/utils.ts +171 -366
  1229. package/src/feature-libraries/treeCursorUtils.ts +7 -7
  1230. package/src/feature-libraries/treeTextCursor.ts +2 -2
  1231. package/src/feature-libraries/valueUtilities.ts +16 -8
  1232. package/src/index.ts +11 -0
  1233. package/src/packageVersion.ts +1 -1
  1234. package/src/shared-tree/index.ts +3 -2
  1235. package/src/shared-tree/schematizeTree.ts +21 -8
  1236. package/src/shared-tree/schematizingTreeView.ts +79 -83
  1237. package/src/shared-tree/sharedTree.ts +50 -17
  1238. package/src/shared-tree/sharedTreeChangeCodecs.ts +14 -9
  1239. package/src/shared-tree/sharedTreeChangeEnricher.ts +6 -2
  1240. package/src/shared-tree/sharedTreeChangeFamily.ts +44 -24
  1241. package/src/shared-tree/sharedTreeEditBuilder.ts +48 -13
  1242. package/src/shared-tree/treeAlpha.ts +60 -51
  1243. package/src/shared-tree/treeCheckout.ts +160 -73
  1244. package/src/shared-tree-core/branch.ts +21 -6
  1245. package/src/shared-tree-core/branchCommitEnricher.ts +3 -8
  1246. package/src/shared-tree-core/editManager.ts +43 -29
  1247. package/src/shared-tree-core/editManagerCodecs.ts +19 -4
  1248. package/src/shared-tree-core/editManagerFormatCommons.ts +12 -0
  1249. package/src/shared-tree-core/editManagerFormatV1toV4.ts +5 -1
  1250. package/src/shared-tree-core/editManagerSummarizer.ts +3 -3
  1251. package/src/shared-tree-core/index.ts +2 -0
  1252. package/src/shared-tree-core/messageCodecV1ToV4.ts +3 -1
  1253. package/src/shared-tree-core/messageCodecVSharedBranches.ts +2 -1
  1254. package/src/shared-tree-core/messageCodecs.ts +18 -4
  1255. package/src/shared-tree-core/messageFormat.ts +12 -1
  1256. package/src/shared-tree-core/messageFormatV1ToV4.ts +18 -2
  1257. package/src/shared-tree-core/sequenceIdUtils.ts +4 -4
  1258. package/src/shared-tree-core/sharedTreeCore.ts +15 -8
  1259. package/src/shared-tree-core/transaction.ts +115 -56
  1260. package/src/shared-tree-core/transactionEnricher.ts +5 -6
  1261. package/src/simple-tree/api/configuration.ts +1 -1
  1262. package/src/simple-tree/api/customTree.ts +14 -10
  1263. package/src/simple-tree/api/discrepancies.ts +23 -17
  1264. package/src/simple-tree/api/index.ts +5 -0
  1265. package/src/simple-tree/api/schemaFactory.ts +11 -7
  1266. package/src/simple-tree/api/schemaFactoryAlpha.ts +1 -1
  1267. package/src/simple-tree/api/schemaFactoryBeta.ts +1 -1
  1268. package/src/simple-tree/api/schemaFromSimple.ts +18 -9
  1269. package/src/simple-tree/api/simpleSchemaCodec.ts +10 -5
  1270. package/src/simple-tree/api/simpleSchemaToJsonSchema.ts +21 -17
  1271. package/src/simple-tree/api/simpleTreeIndex.ts +8 -8
  1272. package/src/simple-tree/api/snapshotCompatibilityChecker.ts +501 -0
  1273. package/src/simple-tree/api/storedSchema.ts +10 -7
  1274. package/src/simple-tree/api/transactionTypes.ts +19 -4
  1275. package/src/simple-tree/api/tree.ts +3 -1
  1276. package/src/simple-tree/api/treeNodeApi.ts +21 -13
  1277. package/src/simple-tree/api/verboseTree.ts +14 -9
  1278. package/src/simple-tree/core/treeNodeKernel.ts +12 -5
  1279. package/src/simple-tree/core/unhydratedFlexTree.ts +109 -53
  1280. package/src/simple-tree/fieldSchema.ts +6 -4
  1281. package/src/simple-tree/getTreeNodeForField.ts +2 -1
  1282. package/src/simple-tree/index.ts +7 -1
  1283. package/src/simple-tree/leafNodeSchema.ts +8 -5
  1284. package/src/simple-tree/node-kinds/array/arrayNode.ts +32 -30
  1285. package/src/simple-tree/node-kinds/common.ts +2 -5
  1286. package/src/simple-tree/node-kinds/map/mapNode.ts +4 -4
  1287. package/src/simple-tree/node-kinds/object/objectNode.ts +29 -30
  1288. package/src/simple-tree/node-kinds/record/recordNode.ts +12 -12
  1289. package/src/simple-tree/prepareForInsertion.ts +343 -201
  1290. package/src/simple-tree/toStoredSchema.ts +9 -5
  1291. package/src/simple-tree/unhydratedFlexTreeFromInsertable.ts +43 -15
  1292. package/src/text/README.md +8 -0
  1293. package/src/text/index.ts +6 -0
  1294. package/src/text/textDomain.ts +199 -0
  1295. package/src/treeFactory.ts +20 -5
  1296. package/src/util/bTreeUtils.ts +34 -23
  1297. package/src/util/breakable.ts +9 -9
  1298. package/src/util/idAllocator.ts +1 -2
  1299. package/src/util/index.ts +3 -0
  1300. package/src/util/nestedMap.ts +13 -15
  1301. package/src/util/rangeMap.ts +72 -18
  1302. package/src/util/utils.ts +14 -13
  1303. package/.eslintrc.cjs +0 -140
  1304. package/assertTagging.config.mjs +0 -14
  1305. package/dist/feature-libraries/modular-schema/modularChangeFormat.d.ts.map +0 -1
  1306. package/dist/feature-libraries/modular-schema/modularChangeFormat.js.map +0 -1
  1307. package/dist/feature-libraries/sequence-field/relevantRemovedRoots.d.ts +0 -9
  1308. package/dist/feature-libraries/sequence-field/relevantRemovedRoots.d.ts.map +0 -1
  1309. package/dist/feature-libraries/sequence-field/relevantRemovedRoots.js +0 -50
  1310. package/dist/feature-libraries/sequence-field/relevantRemovedRoots.js.map +0 -1
  1311. package/docs/main/sequence-field/move-composition.md +0 -46
  1312. package/lib/feature-libraries/modular-schema/modularChangeFormat.d.ts.map +0 -1
  1313. package/lib/feature-libraries/modular-schema/modularChangeFormat.js.map +0 -1
  1314. package/lib/feature-libraries/sequence-field/relevantRemovedRoots.d.ts +0 -9
  1315. package/lib/feature-libraries/sequence-field/relevantRemovedRoots.d.ts.map +0 -1
  1316. package/lib/feature-libraries/sequence-field/relevantRemovedRoots.js +0 -46
  1317. package/lib/feature-libraries/sequence-field/relevantRemovedRoots.js.map +0 -1
  1318. package/src/feature-libraries/sequence-field/relevantRemovedRoots.ts +0 -57
@@ -12,8 +12,7 @@ function idAllocatorFromMaxId(maxId = undefined) {
12
12
  exports.idAllocatorFromMaxId = idAllocatorFromMaxId;
13
13
  function idAllocatorFromState(state) {
14
14
  return {
15
- allocate: (c) => {
16
- const count = c ?? 1;
15
+ allocate: (count = 1) => {
17
16
  (0, internal_1.assert)(count > 0, 0x5cf /* Must allocate at least one ID */);
18
17
  const id = state.maxId + 1;
19
18
  state.maxId += count;
@@ -1 +1 @@
1
- {"version":3,"file":"idAllocator.js","sourceRoot":"","sources":["../../src/util/idAllocator.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAAmE;AAqBnE,SAAgB,oBAAoB,CAAC,QAA4B,SAAS;IACzE,OAAO,oBAAoB,CAAC,EAAE,KAAK,EAAE,KAAK,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC;AACrD,CAAC;AAFD,oDAEC;AAED,SAAgB,oBAAoB,CAAC,KAAwB;IAC5D,OAAO;QACN,QAAQ,EAAE,CAAC,CAAU,EAAU,EAAE;YAChC,MAAM,KAAK,GAAG,CAAC,IAAI,CAAC,CAAC;YACrB,IAAA,iBAAM,EAAC,KAAK,GAAG,CAAC,EAAE,KAAK,CAAC,mCAAmC,CAAC,CAAC;YAC7D,MAAM,EAAE,GAAW,KAAK,CAAC,KAAK,GAAG,CAAC,CAAC;YACnC,KAAK,CAAC,KAAK,IAAI,KAAK,CAAC;YACrB,OAAO,EAAE,CAAC;QACX,CAAC;QACD,QAAQ,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC,KAAK;KAC3B,CAAC;AACH,CAAC;AAXD,oDAWC;AAEY,QAAA,eAAe,GAAgB;IAC3C,QAAQ,EAAE,GAAG,EAAE,CAAC,IAAA,eAAI,EAAC,KAAK,CAAC,6BAA6B,CAAC;IACzD,QAAQ,EAAE,GAAG,EAAE,CAAC,CAAC;CACjB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, fail } from \"@fluidframework/core-utils/internal\";\n\n/**\n * Used for allocating IDs unique to a particular instance of the allocator.\n */\nexport interface IdAllocator<TId = number> {\n\t/**\n\t * Allocates a block of `count` consecutive IDs and returns the first ID in the block.\n\t * For convenience can be called with no parameters to allocate a single ID.\n\t */\n\tallocate: (count?: number) => TId;\n\t/**\n\t * @returns The maximum ID that was generated by this allocator.\n\t */\n\tgetMaxId: () => TId;\n}\n\nexport interface IdAllocationState {\n\tmaxId: number;\n}\n\nexport function idAllocatorFromMaxId(maxId: number | undefined = undefined): IdAllocator {\n\treturn idAllocatorFromState({ maxId: maxId ?? -1 });\n}\n\nexport function idAllocatorFromState(state: IdAllocationState): IdAllocator {\n\treturn {\n\t\tallocate: (c?: number): number => {\n\t\t\tconst count = c ?? 1;\n\t\t\tassert(count > 0, 0x5cf /* Must allocate at least one ID */);\n\t\t\tconst id: number = state.maxId + 1;\n\t\t\tstate.maxId += count;\n\t\t\treturn id;\n\t\t},\n\t\tgetMaxId: () => state.maxId,\n\t};\n}\n\nexport const fakeIdAllocator: IdAllocator = {\n\tallocate: () => fail(0xae6 /* Should not allocate IDs */),\n\tgetMaxId: () => 0,\n};\n"]}
1
+ {"version":3,"file":"idAllocator.js","sourceRoot":"","sources":["../../src/util/idAllocator.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAAmE;AAqBnE,SAAgB,oBAAoB,CAAC,QAA4B,SAAS;IACzE,OAAO,oBAAoB,CAAC,EAAE,KAAK,EAAE,KAAK,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC;AACrD,CAAC;AAFD,oDAEC;AAED,SAAgB,oBAAoB,CAAC,KAAwB;IAC5D,OAAO;QACN,QAAQ,EAAE,CAAC,QAAgB,CAAC,EAAU,EAAE;YACvC,IAAA,iBAAM,EAAC,KAAK,GAAG,CAAC,EAAE,KAAK,CAAC,mCAAmC,CAAC,CAAC;YAC7D,MAAM,EAAE,GAAW,KAAK,CAAC,KAAK,GAAG,CAAC,CAAC;YACnC,KAAK,CAAC,KAAK,IAAI,KAAK,CAAC;YACrB,OAAO,EAAE,CAAC;QACX,CAAC;QACD,QAAQ,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC,KAAK;KAC3B,CAAC;AACH,CAAC;AAVD,oDAUC;AAEY,QAAA,eAAe,GAAgB;IAC3C,QAAQ,EAAE,GAAG,EAAE,CAAC,IAAA,eAAI,EAAC,KAAK,CAAC,6BAA6B,CAAC;IACzD,QAAQ,EAAE,GAAG,EAAE,CAAC,CAAC;CACjB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, fail } from \"@fluidframework/core-utils/internal\";\n\n/**\n * Used for allocating IDs unique to a particular instance of the allocator.\n */\nexport interface IdAllocator<TId = number> {\n\t/**\n\t * Allocates a block of `count` consecutive IDs and returns the first ID in the block.\n\t * For convenience can be called with no parameters to allocate a single ID.\n\t */\n\tallocate: (count?: number) => TId;\n\t/**\n\t * @returns The maximum ID that was generated by this allocator.\n\t */\n\tgetMaxId: () => TId;\n}\n\nexport interface IdAllocationState {\n\tmaxId: number;\n}\n\nexport function idAllocatorFromMaxId(maxId: number | undefined = undefined): IdAllocator {\n\treturn idAllocatorFromState({ maxId: maxId ?? -1 });\n}\n\nexport function idAllocatorFromState(state: IdAllocationState): IdAllocator {\n\treturn {\n\t\tallocate: (count: number = 1): number => {\n\t\t\tassert(count > 0, 0x5cf /* Must allocate at least one ID */);\n\t\t\tconst id: number = state.maxId + 1;\n\t\t\tstate.maxId += count;\n\t\t\treturn id;\n\t\t},\n\t\tgetMaxId: () => state.maxId,\n\t};\n}\n\nexport const fakeIdAllocator: IdAllocator = {\n\tallocate: () => fail(0xae6 /* Should not allocate IDs */),\n\tgetMaxId: () => 0,\n};\n"]}
@@ -16,7 +16,7 @@ export { ReferenceCountedBase, type ReferenceCounted } from "./referenceCounting
16
16
  export type { _RecursiveTrick, RestrictiveReadonlyRecord, RestrictiveStringRecord, _InlineTrick, FlattenKeys, IsUnion, UnionToIntersection, UnionToTuple, PopUnion, } from "./typeUtils.js";
17
17
  export { unsafeArrayToTuple } from "./typeUtils.js";
18
18
  export { type BrandedKey, type BrandedKeyContent, type BrandedMapSubset, getOrCreateSlotContent, brandedSlot, } from "./brandedMap.js";
19
- export { RangeMap, type RangeQueryResult, newIntegerRangeMap, } from "./rangeMap.js";
19
+ export { RangeMap, type RangeQueryResult, type RangeQueryResultFragment, type RangeQueryEntry, newIntegerRangeMap, areAdjacentIntegerRanges, } from "./rangeMap.js";
20
20
  export { type IdAllocator, idAllocatorFromMaxId, idAllocatorFromState, type IdAllocationState, fakeIdAllocator, } from "./idAllocator.js";
21
21
  export { Breakable, type WithBreakable, breakingMethod, throwIfBroken, breakingClass, } from "./breakable.js";
22
22
  export { type TupleBTree, newTupleBTree, mergeTupleBTrees } from "./bTreeUtils.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/util/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,aAAa,EACb,kBAAkB,EAClB,qBAAqB,EACrB,mBAAmB,GACnB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACN,KAAK,EACL,KAAK,KAAK,EACV,WAAW,EACX,KAAK,eAAe,EACpB,KAAK,gBAAgB,EACrB,UAAU,EACV,KAAK,MAAM,EACX,UAAU,EACV,OAAO,GACP,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACzE,OAAO,EACN,WAAW,EACX,iBAAiB,EACjB,KAAK,iBAAiB,EACtB,KAAK,MAAM,GACX,MAAM,aAAa,CAAC;AACrB,OAAO,EACN,mBAAmB,EACnB,mBAAmB,EACnB,uBAAuB,EACvB,kBAAkB,EAClB,KAAK,SAAS,EACd,KAAK,iBAAiB,EACtB,cAAc,EACd,iBAAiB,EACjB,cAAc,EACd,iBAAiB,EACjB,mBAAmB,EACnB,YAAY,EACZ,mBAAmB,EACnB,qBAAqB,EACrB,sBAAsB,GACtB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,cAAc,EAAE,KAAK,SAAS,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACnF,OAAO,EAAE,KAAK,UAAU,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACrE,YAAY,EACX,mBAAmB,EACnB,aAAa,EACb,SAAS,EACT,WAAW,EACX,qBAAqB,EACrB,SAAS,EACT,KAAK,EACL,cAAc,EACd,cAAc,EACd,WAAW,EACX,YAAY,EACZ,WAAW,EACX,mBAAmB,EACnB,WAAW,GACX,MAAM,gBAAgB,CAAC;AACxB,OAAO,E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,kBAAkB,CAAC;AAE1B,OAAO,EACN,SAAS,EACT,KAAK,aAAa,EAClB,cAAc,EACd,aAAa,EACb,aAAa,GACb,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAAE,KAAK,UAAU,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAEnF,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAEnE,OAAO,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/util/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,aAAa,EACb,kBAAkB,EAClB,qBAAqB,EACrB,mBAAmB,GACnB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACN,KAAK,EACL,KAAK,KAAK,EACV,WAAW,EACX,KAAK,eAAe,EACpB,KAAK,gBAAgB,EACrB,UAAU,EACV,KAAK,MAAM,EACX,UAAU,EACV,OAAO,GACP,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACzE,OAAO,EACN,WAAW,EACX,iBAAiB,EACjB,KAAK,iBAAiB,EACtB,KAAK,MAAM,GACX,MAAM,aAAa,CAAC;AACrB,OAAO,EACN,mBAAmB,EACnB,mBAAmB,EACnB,uBAAuB,EACvB,kBAAkB,EAClB,KAAK,SAAS,EACd,KAAK,iBAAiB,EACtB,cAAc,EACd,iBAAiB,EACjB,cAAc,EACd,iBAAiB,EACjB,mBAAmB,EACnB,YAAY,EACZ,mBAAmB,EACnB,qBAAqB,EACrB,sBAAsB,GACtB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,cAAc,EAAE,KAAK,SAAS,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACnF,OAAO,EAAE,KAAK,UAAU,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACrE,YAAY,EAC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,iBAAiB,CAAC;AAEzB,OAAO,EACN,QAAQ,EACR,KAAK,gBAAgB,EACrB,KAAK,wBAAwB,EAC7B,KAAK,eAAe,EACpB,kBAAkB,EAClB,wBAAwB,GACxB,MAAM,eAAe,CAAC;AAEvB,OAAO,EACN,KAAK,WAAW,EAChB,oBAAoB,EACpB,oBAAoB,EACpB,KAAK,iBAAiB,EACtB,eAAe,GACf,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EACN,SAAS,EACT,KAAK,aAAa,EAClB,cAAc,EACd,aAAa,EACb,aAAa,GACb,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAAE,KAAK,UAAU,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAEnF,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAEnE,OAAO,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAC"}
@@ -5,7 +5,7 @@
5
5
  */
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
7
  exports.disposeSymbol = exports.compareNamed = exports.oneFromIterable = exports.invertMap = exports.objectToMap = exports.assertNonNegativeSafeInteger = exports.assertValidRange = exports.assertValidIndex = exports.filterIterable = exports.mapIterable = exports.makeArray = exports.JsonCompatibleReadOnlySchema = exports.isReadonlyArray = exports.isJsonObject = exports.getOrCreate = exports.getOrAddEmptyToMap = exports.compareSets = exports.clone = exports.balancedReduce = exports.asMutable = exports.StackyIterator = exports.OffsetListFactory = exports.nestedSetContains = exports.addToNestedSet = exports.getOrCreateInNestedMap = exports.nestedMapFromFlatList = exports.nestedMapToFlatList = exports.mapNestedMap = exports.tryGetFromNestedMap = exports.tryAddToNestedMap = exports.setInNestedMap = exports.populateNestedMap = exports.SizedNestedMap = exports.forEachInNestedMap = exports.getOrDefaultInNestedMap = exports.getOrAddInNestedMap = exports.deleteFromNestedMap = exports.extractFromOpaque = exports.brandOpaque = exports.brandedStringType = exports.brandedNumberType = exports.unbrand = exports.strictEnum = exports.brandConst = exports.BrandedType = exports.brand = exports.validateSafeInteger = exports.validatePositiveIndex = exports.validateIndexRange = exports.validateIndex = void 0;
8
- exports.readAndParseSnapshotBlob = exports.cloneWithReplacements = exports.mergeTupleBTrees = exports.newTupleBTree = exports.breakingClass = exports.throwIfBroken = exports.breakingMethod = exports.Breakable = exports.fakeIdAllocator = exports.idAllocatorFromState = exports.idAllocatorFromMaxId = exports.newIntegerRangeMap = exports.RangeMap = exports.brandedSlot = exports.getOrCreateSlotContent = exports.unsafeArrayToTuple = exports.ReferenceCountedBase = exports.iterableHasSome = exports.getOrAddInMap = exports.copyProperty = exports.defineLazyCachedProperty = exports.hasSingle = exports.hasSome = exports.getLast = exports.count = exports.find = exports.compareStrings = exports.transformObjectMap = exports.assertValidRangeIndices = exports.capitalize = void 0;
8
+ exports.readAndParseSnapshotBlob = exports.cloneWithReplacements = exports.mergeTupleBTrees = exports.newTupleBTree = exports.breakingClass = exports.throwIfBroken = exports.breakingMethod = exports.Breakable = exports.fakeIdAllocator = exports.idAllocatorFromState = exports.idAllocatorFromMaxId = exports.areAdjacentIntegerRanges = exports.newIntegerRangeMap = exports.RangeMap = exports.brandedSlot = exports.getOrCreateSlotContent = exports.unsafeArrayToTuple = exports.ReferenceCountedBase = exports.iterableHasSome = exports.getOrAddInMap = exports.copyProperty = exports.defineLazyCachedProperty = exports.hasSingle = exports.hasSome = exports.getLast = exports.count = exports.find = exports.compareStrings = exports.transformObjectMap = exports.assertValidRangeIndices = exports.capitalize = void 0;
9
9
  var arrayUtilities_js_1 = require("./arrayUtilities.js");
10
10
  Object.defineProperty(exports, "validateIndex", { enumerable: true, get: function () { return arrayUtilities_js_1.validateIndex; } });
11
11
  Object.defineProperty(exports, "validateIndexRange", { enumerable: true, get: function () { return arrayUtilities_js_1.validateIndexRange; } });
@@ -88,6 +88,7 @@ Object.defineProperty(exports, "brandedSlot", { enumerable: true, get: function
88
88
  var rangeMap_js_1 = require("./rangeMap.js");
89
89
  Object.defineProperty(exports, "RangeMap", { enumerable: true, get: function () { return rangeMap_js_1.RangeMap; } });
90
90
  Object.defineProperty(exports, "newIntegerRangeMap", { enumerable: true, get: function () { return rangeMap_js_1.newIntegerRangeMap; } });
91
+ Object.defineProperty(exports, "areAdjacentIntegerRanges", { enumerable: true, get: function () { return rangeMap_js_1.areAdjacentIntegerRanges; } });
91
92
  var idAllocator_js_1 = require("./idAllocator.js");
92
93
  Object.defineProperty(exports, "idAllocatorFromMaxId", { enumerable: true, get: function () { return idAllocator_js_1.idAllocatorFromMaxId; } });
93
94
  Object.defineProperty(exports, "idAllocatorFromState", { enumerable: true, get: function () { return idAllocator_js_1.idAllocatorFromState; } });
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/util/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;AAEH,yDAK6B;AAJ5B,kHAAA,aAAa,OAAA;AACb,uHAAA,kBAAkB,OAAA;AAClB,0HAAA,qBAAqB,OAAA;AACrB,wHAAA,mBAAmB,OAAA;AAEpB,uCAUoB;AATnB,iGAAA,KAAK,OAAA;AAEL,uGAAA,WAAW,OAAA;AAGX,sGAAA,UAAU,OAAA;AAEV,sGAAA,UAAU,OAAA;AACV,mGAAA,OAAO,OAAA;AAER,qDAAyE;AAAhE,oHAAA,iBAAiB,OAAA;AAAE,oHAAA,iBAAiB,OAAA;AAC7C,yCAKqB;AAJpB,wGAAA,WAAW,OAAA;AACX,8GAAA,iBAAiB,OAAA;AAIlB,+CAgBwB;AAfvB,mHAAA,mBAAmB,OAAA;AACnB,mHAAA,mBAAmB,OAAA;AACnB,uHAAA,uBAAuB,OAAA;AACvB,kHAAA,kBAAkB,OAAA;AAGlB,8GAAA,cAAc,OAAA;AACd,iHAAA,iBAAiB,OAAA;AACjB,8GAAA,cAAc,OAAA;AACd,iHAAA,iBAAiB,OAAA;AACjB,mHAAA,mBAAmB,OAAA;AACnB,4GAAA,YAAY,OAAA;AACZ,mHAAA,mBAAmB,OAAA;AACnB,q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AIuB;AAHtB,uGAAA,QAAQ,OAAA;AAER,iHAAA,kBAAkB,OAAA;AAGnB,mDAM0B;AAJzB,sHAAA,oBAAoB,OAAA;AACpB,sHAAA,oBAAoB,OAAA;AAEpB,iHAAA,eAAe,OAAA;AAGhB,+CAMwB;AALvB,yGAAA,SAAS,OAAA;AAET,8GAAA,cAAc,OAAA;AACd,6GAAA,aAAa,OAAA;AACb,6GAAA,aAAa,OAAA;AAGd,iDAAmF;AAAzD,8GAAA,aAAa,OAAA;AAAE,iHAAA,gBAAgB,OAAA;AAEzD,uEAAmE;AAA1D,iIAAA,qBAAqB,OAAA;AAE9B,6DAAiE;AAAxD,+HAAA,wBAAwB,OAAA","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport {\n\tvalidateIndex,\n\tvalidateIndexRange,\n\tvalidatePositiveIndex,\n\tvalidateSafeInteger,\n} from \"./arrayUtilities.js\";\nexport {\n\tbrand,\n\ttype Brand,\n\tBrandedType,\n\ttype NameFromBranded,\n\ttype ValueFromBranded,\n\tbrandConst,\n\ttype Values,\n\tstrictEnum,\n\tunbrand,\n} from \"./brand.js\";\nexport { brandedNumberType, brandedStringType } from \"./typeboxBrand.js\";\nexport {\n\tbrandOpaque,\n\textractFromOpaque,\n\ttype ExtractFromOpaque,\n\ttype Opaque,\n} from \"./opaque.js\";\nexport {\n\tdeleteFromNestedMap,\n\tgetOrAddInNestedMap,\n\tgetOrDefaultInNestedMap,\n\tforEachInNestedMap,\n\ttype NestedMap,\n\ttype ReadonlyNestedMap,\n\tSizedNestedMap,\n\tpopulateNestedMap,\n\tsetInNestedMap,\n\ttryAddToNestedMap,\n\ttryGetFromNestedMap,\n\tmapNestedMap,\n\tnestedMapToFlatList,\n\tnestedMapFromFlatList,\n\tgetOrCreateInNestedMap,\n} from \"./nestedMap.js\";\nexport { addToNestedSet, type NestedSet, nestedSetContains } from \"./nestedSet.js\";\nexport { type OffsetList, OffsetListFactory } from \"./offsetList.js\";\nexport type {\n\tareSafelyAssignable,\n\tContravariant,\n\tCovariant,\n\teitherIsAny,\n\tEnforceTypeCheckTests,\n\tInvariant,\n\tisAny,\n\tisAssignableTo,\n\tisStrictSubset,\n\tMakeNominal,\n\trequireFalse,\n\trequireTrue,\n\trequireAssignableTo,\n\tareOnlyKeys,\n} from \"./typeCheck.js\";\nexport { StackyIterator } from \"./stackyIterator.js\";\nexport {\n\tasMutable,\n\tbalancedReduce,\n\tclone,\n\tcompareSets,\n\tgetOrAddEmptyToMap,\n\tgetOrCreate,\n\tisJsonObject,\n\tisReadonlyArray,\n\ttype JsonCompatible,\n\ttype JsonCompatibleObject,\n\ttype JsonCompatibleReadOnly,\n\ttype JsonCompatibleReadOnlyObject,\n\tJsonCompatibleReadOnlySchema,\n\tmakeArray,\n\tmapIterable,\n\tfilterIterable,\n\ttype Mutable,\n\ttype Populated,\n\ttype RecursiveReadonly,\n\tassertValidIndex,\n\tassertValidRange,\n\tassertNonNegativeSafeInteger,\n\tobjectToMap,\n\tinvertMap,\n\toneFromIterable,\n\ttype Named,\n\tcompareNamed,\n\tdisposeSymbol,\n\ttype IDisposable,\n\tcapitalize,\n\tassertValidRangeIndices,\n\ttransformObjectMap,\n\tcompareStrings,\n\tfind,\n\tcount,\n\tgetLast,\n\thasSome,\n\thasSingle,\n\tdefineLazyCachedProperty,\n\tcopyPropertyIfDefined as copyProperty,\n\tgetOrAddInMap,\n\titerableHasSome,\n} from \"./utils.js\";\nexport { ReferenceCountedBase, type ReferenceCounted } from \"./referenceCounting.js\";\n\nexport type {\n\t_RecursiveTrick,\n\tRestrictiveReadonlyRecord,\n\tRestrictiveStringRecord,\n\t_InlineTrick,\n\tFlattenKeys,\n\tIsUnion,\n\tUnionToIntersection,\n\tUnionToTuple,\n\tPopUnion,\n} from \"./typeUtils.js\";\n\nexport { unsafeArrayToTuple } from \"./typeUtils.js\";\n\nexport {\n\ttype BrandedKey,\n\ttype BrandedKeyContent,\n\ttype BrandedMapSubset,\n\tgetOrCreateSlotContent,\n\tbrandedSlot,\n} from \"./brandedMap.js\";\n\nexport {\n\tRangeMap,\n\ttype RangeQueryResult,\n\tnewIntegerRangeMap,\n} from \"./rangeMap.js\";\n\nexport {\n\ttype IdAllocator,\n\tidAllocatorFromMaxId,\n\tidAllocatorFromState,\n\ttype IdAllocationState,\n\tfakeIdAllocator,\n} from \"./idAllocator.js\";\n\nexport {\n\tBreakable,\n\ttype WithBreakable,\n\tbreakingMethod,\n\tthrowIfBroken,\n\tbreakingClass,\n} from \"./breakable.js\";\n\nexport { type TupleBTree, newTupleBTree, mergeTupleBTrees } from \"./bTreeUtils.js\";\n\nexport { cloneWithReplacements } from \"./cloneWithReplacements.js\";\n\nexport { readAndParseSnapshotBlob } from \"./readSnapshotBlob.js\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/util/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;AAEH,yDAK6B;AAJ5B,kHAAA,aAAa,OAAA;AACb,uHAAA,kBAAkB,OAAA;AAClB,0HAAA,qBAAqB,OAAA;AACrB,wHAAA,mBAAmB,OAAA;AAEpB,uCAUoB;AATnB,iGAAA,KAAK,OAAA;AAEL,uGAAA,WAAW,OAAA;AAGX,sGAAA,UAAU,OAAA;AAEV,sGAAA,UAAU,OAAA;AACV,mGAAA,OAAO,OAAA;AAER,qDAAyE;AAAhE,oHAAA,iBAAiB,OAAA;AAAE,oHAAA,iBAAiB,OAAA;AAC7C,yCAKqB;AAJpB,wGAAA,WAAW,OAAA;AACX,8GAAA,iBAAiB,OAAA;AAIlB,+CAgBwB;AAfvB,mHAAA,mBAAmB,OAAA;AACnB,mHAAA,mBAAmB,OAAA;AACnB,uHAAA,uBAAuB,OAAA;AACvB,kHAAA,kBAAkB,OAAA;AAGlB,8GAAA,cAAc,OAAA;AACd,iHAAA,iBAAiB,OAAA;AACjB,8GAAA,cAAc,OAAA;AACd,iHAAA,iBAAiB,OAAA;AACjB,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A;AAE3B,iDAMyB;AAFxB,uHAAA,sBAAsB,OAAA;AACtB,4GAAA,WAAW,OAAA;AAGZ,6CAOuB;AANtB,uGAAA,QAAQ,OAAA;AAIR,iHAAA,kBAAkB,OAAA;AAClB,uHAAA,wBAAwB,OAAA;AAGzB,mDAM0B;AAJzB,sHAAA,oBAAoB,OAAA;AACpB,sHAAA,oBAAoB,OAAA;AAEpB,iHAAA,eAAe,OAAA;AAGhB,+CAMwB;AALvB,yGAAA,SAAS,OAAA;AAET,8GAAA,cAAc,OAAA;AACd,6GAAA,aAAa,OAAA;AACb,6GAAA,aAAa,OAAA;AAGd,iDAAmF;AAAzD,8GAAA,aAAa,OAAA;AAAE,iHAAA,gBAAgB,OAAA;AAEzD,uEAAmE;AAA1D,iIAAA,qBAAqB,OAAA;AAE9B,6DAAiE;AAAxD,+HAAA,wBAAwB,OAAA","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport {\n\tvalidateIndex,\n\tvalidateIndexRange,\n\tvalidatePositiveIndex,\n\tvalidateSafeInteger,\n} from \"./arrayUtilities.js\";\nexport {\n\tbrand,\n\ttype Brand,\n\tBrandedType,\n\ttype NameFromBranded,\n\ttype ValueFromBranded,\n\tbrandConst,\n\ttype Values,\n\tstrictEnum,\n\tunbrand,\n} from \"./brand.js\";\nexport { brandedNumberType, brandedStringType } from \"./typeboxBrand.js\";\nexport {\n\tbrandOpaque,\n\textractFromOpaque,\n\ttype ExtractFromOpaque,\n\ttype Opaque,\n} from \"./opaque.js\";\nexport {\n\tdeleteFromNestedMap,\n\tgetOrAddInNestedMap,\n\tgetOrDefaultInNestedMap,\n\tforEachInNestedMap,\n\ttype NestedMap,\n\ttype ReadonlyNestedMap,\n\tSizedNestedMap,\n\tpopulateNestedMap,\n\tsetInNestedMap,\n\ttryAddToNestedMap,\n\ttryGetFromNestedMap,\n\tmapNestedMap,\n\tnestedMapToFlatList,\n\tnestedMapFromFlatList,\n\tgetOrCreateInNestedMap,\n} from \"./nestedMap.js\";\nexport { addToNestedSet, type NestedSet, nestedSetContains } from \"./nestedSet.js\";\nexport { type OffsetList, OffsetListFactory } from \"./offsetList.js\";\nexport type {\n\tareSafelyAssignable,\n\tContravariant,\n\tCovariant,\n\teitherIsAny,\n\tEnforceTypeCheckTests,\n\tInvariant,\n\tisAny,\n\tisAssignableTo,\n\tisStrictSubset,\n\tMakeNominal,\n\trequireFalse,\n\trequireTrue,\n\trequireAssignableTo,\n\tareOnlyKeys,\n} from \"./typeCheck.js\";\nexport { StackyIterator } from \"./stackyIterator.js\";\nexport {\n\tasMutable,\n\tbalancedReduce,\n\tclone,\n\tcompareSets,\n\tgetOrAddEmptyToMap,\n\tgetOrCreate,\n\tisJsonObject,\n\tisReadonlyArray,\n\ttype JsonCompatible,\n\ttype JsonCompatibleObject,\n\ttype JsonCompatibleReadOnly,\n\ttype JsonCompatibleReadOnlyObject,\n\tJsonCompatibleReadOnlySchema,\n\tmakeArray,\n\tmapIterable,\n\tfilterIterable,\n\ttype Mutable,\n\ttype Populated,\n\ttype RecursiveReadonly,\n\tassertValidIndex,\n\tassertValidRange,\n\tassertNonNegativeSafeInteger,\n\tobjectToMap,\n\tinvertMap,\n\toneFromIterable,\n\ttype Named,\n\tcompareNamed,\n\tdisposeSymbol,\n\ttype IDisposable,\n\tcapitalize,\n\tassertValidRangeIndices,\n\ttransformObjectMap,\n\tcompareStrings,\n\tfind,\n\tcount,\n\tgetLast,\n\thasSome,\n\thasSingle,\n\tdefineLazyCachedProperty,\n\tcopyPropertyIfDefined as copyProperty,\n\tgetOrAddInMap,\n\titerableHasSome,\n} from \"./utils.js\";\nexport { ReferenceCountedBase, type ReferenceCounted } from \"./referenceCounting.js\";\n\nexport type {\n\t_RecursiveTrick,\n\tRestrictiveReadonlyRecord,\n\tRestrictiveStringRecord,\n\t_InlineTrick,\n\tFlattenKeys,\n\tIsUnion,\n\tUnionToIntersection,\n\tUnionToTuple,\n\tPopUnion,\n} from \"./typeUtils.js\";\n\nexport { unsafeArrayToTuple } from \"./typeUtils.js\";\n\nexport {\n\ttype BrandedKey,\n\ttype BrandedKeyContent,\n\ttype BrandedMapSubset,\n\tgetOrCreateSlotContent,\n\tbrandedSlot,\n} from \"./brandedMap.js\";\n\nexport {\n\tRangeMap,\n\ttype RangeQueryResult,\n\ttype RangeQueryResultFragment,\n\ttype RangeQueryEntry,\n\tnewIntegerRangeMap,\n\tareAdjacentIntegerRanges,\n} from \"./rangeMap.js\";\n\nexport {\n\ttype IdAllocator,\n\tidAllocatorFromMaxId,\n\tidAllocatorFromState,\n\ttype IdAllocationState,\n\tfakeIdAllocator,\n} from \"./idAllocator.js\";\n\nexport {\n\tBreakable,\n\ttype WithBreakable,\n\tbreakingMethod,\n\tthrowIfBroken,\n\tbreakingClass,\n} from \"./breakable.js\";\n\nexport { type TupleBTree, newTupleBTree, mergeTupleBTrees } from \"./bTreeUtils.js\";\n\nexport { cloneWithReplacements } from \"./cloneWithReplacements.js\";\n\nexport { readAndParseSnapshotBlob } from \"./readSnapshotBlob.js\";\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"nestedMap.d.ts","sourceRoot":"","sources":["../../src/util/nestedMap.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAMH;;;;;;GAMG;AACH,MAAM,MAAM,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,IAAI,GAAG,CAAC,IAAI,EAAE,GAAG,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC;AAEvE;;GAEG;AACH,MAAM,MAAM,iBAAiB,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,IAAI,WAAW,CAAC,IAAI,EAAE,WAAW,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC;AAE/F;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,EAClD,GAAG,EAAE,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,CAAC,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IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,GAAG,KAAK;IAIhE;;;OAGG;IACI,MAAM,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,GAAG,KAAK,GAAG,SAAS;IAQtE;;;OAGG;IACI,GAAG,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,GAAG,IAAI;IAMtD;;;OAGG;IACI,MAAM,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,GAAG,OAAO;IAQ9C;;OAEG;IACI,OAAO,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,KAAK,IAAI,GAAG,IAAI;IAI9E;;OAEG;IACI,KAAK,IAAI,IAAI;IAKb,MAAM,IAAI,gBAAgB,CAAC,KAAK,CAAC;IAIjC,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,gBAAgB,CAAC,CAAC,IAAI,EAAE,GAAG,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC;CAGtE"}
@@ -125,11 +125,11 @@ exports.deleteFromNestedMap = deleteFromNestedMap;
125
125
  */
126
126
  function nestedMapToFlatList(map) {
127
127
  const list = [];
128
- map.forEach((innerMap, key1) => {
129
- innerMap.forEach((val, key2) => {
128
+ for (const [key1, innerMap] of map) {
129
+ for (const [key2, val] of innerMap) {
130
130
  list.push([key1, key2, val]);
131
- });
132
- });
131
+ }
132
+ }
133
133
  return list;
134
134
  }
135
135
  exports.nestedMapToFlatList = nestedMapToFlatList;
@@ -145,11 +145,11 @@ function nestedMapFromFlatList(list) {
145
145
  }
146
146
  exports.nestedMapFromFlatList = nestedMapFromFlatList;
147
147
  function forEachInNestedMap(map, delegate) {
148
- map.forEach((innerMap, keyFirst) => {
149
- innerMap.forEach((val, keySecond) => {
148
+ for (const [keyFirst, innerMap] of map) {
149
+ for (const [keySecond, val] of innerMap) {
150
150
  delegate(val, keyFirst, keySecond);
151
- });
152
- });
151
+ }
152
+ }
153
153
  }
154
154
  exports.forEachInNestedMap = forEachInNestedMap;
155
155
  /**
@@ -161,14 +161,14 @@ exports.forEachInNestedMap = forEachInNestedMap;
161
161
  */
162
162
  function mapNestedMap(input, delegate) {
163
163
  const output = new Map();
164
- input.forEach((inputInnerMap, keyFirst) => {
164
+ for (const [keyFirst, inputInnerMap] of input) {
165
165
  const outputInnerMap = new Map();
166
- inputInnerMap.forEach((val, keySecond) => {
166
+ for (const [keySecond, val] of inputInnerMap) {
167
167
  const mappedValue = delegate(val, keyFirst, keySecond);
168
168
  outputInnerMap.set(keySecond, mappedValue);
169
- });
169
+ }
170
170
  output.set(keyFirst, outputInnerMap);
171
- });
171
+ }
172
172
  return output;
173
173
  }
174
174
  exports.mapNestedMap = mapNestedMap;
@@ -247,7 +247,7 @@ class SizedNestedMap {
247
247
  this.nestedMap.clear();
248
248
  }
249
249
  values() {
250
- return (Array.from(this.nestedMap.values()).flatMap((innerMap) => innerMap.values())[0] ?? (0, internal_1.oob)());
250
+ return [...this.nestedMap.values()].flatMap((innerMap) => innerMap.values())[0] ?? (0, internal_1.oob)();
251
251
  }
252
252
  [Symbol.iterator]() {
253
253
  return this.nestedMap[Symbol.iterator]();
@@ -1 +1 @@
1
- {"version":3,"file":"nestedMap.js","sourceRoot":"","sources":["../../src/util/nestedMap.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAA0D;AAE1D,yCAAwD;AAgBxD;;GAEG;AACH,SAAgB,iBAAiB,CAChC,GAAiC,EACjC,IAAU,EACV,IAAU,EACV,KAAY;IAEZ,IAAI,QAAQ,GAAG,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAC7B,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;QAC5B,QAAQ,GAAG,IAAI,GAAG,EAAE,CAAC;QACrB,G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E,CAAC;IACxB,CAAC;IAEM,MAAM;QACZ,OAAO,CACN,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,IAAA,cAAG,GAAE,CACxF,CAAC;IACH,CAAC;IAEM,CAAC,MAAM,CAAC,QAAQ,CAAC;QACvB,OAAO,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC;IAC1C,CAAC;CACD;AAtFD,wCAsFC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { oob } from \"@fluidframework/core-utils/internal\";\n\nimport { getOrAddInMap, getOrCreate } from \"./utils.js\";\n\n/**\n * A dictionary whose values are keyed off of two objects (key1, key2).\n * As it is a nested map, size() will return the number of distinct key1s.\n * If you need constant-time access to the number of values, use SizedNestedMap instead.\n *\n * This code assumes values will not be undefined (keys can be undefined).\n */\nexport type NestedMap<Key1, Key2, Value> = Map<Key1, Map<Key2, Value>>;\n\n/**\n * A read-only version of {@link NestedMap}.\n */\nexport type ReadonlyNestedMap<Key1, Key2, Value> = ReadonlyMap<Key1, ReadonlyMap<Key2, Value>>;\n\n/**\n * If (key1, key2) already has a value in the map, it is returned, otherwise value is added under (key1, key2) and undefined is returned.\n */\nexport function tryAddToNestedMap<Key1, Key2, Value>(\n\tmap: NestedMap<Key1, Key2, Value>,\n\tkey1: Key1,\n\tkey2: Key2,\n\tvalue: Value,\n): Value | undefined {\n\tlet innerMap = map.get(key1);\n\tif (innerMap === undefined) {\n\t\tinnerMap = new Map();\n\t\tmap.set(key1, innerMap);\n\t}\n\tif (innerMap.has(key2)) {\n\t\treturn innerMap.get(key2);\n\t}\n\tinnerMap.set(key2, value);\n\treturn undefined;\n}\n\n/**\n * Copies over all entries from the source map into the destination map.\n *\n * @param source - The map to copy data from. Not mutated.\n * @param destination - The map to copy data into. Both the outer and inner map may be mutated.\n * @param override - Whether existing entries in `destination` should be replaced by corresponding entries in `source`.\n *\n * @remarks This function performs deep copying when necessary.\n * This ensures that mutating `destination` after this call will not result in unexpected mutations to `source`.\n */\nexport function populateNestedMap<Key1, Key2, Value>(\n\tsource: ReadonlyNestedMap<Key1, Key2, Value>,\n\tdestination: NestedMap<Key1, Key2, Value>,\n\toverride: boolean,\n): void {\n\tfor (const [key1, sourceInner] of source) {\n\t\tlet destinationInner = destination.get(key1);\n\t\tif (destinationInner === undefined) {\n\t\t\tdestinationInner = new Map(sourceInner);\n\t\t\tdestination.set(key1, destinationInner);\n\t\t} else {\n\t\t\tfor (const [key2, value] of sourceInner) {\n\t\t\t\tif (override || !destinationInner.has(key2)) {\n\t\t\t\t\tdestinationInner.set(key2, value);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n\n/**\n * Sets the value at (key1, key2) in map to value.\n * If there already is a value for (key1, key2), it is replaced with the provided one.\n */\nexport function setInNestedMap<Key1, Key2, Value>(\n\tmap: NestedMap<Key1, Key2, Value>,\n\tkey1: Key1,\n\tkey2: Key2,\n\tvalue: Value,\n): void {\n\tconst innerMap = getOrAddInMap(map, key1, new Map<Key2, Value>());\n\tinnerMap.set(key2, value);\n}\n\n/**\n * {@link getOrCreate} for {@link NestedMap}.\n */\nexport function getOrCreateInNestedMap<Key1, Key2, Value>(\n\tmap: NestedMap<Key1, Key2, Value>,\n\tkey1: Key1,\n\tkey2: Key2,\n\tdefaultValue: (key1: Key1, key2: Key2) => Value,\n): Value {\n\tconst innerMap = getOrAddInMap(map, key1, new Map<Key2, Value>());\n\treturn getOrCreate(innerMap, key2, (): Value => defaultValue(key1, key2));\n}\n\n/**\n * Returns the value at (key1, key2) in map, or undefined if not present.\n */\nexport function tryGetFromNestedMap<Key1, Key2, Value>(\n\tmap: NestedMap<Key1, Key2, Value>,\n\tkey1: Key1,\n\tkey2: Key2,\n): Value | undefined {\n\tconst innerMap = map.get(key1);\n\tif (innerMap === undefined) {\n\t\treturn undefined;\n\t}\n\treturn innerMap.get(key2);\n}\n\n/**\n * If (key1, key2) is not in the map, add value to the map.\n * Returns whatever is at (key1, key2) in map (which will be value if it was empty before).\n */\nexport function getOrAddInNestedMap<Key1, Key2, Value>(\n\tmap: NestedMap<Key1, Key2, Value>,\n\tkey1: Key1,\n\tkey2: Key2,\n\tvalue: Value,\n): Value {\n\tconst existing = tryAddToNestedMap(map, key1, key2, value);\n\tif (existing !== undefined) {\n\t\treturn existing;\n\t}\n\treturn value;\n}\n\n/**\n * Does not change map.\n * If (key1, key2) is not in map, returns value.\n * If (key1, key2) is in map, return its entry.\n */\nexport function getOrDefaultInNestedMap<Key1, Key2, Value>(\n\tmap: NestedMap<Key1, Key2, Value>,\n\tkey1: Key1,\n\tkey2: Key2,\n\tvalue: Value,\n): Value {\n\tconst existing = tryGetFromNestedMap(map, key1, key2);\n\tif (existing !== undefined) {\n\t\treturn existing;\n\t}\n\treturn value;\n}\n\n/**\n * Removes the value at (key1, key2) from the map.\n *\n * @returns true iff found.\n */\nexport function deleteFromNestedMap<Key1, Key2, Value>(\n\tmap: NestedMap<Key1, Key2, Value>,\n\tkey1: Key1,\n\tkey2: Key2,\n): boolean {\n\tconst innerMap = map.get(key1);\n\tif (innerMap === undefined) {\n\t\treturn false;\n\t}\n\tconst deleted = innerMap.delete(key2);\n\tif (innerMap.size === 0) {\n\t\tmap.delete(key1);\n\t}\n\treturn deleted;\n}\n\n/**\n * Converts a nested map to a flat list of triplets.\n */\nexport function nestedMapToFlatList<Key1, Key2, Value>(\n\tmap: ReadonlyNestedMap<Key1, Key2, Value>,\n): [Key1, Key2, Value][] {\n\tconst list: [Key1, Key2, Value][] = [];\n\tmap.forEach((innerMap, key1) => {\n\t\tinnerMap.forEach((val, key2) => {\n\t\t\tlist.push([key1, key2, val]);\n\t\t});\n\t});\n\treturn list;\n}\n\n/**\n * Builds a nested map from a flat list of triplets.\n */\nexport function nestedMapFromFlatList<Key1, Key2, Value>(\n\tlist: readonly (readonly [Key1, Key2, Value])[],\n): NestedMap<Key1, Key2, Value> {\n\tconst map = new Map<Key1, Map<Key2, Value>>();\n\tfor (const [key1, key2, val] of list) {\n\t\tgetOrAddInMap(map, key1, new Map<Key2, Value>()).set(key2, val);\n\t}\n\treturn map;\n}\n\nexport function forEachInNestedMap<Key1, Key2, Value>(\n\tmap: ReadonlyNestedMap<Key1, Key2, Value>,\n\tdelegate: (value: Value, key1: Key1, key2: Key2) => void,\n): void {\n\tmap.forEach((innerMap, keyFirst) => {\n\t\tinnerMap.forEach((val, keySecond) => {\n\t\t\tdelegate(val, keyFirst, keySecond);\n\t\t});\n\t});\n}\n\n/**\n * Maps the `input` map values using the provided `delegate`.\n *\n * @param input - The `NestedMap` whose contents are being mapped.\n * @param delegate - The delegate to use for mapping values,\n * @returns A new `NestedMap` with the same keys as `input`, but with the values produced by `delegate`.\n */\nexport function mapNestedMap<Key1, Key2, ValueIn, ValueOut = ValueIn>(\n\tinput: ReadonlyNestedMap<Key1, Key2, ValueIn>,\n\tdelegate: (value: ValueIn, key1: Key1, key2: Key2) => ValueOut,\n): NestedMap<Key1, Key2, ValueOut> {\n\tconst output = new Map<Key1, Map<Key2, ValueOut>>();\n\tinput.forEach((inputInnerMap, keyFirst) => {\n\t\tconst outputInnerMap = new Map<Key2, ValueOut>();\n\t\tinputInnerMap.forEach((val, keySecond) => {\n\t\t\tconst mappedValue = delegate(val, keyFirst, keySecond);\n\t\t\toutputInnerMap.set(keySecond, mappedValue);\n\t\t});\n\t\toutput.set(keyFirst, outputInnerMap);\n\t});\n\treturn output;\n}\n\n/**\n * Map with two keys; same semantics as NestedMap, but maintains a size count for the entire collection.\n * Note: undefined is not supported as a value, and will cause incorrect behavior.\n */\nexport class SizedNestedMap<Key1, Key2, Value> {\n\tprivate readonly nestedMap: NestedMap<Key1, Key2, Value> = new Map();\n\tprivate count = 0;\n\n\t/**\n\t * Returns the total number of elements in this nested map.\n\t */\n\tpublic get size(): number {\n\t\treturn this.count;\n\t}\n\n\t/**\n\t * If (key1, key2) already has a value in the map, it is returned, otherwise value is added under (key1, key2) and undefined is\n\t * returned.\n\t */\n\tpublic tryGet(key1: Key1, key2: Key2): Value | undefined {\n\t\treturn tryGetFromNestedMap(this.nestedMap, key1, key2);\n\t}\n\n\t/**\n\t * Does not change map.\n\t * If (key1, key2) is not in map, returns value.\n\t * If (key1, key2) is in map, return its entry.\n\t */\n\tpublic getOrDefault(key1: Key1, key2: Key2, value: Value): Value {\n\t\treturn getOrDefaultInNestedMap(this.nestedMap, key1, key2, value);\n\t}\n\n\t/**\n\t * If (key1, key2) already has a value in the map, it is returned, otherwise value is added under (key1, key2) and undefined is\n\t * returned.\n\t */\n\tpublic tryAdd(key1: Key1, key2: Key2, value: Value): Value | undefined {\n\t\tconst currentVal = tryAddToNestedMap(this.nestedMap, key1, key2, value);\n\t\tif (currentVal === undefined) {\n\t\t\tthis.count++;\n\t\t}\n\t\treturn currentVal;\n\t}\n\n\t/**\n\t * Sets the value at (key1, key2) in map to value.\n\t * If there already is a value for (key1, key2), it is replaced with the provided one.\n\t */\n\tpublic set(key1: Key1, key2: Key2, value: Value): void {\n\t\tif (this.tryAdd(key1, key2, value) !== undefined) {\n\t\t\tsetInNestedMap(this.nestedMap, key1, key2, value);\n\t\t}\n\t}\n\n\t/**\n\t * Removes the value at (key1, key2) from the map.\n\t * Returns true iff found.\n\t */\n\tpublic delete(key1: Key1, key2: Key2): boolean {\n\t\tconst deleted = deleteFromNestedMap(this.nestedMap, key1, key2);\n\t\tif (deleted) {\n\t\t\tthis.count--;\n\t\t}\n\t\treturn deleted;\n\t}\n\n\t/**\n\t * Runs the supplied delegate for every (value, key1, key2).\n\t */\n\tpublic forEach(delegate: (value: Value, key1: Key1, key2: Key2) => void): void {\n\t\tforEachInNestedMap(this.nestedMap, delegate);\n\t}\n\n\t/**\n\t * Clears the map.\n\t */\n\tpublic clear(): void {\n\t\tthis.count = 0;\n\t\tthis.nestedMap.clear();\n\t}\n\n\tpublic values(): IterableIterator<Value> {\n\t\treturn (\n\t\t\tArray.from(this.nestedMap.values()).flatMap((innerMap) => innerMap.values())[0] ?? oob()\n\t\t);\n\t}\n\n\tpublic [Symbol.iterator](): IterableIterator<[Key1, Map<Key2, Value>]> {\n\t\treturn this.nestedMap[Symbol.iterator]();\n\t}\n}\n"]}
1
+ {"version":3,"file":"nestedMap.js","sourceRoot":"","sources":["../../src/util/nestedMap.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAA0D;AAE1D,yCAAwD;AAgBxD;;GAEG;AACH,SAAgB,iBAAiB,CAChC,GAAiC,EACjC,IAAU,EACV,IAAU,EACV,KAAY;IAEZ,IAAI,QAAQ,GAAG,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAC7B,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;QAC5B,QAAQ,GAAG,IAAI,GAAG,EAAE,CAAC;QACrB,GAAG,CAAC,GAAG,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;IACzB,CAAC;IACD,IAAI,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;QACxB,OAAO,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAC3B,CAAC;IACD,QAAQ,CAAC,GAAG,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IAC1B,OAAO,SAAS,CAAC;AAClB,CAAC;AAhBD,8CAgBC;AAED;;;;;;;;;GASG;AACH,SAAgB,iBAAiB,CAChC,MAA4C,EAC5C,WAAyC,EACzC,QAAiB;IAEjB,KAAK,MAAM,CAAC,IAAI,EAAE,WAAW,CAAC,IAAI,MAAM,EAAE,CAAC;QAC1C,IAAI,gBAAgB,GAAG,WAAW,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QAC7C,IAAI,gBAAgB,KAAK,SAAS,EAAE,CAAC;YACpC,gBAAgB,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C,KAAK,SAAS,EAAE,CAAC;YAClD,cAAc,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC;QACnD,CAAC;IACF,CAAC;IAED;;;OAGG;IACI,MAAM,CAAC,IAAU,EAAE,IAAU;QACnC,MAAM,OAAO,GAAG,mBAAmB,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;QAChE,IAAI,OAAO,EAAE,CAAC;YACb,IAAI,CAAC,KAAK,EAAE,CAAC;QACd,CAAC;QACD,OAAO,OAAO,CAAC;IAChB,CAAC;IAED;;OAEG;IACI,OAAO,CAAC,QAAwD;QACtE,kBAAkB,CAAC,IAAI,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;IAC9C,CAAC;IAED;;OAEG;IACI,KAAK;QACX,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC;QACf,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC;IACxB,CAAC;IAEM,MAAM;QACZ,OAAO,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,IAAA,cAAG,GAAE,CAAC;IAC1F,CAAC;IAEM,CAAC,MAAM,CAAC,QAAQ,CAAC;QACvB,OAAO,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC;IAC1C,CAAC;CACD;AApFD,wCAoFC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { oob } from \"@fluidframework/core-utils/internal\";\n\nimport { getOrAddInMap, getOrCreate } from \"./utils.js\";\n\n/**\n * A dictionary whose values are keyed off of two objects (key1, key2).\n * As it is a nested map, size() will return the number of distinct key1s.\n * If you need constant-time access to the number of values, use SizedNestedMap instead.\n *\n * This code assumes values will not be undefined (keys can be undefined).\n */\nexport type NestedMap<Key1, Key2, Value> = Map<Key1, Map<Key2, Value>>;\n\n/**\n * A read-only version of {@link NestedMap}.\n */\nexport type ReadonlyNestedMap<Key1, Key2, Value> = ReadonlyMap<Key1, ReadonlyMap<Key2, Value>>;\n\n/**\n * If (key1, key2) already has a value in the map, it is returned, otherwise value is added under (key1, key2) and undefined is returned.\n */\nexport function tryAddToNestedMap<Key1, Key2, Value>(\n\tmap: NestedMap<Key1, Key2, Value>,\n\tkey1: Key1,\n\tkey2: Key2,\n\tvalue: Value,\n): Value | undefined {\n\tlet innerMap = map.get(key1);\n\tif (innerMap === undefined) {\n\t\tinnerMap = new Map();\n\t\tmap.set(key1, innerMap);\n\t}\n\tif (innerMap.has(key2)) {\n\t\treturn innerMap.get(key2);\n\t}\n\tinnerMap.set(key2, value);\n\treturn undefined;\n}\n\n/**\n * Copies over all entries from the source map into the destination map.\n *\n * @param source - The map to copy data from. Not mutated.\n * @param destination - The map to copy data into. Both the outer and inner map may be mutated.\n * @param override - Whether existing entries in `destination` should be replaced by corresponding entries in `source`.\n *\n * @remarks This function performs deep copying when necessary.\n * This ensures that mutating `destination` after this call will not result in unexpected mutations to `source`.\n */\nexport function populateNestedMap<Key1, Key2, Value>(\n\tsource: ReadonlyNestedMap<Key1, Key2, Value>,\n\tdestination: NestedMap<Key1, Key2, Value>,\n\toverride: boolean,\n): void {\n\tfor (const [key1, sourceInner] of source) {\n\t\tlet destinationInner = destination.get(key1);\n\t\tif (destinationInner === undefined) {\n\t\t\tdestinationInner = new Map(sourceInner);\n\t\t\tdestination.set(key1, destinationInner);\n\t\t} else {\n\t\t\tfor (const [key2, value] of sourceInner) {\n\t\t\t\tif (override || !destinationInner.has(key2)) {\n\t\t\t\t\tdestinationInner.set(key2, value);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n\n/**\n * Sets the value at (key1, key2) in map to value.\n * If there already is a value for (key1, key2), it is replaced with the provided one.\n */\nexport function setInNestedMap<Key1, Key2, Value>(\n\tmap: NestedMap<Key1, Key2, Value>,\n\tkey1: Key1,\n\tkey2: Key2,\n\tvalue: Value,\n): void {\n\tconst innerMap = getOrAddInMap(map, key1, new Map<Key2, Value>());\n\tinnerMap.set(key2, value);\n}\n\n/**\n * {@link getOrCreate} for {@link NestedMap}.\n */\nexport function getOrCreateInNestedMap<Key1, Key2, Value>(\n\tmap: NestedMap<Key1, Key2, Value>,\n\tkey1: Key1,\n\tkey2: Key2,\n\tdefaultValue: (key1: Key1, key2: Key2) => Value,\n): Value {\n\tconst innerMap = getOrAddInMap(map, key1, new Map<Key2, Value>());\n\treturn getOrCreate(innerMap, key2, (): Value => defaultValue(key1, key2));\n}\n\n/**\n * Returns the value at (key1, key2) in map, or undefined if not present.\n */\nexport function tryGetFromNestedMap<Key1, Key2, Value>(\n\tmap: NestedMap<Key1, Key2, Value>,\n\tkey1: Key1,\n\tkey2: Key2,\n): Value | undefined {\n\tconst innerMap = map.get(key1);\n\tif (innerMap === undefined) {\n\t\treturn undefined;\n\t}\n\treturn innerMap.get(key2);\n}\n\n/**\n * If (key1, key2) is not in the map, add value to the map.\n * Returns whatever is at (key1, key2) in map (which will be value if it was empty before).\n */\nexport function getOrAddInNestedMap<Key1, Key2, Value>(\n\tmap: NestedMap<Key1, Key2, Value>,\n\tkey1: Key1,\n\tkey2: Key2,\n\tvalue: Value,\n): Value {\n\tconst existing = tryAddToNestedMap(map, key1, key2, value);\n\tif (existing !== undefined) {\n\t\treturn existing;\n\t}\n\treturn value;\n}\n\n/**\n * Does not change map.\n * If (key1, key2) is not in map, returns value.\n * If (key1, key2) is in map, return its entry.\n */\nexport function getOrDefaultInNestedMap<Key1, Key2, Value>(\n\tmap: NestedMap<Key1, Key2, Value>,\n\tkey1: Key1,\n\tkey2: Key2,\n\tvalue: Value,\n): Value {\n\tconst existing = tryGetFromNestedMap(map, key1, key2);\n\tif (existing !== undefined) {\n\t\treturn existing;\n\t}\n\treturn value;\n}\n\n/**\n * Removes the value at (key1, key2) from the map.\n *\n * @returns true iff found.\n */\nexport function deleteFromNestedMap<Key1, Key2, Value>(\n\tmap: NestedMap<Key1, Key2, Value>,\n\tkey1: Key1,\n\tkey2: Key2,\n): boolean {\n\tconst innerMap = map.get(key1);\n\tif (innerMap === undefined) {\n\t\treturn false;\n\t}\n\tconst deleted = innerMap.delete(key2);\n\tif (innerMap.size === 0) {\n\t\tmap.delete(key1);\n\t}\n\treturn deleted;\n}\n\n/**\n * Converts a nested map to a flat list of triplets.\n */\nexport function nestedMapToFlatList<Key1, Key2, Value>(\n\tmap: ReadonlyNestedMap<Key1, Key2, Value>,\n): [Key1, Key2, Value][] {\n\tconst list: [Key1, Key2, Value][] = [];\n\tfor (const [key1, innerMap] of map) {\n\t\tfor (const [key2, val] of innerMap) {\n\t\t\tlist.push([key1, key2, val]);\n\t\t}\n\t}\n\treturn list;\n}\n\n/**\n * Builds a nested map from a flat list of triplets.\n */\nexport function nestedMapFromFlatList<Key1, Key2, Value>(\n\tlist: readonly (readonly [Key1, Key2, Value])[],\n): NestedMap<Key1, Key2, Value> {\n\tconst map = new Map<Key1, Map<Key2, Value>>();\n\tfor (const [key1, key2, val] of list) {\n\t\tgetOrAddInMap(map, key1, new Map<Key2, Value>()).set(key2, val);\n\t}\n\treturn map;\n}\n\nexport function forEachInNestedMap<Key1, Key2, Value>(\n\tmap: ReadonlyNestedMap<Key1, Key2, Value>,\n\tdelegate: (value: Value, key1: Key1, key2: Key2) => void,\n): void {\n\tfor (const [keyFirst, innerMap] of map) {\n\t\tfor (const [keySecond, val] of innerMap) {\n\t\t\tdelegate(val, keyFirst, keySecond);\n\t\t}\n\t}\n}\n\n/**\n * Maps the `input` map values using the provided `delegate`.\n *\n * @param input - The `NestedMap` whose contents are being mapped.\n * @param delegate - The delegate to use for mapping values,\n * @returns A new `NestedMap` with the same keys as `input`, but with the values produced by `delegate`.\n */\nexport function mapNestedMap<Key1, Key2, ValueIn, ValueOut = ValueIn>(\n\tinput: ReadonlyNestedMap<Key1, Key2, ValueIn>,\n\tdelegate: (value: ValueIn, key1: Key1, key2: Key2) => ValueOut,\n): NestedMap<Key1, Key2, ValueOut> {\n\tconst output = new Map<Key1, Map<Key2, ValueOut>>();\n\tfor (const [keyFirst, inputInnerMap] of input) {\n\t\tconst outputInnerMap = new Map<Key2, ValueOut>();\n\t\tfor (const [keySecond, val] of inputInnerMap) {\n\t\t\tconst mappedValue = delegate(val, keyFirst, keySecond);\n\t\t\toutputInnerMap.set(keySecond, mappedValue);\n\t\t}\n\t\toutput.set(keyFirst, outputInnerMap);\n\t}\n\treturn output;\n}\n\n/**\n * Map with two keys; same semantics as NestedMap, but maintains a size count for the entire collection.\n * Note: undefined is not supported as a value, and will cause incorrect behavior.\n */\nexport class SizedNestedMap<Key1, Key2, Value> {\n\tprivate readonly nestedMap: NestedMap<Key1, Key2, Value> = new Map();\n\tprivate count = 0;\n\n\t/**\n\t * Returns the total number of elements in this nested map.\n\t */\n\tpublic get size(): number {\n\t\treturn this.count;\n\t}\n\n\t/**\n\t * If (key1, key2) already has a value in the map, it is returned, otherwise value is added under (key1, key2) and undefined is\n\t * returned.\n\t */\n\tpublic tryGet(key1: Key1, key2: Key2): Value | undefined {\n\t\treturn tryGetFromNestedMap(this.nestedMap, key1, key2);\n\t}\n\n\t/**\n\t * Does not change map.\n\t * If (key1, key2) is not in map, returns value.\n\t * If (key1, key2) is in map, return its entry.\n\t */\n\tpublic getOrDefault(key1: Key1, key2: Key2, value: Value): Value {\n\t\treturn getOrDefaultInNestedMap(this.nestedMap, key1, key2, value);\n\t}\n\n\t/**\n\t * If (key1, key2) already has a value in the map, it is returned, otherwise value is added under (key1, key2) and undefined is\n\t * returned.\n\t */\n\tpublic tryAdd(key1: Key1, key2: Key2, value: Value): Value | undefined {\n\t\tconst currentVal = tryAddToNestedMap(this.nestedMap, key1, key2, value);\n\t\tif (currentVal === undefined) {\n\t\t\tthis.count++;\n\t\t}\n\t\treturn currentVal;\n\t}\n\n\t/**\n\t * Sets the value at (key1, key2) in map to value.\n\t * If there already is a value for (key1, key2), it is replaced with the provided one.\n\t */\n\tpublic set(key1: Key1, key2: Key2, value: Value): void {\n\t\tif (this.tryAdd(key1, key2, value) !== undefined) {\n\t\t\tsetInNestedMap(this.nestedMap, key1, key2, value);\n\t\t}\n\t}\n\n\t/**\n\t * Removes the value at (key1, key2) from the map.\n\t * Returns true iff found.\n\t */\n\tpublic delete(key1: Key1, key2: Key2): boolean {\n\t\tconst deleted = deleteFromNestedMap(this.nestedMap, key1, key2);\n\t\tif (deleted) {\n\t\t\tthis.count--;\n\t\t}\n\t\treturn deleted;\n\t}\n\n\t/**\n\t * Runs the supplied delegate for every (value, key1, key2).\n\t */\n\tpublic forEach(delegate: (value: Value, key1: Key1, key2: Key2) => void): void {\n\t\tforEachInNestedMap(this.nestedMap, delegate);\n\t}\n\n\t/**\n\t * Clears the map.\n\t */\n\tpublic clear(): void {\n\t\tthis.count = 0;\n\t\tthis.nestedMap.clear();\n\t}\n\n\tpublic values(): IterableIterator<Value> {\n\t\treturn [...this.nestedMap.values()].flatMap((innerMap) => innerMap.values())[0] ?? oob();\n\t}\n\n\tpublic [Symbol.iterator](): IterableIterator<[Key1, Map<Key2, Value>]> {\n\t\treturn this.nestedMap[Symbol.iterator]();\n\t}\n}\n"]}
@@ -10,8 +10,8 @@
10
10
  * The structure of the keys is described by the `offsetKey` and `subtractKeys` functions provided in the constructor.
11
11
  */
12
12
  export declare class RangeMap<K, V> {
13
- private readonly offsetKey;
14
- private readonly subtractKeys;
13
+ readonly offsetKey: (key: K, offset: number) => K;
14
+ readonly subtractKeys: (a: K, b: K) => number;
15
15
  readonly offsetValue: (value: V, offset: number) => V;
16
16
  private tree;
17
17
  /**
@@ -46,6 +46,10 @@ export declare class RangeMap<K, V> {
46
46
  * The entries are in the same order as the keys, and there is an entry for every key with a non `undefined` value.
47
47
  */
48
48
  getAll(start: K, length: number): RangeQueryEntry<K, V>[];
49
+ /**
50
+ * Like getAll, but includes entries where the value is undefined.
51
+ */
52
+ getAll2(start: K, length: number): RangeQueryResultFragment<V | undefined>[];
49
53
  /**
50
54
  * Retrieves the value for some prefix of the query range.
51
55
  *
@@ -54,7 +58,7 @@ export declare class RangeMap<K, V> {
54
58
  * @returns A RangeQueryResult containing the value associated with `start`,
55
59
  * and the number of consecutive keys with that same value (at least 1, at most `length`).
56
60
  */
57
- getFirst(start: K, length: number): RangeQueryResult<K, V>;
61
+ getFirst(start: K, length: number): RangeQueryResult<V | undefined>;
58
62
  /**
59
63
  * Sets the value for a specified range.
60
64
  *
@@ -82,9 +86,11 @@ export declare class RangeMap<K, V> {
82
86
  *
83
87
  * @param start - The start of the range to delete (inclusive).
84
88
  * @param length - The length of the range to delete.
89
+ * @returns The number of entries deleted.
85
90
  */
86
- delete(start: K, length: number): void;
91
+ delete(start: K, length: number): number;
87
92
  clone(): RangeMap<K, V>;
93
+ mapEntries(mapKey: (key: K) => K, mapValue: (value: V) => V): RangeMap<K, V>;
88
94
  /**
89
95
  * Returns a new map which contains the entries from both input maps.
90
96
  */
@@ -98,16 +104,11 @@ export declare class RangeMap<K, V> {
98
104
  /**
99
105
  * Describes the result of a range query, including the value and length of the matching prefix.
100
106
  */
101
- export interface RangeQueryResult<K, V> {
102
- /**
103
- * The key for the first element in the range.
104
- */
105
- readonly start: K;
107
+ export interface RangeQueryResult<V> {
106
108
  /**
107
109
  * The value of the first key in the query range.
108
- * If no matching range is found, this will be undefined.
109
110
  */
110
- readonly value: V | undefined;
111
+ readonly value: V;
111
112
  /**
112
113
  * The length of the prefix of the query range which has the same value.
113
114
  * For example, if a RangeMap has the same value for keys 5, 6, and 7,
@@ -115,8 +116,19 @@ export interface RangeQueryResult<K, V> {
115
116
  */
116
117
  readonly length: number;
117
118
  }
118
- export interface RangeQueryEntry<K, V> extends RangeQueryResult<K, V> {
119
+ export interface RangeQueryResultFragment<V> extends RangeQueryResult<V> {
120
+ /**
121
+ * The offset from the query key to the key this result is associated with.
122
+ * This is useful in the case where a query returns multiple `RangeQueryResults`
123
+ * addressing the key range.
124
+ */
125
+ readonly offset: number;
126
+ }
127
+ export interface RangeQueryEntry<K, V> {
128
+ readonly start: K;
119
129
  readonly value: V;
130
+ readonly length: number;
120
131
  }
121
132
  export declare function newIntegerRangeMap<V>(): RangeMap<number, V>;
133
+ export declare function areAdjacentIntegerRanges(firstStart: number, firstLength: number, secondStart: number): boolean;
122
134
  //# sourceMappingURL=rangeMap.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"rangeMap.d.ts","sourceRoot":"","sources":["../../src/util/rangeMap.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH;;;;;;GAMG;AACH,qBAAa,QAAQ,CAAC,CAAC,EAAE,CAAC;IAqBxB,OAAO,CAAC,QAAQ,CAAC,SAAS;IAC1B,OAAO,CAAC,QAAQ,CAAC,YAAY;aACb,WAAW,EAAE,CAAC,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,MAAM,KAAK,CAAC;IAtB7D,OAAO,CAAC,IAAI,CAA0B;IAEtC;;;;;;;;;;;;;;;;OAgBG;gBAEe,SAAS,EAAE,CAAC,GAAG,EAAE,CAAC,EAAE,MAAM,EAAE,MAAM,KAAK,CAAC,EACxC,YAAY,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,KAAK,MAAM,EACrC,WAAW,GAAE,CAAC,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,MAAM,KAAK,CAAwB;IAKpF;;OAEG;IACI,OAAO,IAAI,eAAe,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE;IASlC,KAAK,IAAI,IAAI;IAIpB;;;;;;;OAOG;IACI,MAAM,CAAC,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,MAAM,GAAG,eAAe,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE;IA2BhE;;;;;;;OAOG;IACI,QAAQ,CAAC,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,MAA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AAC,CAE3D;AAcD,wBAAgB,wBAAwB,CACvC,UAAU,EAAE,MAAM,EAClB,WAAW,EAAE,MAAM,EACnB,WAAW,EAAE,MAAM,GACjB,OAAO,CAET"}
@@ -4,7 +4,7 @@
4
4
  * Licensed under the MIT License.
5
5
  */
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.newIntegerRangeMap = exports.RangeMap = void 0;
7
+ exports.areAdjacentIntegerRanges = exports.newIntegerRangeMap = exports.RangeMap = void 0;
8
8
  const internal_1 = require("@fluidframework/core-utils/internal");
9
9
  const sorted_btree_es6_1 = require("@tylerbu/sorted-btree-es6");
10
10
  /**
@@ -82,6 +82,30 @@ class RangeMap {
82
82
  }
83
83
  return entries;
84
84
  }
85
+ // XXX: Merge with getAll
86
+ /**
87
+ * Like getAll, but includes entries where the value is undefined.
88
+ */
89
+ getAll2(start, length) {
90
+ let nextKey = start;
91
+ let offset = 0;
92
+ const result = [];
93
+ for (const entry of this.getAll(start, length)) {
94
+ const lengthBefore = this.subtractKeys(entry.start, nextKey);
95
+ if (lengthBefore > 0) {
96
+ result.push({ offset, length: lengthBefore, value: undefined });
97
+ offset += lengthBefore;
98
+ }
99
+ result.push({ offset, length: entry.length, value: entry.value });
100
+ nextKey = this.offsetKey(entry.start, entry.length);
101
+ offset += entry.length;
102
+ }
103
+ const lengthRemaining = length - offset;
104
+ if (lengthRemaining > 0) {
105
+ result.push({ offset, length: lengthRemaining, value: undefined });
106
+ }
107
+ return result;
108
+ }
85
109
  /**
86
110
  * Retrieves the value for some prefix of the query range.
87
111
  *
@@ -103,7 +127,6 @@ class RangeMap {
103
127
  if (overlappingLength > 0) {
104
128
  return {
105
129
  value: this.offsetValue(value, lengthBeforeQuery),
106
- start,
107
130
  length: overlappingLength,
108
131
  };
109
132
  }
@@ -117,10 +140,10 @@ class RangeMap {
117
140
  const entryKey = key;
118
141
  const lastQueryKey = this.offsetKey(start, length - 1);
119
142
  if (this.le(entryKey, lastQueryKey)) {
120
- return { value: undefined, start, length: this.subtractKeys(entryKey, start) };
143
+ return { value: undefined, length: this.subtractKeys(entryKey, start) };
121
144
  }
122
145
  }
123
- return { value: undefined, start, length };
146
+ return { value: undefined, length };
124
147
  }
125
148
  }
126
149
  /**
@@ -155,15 +178,19 @@ class RangeMap {
155
178
  *
156
179
  * @param start - The start of the range to delete (inclusive).
157
180
  * @param length - The length of the range to delete.
181
+ * @returns The number of entries deleted.
158
182
  */
159
183
  delete(start, length) {
184
+ let deleteCount = 0;
160
185
  const lastDeleteKey = this.offsetKey(start, length - 1);
161
186
  for (const { start: key, length: entryLength, value } of this.getIntersectingEntries(start, length)) {
187
+ deleteCount += entryLength;
162
188
  this.tree.delete(key);
163
189
  const lengthBefore = this.subtractKeys(start, key);
164
190
  if (lengthBefore > 0) {
165
191
  // A portion of this entry comes before the deletion range, so we reinsert that portion.
166
192
  this.tree.set(key, { length: lengthBefore, value });
193
+ deleteCount -= lengthBefore;
167
194
  }
168
195
  const lastEntryKey = this.offsetKey(key, entryLength - 1);
169
196
  const lengthAfter = this.subtractKeys(lastEntryKey, lastDeleteKey);
@@ -175,14 +202,23 @@ class RangeMap {
175
202
  length: lengthAfter,
176
203
  value: this.offsetValue(value, difference),
177
204
  });
205
+ deleteCount -= lengthAfter;
178
206
  }
179
207
  }
208
+ return deleteCount;
180
209
  }
181
210
  clone() {
182
211
  const cloned = new RangeMap(this.offsetKey, this.subtractKeys, this.offsetValue);
183
212
  cloned.tree = this.tree.clone();
184
213
  return cloned;
185
214
  }
215
+ mapEntries(mapKey, mapValue) {
216
+ const result = new RangeMap(this.offsetKey, this.subtractKeys, this.offsetValue);
217
+ for (const entry of this.entries()) {
218
+ result.set(mapKey(entry.start), entry.length, mapValue(entry.value));
219
+ }
220
+ return result;
221
+ }
186
222
  /**
187
223
  * Returns a new map which contains the entries from both input maps.
188
224
  */
@@ -193,9 +229,9 @@ class RangeMap {
193
229
  const merged = new RangeMap(a.offsetKey, a.subtractKeys, a.offsetValue);
194
230
  // TODO: Is there a good pattern that lets us make `tree` readonly?
195
231
  merged.tree = a.tree.clone();
196
- for (const [key, value] of b.tree.entries()) {
232
+ for (const entry of b.entries()) {
197
233
  // TODO: Handle key collisions
198
- merged.tree.set(key, value);
234
+ merged.set(entry.start, entry.length, entry.value);
199
235
  }
200
236
  return merged;
201
237
  }
@@ -255,4 +291,8 @@ function subtractIntegers(a, b) {
255
291
  function defaultValueOffsetFn(value, offset) {
256
292
  return value;
257
293
  }
294
+ function areAdjacentIntegerRanges(firstStart, firstLength, secondStart) {
295
+ return firstStart + firstLength === secondStart;
296
+ }
297
+ exports.areAdjacentIntegerRanges = areAdjacentIntegerRanges;
258
298
  //# sourceMappingURL=rangeMap.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"rangeMap.js","sourceRoot":"","sources":["../../src/util/rangeMap.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAAkE;AAClE,gEAAkD;AAElD;;;;;;GAMG;AACH,MAAa,QAAQ;IAGpB;;;;;;;;;;;;;;;;OAgBG;IACH,YACkB,SAAwC,EACxC,YAAoC,EACrC,cAA+C,oBAAoB;QAFlE,cAAS,GAAT,SAAS,CAA+B;QACxC,iBAAY,GAAZ,YAAY,CAAwB;QACrC,gBAAW,GAAX,WAAW,CAAwD;QAEnF,IAAI,CAAC,IAAI,GAAG,IAAI,wBAAK,CAAC,SAAS,EAAE,YAAY,CAAC,CAAC;IAChD,CAAC;IAED;;OAEG;IACI,OAAO;QACb,MAAM,OAAO,GAA4B,EAAE,CAAC;QAC5C,KAAK,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,EAAE,CAAC;YAClD,OAAO,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,CAAC,CAAC;QACnE,CAAC;QAED,OAAO,OAAO,CAAC;IAChB,CAAC;IAEM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a,CAAC,GAAW,EAAE,MAAc;IACjD,OAAO,GAAG,GAAG,MAAM,CAAC;AACrB,CAAC;AAED,SAAS,gBAAgB,CAAC,CAAS,EAAE,CAAS;IAC7C,OAAO,CAAC,GAAG,CAAC,CAAC;AACd,CAAC;AAED,SAAS,oBAAoB,CAAI,KAAQ,EAAE,MAAc;IACxD,OAAO,KAAK,CAAC;AACd,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, oob } from \"@fluidframework/core-utils/internal\";\nimport { BTree } from \"@tylerbu/sorted-btree-es6\";\n\n/**\n * RangeMap represents a mapping from keys of type K to values of type V or undefined.\n * The set of all possible keys is assumed to be fully ordered,\n * and for each key there should be a single next higher key.\n * The values for a range of consecutive keys can be changed or queried in a single operation.\n * The structure of the keys is described by the `offsetKey` and `subtractKeys` functions provided in the constructor.\n */\nexport class RangeMap<K, V> {\n\tprivate tree: BTree<K, RangeEntry<V>>;\n\n\t/**\n\t * @param offsetKey - Function which returns a new key which is `offset` keys after `key`.\n\t * When `offset` is negative, the returned key should come before `key`.\n\t *\n\t * @param subtractKeys - Function which returns the difference between `b` and `a`.\n\t * Offsetting `b` by this difference should return `a`.\n\t * The difference can be infinite if `a` cannot be reached from `b` by offsetting,\n\t * but the difference should still be positive if `a` is larger than `b` and negative if smaller.\n\t *\n\t * @param offsetValue - Function used to associate a range of values with a range of keys.\n\t * When writing to a range of keys starting with `start`, the value of the nth key is interpreted to be\n\t * `offsetValue(firstValue, n - 1)`.\n\t * The same logic should be used when interpreting the values for keys after the first in a\n\t * `RangeQueryResult` or `RangeQueryEntry`.\n\t *\n\t * If `offsetValue` is left unspecified, all keys in a block will be given the same value.\n\t */\n\tpublic constructor(\n\t\tprivate readonly offsetKey: (key: K, offset: number) => K,\n\t\tprivate readonly subtractKeys: (a: K, b: K) => number,\n\t\tpublic readonly offsetValue: (value: V, offset: number) => V = defaultValueOffsetFn,\n\t) {\n\t\tthis.tree = new BTree(undefined, subtractKeys);\n\t}\n\n\t/**\n\t * Retrieves all entries from the RangeMap.\n\t */\n\tpublic entries(): RangeQueryEntry<K, V>[] {\n\t\tconst entries: RangeQueryEntry<K, V>[] = [];\n\t\tfor (const [start, entry] of this.tree.entries()) {\n\t\t\tentries.push({ start, length: entry.length, value: entry.value });\n\t\t}\n\n\t\treturn entries;\n\t}\n\n\tpublic clear(): void {\n\t\tthis.tree.clear();\n\t}\n\n\t/**\n\t * Retrieves the values for all keys in the query range.\n\t *\n\t * @param start - The first key in the range being queried\n\t * @param length - The length of the query range\n\t * @returns A list of entries, each describing the value for some subrange of the query.\n\t * The entries are in the same order as the keys, and there is an entry for every key with a non `undefined` value.\n\t */\n\tpublic getAll(start: K, length: number): RangeQueryEntry<K, V>[] {\n\t\tconst entries = this.getIntersectingEntries(start, length);\n\t\tif (entries.length === 0) {\n\t\t\treturn entries;\n\t\t}\n\n\t\tconst firstEntry = entries[0] ?? oob();\n\t\tconst lengthBefore = this.subtractKeys(start, firstEntry.start);\n\t\tif (lengthBefore > 0) {\n\t\t\tentries[0] = {\n\t\t\t\tstart,\n\t\t\t\tlength: firstEntry.length - lengthBefore,\n\t\t\t\tvalue: this.offsetValue(firstEntry.value, lengthBefore),\n\t\t\t};\n\t\t}\n\n\t\tconst lastEntry = entries[entries.length - 1] ?? oob();\n\t\tconst lastEntryKey = this.offsetKey(lastEntry.start, lastEntry.length - 1);\n\t\tconst lastQueryKey = this.offsetKey(start, length - 1);\n\t\tconst lengthAfter = this.subtractKeys(lastEntryKey, lastQueryKey);\n\t\tif (lengthAfter > 0) {\n\t\t\tentries[entries.length - 1] = { ...lastEntry, length: lastEntry.length - lengthAfter };\n\t\t}\n\n\t\treturn entries;\n\t}\n\n\t/**\n\t * Retrieves the value for some prefix of the query range.\n\t *\n\t * @param start - The first key in the query range.\n\t * @param length - The length of the query range.\n\t * @returns A RangeQueryResult containing the value associated with `start`,\n\t * and the number of consecutive keys with that same value (at least 1, at most `length`).\n\t */\n\tpublic getFirst(start: K, length: number): RangeQueryResult<K, V> {\n\t\t{\n\t\t\t// We first check for an entry with a key less than or equal to `start`.\n\t\t\tconst entry = this.tree.getPairOrNextLower(start);\n\t\t\tif (entry !== undefined) {\n\t\t\t\tconst entryKey = entry[0];\n\t\t\t\tconst { value, length: entryLength } = entry[1];\n\n\t\t\t\tconst entryLastKey = this.offsetKey(entryKey, entryLength - 1);\n\t\t\t\tconst lengthBeforeQuery = this.subtractKeys(start, entryKey);\n\t\t\t\tconst overlappingLength = Math.min(this.subtractKeys(entryLastKey, start) + 1, length);\n\t\t\t\tif (overlappingLength > 0) {\n\t\t\t\t\treturn {\n\t\t\t\t\t\tvalue: this.offsetValue(value, lengthBeforeQuery),\n\t\t\t\t\t\tstart,\n\t\t\t\t\t\tlength: overlappingLength,\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t{\n\t\t\t// There is no value associated with `start`.\n\t\t\t// Now we need to determine how many of the following keys are also undefined.\n\t\t\tconst key = this.tree.nextHigherKey(start);\n\t\t\tif (key !== undefined) {\n\t\t\t\tconst entryKey = key;\n\n\t\t\t\tconst lastQueryKey = this.offsetKey(start, length - 1);\n\t\t\t\tif (this.le(entryKey, lastQueryKey)) {\n\t\t\t\t\treturn { value: undefined, start, length: this.subtractKeys(entryKey, start) };\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn { value: undefined, start, length };\n\t\t}\n\t}\n\n\t/**\n\t * Sets the value for a specified range.\n\t *\n\t * @param start - The first key in the range being set.\n\t * @param length - The length of the range.\n\t * @param value - The value to associate with the range.\n\t */\n\tpublic set(start: K, length: number, value: V | undefined): void {\n\t\tthis.delete(start, length);\n\t\tif (value !== undefined) {\n\t\t\tthis.tree.set(start, { value, length });\n\t\t}\n\t}\n\n\t/**\n\t * Deletes values within a specified range, updating or removing existing entries.\n\t *\n\t * 1. If an entry is completely included in the deletion range, the whole entry will be deleted\n\t * e.g.: map = [[1, 2], [4, 6]], delete range: [3, 6]\n\t * map becomes [[1, 2]] after deletion\n\t * (Note: the notation [a, b] represents start = a, end = b for simpler visualization, instead of `b`\n\t * representing the length)\n\t *\n\t * 2. If an entry is partially overlapped with the deletion range, the start or end point will be shifted\n\t * e.g.: map = [[1, 2], [4, 6]], delete range: [2, 4]\n\t * map becomes [[1, 1], [5, 6]] after deletion\n\t *\n\t * 3. If an entry completely includes the deletion range, the original entry may be split into two.\n\t * e.g.: map = [[1, 6]], delete range: [2, 4]\n\t * map becomes [[1, 1], [5, 6]]\n\t *\n\t * @param start - The start of the range to delete (inclusive).\n\t * @param length - The length of the range to delete.\n\t */\n\tpublic delete(start: K, length: number): void {\n\t\tconst lastDeleteKey = this.offsetKey(start, length - 1);\n\t\tfor (const { start: key, length: entryLength, value } of this.getIntersectingEntries(\n\t\t\tstart,\n\t\t\tlength,\n\t\t)) {\n\t\t\tthis.tree.delete(key);\n\t\t\tconst lengthBefore = this.subtractKeys(start, key);\n\t\t\tif (lengthBefore > 0) {\n\t\t\t\t// A portion of this entry comes before the deletion range, so we reinsert that portion.\n\t\t\t\tthis.tree.set(key, { length: lengthBefore, value });\n\t\t\t}\n\n\t\t\tconst lastEntryKey = this.offsetKey(key, entryLength - 1);\n\t\t\tconst lengthAfter = this.subtractKeys(lastEntryKey, lastDeleteKey);\n\t\t\tif (lengthAfter > 0) {\n\t\t\t\t// A portion of this entry comes after the deletion range, so we reinsert that portion.\n\t\t\t\tconst newKey = this.offsetKey(lastDeleteKey, 1);\n\t\t\t\tconst difference = this.subtractKeys(newKey, key);\n\t\t\t\tthis.tree.set(newKey, {\n\t\t\t\t\tlength: lengthAfter,\n\t\t\t\t\tvalue: this.offsetValue(value, difference),\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic clone(): RangeMap<K, V> {\n\t\tconst cloned = new RangeMap<K, V>(this.offsetKey, this.subtractKeys, this.offsetValue);\n\t\tcloned.tree = this.tree.clone();\n\t\treturn cloned;\n\t}\n\n\t/**\n\t * Returns a new map which contains the entries from both input maps.\n\t */\n\tpublic static union<K, V>(a: RangeMap<K, V>, b: RangeMap<K, V>): RangeMap<K, V> {\n\t\tassert(\n\t\t\ta.offsetKey === b.offsetKey &&\n\t\t\t\ta.subtractKeys === b.subtractKeys &&\n\t\t\t\ta.offsetValue === b.offsetValue,\n\t\t\t0xaae /* Maps should have the same behavior */,\n\t\t);\n\n\t\tconst merged = new RangeMap<K, V>(a.offsetKey, a.subtractKeys, a.offsetValue);\n\n\t\t// TODO: Is there a good pattern that lets us make `tree` readonly?\n\t\tmerged.tree = a.tree.clone();\n\t\tfor (const [key, value] of b.tree.entries()) {\n\t\t\t// TODO: Handle key collisions\n\t\t\tmerged.tree.set(key, value);\n\t\t}\n\n\t\treturn merged;\n\t}\n\n\tprivate getIntersectingEntries(start: K, length: number): RangeQueryEntry<K, V>[] {\n\t\tconst entries: RangeQueryEntry<K, V>[] = [];\n\t\tconst lastQueryKey = this.offsetKey(start, length - 1);\n\t\t{\n\t\t\tconst entry = this.tree.getPairOrNextLower(start);\n\t\t\tif (entry !== undefined) {\n\t\t\t\tconst key = entry[0];\n\t\t\t\tconst { length: entryLength, value } = entry[1];\n\t\t\t\tconst lastEntryKey = this.offsetKey(key, entryLength - 1);\n\t\t\t\tif (this.ge(lastEntryKey, start)) {\n\t\t\t\t\tentries.push({ start: key, length: entryLength, value });\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t{\n\t\t\tlet entry = this.tree.nextHigherPair(start);\n\t\t\twhile (entry !== undefined) {\n\t\t\t\tconst key = entry[0];\n\t\t\t\tif (this.gt(key, lastQueryKey)) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tconst { length: entryLength, value } = entry[1];\n\t\t\t\tconst lastEntryKey = this.offsetKey(key, entryLength - 1);\n\n\t\t\t\tentries.push({ start: key, length: entryLength, value });\n\t\t\t\tentry = this.tree.nextHigherPair(lastEntryKey);\n\t\t\t}\n\t\t}\n\n\t\treturn entries;\n\t}\n\n\tprivate gt(a: K, b: K): boolean {\n\t\treturn this.subtractKeys(a, b) > 0;\n\t}\n\n\tprivate ge(a: K, b: K): boolean {\n\t\treturn this.subtractKeys(a, b) >= 0;\n\t}\n\n\tprivate lt(a: K, b: K): boolean {\n\t\treturn this.subtractKeys(a, b) < 0;\n\t}\n\n\tprivate le(a: K, b: K): boolean {\n\t\treturn this.subtractKeys(a, b) <= 0;\n\t}\n}\n\n/**\n * Represents a contiguous range of values in the RangeMap.\n */\ninterface RangeEntry<V> {\n\t/**\n\t * The length of the range.\n\t */\n\treadonly length: number;\n\n\t/**\n\t * The value associated with this range.\n\t */\n\treadonly value: V;\n}\n\n/**\n * Describes the result of a range query, including the value and length of the matching prefix.\n */\nexport interface RangeQueryResult<K, V> {\n\t/**\n\t * The key for the first element in the range.\n\t */\n\treadonly start: K;\n\n\t/**\n\t * The value of the first key in the query range.\n\t * If no matching range is found, this will be undefined.\n\t */\n\treadonly value: V | undefined;\n\n\t/**\n\t * The length of the prefix of the query range which has the same value.\n\t * For example, if a RangeMap has the same value for keys 5, 6, and 7,\n\t * a query about the range [5, 10] would give a result with length 3.\n\t */\n\treadonly length: number;\n}\n\nexport interface RangeQueryEntry<K, V> extends RangeQueryResult<K, V> {\n\treadonly value: V;\n}\n\nexport function newIntegerRangeMap<V>(): RangeMap<number, V> {\n\treturn new RangeMap(offsetInteger, subtractIntegers);\n}\n\nfunction offsetInteger(key: number, offset: number): number {\n\treturn key + offset;\n}\n\nfunction subtractIntegers(a: number, b: number): number {\n\treturn a - b;\n}\n\nfunction defaultValueOffsetFn<T>(value: T, offset: number): T {\n\treturn value;\n}\n"]}
1
+ {"version":3,"file":"rangeMap.js","sourceRoot":"","sources":["../../src/util/rangeMap.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAAkE;AAClE,gEAAkD;AAElD;;;;;;GAMG;AACH,MAAa,QAAQ;IAGpB;;;;;;;;;;;;;;;;OAgBG;IACH,YACiB,S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,EAClB,WAAmB,EACnB,WAAmB;IAEnB,OAAO,UAAU,GAAG,WAAW,KAAK,WAAW,CAAC;AACjD,CAAC;AAND,4DAMC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, oob } from \"@fluidframework/core-utils/internal\";\nimport { BTree } from \"@tylerbu/sorted-btree-es6\";\n\n/**\n * RangeMap represents a mapping from keys of type K to values of type V or undefined.\n * The set of all possible keys is assumed to be fully ordered,\n * and for each key there should be a single next higher key.\n * The values for a range of consecutive keys can be changed or queried in a single operation.\n * The structure of the keys is described by the `offsetKey` and `subtractKeys` functions provided in the constructor.\n */\nexport class RangeMap<K, V> {\n\tprivate tree: BTree<K, RangeEntry<V>>;\n\n\t/**\n\t * @param offsetKey - Function which returns a new key which is `offset` keys after `key`.\n\t * When `offset` is negative, the returned key should come before `key`.\n\t *\n\t * @param subtractKeys - Function which returns the difference between `b` and `a`.\n\t * Offsetting `b` by this difference should return `a`.\n\t * The difference can be infinite if `a` cannot be reached from `b` by offsetting,\n\t * but the difference should still be positive if `a` is larger than `b` and negative if smaller.\n\t *\n\t * @param offsetValue - Function used to associate a range of values with a range of keys.\n\t * When writing to a range of keys starting with `start`, the value of the nth key is interpreted to be\n\t * `offsetValue(firstValue, n - 1)`.\n\t * The same logic should be used when interpreting the values for keys after the first in a\n\t * `RangeQueryResult` or `RangeQueryEntry`.\n\t *\n\t * If `offsetValue` is left unspecified, all keys in a block will be given the same value.\n\t */\n\tpublic constructor(\n\t\tpublic readonly offsetKey: (key: K, offset: number) => K,\n\t\tpublic readonly subtractKeys: (a: K, b: K) => number,\n\t\tpublic readonly offsetValue: (value: V, offset: number) => V = defaultValueOffsetFn,\n\t) {\n\t\tthis.tree = new BTree(undefined, subtractKeys);\n\t}\n\n\t/**\n\t * Retrieves all entries from the RangeMap.\n\t */\n\tpublic entries(): RangeQueryEntry<K, V>[] {\n\t\tconst entries: RangeQueryEntry<K, V>[] = [];\n\t\tfor (const [start, entry] of this.tree.entries()) {\n\t\t\tentries.push({ start, length: entry.length, value: entry.value });\n\t\t}\n\n\t\treturn entries;\n\t}\n\n\tpublic clear(): void {\n\t\tthis.tree.clear();\n\t}\n\n\t/**\n\t * Retrieves the values for all keys in the query range.\n\t *\n\t * @param start - The first key in the range being queried\n\t * @param length - The length of the query range\n\t * @returns A list of entries, each describing the value for some subrange of the query.\n\t * The entries are in the same order as the keys, and there is an entry for every key with a non `undefined` value.\n\t */\n\tpublic getAll(start: K, length: number): RangeQueryEntry<K, V>[] {\n\t\tconst entries = this.getIntersectingEntries(start, length);\n\t\tif (entries.length === 0) {\n\t\t\treturn entries;\n\t\t}\n\n\t\tconst firstEntry = entries[0] ?? oob();\n\t\tconst lengthBefore = this.subtractKeys(start, firstEntry.start);\n\t\tif (lengthBefore > 0) {\n\t\t\tentries[0] = {\n\t\t\t\tstart,\n\t\t\t\tlength: firstEntry.length - lengthBefore,\n\t\t\t\tvalue: this.offsetValue(firstEntry.value, lengthBefore),\n\t\t\t};\n\t\t}\n\n\t\tconst lastEntry = entries[entries.length - 1] ?? oob();\n\t\tconst lastEntryKey = this.offsetKey(lastEntry.start, lastEntry.length - 1);\n\t\tconst lastQueryKey = this.offsetKey(start, length - 1);\n\t\tconst lengthAfter = this.subtractKeys(lastEntryKey, lastQueryKey);\n\t\tif (lengthAfter > 0) {\n\t\t\tentries[entries.length - 1] = { ...lastEntry, length: lastEntry.length - lengthAfter };\n\t\t}\n\n\t\treturn entries;\n\t}\n\n\t// XXX: Merge with getAll\n\t/**\n\t * Like getAll, but includes entries where the value is undefined.\n\t */\n\tpublic getAll2(start: K, length: number): RangeQueryResultFragment<V | undefined>[] {\n\t\tlet nextKey = start;\n\t\tlet offset = 0;\n\t\tconst result: RangeQueryResultFragment<V | undefined>[] = [];\n\t\tfor (const entry of this.getAll(start, length)) {\n\t\t\tconst lengthBefore = this.subtractKeys(entry.start, nextKey);\n\t\t\tif (lengthBefore > 0) {\n\t\t\t\tresult.push({ offset, length: lengthBefore, value: undefined });\n\t\t\t\toffset += lengthBefore;\n\t\t\t}\n\n\t\t\tresult.push({ offset, length: entry.length, value: entry.value });\n\t\t\tnextKey = this.offsetKey(entry.start, entry.length);\n\t\t\toffset += entry.length;\n\t\t}\n\n\t\tconst lengthRemaining = length - offset;\n\t\tif (lengthRemaining > 0) {\n\t\t\tresult.push({ offset, length: lengthRemaining, value: undefined });\n\t\t}\n\n\t\treturn result;\n\t}\n\n\t/**\n\t * Retrieves the value for some prefix of the query range.\n\t *\n\t * @param start - The first key in the query range.\n\t * @param length - The length of the query range.\n\t * @returns A RangeQueryResult containing the value associated with `start`,\n\t * and the number of consecutive keys with that same value (at least 1, at most `length`).\n\t */\n\tpublic getFirst(start: K, length: number): RangeQueryResult<V | undefined> {\n\t\t{\n\t\t\t// We first check for an entry with a key less than or equal to `start`.\n\t\t\tconst entry = this.tree.getPairOrNextLower(start);\n\t\t\tif (entry !== undefined) {\n\t\t\t\tconst entryKey = entry[0];\n\t\t\t\tconst { value, length: entryLength } = entry[1];\n\n\t\t\t\tconst entryLastKey = this.offsetKey(entryKey, entryLength - 1);\n\t\t\t\tconst lengthBeforeQuery = this.subtractKeys(start, entryKey);\n\t\t\t\tconst overlappingLength = Math.min(this.subtractKeys(entryLastKey, start) + 1, length);\n\t\t\t\tif (overlappingLength > 0) {\n\t\t\t\t\treturn {\n\t\t\t\t\t\tvalue: this.offsetValue(value, lengthBeforeQuery),\n\t\t\t\t\t\tlength: overlappingLength,\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t{\n\t\t\t// There is no value associated with `start`.\n\t\t\t// Now we need to determine how many of the following keys are also undefined.\n\t\t\tconst key = this.tree.nextHigherKey(start);\n\t\t\tif (key !== undefined) {\n\t\t\t\tconst entryKey = key;\n\n\t\t\t\tconst lastQueryKey = this.offsetKey(start, length - 1);\n\t\t\t\tif (this.le(entryKey, lastQueryKey)) {\n\t\t\t\t\treturn { value: undefined, length: this.subtractKeys(entryKey, start) };\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn { value: undefined, length };\n\t\t}\n\t}\n\n\t/**\n\t * Sets the value for a specified range.\n\t *\n\t * @param start - The first key in the range being set.\n\t * @param length - The length of the range.\n\t * @param value - The value to associate with the range.\n\t */\n\tpublic set(start: K, length: number, value: V | undefined): void {\n\t\tthis.delete(start, length);\n\t\tif (value !== undefined) {\n\t\t\tthis.tree.set(start, { value, length });\n\t\t}\n\t}\n\n\t/**\n\t * Deletes values within a specified range, updating or removing existing entries.\n\t *\n\t * 1. If an entry is completely included in the deletion range, the whole entry will be deleted\n\t * e.g.: map = [[1, 2], [4, 6]], delete range: [3, 6]\n\t * map becomes [[1, 2]] after deletion\n\t * (Note: the notation [a, b] represents start = a, end = b for simpler visualization, instead of `b`\n\t * representing the length)\n\t *\n\t * 2. If an entry is partially overlapped with the deletion range, the start or end point will be shifted\n\t * e.g.: map = [[1, 2], [4, 6]], delete range: [2, 4]\n\t * map becomes [[1, 1], [5, 6]] after deletion\n\t *\n\t * 3. If an entry completely includes the deletion range, the original entry may be split into two.\n\t * e.g.: map = [[1, 6]], delete range: [2, 4]\n\t * map becomes [[1, 1], [5, 6]]\n\t *\n\t * @param start - The start of the range to delete (inclusive).\n\t * @param length - The length of the range to delete.\n\t * @returns The number of entries deleted.\n\t */\n\tpublic delete(start: K, length: number): number {\n\t\tlet deleteCount = 0;\n\t\tconst lastDeleteKey = this.offsetKey(start, length - 1);\n\t\tfor (const { start: key, length: entryLength, value } of this.getIntersectingEntries(\n\t\t\tstart,\n\t\t\tlength,\n\t\t)) {\n\t\t\tdeleteCount += entryLength;\n\t\t\tthis.tree.delete(key);\n\t\t\tconst lengthBefore = this.subtractKeys(start, key);\n\t\t\tif (lengthBefore > 0) {\n\t\t\t\t// A portion of this entry comes before the deletion range, so we reinsert that portion.\n\t\t\t\tthis.tree.set(key, { length: lengthBefore, value });\n\t\t\t\tdeleteCount -= lengthBefore;\n\t\t\t}\n\n\t\t\tconst lastEntryKey = this.offsetKey(key, entryLength - 1);\n\t\t\tconst lengthAfter = this.subtractKeys(lastEntryKey, lastDeleteKey);\n\t\t\tif (lengthAfter > 0) {\n\t\t\t\t// A portion of this entry comes after the deletion range, so we reinsert that portion.\n\t\t\t\tconst newKey = this.offsetKey(lastDeleteKey, 1);\n\t\t\t\tconst difference = this.subtractKeys(newKey, key);\n\t\t\t\tthis.tree.set(newKey, {\n\t\t\t\t\tlength: lengthAfter,\n\t\t\t\t\tvalue: this.offsetValue(value, difference),\n\t\t\t\t});\n\t\t\t\tdeleteCount -= lengthAfter;\n\t\t\t}\n\t\t}\n\t\treturn deleteCount;\n\t}\n\n\tpublic clone(): RangeMap<K, V> {\n\t\tconst cloned = new RangeMap<K, V>(this.offsetKey, this.subtractKeys, this.offsetValue);\n\t\tcloned.tree = this.tree.clone();\n\t\treturn cloned;\n\t}\n\n\tpublic mapEntries(mapKey: (key: K) => K, mapValue: (value: V) => V): RangeMap<K, V> {\n\t\tconst result = new RangeMap<K, V>(this.offsetKey, this.subtractKeys, this.offsetValue);\n\t\tfor (const entry of this.entries()) {\n\t\t\tresult.set(mapKey(entry.start), entry.length, mapValue(entry.value));\n\t\t}\n\t\treturn result;\n\t}\n\n\t/**\n\t * Returns a new map which contains the entries from both input maps.\n\t */\n\tpublic static union<K, V>(a: RangeMap<K, V>, b: RangeMap<K, V>): RangeMap<K, V> {\n\t\tassert(\n\t\t\ta.offsetKey === b.offsetKey &&\n\t\t\t\ta.subtractKeys === b.subtractKeys &&\n\t\t\t\ta.offsetValue === b.offsetValue,\n\t\t\t0xaae /* Maps should have the same behavior */,\n\t\t);\n\n\t\tconst merged = new RangeMap<K, V>(a.offsetKey, a.subtractKeys, a.offsetValue);\n\n\t\t// TODO: Is there a good pattern that lets us make `tree` readonly?\n\t\tmerged.tree = a.tree.clone();\n\t\tfor (const entry of b.entries()) {\n\t\t\t// TODO: Handle key collisions\n\t\t\tmerged.set(entry.start, entry.length, entry.value);\n\t\t}\n\n\t\treturn merged;\n\t}\n\n\tprivate getIntersectingEntries(start: K, length: number): RangeQueryEntry<K, V>[] {\n\t\tconst entries: RangeQueryEntry<K, V>[] = [];\n\t\tconst lastQueryKey = this.offsetKey(start, length - 1);\n\t\t{\n\t\t\tconst entry = this.tree.getPairOrNextLower(start);\n\t\t\tif (entry !== undefined) {\n\t\t\t\tconst key = entry[0];\n\t\t\t\tconst { length: entryLength, value } = entry[1];\n\t\t\t\tconst lastEntryKey = this.offsetKey(key, entryLength - 1);\n\t\t\t\tif (this.ge(lastEntryKey, start)) {\n\t\t\t\t\tentries.push({ start: key, length: entryLength, value });\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t{\n\t\t\tlet entry = this.tree.nextHigherPair(start);\n\t\t\twhile (entry !== undefined) {\n\t\t\t\tconst key = entry[0];\n\t\t\t\tif (this.gt(key, lastQueryKey)) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tconst { length: entryLength, value } = entry[1];\n\t\t\t\tconst lastEntryKey = this.offsetKey(key, entryLength - 1);\n\n\t\t\t\tentries.push({ start: key, length: entryLength, value });\n\t\t\t\tentry = this.tree.nextHigherPair(lastEntryKey);\n\t\t\t}\n\t\t}\n\n\t\treturn entries;\n\t}\n\n\tprivate gt(a: K, b: K): boolean {\n\t\treturn this.subtractKeys(a, b) > 0;\n\t}\n\n\tprivate ge(a: K, b: K): boolean {\n\t\treturn this.subtractKeys(a, b) >= 0;\n\t}\n\n\tprivate lt(a: K, b: K): boolean {\n\t\treturn this.subtractKeys(a, b) < 0;\n\t}\n\n\tprivate le(a: K, b: K): boolean {\n\t\treturn this.subtractKeys(a, b) <= 0;\n\t}\n}\n\n/**\n * Represents a contiguous range of values in the RangeMap.\n */\ninterface RangeEntry<V> {\n\t/**\n\t * The length of the range.\n\t */\n\treadonly length: number;\n\n\t/**\n\t * The value associated with this range.\n\t */\n\treadonly value: V;\n}\n\n/**\n * Describes the result of a range query, including the value and length of the matching prefix.\n */\nexport interface RangeQueryResult<V> {\n\t/**\n\t * The value of the first key in the query range.\n\t */\n\treadonly value: V;\n\n\t/**\n\t * The length of the prefix of the query range which has the same value.\n\t * For example, if a RangeMap has the same value for keys 5, 6, and 7,\n\t * a query about the range [5, 10] would give a result with length 3.\n\t */\n\treadonly length: number;\n}\n\nexport interface RangeQueryResultFragment<V> extends RangeQueryResult<V> {\n\t/**\n\t * The offset from the query key to the key this result is associated with.\n\t * This is useful in the case where a query returns multiple `RangeQueryResults`\n\t * addressing the key range.\n\t */\n\treadonly offset: number;\n}\n\nexport interface RangeQueryEntry<K, V> {\n\treadonly start: K;\n\treadonly value: V;\n\treadonly length: number;\n}\n\nexport function newIntegerRangeMap<V>(): RangeMap<number, V> {\n\treturn new RangeMap(offsetInteger, subtractIntegers);\n}\n\nfunction offsetInteger(key: number, offset: number): number {\n\treturn key + offset;\n}\n\nfunction subtractIntegers(a: number, b: number): number {\n\treturn a - b;\n}\n\nfunction defaultValueOffsetFn<T>(value: T, offset: number): T {\n\treturn value;\n}\n\nexport function areAdjacentIntegerRanges(\n\tfirstStart: number,\n\tfirstLength: number,\n\tsecondStart: number,\n): boolean {\n\treturn firstStart + firstLength === secondStart;\n}\n"]}