@fluidframework/tree 2.74.0 → 2.80.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (895) hide show
  1. package/.eslintrc.cjs +1 -16
  2. package/CHANGELOG.md +18 -0
  3. package/api-report/tree.alpha.api.md +20 -2
  4. package/dist/alpha.d.ts +4 -0
  5. package/dist/codec/codec.d.ts +31 -3
  6. package/dist/codec/codec.d.ts.map +1 -1
  7. package/dist/codec/codec.js +10 -0
  8. package/dist/codec/codec.js.map +1 -1
  9. package/dist/codec/index.d.ts +2 -2
  10. package/dist/codec/index.d.ts.map +1 -1
  11. package/dist/codec/index.js +2 -2
  12. package/dist/codec/index.js.map +1 -1
  13. package/dist/codec/versioned/codec.d.ts +80 -22
  14. package/dist/codec/versioned/codec.d.ts.map +1 -1
  15. package/dist/codec/versioned/codec.js +137 -15
  16. package/dist/codec/versioned/codec.js.map +1 -1
  17. package/dist/codec/versioned/index.d.ts +1 -1
  18. package/dist/codec/versioned/index.d.ts.map +1 -1
  19. package/dist/codec/versioned/index.js +2 -2
  20. package/dist/codec/versioned/index.js.map +1 -1
  21. package/dist/core/index.d.ts +2 -2
  22. package/dist/core/index.d.ts.map +1 -1
  23. package/dist/core/index.js +3 -4
  24. package/dist/core/index.js.map +1 -1
  25. package/dist/core/rebase/changeRebaser.d.ts +36 -2
  26. package/dist/core/rebase/changeRebaser.d.ts.map +1 -1
  27. package/dist/core/rebase/changeRebaser.js.map +1 -1
  28. package/dist/core/rebase/index.d.ts +2 -2
  29. package/dist/core/rebase/index.d.ts.map +1 -1
  30. package/dist/core/rebase/index.js +1 -2
  31. package/dist/core/rebase/index.js.map +1 -1
  32. package/dist/core/rebase/types.d.ts +6 -2
  33. package/dist/core/rebase/types.d.ts.map +1 -1
  34. package/dist/core/rebase/types.js +1 -12
  35. package/dist/core/rebase/types.js.map +1 -1
  36. package/dist/core/rebase/utils.js +3 -3
  37. package/dist/core/rebase/utils.js.map +1 -1
  38. package/dist/core/schema-stored/schema.js +3 -3
  39. package/dist/core/schema-stored/schema.js.map +1 -1
  40. package/dist/core/tree/anchorSet.d.ts.map +1 -1
  41. package/dist/core/tree/anchorSet.js +3 -4
  42. package/dist/core/tree/anchorSet.js.map +1 -1
  43. package/dist/core/tree/detachedFieldIndex.d.ts +1 -2
  44. package/dist/core/tree/detachedFieldIndex.d.ts.map +1 -1
  45. package/dist/core/tree/detachedFieldIndex.js +12 -56
  46. package/dist/core/tree/detachedFieldIndex.js.map +1 -1
  47. package/dist/core/tree/detachedFieldIndexCodecCommon.d.ts +18 -10
  48. package/dist/core/tree/detachedFieldIndexCodecCommon.d.ts.map +1 -1
  49. package/dist/core/tree/detachedFieldIndexCodecCommon.js +6 -6
  50. package/dist/core/tree/detachedFieldIndexCodecCommon.js.map +1 -1
  51. package/dist/core/tree/detachedFieldIndexCodecV1.d.ts +2 -3
  52. package/dist/core/tree/detachedFieldIndexCodecV1.d.ts.map +1 -1
  53. package/dist/core/tree/detachedFieldIndexCodecV1.js +4 -5
  54. package/dist/core/tree/detachedFieldIndexCodecV1.js.map +1 -1
  55. package/dist/core/tree/detachedFieldIndexCodecV2.d.ts +2 -3
  56. package/dist/core/tree/detachedFieldIndexCodecV2.d.ts.map +1 -1
  57. package/dist/core/tree/detachedFieldIndexCodecV2.js +4 -6
  58. package/dist/core/tree/detachedFieldIndexCodecV2.js.map +1 -1
  59. package/dist/core/tree/detachedFieldIndexCodecs.d.ts +5 -6
  60. package/dist/core/tree/detachedFieldIndexCodecs.d.ts.map +1 -1
  61. package/dist/core/tree/detachedFieldIndexCodecs.js +11 -41
  62. package/dist/core/tree/detachedFieldIndexCodecs.js.map +1 -1
  63. package/dist/core/tree/index.d.ts +1 -1
  64. package/dist/core/tree/index.d.ts.map +1 -1
  65. package/dist/core/tree/index.js +2 -2
  66. package/dist/core/tree/index.js.map +1 -1
  67. package/dist/core/tree/mapTree.js +1 -1
  68. package/dist/core/tree/mapTree.js.map +1 -1
  69. package/dist/core/tree/sparseTree.d.ts.map +1 -1
  70. package/dist/core/tree/sparseTree.js +1 -0
  71. package/dist/core/tree/sparseTree.js.map +1 -1
  72. package/dist/core/tree/treeTextFormat.d.ts.map +1 -1
  73. package/dist/core/tree/treeTextFormat.js +5 -9
  74. package/dist/core/tree/treeTextFormat.js.map +1 -1
  75. package/dist/feature-libraries/changeAtomIdBTree.d.ts +10 -0
  76. package/dist/feature-libraries/changeAtomIdBTree.d.ts.map +1 -0
  77. package/dist/feature-libraries/changeAtomIdBTree.js +16 -0
  78. package/dist/feature-libraries/changeAtomIdBTree.js.map +1 -0
  79. package/dist/feature-libraries/chunked-forest/basicChunk.js +1 -1
  80. package/dist/feature-libraries/chunked-forest/basicChunk.js.map +1 -1
  81. package/dist/feature-libraries/chunked-forest/chunkedForest.js +6 -6
  82. package/dist/feature-libraries/chunked-forest/chunkedForest.js.map +1 -1
  83. package/dist/feature-libraries/chunked-forest/codec/chunkDecoding.d.ts.map +1 -1
  84. package/dist/feature-libraries/chunked-forest/codec/chunkDecoding.js +7 -4
  85. package/dist/feature-libraries/chunked-forest/codec/chunkDecoding.js.map +1 -1
  86. package/dist/feature-libraries/chunked-forest/codec/codecs.d.ts.map +1 -1
  87. package/dist/feature-libraries/chunked-forest/codec/codecs.js +19 -11
  88. package/dist/feature-libraries/chunked-forest/codec/codecs.js.map +1 -1
  89. package/dist/feature-libraries/chunked-forest/codec/compressedEncode.js +3 -3
  90. package/dist/feature-libraries/chunked-forest/codec/compressedEncode.js.map +1 -1
  91. package/dist/feature-libraries/chunked-forest/codec/schemaBasedEncode.js +9 -5
  92. package/dist/feature-libraries/chunked-forest/codec/schemaBasedEncode.js.map +1 -1
  93. package/dist/feature-libraries/chunked-forest/uniformChunk.js +1 -1
  94. package/dist/feature-libraries/chunked-forest/uniformChunk.js.map +1 -1
  95. package/dist/feature-libraries/default-schema/defaultEditBuilder.d.ts +15 -5
  96. package/dist/feature-libraries/default-schema/defaultEditBuilder.d.ts.map +1 -1
  97. package/dist/feature-libraries/default-schema/defaultEditBuilder.js +19 -14
  98. package/dist/feature-libraries/default-schema/defaultEditBuilder.js.map +1 -1
  99. package/dist/feature-libraries/default-schema/defaultFieldKinds.d.ts +1 -1
  100. package/dist/feature-libraries/default-schema/defaultFieldKinds.d.ts.map +1 -1
  101. package/dist/feature-libraries/default-schema/defaultFieldKinds.js +11 -1
  102. package/dist/feature-libraries/default-schema/defaultFieldKinds.js.map +1 -1
  103. package/dist/feature-libraries/default-schema/mappedEditBuilder.d.ts +2 -0
  104. package/dist/feature-libraries/default-schema/mappedEditBuilder.d.ts.map +1 -1
  105. package/dist/feature-libraries/default-schema/mappedEditBuilder.js +6 -0
  106. package/dist/feature-libraries/default-schema/mappedEditBuilder.js.map +1 -1
  107. package/dist/feature-libraries/flex-tree/lazyField.d.ts.map +1 -1
  108. package/dist/feature-libraries/flex-tree/lazyField.js +11 -13
  109. package/dist/feature-libraries/flex-tree/lazyField.js.map +1 -1
  110. package/dist/feature-libraries/index.d.ts +3 -2
  111. package/dist/feature-libraries/index.d.ts.map +1 -1
  112. package/dist/feature-libraries/index.js +9 -7
  113. package/dist/feature-libraries/index.js.map +1 -1
  114. package/dist/feature-libraries/indexing/anchorTreeIndex.js +6 -6
  115. package/dist/feature-libraries/indexing/anchorTreeIndex.js.map +1 -1
  116. package/dist/feature-libraries/mitigatedChangeFamily.d.ts.map +1 -1
  117. package/dist/feature-libraries/mitigatedChangeFamily.js +10 -1
  118. package/dist/feature-libraries/mitigatedChangeFamily.js.map +1 -1
  119. package/dist/feature-libraries/modular-schema/comparison.d.ts.map +1 -1
  120. package/dist/feature-libraries/modular-schema/comparison.js +12 -9
  121. package/dist/feature-libraries/modular-schema/comparison.js.map +1 -1
  122. package/dist/feature-libraries/modular-schema/defaultRevisionReplacer.d.ts +25 -0
  123. package/dist/feature-libraries/modular-schema/defaultRevisionReplacer.d.ts.map +1 -0
  124. package/dist/feature-libraries/modular-schema/defaultRevisionReplacer.js +59 -0
  125. package/dist/feature-libraries/modular-schema/defaultRevisionReplacer.js.map +1 -0
  126. package/dist/feature-libraries/modular-schema/fieldChangeHandler.d.ts +3 -3
  127. package/dist/feature-libraries/modular-schema/fieldChangeHandler.d.ts.map +1 -1
  128. package/dist/feature-libraries/modular-schema/fieldChangeHandler.js.map +1 -1
  129. package/dist/feature-libraries/modular-schema/genericFieldKind.d.ts.map +1 -1
  130. package/dist/feature-libraries/modular-schema/genericFieldKind.js +4 -4
  131. package/dist/feature-libraries/modular-schema/genericFieldKind.js.map +1 -1
  132. package/dist/feature-libraries/modular-schema/genericFieldKindCodecs.js +2 -2
  133. package/dist/feature-libraries/modular-schema/genericFieldKindCodecs.js.map +1 -1
  134. package/dist/feature-libraries/modular-schema/index.d.ts +4 -2
  135. package/dist/feature-libraries/modular-schema/index.d.ts.map +1 -1
  136. package/dist/feature-libraries/modular-schema/index.js +11 -7
  137. package/dist/feature-libraries/modular-schema/index.js.map +1 -1
  138. package/dist/feature-libraries/modular-schema/modularChangeCodecV1.d.ts +49 -0
  139. package/dist/feature-libraries/modular-schema/modularChangeCodecV1.d.ts.map +1 -0
  140. package/dist/feature-libraries/modular-schema/modularChangeCodecV1.js +315 -0
  141. package/dist/feature-libraries/modular-schema/modularChangeCodecV1.js.map +1 -0
  142. package/dist/feature-libraries/modular-schema/modularChangeCodecV2.d.ts +15 -0
  143. package/dist/feature-libraries/modular-schema/modularChangeCodecV2.d.ts.map +1 -0
  144. package/dist/feature-libraries/modular-schema/modularChangeCodecV2.js +31 -0
  145. package/dist/feature-libraries/modular-schema/modularChangeCodecV2.js.map +1 -0
  146. package/dist/feature-libraries/modular-schema/modularChangeCodecs.d.ts +2 -2
  147. package/dist/feature-libraries/modular-schema/modularChangeCodecs.d.ts.map +1 -1
  148. package/dist/feature-libraries/modular-schema/modularChangeCodecs.js +25 -288
  149. package/dist/feature-libraries/modular-schema/modularChangeCodecs.js.map +1 -1
  150. package/dist/feature-libraries/modular-schema/modularChangeFamily.d.ts +14 -8
  151. package/dist/feature-libraries/modular-schema/modularChangeFamily.d.ts.map +1 -1
  152. package/dist/feature-libraries/modular-schema/modularChangeFamily.js +225 -195
  153. package/dist/feature-libraries/modular-schema/modularChangeFamily.js.map +1 -1
  154. package/dist/feature-libraries/modular-schema/{modularChangeFormat.d.ts → modularChangeFormatV1.d.ts} +5 -6
  155. package/dist/feature-libraries/modular-schema/modularChangeFormatV1.d.ts.map +1 -0
  156. package/dist/feature-libraries/modular-schema/{modularChangeFormat.js → modularChangeFormatV1.js} +7 -7
  157. package/dist/feature-libraries/modular-schema/modularChangeFormatV1.js.map +1 -0
  158. package/dist/feature-libraries/modular-schema/modularChangeFormatV2.d.ts +112 -0
  159. package/dist/feature-libraries/modular-schema/modularChangeFormatV2.d.ts.map +1 -0
  160. package/dist/feature-libraries/modular-schema/modularChangeFormatV2.js +21 -0
  161. package/dist/feature-libraries/modular-schema/modularChangeFormatV2.js.map +1 -0
  162. package/dist/feature-libraries/modular-schema/modularChangeTypes.d.ts +13 -3
  163. package/dist/feature-libraries/modular-schema/modularChangeTypes.d.ts.map +1 -1
  164. package/dist/feature-libraries/modular-schema/modularChangeTypes.js.map +1 -1
  165. package/dist/feature-libraries/node-identifier/mockNodeIdentifierManager.js +1 -1
  166. package/dist/feature-libraries/node-identifier/mockNodeIdentifierManager.js.map +1 -1
  167. package/dist/feature-libraries/object-forest/objectForest.js +4 -4
  168. package/dist/feature-libraries/object-forest/objectForest.js.map +1 -1
  169. package/dist/feature-libraries/optional-field/optionalField.d.ts.map +1 -1
  170. package/dist/feature-libraries/optional-field/optionalField.js +34 -39
  171. package/dist/feature-libraries/optional-field/optionalField.js.map +1 -1
  172. package/dist/feature-libraries/schema-edits/schemaChangeCodecs.d.ts.map +1 -1
  173. package/dist/feature-libraries/schema-edits/schemaChangeCodecs.js +14 -2
  174. package/dist/feature-libraries/schema-edits/schemaChangeCodecs.js.map +1 -1
  175. package/dist/feature-libraries/schema-index/codec.d.ts +7 -21
  176. package/dist/feature-libraries/schema-index/codec.d.ts.map +1 -1
  177. package/dist/feature-libraries/schema-index/codec.js +28 -70
  178. package/dist/feature-libraries/schema-index/codec.js.map +1 -1
  179. package/dist/feature-libraries/schema-index/index.d.ts +2 -2
  180. package/dist/feature-libraries/schema-index/index.d.ts.map +1 -1
  181. package/dist/feature-libraries/schema-index/index.js +2 -5
  182. package/dist/feature-libraries/schema-index/index.js.map +1 -1
  183. package/dist/feature-libraries/schema-index/schemaSummarizer.d.ts +1 -9
  184. package/dist/feature-libraries/schema-index/schemaSummarizer.d.ts.map +1 -1
  185. package/dist/feature-libraries/schema-index/schemaSummarizer.js +1 -12
  186. package/dist/feature-libraries/schema-index/schemaSummarizer.js.map +1 -1
  187. package/dist/feature-libraries/schemaChecker.d.ts.map +1 -1
  188. package/dist/feature-libraries/schemaChecker.js +11 -6
  189. package/dist/feature-libraries/schemaChecker.js.map +1 -1
  190. package/dist/feature-libraries/sequence-field/compose.d.ts.map +1 -1
  191. package/dist/feature-libraries/sequence-field/compose.js +17 -13
  192. package/dist/feature-libraries/sequence-field/compose.js.map +1 -1
  193. package/dist/feature-libraries/sequence-field/invert.js +5 -4
  194. package/dist/feature-libraries/sequence-field/invert.js.map +1 -1
  195. package/dist/feature-libraries/sequence-field/moveEffectTable.d.ts.map +1 -1
  196. package/dist/feature-libraries/sequence-field/moveEffectTable.js +15 -9
  197. package/dist/feature-libraries/sequence-field/moveEffectTable.js.map +1 -1
  198. package/dist/feature-libraries/sequence-field/rebase.js +26 -18
  199. package/dist/feature-libraries/sequence-field/rebase.js.map +1 -1
  200. package/dist/feature-libraries/sequence-field/replaceRevisions.d.ts +2 -2
  201. package/dist/feature-libraries/sequence-field/replaceRevisions.d.ts.map +1 -1
  202. package/dist/feature-libraries/sequence-field/replaceRevisions.js +40 -35
  203. package/dist/feature-libraries/sequence-field/replaceRevisions.js.map +1 -1
  204. package/dist/feature-libraries/sequence-field/sequenceFieldCodecV2.d.ts.map +1 -1
  205. package/dist/feature-libraries/sequence-field/sequenceFieldCodecV2.js +16 -8
  206. package/dist/feature-libraries/sequence-field/sequenceFieldCodecV2.js.map +1 -1
  207. package/dist/feature-libraries/sequence-field/sequenceFieldCodecV3.d.ts.map +1 -1
  208. package/dist/feature-libraries/sequence-field/sequenceFieldCodecV3.js +4 -2
  209. package/dist/feature-libraries/sequence-field/sequenceFieldCodecV3.js.map +1 -1
  210. package/dist/feature-libraries/sequence-field/sequenceFieldToDelta.d.ts.map +1 -1
  211. package/dist/feature-libraries/sequence-field/sequenceFieldToDelta.js +6 -3
  212. package/dist/feature-libraries/sequence-field/sequenceFieldToDelta.js.map +1 -1
  213. package/dist/feature-libraries/sequence-field/utils.d.ts.map +1 -1
  214. package/dist/feature-libraries/sequence-field/utils.js +46 -27
  215. package/dist/feature-libraries/sequence-field/utils.js.map +1 -1
  216. package/dist/feature-libraries/treeCursorUtils.js +7 -7
  217. package/dist/feature-libraries/treeCursorUtils.js.map +1 -1
  218. package/dist/feature-libraries/treeTextCursor.js +2 -2
  219. package/dist/feature-libraries/treeTextCursor.js.map +1 -1
  220. package/dist/feature-libraries/valueUtilities.d.ts.map +1 -1
  221. package/dist/feature-libraries/valueUtilities.js +16 -8
  222. package/dist/feature-libraries/valueUtilities.js.map +1 -1
  223. package/dist/index.d.ts +2 -2
  224. package/dist/index.d.ts.map +1 -1
  225. package/dist/index.js.map +1 -1
  226. package/dist/packageVersion.d.ts +1 -1
  227. package/dist/packageVersion.js +1 -1
  228. package/dist/packageVersion.js.map +1 -1
  229. package/dist/shared-tree/schematizingTreeView.d.ts +2 -3
  230. package/dist/shared-tree/schematizingTreeView.d.ts.map +1 -1
  231. package/dist/shared-tree/schematizingTreeView.js +20 -9
  232. package/dist/shared-tree/schematizingTreeView.js.map +1 -1
  233. package/dist/shared-tree/sharedTree.d.ts.map +1 -1
  234. package/dist/shared-tree/sharedTree.js +61 -44
  235. package/dist/shared-tree/sharedTree.js.map +1 -1
  236. package/dist/shared-tree/sharedTreeChangeCodecs.d.ts +1 -1
  237. package/dist/shared-tree/sharedTreeChangeCodecs.d.ts.map +1 -1
  238. package/dist/shared-tree/sharedTreeChangeCodecs.js +9 -8
  239. package/dist/shared-tree/sharedTreeChangeCodecs.js.map +1 -1
  240. package/dist/shared-tree/sharedTreeChangeEnricher.d.ts.map +1 -1
  241. package/dist/shared-tree/sharedTreeChangeEnricher.js +4 -2
  242. package/dist/shared-tree/sharedTreeChangeEnricher.js.map +1 -1
  243. package/dist/shared-tree/sharedTreeChangeFamily.d.ts +3 -2
  244. package/dist/shared-tree/sharedTreeChangeFamily.d.ts.map +1 -1
  245. package/dist/shared-tree/sharedTreeChangeFamily.js +19 -14
  246. package/dist/shared-tree/sharedTreeChangeFamily.js.map +1 -1
  247. package/dist/shared-tree/sharedTreeEditBuilder.d.ts.map +1 -1
  248. package/dist/shared-tree/sharedTreeEditBuilder.js +1 -1
  249. package/dist/shared-tree/sharedTreeEditBuilder.js.map +1 -1
  250. package/dist/shared-tree/treeAlpha.d.ts +35 -29
  251. package/dist/shared-tree/treeAlpha.d.ts.map +1 -1
  252. package/dist/shared-tree/treeAlpha.js +21 -23
  253. package/dist/shared-tree/treeAlpha.js.map +1 -1
  254. package/dist/shared-tree/treeCheckout.d.ts +2 -0
  255. package/dist/shared-tree/treeCheckout.d.ts.map +1 -1
  256. package/dist/shared-tree/treeCheckout.js +31 -18
  257. package/dist/shared-tree/treeCheckout.js.map +1 -1
  258. package/dist/shared-tree-core/branch.d.ts +3 -1
  259. package/dist/shared-tree-core/branch.d.ts.map +1 -1
  260. package/dist/shared-tree-core/branch.js +5 -3
  261. package/dist/shared-tree-core/branch.js.map +1 -1
  262. package/dist/shared-tree-core/branchCommitEnricher.d.ts.map +1 -1
  263. package/dist/shared-tree-core/branchCommitEnricher.js +1 -1
  264. package/dist/shared-tree-core/branchCommitEnricher.js.map +1 -1
  265. package/dist/shared-tree-core/editManager.js +1 -1
  266. package/dist/shared-tree-core/editManager.js.map +1 -1
  267. package/dist/shared-tree-core/editManagerCodecs.d.ts.map +1 -1
  268. package/dist/shared-tree-core/editManagerCodecs.js +9 -4
  269. package/dist/shared-tree-core/editManagerCodecs.js.map +1 -1
  270. package/dist/shared-tree-core/editManagerFormatCommons.d.ts +1 -0
  271. package/dist/shared-tree-core/editManagerFormatCommons.d.ts.map +1 -1
  272. package/dist/shared-tree-core/editManagerFormatCommons.js +6 -0
  273. package/dist/shared-tree-core/editManagerFormatCommons.js.map +1 -1
  274. package/dist/shared-tree-core/editManagerFormatV1toV4.d.ts +2 -2
  275. package/dist/shared-tree-core/editManagerFormatV1toV4.d.ts.map +1 -1
  276. package/dist/shared-tree-core/editManagerFormatV1toV4.js +1 -0
  277. package/dist/shared-tree-core/editManagerFormatV1toV4.js.map +1 -1
  278. package/dist/shared-tree-core/editManagerSummarizer.js +3 -3
  279. package/dist/shared-tree-core/editManagerSummarizer.js.map +1 -1
  280. package/dist/shared-tree-core/messageCodecV1ToV4.d.ts +1 -1
  281. package/dist/shared-tree-core/messageCodecV1ToV4.d.ts.map +1 -1
  282. package/dist/shared-tree-core/messageCodecV1ToV4.js.map +1 -1
  283. package/dist/shared-tree-core/messageCodecVSharedBranches.d.ts.map +1 -1
  284. package/dist/shared-tree-core/messageCodecVSharedBranches.js +2 -1
  285. package/dist/shared-tree-core/messageCodecVSharedBranches.js.map +1 -1
  286. package/dist/shared-tree-core/messageCodecs.d.ts.map +1 -1
  287. package/dist/shared-tree-core/messageCodecs.js +8 -4
  288. package/dist/shared-tree-core/messageCodecs.js.map +1 -1
  289. package/dist/shared-tree-core/messageFormat.d.ts +1 -0
  290. package/dist/shared-tree-core/messageFormat.d.ts.map +1 -1
  291. package/dist/shared-tree-core/messageFormat.js +6 -0
  292. package/dist/shared-tree-core/messageFormat.js.map +1 -1
  293. package/dist/shared-tree-core/messageFormatV1ToV4.d.ts +3 -2
  294. package/dist/shared-tree-core/messageFormatV1ToV4.d.ts.map +1 -1
  295. package/dist/shared-tree-core/messageFormatV1ToV4.js +8 -1
  296. package/dist/shared-tree-core/messageFormatV1ToV4.js.map +1 -1
  297. package/dist/shared-tree-core/sequenceIdUtils.d.ts.map +1 -1
  298. package/dist/shared-tree-core/sequenceIdUtils.js +4 -4
  299. package/dist/shared-tree-core/sequenceIdUtils.js.map +1 -1
  300. package/dist/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
  301. package/dist/shared-tree-core/sharedTreeCore.js +12 -8
  302. package/dist/shared-tree-core/sharedTreeCore.js.map +1 -1
  303. package/dist/shared-tree-core/transaction.d.ts +25 -8
  304. package/dist/shared-tree-core/transaction.d.ts.map +1 -1
  305. package/dist/shared-tree-core/transaction.js +65 -30
  306. package/dist/shared-tree-core/transaction.js.map +1 -1
  307. package/dist/shared-tree-core/transactionEnricher.d.ts +2 -2
  308. package/dist/shared-tree-core/transactionEnricher.d.ts.map +1 -1
  309. package/dist/shared-tree-core/transactionEnricher.js +3 -3
  310. package/dist/shared-tree-core/transactionEnricher.js.map +1 -1
  311. package/dist/simple-tree/api/configuration.js +1 -1
  312. package/dist/simple-tree/api/configuration.js.map +1 -1
  313. package/dist/simple-tree/api/customTree.d.ts.map +1 -1
  314. package/dist/simple-tree/api/customTree.js +13 -9
  315. package/dist/simple-tree/api/customTree.js.map +1 -1
  316. package/dist/simple-tree/api/discrepancies.d.ts.map +1 -1
  317. package/dist/simple-tree/api/discrepancies.js +21 -17
  318. package/dist/simple-tree/api/discrepancies.js.map +1 -1
  319. package/dist/simple-tree/api/index.d.ts +1 -1
  320. package/dist/simple-tree/api/index.d.ts.map +1 -1
  321. package/dist/simple-tree/api/index.js.map +1 -1
  322. package/dist/simple-tree/api/schemaFactory.d.ts.map +1 -1
  323. package/dist/simple-tree/api/schemaFactory.js +12 -8
  324. package/dist/simple-tree/api/schemaFactory.js.map +1 -1
  325. package/dist/simple-tree/api/schemaFromSimple.js +18 -9
  326. package/dist/simple-tree/api/schemaFromSimple.js.map +1 -1
  327. package/dist/simple-tree/api/simpleSchemaCodec.js +10 -5
  328. package/dist/simple-tree/api/simpleSchemaCodec.js.map +1 -1
  329. package/dist/simple-tree/api/simpleSchemaToJsonSchema.d.ts.map +1 -1
  330. package/dist/simple-tree/api/simpleSchemaToJsonSchema.js +15 -11
  331. package/dist/simple-tree/api/simpleSchemaToJsonSchema.js.map +1 -1
  332. package/dist/simple-tree/api/simpleTreeIndex.js +10 -10
  333. package/dist/simple-tree/api/simpleTreeIndex.js.map +1 -1
  334. package/dist/simple-tree/api/storedSchema.d.ts.map +1 -1
  335. package/dist/simple-tree/api/storedSchema.js +2 -3
  336. package/dist/simple-tree/api/storedSchema.js.map +1 -1
  337. package/dist/simple-tree/api/transactionTypes.d.ts +17 -4
  338. package/dist/simple-tree/api/transactionTypes.d.ts.map +1 -1
  339. package/dist/simple-tree/api/transactionTypes.js.map +1 -1
  340. package/dist/simple-tree/api/treeNodeApi.d.ts.map +1 -1
  341. package/dist/simple-tree/api/treeNodeApi.js +21 -13
  342. package/dist/simple-tree/api/treeNodeApi.js.map +1 -1
  343. package/dist/simple-tree/api/verboseTree.d.ts.map +1 -1
  344. package/dist/simple-tree/api/verboseTree.js +14 -9
  345. package/dist/simple-tree/api/verboseTree.js.map +1 -1
  346. package/dist/simple-tree/core/treeNodeKernel.d.ts.map +1 -1
  347. package/dist/simple-tree/core/treeNodeKernel.js +6 -3
  348. package/dist/simple-tree/core/treeNodeKernel.js.map +1 -1
  349. package/dist/simple-tree/core/unhydratedFlexTree.d.ts.map +1 -1
  350. package/dist/simple-tree/core/unhydratedFlexTree.js +20 -15
  351. package/dist/simple-tree/core/unhydratedFlexTree.js.map +1 -1
  352. package/dist/simple-tree/getTreeNodeForField.d.ts.map +1 -1
  353. package/dist/simple-tree/getTreeNodeForField.js +2 -1
  354. package/dist/simple-tree/getTreeNodeForField.js.map +1 -1
  355. package/dist/simple-tree/index.d.ts +1 -1
  356. package/dist/simple-tree/index.d.ts.map +1 -1
  357. package/dist/simple-tree/index.js.map +1 -1
  358. package/dist/simple-tree/leafNodeSchema.js +9 -6
  359. package/dist/simple-tree/leafNodeSchema.js.map +1 -1
  360. package/dist/simple-tree/node-kinds/array/arrayNode.js +15 -15
  361. package/dist/simple-tree/node-kinds/array/arrayNode.js.map +1 -1
  362. package/dist/simple-tree/node-kinds/object/objectNode.d.ts.map +1 -1
  363. package/dist/simple-tree/node-kinds/object/objectNode.js +4 -5
  364. package/dist/simple-tree/node-kinds/object/objectNode.js.map +1 -1
  365. package/dist/simple-tree/node-kinds/record/recordNode.d.ts.map +1 -1
  366. package/dist/simple-tree/node-kinds/record/recordNode.js +2 -3
  367. package/dist/simple-tree/node-kinds/record/recordNode.js.map +1 -1
  368. package/dist/simple-tree/toStoredSchema.d.ts.map +1 -1
  369. package/dist/simple-tree/toStoredSchema.js +9 -5
  370. package/dist/simple-tree/toStoredSchema.js.map +1 -1
  371. package/dist/treeFactory.js +7 -3
  372. package/dist/treeFactory.js.map +1 -1
  373. package/dist/util/bTreeUtils.js +1 -1
  374. package/dist/util/bTreeUtils.js.map +1 -1
  375. package/dist/util/breakable.js +7 -9
  376. package/dist/util/breakable.js.map +1 -1
  377. package/dist/util/idAllocator.d.ts.map +1 -1
  378. package/dist/util/idAllocator.js +1 -2
  379. package/dist/util/idAllocator.js.map +1 -1
  380. package/dist/util/nestedMap.d.ts.map +1 -1
  381. package/dist/util/nestedMap.js +1 -1
  382. package/dist/util/nestedMap.js.map +1 -1
  383. package/dist/util/utils.d.ts.map +1 -1
  384. package/dist/util/utils.js +16 -15
  385. package/dist/util/utils.js.map +1 -1
  386. package/eslint.config.mts +1 -16
  387. package/lib/alpha.d.ts +4 -0
  388. package/lib/codec/codec.d.ts +31 -3
  389. package/lib/codec/codec.d.ts.map +1 -1
  390. package/lib/codec/codec.js +10 -0
  391. package/lib/codec/codec.js.map +1 -1
  392. package/lib/codec/index.d.ts +2 -2
  393. package/lib/codec/index.d.ts.map +1 -1
  394. package/lib/codec/index.js +1 -1
  395. package/lib/codec/index.js.map +1 -1
  396. package/lib/codec/versioned/codec.d.ts +80 -22
  397. package/lib/codec/versioned/codec.d.ts.map +1 -1
  398. package/lib/codec/versioned/codec.js +138 -15
  399. package/lib/codec/versioned/codec.js.map +1 -1
  400. package/lib/codec/versioned/index.d.ts +1 -1
  401. package/lib/codec/versioned/index.d.ts.map +1 -1
  402. package/lib/codec/versioned/index.js +1 -1
  403. package/lib/codec/versioned/index.js.map +1 -1
  404. package/lib/core/index.d.ts +2 -2
  405. package/lib/core/index.d.ts.map +1 -1
  406. package/lib/core/index.js +2 -2
  407. package/lib/core/index.js.map +1 -1
  408. package/lib/core/rebase/changeRebaser.d.ts +36 -2
  409. package/lib/core/rebase/changeRebaser.d.ts.map +1 -1
  410. package/lib/core/rebase/changeRebaser.js.map +1 -1
  411. package/lib/core/rebase/index.d.ts +2 -2
  412. package/lib/core/rebase/index.d.ts.map +1 -1
  413. package/lib/core/rebase/index.js +1 -1
  414. package/lib/core/rebase/index.js.map +1 -1
  415. package/lib/core/rebase/types.d.ts +6 -2
  416. package/lib/core/rebase/types.d.ts.map +1 -1
  417. package/lib/core/rebase/types.js +0 -10
  418. package/lib/core/rebase/types.js.map +1 -1
  419. package/lib/core/rebase/utils.js +3 -3
  420. package/lib/core/rebase/utils.js.map +1 -1
  421. package/lib/core/schema-stored/schema.js +3 -3
  422. package/lib/core/schema-stored/schema.js.map +1 -1
  423. package/lib/core/tree/anchorSet.d.ts.map +1 -1
  424. package/lib/core/tree/anchorSet.js +3 -4
  425. package/lib/core/tree/anchorSet.js.map +1 -1
  426. package/lib/core/tree/detachedFieldIndex.d.ts +1 -2
  427. package/lib/core/tree/detachedFieldIndex.d.ts.map +1 -1
  428. package/lib/core/tree/detachedFieldIndex.js +13 -57
  429. package/lib/core/tree/detachedFieldIndex.js.map +1 -1
  430. package/lib/core/tree/detachedFieldIndexCodecCommon.d.ts +18 -10
  431. package/lib/core/tree/detachedFieldIndexCodecCommon.d.ts.map +1 -1
  432. package/lib/core/tree/detachedFieldIndexCodecCommon.js +4 -4
  433. package/lib/core/tree/detachedFieldIndexCodecCommon.js.map +1 -1
  434. package/lib/core/tree/detachedFieldIndexCodecV1.d.ts +2 -3
  435. package/lib/core/tree/detachedFieldIndexCodecV1.d.ts.map +1 -1
  436. package/lib/core/tree/detachedFieldIndexCodecV1.js +4 -5
  437. package/lib/core/tree/detachedFieldIndexCodecV1.js.map +1 -1
  438. package/lib/core/tree/detachedFieldIndexCodecV2.d.ts +2 -3
  439. package/lib/core/tree/detachedFieldIndexCodecV2.d.ts.map +1 -1
  440. package/lib/core/tree/detachedFieldIndexCodecV2.js +4 -6
  441. package/lib/core/tree/detachedFieldIndexCodecV2.js.map +1 -1
  442. package/lib/core/tree/detachedFieldIndexCodecs.d.ts +5 -6
  443. package/lib/core/tree/detachedFieldIndexCodecs.d.ts.map +1 -1
  444. package/lib/core/tree/detachedFieldIndexCodecs.js +12 -39
  445. package/lib/core/tree/detachedFieldIndexCodecs.js.map +1 -1
  446. package/lib/core/tree/index.d.ts +1 -1
  447. package/lib/core/tree/index.d.ts.map +1 -1
  448. package/lib/core/tree/index.js +1 -1
  449. package/lib/core/tree/index.js.map +1 -1
  450. package/lib/core/tree/mapTree.js +1 -1
  451. package/lib/core/tree/mapTree.js.map +1 -1
  452. package/lib/core/tree/sparseTree.d.ts.map +1 -1
  453. package/lib/core/tree/sparseTree.js +1 -0
  454. package/lib/core/tree/sparseTree.js.map +1 -1
  455. package/lib/core/tree/treeTextFormat.d.ts.map +1 -1
  456. package/lib/core/tree/treeTextFormat.js +5 -9
  457. package/lib/core/tree/treeTextFormat.js.map +1 -1
  458. package/lib/feature-libraries/changeAtomIdBTree.d.ts +10 -0
  459. package/lib/feature-libraries/changeAtomIdBTree.d.ts.map +1 -0
  460. package/lib/feature-libraries/changeAtomIdBTree.js +11 -0
  461. package/lib/feature-libraries/changeAtomIdBTree.js.map +1 -0
  462. package/lib/feature-libraries/chunked-forest/basicChunk.js +1 -1
  463. package/lib/feature-libraries/chunked-forest/basicChunk.js.map +1 -1
  464. package/lib/feature-libraries/chunked-forest/chunkedForest.js +6 -6
  465. package/lib/feature-libraries/chunked-forest/chunkedForest.js.map +1 -1
  466. package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.d.ts.map +1 -1
  467. package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.js +7 -4
  468. package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.js.map +1 -1
  469. package/lib/feature-libraries/chunked-forest/codec/codecs.d.ts.map +1 -1
  470. package/lib/feature-libraries/chunked-forest/codec/codecs.js +19 -11
  471. package/lib/feature-libraries/chunked-forest/codec/codecs.js.map +1 -1
  472. package/lib/feature-libraries/chunked-forest/codec/compressedEncode.js +3 -3
  473. package/lib/feature-libraries/chunked-forest/codec/compressedEncode.js.map +1 -1
  474. package/lib/feature-libraries/chunked-forest/codec/schemaBasedEncode.js +9 -5
  475. package/lib/feature-libraries/chunked-forest/codec/schemaBasedEncode.js.map +1 -1
  476. package/lib/feature-libraries/chunked-forest/uniformChunk.js +1 -1
  477. package/lib/feature-libraries/chunked-forest/uniformChunk.js.map +1 -1
  478. package/lib/feature-libraries/default-schema/defaultEditBuilder.d.ts +15 -5
  479. package/lib/feature-libraries/default-schema/defaultEditBuilder.d.ts.map +1 -1
  480. package/lib/feature-libraries/default-schema/defaultEditBuilder.js +19 -14
  481. package/lib/feature-libraries/default-schema/defaultEditBuilder.js.map +1 -1
  482. package/lib/feature-libraries/default-schema/defaultFieldKinds.d.ts +1 -1
  483. package/lib/feature-libraries/default-schema/defaultFieldKinds.d.ts.map +1 -1
  484. package/lib/feature-libraries/default-schema/defaultFieldKinds.js +11 -1
  485. package/lib/feature-libraries/default-schema/defaultFieldKinds.js.map +1 -1
  486. package/lib/feature-libraries/default-schema/mappedEditBuilder.d.ts +2 -0
  487. package/lib/feature-libraries/default-schema/mappedEditBuilder.d.ts.map +1 -1
  488. package/lib/feature-libraries/default-schema/mappedEditBuilder.js +6 -0
  489. package/lib/feature-libraries/default-schema/mappedEditBuilder.js.map +1 -1
  490. package/lib/feature-libraries/flex-tree/lazyField.d.ts.map +1 -1
  491. package/lib/feature-libraries/flex-tree/lazyField.js +11 -13
  492. package/lib/feature-libraries/flex-tree/lazyField.js.map +1 -1
  493. package/lib/feature-libraries/index.d.ts +3 -2
  494. package/lib/feature-libraries/index.d.ts.map +1 -1
  495. package/lib/feature-libraries/index.js +3 -2
  496. package/lib/feature-libraries/index.js.map +1 -1
  497. package/lib/feature-libraries/indexing/anchorTreeIndex.js +6 -6
  498. package/lib/feature-libraries/indexing/anchorTreeIndex.js.map +1 -1
  499. package/lib/feature-libraries/mitigatedChangeFamily.d.ts.map +1 -1
  500. package/lib/feature-libraries/mitigatedChangeFamily.js +10 -1
  501. package/lib/feature-libraries/mitigatedChangeFamily.js.map +1 -1
  502. package/lib/feature-libraries/modular-schema/comparison.d.ts.map +1 -1
  503. package/lib/feature-libraries/modular-schema/comparison.js +12 -9
  504. package/lib/feature-libraries/modular-schema/comparison.js.map +1 -1
  505. package/lib/feature-libraries/modular-schema/defaultRevisionReplacer.d.ts +25 -0
  506. package/lib/feature-libraries/modular-schema/defaultRevisionReplacer.d.ts.map +1 -0
  507. package/lib/feature-libraries/modular-schema/defaultRevisionReplacer.js +55 -0
  508. package/lib/feature-libraries/modular-schema/defaultRevisionReplacer.js.map +1 -0
  509. package/lib/feature-libraries/modular-schema/fieldChangeHandler.d.ts +3 -3
  510. package/lib/feature-libraries/modular-schema/fieldChangeHandler.d.ts.map +1 -1
  511. package/lib/feature-libraries/modular-schema/fieldChangeHandler.js.map +1 -1
  512. package/lib/feature-libraries/modular-schema/genericFieldKind.d.ts.map +1 -1
  513. package/lib/feature-libraries/modular-schema/genericFieldKind.js +5 -5
  514. package/lib/feature-libraries/modular-schema/genericFieldKind.js.map +1 -1
  515. package/lib/feature-libraries/modular-schema/genericFieldKindCodecs.js +1 -1
  516. package/lib/feature-libraries/modular-schema/genericFieldKindCodecs.js.map +1 -1
  517. package/lib/feature-libraries/modular-schema/index.d.ts +4 -2
  518. package/lib/feature-libraries/modular-schema/index.d.ts.map +1 -1
  519. package/lib/feature-libraries/modular-schema/index.js +3 -1
  520. package/lib/feature-libraries/modular-schema/index.js.map +1 -1
  521. package/lib/feature-libraries/modular-schema/modularChangeCodecV1.d.ts +49 -0
  522. package/lib/feature-libraries/modular-schema/modularChangeCodecV1.d.ts.map +1 -0
  523. package/lib/feature-libraries/modular-schema/modularChangeCodecV1.js +298 -0
  524. package/lib/feature-libraries/modular-schema/modularChangeCodecV1.js.map +1 -0
  525. package/lib/feature-libraries/modular-schema/modularChangeCodecV2.d.ts +15 -0
  526. package/lib/feature-libraries/modular-schema/modularChangeCodecV2.d.ts.map +1 -0
  527. package/lib/feature-libraries/modular-schema/modularChangeCodecV2.js +27 -0
  528. package/lib/feature-libraries/modular-schema/modularChangeCodecV2.js.map +1 -0
  529. package/lib/feature-libraries/modular-schema/modularChangeCodecs.d.ts +2 -2
  530. package/lib/feature-libraries/modular-schema/modularChangeCodecs.d.ts.map +1 -1
  531. package/lib/feature-libraries/modular-schema/modularChangeCodecs.js +27 -290
  532. package/lib/feature-libraries/modular-schema/modularChangeCodecs.js.map +1 -1
  533. package/lib/feature-libraries/modular-schema/modularChangeFamily.d.ts +14 -8
  534. package/lib/feature-libraries/modular-schema/modularChangeFamily.d.ts.map +1 -1
  535. package/lib/feature-libraries/modular-schema/modularChangeFamily.js +118 -88
  536. package/lib/feature-libraries/modular-schema/modularChangeFamily.js.map +1 -1
  537. package/lib/feature-libraries/modular-schema/{modularChangeFormat.d.ts → modularChangeFormatV1.d.ts} +5 -6
  538. package/lib/feature-libraries/modular-schema/modularChangeFormatV1.d.ts.map +1 -0
  539. package/lib/feature-libraries/modular-schema/{modularChangeFormat.js → modularChangeFormatV1.js} +4 -4
  540. package/lib/feature-libraries/modular-schema/modularChangeFormatV1.js.map +1 -0
  541. package/lib/feature-libraries/modular-schema/modularChangeFormatV2.d.ts +112 -0
  542. package/lib/feature-libraries/modular-schema/modularChangeFormatV2.d.ts.map +1 -0
  543. package/lib/feature-libraries/modular-schema/modularChangeFormatV2.js +18 -0
  544. package/lib/feature-libraries/modular-schema/modularChangeFormatV2.js.map +1 -0
  545. package/lib/feature-libraries/modular-schema/modularChangeTypes.d.ts +13 -3
  546. package/lib/feature-libraries/modular-schema/modularChangeTypes.d.ts.map +1 -1
  547. package/lib/feature-libraries/modular-schema/modularChangeTypes.js.map +1 -1
  548. package/lib/feature-libraries/node-identifier/mockNodeIdentifierManager.js +1 -1
  549. package/lib/feature-libraries/node-identifier/mockNodeIdentifierManager.js.map +1 -1
  550. package/lib/feature-libraries/object-forest/objectForest.js +4 -4
  551. package/lib/feature-libraries/object-forest/objectForest.js.map +1 -1
  552. package/lib/feature-libraries/optional-field/optionalField.d.ts.map +1 -1
  553. package/lib/feature-libraries/optional-field/optionalField.js +35 -40
  554. package/lib/feature-libraries/optional-field/optionalField.js.map +1 -1
  555. package/lib/feature-libraries/schema-edits/schemaChangeCodecs.d.ts.map +1 -1
  556. package/lib/feature-libraries/schema-edits/schemaChangeCodecs.js +15 -3
  557. package/lib/feature-libraries/schema-edits/schemaChangeCodecs.js.map +1 -1
  558. package/lib/feature-libraries/schema-index/codec.d.ts +7 -21
  559. package/lib/feature-libraries/schema-index/codec.d.ts.map +1 -1
  560. package/lib/feature-libraries/schema-index/codec.js +30 -68
  561. package/lib/feature-libraries/schema-index/codec.js.map +1 -1
  562. package/lib/feature-libraries/schema-index/index.d.ts +2 -2
  563. package/lib/feature-libraries/schema-index/index.d.ts.map +1 -1
  564. package/lib/feature-libraries/schema-index/index.js +2 -2
  565. package/lib/feature-libraries/schema-index/index.js.map +1 -1
  566. package/lib/feature-libraries/schema-index/schemaSummarizer.d.ts +1 -9
  567. package/lib/feature-libraries/schema-index/schemaSummarizer.d.ts.map +1 -1
  568. package/lib/feature-libraries/schema-index/schemaSummarizer.js +0 -10
  569. package/lib/feature-libraries/schema-index/schemaSummarizer.js.map +1 -1
  570. package/lib/feature-libraries/schemaChecker.d.ts.map +1 -1
  571. package/lib/feature-libraries/schemaChecker.js +11 -6
  572. package/lib/feature-libraries/schemaChecker.js.map +1 -1
  573. package/lib/feature-libraries/sequence-field/compose.d.ts.map +1 -1
  574. package/lib/feature-libraries/sequence-field/compose.js +17 -13
  575. package/lib/feature-libraries/sequence-field/compose.js.map +1 -1
  576. package/lib/feature-libraries/sequence-field/invert.js +5 -4
  577. package/lib/feature-libraries/sequence-field/invert.js.map +1 -1
  578. package/lib/feature-libraries/sequence-field/moveEffectTable.d.ts.map +1 -1
  579. package/lib/feature-libraries/sequence-field/moveEffectTable.js +15 -9
  580. package/lib/feature-libraries/sequence-field/moveEffectTable.js.map +1 -1
  581. package/lib/feature-libraries/sequence-field/rebase.js +26 -18
  582. package/lib/feature-libraries/sequence-field/rebase.js.map +1 -1
  583. package/lib/feature-libraries/sequence-field/replaceRevisions.d.ts +2 -2
  584. package/lib/feature-libraries/sequence-field/replaceRevisions.d.ts.map +1 -1
  585. package/lib/feature-libraries/sequence-field/replaceRevisions.js +41 -36
  586. package/lib/feature-libraries/sequence-field/replaceRevisions.js.map +1 -1
  587. package/lib/feature-libraries/sequence-field/sequenceFieldCodecV2.d.ts.map +1 -1
  588. package/lib/feature-libraries/sequence-field/sequenceFieldCodecV2.js +16 -8
  589. package/lib/feature-libraries/sequence-field/sequenceFieldCodecV2.js.map +1 -1
  590. package/lib/feature-libraries/sequence-field/sequenceFieldCodecV3.d.ts.map +1 -1
  591. package/lib/feature-libraries/sequence-field/sequenceFieldCodecV3.js +4 -2
  592. package/lib/feature-libraries/sequence-field/sequenceFieldCodecV3.js.map +1 -1
  593. package/lib/feature-libraries/sequence-field/sequenceFieldToDelta.d.ts.map +1 -1
  594. package/lib/feature-libraries/sequence-field/sequenceFieldToDelta.js +6 -3
  595. package/lib/feature-libraries/sequence-field/sequenceFieldToDelta.js.map +1 -1
  596. package/lib/feature-libraries/sequence-field/utils.d.ts.map +1 -1
  597. package/lib/feature-libraries/sequence-field/utils.js +46 -27
  598. package/lib/feature-libraries/sequence-field/utils.js.map +1 -1
  599. package/lib/feature-libraries/treeCursorUtils.js +7 -7
  600. package/lib/feature-libraries/treeCursorUtils.js.map +1 -1
  601. package/lib/feature-libraries/treeTextCursor.js +2 -2
  602. package/lib/feature-libraries/treeTextCursor.js.map +1 -1
  603. package/lib/feature-libraries/valueUtilities.d.ts.map +1 -1
  604. package/lib/feature-libraries/valueUtilities.js +16 -8
  605. package/lib/feature-libraries/valueUtilities.js.map +1 -1
  606. package/lib/index.d.ts +2 -2
  607. package/lib/index.d.ts.map +1 -1
  608. package/lib/index.js.map +1 -1
  609. package/lib/packageVersion.d.ts +1 -1
  610. package/lib/packageVersion.js +1 -1
  611. package/lib/packageVersion.js.map +1 -1
  612. package/lib/shared-tree/schematizingTreeView.d.ts +2 -3
  613. package/lib/shared-tree/schematizingTreeView.d.ts.map +1 -1
  614. package/lib/shared-tree/schematizingTreeView.js +20 -9
  615. package/lib/shared-tree/schematizingTreeView.js.map +1 -1
  616. package/lib/shared-tree/sharedTree.d.ts.map +1 -1
  617. package/lib/shared-tree/sharedTree.js +30 -13
  618. package/lib/shared-tree/sharedTree.js.map +1 -1
  619. package/lib/shared-tree/sharedTreeChangeCodecs.d.ts +1 -1
  620. package/lib/shared-tree/sharedTreeChangeCodecs.d.ts.map +1 -1
  621. package/lib/shared-tree/sharedTreeChangeCodecs.js +9 -8
  622. package/lib/shared-tree/sharedTreeChangeCodecs.js.map +1 -1
  623. package/lib/shared-tree/sharedTreeChangeEnricher.d.ts.map +1 -1
  624. package/lib/shared-tree/sharedTreeChangeEnricher.js +4 -2
  625. package/lib/shared-tree/sharedTreeChangeEnricher.js.map +1 -1
  626. package/lib/shared-tree/sharedTreeChangeFamily.d.ts +3 -2
  627. package/lib/shared-tree/sharedTreeChangeFamily.d.ts.map +1 -1
  628. package/lib/shared-tree/sharedTreeChangeFamily.js +19 -14
  629. package/lib/shared-tree/sharedTreeChangeFamily.js.map +1 -1
  630. package/lib/shared-tree/sharedTreeEditBuilder.d.ts.map +1 -1
  631. package/lib/shared-tree/sharedTreeEditBuilder.js +1 -1
  632. package/lib/shared-tree/sharedTreeEditBuilder.js.map +1 -1
  633. package/lib/shared-tree/treeAlpha.d.ts +35 -29
  634. package/lib/shared-tree/treeAlpha.d.ts.map +1 -1
  635. package/lib/shared-tree/treeAlpha.js +21 -23
  636. package/lib/shared-tree/treeAlpha.js.map +1 -1
  637. package/lib/shared-tree/treeCheckout.d.ts +2 -0
  638. package/lib/shared-tree/treeCheckout.d.ts.map +1 -1
  639. package/lib/shared-tree/treeCheckout.js +32 -19
  640. package/lib/shared-tree/treeCheckout.js.map +1 -1
  641. package/lib/shared-tree-core/branch.d.ts +3 -1
  642. package/lib/shared-tree-core/branch.d.ts.map +1 -1
  643. package/lib/shared-tree-core/branch.js +5 -3
  644. package/lib/shared-tree-core/branch.js.map +1 -1
  645. package/lib/shared-tree-core/branchCommitEnricher.d.ts.map +1 -1
  646. package/lib/shared-tree-core/branchCommitEnricher.js +2 -2
  647. package/lib/shared-tree-core/branchCommitEnricher.js.map +1 -1
  648. package/lib/shared-tree-core/editManager.js +1 -1
  649. package/lib/shared-tree-core/editManager.js.map +1 -1
  650. package/lib/shared-tree-core/editManagerCodecs.d.ts.map +1 -1
  651. package/lib/shared-tree-core/editManagerCodecs.js +9 -4
  652. package/lib/shared-tree-core/editManagerCodecs.js.map +1 -1
  653. package/lib/shared-tree-core/editManagerFormatCommons.d.ts +1 -0
  654. package/lib/shared-tree-core/editManagerFormatCommons.d.ts.map +1 -1
  655. package/lib/shared-tree-core/editManagerFormatCommons.js +6 -0
  656. package/lib/shared-tree-core/editManagerFormatCommons.js.map +1 -1
  657. package/lib/shared-tree-core/editManagerFormatV1toV4.d.ts +2 -2
  658. package/lib/shared-tree-core/editManagerFormatV1toV4.d.ts.map +1 -1
  659. package/lib/shared-tree-core/editManagerFormatV1toV4.js +1 -0
  660. package/lib/shared-tree-core/editManagerFormatV1toV4.js.map +1 -1
  661. package/lib/shared-tree-core/editManagerSummarizer.js +3 -3
  662. package/lib/shared-tree-core/editManagerSummarizer.js.map +1 -1
  663. package/lib/shared-tree-core/messageCodecV1ToV4.d.ts +1 -1
  664. package/lib/shared-tree-core/messageCodecV1ToV4.d.ts.map +1 -1
  665. package/lib/shared-tree-core/messageCodecV1ToV4.js.map +1 -1
  666. package/lib/shared-tree-core/messageCodecVSharedBranches.d.ts.map +1 -1
  667. package/lib/shared-tree-core/messageCodecVSharedBranches.js +2 -1
  668. package/lib/shared-tree-core/messageCodecVSharedBranches.js.map +1 -1
  669. package/lib/shared-tree-core/messageCodecs.d.ts.map +1 -1
  670. package/lib/shared-tree-core/messageCodecs.js +8 -4
  671. package/lib/shared-tree-core/messageCodecs.js.map +1 -1
  672. package/lib/shared-tree-core/messageFormat.d.ts +1 -0
  673. package/lib/shared-tree-core/messageFormat.d.ts.map +1 -1
  674. package/lib/shared-tree-core/messageFormat.js +6 -0
  675. package/lib/shared-tree-core/messageFormat.js.map +1 -1
  676. package/lib/shared-tree-core/messageFormatV1ToV4.d.ts +3 -2
  677. package/lib/shared-tree-core/messageFormatV1ToV4.d.ts.map +1 -1
  678. package/lib/shared-tree-core/messageFormatV1ToV4.js +8 -1
  679. package/lib/shared-tree-core/messageFormatV1ToV4.js.map +1 -1
  680. package/lib/shared-tree-core/sequenceIdUtils.d.ts.map +1 -1
  681. package/lib/shared-tree-core/sequenceIdUtils.js +4 -4
  682. package/lib/shared-tree-core/sequenceIdUtils.js.map +1 -1
  683. package/lib/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
  684. package/lib/shared-tree-core/sharedTreeCore.js +12 -8
  685. package/lib/shared-tree-core/sharedTreeCore.js.map +1 -1
  686. package/lib/shared-tree-core/transaction.d.ts +25 -8
  687. package/lib/shared-tree-core/transaction.d.ts.map +1 -1
  688. package/lib/shared-tree-core/transaction.js +67 -32
  689. package/lib/shared-tree-core/transaction.js.map +1 -1
  690. package/lib/shared-tree-core/transactionEnricher.d.ts +2 -2
  691. package/lib/shared-tree-core/transactionEnricher.d.ts.map +1 -1
  692. package/lib/shared-tree-core/transactionEnricher.js +3 -3
  693. package/lib/shared-tree-core/transactionEnricher.js.map +1 -1
  694. package/lib/simple-tree/api/configuration.js +1 -1
  695. package/lib/simple-tree/api/configuration.js.map +1 -1
  696. package/lib/simple-tree/api/customTree.d.ts.map +1 -1
  697. package/lib/simple-tree/api/customTree.js +13 -9
  698. package/lib/simple-tree/api/customTree.js.map +1 -1
  699. package/lib/simple-tree/api/discrepancies.d.ts.map +1 -1
  700. package/lib/simple-tree/api/discrepancies.js +21 -17
  701. package/lib/simple-tree/api/discrepancies.js.map +1 -1
  702. package/lib/simple-tree/api/index.d.ts +1 -1
  703. package/lib/simple-tree/api/index.d.ts.map +1 -1
  704. package/lib/simple-tree/api/index.js.map +1 -1
  705. package/lib/simple-tree/api/schemaFactory.d.ts.map +1 -1
  706. package/lib/simple-tree/api/schemaFactory.js +12 -8
  707. package/lib/simple-tree/api/schemaFactory.js.map +1 -1
  708. package/lib/simple-tree/api/schemaFromSimple.js +18 -9
  709. package/lib/simple-tree/api/schemaFromSimple.js.map +1 -1
  710. package/lib/simple-tree/api/simpleSchemaCodec.js +10 -5
  711. package/lib/simple-tree/api/simpleSchemaCodec.js.map +1 -1
  712. package/lib/simple-tree/api/simpleSchemaToJsonSchema.d.ts.map +1 -1
  713. package/lib/simple-tree/api/simpleSchemaToJsonSchema.js +15 -11
  714. package/lib/simple-tree/api/simpleSchemaToJsonSchema.js.map +1 -1
  715. package/lib/simple-tree/api/simpleTreeIndex.js +10 -10
  716. package/lib/simple-tree/api/simpleTreeIndex.js.map +1 -1
  717. package/lib/simple-tree/api/storedSchema.d.ts.map +1 -1
  718. package/lib/simple-tree/api/storedSchema.js +4 -7
  719. package/lib/simple-tree/api/storedSchema.js.map +1 -1
  720. package/lib/simple-tree/api/transactionTypes.d.ts +17 -4
  721. package/lib/simple-tree/api/transactionTypes.d.ts.map +1 -1
  722. package/lib/simple-tree/api/transactionTypes.js.map +1 -1
  723. package/lib/simple-tree/api/treeNodeApi.d.ts.map +1 -1
  724. package/lib/simple-tree/api/treeNodeApi.js +21 -13
  725. package/lib/simple-tree/api/treeNodeApi.js.map +1 -1
  726. package/lib/simple-tree/api/verboseTree.d.ts.map +1 -1
  727. package/lib/simple-tree/api/verboseTree.js +14 -9
  728. package/lib/simple-tree/api/verboseTree.js.map +1 -1
  729. package/lib/simple-tree/core/treeNodeKernel.d.ts.map +1 -1
  730. package/lib/simple-tree/core/treeNodeKernel.js +6 -3
  731. package/lib/simple-tree/core/treeNodeKernel.js.map +1 -1
  732. package/lib/simple-tree/core/unhydratedFlexTree.d.ts.map +1 -1
  733. package/lib/simple-tree/core/unhydratedFlexTree.js +20 -15
  734. package/lib/simple-tree/core/unhydratedFlexTree.js.map +1 -1
  735. package/lib/simple-tree/getTreeNodeForField.d.ts.map +1 -1
  736. package/lib/simple-tree/getTreeNodeForField.js +2 -1
  737. package/lib/simple-tree/getTreeNodeForField.js.map +1 -1
  738. package/lib/simple-tree/index.d.ts +1 -1
  739. package/lib/simple-tree/index.d.ts.map +1 -1
  740. package/lib/simple-tree/index.js.map +1 -1
  741. package/lib/simple-tree/leafNodeSchema.js +9 -6
  742. package/lib/simple-tree/leafNodeSchema.js.map +1 -1
  743. package/lib/simple-tree/node-kinds/array/arrayNode.js +15 -15
  744. package/lib/simple-tree/node-kinds/array/arrayNode.js.map +1 -1
  745. package/lib/simple-tree/node-kinds/object/objectNode.d.ts.map +1 -1
  746. package/lib/simple-tree/node-kinds/object/objectNode.js +4 -5
  747. package/lib/simple-tree/node-kinds/object/objectNode.js.map +1 -1
  748. package/lib/simple-tree/node-kinds/record/recordNode.d.ts.map +1 -1
  749. package/lib/simple-tree/node-kinds/record/recordNode.js +2 -3
  750. package/lib/simple-tree/node-kinds/record/recordNode.js.map +1 -1
  751. package/lib/simple-tree/toStoredSchema.d.ts.map +1 -1
  752. package/lib/simple-tree/toStoredSchema.js +9 -5
  753. package/lib/simple-tree/toStoredSchema.js.map +1 -1
  754. package/lib/treeFactory.js +7 -3
  755. package/lib/treeFactory.js.map +1 -1
  756. package/lib/util/bTreeUtils.js +1 -1
  757. package/lib/util/bTreeUtils.js.map +1 -1
  758. package/lib/util/breakable.js +7 -9
  759. package/lib/util/breakable.js.map +1 -1
  760. package/lib/util/idAllocator.d.ts.map +1 -1
  761. package/lib/util/idAllocator.js +1 -2
  762. package/lib/util/idAllocator.js.map +1 -1
  763. package/lib/util/nestedMap.d.ts.map +1 -1
  764. package/lib/util/nestedMap.js +1 -1
  765. package/lib/util/nestedMap.js.map +1 -1
  766. package/lib/util/utils.d.ts.map +1 -1
  767. package/lib/util/utils.js +16 -15
  768. package/lib/util/utils.js.map +1 -1
  769. package/package.json +32 -32
  770. package/src/codec/codec.ts +48 -8
  771. package/src/codec/index.ts +4 -1
  772. package/src/codec/versioned/codec.ts +340 -22
  773. package/src/codec/versioned/index.ts +3 -1
  774. package/src/core/index.ts +2 -2
  775. package/src/core/rebase/changeRebaser.ts +40 -6
  776. package/src/core/rebase/index.ts +1 -1
  777. package/src/core/rebase/types.ts +6 -18
  778. package/src/core/rebase/utils.ts +3 -3
  779. package/src/core/schema-stored/schema.ts +3 -3
  780. package/src/core/tree/anchorSet.ts +3 -4
  781. package/src/core/tree/detachedFieldIndex.ts +13 -74
  782. package/src/core/tree/detachedFieldIndexCodecCommon.ts +4 -8
  783. package/src/core/tree/detachedFieldIndexCodecV1.ts +3 -7
  784. package/src/core/tree/detachedFieldIndexCodecV2.ts +5 -9
  785. package/src/core/tree/detachedFieldIndexCodecs.ts +21 -64
  786. package/src/core/tree/index.ts +1 -1
  787. package/src/core/tree/mapTree.ts +1 -1
  788. package/src/core/tree/sparseTree.ts +1 -0
  789. package/src/core/tree/treeTextFormat.ts +5 -9
  790. package/src/feature-libraries/changeAtomIdBTree.ts +24 -0
  791. package/src/feature-libraries/chunked-forest/basicChunk.ts +1 -1
  792. package/src/feature-libraries/chunked-forest/chunkedForest.ts +5 -5
  793. package/src/feature-libraries/chunked-forest/codec/chunkDecoding.ts +7 -4
  794. package/src/feature-libraries/chunked-forest/codec/codecs.ts +19 -11
  795. package/src/feature-libraries/chunked-forest/codec/compressedEncode.ts +3 -3
  796. package/src/feature-libraries/chunked-forest/codec/schemaBasedEncode.ts +9 -5
  797. package/src/feature-libraries/chunked-forest/uniformChunk.ts +1 -1
  798. package/src/feature-libraries/default-schema/defaultEditBuilder.ts +48 -17
  799. package/src/feature-libraries/default-schema/defaultFieldKinds.ts +12 -2
  800. package/src/feature-libraries/default-schema/mappedEditBuilder.ts +6 -0
  801. package/src/feature-libraries/flex-tree/lazyField.ts +13 -14
  802. package/src/feature-libraries/index.ts +10 -5
  803. package/src/feature-libraries/indexing/anchorTreeIndex.ts +5 -5
  804. package/src/feature-libraries/mitigatedChangeFamily.ts +11 -6
  805. package/src/feature-libraries/modular-schema/comparison.ts +12 -9
  806. package/src/feature-libraries/modular-schema/defaultRevisionReplacer.ts +70 -0
  807. package/src/feature-libraries/modular-schema/fieldChangeHandler.ts +3 -6
  808. package/src/feature-libraries/modular-schema/genericFieldKind.ts +5 -7
  809. package/src/feature-libraries/modular-schema/genericFieldKindCodecs.ts +1 -1
  810. package/src/feature-libraries/modular-schema/index.ts +5 -2
  811. package/src/feature-libraries/modular-schema/modularChangeCodecV1.ts +703 -0
  812. package/src/feature-libraries/modular-schema/modularChangeCodecV2.ts +89 -0
  813. package/src/feature-libraries/modular-schema/modularChangeCodecs.ts +39 -523
  814. package/src/feature-libraries/modular-schema/modularChangeFamily.ts +159 -125
  815. package/src/feature-libraries/modular-schema/{modularChangeFormat.ts → modularChangeFormatV1.ts} +4 -4
  816. package/src/feature-libraries/modular-schema/modularChangeFormatV2.ts +34 -0
  817. package/src/feature-libraries/modular-schema/modularChangeTypes.ts +13 -4
  818. package/src/feature-libraries/node-identifier/mockNodeIdentifierManager.ts +1 -1
  819. package/src/feature-libraries/object-forest/objectForest.ts +4 -4
  820. package/src/feature-libraries/optional-field/optionalField.ts +34 -46
  821. package/src/feature-libraries/schema-edits/schemaChangeCodecs.ts +18 -3
  822. package/src/feature-libraries/schema-index/codec.ts +30 -90
  823. package/src/feature-libraries/schema-index/index.ts +2 -4
  824. package/src/feature-libraries/schema-index/schemaSummarizer.ts +0 -17
  825. package/src/feature-libraries/schemaChecker.ts +11 -6
  826. package/src/feature-libraries/sequence-field/compose.ts +17 -13
  827. package/src/feature-libraries/sequence-field/invert.ts +5 -4
  828. package/src/feature-libraries/sequence-field/moveEffectTable.ts +15 -9
  829. package/src/feature-libraries/sequence-field/rebase.ts +26 -18
  830. package/src/feature-libraries/sequence-field/replaceRevisions.ts +52 -56
  831. package/src/feature-libraries/sequence-field/sequenceFieldCodecV2.ts +16 -8
  832. package/src/feature-libraries/sequence-field/sequenceFieldCodecV3.ts +4 -2
  833. package/src/feature-libraries/sequence-field/sequenceFieldToDelta.ts +6 -3
  834. package/src/feature-libraries/sequence-field/utils.ts +46 -27
  835. package/src/feature-libraries/treeCursorUtils.ts +7 -7
  836. package/src/feature-libraries/treeTextCursor.ts +2 -2
  837. package/src/feature-libraries/valueUtilities.ts +16 -8
  838. package/src/index.ts +4 -0
  839. package/src/packageVersion.ts +1 -1
  840. package/src/shared-tree/schematizingTreeView.ts +23 -13
  841. package/src/shared-tree/sharedTree.ts +30 -14
  842. package/src/shared-tree/sharedTreeChangeCodecs.ts +10 -9
  843. package/src/shared-tree/sharedTreeChangeEnricher.ts +4 -2
  844. package/src/shared-tree/sharedTreeChangeFamily.ts +29 -19
  845. package/src/shared-tree/sharedTreeEditBuilder.ts +9 -5
  846. package/src/shared-tree/treeAlpha.ts +60 -51
  847. package/src/shared-tree/treeCheckout.ts +66 -50
  848. package/src/shared-tree-core/branch.ts +8 -3
  849. package/src/shared-tree-core/branchCommitEnricher.ts +3 -8
  850. package/src/shared-tree-core/editManager.ts +1 -1
  851. package/src/shared-tree-core/editManagerCodecs.ts +9 -4
  852. package/src/shared-tree-core/editManagerFormatCommons.ts +6 -0
  853. package/src/shared-tree-core/editManagerFormatV1toV4.ts +3 -1
  854. package/src/shared-tree-core/editManagerSummarizer.ts +3 -3
  855. package/src/shared-tree-core/messageCodecV1ToV4.ts +2 -1
  856. package/src/shared-tree-core/messageCodecVSharedBranches.ts +2 -1
  857. package/src/shared-tree-core/messageCodecs.ts +8 -4
  858. package/src/shared-tree-core/messageFormat.ts +6 -1
  859. package/src/shared-tree-core/messageFormatV1ToV4.ts +16 -2
  860. package/src/shared-tree-core/sequenceIdUtils.ts +4 -4
  861. package/src/shared-tree-core/sharedTreeCore.ts +11 -7
  862. package/src/shared-tree-core/transaction.ts +115 -56
  863. package/src/shared-tree-core/transactionEnricher.ts +5 -6
  864. package/src/simple-tree/api/configuration.ts +1 -1
  865. package/src/simple-tree/api/customTree.ts +14 -10
  866. package/src/simple-tree/api/discrepancies.ts +23 -17
  867. package/src/simple-tree/api/index.ts +2 -0
  868. package/src/simple-tree/api/schemaFactory.ts +11 -7
  869. package/src/simple-tree/api/schemaFromSimple.ts +18 -9
  870. package/src/simple-tree/api/simpleSchemaCodec.ts +10 -5
  871. package/src/simple-tree/api/simpleSchemaToJsonSchema.ts +17 -13
  872. package/src/simple-tree/api/simpleTreeIndex.ts +8 -8
  873. package/src/simple-tree/api/storedSchema.ts +10 -7
  874. package/src/simple-tree/api/transactionTypes.ts +19 -4
  875. package/src/simple-tree/api/treeNodeApi.ts +21 -13
  876. package/src/simple-tree/api/verboseTree.ts +14 -9
  877. package/src/simple-tree/core/treeNodeKernel.ts +6 -3
  878. package/src/simple-tree/core/unhydratedFlexTree.ts +22 -17
  879. package/src/simple-tree/getTreeNodeForField.ts +2 -1
  880. package/src/simple-tree/index.ts +2 -0
  881. package/src/simple-tree/leafNodeSchema.ts +8 -5
  882. package/src/simple-tree/node-kinds/array/arrayNode.ts +23 -23
  883. package/src/simple-tree/node-kinds/object/objectNode.ts +4 -5
  884. package/src/simple-tree/node-kinds/record/recordNode.ts +2 -3
  885. package/src/simple-tree/toStoredSchema.ts +9 -5
  886. package/src/treeFactory.ts +10 -5
  887. package/src/util/bTreeUtils.ts +1 -1
  888. package/src/util/breakable.ts +9 -9
  889. package/src/util/idAllocator.ts +1 -2
  890. package/src/util/nestedMap.ts +1 -3
  891. package/src/util/utils.ts +14 -13
  892. package/dist/feature-libraries/modular-schema/modularChangeFormat.d.ts.map +0 -1
  893. package/dist/feature-libraries/modular-schema/modularChangeFormat.js.map +0 -1
  894. package/lib/feature-libraries/modular-schema/modularChangeFormat.d.ts.map +0 -1
  895. package/lib/feature-libraries/modular-schema/modularChangeFormat.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"sharedTreeChangeCodecs.js","sourceRoot":"","sources":["../../src/shared-tree/sharedTreeChangeCodecs.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,qCAAqC,CAAC;AAE3D,OAAO,EAGN,4BAA4B,EAK5B,eAAe,EACf,oBAAoB,GACpB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAEN,mBAAmB,GAEnB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAIN,mBAAmB,EACnB,kCAAkC,EAClC,iCAAiC,EACjC,sBAAsB,GACtB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACN,KAAK,GAIL,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EACN,uBAAuB,GAEvB,MAAM,6BAA6B,CAAC;AAGrC,MAAM,UAAU,+BAA+B,CAC9C,wBAA+E,EAC/E,OAA0B;IAE1B,MAAM,kBAAkB,GAAG,sBAAsB,CAAC,OAAO,CAAC,CAAC;IAC3D,MAAM,QAAQ,GAQR,KAAK,CAAC,IAAI,CAAC,2BAA2B,CAAC,OAAO,EAAE,CAAC,CAAC,GAAG,CAC1D,CAAC,CAAC,MAAM,EAAE,EAAE,aAAa,EAAE,YAAY,EAAE,CAAC,EAAE,EAAE,CAAC;QAC9C,MAAM;QACN,yBAAyB,CACxB,wBAAwB,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC,IAA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,OAAO,EAAE,EAAE;YAClC,MAAM,OAAO,GAAyC,EAAE,CAAC;YACzD,KAAK,MAAM,SAAS,IAAI,aAAa,EAAE,CAAC;gBACvC,OAAO,CAAC,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC,CAAC;YAC3D,CAAC;YACD,OAAO,EAAE,OAAO,EAAE,CAAC;QACpB,CAAC;KACD,EACD,YAAY,CAAC,aAAa,CAC1B,CAAC;AACH,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { fail } from \"@fluidframework/core-utils/internal\";\nimport type { MinimumVersionForCollab } from \"@fluidframework/runtime-definitions/internal\";\nimport {\n\ttype CodecTree,\n\ttype CodecWriteOptions,\n\tDiscriminatedUnionDispatcher,\n\ttype FormatVersion,\n\ttype ICodecFamily,\n\ttype ICodecOptions,\n\ttype IJsonCodec,\n\tmakeCodecFamily,\n\twithSchemaValidation,\n} from \"../codec/index.js\";\nimport {\n\ttype ChangeEncodingContext,\n\tSchemaFormatVersion,\n\ttype TreeStoredSchema,\n} from \"../core/index.js\";\nimport {\n\ttype ModularChangeFormatVersion,\n\ttype ModularChangeset,\n\ttype SchemaChange,\n\tdefaultSchemaPolicy,\n\tgetCodecTreeForModularChangeFormat,\n\tgetCodecTreeForSchemaChangeFormat,\n\tmakeSchemaChangeCodecs,\n} from \"../feature-libraries/index.js\";\nimport {\n\tbrand,\n\ttype Brand,\n\ttype JsonCompatibleReadOnly,\n\ttype Mutable,\n} from \"../util/index.js\";\n\nimport {\n\tEncodedSharedTreeChange,\n\ttype EncodedSharedTreeInnerChange,\n} from \"./sharedTreeChangeFormat.js\";\nimport type { SharedTreeChange, SharedTreeInnerChange } from \"./sharedTreeChangeTypes.js\";\n\nexport function makeSharedTreeChangeCodecFamily(\n\tmodularChangeCodecFamily: ICodecFamily<ModularChangeset, ChangeEncodingContext>,\n\toptions: CodecWriteOptions,\n): ICodecFamily<SharedTreeChange, ChangeEncodingContext> {\n\tconst schemaChangeCodecs = makeSchemaChangeCodecs(options);\n\tconst versions: [\n\t\tFormatVersion,\n\t\tIJsonCodec<\n\t\t\tSharedTreeChange,\n\t\t\tEncodedSharedTreeChange,\n\t\t\tEncodedSharedTreeChange,\n\t\t\tChangeEncodingContext\n\t\t>,\n\t][] = Array.from(dependenciesForChangeFormat.entries()).map(\n\t\t([format, { modularChange, schemaChange }]) => [\n\t\t\tformat,\n\t\t\tmakeSharedTreeChangeCodec(\n\t\t\t\tmodularChangeCodecFamily.resolve(modularChange).json,\n\t\t\t\tschemaChangeCodecs.resolve(schemaChange).json,\n\t\t\t\toptions,\n\t\t\t),\n\t\t],\n\t);\n\treturn makeCodecFamily(versions);\n}\n\ninterface ChangeFormatDependencies {\n\treadonly modularChange: ModularChangeFormatVersion;\n\treadonly schemaChange: SchemaFormatVersion;\n}\n\nexport type SharedTreeChangeFormatVersion = Brand<3 | 4, \"SharedTreeChangeFormatVersion\">;\n\n/**\n * Defines for each SharedTree change format the corresponding dependent formats to use.\n * This is an arbitrary mapping that is injected in the SharedTree change codec.\n * Once an entry is defined and used in production, it cannot be changed.\n * This is because the format for the dependent formats are not explicitly versioned.\n */\nexport const dependenciesForChangeFormat: Map<\n\tSharedTreeChangeFormatVersion,\n\tChangeFormatDependencies\n> = new Map([\n\t[brand(3), { modularChange: brand(3), schemaChange: SchemaFormatVersion.v1 }],\n\t[brand(4), { modularChange: brand(4), schemaChange: SchemaFormatVersion.v1 }],\n]);\n\nexport function getCodecTreeForChangeFormat(\n\tversion: SharedTreeChangeFormatVersion,\n\tclientVersion: MinimumVersionForCollab,\n): CodecTree {\n\tconst { modularChange, schemaChange } =\n\t\tdependenciesForChangeFormat.get(version) ?? fail(0xc78 /* Unknown change format */);\n\treturn {\n\t\tname: \"SharedTreeChange\",\n\t\tversion,\n\t\tchildren: [\n\t\t\tgetCodecTreeForModularChangeFormat(modularChange),\n\t\t\tgetCodecTreeForSchemaChangeFormat(schemaChange, clientVersion),\n\t\t],\n\t};\n}\n\nfunction makeSharedTreeChangeCodec(\n\tmodularChangeCodec: IJsonCodec<\n\t\tModularChangeset,\n\t\tJsonCompatibleReadOnly,\n\t\tJsonCompatibleReadOnly,\n\t\tChangeEncodingContext\n\t>,\n\tschemaChangeCodec: IJsonCodec<SchemaChange>,\n\tcodecOptions: ICodecOptions,\n): IJsonCodec<\n\tSharedTreeChange,\n\tEncodedSharedTreeChange,\n\tEncodedSharedTreeChange,\n\tChangeEncodingContext\n> {\n\tconst decoderLibrary = new DiscriminatedUnionDispatcher<\n\t\tEncodedSharedTreeInnerChange,\n\t\t[context: ChangeEncodingContext],\n\t\tSharedTreeInnerChange\n\t>({\n\t\tdata(encoded, context): SharedTreeInnerChange {\n\t\t\treturn {\n\t\t\t\ttype: \"data\",\n\t\t\t\tinnerChange: modularChangeCodec.decode(encoded, context),\n\t\t\t};\n\t\t},\n\t\tschema(encoded): SharedTreeInnerChange {\n\t\t\treturn {\n\t\t\t\ttype: \"schema\",\n\t\t\t\tinnerChange: schemaChangeCodec.decode(encoded),\n\t\t\t};\n\t\t},\n\t});\n\n\treturn withSchemaValidation(\n\t\tEncodedSharedTreeChange,\n\t\t{\n\t\t\tencode: (change, context) => {\n\t\t\t\tconst changes: EncodedSharedTreeInnerChange[] = [];\n\t\t\t\tlet updatedSchema: TreeStoredSchema | undefined;\n\t\t\t\tfor (const decodedChange of change.changes) {\n\t\t\t\t\tif (decodedChange.type === \"data\") {\n\t\t\t\t\t\tconst schemaAndPolicy =\n\t\t\t\t\t\t\tupdatedSchema !== undefined\n\t\t\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\t\t\tpolicy:\n\t\t\t\t\t\t\t\t\t\t\tcontext.schema !== undefined\n\t\t\t\t\t\t\t\t\t\t\t\t? context.schema.policy\n\t\t\t\t\t\t\t\t\t\t\t\t: defaultSchemaPolicy,\n\t\t\t\t\t\t\t\t\t\tschema: updatedSchema,\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t: context.schema;\n\t\t\t\t\t\tchanges.push({\n\t\t\t\t\t\t\tdata: modularChangeCodec.encode(decodedChange.innerChange, {\n\t\t\t\t\t\t\t\toriginatorId: context.originatorId,\n\t\t\t\t\t\t\t\tschema: schemaAndPolicy,\n\t\t\t\t\t\t\t\tidCompressor: context.idCompressor,\n\t\t\t\t\t\t\t\trevision: context.revision,\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t});\n\t\t\t\t\t} else if (decodedChange.type === \"schema\") {\n\t\t\t\t\t\tchanges.push({\n\t\t\t\t\t\t\tschema: schemaChangeCodec.encode(decodedChange.innerChange),\n\t\t\t\t\t\t});\n\t\t\t\t\t\tupdatedSchema = decodedChange.innerChange.schema.new;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn changes;\n\t\t\t},\n\t\t\tdecode: (encodedChange, context) => {\n\t\t\t\tconst changes: Mutable<SharedTreeChange[\"changes\"]> = [];\n\t\t\t\tfor (const subChange of encodedChange) {\n\t\t\t\t\tchanges.push(decoderLibrary.dispatch(subChange, context));\n\t\t\t\t}\n\t\t\t\treturn { changes };\n\t\t\t},\n\t\t},\n\t\tcodecOptions.jsonValidator,\n\t);\n}\n"]}
1
+ {"version":3,"file":"sharedTreeChangeCodecs.js","sourceRoot":"","sources":["../../src/shared-tree/sharedTreeChangeCodecs.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,qCAAqC,CAAC;AAE3D,OAAO,EAGN,4BAA4B,EAK5B,eAAe,EACf,oBAAoB,GACpB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAEN,mBAAmB,GAEnB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAIN,mBAAmB,EACnB,kCAAkC,EAClC,iCAAiC,EACjC,sBAAsB,GACtB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACN,KAAK,GAIL,MAAM,kBAAkB,CAAC;AA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AAC,aAAa,CAAC,WAAW,EAAE;4BAC1D,YAAY,EAAE,OAAO,CAAC,YAAY;4BAClC,MAAM,EAAE,eAAe;4BACvB,YAAY,EAAE,OAAO,CAAC,YAAY;4BAClC,QAAQ,EAAE,OAAO,CAAC,QAAQ;yBAC1B,CAAC;qBACF,CAAC,CAAC;gBACJ,CAAC;qBAAM,IAAI,aAAa,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;oBAC5C,OAAO,CAAC,IAAI,CAAC;wBACZ,MAAM,EAAE,iBAAiB,CAAC,MAAM,CAAC,aAAa,CAAC,WAAW,CAAC;qBAC3D,CAAC,CAAC;oBACH,aAAa,GAAG,aAAa,CAAC,WAAW,CAAC,MAAM,CAAC,GAAG,CAAC;gBACtD,CAAC;YACF,CAAC;YACD,OAAO,OAAO,CAAC;QAChB,CAAC;QACD,MAAM,EAAE,CAAC,aAAa,EAAE,OAAO,EAAE,EAAE;YAClC,MAAM,OAAO,GAAyC,EAAE,CAAC;YACzD,KAAK,MAAM,SAAS,IAAI,aAAa,EAAE,CAAC;gBACvC,OAAO,CAAC,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC,CAAC;YAC3D,CAAC;YACD,OAAO,EAAE,OAAO,EAAE,CAAC;QACpB,CAAC;KACD,EACD,YAAY,CAAC,aAAa,CAC1B,CAAC;AACH,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { fail } from \"@fluidframework/core-utils/internal\";\nimport type { MinimumVersionForCollab } from \"@fluidframework/runtime-definitions/internal\";\nimport {\n\ttype CodecTree,\n\ttype CodecWriteOptions,\n\tDiscriminatedUnionDispatcher,\n\ttype FormatVersion,\n\ttype ICodecFamily,\n\ttype ICodecOptions,\n\ttype IJsonCodec,\n\tmakeCodecFamily,\n\twithSchemaValidation,\n} from \"../codec/index.js\";\nimport {\n\ttype ChangeEncodingContext,\n\tSchemaFormatVersion,\n\ttype TreeStoredSchema,\n} from \"../core/index.js\";\nimport {\n\ttype ModularChangeFormatVersion,\n\ttype ModularChangeset,\n\ttype SchemaChange,\n\tdefaultSchemaPolicy,\n\tgetCodecTreeForModularChangeFormat,\n\tgetCodecTreeForSchemaChangeFormat,\n\tmakeSchemaChangeCodecs,\n} from \"../feature-libraries/index.js\";\nimport {\n\tbrand,\n\ttype Brand,\n\ttype JsonCompatibleReadOnly,\n\ttype Mutable,\n} from \"../util/index.js\";\n\nimport {\n\tEncodedSharedTreeChange,\n\ttype EncodedSharedTreeInnerChange,\n} from \"./sharedTreeChangeFormat.js\";\nimport type { SharedTreeChange, SharedTreeInnerChange } from \"./sharedTreeChangeTypes.js\";\n\nexport function makeSharedTreeChangeCodecFamily(\n\tmodularChangeCodecFamily: ICodecFamily<ModularChangeset, ChangeEncodingContext>,\n\toptions: CodecWriteOptions,\n): ICodecFamily<SharedTreeChange, ChangeEncodingContext> {\n\tconst schemaChangeCodecs = makeSchemaChangeCodecs(options);\n\tconst versions: [\n\t\tFormatVersion,\n\t\tIJsonCodec<\n\t\t\tSharedTreeChange,\n\t\t\tEncodedSharedTreeChange,\n\t\t\tEncodedSharedTreeChange,\n\t\t\tChangeEncodingContext\n\t\t>,\n\t][] = [...dependenciesForChangeFormat.entries()].map(\n\t\t([format, { modularChange, schemaChange }]) => [\n\t\t\tformat,\n\t\t\tmakeSharedTreeChangeCodec(\n\t\t\t\tmodularChangeCodecFamily.resolve(modularChange).json,\n\t\t\t\tschemaChangeCodecs.resolve(schemaChange).json,\n\t\t\t\toptions,\n\t\t\t),\n\t\t],\n\t);\n\treturn makeCodecFamily(versions);\n}\n\ninterface ChangeFormatDependencies {\n\treadonly modularChange: ModularChangeFormatVersion;\n\treadonly schemaChange: SchemaFormatVersion;\n}\n\nexport type SharedTreeChangeFormatVersion = Brand<3 | 4 | 5, \"SharedTreeChangeFormatVersion\">;\n\n/**\n * Defines for each SharedTree change format the corresponding dependent formats to use.\n * This is an arbitrary mapping that is injected in the SharedTree change codec.\n * Once an entry is defined and used in production, it cannot be changed.\n * This is because the format for the dependent formats are not explicitly versioned.\n */\nexport const dependenciesForChangeFormat: Map<\n\tSharedTreeChangeFormatVersion,\n\tChangeFormatDependencies\n> = new Map([\n\t[brand(3), { modularChange: brand(3), schemaChange: SchemaFormatVersion.v1 }],\n\t[brand(4), { modularChange: brand(4), schemaChange: SchemaFormatVersion.v1 }],\n\t[brand(5), { modularChange: brand(5), schemaChange: SchemaFormatVersion.v1 }],\n]);\n\nexport function getCodecTreeForChangeFormat(\n\tversion: SharedTreeChangeFormatVersion,\n\tclientVersion: MinimumVersionForCollab,\n): CodecTree {\n\tconst { modularChange, schemaChange } =\n\t\tdependenciesForChangeFormat.get(version) ?? fail(0xc78 /* Unknown change format */);\n\treturn {\n\t\tname: \"SharedTreeChange\",\n\t\tversion,\n\t\tchildren: [\n\t\t\tgetCodecTreeForModularChangeFormat(modularChange),\n\t\t\tgetCodecTreeForSchemaChangeFormat(schemaChange, clientVersion),\n\t\t],\n\t};\n}\n\nfunction makeSharedTreeChangeCodec(\n\tmodularChangeCodec: IJsonCodec<\n\t\tModularChangeset,\n\t\tJsonCompatibleReadOnly,\n\t\tJsonCompatibleReadOnly,\n\t\tChangeEncodingContext\n\t>,\n\tschemaChangeCodec: IJsonCodec<SchemaChange>,\n\tcodecOptions: ICodecOptions,\n): IJsonCodec<\n\tSharedTreeChange,\n\tEncodedSharedTreeChange,\n\tEncodedSharedTreeChange,\n\tChangeEncodingContext\n> {\n\tconst decoderLibrary = new DiscriminatedUnionDispatcher<\n\t\tEncodedSharedTreeInnerChange,\n\t\t[context: ChangeEncodingContext],\n\t\tSharedTreeInnerChange\n\t>({\n\t\tdata(encoded, context): SharedTreeInnerChange {\n\t\t\treturn {\n\t\t\t\ttype: \"data\",\n\t\t\t\tinnerChange: modularChangeCodec.decode(encoded, context),\n\t\t\t};\n\t\t},\n\t\tschema(encoded): SharedTreeInnerChange {\n\t\t\treturn {\n\t\t\t\ttype: \"schema\",\n\t\t\t\tinnerChange: schemaChangeCodec.decode(encoded),\n\t\t\t};\n\t\t},\n\t});\n\n\treturn withSchemaValidation(\n\t\tEncodedSharedTreeChange,\n\t\t{\n\t\t\tencode: (change, context) => {\n\t\t\t\tconst changes: EncodedSharedTreeInnerChange[] = [];\n\t\t\t\tlet updatedSchema: TreeStoredSchema | undefined;\n\t\t\t\tfor (const decodedChange of change.changes) {\n\t\t\t\t\tif (decodedChange.type === \"data\") {\n\t\t\t\t\t\tconst schemaAndPolicy =\n\t\t\t\t\t\t\tupdatedSchema === undefined\n\t\t\t\t\t\t\t\t? context.schema\n\t\t\t\t\t\t\t\t: {\n\t\t\t\t\t\t\t\t\t\tpolicy:\n\t\t\t\t\t\t\t\t\t\t\tcontext.schema === undefined\n\t\t\t\t\t\t\t\t\t\t\t\t? defaultSchemaPolicy\n\t\t\t\t\t\t\t\t\t\t\t\t: context.schema.policy,\n\t\t\t\t\t\t\t\t\t\tschema: updatedSchema,\n\t\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\tchanges.push({\n\t\t\t\t\t\t\tdata: modularChangeCodec.encode(decodedChange.innerChange, {\n\t\t\t\t\t\t\t\toriginatorId: context.originatorId,\n\t\t\t\t\t\t\t\tschema: schemaAndPolicy,\n\t\t\t\t\t\t\t\tidCompressor: context.idCompressor,\n\t\t\t\t\t\t\t\trevision: context.revision,\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t});\n\t\t\t\t\t} else if (decodedChange.type === \"schema\") {\n\t\t\t\t\t\tchanges.push({\n\t\t\t\t\t\t\tschema: schemaChangeCodec.encode(decodedChange.innerChange),\n\t\t\t\t\t\t});\n\t\t\t\t\t\tupdatedSchema = decodedChange.innerChange.schema.new;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn changes;\n\t\t\t},\n\t\t\tdecode: (encodedChange, context) => {\n\t\t\t\tconst changes: Mutable<SharedTreeChange[\"changes\"]> = [];\n\t\t\t\tfor (const subChange of encodedChange) {\n\t\t\t\t\tchanges.push(decoderLibrary.dispatch(subChange, context));\n\t\t\t\t}\n\t\t\t\treturn { changes };\n\t\t\t},\n\t\t},\n\t\tcodecOptions.jsonValidator,\n\t);\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"sharedTreeChangeEnricher.d.ts","sourceRoot":"","sources":["../../src/shared-tree/sharedTreeChangeEnricher.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAGN,KAAK,kBAAkB,EACvB,KAAK,eAAe,EACpB,KAAK,mBAAmB,EACxB,KAAK,0BAA0B,EAC/B,KAAK,WAAW,EAChB,KAAK,0BAA0B,EAG/B,MAAM,kBAAkB,CAAC;AAS1B,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEjD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,KAAK,EACX,6BAA6B,EAC7B,8BAA8B,EAC9B,MAAM,8BAA8B,CAAC;AACtC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAEnE,qBAAa,gCACZ,YAAW,8BAA8B,CAAC,gBAAgB,CAAC;IAW1D,SAAS,CAAC,QAAQ,CAAC,cAAc,EAAE,mBAAmB;IACtD,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,SAAS,CAAC,QAAQ,CAAC,oBAAoB,EAAE,0BAA0B;IACnE,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAC;IAZ/B;;;;;;;OAOG;gBAEiB,cAAc,EAAE,mBAAmB,EACrC,MAAM,EAAE,0BAA0B,EAChC,oBAAoB,EAAE,0BAA0B,EAClD,YAAY,CAAC,2BAAe;IAGvC,IAAI,IAAI,6BAA6B,CAAC,gBAAgB,CAAC;IAQvD,uBAAuB,CAAC,MAAM,EAAE,gBAAgB,GAAG,gBAAgB;IAS1E,OAAO,CAAC,QAAQ,CAAC,eAAe,CAa9B;CACF;AAED,qBAAa,+BAC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C,oBAAoB,EAAE,0BAA0B,EAClD,YAAY,CAAC,2BAAe;IAGvC,IAAI,IAAI,6BAA6B,CAAC,gBAAgB,CAAC;IAQvD,uBAAuB,CAAC,MAAM,EAAE,gBAAgB,GAAG,gBAAgB;IAS1E,OAAO,CAAC,QAAQ,CAAC,eAAe,CAa9B;CACF;AAED,qBAAa,+BACZ,SAAQ,gCACR,YAAW,6BAA6B,CAAC,gBAAgB,CAAC;IAWzD,OAAO,CAAC,QAAQ,CAAC,MAAM;IAEvB,OAAO,CAAC,QAAQ,CAAC,YAAY;IAX9B;;;;;;;OAOG;gBAEe,MAAM,EAAE,eAAe,EACxC,MAAM,EAAE,0BAA0B,EACjB,YAAY,EAAE,kBAAkB,EACjD,YAAY,CAAC,EAAE,aAAa;IAKtB,cAAc,CAAC,MAAM,EAAE,gBAAgB,EAAE,QAAQ,CAAC,EAAE,WAAW,GAAG,IAAI;IAyBtE,CAAC,aAAa,CAAC,IAAI,IAAI;CAG9B"}
@@ -68,14 +68,16 @@ export class SharedTreeMutableChangeEnricher extends SharedTreeReadonlyChangeEnr
68
68
  visitor.free();
69
69
  break;
70
70
  }
71
- case "schema":
71
+ case "schema": {
72
72
  // This enricher doesn't need to maintain schema information.
73
73
  // Note that the refreshers being generated through `updateChangeEnrichments` will be encoded using
74
74
  // the schema that was used in the input context of the data changeset these refreshers are on.
75
75
  // See the encoding logic in SharedTreeCore for details.
76
76
  break;
77
- default:
77
+ }
78
+ default: {
78
79
  unreachableCase(type);
80
+ }
79
81
  }
80
82
  }
81
83
  }
@@ -1 +1 @@
1
- {"version":3,"file":"sharedTreeChangeEnricher.js","sourceRoot":"","sources":["../../src/shared-tree/sharedTreeChangeEnricher.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAC;AACtE,OAAO,EACN,SAAS,EAQT,SAAS,EACT,UAAU,GACV,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAEN,SAAS,E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!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { unreachableCase } from \"@fluidframework/core-utils/internal\";\nimport {\n\tAnchorSet,\n\ttype DeltaDetachedNodeId,\n\ttype DetachedFieldIndex,\n\ttype IEditableForest,\n\ttype IForestSubscription,\n\ttype ReadOnlyDetachedFieldIndex,\n\ttype RevisionTag,\n\ttype TreeStoredSchemaRepository,\n\ttagChange,\n\tvisitDelta,\n} from \"../core/index.js\";\nimport {\n\ttype TreeChunk,\n\tchunkTree,\n\tdefaultChunkPolicy,\n\tintoDelta,\n\trelevantRemovedRoots,\n\tupdateRefreshers as updateDataChangeRefreshers,\n} from \"../feature-libraries/index.js\";\nimport { disposeSymbol } from \"../util/index.js\";\nimport { updateRefreshers } from \"./sharedTreeChangeFamily.js\";\nimport type { SharedTreeChange } from \"./sharedTreeChangeTypes.js\";\nimport type {\n\tChangeEnricherMutableCheckout,\n\tChangeEnricherReadonlyCheckout,\n} from \"../shared-tree-core/index.js\";\nimport type { IIdCompressor } from \"@fluidframework/id-compressor\";\n\nexport class SharedTreeReadonlyChangeEnricher\n\timplements ChangeEnricherReadonlyCheckout<SharedTreeChange>\n{\n\t/**\n\t * @param borrowedForest - The state based on which to enrich changes.\n\t * Not owned by the constructed instance.\n\t * @param schema - The schema that corresponds to the forest.\n\t * @param borrowedRemovedRoots - The set of removed roots based on which to enrich changes.\n\t * Not owned by the constructed instance.\n\t * @param idCompressor - The id compressor to use when chunking trees.\n\t */\n\tpublic constructor(\n\t\tprotected readonly borrowedForest: IForestSubscription,\n\t\tprivate readonly schema: TreeStoredSchemaRepository,\n\t\tprotected readonly borrowedRemovedRoots: ReadOnlyDetachedFieldIndex,\n\t\tprivate readonly idCompressor?: IIdCompressor,\n\t) {}\n\n\tpublic fork(): ChangeEnricherMutableCheckout<SharedTreeChange> {\n\t\treturn new SharedTreeMutableChangeEnricher(\n\t\t\tthis.borrowedForest.clone(this.schema, new AnchorSet()),\n\t\t\tthis.schema,\n\t\t\tthis.borrowedRemovedRoots.clone(),\n\t\t);\n\t}\n\n\tpublic updateChangeEnrichments(change: SharedTreeChange): SharedTreeChange {\n\t\treturn updateRefreshers(\n\t\t\tchange,\n\t\t\tthis.getDetachedRoot,\n\t\t\trelevantRemovedRoots,\n\t\t\tupdateDataChangeRefreshers,\n\t\t);\n\t}\n\n\tprivate readonly getDetachedRoot = (id: DeltaDetachedNodeId): TreeChunk | undefined => {\n\t\tconst root = this.borrowedRemovedRoots.tryGetEntry(id);\n\t\tif (root !== undefined) {\n\t\t\tconst cursor = this.borrowedForest.getCursorAboveDetachedFields();\n\t\t\tconst parentField = this.borrowedRemovedRoots.toFieldKey(root);\n\t\t\tcursor.enterField(parentField);\n\t\t\tcursor.enterNode(0);\n\t\t\treturn chunkTree(cursor, {\n\t\t\t\tpolicy: defaultChunkPolicy,\n\t\t\t\tidCompressor: this.idCompressor,\n\t\t\t});\n\t\t}\n\t\treturn undefined;\n\t};\n}\n\nexport class SharedTreeMutableChangeEnricher\n\textends SharedTreeReadonlyChangeEnricher\n\timplements ChangeEnricherMutableCheckout<SharedTreeChange>\n{\n\t/**\n\t * @param forest - The state based on which to enrich changes.\n\t * Owned by the constructed instance.\n\t * @param schema - The schema that corresponds to the forest.\n\t * @param removedRoots - The set of removed roots based on which to enrich changes.\n\t * Owned by the constructed instance.\n\t * @param idCompressor - The id compressor to use when chunking trees.\n\t */\n\tpublic constructor(\n\t\tprivate readonly forest: IEditableForest,\n\t\tschema: TreeStoredSchemaRepository,\n\t\tprivate readonly removedRoots: DetachedFieldIndex,\n\t\tidCompressor?: IIdCompressor,\n\t) {\n\t\tsuper(forest, schema, removedRoots, idCompressor);\n\t}\n\n\tpublic applyTipChange(change: SharedTreeChange, revision?: RevisionTag): void {\n\t\tfor (const dataOrSchemaChange of change.changes) {\n\t\t\tconst type = dataOrSchemaChange.type;\n\t\t\tswitch (type) {\n\t\t\t\tcase \"data\": {\n\t\t\t\t\tconst delta = intoDelta(tagChange(dataOrSchemaChange.innerChange, revision));\n\t\t\t\t\tconst visitor = this.forest.acquireVisitor();\n\t\t\t\t\tvisitDelta(delta, visitor, this.removedRoots, revision);\n\t\t\t\t\tvisitor.free();\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcase \"schema\":\n\t\t\t\t\t// This enricher doesn't need to maintain schema information.\n\t\t\t\t\t// Note that the refreshers being generated through `updateChangeEnrichments` will be encoded using\n\t\t\t\t\t// the schema that was used in the input context of the data changeset these refreshers are on.\n\t\t\t\t\t// See the encoding logic in SharedTreeCore for details.\n\t\t\t\t\tbreak;\n\t\t\t\tdefault:\n\t\t\t\t\tunreachableCase(type);\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic [disposeSymbol](): void {\n\t\t// TODO: in the future, forest and/or its AnchorSet may require disposal.\n\t}\n}\n"]}
1
+ {"version":3,"file":"sharedTreeChangeEnricher.js","sourceRoot":"","sources":["../../src/shared-tree/sharedTreeChangeEnricher.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAC;AACtE,OAAO,EACN,SAAS,EAQT,SAAS,EACT,UAAU,GACV,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAEN,SAAS,EACT,kBAAkB,EAClB,SAAS,EACT,oBAAoB,EACpB,gBAAgB,IAAI,0BAA0B,GAC9C,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAQ/D,MAAM,OAAO,gCAAgC;IAG5C;;;;;;;OAOG;IACH,YACoB,cAAmC,EACrC,MAAkC,EAChC,oBAAgD,EAClD,YAA4B;QAH1B,mBAAc,GAAd,cAAc,CAAqB;QACrC,WAAM,GAAN,MAAM,CAA4B;QAChC,yBAAoB,GAApB,oBAAoB,CAA4B;QAClD,iBAAY,GAAZ,YAAY,CAAgB;QAoB7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,CAAC;IAEM,cAAc,CAAC,MAAwB,EAAE,QAAsB;QACrE,KAAK,MAAM,kBAAkB,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC;YACjD,MAAM,IAAI,GAAG,kBAAkB,CAAC,IAAI,CAAC;YACrC,QAAQ,IAAI,EAAE,CAAC;gBACd,KAAK,MAAM,CAAC,CAAC,CAAC;oBACb,MAAM,KAAK,GAAG,SAAS,CAAC,SAAS,CAAC,kBAAkB,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAC,CAAC;oBAC7E,MAAM,OAAO,GAAG,IAAI,CAAC,MAAM,CAAC,cAAc,EAAE,CAAC;oBAC7C,UAAU,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,CAAC,YAAY,EAAE,QAAQ,CAAC,CAAC;oBACxD,OAAO,CAAC,IAAI,EAAE,CAAC;oBACf,MAAM;gBACP,CAAC;gBACD,KAAK,QAAQ,CAAC,CAAC,CAAC;oBACf,6DAA6D;oBAC7D,mGAAmG;oBACnG,+FAA+F;oBAC/F,wDAAwD;oBACxD,MAAM;gBACP,CAAC;gBACD,OAAO,CAAC,CAAC,CAAC;oBACT,eAAe,CAAC,IAAI,CAAC,CAAC;gBACvB,CAAC;YACF,CAAC;QACF,CAAC;IACF,CAAC;IAEM,CAAC,aAAa,CAAC;QACrB,yEAAyE;IAC1E,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { unreachableCase } from \"@fluidframework/core-utils/internal\";\nimport {\n\tAnchorSet,\n\ttype DeltaDetachedNodeId,\n\ttype DetachedFieldIndex,\n\ttype IEditableForest,\n\ttype IForestSubscription,\n\ttype ReadOnlyDetachedFieldIndex,\n\ttype RevisionTag,\n\ttype TreeStoredSchemaRepository,\n\ttagChange,\n\tvisitDelta,\n} from \"../core/index.js\";\nimport {\n\ttype TreeChunk,\n\tchunkTree,\n\tdefaultChunkPolicy,\n\tintoDelta,\n\trelevantRemovedRoots,\n\tupdateRefreshers as updateDataChangeRefreshers,\n} from \"../feature-libraries/index.js\";\nimport { disposeSymbol } from \"../util/index.js\";\nimport { updateRefreshers } from \"./sharedTreeChangeFamily.js\";\nimport type { SharedTreeChange } from \"./sharedTreeChangeTypes.js\";\nimport type {\n\tChangeEnricherMutableCheckout,\n\tChangeEnricherReadonlyCheckout,\n} from \"../shared-tree-core/index.js\";\nimport type { IIdCompressor } from \"@fluidframework/id-compressor\";\n\nexport class SharedTreeReadonlyChangeEnricher\n\timplements ChangeEnricherReadonlyCheckout<SharedTreeChange>\n{\n\t/**\n\t * @param borrowedForest - The state based on which to enrich changes.\n\t * Not owned by the constructed instance.\n\t * @param schema - The schema that corresponds to the forest.\n\t * @param borrowedRemovedRoots - The set of removed roots based on which to enrich changes.\n\t * Not owned by the constructed instance.\n\t * @param idCompressor - The id compressor to use when chunking trees.\n\t */\n\tpublic constructor(\n\t\tprotected readonly borrowedForest: IForestSubscription,\n\t\tprivate readonly schema: TreeStoredSchemaRepository,\n\t\tprotected readonly borrowedRemovedRoots: ReadOnlyDetachedFieldIndex,\n\t\tprivate readonly idCompressor?: IIdCompressor,\n\t) {}\n\n\tpublic fork(): ChangeEnricherMutableCheckout<SharedTreeChange> {\n\t\treturn new SharedTreeMutableChangeEnricher(\n\t\t\tthis.borrowedForest.clone(this.schema, new AnchorSet()),\n\t\t\tthis.schema,\n\t\t\tthis.borrowedRemovedRoots.clone(),\n\t\t);\n\t}\n\n\tpublic updateChangeEnrichments(change: SharedTreeChange): SharedTreeChange {\n\t\treturn updateRefreshers(\n\t\t\tchange,\n\t\t\tthis.getDetachedRoot,\n\t\t\trelevantRemovedRoots,\n\t\t\tupdateDataChangeRefreshers,\n\t\t);\n\t}\n\n\tprivate readonly getDetachedRoot = (id: DeltaDetachedNodeId): TreeChunk | undefined => {\n\t\tconst root = this.borrowedRemovedRoots.tryGetEntry(id);\n\t\tif (root !== undefined) {\n\t\t\tconst cursor = this.borrowedForest.getCursorAboveDetachedFields();\n\t\t\tconst parentField = this.borrowedRemovedRoots.toFieldKey(root);\n\t\t\tcursor.enterField(parentField);\n\t\t\tcursor.enterNode(0);\n\t\t\treturn chunkTree(cursor, {\n\t\t\t\tpolicy: defaultChunkPolicy,\n\t\t\t\tidCompressor: this.idCompressor,\n\t\t\t});\n\t\t}\n\t\treturn undefined;\n\t};\n}\n\nexport class SharedTreeMutableChangeEnricher\n\textends SharedTreeReadonlyChangeEnricher\n\timplements ChangeEnricherMutableCheckout<SharedTreeChange>\n{\n\t/**\n\t * @param forest - The state based on which to enrich changes.\n\t * Owned by the constructed instance.\n\t * @param schema - The schema that corresponds to the forest.\n\t * @param removedRoots - The set of removed roots based on which to enrich changes.\n\t * Owned by the constructed instance.\n\t * @param idCompressor - The id compressor to use when chunking trees.\n\t */\n\tpublic constructor(\n\t\tprivate readonly forest: IEditableForest,\n\t\tschema: TreeStoredSchemaRepository,\n\t\tprivate readonly removedRoots: DetachedFieldIndex,\n\t\tidCompressor?: IIdCompressor,\n\t) {\n\t\tsuper(forest, schema, removedRoots, idCompressor);\n\t}\n\n\tpublic applyTipChange(change: SharedTreeChange, revision?: RevisionTag): void {\n\t\tfor (const dataOrSchemaChange of change.changes) {\n\t\t\tconst type = dataOrSchemaChange.type;\n\t\t\tswitch (type) {\n\t\t\t\tcase \"data\": {\n\t\t\t\t\tconst delta = intoDelta(tagChange(dataOrSchemaChange.innerChange, revision));\n\t\t\t\t\tconst visitor = this.forest.acquireVisitor();\n\t\t\t\t\tvisitDelta(delta, visitor, this.removedRoots, revision);\n\t\t\t\t\tvisitor.free();\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcase \"schema\": {\n\t\t\t\t\t// This enricher doesn't need to maintain schema information.\n\t\t\t\t\t// Note that the refreshers being generated through `updateChangeEnrichments` will be encoded using\n\t\t\t\t\t// the schema that was used in the input context of the data changeset these refreshers are on.\n\t\t\t\t\t// See the encoding logic in SharedTreeCore for details.\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tdefault: {\n\t\t\t\t\tunreachableCase(type);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic [disposeSymbol](): void {\n\t\t// TODO: in the future, forest and/or its AnchorSet may require disposal.\n\t}\n}\n"]}
@@ -4,7 +4,7 @@
4
4
  */
5
5
  import type { IIdCompressor } from "@fluidframework/id-compressor";
6
6
  import type { CodecWriteOptions, ICodecFamily } from "../codec/index.js";
7
- import { type ChangeEncodingContext, type ChangeFamily, type ChangeRebaser, type DeltaDetachedNodeId, type RevisionMetadataSource, type RevisionTag, type RevisionTagCodec, type TaggedChange } from "../core/index.js";
7
+ import { type ChangeEncodingContext, type ChangeFamily, type ChangeRebaser, type DeltaDetachedNodeId, type RevisionMetadataSource, type RevisionReplacer, type RevisionTag, type RevisionTagCodec, type TaggedChange } from "../core/index.js";
8
8
  import { type FieldBatchCodec, type ModularChangeset, type TreeChunk, type TreeCompressionStrategy } from "../feature-libraries/index.js";
9
9
  import type { SharedTreeChange } from "./sharedTreeChangeTypes.js";
10
10
  import { SharedTreeEditBuilder } from "./sharedTreeEditBuilder.js";
@@ -23,7 +23,8 @@ export declare class SharedTreeChangeFamily implements ChangeFamily<SharedTreeEd
23
23
  compose(changes: TaggedChange<SharedTreeChange>[]): SharedTreeChange;
24
24
  invert(change: TaggedChange<SharedTreeChange>, isRollback: boolean, revision: RevisionTag): SharedTreeChange;
25
25
  rebase(change: TaggedChange<SharedTreeChange>, over: TaggedChange<SharedTreeChange>, revisionMetadata: RevisionMetadataSource): SharedTreeChange;
26
- changeRevision(change: SharedTreeChange, newRevision: RevisionTag | undefined, rollbackOf?: RevisionTag): SharedTreeChange;
26
+ getRevisions(change: SharedTreeChange): Set<RevisionTag | undefined>;
27
+ changeRevision(change: SharedTreeChange, replacer: RevisionReplacer): SharedTreeChange;
27
28
  get rebaser(): ChangeRebaser<SharedTreeChange>;
28
29
  }
29
30
  export declare function hasSchemaChange(change: SharedTreeChange): boolean;
@@ -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pE,MAAM,CACZ,MAAM,EAAE,YAAY,CAAC,gBAAgB,CAAC,EACtC,UAAU,EAAE,OAAO,EACnB,QAAQ,EAAE,WAAW,GACnB,gBAAgB;IAqCZ,MAAM,CACZ,MAAM,EAAE,YAAY,CAAC,gBAAgB,CAAC,EACtC,IAAI,EAAE,YAAY,CAAC,gBAAgB,CAAC,EACpC,gBAAgB,EAAE,sBAAsB,GACtC,gBAAgB;IA0CZ,YAAY,CAAC,MAAM,EAAE,gBAAgB,GAAG,GAAG,CAAC,WAAW,GAAG,SAAS,CAAC;IAepE,cAAc,CACpB,MAAM,EAAE,gBAAgB,EACxB,QAAQ,EAAE,gBAAgB,GACxB,gBAAgB;IAMnB,IAAW,OAAO,IAAI,aAAa,CAAC,gBAAgB,CAAC,CAEpD;CACD;AAED,wBAAgB,eAAe,CAAC,MAAM,EAAE,gBAAgB,GAAG,OAAO,CAEjE;AAmBD;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAC/B,MAAM,EAAE,gBAAgB,EACxB,eAAe,EAAE,CAAC,EAAE,EAAE,mBAAmB,KAAK,SAAS,GAAG,SAAS,EACnE,kCAAkC,EAAE,CACnC,YAAY,EAAE,gBAAgB,KAC1B,QAAQ,CAAC,mBAAmB,CAAC,EAClC,0BAA0B,EAAE,CAC3B,MAAM,EAAE,gBAAgB,EACxB,eAAe,EAAE,CAAC,EAAE,EAAE,mBAAmB,KAAK,SAAS,GAAG,SAAS,EACnE,YAAY,EAAE,QAAQ,CAAC,mBAAmB,CAAC,EAC3C,iBAAiB,EAAE,OAAO,KACtB,gBAAgB,GACnB,gBAAgB,CAsDlB"}
@@ -17,7 +17,7 @@ export class SharedTreeChangeFamily {
17
17
  constructor(revisionTagCodec, fieldBatchCodec, codecOptions, chunkCompressionStrategy, idCompressor) {
18
18
  this.idCompressor = idCompressor;
19
19
  const modularChangeCodec = makeModularChangeCodecFamily(fieldKindConfigurations, revisionTagCodec, fieldBatchCodec, codecOptions, chunkCompressionStrategy);
20
- this.modularChangeFamily = new ModularChangeFamily(fieldKinds, modularChangeCodec);
20
+ this.modularChangeFamily = new ModularChangeFamily(fieldKinds, modularChangeCodec, codecOptions);
21
21
  this.codecs = makeSharedTreeChangeCodecFamily(this.modularChangeFamily.codecs, codecOptions);
22
22
  }
23
23
  buildEditor(mintRevisionTag, changeReceiver) {
@@ -52,11 +52,12 @@ export class SharedTreeChangeFamily {
52
52
  invert(change, isRollback, revision) {
53
53
  const invertInnerChange = (innerChange) => {
54
54
  switch (innerChange.type) {
55
- case "data":
55
+ case "data": {
56
56
  return {
57
57
  type: "data",
58
58
  innerChange: this.modularChangeFamily.invert(mapTaggedChange(change, innerChange.innerChange), isRollback, revision),
59
59
  };
60
+ }
60
61
  case "schema": {
61
62
  return {
62
63
  type: "schema",
@@ -69,8 +70,9 @@ export class SharedTreeChangeFamily {
69
70
  },
70
71
  };
71
72
  }
72
- default:
73
+ default: {
73
74
  fail(0xacc /* Unknown SharedTree change type. */);
75
+ }
74
76
  }
75
77
  };
76
78
  return {
@@ -105,17 +107,20 @@ export class SharedTreeChangeFamily {
105
107
  ],
106
108
  };
107
109
  }
108
- changeRevision(change, newRevision, rollbackOf) {
109
- return {
110
- changes: change.changes.map((inner) => {
111
- return inner.type === "data"
112
- ? {
113
- ...inner,
114
- innerChange: this.modularChangeFamily.rebaser.changeRevision(inner.innerChange, newRevision, rollbackOf),
115
- }
116
- : inner;
117
- }),
118
- };
110
+ getRevisions(change) {
111
+ const aggregated = new Set();
112
+ for (const innerChange of change.changes) {
113
+ if (innerChange.type === "data") {
114
+ const innerRevisions = this.modularChangeFamily.rebaser.getRevisions(innerChange.innerChange);
115
+ for (const tag of innerRevisions) {
116
+ aggregated.add(tag);
117
+ }
118
+ }
119
+ }
120
+ return aggregated;
121
+ }
122
+ changeRevision(change, replacer) {
123
+ return mapDataChanges(change, (inner) => this.modularChangeFamily.rebaser.changeRevision(inner, replacer));
119
124
  }
120
125
  get rebaser() {
121
126
  return this;
@@ -1 +1 @@
1
- {"version":3,"file":"sharedTreeChangeFamily.js","sourceRoot":"","sources":["../../src/shared-tree/sharedTreeChangeFamily.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,qCAAqC,CAAC;AAInE,OAAO,EASN,eAAe,GACf,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAEN,mBAAmB,EAInB,uBAAuB,EACvB,UAAU,EACV,4BAA4B,GAC5B,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAGN,cAAc,EACd,SAAS,EACT,iBAAiB,GACjB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAAE,+BAA+B,EAAE,MAAM,6BAA6B,CAAC;AAE9E,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAEnE;;;;GAIG;AACH,MAAM,OAAO,sBAAsB;IAYlC,YACC,gBAAkC,EAClC,eAAgC,EAChC,YAA+B,EAC/B,wBAAkD,EACjC,YAA4B;QAA5B,iBAAY,GAAZ,YAAY,CAAgB;QAE7C,MAAM,kBAAkB,GAAG,4BAA4B,CACtD,uBAAuB,EACvB,gBAAgB,EAChB,eAAe,EACf,YAAY,EACZ,wBAAwB,CACxB,CAAC;QACF,IAAI,CAAC,mBAAmB,GAAG,IAAI,mBAAmB,CAAC,UAAU,EAAE,kBAAkB,CAAC,CAAC;QACnF,IAAI,CAAC,MAAM,GAAG,+BAA+B,CAC5C,IAAI,CAAC,mBAAmB,CAAC,MAAM,EAC/B,YAAY,CACZ,CAAC;IACH,CAAC;IAEM,WAAW,CACjB,eAAkC,EAClC,cAAgE;QAEhE,OAAO,IAAI,qBAAqB,CAC/B,IAAI,CAAC,mBAAmB,EACxB,eAAe,EACf,cAAc,CACd,CAAC;IACH,CAAC;IAEM,OAAO,CAAC,OAAyC;QACvD,MAAM,UAAU,GAAyC,EAAE,CAAC;QAC5D,MAAM,aAAa,GAAqC,EAAE,CAAC;QAE3D,MAAM,kBAAkB,GAAG,GA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AkC,CAAC,UAAU,CAAC,CAAC;QACpE,IAAI,iBAAiB,EAAE,CAAC;YACvB,iBAAiB,GAAG,KAAK,CAAC;YAC1B,OAAO,0BAA0B,CAChC,UAAU,EACV,0BAA0B,EAC1B,YAAY,EACZ,IAAI,CACJ,CAAC;QACH,CAAC;aAAM,CAAC;YACP,OAAO,0BAA0B,CAChC,UAAU,EACV,0BAA0B,EAC1B,mBAAmB,CAAC,YAAY,CAAC,EACjC,KAAK,CACL,CAAC;QACH,CAAC;IACF,CAAC,CAAC,CAAC;AACJ,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\";\nimport type { IIdCompressor } from \"@fluidframework/id-compressor\";\n\nimport type { CodecWriteOptions, ICodecFamily } from \"../codec/index.js\";\nimport {\n\ttype ChangeEncodingContext,\n\ttype ChangeFamily,\n\ttype ChangeRebaser,\n\ttype DeltaDetachedNodeId,\n\ttype RevisionMetadataSource,\n\ttype RevisionTag,\n\ttype RevisionTagCodec,\n\ttype TaggedChange,\n\tmapTaggedChange,\n} from \"../core/index.js\";\nimport {\n\ttype FieldBatchCodec,\n\tModularChangeFamily,\n\ttype ModularChangeset,\n\ttype TreeChunk,\n\ttype TreeCompressionStrategy,\n\tfieldKindConfigurations,\n\tfieldKinds,\n\tmakeModularChangeCodecFamily,\n} from \"../feature-libraries/index.js\";\nimport {\n\ttype Mutable,\n\ttype NestedSet,\n\taddToNestedSet,\n\thasSingle,\n\tnestedSetContains,\n} from \"../util/index.js\";\n\nimport { makeSharedTreeChangeCodecFamily } from \"./sharedTreeChangeCodecs.js\";\nimport type { SharedTreeChange } from \"./sharedTreeChangeTypes.js\";\nimport { SharedTreeEditBuilder } from \"./sharedTreeEditBuilder.js\";\n\n/**\n * Implementation of {@link ChangeFamily} that combines edits to fields and schema changes.\n *\n * @sealed\n */\nexport class SharedTreeChangeFamily\n\timplements\n\t\tChangeFamily<SharedTreeEditBuilder, SharedTreeChange>,\n\t\tChangeRebaser<SharedTreeChange>\n{\n\tpublic static readonly emptyChange: SharedTreeChange = {\n\t\tchanges: [],\n\t};\n\n\tpublic readonly codecs: ICodecFamily<SharedTreeChange, ChangeEncodingContext>;\n\tprivate readonly modularChangeFamily: ModularChangeFamily;\n\n\tpublic constructor(\n\t\trevisionTagCodec: RevisionTagCodec,\n\t\tfieldBatchCodec: FieldBatchCodec,\n\t\tcodecOptions: CodecWriteOptions,\n\t\tchunkCompressionStrategy?: TreeCompressionStrategy,\n\t\tprivate readonly idCompressor?: IIdCompressor,\n\t) {\n\t\tconst modularChangeCodec = makeModularChangeCodecFamily(\n\t\t\tfieldKindConfigurations,\n\t\t\trevisionTagCodec,\n\t\t\tfieldBatchCodec,\n\t\t\tcodecOptions,\n\t\t\tchunkCompressionStrategy,\n\t\t);\n\t\tthis.modularChangeFamily = new ModularChangeFamily(fieldKinds, modularChangeCodec);\n\t\tthis.codecs = makeSharedTreeChangeCodecFamily(\n\t\t\tthis.modularChangeFamily.codecs,\n\t\t\tcodecOptions,\n\t\t);\n\t}\n\n\tpublic buildEditor(\n\t\tmintRevisionTag: () => RevisionTag,\n\t\tchangeReceiver: (change: TaggedChange<SharedTreeChange>) => void,\n\t): SharedTreeEditBuilder {\n\t\treturn new SharedTreeEditBuilder(\n\t\t\tthis.modularChangeFamily,\n\t\t\tmintRevisionTag,\n\t\t\tchangeReceiver,\n\t\t);\n\t}\n\n\tpublic compose(changes: TaggedChange<SharedTreeChange>[]): SharedTreeChange {\n\t\tconst newChanges: Mutable<SharedTreeChange[\"changes\"]> = [];\n\t\tconst dataChangeRun: TaggedChange<ModularChangeset>[] = [];\n\n\t\tconst flushDataChangeRun = (): void => {\n\t\t\tif (dataChangeRun.length > 0) {\n\t\t\t\tnewChanges.push({\n\t\t\t\t\ttype: \"data\",\n\t\t\t\t\tinnerChange: this.modularChangeFamily.compose(dataChangeRun),\n\t\t\t\t});\n\t\t\t\tdataChangeRun.length = 0;\n\t\t\t}\n\t\t};\n\n\t\tfor (const topChange of changes) {\n\t\t\tfor (const change of topChange.change.changes) {\n\t\t\t\tif (change.type === \"schema\") {\n\t\t\t\t\tflushDataChangeRun();\n\t\t\t\t\tnewChanges.push(change);\n\t\t\t\t} else {\n\t\t\t\t\tdataChangeRun.push(mapTaggedChange(topChange, change.innerChange));\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tflushDataChangeRun();\n\t\treturn { changes: newChanges };\n\t}\n\n\tpublic invert(\n\t\tchange: TaggedChange<SharedTreeChange>,\n\t\tisRollback: boolean,\n\t\trevision: RevisionTag,\n\t): SharedTreeChange {\n\t\tconst invertInnerChange: (\n\t\t\tinnerChange: SharedTreeChange[\"changes\"][number],\n\t\t) => SharedTreeChange[\"changes\"][number] = (innerChange) => {\n\t\t\tswitch (innerChange.type) {\n\t\t\t\tcase \"data\":\n\t\t\t\t\treturn {\n\t\t\t\t\t\ttype: \"data\",\n\t\t\t\t\t\tinnerChange: this.modularChangeFamily.invert(\n\t\t\t\t\t\t\tmapTaggedChange(change, innerChange.innerChange),\n\t\t\t\t\t\t\tisRollback,\n\t\t\t\t\t\t\trevision,\n\t\t\t\t\t\t),\n\t\t\t\t\t};\n\t\t\t\tcase \"schema\": {\n\t\t\t\t\treturn {\n\t\t\t\t\t\ttype: \"schema\",\n\t\t\t\t\t\tinnerChange: {\n\t\t\t\t\t\t\tschema: {\n\t\t\t\t\t\t\t\tnew: innerChange.innerChange.schema.old,\n\t\t\t\t\t\t\t\told: innerChange.innerChange.schema.new,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tisInverse: true,\n\t\t\t\t\t\t},\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t\tdefault:\n\t\t\t\t\tfail(0xacc /* Unknown SharedTree change type. */);\n\t\t\t}\n\t\t};\n\t\treturn {\n\t\t\tchanges: change.change.changes.map(invertInnerChange).reverse(),\n\t\t};\n\t}\n\n\tpublic rebase(\n\t\tchange: TaggedChange<SharedTreeChange>,\n\t\tover: TaggedChange<SharedTreeChange>,\n\t\trevisionMetadata: RevisionMetadataSource,\n\t): SharedTreeChange {\n\t\tif (change.change.changes.length === 0 || over.change.changes.length === 0) {\n\t\t\treturn change.change;\n\t\t}\n\n\t\tif (hasSchemaChange(change.change) || hasSchemaChange(over.change)) {\n\t\t\t// Any SharedTreeChange (a list of sub-changes) that contains a schema change will cause ANY change that rebases over it to conflict.\n\t\t\t// Similarly, any SharedTreeChange containing a schema change will fail to rebase over ANY change.\n\t\t\t// Those two combine to mean: no concurrency with schema changes is supported.\n\t\t\t// This is fine because it's an open problem. Example: a tree with an A at the root and a schema that allows an A | B at the root will\n\t\t\t// become out of schema if a schema changes to restrict root types to just A is concurrent with a data change that sets it to a B.\n\t\t\t// We don't have an efficient way to detect this document-wide and there are varying opinions on restricting schema changes to prevent this.\n\t\t\t// A SharedTreeChange containing a schema change will NOT conflict in a non-concurrency case, as the \"meatless sandwich\" optimization\n\t\t\t// will result in rebase never being called.\n\t\t\treturn SharedTreeChangeFamily.emptyChange;\n\t\t}\n\t\tassert(\n\t\t\thasSingle(change.change.changes) && hasSingle(over.change.changes),\n\t\t\t0x884 /* SharedTreeChange should have exactly one inner change if no schema change is present. */,\n\t\t);\n\n\t\tconst dataChangeIntention = change.change.changes[0];\n\t\tconst dataChangeOver = over.change.changes[0];\n\t\tassert(\n\t\t\tdataChangeIntention.type === \"data\" && dataChangeOver.type === \"data\",\n\t\t\t0x885 /* Data change should be present. */,\n\t\t);\n\n\t\treturn {\n\t\t\tchanges: [\n\t\t\t\t{\n\t\t\t\t\ttype: \"data\",\n\t\t\t\t\tinnerChange: this.modularChangeFamily.rebase(\n\t\t\t\t\t\tmapTaggedChange(change, dataChangeIntention.innerChange),\n\t\t\t\t\t\tmapTaggedChange(over, dataChangeOver.innerChange),\n\t\t\t\t\t\trevisionMetadata,\n\t\t\t\t\t),\n\t\t\t\t},\n\t\t\t],\n\t\t};\n\t}\n\n\tpublic changeRevision(\n\t\tchange: SharedTreeChange,\n\t\tnewRevision: RevisionTag | undefined,\n\t\trollbackOf?: RevisionTag,\n\t): SharedTreeChange {\n\t\treturn {\n\t\t\tchanges: change.changes.map((inner) => {\n\t\t\t\treturn inner.type === \"data\"\n\t\t\t\t\t? {\n\t\t\t\t\t\t\t...inner,\n\t\t\t\t\t\t\tinnerChange: this.modularChangeFamily.rebaser.changeRevision(\n\t\t\t\t\t\t\t\tinner.innerChange,\n\t\t\t\t\t\t\t\tnewRevision,\n\t\t\t\t\t\t\t\trollbackOf,\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t}\n\t\t\t\t\t: inner;\n\t\t\t}),\n\t\t};\n\t}\n\n\tpublic get rebaser(): ChangeRebaser<SharedTreeChange> {\n\t\treturn this;\n\t}\n}\n\nexport function hasSchemaChange(change: SharedTreeChange): boolean {\n\treturn change.changes.some((innerChange) => innerChange.type === \"schema\");\n}\n\nfunction mapDataChanges(\n\tchange: SharedTreeChange,\n\tmap: (change: ModularChangeset) => ModularChangeset,\n): SharedTreeChange {\n\treturn {\n\t\tchanges: change.changes.map((dataOrSchemaChange) => {\n\t\t\tif (dataOrSchemaChange.type === \"data\") {\n\t\t\t\treturn {\n\t\t\t\t\ttype: \"data\",\n\t\t\t\t\tinnerChange: map(dataOrSchemaChange.innerChange),\n\t\t\t\t};\n\t\t\t}\n\t\t\treturn dataOrSchemaChange;\n\t\t}),\n\t};\n}\n\n/**\n * Produces an equivalent change with an updated set of appropriate refreshers.\n * @param change - The change to compute refreshers for. Not mutated.\n * @param getDetachedNode - retrieves a {@link TreeChunk} for the corresponding detached node id.\n * Is expected to read from a forest in a state that corresponds to the input context of the given change.\n * @returns An equivalent change with an updated set of appropriate refreshers.\n */\nexport function updateRefreshers(\n\tchange: SharedTreeChange,\n\tgetDetachedNode: (id: DeltaDetachedNodeId) => TreeChunk | undefined,\n\trelevantRemovedRootsFromDataChange: (\n\t\ttaggedChange: ModularChangeset,\n\t) => Iterable<DeltaDetachedNodeId>,\n\tupdateDataChangeRefreshers: (\n\t\tchange: ModularChangeset,\n\t\tgetDetachedNode: (id: DeltaDetachedNodeId) => TreeChunk | undefined,\n\t\tremovedRoots: Iterable<DeltaDetachedNodeId>,\n\t\trequireRefreshers: boolean,\n\t) => ModularChangeset,\n): SharedTreeChange {\n\t// Adding refreshers to a SharedTreeChange is not as simple as adding refreshers to each of its data changes.\n\t// This is because earlier data changes affect the state of the forest in ways that can influence the refreshers\n\t// needed for later data changes. This can happen in two ways:\n\t// 1. By removing a tree that is a relevant root to a later data change.\n\t// 2. By changing the contents of a tree that is a relevant root to a later data change.\n\t// (Note that these two cases can compound)\n\t// Thankfully, in both of these cases, refreshers can be omitted from the later data changes because the forest\n\t// applying those data changes is guaranteed to still have have the relevant trees in memory.\n\t// This means that for the first data change, all required refreshers should be added (and none should be missing).\n\t// While for later data changes, we should not include refreshers that either:\n\t// A) were already included in the earlier data changes\n\t// B) correspond to trees that were removed by earlier data changes\n\t// Set A is excluded by tracking which roots have already been included in the earlier data changes, and filtering\n\t// them out from the relevant removed roots.\n\t// Set B is excluded because the `getDetachedNode` is bound to return `undefined` for them, which tell\n\t// `defaultUpdateRefreshers` to ignore. One downside of this approach is that it prevents `defaultUpdateRefreshers`\n\t// from detecting cases where a detached node is missing for another reason (which would be a bug).\n\n\t// The roots that have been included as refreshers across all data changes so far.\n\tconst includedRoots: NestedSet<RevisionTag | undefined, number> = new Map();\n\tfunction getAndRememberDetachedNode(id: DeltaDetachedNodeId): TreeChunk | undefined {\n\t\taddToNestedSet(includedRoots, id.major, id.minor);\n\t\treturn getDetachedNode(id);\n\t}\n\tfunction* filterIncludedRoots(\n\t\ttoFilter: Iterable<DeltaDetachedNodeId>,\n\t): Iterable<DeltaDetachedNodeId> {\n\t\tfor (const id of toFilter) {\n\t\t\tif (!nestedSetContains(includedRoots, id.major, id.minor)) {\n\t\t\t\tyield id;\n\t\t\t}\n\t\t}\n\t}\n\tlet isFirstDataChange = true;\n\treturn mapDataChanges(change, (dataChange) => {\n\t\tconst removedRoots = relevantRemovedRootsFromDataChange(dataChange);\n\t\tif (isFirstDataChange) {\n\t\t\tisFirstDataChange = false;\n\t\t\treturn updateDataChangeRefreshers(\n\t\t\t\tdataChange,\n\t\t\t\tgetAndRememberDetachedNode,\n\t\t\t\tremovedRoots,\n\t\t\t\ttrue,\n\t\t\t);\n\t\t} else {\n\t\t\treturn updateDataChangeRefreshers(\n\t\t\t\tdataChange,\n\t\t\t\tgetAndRememberDetachedNode,\n\t\t\t\tfilterIncludedRoots(removedRoots),\n\t\t\t\tfalse,\n\t\t\t);\n\t\t}\n\t});\n}\n"]}
1
+ {"version":3,"file":"sharedTreeChangeFamily.js","sourceRoot":"","sources":["../../src/shared-tree/sharedTreeChangeFamily.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,qCAAqC,CAAC;AAInE,OAAO,EAUN,eAAe,GACf,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAEN,mBAAmB,EAInB,uBAAuB,EACvB,UAAU,EACV,4BAA4B,GAC5B,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAGN,cAAc,EACd,SAAS,EACT,iBAAiB,GACjB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAAE,+BAA+B,EAAE,MAAM,6BAA6B,CAAC;AAE9E,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAEnE;;;;GAIG;AACH,MAAM,OAAO,sBAAsB;IAYlC,YACC,gBAAkC,EAClC,eAAgC,EAChC,YAA+B,EAC/B,wBAAkD,EACjC,YAA4B;QAA5B,iBAAY,GAAZ,YAAY,CAAgB;QAE7C,MAAM,kBAAkB,GAAG,4BAA4B,CACtD,uBAAuB,EACvB,gBAAgB,EAChB,eAAe,EACf,YAAY,EACZ,wBAAwB,CACxB,CAAC;QACF,IAAI,CAAC,mBAAmB,GAAG,IAAI,mBAAmB,CACjD,UAAU,EAC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EAA8E;IAC9E,uDAAuD;IACvD,mEAAmE;IACnE,kHAAkH;IAClH,4CAA4C;IAC5C,sGAAsG;IACtG,mHAAmH;IACnH,mGAAmG;IAEnG,kFAAkF;IAClF,MAAM,aAAa,GAA+C,IAAI,GAAG,EAAE,CAAC;IAC5E,SAAS,0BAA0B,CAAC,EAAuB;QAC1D,cAAc,CAAC,aAAa,EAAE,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,CAAC;QAClD,OAAO,eAAe,CAAC,EAAE,CAAC,CAAC;IAC5B,CAAC;IACD,QAAQ,CAAC,CAAC,mBAAmB,CAC5B,QAAuC;QAEvC,KAAK,MAAM,EAAE,IAAI,QAAQ,EAAE,CAAC;YAC3B,IAAI,CAAC,iBAAiB,CAAC,aAAa,EAAE,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC;gBAC3D,MAAM,EAAE,CAAC;YACV,CAAC;QACF,CAAC;IACF,CAAC;IACD,IAAI,iBAAiB,GAAG,IAAI,CAAC;IAC7B,OAAO,cAAc,CAAC,MAAM,EAAE,CAAC,UAAU,EAAE,EAAE;QAC5C,MAAM,YAAY,GAAG,kCAAkC,CAAC,UAAU,CAAC,CAAC;QACpE,IAAI,iBAAiB,EAAE,CAAC;YACvB,iBAAiB,GAAG,KAAK,CAAC;YAC1B,OAAO,0BAA0B,CAChC,UAAU,EACV,0BAA0B,EAC1B,YAAY,EACZ,IAAI,CACJ,CAAC;QACH,CAAC;aAAM,CAAC;YACP,OAAO,0BAA0B,CAChC,UAAU,EACV,0BAA0B,EAC1B,mBAAmB,CAAC,YAAY,CAAC,EACjC,KAAK,CACL,CAAC;QACH,CAAC;IACF,CAAC,CAAC,CAAC;AACJ,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\";\nimport type { IIdCompressor } from \"@fluidframework/id-compressor\";\n\nimport type { CodecWriteOptions, ICodecFamily } from \"../codec/index.js\";\nimport {\n\ttype ChangeEncodingContext,\n\ttype ChangeFamily,\n\ttype ChangeRebaser,\n\ttype DeltaDetachedNodeId,\n\ttype RevisionMetadataSource,\n\ttype RevisionReplacer,\n\ttype RevisionTag,\n\ttype RevisionTagCodec,\n\ttype TaggedChange,\n\tmapTaggedChange,\n} from \"../core/index.js\";\nimport {\n\ttype FieldBatchCodec,\n\tModularChangeFamily,\n\ttype ModularChangeset,\n\ttype TreeChunk,\n\ttype TreeCompressionStrategy,\n\tfieldKindConfigurations,\n\tfieldKinds,\n\tmakeModularChangeCodecFamily,\n} from \"../feature-libraries/index.js\";\nimport {\n\ttype Mutable,\n\ttype NestedSet,\n\taddToNestedSet,\n\thasSingle,\n\tnestedSetContains,\n} from \"../util/index.js\";\n\nimport { makeSharedTreeChangeCodecFamily } from \"./sharedTreeChangeCodecs.js\";\nimport type { SharedTreeChange } from \"./sharedTreeChangeTypes.js\";\nimport { SharedTreeEditBuilder } from \"./sharedTreeEditBuilder.js\";\n\n/**\n * Implementation of {@link ChangeFamily} that combines edits to fields and schema changes.\n *\n * @sealed\n */\nexport class SharedTreeChangeFamily\n\timplements\n\t\tChangeFamily<SharedTreeEditBuilder, SharedTreeChange>,\n\t\tChangeRebaser<SharedTreeChange>\n{\n\tpublic static readonly emptyChange: SharedTreeChange = {\n\t\tchanges: [],\n\t};\n\n\tpublic readonly codecs: ICodecFamily<SharedTreeChange, ChangeEncodingContext>;\n\tprivate readonly modularChangeFamily: ModularChangeFamily;\n\n\tpublic constructor(\n\t\trevisionTagCodec: RevisionTagCodec,\n\t\tfieldBatchCodec: FieldBatchCodec,\n\t\tcodecOptions: CodecWriteOptions,\n\t\tchunkCompressionStrategy?: TreeCompressionStrategy,\n\t\tprivate readonly idCompressor?: IIdCompressor,\n\t) {\n\t\tconst modularChangeCodec = makeModularChangeCodecFamily(\n\t\t\tfieldKindConfigurations,\n\t\t\trevisionTagCodec,\n\t\t\tfieldBatchCodec,\n\t\t\tcodecOptions,\n\t\t\tchunkCompressionStrategy,\n\t\t);\n\t\tthis.modularChangeFamily = new ModularChangeFamily(\n\t\t\tfieldKinds,\n\t\t\tmodularChangeCodec,\n\t\t\tcodecOptions,\n\t\t);\n\t\tthis.codecs = makeSharedTreeChangeCodecFamily(\n\t\t\tthis.modularChangeFamily.codecs,\n\t\t\tcodecOptions,\n\t\t);\n\t}\n\n\tpublic buildEditor(\n\t\tmintRevisionTag: () => RevisionTag,\n\t\tchangeReceiver: (change: TaggedChange<SharedTreeChange>) => void,\n\t): SharedTreeEditBuilder {\n\t\treturn new SharedTreeEditBuilder(\n\t\t\tthis.modularChangeFamily,\n\t\t\tmintRevisionTag,\n\t\t\tchangeReceiver,\n\t\t);\n\t}\n\n\tpublic compose(changes: TaggedChange<SharedTreeChange>[]): SharedTreeChange {\n\t\tconst newChanges: Mutable<SharedTreeChange[\"changes\"]> = [];\n\t\tconst dataChangeRun: TaggedChange<ModularChangeset>[] = [];\n\n\t\tconst flushDataChangeRun = (): void => {\n\t\t\tif (dataChangeRun.length > 0) {\n\t\t\t\tnewChanges.push({\n\t\t\t\t\ttype: \"data\",\n\t\t\t\t\tinnerChange: this.modularChangeFamily.compose(dataChangeRun),\n\t\t\t\t});\n\t\t\t\tdataChangeRun.length = 0;\n\t\t\t}\n\t\t};\n\n\t\tfor (const topChange of changes) {\n\t\t\tfor (const change of topChange.change.changes) {\n\t\t\t\tif (change.type === \"schema\") {\n\t\t\t\t\tflushDataChangeRun();\n\t\t\t\t\tnewChanges.push(change);\n\t\t\t\t} else {\n\t\t\t\t\tdataChangeRun.push(mapTaggedChange(topChange, change.innerChange));\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tflushDataChangeRun();\n\t\treturn { changes: newChanges };\n\t}\n\n\tpublic invert(\n\t\tchange: TaggedChange<SharedTreeChange>,\n\t\tisRollback: boolean,\n\t\trevision: RevisionTag,\n\t): SharedTreeChange {\n\t\tconst invertInnerChange: (\n\t\t\tinnerChange: SharedTreeChange[\"changes\"][number],\n\t\t) => SharedTreeChange[\"changes\"][number] = (innerChange) => {\n\t\t\tswitch (innerChange.type) {\n\t\t\t\tcase \"data\": {\n\t\t\t\t\treturn {\n\t\t\t\t\t\ttype: \"data\",\n\t\t\t\t\t\tinnerChange: this.modularChangeFamily.invert(\n\t\t\t\t\t\t\tmapTaggedChange(change, innerChange.innerChange),\n\t\t\t\t\t\t\tisRollback,\n\t\t\t\t\t\t\trevision,\n\t\t\t\t\t\t),\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t\tcase \"schema\": {\n\t\t\t\t\treturn {\n\t\t\t\t\t\ttype: \"schema\",\n\t\t\t\t\t\tinnerChange: {\n\t\t\t\t\t\t\tschema: {\n\t\t\t\t\t\t\t\tnew: innerChange.innerChange.schema.old,\n\t\t\t\t\t\t\t\told: innerChange.innerChange.schema.new,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tisInverse: true,\n\t\t\t\t\t\t},\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t\tdefault: {\n\t\t\t\t\tfail(0xacc /* Unknown SharedTree change type. */);\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\t\treturn {\n\t\t\tchanges: change.change.changes.map(invertInnerChange).reverse(),\n\t\t};\n\t}\n\n\tpublic rebase(\n\t\tchange: TaggedChange<SharedTreeChange>,\n\t\tover: TaggedChange<SharedTreeChange>,\n\t\trevisionMetadata: RevisionMetadataSource,\n\t): SharedTreeChange {\n\t\tif (change.change.changes.length === 0 || over.change.changes.length === 0) {\n\t\t\treturn change.change;\n\t\t}\n\n\t\tif (hasSchemaChange(change.change) || hasSchemaChange(over.change)) {\n\t\t\t// Any SharedTreeChange (a list of sub-changes) that contains a schema change will cause ANY change that rebases over it to conflict.\n\t\t\t// Similarly, any SharedTreeChange containing a schema change will fail to rebase over ANY change.\n\t\t\t// Those two combine to mean: no concurrency with schema changes is supported.\n\t\t\t// This is fine because it's an open problem. Example: a tree with an A at the root and a schema that allows an A | B at the root will\n\t\t\t// become out of schema if a schema changes to restrict root types to just A is concurrent with a data change that sets it to a B.\n\t\t\t// We don't have an efficient way to detect this document-wide and there are varying opinions on restricting schema changes to prevent this.\n\t\t\t// A SharedTreeChange containing a schema change will NOT conflict in a non-concurrency case, as the \"meatless sandwich\" optimization\n\t\t\t// will result in rebase never being called.\n\t\t\treturn SharedTreeChangeFamily.emptyChange;\n\t\t}\n\t\tassert(\n\t\t\thasSingle(change.change.changes) && hasSingle(over.change.changes),\n\t\t\t0x884 /* SharedTreeChange should have exactly one inner change if no schema change is present. */,\n\t\t);\n\n\t\tconst dataChangeIntention = change.change.changes[0];\n\t\tconst dataChangeOver = over.change.changes[0];\n\t\tassert(\n\t\t\tdataChangeIntention.type === \"data\" && dataChangeOver.type === \"data\",\n\t\t\t0x885 /* Data change should be present. */,\n\t\t);\n\n\t\treturn {\n\t\t\tchanges: [\n\t\t\t\t{\n\t\t\t\t\ttype: \"data\",\n\t\t\t\t\tinnerChange: this.modularChangeFamily.rebase(\n\t\t\t\t\t\tmapTaggedChange(change, dataChangeIntention.innerChange),\n\t\t\t\t\t\tmapTaggedChange(over, dataChangeOver.innerChange),\n\t\t\t\t\t\trevisionMetadata,\n\t\t\t\t\t),\n\t\t\t\t},\n\t\t\t],\n\t\t};\n\t}\n\n\tpublic getRevisions(change: SharedTreeChange): Set<RevisionTag | undefined> {\n\t\tconst aggregated: Set<RevisionTag | undefined> = new Set();\n\t\tfor (const innerChange of change.changes) {\n\t\t\tif (innerChange.type === \"data\") {\n\t\t\t\tconst innerRevisions = this.modularChangeFamily.rebaser.getRevisions(\n\t\t\t\t\tinnerChange.innerChange,\n\t\t\t\t);\n\t\t\t\tfor (const tag of innerRevisions) {\n\t\t\t\t\taggregated.add(tag);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn aggregated;\n\t}\n\n\tpublic changeRevision(\n\t\tchange: SharedTreeChange,\n\t\treplacer: RevisionReplacer,\n\t): SharedTreeChange {\n\t\treturn mapDataChanges(change, (inner) =>\n\t\t\tthis.modularChangeFamily.rebaser.changeRevision(inner, replacer),\n\t\t);\n\t}\n\n\tpublic get rebaser(): ChangeRebaser<SharedTreeChange> {\n\t\treturn this;\n\t}\n}\n\nexport function hasSchemaChange(change: SharedTreeChange): boolean {\n\treturn change.changes.some((innerChange) => innerChange.type === \"schema\");\n}\n\nfunction mapDataChanges(\n\tchange: SharedTreeChange,\n\tmap: (change: ModularChangeset) => ModularChangeset,\n): SharedTreeChange {\n\treturn {\n\t\tchanges: change.changes.map((dataOrSchemaChange) => {\n\t\t\tif (dataOrSchemaChange.type === \"data\") {\n\t\t\t\treturn {\n\t\t\t\t\ttype: \"data\",\n\t\t\t\t\tinnerChange: map(dataOrSchemaChange.innerChange),\n\t\t\t\t};\n\t\t\t}\n\t\t\treturn dataOrSchemaChange;\n\t\t}),\n\t};\n}\n\n/**\n * Produces an equivalent change with an updated set of appropriate refreshers.\n * @param change - The change to compute refreshers for. Not mutated.\n * @param getDetachedNode - retrieves a {@link TreeChunk} for the corresponding detached node id.\n * Is expected to read from a forest in a state that corresponds to the input context of the given change.\n * @returns An equivalent change with an updated set of appropriate refreshers.\n */\nexport function updateRefreshers(\n\tchange: SharedTreeChange,\n\tgetDetachedNode: (id: DeltaDetachedNodeId) => TreeChunk | undefined,\n\trelevantRemovedRootsFromDataChange: (\n\t\ttaggedChange: ModularChangeset,\n\t) => Iterable<DeltaDetachedNodeId>,\n\tupdateDataChangeRefreshers: (\n\t\tchange: ModularChangeset,\n\t\tgetDetachedNode: (id: DeltaDetachedNodeId) => TreeChunk | undefined,\n\t\tremovedRoots: Iterable<DeltaDetachedNodeId>,\n\t\trequireRefreshers: boolean,\n\t) => ModularChangeset,\n): SharedTreeChange {\n\t// Adding refreshers to a SharedTreeChange is not as simple as adding refreshers to each of its data changes.\n\t// This is because earlier data changes affect the state of the forest in ways that can influence the refreshers\n\t// needed for later data changes. This can happen in two ways:\n\t// 1. By removing a tree that is a relevant root to a later data change.\n\t// 2. By changing the contents of a tree that is a relevant root to a later data change.\n\t// (Note that these two cases can compound)\n\t// Thankfully, in both of these cases, refreshers can be omitted from the later data changes because the forest\n\t// applying those data changes is guaranteed to still have have the relevant trees in memory.\n\t// This means that for the first data change, all required refreshers should be added (and none should be missing).\n\t// While for later data changes, we should not include refreshers that either:\n\t// A) were already included in the earlier data changes\n\t// B) correspond to trees that were removed by earlier data changes\n\t// Set A is excluded by tracking which roots have already been included in the earlier data changes, and filtering\n\t// them out from the relevant removed roots.\n\t// Set B is excluded because the `getDetachedNode` is bound to return `undefined` for them, which tell\n\t// `defaultUpdateRefreshers` to ignore. One downside of this approach is that it prevents `defaultUpdateRefreshers`\n\t// from detecting cases where a detached node is missing for another reason (which would be a bug).\n\n\t// The roots that have been included as refreshers across all data changes so far.\n\tconst includedRoots: NestedSet<RevisionTag | undefined, number> = new Map();\n\tfunction getAndRememberDetachedNode(id: DeltaDetachedNodeId): TreeChunk | undefined {\n\t\taddToNestedSet(includedRoots, id.major, id.minor);\n\t\treturn getDetachedNode(id);\n\t}\n\tfunction* filterIncludedRoots(\n\t\ttoFilter: Iterable<DeltaDetachedNodeId>,\n\t): Iterable<DeltaDetachedNodeId> {\n\t\tfor (const id of toFilter) {\n\t\t\tif (!nestedSetContains(includedRoots, id.major, id.minor)) {\n\t\t\t\tyield id;\n\t\t\t}\n\t\t}\n\t}\n\tlet isFirstDataChange = true;\n\treturn mapDataChanges(change, (dataChange) => {\n\t\tconst removedRoots = relevantRemovedRootsFromDataChange(dataChange);\n\t\tif (isFirstDataChange) {\n\t\t\tisFirstDataChange = false;\n\t\t\treturn updateDataChangeRefreshers(\n\t\t\t\tdataChange,\n\t\t\t\tgetAndRememberDetachedNode,\n\t\t\t\tremovedRoots,\n\t\t\t\ttrue,\n\t\t\t);\n\t\t} else {\n\t\t\treturn updateDataChangeRefreshers(\n\t\t\t\tdataChange,\n\t\t\t\tgetAndRememberDetachedNode,\n\t\t\t\tfilterIncludedRoots(removedRoots),\n\t\t\t\tfalse,\n\t\t\t);\n\t\t}\n\t});\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"sharedTreeEditBuilder.d.ts","sourceRoot":"","sources":["../../src/shared-tree/sharedTreeEditBuilder.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EACX,kBAAkB,EAClB,WAAW,EACX,YAAY,EACZ,gBAAgB,EAChB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACN,kBAAkB,EAClB,KAAK,mBAAmB,EACxB,KAAK,mBAAmB,EACxB,MAAM,+BAA+B,CAAC;AAEvC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAEnE;;;GAGG;AACH,MAAM,WAAW,aAAa;IAC7B;;;;OAIG;IACH,eAAe,CAAC,SAAS,EAAE,gBAAgB,EAAE,SAAS,EAAE,gBAAgB,GAAG,IAAI,CAAC;CAChF;AAED;;GAEG;AACH,MAAM,WAAW,iBAAkB,SAAQ,mBAAmB;IAC7D;;OAEG;IACH,MAAM,EAAE,aAAa,CAAC;CACtB;AAED;;;GAGG;AACH,qBAAa,qBACZ,SAAQ,kBACR,YAAW,kBAAkB,EAAE,iBAAiB;IAO/C,OAAO,CAAC,QAAQ,CAAC,cAAc;IALhC,SAAgB,MAAM,EAAE,aAAa,CAAC;gBAGrC,mBAAmB,EAAE,mBAAmB,EACxC,eAAe,EAAE,MAAM,WAAW,EACjB,cAAc,EAAE,CAAC,MAAM,EAAE,YAAY,CAAC,gBAAgB,CAAC,KAAK,IAAI;CA4BlF"}
1
+ {"version":3,"file":"sharedTreeEditBuilder.d.ts","sourceRoot":"","sources":["../../src/shared-tree/sharedTreeEditBuilder.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EACX,kBAAkB,EAClB,WAAW,EACX,YAAY,EACZ,gBAAgB,EAChB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACN,kBAAkB,EAClB,KAAK,mBAAmB,EACxB,KAAK,mBAAmB,EACxB,MAAM,+BAA+B,CAAC;AAEvC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAEnE;;;GAGG;AACH,MAAM,WAAW,aAAa;IAC7B;;;;OAIG;IACH,eAAe,CAAC,SAAS,EAAE,gBAAgB,EAAE,SAAS,EAAE,gBAAgB,GAAG,IAAI,CAAC;CAChF;AAED;;GAEG;AACH,MAAM,WAAW,iBAAkB,SAAQ,mBAAmB;IAC7D;;OAEG;IACH,MAAM,EAAE,aAAa,CAAC;CACtB;AAED;;;GAGG;AACH,qBAAa,qBACZ,SAAQ,kBACR,YAAW,kBAAkB,EAAE,iBAAiB;IAO/C,OAAO,CAAC,QAAQ,CAAC,cAAc;IALhC,SAAgB,MAAM,EAAE,aAAa,CAAC;gBAGrC,mBAAmB,EAAE,mBAAmB,EACxC,eAAe,EAAE,MAAM,WAAW,EACjB,cAAc,EAAE,CAAC,MAAM,EAAE,YAAY,CAAC,gBAAgB,CAAC,KAAK,IAAI;CAgClF"}
@@ -12,7 +12,7 @@ export class SharedTreeEditBuilder extends DefaultEditBuilder {
12
12
  super(modularChangeFamily, mintRevisionTag, (taggedChange) => changeReceiver({
13
13
  ...taggedChange,
14
14
  change: { changes: [{ type: "data", innerChange: taggedChange.change }] },
15
- }));
15
+ }), modularChangeFamily.codecOptions);
16
16
  this.changeReceiver = changeReceiver;
17
17
  this.schema = {
18
18
  setStoredSchema: (oldSchema, newSchema) => {
@@ -1 +1 @@
1
- {"version":3,"file":"sharedTreeEditBuilder.js","sourceRoot":"","sources":["../../src/shared-tree/sharedTreeEditBuilder.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAQH,OAAO,EACN,kBAAkB,GAGlB,MAAM,+BAA+B,CAAC;AA2BvC;;;GAGG;AACH,MAAM,OAAO,qBACZ,SAAQ,kBAAkB;IAK1B,YACC,mBAAwC,EACxC,eAAkC,EACjB,cAAgE;QAEjF,KAAK,CAAC,mBAAmB,EAAE,eAAe,EAAE,CAAC,YAAY,EAAE,EAAE,CAC5D,cAAc,CAAC;YACd,GAAG,YAAY;YACf,MAAM,EAAE,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,WAAW,EAAE,YAAY,CAAC,MAAM,EAAE,CAAC,EAAE;SACzE,CAAC,CACF,CAAC;QAPe,mBAAc,GAAd,cAAc,CAAkD;QASjF,IAAI,CAAC,MAAM,GAAG;YACb,eAAe,EAAE,CAAC,SAAS,EAAE,SAAS,EAAE,EAAE;gBACzC,IAAI,CAAC,cAAc,CAAC;oBACnB,QAAQ,EAAE,eAAe,EAAE;oBAC3B,MAAM,EAAE;wBACP,OAAO,EAAE;4BACR;gCACC,IAAI,EAAE,QAAQ;gCACd,WAAW,EAAE;oCACZ,MAAM,EAAE,EAAE,GAAG,EAAE,SAAS,EAAE,GAAG,EAAE,SAAS,EAAE;oCAC1C,SAAS,EAAE,KAAK;iCAChB;6BACD;yBACD;qBACD;iBACD,CAAC,CAAC;YACJ,CAAC;SACD,CAAC;IACH,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type {\n\tChangeFamilyEditor,\n\tRevisionTag,\n\tTaggedChange,\n\tTreeStoredSchema,\n} from \"../core/index.js\";\nimport {\n\tDefaultEditBuilder,\n\ttype IDefaultEditBuilder,\n\ttype ModularChangeFamily,\n} from \"../feature-libraries/index.js\";\n\nimport type { SharedTreeChange } from \"./sharedTreeChangeTypes.js\";\n\n/**\n * Editor for schema changes.\n * The only currently supported operation is to replace the stored schema.\n */\nexport interface ISchemaEditor {\n\t/**\n\t * Updates the stored schema.\n\t * @param oldSchema - The schema being overwritten.\n\t * @param newSchema - The new schema to apply.\n\t */\n\tsetStoredSchema(oldSchema: TreeStoredSchema, newSchema: TreeStoredSchema): void;\n}\n\n/**\n * SharedTree editor for transactional tree data and schema changes.\n */\nexport interface ISharedTreeEditor extends IDefaultEditBuilder {\n\t/**\n\t * Editor for schema changes.\n\t */\n\tschema: ISchemaEditor;\n}\n\n/**\n * Implementation of {@link IDefaultEditBuilder} based on the default set of supported field kinds.\n * @sealed\n */\nexport class SharedTreeEditBuilder\n\textends DefaultEditBuilder\n\timplements ChangeFamilyEditor, ISharedTreeEditor\n{\n\tpublic readonly schema: ISchemaEditor;\n\n\tpublic constructor(\n\t\tmodularChangeFamily: ModularChangeFamily,\n\t\tmintRevisionTag: () => RevisionTag,\n\t\tprivate readonly changeReceiver: (change: TaggedChange<SharedTreeChange>) => void,\n\t) {\n\t\tsuper(modularChangeFamily, mintRevisionTag, (taggedChange) =>\n\t\t\tchangeReceiver({\n\t\t\t\t...taggedChange,\n\t\t\t\tchange: { changes: [{ type: \"data\", innerChange: taggedChange.change }] },\n\t\t\t}),\n\t\t);\n\n\t\tthis.schema = {\n\t\t\tsetStoredSchema: (oldSchema, newSchema) => {\n\t\t\t\tthis.changeReceiver({\n\t\t\t\t\trevision: mintRevisionTag(),\n\t\t\t\t\tchange: {\n\t\t\t\t\t\tchanges: [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\ttype: \"schema\",\n\t\t\t\t\t\t\t\tinnerChange: {\n\t\t\t\t\t\t\t\t\tschema: { new: newSchema, old: oldSchema },\n\t\t\t\t\t\t\t\t\tisInverse: false,\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t],\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t},\n\t\t};\n\t}\n}\n"]}
1
+ {"version":3,"file":"sharedTreeEditBuilder.js","sourceRoot":"","sources":["../../src/shared-tree/sharedTreeEditBuilder.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAQH,OAAO,EACN,kBAAkB,GAGlB,MAAM,+BAA+B,CAAC;AA2BvC;;;GAGG;AACH,MAAM,OAAO,qBACZ,SAAQ,kBAAkB;IAK1B,YACC,mBAAwC,EACxC,eAAkC,EACjB,cAAgE;QAEjF,KAAK,CACJ,mBAAmB,EACnB,eAAe,EACf,CAAC,YAAY,EAAE,EAAE,CAChB,cAAc,CAAC;YACd,GAAG,YAAY;YACf,MAAM,EAAE,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,WAAW,EAAE,YAAY,CAAC,MAAM,EAAE,CAAC,EAAE;SACzE,CAAC,EACH,mBAAmB,CAAC,YAAY,CAChC,CAAC;QAXe,mBAAc,GAAd,cAAc,CAAkD;QAajF,IAAI,CAAC,MAAM,GAAG;YACb,eAAe,EAAE,CAAC,SAAS,EAAE,SAAS,EAAE,EAAE;gBACzC,IAAI,CAAC,cAAc,CAAC;oBACnB,QAAQ,EAAE,eAAe,EAAE;oBAC3B,MAAM,EAAE;wBACP,OAAO,EAAE;4BACR;gCACC,IAAI,EAAE,QAAQ;gCACd,WAAW,EAAE;oCACZ,MAAM,EAAE,EAAE,GAAG,EAAE,SAAS,EAAE,GAAG,EAAE,SAAS,EAAE;oCAC1C,SAAS,EAAE,KAAK;iCAChB;6BACD;yBACD;qBACD;iBACD,CAAC,CAAC;YACJ,CAAC;SACD,CAAC;IACH,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type {\n\tChangeFamilyEditor,\n\tRevisionTag,\n\tTaggedChange,\n\tTreeStoredSchema,\n} from \"../core/index.js\";\nimport {\n\tDefaultEditBuilder,\n\ttype IDefaultEditBuilder,\n\ttype ModularChangeFamily,\n} from \"../feature-libraries/index.js\";\n\nimport type { SharedTreeChange } from \"./sharedTreeChangeTypes.js\";\n\n/**\n * Editor for schema changes.\n * The only currently supported operation is to replace the stored schema.\n */\nexport interface ISchemaEditor {\n\t/**\n\t * Updates the stored schema.\n\t * @param oldSchema - The schema being overwritten.\n\t * @param newSchema - The new schema to apply.\n\t */\n\tsetStoredSchema(oldSchema: TreeStoredSchema, newSchema: TreeStoredSchema): void;\n}\n\n/**\n * SharedTree editor for transactional tree data and schema changes.\n */\nexport interface ISharedTreeEditor extends IDefaultEditBuilder {\n\t/**\n\t * Editor for schema changes.\n\t */\n\tschema: ISchemaEditor;\n}\n\n/**\n * Implementation of {@link IDefaultEditBuilder} based on the default set of supported field kinds.\n * @sealed\n */\nexport class SharedTreeEditBuilder\n\textends DefaultEditBuilder\n\timplements ChangeFamilyEditor, ISharedTreeEditor\n{\n\tpublic readonly schema: ISchemaEditor;\n\n\tpublic constructor(\n\t\tmodularChangeFamily: ModularChangeFamily,\n\t\tmintRevisionTag: () => RevisionTag,\n\t\tprivate readonly changeReceiver: (change: TaggedChange<SharedTreeChange>) => void,\n\t) {\n\t\tsuper(\n\t\t\tmodularChangeFamily,\n\t\t\tmintRevisionTag,\n\t\t\t(taggedChange) =>\n\t\t\t\tchangeReceiver({\n\t\t\t\t\t...taggedChange,\n\t\t\t\t\tchange: { changes: [{ type: \"data\", innerChange: taggedChange.change }] },\n\t\t\t\t}),\n\t\t\tmodularChangeFamily.codecOptions,\n\t\t);\n\n\t\tthis.schema = {\n\t\t\tsetStoredSchema: (oldSchema, newSchema) => {\n\t\t\t\tthis.changeReceiver({\n\t\t\t\t\trevision: mintRevisionTag(),\n\t\t\t\t\tchange: {\n\t\t\t\t\t\tchanges: [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\ttype: \"schema\",\n\t\t\t\t\t\t\t\tinnerChange: {\n\t\t\t\t\t\t\t\t\tschema: { new: newSchema, old: oldSchema },\n\t\t\t\t\t\t\t\t\tisInverse: false,\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t],\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t},\n\t\t};\n\t}\n}\n"]}
@@ -4,66 +4,71 @@
4
4
  */
5
5
  import type { IFluidHandle } from "@fluidframework/core-interfaces";
6
6
  import type { IIdCompressor } from "@fluidframework/id-compressor";
7
- import { TreeNode, type Unhydrated, type ImplicitFieldSchema, type InsertableField, type TreeFieldFromImplicitField, type TreeLeafValue, type UnsafeUnknownSchema, type TreeEncodingOptions, type VerboseTree, type TreeBranch, type TreeParsingOptions, type ConciseTree, type TreeNodeSchema } from "../simple-tree/index.js";
7
+ import { TreeNode, type Unhydrated, type ImplicitFieldSchema, type InsertableField, type TreeFieldFromImplicitField, type TreeLeafValue, type UnsafeUnknownSchema, type TreeEncodingOptions, type VerboseTree, type TreeBranch, type TreeParsingOptions, type ConciseTree, type TreeNodeSchema, type TreeBranchAlpha } from "../simple-tree/index.js";
8
8
  import { type JsonCompatible } from "../util/index.js";
9
9
  import { type ICodecOptions, type CodecWriteOptions } from "../codec/index.js";
10
- import type { TreeBranchAlpha } from "../simple-tree/index.js";
11
10
  /**
12
- * A utility interface for retrieving or converting node identifiers.
13
- *
11
+ * A utility interface for manipulating node identifiers.
14
12
  * @remarks
15
13
  * This provides methods to:
16
14
  *
17
- * - Retrieve long or short identifiers from nodes
18
- *
19
- * - Convert between long identifiers and short identifiers
20
- *
21
- * - Generates long identifiers
15
+ * - Retrieve identifiers from nodes
16
+ * - Generate identifiers
17
+ * - Convert between short numeric identifiers and long string identifiers
22
18
  *
23
19
  * @alpha @sealed
24
20
  */
25
21
  export interface TreeIdentifierUtils {
26
22
  /**
27
- * Returns the contents of a node's {@link SchemaFactory.identifier} field as a stable identifier.
28
- * If the identifier field does not exist, returns undefined.
23
+ * Returns the identifier of a node.
24
+ * @remarks
25
+ * This returns the node's UUID if and only if it has exactly one {@link SchemaFactory.identifier | identifier field}.
26
+ * If it has no identifier field, this returns undefined.
27
+ * If it has more than one identifier field, this throws an error.
28
+ * In that case, query the identifier fields directly instead.
29
29
  *
30
30
  * @param node - The TreeNode you want to get the identifier from,
31
31
  */
32
32
  (node: TreeNode): string | undefined;
33
33
  /**
34
- * Returns the shortened identifier as a number given long identifier known by the id compressor on the branch if possible.
35
- * Otherwise, it will return the original string identifier provided.
36
- * If the id does not exist, or is unknown by the id compressor, it returns undefined.
34
+ * Returns the shortened identifier as a number given a UUID known by the id compressor on the branch.
35
+ * @remarks
36
+ * If the given string is not a valid identifier and/or was not generated by the SharedTree, this will return `undefined`.
37
+ *
38
+ * See {@link TreeIdentifierUtils.getShort} for additional details about shortened identifiers.
37
39
  *
38
- * This method is the inverse of {@link TreeIdentifierUtils.lengthen}. If you shorten an identifier
39
- * and then immediately pass it to {@link TreeIdentifierUtils.lengthen}, you will get the original string back.
40
+ * This method is the inverse of {@link TreeIdentifierUtils.lengthen}.
41
+ * If you shorten an identifier and then immediately pass it to {@link TreeIdentifierUtils.lengthen}, you will get the original string back.
40
42
  *
41
- * @param branch - TreeBranch from where you get the idCompressor to do the decompression.
42
- * @param nodeIdentifier - the stable identifier that needs to be shortened.
43
+ * @param branch - The branch (and/or view) of the SharedTree that will perform the compression.
44
+ * @param nodeIdentifier - the stable identifier to be shortened.
43
45
  */
44
46
  shorten(branch: TreeBranch, nodeIdentifier: string): number | undefined;
45
47
  /**
46
- * Returns the stable id as a string if the identifier is decompressible and known by the id compressor. Otherwise, it will throw an error.
48
+ * Returns the stable id as a string if the identifier is decompressible and known by the id compressor.
49
+ * @remarks
50
+ * If the given number does not correspond to a valid identifier generated by the SharedTree, this will return `undefined`.
47
51
  *
48
- * This method is the inverse of {@link TreeIdentifierUtils.shorten}. If you lengthen an identifier
49
- * and then immediately pass it to {@link TreeIdentifierUtils.shorten}, you will get the original short identifier back.
52
+ * This method is the inverse of {@link TreeIdentifierUtils.shorten}.
53
+ * If you lengthen an identifier and then immediately pass it to {@link TreeIdentifierUtils.shorten}, you will get the original short identifier back.
50
54
  *
51
- * @param branch - TreeBranch from where you want to get the id compressor to do the decompression.
52
- * @param nodeIdentifier - The local identifier that needs to be expanded.
55
+ * @param branch - The branch (and/or view) of the SharedTree that will perform the decompression.
56
+ * @param nodeIdentifier - The local identifier to be lengthened.
53
57
  */
54
58
  lengthen(branch: TreeBranch, nodeIdentifier: number): string;
55
59
  /**
56
- * Returns the {@link SchemaFactory.identifier | identifier} of the given node in the most compressed form possible.
60
+ * Returns the {@link TreeIdentifierUtils.shorten | shortened} form of the identifier {@link SchemaFactory.identifier | identifier} for the given node.
57
61
  * @remarks
58
62
  * If the node is {@link Unhydrated | hydrated} and its identifier is a valid UUID that was automatically generated by the SharedTree it is part of (or something else using the same {@link @fluidframework/id-compressor#IIdCompressor}), then this will return a process-unique integer corresponding to that identifier.
59
63
  * This is useful for performance-sensitive scenarios involving many nodes with identifiers that need to be compactly retained in memory or used for efficient lookup.
60
- * Note that automatically generated identifiers that were accessed before the node was hydrated will return the generated UUID, not the process-unique integer.
64
+ * Note that automatically generated identifiers that were accessed before the node was hydrated will not yield a short identifier until after hydration.
61
65
  *
62
- * If the node's identifier is any other user-provided string, then this will return undefined.
66
+ * If the node's identifier is any other user-provided string, then this will return `undefined`.
63
67
  *
64
68
  * If the node has no identifier (that is, it has no {@link SchemaFactory.identifier | identifier} field), then this returns `undefined`.
65
69
  *
66
70
  * If the node has more than one identifier, then this will throw an error.
71
+ * In that case, retrieve the identifiers individually via their fields instead.
67
72
  *
68
73
  * The returned integer should not be serialized or preserved outside of the current process.
69
74
  * Its lifetime is that of the current in-memory instance of the FF container for this client, and it is not guaranteed to be unique or stable outside of that context.
@@ -71,10 +76,11 @@ export interface TreeIdentifierUtils {
71
76
  */
72
77
  getShort(node: TreeNode): number | undefined;
73
78
  /**
74
- * Creates and returns a long identifier.
75
- * The long identifier is a compressible, stable identifier generated by the tree's ID compressor.
79
+ * Creates a new identifier.
80
+ * @remarks
81
+ * The returned UUID string can be {@link TreeIdentifierUtils.shorten | shortened} for high-performance scenarios.
76
82
  *
77
- * @param branch - TreeBranch from where you want to get the id compressor to generate the identifier from.
83
+ * @param branch - The branch (and/or view) of the SharedTree that will generate and manage the identifier.
78
84
  */
79
85
  create(branch: TreeBranch): string;
80
86
  }
@@ -1 +1 @@
1
- {"version":3,"file":"treeAlpha.d.ts","sourceRoot":"","sources":["../../src/shared-tree/treeAlpha.ts"],"names":[],"mappings":"AAAA;;;G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AM,IAAI,CAAC;CACjC;AA4JD;;;;GAIG;AACH,eAAO,MAAM,SAAS,EAAE,SAmUvB,CAAC"}
@@ -14,22 +14,19 @@ import { independentInitializedView } from "./independentView.js";
14
14
  import { SchematizingSimpleTreeView, ViewSlot } from "./schematizingTreeView.js";
15
15
  import { isFluidHandle } from "@fluidframework/runtime-utils";
16
16
  const identifier = (node) => {
17
- const nodeIdentifier = getIdentifierFromNode(node, "uncompressed");
18
- if (typeof nodeIdentifier === "number") {
19
- throw new TypeError("identifier should be uncompressed.");
20
- }
21
- return nodeIdentifier;
17
+ return getIdentifierFromNode(node, "uncompressed");
22
18
  };
23
19
  identifier.shorten = (branch, nodeIdentifier) => {
24
- const nodeKeyManager = branch
25
- .nodeKeyManager;
20
+ assert(branch instanceof SchematizingSimpleTreeView, 0xcac /* Unexpected branch implementation */);
21
+ const { nodeKeyManager } = branch;
26
22
  const localNodeKey = nodeKeyManager.tryLocalizeNodeIdentifier(nodeIdentifier);
27
- return localNodeKey !== undefined ? extractFromOpaque(localNodeKey) : undefined;
23
+ return localNodeKey === undefined ? undefined : extractFromOpaque(localNodeKey);
28
24
  };
29
25
  identifier.lengthen = (branch, nodeIdentifier) => {
30
- const nodeKeyManager = branch
31
- .nodeKeyManager;
32
- return nodeKeyManager.stabilizeNodeIdentifier(nodeIdentifier);
26
+ assert(branch instanceof SchematizingSimpleTreeView, 0xcad /* Unexpected branch implementation */);
27
+ const { nodeKeyManager } = branch;
28
+ const local = brand(nodeIdentifier);
29
+ return nodeKeyManager.stabilizeNodeIdentifier(local);
33
30
  };
34
31
  identifier.getShort = (node) => {
35
32
  const shortIdentifier = getIdentifierFromNode(node, "compressed");
@@ -87,14 +84,14 @@ class NodeSubscription {
87
84
  return;
88
85
  }
89
86
  const subscription = subscriptions.get(flexNode);
90
- if (subscription !== undefined) {
91
- // Already subscribed to this node.
92
- subscription.keys = undefined; // Now subscribed to all keys.
93
- }
94
- else {
87
+ if (subscription === undefined) {
95
88
  const newSubscription = new NodeSubscription(invalidate, flexNode);
96
89
  subscriptions.set(flexNode, newSubscription);
97
90
  }
91
+ else {
92
+ // Already subscribed to this node.
93
+ subscription.keys = undefined; // Now subscribed to all keys.
94
+ }
98
95
  },
99
96
  observeNodeField(flexNode, key) {
100
97
  if (flexNode.value !== undefined) {
@@ -102,17 +99,17 @@ class NodeSubscription {
102
99
  return;
103
100
  }
104
101
  const subscription = subscriptions.get(flexNode);
105
- if (subscription !== undefined) {
102
+ if (subscription === undefined) {
103
+ const newSubscription = new NodeSubscription(invalidate, flexNode);
104
+ newSubscription.keys = new Set([key]);
105
+ subscriptions.set(flexNode, newSubscription);
106
+ }
107
+ else {
106
108
  // Already subscribed to this node: if not subscribed to all keys, subscribe to this one.
107
109
  // TODO:Performance: due to how JavaScript set ordering works,
108
110
  // it might be faster to check `has` and only add if not present in case the same field is viewed many times.
109
111
  subscription.keys?.add(key);
110
112
  }
111
- else {
112
- const newSubscription = new NodeSubscription(invalidate, flexNode);
113
- newSubscription.keys = new Set([key]);
114
- subscriptions.set(flexNode, newSubscription);
115
- }
116
113
  },
117
114
  observeParentOf(node) {
118
115
  // Supporting parent tracking is more difficult that it might seem at first.
@@ -302,11 +299,12 @@ export const TreeAlpha = {
302
299
  }
303
300
  return getOrCreateNodeFromInnerUnboxedNode(childFlexTree);
304
301
  }
305
- case NodeKind.Map:
302
+ case NodeKind.Map: {
306
303
  if (typeof propertyKey !== "string") {
307
304
  // Map nodes only support string keys.
308
305
  return undefined;
309
306
  }
307
+ }
310
308
  // Fall through
311
309
  case NodeKind.Record:
312
310
  case NodeKind.Object: {