@fluidframework/tree 2.90.0-378676 → 2.90.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 (1104) hide show
  1. package/.vscode/settings.json +6 -5
  2. package/CHANGELOG.md +95 -0
  3. package/README.md +1 -1
  4. package/api-report/tree.alpha.api.md +63 -25
  5. package/api-report/tree.beta.api.md +30 -0
  6. package/api-report/tree.legacy.beta.api.md +30 -0
  7. package/dist/alpha.d.ts +10 -6
  8. package/dist/beta.d.ts +4 -1
  9. package/dist/codec/codec.d.ts +2 -0
  10. package/dist/codec/codec.d.ts.map +1 -1
  11. package/dist/codec/codec.js +4 -3
  12. package/dist/codec/codec.js.map +1 -1
  13. package/dist/codec/index.d.ts +1 -1
  14. package/dist/codec/index.d.ts.map +1 -1
  15. package/dist/codec/index.js +2 -1
  16. package/dist/codec/index.js.map +1 -1
  17. package/dist/codec/versioned/codec.d.ts +13 -1
  18. package/dist/codec/versioned/codec.d.ts.map +1 -1
  19. package/dist/codec/versioned/codec.js +18 -3
  20. package/dist/codec/versioned/codec.js.map +1 -1
  21. package/dist/codec/versioned/format.d.ts +22 -1
  22. package/dist/codec/versioned/format.d.ts.map +1 -1
  23. package/dist/codec/versioned/format.js +16 -3
  24. package/dist/codec/versioned/format.js.map +1 -1
  25. package/dist/codec/versioned/index.d.ts +1 -1
  26. package/dist/codec/versioned/index.d.ts.map +1 -1
  27. package/dist/codec/versioned/index.js +2 -1
  28. package/dist/codec/versioned/index.js.map +1 -1
  29. package/dist/core/change-family/changeFamily.d.ts +1 -4
  30. package/dist/core/change-family/changeFamily.d.ts.map +1 -1
  31. package/dist/core/change-family/changeFamily.js.map +1 -1
  32. package/dist/core/change-family/index.d.ts +1 -1
  33. package/dist/core/change-family/index.d.ts.map +1 -1
  34. package/dist/core/change-family/index.js.map +1 -1
  35. package/dist/core/index.d.ts +3 -4
  36. package/dist/core/index.d.ts.map +1 -1
  37. package/dist/core/index.js +4 -8
  38. package/dist/core/index.js.map +1 -1
  39. package/dist/core/rebase/changeRebaser.d.ts +1 -6
  40. package/dist/core/rebase/changeRebaser.d.ts.map +1 -1
  41. package/dist/core/rebase/changeRebaser.js.map +1 -1
  42. package/dist/core/rebase/index.d.ts +1 -1
  43. package/dist/core/rebase/index.d.ts.map +1 -1
  44. package/dist/core/rebase/index.js +1 -2
  45. package/dist/core/rebase/index.js.map +1 -1
  46. package/dist/core/rebase/types.d.ts +78 -1
  47. package/dist/core/rebase/types.d.ts.map +1 -1
  48. package/dist/core/rebase/types.js +1 -5
  49. package/dist/core/rebase/types.js.map +1 -1
  50. package/dist/core/rebase/utils.d.ts.map +1 -1
  51. package/dist/core/rebase/utils.js +7 -25
  52. package/dist/core/rebase/utils.js.map +1 -1
  53. package/dist/core/tree/delta.d.ts +0 -5
  54. package/dist/core/tree/delta.d.ts.map +1 -1
  55. package/dist/core/tree/delta.js.map +1 -1
  56. package/dist/core/tree/detachedFieldIndex.d.ts +1 -13
  57. package/dist/core/tree/detachedFieldIndex.d.ts.map +1 -1
  58. package/dist/core/tree/detachedFieldIndex.js +1 -14
  59. package/dist/core/tree/detachedFieldIndex.js.map +1 -1
  60. package/dist/core/tree/detachedFieldIndexTypes.d.ts +0 -4
  61. package/dist/core/tree/detachedFieldIndexTypes.d.ts.map +1 -1
  62. package/dist/core/tree/detachedFieldIndexTypes.js.map +1 -1
  63. package/dist/core/tree/index.d.ts +2 -2
  64. package/dist/core/tree/index.d.ts.map +1 -1
  65. package/dist/core/tree/index.js +3 -4
  66. package/dist/core/tree/index.js.map +1 -1
  67. package/dist/core/tree/pathTree.d.ts +3 -11
  68. package/dist/core/tree/pathTree.d.ts.map +1 -1
  69. package/dist/core/tree/pathTree.js +2 -14
  70. package/dist/core/tree/pathTree.js.map +1 -1
  71. package/dist/core/tree/visitDelta.d.ts.map +1 -1
  72. package/dist/core/tree/visitDelta.js +13 -17
  73. package/dist/core/tree/visitDelta.js.map +1 -1
  74. package/dist/feature-libraries/changeAtomIdBTree.d.ts +2 -3
  75. package/dist/feature-libraries/changeAtomIdBTree.d.ts.map +1 -1
  76. package/dist/feature-libraries/changeAtomIdBTree.js +2 -15
  77. package/dist/feature-libraries/changeAtomIdBTree.js.map +1 -1
  78. package/dist/feature-libraries/chunked-forest/codec/codecs.d.ts +8 -7
  79. package/dist/feature-libraries/chunked-forest/codec/codecs.d.ts.map +1 -1
  80. package/dist/feature-libraries/chunked-forest/codec/codecs.js +22 -44
  81. package/dist/feature-libraries/chunked-forest/codec/codecs.js.map +1 -1
  82. package/dist/feature-libraries/chunked-forest/codec/format.d.ts.map +1 -1
  83. package/dist/feature-libraries/chunked-forest/codec/format.js +11 -0
  84. package/dist/feature-libraries/chunked-forest/codec/format.js.map +1 -1
  85. package/dist/feature-libraries/chunked-forest/codec/index.d.ts +3 -2
  86. package/dist/feature-libraries/chunked-forest/codec/index.d.ts.map +1 -1
  87. package/dist/feature-libraries/chunked-forest/codec/index.js +2 -4
  88. package/dist/feature-libraries/chunked-forest/codec/index.js.map +1 -1
  89. package/dist/feature-libraries/chunked-forest/index.d.ts +1 -1
  90. package/dist/feature-libraries/chunked-forest/index.d.ts.map +1 -1
  91. package/dist/feature-libraries/chunked-forest/index.js +2 -4
  92. package/dist/feature-libraries/chunked-forest/index.js.map +1 -1
  93. package/dist/feature-libraries/default-schema/defaultEditBuilder.d.ts +44 -92
  94. package/dist/feature-libraries/default-schema/defaultEditBuilder.d.ts.map +1 -1
  95. package/dist/feature-libraries/default-schema/defaultEditBuilder.js +70 -220
  96. package/dist/feature-libraries/default-schema/defaultEditBuilder.js.map +1 -1
  97. package/dist/feature-libraries/default-schema/defaultFieldKinds.d.ts.map +1 -1
  98. package/dist/feature-libraries/default-schema/defaultFieldKinds.js +2 -12
  99. package/dist/feature-libraries/default-schema/defaultFieldKinds.js.map +1 -1
  100. package/dist/feature-libraries/default-schema/index.d.ts +1 -2
  101. package/dist/feature-libraries/default-schema/index.d.ts.map +1 -1
  102. package/dist/feature-libraries/default-schema/index.js +2 -4
  103. package/dist/feature-libraries/default-schema/index.js.map +1 -1
  104. package/dist/feature-libraries/default-schema/mappedEditBuilder.d.ts +6 -7
  105. package/dist/feature-libraries/default-schema/mappedEditBuilder.d.ts.map +1 -1
  106. package/dist/feature-libraries/default-schema/mappedEditBuilder.js +0 -15
  107. package/dist/feature-libraries/default-schema/mappedEditBuilder.js.map +1 -1
  108. package/dist/feature-libraries/deltaUtils.d.ts +0 -1
  109. package/dist/feature-libraries/deltaUtils.d.ts.map +1 -1
  110. package/dist/feature-libraries/deltaUtils.js +1 -6
  111. package/dist/feature-libraries/deltaUtils.js.map +1 -1
  112. package/dist/feature-libraries/flex-tree/context.d.ts +0 -9
  113. package/dist/feature-libraries/flex-tree/context.d.ts.map +1 -1
  114. package/dist/feature-libraries/flex-tree/context.js +0 -6
  115. package/dist/feature-libraries/flex-tree/context.js.map +1 -1
  116. package/dist/feature-libraries/flex-tree/flexTreeTypes.d.ts +6 -6
  117. package/dist/feature-libraries/flex-tree/flexTreeTypes.d.ts.map +1 -1
  118. package/dist/feature-libraries/flex-tree/flexTreeTypes.js.map +1 -1
  119. package/dist/feature-libraries/flex-tree/lazyField.d.ts +7 -8
  120. package/dist/feature-libraries/flex-tree/lazyField.d.ts.map +1 -1
  121. package/dist/feature-libraries/flex-tree/lazyField.js +8 -39
  122. package/dist/feature-libraries/flex-tree/lazyField.js.map +1 -1
  123. package/dist/feature-libraries/flex-tree/observer.d.ts +17 -0
  124. package/dist/feature-libraries/flex-tree/observer.d.ts.map +1 -1
  125. package/dist/feature-libraries/flex-tree/observer.js.map +1 -1
  126. package/dist/feature-libraries/forest-summary/codec.d.ts +5 -12
  127. package/dist/feature-libraries/forest-summary/codec.d.ts.map +1 -1
  128. package/dist/feature-libraries/forest-summary/codec.js +33 -33
  129. package/dist/feature-libraries/forest-summary/codec.js.map +1 -1
  130. package/dist/feature-libraries/forest-summary/forestSummarizer.d.ts +2 -2
  131. package/dist/feature-libraries/forest-summary/forestSummarizer.d.ts.map +1 -1
  132. package/dist/feature-libraries/forest-summary/forestSummarizer.js +6 -7
  133. package/dist/feature-libraries/forest-summary/forestSummarizer.js.map +1 -1
  134. package/dist/feature-libraries/forest-summary/formatCommon.d.ts +6 -4
  135. package/dist/feature-libraries/forest-summary/formatCommon.d.ts.map +1 -1
  136. package/dist/feature-libraries/forest-summary/formatCommon.js +13 -11
  137. package/dist/feature-libraries/forest-summary/formatCommon.js.map +1 -1
  138. package/dist/feature-libraries/forest-summary/incrementalSummaryBuilder.d.ts +19 -14
  139. package/dist/feature-libraries/forest-summary/incrementalSummaryBuilder.d.ts.map +1 -1
  140. package/dist/feature-libraries/forest-summary/incrementalSummaryBuilder.js +31 -48
  141. package/dist/feature-libraries/forest-summary/incrementalSummaryBuilder.js.map +1 -1
  142. package/dist/feature-libraries/forest-summary/index.d.ts +1 -1
  143. package/dist/feature-libraries/forest-summary/index.d.ts.map +1 -1
  144. package/dist/feature-libraries/forest-summary/index.js +2 -2
  145. package/dist/feature-libraries/forest-summary/index.js.map +1 -1
  146. package/dist/feature-libraries/index.d.ts +6 -6
  147. package/dist/feature-libraries/index.d.ts.map +1 -1
  148. package/dist/feature-libraries/index.js +6 -11
  149. package/dist/feature-libraries/index.js.map +1 -1
  150. package/dist/feature-libraries/indexing/anchorTreeIndex.d.ts +3 -3
  151. package/dist/feature-libraries/indexing/anchorTreeIndex.d.ts.map +1 -1
  152. package/dist/feature-libraries/indexing/anchorTreeIndex.js.map +1 -1
  153. package/dist/feature-libraries/indexing/index.d.ts +1 -1
  154. package/dist/feature-libraries/indexing/index.d.ts.map +1 -1
  155. package/dist/feature-libraries/indexing/index.js.map +1 -1
  156. package/dist/feature-libraries/indexing/types.d.ts +15 -13
  157. package/dist/feature-libraries/indexing/types.d.ts.map +1 -1
  158. package/dist/feature-libraries/indexing/types.js.map +1 -1
  159. package/dist/feature-libraries/mitigatedChangeFamily.d.ts.map +1 -1
  160. package/dist/feature-libraries/mitigatedChangeFamily.js +2 -2
  161. package/dist/feature-libraries/mitigatedChangeFamily.js.map +1 -1
  162. package/dist/feature-libraries/modular-schema/crossFieldQueries.d.ts +24 -100
  163. package/dist/feature-libraries/modular-schema/crossFieldQueries.d.ts.map +1 -1
  164. package/dist/feature-libraries/modular-schema/crossFieldQueries.js +12 -8
  165. package/dist/feature-libraries/modular-schema/crossFieldQueries.js.map +1 -1
  166. package/dist/feature-libraries/modular-schema/fieldChangeHandler.d.ts +51 -85
  167. package/dist/feature-libraries/modular-schema/fieldChangeHandler.d.ts.map +1 -1
  168. package/dist/feature-libraries/modular-schema/fieldChangeHandler.js.map +1 -1
  169. package/dist/feature-libraries/modular-schema/genericFieldKind.d.ts.map +1 -1
  170. package/dist/feature-libraries/modular-schema/genericFieldKind.js +9 -4
  171. package/dist/feature-libraries/modular-schema/genericFieldKind.js.map +1 -1
  172. package/dist/feature-libraries/modular-schema/index.d.ts +3 -3
  173. package/dist/feature-libraries/modular-schema/index.d.ts.map +1 -1
  174. package/dist/feature-libraries/modular-schema/index.js +3 -2
  175. package/dist/feature-libraries/modular-schema/index.js.map +1 -1
  176. package/dist/feature-libraries/modular-schema/modularChangeCodecV1.d.ts +22 -18
  177. package/dist/feature-libraries/modular-schema/modularChangeCodecV1.d.ts.map +1 -1
  178. package/dist/feature-libraries/modular-schema/modularChangeCodecV1.js +158 -276
  179. package/dist/feature-libraries/modular-schema/modularChangeCodecV1.js.map +1 -1
  180. package/dist/feature-libraries/modular-schema/modularChangeCodecV2.d.ts.map +1 -1
  181. package/dist/feature-libraries/modular-schema/modularChangeCodecV2.js +1 -1
  182. package/dist/feature-libraries/modular-schema/modularChangeCodecV2.js.map +1 -1
  183. package/dist/feature-libraries/modular-schema/modularChangeCodecs.d.ts +0 -1
  184. package/dist/feature-libraries/modular-schema/modularChangeCodecs.d.ts.map +1 -1
  185. package/dist/feature-libraries/modular-schema/modularChangeCodecs.js +0 -8
  186. package/dist/feature-libraries/modular-schema/modularChangeCodecs.js.map +1 -1
  187. package/dist/feature-libraries/modular-schema/modularChangeFamily.d.ts +22 -56
  188. package/dist/feature-libraries/modular-schema/modularChangeFamily.d.ts.map +1 -1
  189. package/dist/feature-libraries/modular-schema/modularChangeFamily.js +462 -1390
  190. package/dist/feature-libraries/modular-schema/modularChangeFamily.js.map +1 -1
  191. package/dist/feature-libraries/modular-schema/modularChangeFormatV1.d.ts.map +1 -1
  192. package/dist/feature-libraries/modular-schema/modularChangeFormatV1.js.map +1 -1
  193. package/dist/feature-libraries/modular-schema/modularChangeFormatV2.d.ts +2 -1
  194. package/dist/feature-libraries/modular-schema/modularChangeFormatV2.d.ts.map +1 -1
  195. package/dist/feature-libraries/modular-schema/modularChangeFormatV2.js +3 -3
  196. package/dist/feature-libraries/modular-schema/modularChangeFormatV2.js.map +1 -1
  197. package/dist/feature-libraries/modular-schema/modularChangeTypes.d.ts +10 -49
  198. package/dist/feature-libraries/modular-schema/modularChangeTypes.d.ts.map +1 -1
  199. package/dist/feature-libraries/modular-schema/modularChangeTypes.js +3 -3
  200. package/dist/feature-libraries/modular-schema/modularChangeTypes.js.map +1 -1
  201. package/dist/feature-libraries/optional-field/optionalField.d.ts +32 -13
  202. package/dist/feature-libraries/optional-field/optionalField.d.ts.map +1 -1
  203. package/dist/feature-libraries/optional-field/optionalField.js +446 -257
  204. package/dist/feature-libraries/optional-field/optionalField.js.map +1 -1
  205. package/dist/feature-libraries/optional-field/optionalFieldChangeTypes.d.ts +31 -31
  206. package/dist/feature-libraries/optional-field/optionalFieldChangeTypes.d.ts.map +1 -1
  207. package/dist/feature-libraries/optional-field/optionalFieldChangeTypes.js.map +1 -1
  208. package/dist/feature-libraries/optional-field/optionalFieldCodecV2.d.ts +1 -1
  209. package/dist/feature-libraries/optional-field/optionalFieldCodecV2.d.ts.map +1 -1
  210. package/dist/feature-libraries/optional-field/optionalFieldCodecV2.js +28 -57
  211. package/dist/feature-libraries/optional-field/optionalFieldCodecV2.js.map +1 -1
  212. package/dist/feature-libraries/optional-field/optionalFieldCodecs.d.ts.map +1 -1
  213. package/dist/feature-libraries/optional-field/optionalFieldCodecs.js +1 -5
  214. package/dist/feature-libraries/optional-field/optionalFieldCodecs.js.map +1 -1
  215. package/dist/feature-libraries/optional-field/requiredField.d.ts +2 -3
  216. package/dist/feature-libraries/optional-field/requiredField.d.ts.map +1 -1
  217. package/dist/feature-libraries/optional-field/requiredField.js +1 -6
  218. package/dist/feature-libraries/optional-field/requiredField.js.map +1 -1
  219. package/dist/feature-libraries/sequence-field/compose.d.ts +7 -6
  220. package/dist/feature-libraries/sequence-field/compose.d.ts.map +1 -1
  221. package/dist/feature-libraries/sequence-field/compose.js +259 -81
  222. package/dist/feature-libraries/sequence-field/compose.js.map +1 -1
  223. package/dist/feature-libraries/sequence-field/helperTypes.d.ts +10 -14
  224. package/dist/feature-libraries/sequence-field/helperTypes.d.ts.map +1 -1
  225. package/dist/feature-libraries/sequence-field/helperTypes.js.map +1 -1
  226. package/dist/feature-libraries/sequence-field/invert.d.ts +3 -3
  227. package/dist/feature-libraries/sequence-field/invert.d.ts.map +1 -1
  228. package/dist/feature-libraries/sequence-field/invert.js +167 -65
  229. package/dist/feature-libraries/sequence-field/invert.js.map +1 -1
  230. package/dist/feature-libraries/sequence-field/markQueue.d.ts +2 -2
  231. package/dist/feature-libraries/sequence-field/markQueue.d.ts.map +1 -1
  232. package/dist/feature-libraries/sequence-field/markQueue.js.map +1 -1
  233. package/dist/feature-libraries/sequence-field/moveEffectTable.d.ts +56 -4
  234. package/dist/feature-libraries/sequence-field/moveEffectTable.d.ts.map +1 -1
  235. package/dist/feature-libraries/sequence-field/moveEffectTable.js +90 -7
  236. package/dist/feature-libraries/sequence-field/moveEffectTable.js.map +1 -1
  237. package/dist/feature-libraries/sequence-field/rebase.d.ts +3 -3
  238. package/dist/feature-libraries/sequence-field/rebase.d.ts.map +1 -1
  239. package/dist/feature-libraries/sequence-field/rebase.js +116 -109
  240. package/dist/feature-libraries/sequence-field/rebase.js.map +1 -1
  241. package/dist/feature-libraries/sequence-field/relevantRemovedRoots.d.ts +9 -0
  242. package/dist/feature-libraries/sequence-field/relevantRemovedRoots.d.ts.map +1 -0
  243. package/dist/feature-libraries/sequence-field/relevantRemovedRoots.js +50 -0
  244. package/dist/feature-libraries/sequence-field/relevantRemovedRoots.js.map +1 -0
  245. package/dist/feature-libraries/sequence-field/replaceRevisions.d.ts.map +1 -1
  246. package/dist/feature-libraries/sequence-field/replaceRevisions.js +32 -19
  247. package/dist/feature-libraries/sequence-field/replaceRevisions.js.map +1 -1
  248. package/dist/feature-libraries/sequence-field/sequenceFieldChangeHandler.d.ts.map +1 -1
  249. package/dist/feature-libraries/sequence-field/sequenceFieldChangeHandler.js +2 -1
  250. package/dist/feature-libraries/sequence-field/sequenceFieldChangeHandler.js.map +1 -1
  251. package/dist/feature-libraries/sequence-field/sequenceFieldCodecV2.d.ts +4 -22
  252. package/dist/feature-libraries/sequence-field/sequenceFieldCodecV2.d.ts.map +1 -1
  253. package/dist/feature-libraries/sequence-field/sequenceFieldCodecV2.js +187 -388
  254. package/dist/feature-libraries/sequence-field/sequenceFieldCodecV2.js.map +1 -1
  255. package/dist/feature-libraries/sequence-field/sequenceFieldCodecV3.d.ts.map +1 -1
  256. package/dist/feature-libraries/sequence-field/sequenceFieldCodecV3.js +62 -20
  257. package/dist/feature-libraries/sequence-field/sequenceFieldCodecV3.js.map +1 -1
  258. package/dist/feature-libraries/sequence-field/sequenceFieldEditor.d.ts +2 -2
  259. package/dist/feature-libraries/sequence-field/sequenceFieldEditor.d.ts.map +1 -1
  260. package/dist/feature-libraries/sequence-field/sequenceFieldEditor.js +13 -13
  261. package/dist/feature-libraries/sequence-field/sequenceFieldEditor.js.map +1 -1
  262. package/dist/feature-libraries/sequence-field/sequenceFieldToDelta.d.ts +2 -3
  263. package/dist/feature-libraries/sequence-field/sequenceFieldToDelta.d.ts.map +1 -1
  264. package/dist/feature-libraries/sequence-field/sequenceFieldToDelta.js +111 -16
  265. package/dist/feature-libraries/sequence-field/sequenceFieldToDelta.js.map +1 -1
  266. package/dist/feature-libraries/sequence-field/types.d.ts +74 -37
  267. package/dist/feature-libraries/sequence-field/types.d.ts.map +1 -1
  268. package/dist/feature-libraries/sequence-field/types.js.map +1 -1
  269. package/dist/feature-libraries/sequence-field/utils.d.ts +25 -20
  270. package/dist/feature-libraries/sequence-field/utils.d.ts.map +1 -1
  271. package/dist/feature-libraries/sequence-field/utils.js +320 -159
  272. package/dist/feature-libraries/sequence-field/utils.js.map +1 -1
  273. package/dist/index.d.ts +3 -3
  274. package/dist/index.d.ts.map +1 -1
  275. package/dist/index.js +2 -2
  276. package/dist/index.js.map +1 -1
  277. package/dist/legacy.d.ts +4 -1
  278. package/dist/packageVersion.d.ts +1 -1
  279. package/dist/packageVersion.d.ts.map +1 -1
  280. package/dist/packageVersion.js +1 -1
  281. package/dist/packageVersion.js.map +1 -1
  282. package/dist/shared-tree/independentView.d.ts.map +1 -1
  283. package/dist/shared-tree/independentView.js +3 -3
  284. package/dist/shared-tree/independentView.js.map +1 -1
  285. package/dist/shared-tree/index.d.ts +1 -1
  286. package/dist/shared-tree/index.d.ts.map +1 -1
  287. package/dist/shared-tree/index.js.map +1 -1
  288. package/dist/shared-tree/schematizeTree.d.ts +4 -4
  289. package/dist/shared-tree/schematizeTree.d.ts.map +1 -1
  290. package/dist/shared-tree/schematizeTree.js +1 -2
  291. package/dist/shared-tree/schematizeTree.js.map +1 -1
  292. package/dist/shared-tree/schematizingTreeView.d.ts +10 -1
  293. package/dist/shared-tree/schematizingTreeView.d.ts.map +1 -1
  294. package/dist/shared-tree/schematizingTreeView.js +70 -28
  295. package/dist/shared-tree/schematizingTreeView.js.map +1 -1
  296. package/dist/shared-tree/sharedTree.d.ts +3 -9
  297. package/dist/shared-tree/sharedTree.d.ts.map +1 -1
  298. package/dist/shared-tree/sharedTree.js +8 -11
  299. package/dist/shared-tree/sharedTree.js.map +1 -1
  300. package/dist/shared-tree/sharedTreeChangeCodecs.d.ts +0 -1
  301. package/dist/shared-tree/sharedTreeChangeCodecs.d.ts.map +1 -1
  302. package/dist/shared-tree/sharedTreeChangeCodecs.js +0 -8
  303. package/dist/shared-tree/sharedTreeChangeCodecs.js.map +1 -1
  304. package/dist/shared-tree/sharedTreeChangeFamily.d.ts +4 -4
  305. package/dist/shared-tree/sharedTreeChangeFamily.d.ts.map +1 -1
  306. package/dist/shared-tree/sharedTreeChangeFamily.js +2 -2
  307. package/dist/shared-tree/sharedTreeChangeFamily.js.map +1 -1
  308. package/dist/shared-tree/sharedTreeEditBuilder.d.ts +6 -16
  309. package/dist/shared-tree/sharedTreeEditBuilder.d.ts.map +1 -1
  310. package/dist/shared-tree/sharedTreeEditBuilder.js +7 -14
  311. package/dist/shared-tree/sharedTreeEditBuilder.js.map +1 -1
  312. package/dist/shared-tree/tree.js +1 -1
  313. package/dist/shared-tree/tree.js.map +1 -1
  314. package/dist/shared-tree/treeAlpha.d.ts +8 -1
  315. package/dist/shared-tree/treeAlpha.d.ts.map +1 -1
  316. package/dist/shared-tree/treeAlpha.js +48 -8
  317. package/dist/shared-tree/treeAlpha.js.map +1 -1
  318. package/dist/shared-tree/treeCheckout.d.ts +46 -16
  319. package/dist/shared-tree/treeCheckout.d.ts.map +1 -1
  320. package/dist/shared-tree/treeCheckout.js +129 -73
  321. package/dist/shared-tree/treeCheckout.js.map +1 -1
  322. package/dist/shared-tree/unhydratedTreeContext.d.ts +20 -0
  323. package/dist/shared-tree/unhydratedTreeContext.d.ts.map +1 -0
  324. package/dist/shared-tree/unhydratedTreeContext.js +56 -0
  325. package/dist/shared-tree/unhydratedTreeContext.js.map +1 -0
  326. package/dist/shared-tree-core/branch.d.ts +2 -3
  327. package/dist/shared-tree-core/branch.d.ts.map +1 -1
  328. package/dist/shared-tree-core/branch.js +3 -4
  329. package/dist/shared-tree-core/branch.js.map +1 -1
  330. package/dist/shared-tree-core/editManager.d.ts +2 -2
  331. package/dist/shared-tree-core/editManager.d.ts.map +1 -1
  332. package/dist/shared-tree-core/editManager.js +9 -9
  333. package/dist/shared-tree-core/editManager.js.map +1 -1
  334. package/dist/shared-tree-core/editManagerCodecs.d.ts +0 -4
  335. package/dist/shared-tree-core/editManagerCodecs.d.ts.map +1 -1
  336. package/dist/shared-tree-core/editManagerCodecs.js +2 -10
  337. package/dist/shared-tree-core/editManagerCodecs.js.map +1 -1
  338. package/dist/shared-tree-core/editManagerFormatCommons.d.ts +0 -1
  339. package/dist/shared-tree-core/editManagerFormatCommons.d.ts.map +1 -1
  340. package/dist/shared-tree-core/editManagerFormatCommons.js +0 -6
  341. package/dist/shared-tree-core/editManagerFormatCommons.js.map +1 -1
  342. package/dist/shared-tree-core/editManagerFormatV1toV4.d.ts +2 -2
  343. package/dist/shared-tree-core/editManagerFormatV1toV4.d.ts.map +1 -1
  344. package/dist/shared-tree-core/editManagerFormatV1toV4.js +0 -1
  345. package/dist/shared-tree-core/editManagerFormatV1toV4.js.map +1 -1
  346. package/dist/shared-tree-core/index.d.ts +2 -2
  347. package/dist/shared-tree-core/index.d.ts.map +1 -1
  348. package/dist/shared-tree-core/index.js +1 -3
  349. package/dist/shared-tree-core/index.js.map +1 -1
  350. package/dist/shared-tree-core/messageCodecV1ToV4.d.ts +1 -1
  351. package/dist/shared-tree-core/messageCodecV1ToV4.d.ts.map +1 -1
  352. package/dist/shared-tree-core/messageCodecV1ToV4.js.map +1 -1
  353. package/dist/shared-tree-core/messageCodecs.d.ts +0 -4
  354. package/dist/shared-tree-core/messageCodecs.d.ts.map +1 -1
  355. package/dist/shared-tree-core/messageCodecs.js +2 -10
  356. package/dist/shared-tree-core/messageCodecs.js.map +1 -1
  357. package/dist/shared-tree-core/messageFormat.d.ts +0 -1
  358. package/dist/shared-tree-core/messageFormat.d.ts.map +1 -1
  359. package/dist/shared-tree-core/messageFormat.js +0 -6
  360. package/dist/shared-tree-core/messageFormat.js.map +1 -1
  361. package/dist/shared-tree-core/messageFormatV1ToV4.d.ts +2 -2
  362. package/dist/shared-tree-core/messageFormatV1ToV4.d.ts.map +1 -1
  363. package/dist/shared-tree-core/messageFormatV1ToV4.js +0 -1
  364. package/dist/shared-tree-core/messageFormatV1ToV4.js.map +1 -1
  365. package/dist/shared-tree-core/sharedTreeCore.d.ts +0 -1
  366. package/dist/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
  367. package/dist/shared-tree-core/sharedTreeCore.js +1 -1
  368. package/dist/shared-tree-core/sharedTreeCore.js.map +1 -1
  369. package/dist/shared-tree-core/transaction.d.ts +15 -27
  370. package/dist/shared-tree-core/transaction.d.ts.map +1 -1
  371. package/dist/shared-tree-core/transaction.js +7 -11
  372. package/dist/shared-tree-core/transaction.js.map +1 -1
  373. package/dist/simple-tree/api/configuration.d.ts +4 -0
  374. package/dist/simple-tree/api/configuration.d.ts.map +1 -1
  375. package/dist/simple-tree/api/configuration.js.map +1 -1
  376. package/dist/simple-tree/api/identifierIndex.d.ts +2 -2
  377. package/dist/simple-tree/api/identifierIndex.d.ts.map +1 -1
  378. package/dist/simple-tree/api/identifierIndex.js +1 -1
  379. package/dist/simple-tree/api/identifierIndex.js.map +1 -1
  380. package/dist/simple-tree/api/index.d.ts +3 -3
  381. package/dist/simple-tree/api/index.d.ts.map +1 -1
  382. package/dist/simple-tree/api/index.js +2 -2
  383. package/dist/simple-tree/api/index.js.map +1 -1
  384. package/dist/simple-tree/api/schemaFactory.d.ts +3 -2
  385. package/dist/simple-tree/api/schemaFactory.d.ts.map +1 -1
  386. package/dist/simple-tree/api/schemaFactory.js +3 -2
  387. package/dist/simple-tree/api/schemaFactory.js.map +1 -1
  388. package/dist/simple-tree/api/simpleTreeIndex.d.ts +15 -13
  389. package/dist/simple-tree/api/simpleTreeIndex.d.ts.map +1 -1
  390. package/dist/simple-tree/api/simpleTreeIndex.js +4 -4
  391. package/dist/simple-tree/api/simpleTreeIndex.js.map +1 -1
  392. package/dist/simple-tree/api/snapshotCompatibilityChecker.d.ts +4 -4
  393. package/dist/simple-tree/api/snapshotCompatibilityChecker.js +2 -2
  394. package/dist/simple-tree/api/snapshotCompatibilityChecker.js.map +1 -1
  395. package/dist/simple-tree/api/transactionTypes.d.ts +22 -25
  396. package/dist/simple-tree/api/transactionTypes.d.ts.map +1 -1
  397. package/dist/simple-tree/api/transactionTypes.js.map +1 -1
  398. package/dist/simple-tree/api/tree.d.ts +69 -132
  399. package/dist/simple-tree/api/tree.d.ts.map +1 -1
  400. package/dist/simple-tree/api/tree.js.map +1 -1
  401. package/dist/simple-tree/core/unhydratedFlexTree.d.ts +12 -16
  402. package/dist/simple-tree/core/unhydratedFlexTree.d.ts.map +1 -1
  403. package/dist/simple-tree/core/unhydratedFlexTree.js +8 -59
  404. package/dist/simple-tree/core/unhydratedFlexTree.js.map +1 -1
  405. package/dist/simple-tree/fieldSchema.d.ts +4 -4
  406. package/dist/simple-tree/fieldSchema.d.ts.map +1 -1
  407. package/dist/simple-tree/fieldSchema.js.map +1 -1
  408. package/dist/simple-tree/index.d.ts +3 -3
  409. package/dist/simple-tree/index.d.ts.map +1 -1
  410. package/dist/simple-tree/index.js +3 -3
  411. package/dist/simple-tree/index.js.map +1 -1
  412. package/dist/simple-tree/node-kinds/array/arrayNode.d.ts.map +1 -1
  413. package/dist/simple-tree/node-kinds/array/arrayNode.js +3 -5
  414. package/dist/simple-tree/node-kinds/array/arrayNode.js.map +1 -1
  415. package/dist/simple-tree/node-kinds/common.d.ts.map +1 -1
  416. package/dist/simple-tree/node-kinds/common.js +1 -1
  417. package/dist/simple-tree/node-kinds/common.js.map +1 -1
  418. package/dist/simple-tree/node-kinds/map/mapNode.js +2 -2
  419. package/dist/simple-tree/node-kinds/map/mapNode.js.map +1 -1
  420. package/dist/simple-tree/node-kinds/object/objectNode.d.ts.map +1 -1
  421. package/dist/simple-tree/node-kinds/object/objectNode.js +19 -19
  422. package/dist/simple-tree/node-kinds/object/objectNode.js.map +1 -1
  423. package/dist/simple-tree/node-kinds/record/recordNode.d.ts.map +1 -1
  424. package/dist/simple-tree/node-kinds/record/recordNode.js +2 -4
  425. package/dist/simple-tree/node-kinds/record/recordNode.js.map +1 -1
  426. package/dist/simple-tree/prepareForInsertion.d.ts +47 -54
  427. package/dist/simple-tree/prepareForInsertion.d.ts.map +1 -1
  428. package/dist/simple-tree/prepareForInsertion.js +125 -183
  429. package/dist/simple-tree/prepareForInsertion.js.map +1 -1
  430. package/dist/simple-tree/unhydratedFlexTreeFromInsertable.d.ts +3 -8
  431. package/dist/simple-tree/unhydratedFlexTreeFromInsertable.d.ts.map +1 -1
  432. package/dist/simple-tree/unhydratedFlexTreeFromInsertable.js +13 -27
  433. package/dist/simple-tree/unhydratedFlexTreeFromInsertable.js.map +1 -1
  434. package/dist/text/textDomain.d.ts +27 -9
  435. package/dist/text/textDomain.d.ts.map +1 -1
  436. package/dist/text/textDomain.js +43 -7
  437. package/dist/text/textDomain.js.map +1 -1
  438. package/dist/text/textDomainFormatted.d.ts +14 -8
  439. package/dist/text/textDomainFormatted.d.ts.map +1 -1
  440. package/dist/text/textDomainFormatted.js +97 -25
  441. package/dist/text/textDomainFormatted.js.map +1 -1
  442. package/dist/treeFactory.d.ts.map +1 -1
  443. package/dist/treeFactory.js +2 -12
  444. package/dist/treeFactory.js.map +1 -1
  445. package/dist/util/index.d.ts +1 -1
  446. package/dist/util/index.d.ts.map +1 -1
  447. package/dist/util/index.js +1 -2
  448. package/dist/util/index.js.map +1 -1
  449. package/dist/util/rangeMap.d.ts +11 -22
  450. package/dist/util/rangeMap.d.ts.map +1 -1
  451. package/dist/util/rangeMap.js +4 -38
  452. package/dist/util/rangeMap.js.map +1 -1
  453. package/docs/main/sequence-field/move-composition.md +46 -0
  454. package/lib/alpha.d.ts +10 -6
  455. package/lib/beta.d.ts +4 -1
  456. package/lib/codec/codec.d.ts +2 -0
  457. package/lib/codec/codec.d.ts.map +1 -1
  458. package/lib/codec/codec.js +4 -3
  459. package/lib/codec/codec.js.map +1 -1
  460. package/lib/codec/index.d.ts +1 -1
  461. package/lib/codec/index.d.ts.map +1 -1
  462. package/lib/codec/index.js +1 -1
  463. package/lib/codec/index.js.map +1 -1
  464. package/lib/codec/versioned/codec.d.ts +13 -1
  465. package/lib/codec/versioned/codec.d.ts.map +1 -1
  466. package/lib/codec/versioned/codec.js +18 -3
  467. package/lib/codec/versioned/codec.js.map +1 -1
  468. package/lib/codec/versioned/format.d.ts +22 -1
  469. package/lib/codec/versioned/format.d.ts.map +1 -1
  470. package/lib/codec/versioned/format.js +15 -2
  471. package/lib/codec/versioned/format.js.map +1 -1
  472. package/lib/codec/versioned/index.d.ts +1 -1
  473. package/lib/codec/versioned/index.d.ts.map +1 -1
  474. package/lib/codec/versioned/index.js +1 -1
  475. package/lib/codec/versioned/index.js.map +1 -1
  476. package/lib/core/change-family/changeFamily.d.ts +1 -4
  477. package/lib/core/change-family/changeFamily.d.ts.map +1 -1
  478. package/lib/core/change-family/changeFamily.js.map +1 -1
  479. package/lib/core/change-family/index.d.ts +1 -1
  480. package/lib/core/change-family/index.d.ts.map +1 -1
  481. package/lib/core/change-family/index.js.map +1 -1
  482. package/lib/core/index.d.ts +3 -4
  483. package/lib/core/index.d.ts.map +1 -1
  484. package/lib/core/index.js +2 -3
  485. package/lib/core/index.js.map +1 -1
  486. package/lib/core/rebase/changeRebaser.d.ts +1 -6
  487. package/lib/core/rebase/changeRebaser.d.ts.map +1 -1
  488. package/lib/core/rebase/changeRebaser.js.map +1 -1
  489. package/lib/core/rebase/index.d.ts +1 -1
  490. package/lib/core/rebase/index.d.ts.map +1 -1
  491. package/lib/core/rebase/index.js +1 -1
  492. package/lib/core/rebase/index.js.map +1 -1
  493. package/lib/core/rebase/types.d.ts +78 -1
  494. package/lib/core/rebase/types.d.ts.map +1 -1
  495. package/lib/core/rebase/types.js +0 -3
  496. package/lib/core/rebase/types.js.map +1 -1
  497. package/lib/core/rebase/utils.d.ts.map +1 -1
  498. package/lib/core/rebase/utils.js +7 -25
  499. package/lib/core/rebase/utils.js.map +1 -1
  500. package/lib/core/tree/delta.d.ts +0 -5
  501. package/lib/core/tree/delta.d.ts.map +1 -1
  502. package/lib/core/tree/delta.js.map +1 -1
  503. package/lib/core/tree/detachedFieldIndex.d.ts +1 -13
  504. package/lib/core/tree/detachedFieldIndex.d.ts.map +1 -1
  505. package/lib/core/tree/detachedFieldIndex.js +2 -15
  506. package/lib/core/tree/detachedFieldIndex.js.map +1 -1
  507. package/lib/core/tree/detachedFieldIndexTypes.d.ts +0 -4
  508. package/lib/core/tree/detachedFieldIndexTypes.d.ts.map +1 -1
  509. package/lib/core/tree/detachedFieldIndexTypes.js.map +1 -1
  510. package/lib/core/tree/index.d.ts +2 -2
  511. package/lib/core/tree/index.d.ts.map +1 -1
  512. package/lib/core/tree/index.js +1 -1
  513. package/lib/core/tree/index.js.map +1 -1
  514. package/lib/core/tree/pathTree.d.ts +3 -11
  515. package/lib/core/tree/pathTree.d.ts.map +1 -1
  516. package/lib/core/tree/pathTree.js +1 -12
  517. package/lib/core/tree/pathTree.js.map +1 -1
  518. package/lib/core/tree/visitDelta.d.ts.map +1 -1
  519. package/lib/core/tree/visitDelta.js +13 -17
  520. package/lib/core/tree/visitDelta.js.map +1 -1
  521. package/lib/feature-libraries/changeAtomIdBTree.d.ts +2 -3
  522. package/lib/feature-libraries/changeAtomIdBTree.d.ts.map +1 -1
  523. package/lib/feature-libraries/changeAtomIdBTree.js +3 -15
  524. package/lib/feature-libraries/changeAtomIdBTree.js.map +1 -1
  525. package/lib/feature-libraries/chunked-forest/codec/codecs.d.ts +8 -7
  526. package/lib/feature-libraries/chunked-forest/codec/codecs.d.ts.map +1 -1
  527. package/lib/feature-libraries/chunked-forest/codec/codecs.js +25 -45
  528. package/lib/feature-libraries/chunked-forest/codec/codecs.js.map +1 -1
  529. package/lib/feature-libraries/chunked-forest/codec/format.d.ts.map +1 -1
  530. package/lib/feature-libraries/chunked-forest/codec/format.js +11 -0
  531. package/lib/feature-libraries/chunked-forest/codec/format.js.map +1 -1
  532. package/lib/feature-libraries/chunked-forest/codec/index.d.ts +3 -2
  533. package/lib/feature-libraries/chunked-forest/codec/index.d.ts.map +1 -1
  534. package/lib/feature-libraries/chunked-forest/codec/index.js +2 -2
  535. package/lib/feature-libraries/chunked-forest/codec/index.js.map +1 -1
  536. package/lib/feature-libraries/chunked-forest/index.d.ts +1 -1
  537. package/lib/feature-libraries/chunked-forest/index.d.ts.map +1 -1
  538. package/lib/feature-libraries/chunked-forest/index.js +1 -1
  539. package/lib/feature-libraries/chunked-forest/index.js.map +1 -1
  540. package/lib/feature-libraries/default-schema/defaultEditBuilder.d.ts +44 -92
  541. package/lib/feature-libraries/default-schema/defaultEditBuilder.d.ts.map +1 -1
  542. package/lib/feature-libraries/default-schema/defaultEditBuilder.js +69 -217
  543. package/lib/feature-libraries/default-schema/defaultEditBuilder.js.map +1 -1
  544. package/lib/feature-libraries/default-schema/defaultFieldKinds.d.ts.map +1 -1
  545. package/lib/feature-libraries/default-schema/defaultFieldKinds.js +2 -12
  546. package/lib/feature-libraries/default-schema/defaultFieldKinds.js.map +1 -1
  547. package/lib/feature-libraries/default-schema/index.d.ts +1 -2
  548. package/lib/feature-libraries/default-schema/index.d.ts.map +1 -1
  549. package/lib/feature-libraries/default-schema/index.js +1 -2
  550. package/lib/feature-libraries/default-schema/index.js.map +1 -1
  551. package/lib/feature-libraries/default-schema/mappedEditBuilder.d.ts +6 -7
  552. package/lib/feature-libraries/default-schema/mappedEditBuilder.d.ts.map +1 -1
  553. package/lib/feature-libraries/default-schema/mappedEditBuilder.js +0 -15
  554. package/lib/feature-libraries/default-schema/mappedEditBuilder.js.map +1 -1
  555. package/lib/feature-libraries/deltaUtils.d.ts +0 -1
  556. package/lib/feature-libraries/deltaUtils.d.ts.map +1 -1
  557. package/lib/feature-libraries/deltaUtils.js +1 -5
  558. package/lib/feature-libraries/deltaUtils.js.map +1 -1
  559. package/lib/feature-libraries/flex-tree/context.d.ts +0 -9
  560. package/lib/feature-libraries/flex-tree/context.d.ts.map +1 -1
  561. package/lib/feature-libraries/flex-tree/context.js +0 -6
  562. package/lib/feature-libraries/flex-tree/context.js.map +1 -1
  563. package/lib/feature-libraries/flex-tree/flexTreeTypes.d.ts +6 -6
  564. package/lib/feature-libraries/flex-tree/flexTreeTypes.d.ts.map +1 -1
  565. package/lib/feature-libraries/flex-tree/flexTreeTypes.js.map +1 -1
  566. package/lib/feature-libraries/flex-tree/lazyField.d.ts +7 -8
  567. package/lib/feature-libraries/flex-tree/lazyField.d.ts.map +1 -1
  568. package/lib/feature-libraries/flex-tree/lazyField.js +9 -40
  569. package/lib/feature-libraries/flex-tree/lazyField.js.map +1 -1
  570. package/lib/feature-libraries/flex-tree/observer.d.ts +17 -0
  571. package/lib/feature-libraries/flex-tree/observer.d.ts.map +1 -1
  572. package/lib/feature-libraries/flex-tree/observer.js.map +1 -1
  573. package/lib/feature-libraries/forest-summary/codec.d.ts +5 -12
  574. package/lib/feature-libraries/forest-summary/codec.d.ts.map +1 -1
  575. package/lib/feature-libraries/forest-summary/codec.js +35 -32
  576. package/lib/feature-libraries/forest-summary/codec.js.map +1 -1
  577. package/lib/feature-libraries/forest-summary/forestSummarizer.d.ts +2 -2
  578. package/lib/feature-libraries/forest-summary/forestSummarizer.d.ts.map +1 -1
  579. package/lib/feature-libraries/forest-summary/forestSummarizer.js +7 -8
  580. package/lib/feature-libraries/forest-summary/forestSummarizer.js.map +1 -1
  581. package/lib/feature-libraries/forest-summary/formatCommon.d.ts +6 -4
  582. package/lib/feature-libraries/forest-summary/formatCommon.d.ts.map +1 -1
  583. package/lib/feature-libraries/forest-summary/formatCommon.js +7 -4
  584. package/lib/feature-libraries/forest-summary/formatCommon.js.map +1 -1
  585. package/lib/feature-libraries/forest-summary/incrementalSummaryBuilder.d.ts +19 -14
  586. package/lib/feature-libraries/forest-summary/incrementalSummaryBuilder.d.ts.map +1 -1
  587. package/lib/feature-libraries/forest-summary/incrementalSummaryBuilder.js +30 -47
  588. package/lib/feature-libraries/forest-summary/incrementalSummaryBuilder.js.map +1 -1
  589. package/lib/feature-libraries/forest-summary/index.d.ts +1 -1
  590. package/lib/feature-libraries/forest-summary/index.d.ts.map +1 -1
  591. package/lib/feature-libraries/forest-summary/index.js +1 -1
  592. package/lib/feature-libraries/forest-summary/index.js.map +1 -1
  593. package/lib/feature-libraries/index.d.ts +6 -6
  594. package/lib/feature-libraries/index.d.ts.map +1 -1
  595. package/lib/feature-libraries/index.js +5 -5
  596. package/lib/feature-libraries/index.js.map +1 -1
  597. package/lib/feature-libraries/indexing/anchorTreeIndex.d.ts +3 -3
  598. package/lib/feature-libraries/indexing/anchorTreeIndex.d.ts.map +1 -1
  599. package/lib/feature-libraries/indexing/anchorTreeIndex.js.map +1 -1
  600. package/lib/feature-libraries/indexing/index.d.ts +1 -1
  601. package/lib/feature-libraries/indexing/index.d.ts.map +1 -1
  602. package/lib/feature-libraries/indexing/index.js.map +1 -1
  603. package/lib/feature-libraries/indexing/types.d.ts +15 -13
  604. package/lib/feature-libraries/indexing/types.d.ts.map +1 -1
  605. package/lib/feature-libraries/indexing/types.js.map +1 -1
  606. package/lib/feature-libraries/mitigatedChangeFamily.d.ts.map +1 -1
  607. package/lib/feature-libraries/mitigatedChangeFamily.js +2 -2
  608. package/lib/feature-libraries/mitigatedChangeFamily.js.map +1 -1
  609. package/lib/feature-libraries/modular-schema/crossFieldQueries.d.ts +24 -100
  610. package/lib/feature-libraries/modular-schema/crossFieldQueries.d.ts.map +1 -1
  611. package/lib/feature-libraries/modular-schema/crossFieldQueries.js +10 -7
  612. package/lib/feature-libraries/modular-schema/crossFieldQueries.js.map +1 -1
  613. package/lib/feature-libraries/modular-schema/fieldChangeHandler.d.ts +51 -85
  614. package/lib/feature-libraries/modular-schema/fieldChangeHandler.d.ts.map +1 -1
  615. package/lib/feature-libraries/modular-schema/fieldChangeHandler.js.map +1 -1
  616. package/lib/feature-libraries/modular-schema/genericFieldKind.d.ts.map +1 -1
  617. package/lib/feature-libraries/modular-schema/genericFieldKind.js +9 -4
  618. package/lib/feature-libraries/modular-schema/genericFieldKind.js.map +1 -1
  619. package/lib/feature-libraries/modular-schema/index.d.ts +3 -3
  620. package/lib/feature-libraries/modular-schema/index.d.ts.map +1 -1
  621. package/lib/feature-libraries/modular-schema/index.js +1 -1
  622. package/lib/feature-libraries/modular-schema/index.js.map +1 -1
  623. package/lib/feature-libraries/modular-schema/modularChangeCodecV1.d.ts +22 -18
  624. package/lib/feature-libraries/modular-schema/modularChangeCodecV1.d.ts.map +1 -1
  625. package/lib/feature-libraries/modular-schema/modularChangeCodecV1.js +144 -267
  626. package/lib/feature-libraries/modular-schema/modularChangeCodecV1.js.map +1 -1
  627. package/lib/feature-libraries/modular-schema/modularChangeCodecV2.d.ts.map +1 -1
  628. package/lib/feature-libraries/modular-schema/modularChangeCodecV2.js +1 -1
  629. package/lib/feature-libraries/modular-schema/modularChangeCodecV2.js.map +1 -1
  630. package/lib/feature-libraries/modular-schema/modularChangeCodecs.d.ts +0 -1
  631. package/lib/feature-libraries/modular-schema/modularChangeCodecs.d.ts.map +1 -1
  632. package/lib/feature-libraries/modular-schema/modularChangeCodecs.js +0 -8
  633. package/lib/feature-libraries/modular-schema/modularChangeCodecs.js.map +1 -1
  634. package/lib/feature-libraries/modular-schema/modularChangeFamily.d.ts +22 -56
  635. package/lib/feature-libraries/modular-schema/modularChangeFamily.d.ts.map +1 -1
  636. package/lib/feature-libraries/modular-schema/modularChangeFamily.js +468 -1387
  637. package/lib/feature-libraries/modular-schema/modularChangeFamily.js.map +1 -1
  638. package/lib/feature-libraries/modular-schema/modularChangeFormatV1.d.ts.map +1 -1
  639. package/lib/feature-libraries/modular-schema/modularChangeFormatV1.js.map +1 -1
  640. package/lib/feature-libraries/modular-schema/modularChangeFormatV2.d.ts +2 -1
  641. package/lib/feature-libraries/modular-schema/modularChangeFormatV2.d.ts.map +1 -1
  642. package/lib/feature-libraries/modular-schema/modularChangeFormatV2.js +1 -1
  643. package/lib/feature-libraries/modular-schema/modularChangeFormatV2.js.map +1 -1
  644. package/lib/feature-libraries/modular-schema/modularChangeTypes.d.ts +10 -49
  645. package/lib/feature-libraries/modular-schema/modularChangeTypes.d.ts.map +1 -1
  646. package/lib/feature-libraries/modular-schema/modularChangeTypes.js +1 -1
  647. package/lib/feature-libraries/modular-schema/modularChangeTypes.js.map +1 -1
  648. package/lib/feature-libraries/optional-field/optionalField.d.ts +32 -13
  649. package/lib/feature-libraries/optional-field/optionalField.d.ts.map +1 -1
  650. package/lib/feature-libraries/optional-field/optionalField.js +442 -254
  651. package/lib/feature-libraries/optional-field/optionalField.js.map +1 -1
  652. package/lib/feature-libraries/optional-field/optionalFieldChangeTypes.d.ts +31 -31
  653. package/lib/feature-libraries/optional-field/optionalFieldChangeTypes.d.ts.map +1 -1
  654. package/lib/feature-libraries/optional-field/optionalFieldChangeTypes.js.map +1 -1
  655. package/lib/feature-libraries/optional-field/optionalFieldCodecV2.d.ts +1 -1
  656. package/lib/feature-libraries/optional-field/optionalFieldCodecV2.d.ts.map +1 -1
  657. package/lib/feature-libraries/optional-field/optionalFieldCodecV2.js +26 -55
  658. package/lib/feature-libraries/optional-field/optionalFieldCodecV2.js.map +1 -1
  659. package/lib/feature-libraries/optional-field/optionalFieldCodecs.d.ts.map +1 -1
  660. package/lib/feature-libraries/optional-field/optionalFieldCodecs.js +1 -5
  661. package/lib/feature-libraries/optional-field/optionalFieldCodecs.js.map +1 -1
  662. package/lib/feature-libraries/optional-field/requiredField.d.ts +2 -3
  663. package/lib/feature-libraries/optional-field/requiredField.d.ts.map +1 -1
  664. package/lib/feature-libraries/optional-field/requiredField.js +1 -5
  665. package/lib/feature-libraries/optional-field/requiredField.js.map +1 -1
  666. package/lib/feature-libraries/sequence-field/compose.d.ts +7 -6
  667. package/lib/feature-libraries/sequence-field/compose.d.ts.map +1 -1
  668. package/lib/feature-libraries/sequence-field/compose.js +261 -83
  669. package/lib/feature-libraries/sequence-field/compose.js.map +1 -1
  670. package/lib/feature-libraries/sequence-field/helperTypes.d.ts +10 -14
  671. package/lib/feature-libraries/sequence-field/helperTypes.d.ts.map +1 -1
  672. package/lib/feature-libraries/sequence-field/helperTypes.js.map +1 -1
  673. package/lib/feature-libraries/sequence-field/invert.d.ts +3 -3
  674. package/lib/feature-libraries/sequence-field/invert.d.ts.map +1 -1
  675. package/lib/feature-libraries/sequence-field/invert.js +169 -67
  676. package/lib/feature-libraries/sequence-field/invert.js.map +1 -1
  677. package/lib/feature-libraries/sequence-field/markQueue.d.ts +2 -2
  678. package/lib/feature-libraries/sequence-field/markQueue.d.ts.map +1 -1
  679. package/lib/feature-libraries/sequence-field/markQueue.js.map +1 -1
  680. package/lib/feature-libraries/sequence-field/moveEffectTable.d.ts +56 -4
  681. package/lib/feature-libraries/sequence-field/moveEffectTable.d.ts.map +1 -1
  682. package/lib/feature-libraries/sequence-field/moveEffectTable.js +84 -6
  683. package/lib/feature-libraries/sequence-field/moveEffectTable.js.map +1 -1
  684. package/lib/feature-libraries/sequence-field/rebase.d.ts +3 -3
  685. package/lib/feature-libraries/sequence-field/rebase.d.ts.map +1 -1
  686. package/lib/feature-libraries/sequence-field/rebase.js +118 -111
  687. package/lib/feature-libraries/sequence-field/rebase.js.map +1 -1
  688. package/lib/feature-libraries/sequence-field/relevantRemovedRoots.d.ts +9 -0
  689. package/lib/feature-libraries/sequence-field/relevantRemovedRoots.d.ts.map +1 -0
  690. package/lib/feature-libraries/sequence-field/relevantRemovedRoots.js +46 -0
  691. package/lib/feature-libraries/sequence-field/relevantRemovedRoots.js.map +1 -0
  692. package/lib/feature-libraries/sequence-field/replaceRevisions.d.ts.map +1 -1
  693. package/lib/feature-libraries/sequence-field/replaceRevisions.js +32 -19
  694. package/lib/feature-libraries/sequence-field/replaceRevisions.js.map +1 -1
  695. package/lib/feature-libraries/sequence-field/sequenceFieldChangeHandler.d.ts.map +1 -1
  696. package/lib/feature-libraries/sequence-field/sequenceFieldChangeHandler.js +3 -2
  697. package/lib/feature-libraries/sequence-field/sequenceFieldChangeHandler.js.map +1 -1
  698. package/lib/feature-libraries/sequence-field/sequenceFieldCodecV2.d.ts +4 -22
  699. package/lib/feature-libraries/sequence-field/sequenceFieldCodecV2.d.ts.map +1 -1
  700. package/lib/feature-libraries/sequence-field/sequenceFieldCodecV2.js +182 -379
  701. package/lib/feature-libraries/sequence-field/sequenceFieldCodecV2.js.map +1 -1
  702. package/lib/feature-libraries/sequence-field/sequenceFieldCodecV3.d.ts.map +1 -1
  703. package/lib/feature-libraries/sequence-field/sequenceFieldCodecV3.js +63 -21
  704. package/lib/feature-libraries/sequence-field/sequenceFieldCodecV3.js.map +1 -1
  705. package/lib/feature-libraries/sequence-field/sequenceFieldEditor.d.ts +2 -2
  706. package/lib/feature-libraries/sequence-field/sequenceFieldEditor.d.ts.map +1 -1
  707. package/lib/feature-libraries/sequence-field/sequenceFieldEditor.js +13 -13
  708. package/lib/feature-libraries/sequence-field/sequenceFieldEditor.js.map +1 -1
  709. package/lib/feature-libraries/sequence-field/sequenceFieldToDelta.d.ts +2 -3
  710. package/lib/feature-libraries/sequence-field/sequenceFieldToDelta.d.ts.map +1 -1
  711. package/lib/feature-libraries/sequence-field/sequenceFieldToDelta.js +111 -16
  712. package/lib/feature-libraries/sequence-field/sequenceFieldToDelta.js.map +1 -1
  713. package/lib/feature-libraries/sequence-field/types.d.ts +74 -37
  714. package/lib/feature-libraries/sequence-field/types.d.ts.map +1 -1
  715. package/lib/feature-libraries/sequence-field/types.js.map +1 -1
  716. package/lib/feature-libraries/sequence-field/utils.d.ts +25 -20
  717. package/lib/feature-libraries/sequence-field/utils.d.ts.map +1 -1
  718. package/lib/feature-libraries/sequence-field/utils.js +313 -155
  719. package/lib/feature-libraries/sequence-field/utils.js.map +1 -1
  720. package/lib/index.d.ts +3 -3
  721. package/lib/index.d.ts.map +1 -1
  722. package/lib/index.js +1 -1
  723. package/lib/index.js.map +1 -1
  724. package/lib/legacy.d.ts +4 -1
  725. package/lib/packageVersion.d.ts +1 -1
  726. package/lib/packageVersion.d.ts.map +1 -1
  727. package/lib/packageVersion.js +1 -1
  728. package/lib/packageVersion.js.map +1 -1
  729. package/lib/shared-tree/independentView.d.ts.map +1 -1
  730. package/lib/shared-tree/independentView.js +4 -4
  731. package/lib/shared-tree/independentView.js.map +1 -1
  732. package/lib/shared-tree/index.d.ts +1 -1
  733. package/lib/shared-tree/index.d.ts.map +1 -1
  734. package/lib/shared-tree/index.js.map +1 -1
  735. package/lib/shared-tree/schematizeTree.d.ts +4 -4
  736. package/lib/shared-tree/schematizeTree.d.ts.map +1 -1
  737. package/lib/shared-tree/schematizeTree.js +2 -3
  738. package/lib/shared-tree/schematizeTree.js.map +1 -1
  739. package/lib/shared-tree/schematizingTreeView.d.ts +10 -1
  740. package/lib/shared-tree/schematizingTreeView.d.ts.map +1 -1
  741. package/lib/shared-tree/schematizingTreeView.js +71 -30
  742. package/lib/shared-tree/schematizingTreeView.js.map +1 -1
  743. package/lib/shared-tree/sharedTree.d.ts +3 -9
  744. package/lib/shared-tree/sharedTree.d.ts.map +1 -1
  745. package/lib/shared-tree/sharedTree.js +9 -12
  746. package/lib/shared-tree/sharedTree.js.map +1 -1
  747. package/lib/shared-tree/sharedTreeChangeCodecs.d.ts +0 -1
  748. package/lib/shared-tree/sharedTreeChangeCodecs.d.ts.map +1 -1
  749. package/lib/shared-tree/sharedTreeChangeCodecs.js +0 -8
  750. package/lib/shared-tree/sharedTreeChangeCodecs.js.map +1 -1
  751. package/lib/shared-tree/sharedTreeChangeFamily.d.ts +4 -4
  752. package/lib/shared-tree/sharedTreeChangeFamily.d.ts.map +1 -1
  753. package/lib/shared-tree/sharedTreeChangeFamily.js +3 -3
  754. package/lib/shared-tree/sharedTreeChangeFamily.js.map +1 -1
  755. package/lib/shared-tree/sharedTreeEditBuilder.d.ts +6 -16
  756. package/lib/shared-tree/sharedTreeEditBuilder.d.ts.map +1 -1
  757. package/lib/shared-tree/sharedTreeEditBuilder.js +6 -12
  758. package/lib/shared-tree/sharedTreeEditBuilder.js.map +1 -1
  759. package/lib/shared-tree/tree.js +1 -1
  760. package/lib/shared-tree/tree.js.map +1 -1
  761. package/lib/shared-tree/treeAlpha.d.ts +8 -1
  762. package/lib/shared-tree/treeAlpha.d.ts.map +1 -1
  763. package/lib/shared-tree/treeAlpha.js +49 -9
  764. package/lib/shared-tree/treeAlpha.js.map +1 -1
  765. package/lib/shared-tree/treeCheckout.d.ts +46 -16
  766. package/lib/shared-tree/treeCheckout.d.ts.map +1 -1
  767. package/lib/shared-tree/treeCheckout.js +132 -76
  768. package/lib/shared-tree/treeCheckout.js.map +1 -1
  769. package/lib/shared-tree/unhydratedTreeContext.d.ts +20 -0
  770. package/lib/shared-tree/unhydratedTreeContext.d.ts.map +1 -0
  771. package/lib/shared-tree/unhydratedTreeContext.js +52 -0
  772. package/lib/shared-tree/unhydratedTreeContext.js.map +1 -0
  773. package/lib/shared-tree-core/branch.d.ts +2 -3
  774. package/lib/shared-tree-core/branch.d.ts.map +1 -1
  775. package/lib/shared-tree-core/branch.js +3 -4
  776. package/lib/shared-tree-core/branch.js.map +1 -1
  777. package/lib/shared-tree-core/editManager.d.ts +2 -2
  778. package/lib/shared-tree-core/editManager.d.ts.map +1 -1
  779. package/lib/shared-tree-core/editManager.js +9 -9
  780. package/lib/shared-tree-core/editManager.js.map +1 -1
  781. package/lib/shared-tree-core/editManagerCodecs.d.ts +0 -4
  782. package/lib/shared-tree-core/editManagerCodecs.d.ts.map +1 -1
  783. package/lib/shared-tree-core/editManagerCodecs.js +1 -8
  784. package/lib/shared-tree-core/editManagerCodecs.js.map +1 -1
  785. package/lib/shared-tree-core/editManagerFormatCommons.d.ts +0 -1
  786. package/lib/shared-tree-core/editManagerFormatCommons.d.ts.map +1 -1
  787. package/lib/shared-tree-core/editManagerFormatCommons.js +0 -6
  788. package/lib/shared-tree-core/editManagerFormatCommons.js.map +1 -1
  789. package/lib/shared-tree-core/editManagerFormatV1toV4.d.ts +2 -2
  790. package/lib/shared-tree-core/editManagerFormatV1toV4.d.ts.map +1 -1
  791. package/lib/shared-tree-core/editManagerFormatV1toV4.js +0 -1
  792. package/lib/shared-tree-core/editManagerFormatV1toV4.js.map +1 -1
  793. package/lib/shared-tree-core/index.d.ts +2 -2
  794. package/lib/shared-tree-core/index.d.ts.map +1 -1
  795. package/lib/shared-tree-core/index.js +2 -2
  796. package/lib/shared-tree-core/index.js.map +1 -1
  797. package/lib/shared-tree-core/messageCodecV1ToV4.d.ts +1 -1
  798. package/lib/shared-tree-core/messageCodecV1ToV4.d.ts.map +1 -1
  799. package/lib/shared-tree-core/messageCodecV1ToV4.js.map +1 -1
  800. package/lib/shared-tree-core/messageCodecs.d.ts +0 -4
  801. package/lib/shared-tree-core/messageCodecs.d.ts.map +1 -1
  802. package/lib/shared-tree-core/messageCodecs.js +1 -8
  803. package/lib/shared-tree-core/messageCodecs.js.map +1 -1
  804. package/lib/shared-tree-core/messageFormat.d.ts +0 -1
  805. package/lib/shared-tree-core/messageFormat.d.ts.map +1 -1
  806. package/lib/shared-tree-core/messageFormat.js +0 -6
  807. package/lib/shared-tree-core/messageFormat.js.map +1 -1
  808. package/lib/shared-tree-core/messageFormatV1ToV4.d.ts +2 -2
  809. package/lib/shared-tree-core/messageFormatV1ToV4.d.ts.map +1 -1
  810. package/lib/shared-tree-core/messageFormatV1ToV4.js +0 -1
  811. package/lib/shared-tree-core/messageFormatV1ToV4.js.map +1 -1
  812. package/lib/shared-tree-core/sharedTreeCore.d.ts +0 -1
  813. package/lib/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
  814. package/lib/shared-tree-core/sharedTreeCore.js +1 -1
  815. package/lib/shared-tree-core/sharedTreeCore.js.map +1 -1
  816. package/lib/shared-tree-core/transaction.d.ts +15 -27
  817. package/lib/shared-tree-core/transaction.d.ts.map +1 -1
  818. package/lib/shared-tree-core/transaction.js +7 -11
  819. package/lib/shared-tree-core/transaction.js.map +1 -1
  820. package/lib/simple-tree/api/configuration.d.ts +4 -0
  821. package/lib/simple-tree/api/configuration.d.ts.map +1 -1
  822. package/lib/simple-tree/api/configuration.js.map +1 -1
  823. package/lib/simple-tree/api/identifierIndex.d.ts +2 -2
  824. package/lib/simple-tree/api/identifierIndex.d.ts.map +1 -1
  825. package/lib/simple-tree/api/identifierIndex.js +2 -2
  826. package/lib/simple-tree/api/identifierIndex.js.map +1 -1
  827. package/lib/simple-tree/api/index.d.ts +3 -3
  828. package/lib/simple-tree/api/index.d.ts.map +1 -1
  829. package/lib/simple-tree/api/index.js +1 -1
  830. package/lib/simple-tree/api/index.js.map +1 -1
  831. package/lib/simple-tree/api/schemaFactory.d.ts +3 -2
  832. package/lib/simple-tree/api/schemaFactory.d.ts.map +1 -1
  833. package/lib/simple-tree/api/schemaFactory.js +3 -2
  834. package/lib/simple-tree/api/schemaFactory.js.map +1 -1
  835. package/lib/simple-tree/api/simpleTreeIndex.d.ts +15 -13
  836. package/lib/simple-tree/api/simpleTreeIndex.d.ts.map +1 -1
  837. package/lib/simple-tree/api/simpleTreeIndex.js +2 -2
  838. package/lib/simple-tree/api/simpleTreeIndex.js.map +1 -1
  839. package/lib/simple-tree/api/snapshotCompatibilityChecker.d.ts +4 -4
  840. package/lib/simple-tree/api/snapshotCompatibilityChecker.js +2 -2
  841. package/lib/simple-tree/api/snapshotCompatibilityChecker.js.map +1 -1
  842. package/lib/simple-tree/api/transactionTypes.d.ts +22 -25
  843. package/lib/simple-tree/api/transactionTypes.d.ts.map +1 -1
  844. package/lib/simple-tree/api/transactionTypes.js.map +1 -1
  845. package/lib/simple-tree/api/tree.d.ts +69 -132
  846. package/lib/simple-tree/api/tree.d.ts.map +1 -1
  847. package/lib/simple-tree/api/tree.js.map +1 -1
  848. package/lib/simple-tree/core/unhydratedFlexTree.d.ts +12 -16
  849. package/lib/simple-tree/core/unhydratedFlexTree.d.ts.map +1 -1
  850. package/lib/simple-tree/core/unhydratedFlexTree.js +8 -58
  851. package/lib/simple-tree/core/unhydratedFlexTree.js.map +1 -1
  852. package/lib/simple-tree/fieldSchema.d.ts +4 -4
  853. package/lib/simple-tree/fieldSchema.d.ts.map +1 -1
  854. package/lib/simple-tree/fieldSchema.js.map +1 -1
  855. package/lib/simple-tree/index.d.ts +3 -3
  856. package/lib/simple-tree/index.d.ts.map +1 -1
  857. package/lib/simple-tree/index.js +2 -2
  858. package/lib/simple-tree/index.js.map +1 -1
  859. package/lib/simple-tree/node-kinds/array/arrayNode.d.ts.map +1 -1
  860. package/lib/simple-tree/node-kinds/array/arrayNode.js +4 -6
  861. package/lib/simple-tree/node-kinds/array/arrayNode.js.map +1 -1
  862. package/lib/simple-tree/node-kinds/common.d.ts.map +1 -1
  863. package/lib/simple-tree/node-kinds/common.js +2 -2
  864. package/lib/simple-tree/node-kinds/common.js.map +1 -1
  865. package/lib/simple-tree/node-kinds/map/mapNode.js +2 -2
  866. package/lib/simple-tree/node-kinds/map/mapNode.js.map +1 -1
  867. package/lib/simple-tree/node-kinds/object/objectNode.d.ts.map +1 -1
  868. package/lib/simple-tree/node-kinds/object/objectNode.js +20 -20
  869. package/lib/simple-tree/node-kinds/object/objectNode.js.map +1 -1
  870. package/lib/simple-tree/node-kinds/record/recordNode.d.ts.map +1 -1
  871. package/lib/simple-tree/node-kinds/record/recordNode.js +2 -4
  872. package/lib/simple-tree/node-kinds/record/recordNode.js.map +1 -1
  873. package/lib/simple-tree/prepareForInsertion.d.ts +47 -54
  874. package/lib/simple-tree/prepareForInsertion.d.ts.map +1 -1
  875. package/lib/simple-tree/prepareForInsertion.js +125 -184
  876. package/lib/simple-tree/prepareForInsertion.js.map +1 -1
  877. package/lib/simple-tree/unhydratedFlexTreeFromInsertable.d.ts +3 -8
  878. package/lib/simple-tree/unhydratedFlexTreeFromInsertable.d.ts.map +1 -1
  879. package/lib/simple-tree/unhydratedFlexTreeFromInsertable.js +10 -23
  880. package/lib/simple-tree/unhydratedFlexTreeFromInsertable.js.map +1 -1
  881. package/lib/text/textDomain.d.ts +27 -9
  882. package/lib/text/textDomain.d.ts.map +1 -1
  883. package/lib/text/textDomain.js +45 -9
  884. package/lib/text/textDomain.js.map +1 -1
  885. package/lib/text/textDomainFormatted.d.ts +14 -8
  886. package/lib/text/textDomainFormatted.d.ts.map +1 -1
  887. package/lib/text/textDomainFormatted.js +80 -8
  888. package/lib/text/textDomainFormatted.js.map +1 -1
  889. package/lib/treeFactory.d.ts.map +1 -1
  890. package/lib/treeFactory.js +3 -13
  891. package/lib/treeFactory.js.map +1 -1
  892. package/lib/util/index.d.ts +1 -1
  893. package/lib/util/index.d.ts.map +1 -1
  894. package/lib/util/index.js +1 -1
  895. package/lib/util/index.js.map +1 -1
  896. package/lib/util/rangeMap.d.ts +11 -22
  897. package/lib/util/rangeMap.d.ts.map +1 -1
  898. package/lib/util/rangeMap.js +3 -36
  899. package/lib/util/rangeMap.js.map +1 -1
  900. package/package.json +24 -24
  901. package/src/codec/codec.ts +5 -4
  902. package/src/codec/index.ts +1 -0
  903. package/src/codec/versioned/codec.ts +32 -6
  904. package/src/codec/versioned/format.ts +17 -2
  905. package/src/codec/versioned/index.ts +1 -1
  906. package/src/core/change-family/changeFamily.ts +0 -5
  907. package/src/core/change-family/index.ts +0 -1
  908. package/src/core/index.ts +3 -10
  909. package/src/core/rebase/changeRebaser.ts +1 -6
  910. package/src/core/rebase/index.ts +2 -1
  911. package/src/core/rebase/types.ts +80 -4
  912. package/src/core/rebase/utils.ts +7 -31
  913. package/src/core/tree/delta.ts +0 -6
  914. package/src/core/tree/detachedFieldIndex.ts +1 -29
  915. package/src/core/tree/detachedFieldIndexTypes.ts +0 -5
  916. package/src/core/tree/index.ts +12 -13
  917. package/src/core/tree/pathTree.ts +4 -16
  918. package/src/core/tree/visitDelta.ts +11 -31
  919. package/src/feature-libraries/changeAtomIdBTree.ts +3 -28
  920. package/src/feature-libraries/chunked-forest/codec/codecs.ts +59 -78
  921. package/src/feature-libraries/chunked-forest/codec/format.ts +11 -0
  922. package/src/feature-libraries/chunked-forest/codec/index.ts +3 -3
  923. package/src/feature-libraries/chunked-forest/index.ts +2 -3
  924. package/src/feature-libraries/default-schema/defaultEditBuilder.ts +127 -369
  925. package/src/feature-libraries/default-schema/defaultFieldKinds.ts +4 -13
  926. package/src/feature-libraries/default-schema/index.ts +5 -16
  927. package/src/feature-libraries/default-schema/mappedEditBuilder.ts +9 -35
  928. package/src/feature-libraries/deltaUtils.ts +1 -6
  929. package/src/feature-libraries/flex-tree/context.ts +0 -17
  930. package/src/feature-libraries/flex-tree/flexTreeTypes.ts +8 -7
  931. package/src/feature-libraries/flex-tree/lazyField.ts +24 -65
  932. package/src/feature-libraries/flex-tree/observer.ts +17 -0
  933. package/src/feature-libraries/forest-summary/codec.ts +46 -56
  934. package/src/feature-libraries/forest-summary/forestSummarizer.ts +5 -14
  935. package/src/feature-libraries/forest-summary/formatCommon.ts +14 -19
  936. package/src/feature-libraries/forest-summary/incrementalSummaryBuilder.ts +44 -74
  937. package/src/feature-libraries/forest-summary/index.ts +1 -1
  938. package/src/feature-libraries/index.ts +11 -26
  939. package/src/feature-libraries/indexing/anchorTreeIndex.ts +3 -5
  940. package/src/feature-libraries/indexing/index.ts +1 -1
  941. package/src/feature-libraries/indexing/types.ts +15 -17
  942. package/src/feature-libraries/mitigatedChangeFamily.ts +1 -3
  943. package/src/feature-libraries/modular-schema/crossFieldQueries.ts +47 -144
  944. package/src/feature-libraries/modular-schema/fieldChangeHandler.ts +58 -113
  945. package/src/feature-libraries/modular-schema/genericFieldKind.ts +18 -7
  946. package/src/feature-libraries/modular-schema/index.ts +16 -16
  947. package/src/feature-libraries/modular-schema/modularChangeCodecV1.ts +329 -604
  948. package/src/feature-libraries/modular-schema/modularChangeCodecV2.ts +0 -1
  949. package/src/feature-libraries/modular-schema/modularChangeCodecs.ts +0 -14
  950. package/src/feature-libraries/modular-schema/modularChangeFamily.ts +748 -2694
  951. package/src/feature-libraries/modular-schema/modularChangeFormatV1.ts +0 -1
  952. package/src/feature-libraries/modular-schema/modularChangeFormatV2.ts +1 -1
  953. package/src/feature-libraries/modular-schema/modularChangeTypes.ts +10 -62
  954. package/src/feature-libraries/optional-field/optionalField.ts +568 -359
  955. package/src/feature-libraries/optional-field/optionalFieldChangeTypes.ts +35 -31
  956. package/src/feature-libraries/optional-field/optionalFieldCodecV2.ts +35 -89
  957. package/src/feature-libraries/optional-field/optionalFieldCodecs.ts +1 -5
  958. package/src/feature-libraries/optional-field/requiredField.ts +2 -15
  959. package/src/feature-libraries/sequence-field/compose.ts +522 -137
  960. package/src/feature-libraries/sequence-field/helperTypes.ts +19 -34
  961. package/src/feature-libraries/sequence-field/invert.ts +228 -102
  962. package/src/feature-libraries/sequence-field/markQueue.ts +2 -2
  963. package/src/feature-libraries/sequence-field/moveEffectTable.ts +195 -8
  964. package/src/feature-libraries/sequence-field/rebase.ts +207 -171
  965. package/src/feature-libraries/sequence-field/relevantRemovedRoots.ts +57 -0
  966. package/src/feature-libraries/sequence-field/replaceRevisions.ts +52 -26
  967. package/src/feature-libraries/sequence-field/sequenceFieldChangeHandler.ts +3 -8
  968. package/src/feature-libraries/sequence-field/sequenceFieldCodecV2.ts +229 -677
  969. package/src/feature-libraries/sequence-field/sequenceFieldCodecV3.ts +70 -56
  970. package/src/feature-libraries/sequence-field/sequenceFieldEditor.ts +30 -28
  971. package/src/feature-libraries/sequence-field/sequenceFieldToDelta.ts +131 -21
  972. package/src/feature-libraries/sequence-field/types.ts +79 -40
  973. package/src/feature-libraries/sequence-field/utils.ts +370 -211
  974. package/src/index.ts +6 -3
  975. package/src/packageVersion.ts +1 -1
  976. package/src/shared-tree/independentView.ts +9 -15
  977. package/src/shared-tree/index.ts +2 -3
  978. package/src/shared-tree/schematizeTree.ts +8 -21
  979. package/src/shared-tree/schematizingTreeView.ts +111 -48
  980. package/src/shared-tree/sharedTree.ts +23 -40
  981. package/src/shared-tree/sharedTreeChangeCodecs.ts +0 -8
  982. package/src/shared-tree/sharedTreeChangeFamily.ts +4 -7
  983. package/src/shared-tree/sharedTreeEditBuilder.ts +8 -43
  984. package/src/shared-tree/tree.ts +1 -1
  985. package/src/shared-tree/treeAlpha.ts +64 -11
  986. package/src/shared-tree/treeCheckout.ts +159 -114
  987. package/src/shared-tree/unhydratedTreeContext.ts +87 -0
  988. package/src/shared-tree-core/branch.ts +2 -8
  989. package/src/shared-tree-core/editManager.ts +2 -16
  990. package/src/shared-tree-core/editManagerCodecs.ts +1 -11
  991. package/src/shared-tree-core/editManagerFormatCommons.ts +0 -6
  992. package/src/shared-tree-core/editManagerFormatV1toV4.ts +1 -3
  993. package/src/shared-tree-core/index.ts +0 -2
  994. package/src/shared-tree-core/messageCodecV1ToV4.ts +1 -2
  995. package/src/shared-tree-core/messageCodecs.ts +1 -11
  996. package/src/shared-tree-core/messageFormat.ts +0 -6
  997. package/src/shared-tree-core/messageFormatV1ToV4.ts +1 -3
  998. package/src/shared-tree-core/sharedTreeCore.ts +1 -4
  999. package/src/shared-tree-core/transaction.ts +19 -39
  1000. package/src/simple-tree/api/configuration.ts +4 -0
  1001. package/src/simple-tree/api/identifierIndex.ts +4 -4
  1002. package/src/simple-tree/api/index.ts +3 -1
  1003. package/src/simple-tree/api/schemaFactory.ts +3 -2
  1004. package/src/simple-tree/api/simpleTreeIndex.ts +26 -20
  1005. package/src/simple-tree/api/snapshotCompatibilityChecker.ts +4 -4
  1006. package/src/simple-tree/api/transactionTypes.ts +24 -26
  1007. package/src/simple-tree/api/tree.ts +92 -131
  1008. package/src/simple-tree/core/unhydratedFlexTree.ts +35 -82
  1009. package/src/simple-tree/fieldSchema.ts +4 -6
  1010. package/src/simple-tree/index.ts +5 -4
  1011. package/src/simple-tree/node-kinds/array/arrayNode.ts +5 -7
  1012. package/src/simple-tree/node-kinds/common.ts +5 -2
  1013. package/src/simple-tree/node-kinds/map/mapNode.ts +4 -4
  1014. package/src/simple-tree/node-kinds/object/objectNode.ts +26 -26
  1015. package/src/simple-tree/node-kinds/record/recordNode.ts +9 -10
  1016. package/src/simple-tree/prepareForInsertion.ts +200 -342
  1017. package/src/simple-tree/unhydratedFlexTreeFromInsertable.ts +15 -35
  1018. package/src/text/textDomain.ts +91 -12
  1019. package/src/text/textDomainFormatted.ts +127 -15
  1020. package/src/treeFactory.ts +4 -16
  1021. package/src/util/index.ts +0 -3
  1022. package/src/util/rangeMap.ts +15 -63
  1023. package/dist/core/schema-view/index.d.ts +0 -6
  1024. package/dist/core/schema-view/index.d.ts.map +0 -1
  1025. package/dist/core/schema-view/index.js +0 -10
  1026. package/dist/core/schema-view/index.js.map +0 -1
  1027. package/dist/core/schema-view/view.d.ts +0 -31
  1028. package/dist/core/schema-view/view.d.ts.map +0 -1
  1029. package/dist/core/schema-view/view.js +0 -18
  1030. package/dist/core/schema-view/view.js.map +0 -1
  1031. package/dist/feature-libraries/default-schema/locationBasedEditBuilder.d.ts +0 -40
  1032. package/dist/feature-libraries/default-schema/locationBasedEditBuilder.d.ts.map +0 -1
  1033. package/dist/feature-libraries/default-schema/locationBasedEditBuilder.js +0 -153
  1034. package/dist/feature-libraries/default-schema/locationBasedEditBuilder.js.map +0 -1
  1035. package/dist/feature-libraries/forest-summary/formatV1.d.ts +0 -12
  1036. package/dist/feature-libraries/forest-summary/formatV1.d.ts.map +0 -1
  1037. package/dist/feature-libraries/forest-summary/formatV1.js +0 -10
  1038. package/dist/feature-libraries/forest-summary/formatV1.js.map +0 -1
  1039. package/dist/feature-libraries/forest-summary/formatV2.d.ts +0 -12
  1040. package/dist/feature-libraries/forest-summary/formatV2.d.ts.map +0 -1
  1041. package/dist/feature-libraries/forest-summary/formatV2.js +0 -10
  1042. package/dist/feature-libraries/forest-summary/formatV2.js.map +0 -1
  1043. package/dist/feature-libraries/modular-schema/modularChangeCodecV3.d.ts +0 -15
  1044. package/dist/feature-libraries/modular-schema/modularChangeCodecV3.d.ts.map +0 -1
  1045. package/dist/feature-libraries/modular-schema/modularChangeCodecV3.js +0 -296
  1046. package/dist/feature-libraries/modular-schema/modularChangeCodecV3.js.map +0 -1
  1047. package/dist/feature-libraries/modular-schema/modularChangeFormatV3.d.ts +0 -74
  1048. package/dist/feature-libraries/modular-schema/modularChangeFormatV3.d.ts.map +0 -1
  1049. package/dist/feature-libraries/modular-schema/modularChangeFormatV3.js +0 -35
  1050. package/dist/feature-libraries/modular-schema/modularChangeFormatV3.js.map +0 -1
  1051. package/dist/feature-libraries/optional-field/optionalFieldChangeFormatV3.d.ts +0 -23
  1052. package/dist/feature-libraries/optional-field/optionalFieldChangeFormatV3.d.ts.map +0 -1
  1053. package/dist/feature-libraries/optional-field/optionalFieldChangeFormatV3.js +0 -31
  1054. package/dist/feature-libraries/optional-field/optionalFieldChangeFormatV3.js.map +0 -1
  1055. package/dist/feature-libraries/optional-field/optionalFieldCodecV3.d.ts +0 -12
  1056. package/dist/feature-libraries/optional-field/optionalFieldCodecV3.d.ts.map +0 -1
  1057. package/dist/feature-libraries/optional-field/optionalFieldCodecV3.js +0 -57
  1058. package/dist/feature-libraries/optional-field/optionalFieldCodecV3.js.map +0 -1
  1059. package/lib/core/schema-view/index.d.ts +0 -6
  1060. package/lib/core/schema-view/index.d.ts.map +0 -1
  1061. package/lib/core/schema-view/index.js +0 -6
  1062. package/lib/core/schema-view/index.js.map +0 -1
  1063. package/lib/core/schema-view/view.d.ts +0 -31
  1064. package/lib/core/schema-view/view.d.ts.map +0 -1
  1065. package/lib/core/schema-view/view.js +0 -14
  1066. package/lib/core/schema-view/view.js.map +0 -1
  1067. package/lib/feature-libraries/default-schema/locationBasedEditBuilder.d.ts +0 -40
  1068. package/lib/feature-libraries/default-schema/locationBasedEditBuilder.d.ts.map +0 -1
  1069. package/lib/feature-libraries/default-schema/locationBasedEditBuilder.js +0 -149
  1070. package/lib/feature-libraries/default-schema/locationBasedEditBuilder.js.map +0 -1
  1071. package/lib/feature-libraries/forest-summary/formatV1.d.ts +0 -12
  1072. package/lib/feature-libraries/forest-summary/formatV1.d.ts.map +0 -1
  1073. package/lib/feature-libraries/forest-summary/formatV1.js +0 -7
  1074. package/lib/feature-libraries/forest-summary/formatV1.js.map +0 -1
  1075. package/lib/feature-libraries/forest-summary/formatV2.d.ts +0 -12
  1076. package/lib/feature-libraries/forest-summary/formatV2.d.ts.map +0 -1
  1077. package/lib/feature-libraries/forest-summary/formatV2.js +0 -7
  1078. package/lib/feature-libraries/forest-summary/formatV2.js.map +0 -1
  1079. package/lib/feature-libraries/modular-schema/modularChangeCodecV3.d.ts +0 -15
  1080. package/lib/feature-libraries/modular-schema/modularChangeCodecV3.d.ts.map +0 -1
  1081. package/lib/feature-libraries/modular-schema/modularChangeCodecV3.js +0 -292
  1082. package/lib/feature-libraries/modular-schema/modularChangeCodecV3.js.map +0 -1
  1083. package/lib/feature-libraries/modular-schema/modularChangeFormatV3.d.ts +0 -74
  1084. package/lib/feature-libraries/modular-schema/modularChangeFormatV3.d.ts.map +0 -1
  1085. package/lib/feature-libraries/modular-schema/modularChangeFormatV3.js +0 -32
  1086. package/lib/feature-libraries/modular-schema/modularChangeFormatV3.js.map +0 -1
  1087. package/lib/feature-libraries/optional-field/optionalFieldChangeFormatV3.d.ts +0 -23
  1088. package/lib/feature-libraries/optional-field/optionalFieldChangeFormatV3.d.ts.map +0 -1
  1089. package/lib/feature-libraries/optional-field/optionalFieldChangeFormatV3.js +0 -27
  1090. package/lib/feature-libraries/optional-field/optionalFieldChangeFormatV3.js.map +0 -1
  1091. package/lib/feature-libraries/optional-field/optionalFieldCodecV3.d.ts +0 -12
  1092. package/lib/feature-libraries/optional-field/optionalFieldCodecV3.d.ts.map +0 -1
  1093. package/lib/feature-libraries/optional-field/optionalFieldCodecV3.js +0 -53
  1094. package/lib/feature-libraries/optional-field/optionalFieldCodecV3.js.map +0 -1
  1095. package/src/core/schema-view/README.md +0 -9
  1096. package/src/core/schema-view/index.ts +0 -10
  1097. package/src/core/schema-view/view.ts +0 -38
  1098. package/src/feature-libraries/default-schema/locationBasedEditBuilder.ts +0 -231
  1099. package/src/feature-libraries/forest-summary/formatV1.ts +0 -11
  1100. package/src/feature-libraries/forest-summary/formatV2.ts +0 -11
  1101. package/src/feature-libraries/modular-schema/modularChangeCodecV3.ts +0 -649
  1102. package/src/feature-libraries/modular-schema/modularChangeFormatV3.ts +0 -67
  1103. package/src/feature-libraries/optional-field/optionalFieldChangeFormatV3.ts +0 -45
  1104. package/src/feature-libraries/optional-field/optionalFieldCodecV3.ts +0 -94
@@ -1 +1 @@
1
- {"version":3,"file":"visitDelta.js","sourceRoot":"","sources":["../../../src/core/tree/visitDelta.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAE7D,OAAO,EAAkB,cAAc,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAK1F,OAAO,EAAE,cAAc,EAA+B,MAAM,aAAa,CAAC;AAE1E,OAAO,EAAE,uBAAuB,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAKzE;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH;;;;;;;;;;GAUG;AACH,MAAM,UAAU,UAAU,CACzB,KAAiB,EACjB,OAAqB,EACrB,kBAAsC,EACtC,cAAuC;IAEvC,MAAM,eAAe,GAAsC,IAAI,GAAG,EAAE,CAAC;IACrE,MAAM,eAAe,GAAsC,IAAI,GAAG,EAAE,CAAC;IACrE,MAAM,aAAa,GAA+B,EAAE,CAAC;IACrD,MAAM,gBAAgB,GAAoC,EAAE,CAAC;IAC7D,MAAM,UAAU,GAAoD,IAAI,GAAG,EAAE,CAAC;IAC9E,KAAK,MAAM,EACV,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,EACpB,KAAK,GACL,IAAI,KAAK,CAAC,UAAU,IAAI,EAAE,EAAE,CAAC;QAC7B,MAAM,WAAW,GAAG,oBAAoB,CAAC,KAAK,CAAC,CAAC;QAChD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,cAAc,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC;YAClD,MAAM,WAAW,GAAG,KAAK,GAAG,CAAC,CAAC;YAC9B,cAAc,CAAC,UAAU,EAAE,KAAK,EAAE,WAAW,EAAE,WAA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,KAAK,SAAS,IAAI,IAAI,CAAC,MAAM,KAAK,SAAS,EAAE,CAAC;YAC5D,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC;QACrB,CAAC;IACF,CAAC;AACF,CAAC;AAED;;;;GAIG;AACH,SAAS,oBAAoB,CAAC,KAAgB;IAC7C,OAAO,cAAc,CAAC,KAAK,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;AACxD,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\n\nimport { type NestedMap, setInNestedMap, tryGetFromNestedMap } from \"../../util/index.js\";\nimport type { RevisionTag } from \"../rebase/index.js\";\nimport type { FieldKey } from \"../schema-stored/index.js\";\n\nimport type { TreeChunk } from \"./chunk.js\";\nimport { mapCursorField, type ITreeCursorSynchronous } from \"./cursor.js\";\nimport type * as Delta from \"./delta.js\";\nimport { areDetachedNodeIdsEqual, offsetDetachId } from \"./deltaUtil.js\";\nimport type { DetachedFieldIndex } from \"./detachedFieldIndex.js\";\nimport type { ForestRootId, Major, Minor } from \"./detachedFieldIndexTypes.js\";\nimport type { NodeIndex, PlaceIndex, Range } from \"./pathTree.js\";\n\n/**\n * Implementation notes:\n *\n * The visit is organized into four phases:\n * 1. a detach pass\n * 2. root transfers\n * 3. an attach pass\n * 4. root destructions\n *\n * The core idea is that before content can be attached, it must first exist and be in a detached field.\n *\n * While the detach pass ensures that nodes to be attached are in a detached state, it does not guarantee that they\n * reside in the correct detached field. That is the responsibility of the root transfers phase.\n *\n * The attach phase carries out attaches.\n *\n * After the attach phase, roots destruction is carried out.\n * This needs to happen last to allow modifications to detached roots to be applied before they are destroyed.\n *\n * The details of the delta visit algorithm can impact how/when events are emitted by the objects that own the visitors.\n * For example, as of 2024-03-27, the subtreeChanged event of an AnchorNode is emitted when exiting a node during a\n * delta visit, and thus the two-pass nature of the algorithm means the event fires twice for any given change.\n */\n\n/**\n * Crawls the given `delta`, calling `visitor`'s callback for each change encountered.\n * Each successive call to the visitor callbacks assumes that the change described by earlier calls have been applied\n * to the document tree. For example, for a change that removes the first and third node of a field, the visitor calls\n * will first call detach with a range from indices 0 to 1 then call detach with a range from indices 1 to 2.\n *\n * @param delta - The delta to be crawled.\n * @param visitor - The object to notify of the changes encountered.\n * @param detachedFieldIndex - Index responsible for keeping track of the existing detached fields.\n * @param latestRevision - The latest revision tag associated with this delta.\n */\nexport function visitDelta(\n\tdelta: Delta.Root,\n\tvisitor: DeltaVisitor,\n\tdetachedFieldIndex: DetachedFieldIndex,\n\tlatestRevision: RevisionTag | undefined,\n): void {\n\tconst detachPassRoots: Map<ForestRootId, Delta.FieldMap> = new Map();\n\tconst attachPassRoots: Map<ForestRootId, Delta.FieldMap> = new Map();\n\tconst rootTransfers: Delta.DetachedNodeRename[] = [];\n\tconst rootDestructions: Delta.DetachedNodeDestruction[] = [];\n\tconst refreshers: NestedMap<Major, Minor, ITreeCursorSynchronous> = new Map();\n\tfor (const {\n\t\tid: { major, minor },\n\t\ttrees,\n\t} of delta.refreshers ?? []) {\n\t\tconst treeCursors = nodeCursorsFromChunk(trees);\n\t\tfor (let i = 0; i < trees.topLevelLength; i += 1) {\n\t\t\tconst offsettedId = minor + i;\n\t\t\tsetInNestedMap(refreshers, major, offsettedId, treeCursors[i]);\n\t\t}\n\t}\n\tconst detachConfig: PassConfig = {\n\t\tfunc: detachPass,\n\t\tlatestRevision,\n\t\trefreshers,\n\t\tdetachedFieldIndex,\n\t\tdetachPassRoots,\n\t\tattachPassRoots,\n\t\trootTransfers,\n\t\trootDestructions,\n\t};\n\tprocessBuilds(delta.build, detachConfig, visitor);\n\tprocessGlobal(delta.global, detachConfig, visitor);\n\tprocessRename(delta.rename, detachConfig);\n\tvisitFieldMarks(delta.fields, visitor, detachConfig);\n\tfixedPointVisitOfRoots(visitor, detachPassRoots, detachConfig);\n\ttransferRoots(\n\t\trootTransfers,\n\t\tattachPassRoots,\n\t\tdetachedFieldIndex,\n\t\tvisitor,\n\t\trefreshers,\n\t\tlatestRevision,\n\t);\n\tconst attachConfig: PassConfig = {\n\t\tfunc: attachPass,\n\t\tlatestRevision,\n\t\trefreshers,\n\t\tdetachedFieldIndex,\n\t\tdetachPassRoots,\n\t\tattachPassRoots,\n\t\trootTransfers,\n\t\trootDestructions,\n\t};\n\tvisitFieldMarks(delta.fields, visitor, attachConfig);\n\tfixedPointVisitOfRoots(visitor, attachPassRoots, attachConfig);\n\tcollectDestroys(delta.destroy, attachConfig);\n\tfor (const { id, count } of rootDestructions) {\n\t\tfor (let i = 0; i < count; i += 1) {\n\t\t\tconst offsetId = offsetDetachId(id, i);\n\t\t\tconst root = detachedFieldIndex.getEntry(offsetId);\n\t\t\tconst field = detachedFieldIndex.toFieldKey(root);\n\t\t\tvisitor.destroy(field, 1);\n\t\t\tdetachedFieldIndex.deleteEntry(offsetId);\n\t\t}\n\t}\n}\n\n/**\n * Visits all nodes in `roots` until none are left.\n * This function tolerates entries being added to and removed from `roots` as part of visits.\n * @param visitor - The visitor to visit the roots with.\n * @param roots - The initial set of roots to visit.\n * Individual entries are removed prior to being visited.\n * @param config - The configuration to use for visits.\n */\nfunction fixedPointVisitOfRoots(\n\tvisitor: DeltaVisitor,\n\troots: Map<ForestRootId, Delta.FieldMap>,\n\tconfig: PassConfig,\n): void {\n\twhile (roots.size > 0) {\n\t\tfor (const [root, modifications] of roots) {\n\t\t\troots.delete(root);\n\t\t\tconst field = config.detachedFieldIndex.toFieldKey(root);\n\t\t\tvisitor.enterField(field);\n\t\t\t// Note: each visit may lead to `roots` being populated with new entries or having some entries removed.\n\t\t\tvisitNode(0, modifications, visitor, config);\n\t\t\tvisitor.exitField(field);\n\t\t}\n\t}\n}\n\n/**\n * Transfers roots from one detached field to another.\n * This occurs in the following circumstances:\n * - A changeset moves then removes a node\n * - A changeset restores then moves a node\n * - A changeset restores then removes a node\n * TODO#5481: update the DetachedFieldIndex instead of moving the nodes around.\n *\n * @param rootTransfers - The transfers to perform.\n * @param mapToUpdate - A map to update based on the transfers being performed.\n * @param detachedFieldIndex - The index to update based on the transfers being performed.\n * @param visitor - The visitor to inform of the transfers being performed.\n */\nfunction transferRoots(\n\trootTransfers: readonly Delta.DetachedNodeRename[],\n\tmapToUpdate: Map<ForestRootId, unknown>,\n\tdetachedFieldIndex: DetachedFieldIndex,\n\tvisitor: DeltaVisitor,\n\trefreshers: NestedMap<Major, Minor, ITreeCursorSynchronous>,\n\trevision?: RevisionTag,\n): void {\n\ttype AtomizedNodeRename = Omit<Delta.DetachedNodeRename, \"count\"> & {\n\t\tisAttachable?: boolean;\n\t};\n\tlet nextBatch = rootTransfers.flatMap(({ oldId, newId, count }) => {\n\t\tconst atomized: AtomizedNodeRename[] = [];\n\t\t// It's possible for a detached node to be revived transiently such that it ends up back in the same detached field.\n\t\t// Making such a transfer wouldn't just be inefficient, it would lead us to mistakenly think we have moved all content\n\t\t// out of the source detached field, and would lead us to delete the tree index entry for that source detached field.\n\t\t// This would effectively result in the tree index missing an entry for the detached field.\n\t\t// This if statement prevents that from happening.\n\t\tif (!areDetachedNodeIdsEqual(oldId, newId)) {\n\t\t\tfor (let i = 0; i < count; i += 1) {\n\t\t\t\tconst source = detachedFieldIndex.isAttachable(offsetDetachId(oldId, i));\n\t\t\t\tatomized.push({\n\t\t\t\t\toldId: offsetDetachId(oldId, i),\n\t\t\t\t\tnewId: offsetDetachId(newId, i),\n\t\t\t\t\tisAttachable: source,\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t\treturn atomized;\n\t});\n\twhile (nextBatch.length > 0) {\n\t\tconst delayed: AtomizedNodeRename[] = [];\n\t\tconst priorSize = nextBatch.length;\n\t\tfor (const { oldId, newId, isAttachable } of nextBatch) {\n\t\t\tlet oldRootId = detachedFieldIndex.tryGetEntry(oldId);\n\t\t\tif (oldRootId === undefined) {\n\t\t\t\tconst tree = tryGetFromNestedMap(refreshers, oldId.major, oldId.minor);\n\t\t\t\tif (tree !== undefined) {\n\t\t\t\t\tbuildTrees(oldId, [tree], detachedFieldIndex, revision, false, visitor);\n\t\t\t\t\toldRootId = detachedFieldIndex.getEntry(oldId);\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (oldRootId === undefined) {\n\t\t\t\t// The source field is not populated.\n\t\t\t\t// This can happen when another rename needs to be performed first.\n\t\t\t\tdelayed.push({ oldId, newId, isAttachable });\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tlet newRootId = detachedFieldIndex.tryGetEntry(newId);\n\t\t\tif (newRootId !== undefined) {\n\t\t\t\t// The destination field is already occupied.\n\t\t\t\t// This can happen when another rename needs to be performed first.\n\t\t\t\tdelayed.push({ oldId, newId, isAttachable });\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tnewRootId = detachedFieldIndex.createEntry(newId, revision, isAttachable);\n\t\t\tconst fields = mapToUpdate.get(oldRootId);\n\t\t\tif (fields !== undefined) {\n\t\t\t\tmapToUpdate.delete(oldRootId);\n\t\t\t\tmapToUpdate.set(newRootId, fields);\n\t\t\t}\n\t\t\tconst oldField = detachedFieldIndex.toFieldKey(oldRootId);\n\t\t\tconst newField = detachedFieldIndex.toFieldKey(newRootId);\n\t\t\tvisitor.enterField(oldField);\n\t\t\tvisitor.detach({ start: 0, end: 1 }, newField, newId, false);\n\t\t\tvisitor.exitField(oldField);\n\t\t\tdetachedFieldIndex.deleteEntry(oldId);\n\t\t}\n\t\tassert(delayed.length < priorSize, 0x7cf /* transferRoots should make progress */);\n\t\tnextBatch = delayed;\n\t}\n}\n\n/**\n * Visitor for changes in a delta.\n * Must be freed after use.\n */\nexport interface DeltaVisitor {\n\t/**\n\t * Frees/releases the visitor.\n\t *\n\t * Must be called once the visitor finished traversing the delta for a couple of reasons:\n\t *\n\t * 1. Some visitors, such as those from forests, are put into a special mode while they have a visitor, forbidding some actions (like making more visitors).\n\t *\n\t * 2. Some visitors, such as those from an anchorSet, defer some events for batching purposes until the visitor is freed.\n\t */\n\tfree(): void;\n\t/**\n\t * Creates nodes for the given content in a new detached field.\n\t * @param content - The content to create.\n\t * @param destination - The key for a new detached field.\n\t * A field with this key must not already exist.\n\t */\n\tcreate(content: readonly ITreeCursorSynchronous[], destination: FieldKey): void;\n\t/**\n\t * Recursively destroys the given detached field and all of the nodes within it.\n\t * @param detachedField - The key for the detached field to destroy.\n\t * @param count - The number of nodes being destroyed.\n\t * Expected to match the number of nodes in the detached field being destroyed.\n\t */\n\tdestroy(detachedField: FieldKey, count: number): void;\n\t/**\n\t * Transfers all the nodes from a detached field to the current field.\n\t * @param source - The detached field to transfer the nodes from.\n\t * @param count - The number of nodes being attached.\n\t * Expected to match the number of nodes in the source detached field.\n\t * @param destination - The index at which to attach the nodes.\n\t */\n\tattach(source: FieldKey, count: number, destination: PlaceIndex): void;\n\t/**\n\t * Transfers a range of nodes from the current field to a new detached field.\n\t * @param source - The bounds of the range of nodes to detach.\n\t * @param destination - The key for a new detached field.\n\t * A field with this key must not already exist.\n\t * @param id - The ID assigned to the first detached node as a result of the detach. The other nodes in the detached range are assigned subsequent IDs.\n\t * @param isReplaced - Whether the detached content will be replaced by a later attach.\n\t * This is not guaranteed to be true in all cases where it could be true,\n\t * but it is guaranteed to be true in all cases where a later attach is needed to keep the data compliant with the schema.\n\t */\n\tdetach(\n\t\tsource: Range,\n\t\tdestination: FieldKey,\n\t\tid: Delta.DetachedNodeId,\n\t\tisReplaced: boolean,\n\t): void;\n\n\t/**\n\t * Tells the visitor that it should update its \"current location\" to be the Node at the specified index\n\t * within the Field that is the current \"current location\".\n\t * Future calls to methods of {@link DeltaVisitor} will assume that's the location where their effects are happening.\n\t * @param index - The index (within the Field) of the node that should become the new \"current location\".\n\t *\n\t * @remarks This should only be called when the \"current location\" is a Field.\n\t */\n\tenterNode(index: NodeIndex): void;\n\n\t/**\n\t * Tells the visitor that it should update its \"current location\" to be the Field which contains the Node\n\t * that is the current \"current location\".\n\t * Future calls to methods of {@link DeltaVisitor} will assume that's the location where their effects are happening.\n\t * @param index - The index (within its Field) of the node that is being exited.\n\t *\n\t * @remarks This should only be called when the \"current location\" is a Node.\n\t */\n\texitNode(index: NodeIndex): void;\n\n\t/**\n\t * Tells the visitor that it should update its \"current location\" to be the Field with the specified key,\n\t * within the Node that is the current \"current location\".\n\t * Future calls to methods of {@link DeltaVisitor} will assume that's the location where their effects are happening.\n\t * @param key - The key of the field that should become the new \"current location\".\n\t *\n\t * @remarks This should only be called when the \"current location\" is a Node.\n\t */\n\tenterField(key: FieldKey): void;\n\n\t/**\n\t * Tells the visitor that it should update its \"current location\" to be the Node which contains the Field\n\t * that is the current \"current location\".\n\t * Future calls to methods of {@link DeltaVisitor} will assume that's the location where their effects are happening.\n\t * @param key - The key of the field that is being exited.\n\t *\n\t * @remarks This should only be called when the \"current location\" is a Field.\n\t */\n\texitField(key: FieldKey): void;\n}\n\ninterface PassConfig {\n\treadonly func: Pass;\n\n\t/**\n\t * The latest revision tag associated with the given delta. This is used to keep track\n\t * of when repair data should be garbage collected.\n\t */\n\treadonly latestRevision: RevisionTag | undefined;\n\n\treadonly detachedFieldIndex: DetachedFieldIndex;\n\t/**\n\t * A mapping between forest root id and trees that represent refresher data. Each entry is only\n\t * created in the forest once needed.\n\t */\n\treadonly refreshers: NestedMap<Major, Minor, ITreeCursorSynchronous>;\n\t/**\n\t * Nested changes on roots that need to be visited as part of the detach pass.\n\t * Each entry is removed when its associated changes are visited.\n\t */\n\treadonly detachPassRoots: Map<ForestRootId, Delta.FieldMap>;\n\t/**\n\t * Nested changes on roots that need to be visited as part of the attach pass.\n\t * Each entry is removed when its associated changes are visited.\n\t * Some of these roots will attached during the attach pass, in which case the nested changes are visited after\n\t * the node is attached.\n\t * Some of these nodes will never be attached, in which case we visit them in their detached fields at the end of\n\t * the attach pass. Note that such a visit might lead to more nodes being attached, including nodes were visited as\n\t * roots.\n\t */\n\treadonly attachPassRoots: Map<ForestRootId, Delta.FieldMap>;\n\t/**\n\t * Represents transfers of roots from one detached field to another.\n\t */\n\treadonly rootTransfers: Delta.DetachedNodeRename[];\n\t/**\n\t * Represents roots that need to be destroyed.\n\t * Collected as part of the detach pass.\n\t * Carried out at the end of the attach pass.\n\t */\n\treadonly rootDestructions: Delta.DetachedNodeDestruction[];\n}\n\ntype Pass = (delta: Delta.FieldChanges, visitor: DeltaVisitor, config: PassConfig) => void;\n\nfunction visitFieldMarks(\n\tfields: Delta.FieldMap | undefined,\n\tvisitor: DeltaVisitor,\n\tconfig: PassConfig,\n): void {\n\tif (fields !== undefined) {\n\t\tfor (const [key, field] of fields) {\n\t\t\tvisitor.enterField(key);\n\t\t\tconfig.func(field, visitor, config);\n\t\t\tvisitor.exitField(key);\n\t\t}\n\t}\n}\n\nfunction visitNode(\n\tindex: number,\n\tfields: Delta.FieldMap | undefined,\n\tvisitor: DeltaVisitor,\n\tconfig: PassConfig,\n): void {\n\tif (fields !== undefined) {\n\t\tvisitor.enterNode(index);\n\t\tvisitFieldMarks(fields, visitor, config);\n\t\tvisitor.exitNode(index);\n\t}\n}\n\n/**\n * Performs the following:\n * - Collects all roots that may need an attach pass\n * - Executes detaches (bottom-up)\n */\nfunction detachPass(\n\tfieldChanges: Delta.FieldChanges,\n\tvisitor: DeltaVisitor,\n\tconfig: PassConfig,\n): void {\n\tlet index = 0;\n\tfor (const mark of fieldChanges.marks) {\n\t\tif (mark.fields !== undefined) {\n\t\t\tassert(\n\t\t\t\tmark.attach === undefined || mark.detach !== undefined,\n\t\t\t\t0x7d0 /* Invalid nested changes on an additive mark */,\n\t\t\t);\n\t\t\tvisitNode(index, mark.fields, visitor, config);\n\t\t}\n\t\tif (mark.detach !== undefined) {\n\t\t\tfor (let i = 0; i < mark.count; i += 1) {\n\t\t\t\tconst id = offsetDetachId(mark.detach, i);\n\t\t\t\tconst root = config.detachedFieldIndex.createEntry(\n\t\t\t\t\tid,\n\t\t\t\t\tconfig.latestRevision,\n\t\t\t\t\tfieldChanges.allowReattach,\n\t\t\t\t);\n\t\t\t\tif (mark.fields !== undefined) {\n\t\t\t\t\tconfig.attachPassRoots.set(root, mark.fields);\n\t\t\t\t}\n\t\t\t\tconst field = config.detachedFieldIndex.toFieldKey(root);\n\t\t\t\tvisitor.detach({ start: index, end: index + 1 }, field, id, mark.attach !== undefined);\n\t\t\t}\n\t\t}\n\t\tif (mark.detach === undefined && mark.attach === undefined) {\n\t\t\tindex += mark.count;\n\t\t}\n\t}\n}\n\nfunction buildTrees(\n\tid: Delta.DetachedNodeId,\n\ttrees: readonly ITreeCursorSynchronous[],\n\tdetachedFieldIndex: DetachedFieldIndex,\n\tlatestRevision: RevisionTag | undefined,\n\tisAttachable: boolean,\n\tvisitor: DeltaVisitor,\n): void {\n\tfor (const [i, tree] of trees.entries()) {\n\t\tconst offsettedId = offsetDetachId(id, i);\n\t\tlet root = detachedFieldIndex.tryGetEntry(offsettedId);\n\t\tassert(root === undefined, 0x929 /* Unable to build tree that already exists */);\n\t\troot = detachedFieldIndex.createEntry(offsettedId, latestRevision, isAttachable);\n\t\tconst field = detachedFieldIndex.toFieldKey(root);\n\t\tvisitor.create([tree], field);\n\t}\n}\n\nfunction processBuilds(\n\tbuilds: readonly Delta.DetachedNodeBuild[] | undefined,\n\tconfig: PassConfig,\n\tvisitor: DeltaVisitor,\n): void {\n\tif (builds !== undefined) {\n\t\tfor (const { id, trees } of builds) {\n\t\t\tbuildTrees(\n\t\t\t\tid,\n\t\t\t\tnodeCursorsFromChunk(trees),\n\t\t\t\tconfig.detachedFieldIndex,\n\t\t\t\tconfig.latestRevision,\n\t\t\t\ttrue,\n\t\t\t\tvisitor,\n\t\t\t);\n\t\t}\n\t}\n}\n\nfunction processGlobal(\n\tglobal: readonly Delta.DetachedNodeChanges[] | undefined,\n\tconfig: PassConfig,\n\tvisitor: DeltaVisitor,\n): void {\n\tif (global !== undefined) {\n\t\tfor (const { id, fields } of global) {\n\t\t\tlet root = config.detachedFieldIndex.tryGetEntry(id);\n\t\t\tif (root === undefined) {\n\t\t\t\tconst tree = tryGetFromNestedMap(config.refreshers, id.major, id.minor);\n\t\t\t\tassert(tree !== undefined, 0x928 /* refresher data not found */);\n\t\t\t\tbuildTrees(\n\t\t\t\t\tid,\n\t\t\t\t\t[tree],\n\t\t\t\t\tconfig.detachedFieldIndex,\n\t\t\t\t\tconfig.latestRevision,\n\t\t\t\t\tfalse,\n\t\t\t\t\tvisitor,\n\t\t\t\t);\n\t\t\t\troot = config.detachedFieldIndex.getEntry(id);\n\t\t\t}\n\t\t\t// the revision is updated for any refresher data included in the delta that is used\n\t\t\tconfig.detachedFieldIndex.updateLatestRevision(id, config.latestRevision);\n\t\t\tconfig.detachPassRoots.set(root, fields);\n\t\t\tconfig.attachPassRoots.set(root, fields);\n\t\t}\n\t}\n}\n\nfunction processRename(\n\trename: readonly Delta.DetachedNodeRename[] | undefined,\n\tconfig: PassConfig,\n): void {\n\tif (rename !== undefined) {\n\t\tconfig.rootTransfers.push(...rename);\n\t}\n}\n\nfunction collectDestroys(\n\tdestroys: readonly Delta.DetachedNodeDestruction[] | undefined,\n\tconfig: PassConfig,\n): void {\n\tif (destroys !== undefined) {\n\t\tconfig.rootDestructions.push(...destroys);\n\t}\n}\n\n/**\n * Preforms the following:\n * - Executes attaches (top-down) applying nested changes on the attached nodes\n */\nfunction attachPass(\n\tfieldChanges: Delta.FieldChanges,\n\tvisitor: DeltaVisitor,\n\tconfig: PassConfig,\n): void {\n\tlet index = 0;\n\tfor (const mark of fieldChanges.marks) {\n\t\tif (mark.attach !== undefined) {\n\t\t\tfor (let i = 0; i < mark.count; i += 1) {\n\t\t\t\tconst offsetAttachId = offsetDetachId(mark.attach, i);\n\t\t\t\tlet sourceRoot = config.detachedFieldIndex.tryGetEntry(offsetAttachId);\n\t\t\t\tif (sourceRoot === undefined) {\n\t\t\t\t\tconst tree = tryGetFromNestedMap(\n\t\t\t\t\t\tconfig.refreshers,\n\t\t\t\t\t\toffsetAttachId.major,\n\t\t\t\t\t\toffsetAttachId.minor,\n\t\t\t\t\t);\n\t\t\t\t\tassert(tree !== undefined, 0x92a /* refresher data not found */);\n\t\t\t\t\tbuildTrees(\n\t\t\t\t\t\toffsetAttachId,\n\t\t\t\t\t\t[tree],\n\t\t\t\t\t\tconfig.detachedFieldIndex,\n\t\t\t\t\t\tconfig.latestRevision,\n\t\t\t\t\t\tfalse,\n\t\t\t\t\t\tvisitor,\n\t\t\t\t\t);\n\t\t\t\t\tsourceRoot = config.detachedFieldIndex.getEntry(offsetAttachId);\n\t\t\t\t}\n\t\t\t\tconst sourceField = config.detachedFieldIndex.toFieldKey(sourceRoot);\n\t\t\t\tconst offsetIndex = index + i;\n\t\t\t\tvisitor.attach(sourceField, 1, offsetIndex);\n\t\t\t\tconfig.detachedFieldIndex.deleteEntry(offsetAttachId);\n\t\t\t\tconst fields = config.attachPassRoots.get(sourceRoot);\n\t\t\t\tif (fields !== undefined) {\n\t\t\t\t\tconfig.attachPassRoots.delete(sourceRoot);\n\t\t\t\t\tvisitNode(offsetIndex, fields, visitor, config);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif (mark.detach === undefined && mark.fields !== undefined) {\n\t\t\tvisitNode(index, mark.fields, visitor, config);\n\t\t}\n\t\tif (mark.detach === undefined || mark.attach !== undefined) {\n\t\t\tindex += mark.count;\n\t\t}\n\t}\n}\n\n/**\n * Converts a chunk of trees into an array of cursors.\n *\n * TODO: Update the visitDelta logic and downstream APIs to avoid splitting up sequences into individual nodes.\n */\nfunction nodeCursorsFromChunk(trees: TreeChunk): ITreeCursorSynchronous[] {\n\treturn mapCursorField(trees.cursor(), (c) => c.fork());\n}\n"]}
1
+ {"version":3,"file":"visitDelta.js","sourceRoot":"","sources":["../../../src/core/tree/visitDelta.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAE7D,OAAO,EAAkB,cAAc,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAK1F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AAC,MAAM,CAAC,WAAW,EAAE,CAAC,EAAE,WAAW,CAAC,CAAC;gBAC5C,MAAM,CAAC,kBAAkB,CAAC,WAAW,CAAC,cAAc,CAAC,CAAC;gBACtD,MAAM,MAAM,GAAG,MAAM,CAAC,eAAe,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;gBACtD,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;oBAC1B,MAAM,CAAC,eAAe,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;oBAC1C,SAAS,CAAC,WAAW,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;gBACjD,CAAC;YACF,CAAC;QACF,CAAC;QACD,IAAI,IAAI,CAAC,MAAM,KAAK,SAAS,IAAI,IAAI,CAAC,MAAM,KAAK,SAAS,EAAE,CAAC;YAC5D,SAAS,CAAC,KAAK,EAAE,IAAI,CAAC,MAAM,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;QAChD,CAAC;QACD,IAAI,IAAI,CAAC,MAAM,KAAK,SAAS,IAAI,IAAI,CAAC,MAAM,KAAK,SAAS,EAAE,CAAC;YAC5D,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC;QACrB,CAAC;IACF,CAAC;AACF,CAAC;AAED;;;;GAIG;AACH,SAAS,oBAAoB,CAAC,KAAgB;IAC7C,OAAO,cAAc,CAAC,KAAK,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;AACxD,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\n\nimport { type NestedMap, setInNestedMap, tryGetFromNestedMap } from \"../../util/index.js\";\nimport type { RevisionTag } from \"../rebase/index.js\";\nimport type { FieldKey } from \"../schema-stored/index.js\";\n\nimport type { TreeChunk } from \"./chunk.js\";\nimport { mapCursorField, type ITreeCursorSynchronous } from \"./cursor.js\";\nimport type * as Delta from \"./delta.js\";\nimport { areDetachedNodeIdsEqual, offsetDetachId } from \"./deltaUtil.js\";\nimport type { DetachedFieldIndex } from \"./detachedFieldIndex.js\";\nimport type { ForestRootId, Major, Minor } from \"./detachedFieldIndexTypes.js\";\nimport type { NodeIndex, PlaceIndex, Range } from \"./pathTree.js\";\n\n/**\n * Implementation notes:\n *\n * The visit is organized into four phases:\n * 1. a detach pass\n * 2. root transfers\n * 3. an attach pass\n * 4. root destructions\n *\n * The core idea is that before content can be attached, it must first exist and be in a detached field.\n *\n * While the detach pass ensures that nodes to be attached are in a detached state, it does not guarantee that they\n * reside in the correct detached field. That is the responsibility of the root transfers phase.\n *\n * The attach phase carries out attaches.\n *\n * After the attach phase, roots destruction is carried out.\n * This needs to happen last to allow modifications to detached roots to be applied before they are destroyed.\n *\n * The details of the delta visit algorithm can impact how/when events are emitted by the objects that own the visitors.\n * For example, as of 2024-03-27, the subtreeChanged event of an AnchorNode is emitted when exiting a node during a\n * delta visit, and thus the two-pass nature of the algorithm means the event fires twice for any given change.\n */\n\n/**\n * Crawls the given `delta`, calling `visitor`'s callback for each change encountered.\n * Each successive call to the visitor callbacks assumes that the change described by earlier calls have been applied\n * to the document tree. For example, for a change that removes the first and third node of a field, the visitor calls\n * will first call detach with a range from indices 0 to 1 then call detach with a range from indices 1 to 2.\n *\n * @param delta - The delta to be crawled.\n * @param visitor - The object to notify of the changes encountered.\n * @param detachedFieldIndex - Index responsible for keeping track of the existing detached fields.\n * @param latestRevision - The latest revision tag associated with this delta.\n */\nexport function visitDelta(\n\tdelta: Delta.Root,\n\tvisitor: DeltaVisitor,\n\tdetachedFieldIndex: DetachedFieldIndex,\n\tlatestRevision: RevisionTag | undefined,\n): void {\n\tconst detachPassRoots: Map<ForestRootId, Delta.FieldMap> = new Map();\n\tconst attachPassRoots: Map<ForestRootId, Delta.FieldMap> = new Map();\n\tconst rootTransfers: Delta.DetachedNodeRename[] = [];\n\tconst rootDestructions: Delta.DetachedNodeDestruction[] = [];\n\tconst refreshers: NestedMap<Major, Minor, ITreeCursorSynchronous> = new Map();\n\tfor (const {\n\t\tid: { major, minor },\n\t\ttrees,\n\t} of delta.refreshers ?? []) {\n\t\tconst treeCursors = nodeCursorsFromChunk(trees);\n\t\tfor (let i = 0; i < trees.topLevelLength; i += 1) {\n\t\t\tconst offsettedId = minor + i;\n\t\t\tsetInNestedMap(refreshers, major, offsettedId, treeCursors[i]);\n\t\t}\n\t}\n\tconst detachConfig: PassConfig = {\n\t\tfunc: detachPass,\n\t\tlatestRevision,\n\t\trefreshers,\n\t\tdetachedFieldIndex,\n\t\tdetachPassRoots,\n\t\tattachPassRoots,\n\t\trootTransfers,\n\t\trootDestructions,\n\t};\n\tprocessBuilds(delta.build, detachConfig, visitor);\n\tprocessGlobal(delta.global, detachConfig, visitor);\n\tprocessRename(delta.rename, detachConfig);\n\tvisitFieldMarks(delta.fields, visitor, detachConfig);\n\tfixedPointVisitOfRoots(visitor, detachPassRoots, detachConfig);\n\ttransferRoots(\n\t\trootTransfers,\n\t\tattachPassRoots,\n\t\tdetachedFieldIndex,\n\t\tvisitor,\n\t\trefreshers,\n\t\tlatestRevision,\n\t);\n\tconst attachConfig: PassConfig = {\n\t\tfunc: attachPass,\n\t\tlatestRevision,\n\t\trefreshers,\n\t\tdetachedFieldIndex,\n\t\tdetachPassRoots,\n\t\tattachPassRoots,\n\t\trootTransfers,\n\t\trootDestructions,\n\t};\n\tvisitFieldMarks(delta.fields, visitor, attachConfig);\n\tfixedPointVisitOfRoots(visitor, attachPassRoots, attachConfig);\n\tcollectDestroys(delta.destroy, attachConfig);\n\tfor (const { id, count } of rootDestructions) {\n\t\tfor (let i = 0; i < count; i += 1) {\n\t\t\tconst offsetId = offsetDetachId(id, i);\n\t\t\tconst root = detachedFieldIndex.getEntry(offsetId);\n\t\t\tconst field = detachedFieldIndex.toFieldKey(root);\n\t\t\tvisitor.destroy(field, 1);\n\t\t\tdetachedFieldIndex.deleteEntry(offsetId);\n\t\t}\n\t}\n}\n\n/**\n * Visits all nodes in `roots` until none are left.\n * This function tolerates entries being added to and removed from `roots` as part of visits.\n * @param visitor - The visitor to visit the roots with.\n * @param roots - The initial set of roots to visit.\n * Individual entries are removed prior to being visited.\n * @param config - The configuration to use for visits.\n */\nfunction fixedPointVisitOfRoots(\n\tvisitor: DeltaVisitor,\n\troots: Map<ForestRootId, Delta.FieldMap>,\n\tconfig: PassConfig,\n): void {\n\twhile (roots.size > 0) {\n\t\tfor (const [root, modifications] of roots) {\n\t\t\troots.delete(root);\n\t\t\tconst field = config.detachedFieldIndex.toFieldKey(root);\n\t\t\tvisitor.enterField(field);\n\t\t\t// Note: each visit may lead to `roots` being populated with new entries or having some entries removed.\n\t\t\tvisitNode(0, modifications, visitor, config);\n\t\t\tvisitor.exitField(field);\n\t\t}\n\t}\n}\n\n/**\n * Transfers roots from one detached field to another.\n * This occurs in the following circumstances:\n * - A changeset moves then removes a node\n * - A changeset restores then moves a node\n * - A changeset restores then removes a node\n * TODO#5481: update the DetachedFieldIndex instead of moving the nodes around.\n *\n * @param rootTransfers - The transfers to perform.\n * @param mapToUpdate - A map to update based on the transfers being performed.\n * @param detachedFieldIndex - The index to update based on the transfers being performed.\n * @param visitor - The visitor to inform of the transfers being performed.\n */\nfunction transferRoots(\n\trootTransfers: readonly Delta.DetachedNodeRename[],\n\tmapToUpdate: Map<ForestRootId, unknown>,\n\tdetachedFieldIndex: DetachedFieldIndex,\n\tvisitor: DeltaVisitor,\n\trefreshers: NestedMap<Major, Minor, ITreeCursorSynchronous>,\n\trevision?: RevisionTag,\n): void {\n\ttype AtomizedNodeRename = Omit<Delta.DetachedNodeRename, \"count\">;\n\tlet nextBatch = rootTransfers.flatMap(({ oldId, newId, count }) => {\n\t\tconst atomized: AtomizedNodeRename[] = [];\n\t\t// It's possible for a detached node to be revived transiently such that it ends up back in the same detached field.\n\t\t// Making such a transfer wouldn't just be inefficient, it would lead us to mistakenly think we have moved all content\n\t\t// out of the source detached field, and would lead us to delete the tree index entry for that source detached field.\n\t\t// This would effectively result in the tree index missing an entry for the detached field.\n\t\t// This if statement prevents that from happening.\n\t\tif (!areDetachedNodeIdsEqual(oldId, newId)) {\n\t\t\tfor (let i = 0; i < count; i += 1) {\n\t\t\t\tatomized.push({ oldId: offsetDetachId(oldId, i), newId: offsetDetachId(newId, i) });\n\t\t\t}\n\t\t}\n\t\treturn atomized;\n\t});\n\twhile (nextBatch.length > 0) {\n\t\tconst delayed: AtomizedNodeRename[] = [];\n\t\tconst priorSize = nextBatch.length;\n\t\tfor (const { oldId, newId } of nextBatch) {\n\t\t\tlet oldRootId = detachedFieldIndex.tryGetEntry(oldId);\n\t\t\tif (oldRootId === undefined) {\n\t\t\t\tconst tree = tryGetFromNestedMap(refreshers, oldId.major, oldId.minor);\n\t\t\t\tif (tree !== undefined) {\n\t\t\t\t\tbuildTrees(oldId, [tree], detachedFieldIndex, revision, visitor);\n\t\t\t\t\toldRootId = detachedFieldIndex.getEntry(oldId);\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (oldRootId === undefined) {\n\t\t\t\t// The source field is not populated.\n\t\t\t\t// This can happen when another rename needs to be performed first.\n\t\t\t\tdelayed.push({ oldId, newId });\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tlet newRootId = detachedFieldIndex.tryGetEntry(newId);\n\t\t\tif (newRootId !== undefined) {\n\t\t\t\t// The destination field is already occupied.\n\t\t\t\t// This can happen when another rename needs to be performed first.\n\t\t\t\tdelayed.push({ oldId, newId });\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\t// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions -- intentional behavior\n\t\t\tnewRootId = detachedFieldIndex.createEntry(newId, revision);\n\t\t\tconst fields = mapToUpdate.get(oldRootId);\n\t\t\tif (fields !== undefined) {\n\t\t\t\tmapToUpdate.delete(oldRootId);\n\t\t\t\tmapToUpdate.set(newRootId, fields);\n\t\t\t}\n\t\t\tconst oldField = detachedFieldIndex.toFieldKey(oldRootId);\n\t\t\tconst newField = detachedFieldIndex.toFieldKey(newRootId);\n\t\t\tvisitor.enterField(oldField);\n\t\t\tvisitor.detach({ start: 0, end: 1 }, newField, newId, false);\n\t\t\tvisitor.exitField(oldField);\n\t\t\tdetachedFieldIndex.deleteEntry(oldId);\n\t\t}\n\t\tassert(delayed.length < priorSize, 0x7cf /* transferRoots should make progress */);\n\t\tnextBatch = delayed;\n\t}\n}\n\n/**\n * Visitor for changes in a delta.\n * Must be freed after use.\n */\nexport interface DeltaVisitor {\n\t/**\n\t * Frees/releases the visitor.\n\t *\n\t * Must be called once the visitor finished traversing the delta for a couple of reasons:\n\t *\n\t * 1. Some visitors, such as those from forests, are put into a special mode while they have a visitor, forbidding some actions (like making more visitors).\n\t *\n\t * 2. Some visitors, such as those from an anchorSet, defer some events for batching purposes until the visitor is freed.\n\t */\n\tfree(): void;\n\t/**\n\t * Creates nodes for the given content in a new detached field.\n\t * @param content - The content to create.\n\t * @param destination - The key for a new detached field.\n\t * A field with this key must not already exist.\n\t */\n\tcreate(content: readonly ITreeCursorSynchronous[], destination: FieldKey): void;\n\t/**\n\t * Recursively destroys the given detached field and all of the nodes within it.\n\t * @param detachedField - The key for the detached field to destroy.\n\t * @param count - The number of nodes being destroyed.\n\t * Expected to match the number of nodes in the detached field being destroyed.\n\t */\n\tdestroy(detachedField: FieldKey, count: number): void;\n\t/**\n\t * Transfers all the nodes from a detached field to the current field.\n\t * @param source - The detached field to transfer the nodes from.\n\t * @param count - The number of nodes being attached.\n\t * Expected to match the number of nodes in the source detached field.\n\t * @param destination - The index at which to attach the nodes.\n\t */\n\tattach(source: FieldKey, count: number, destination: PlaceIndex): void;\n\t/**\n\t * Transfers a range of nodes from the current field to a new detached field.\n\t * @param source - The bounds of the range of nodes to detach.\n\t * @param destination - The key for a new detached field.\n\t * A field with this key must not already exist.\n\t * @param id - The ID assigned to the first detached node as a result of the detach. The other nodes in the detached range are assigned subsequent IDs.\n\t * @param isReplaced - Whether the detached content will be replaced by a later attach.\n\t * This is not guaranteed to be true in all cases where it could be true,\n\t * but it is guaranteed to be true in all cases where a later attach is needed to keep the data compliant with the schema.\n\t */\n\tdetach(\n\t\tsource: Range,\n\t\tdestination: FieldKey,\n\t\tid: Delta.DetachedNodeId,\n\t\tisReplaced: boolean,\n\t): void;\n\n\t/**\n\t * Tells the visitor that it should update its \"current location\" to be the Node at the specified index\n\t * within the Field that is the current \"current location\".\n\t * Future calls to methods of {@link DeltaVisitor} will assume that's the location where their effects are happening.\n\t * @param index - The index (within the Field) of the node that should become the new \"current location\".\n\t *\n\t * @remarks This should only be called when the \"current location\" is a Field.\n\t */\n\tenterNode(index: NodeIndex): void;\n\n\t/**\n\t * Tells the visitor that it should update its \"current location\" to be the Field which contains the Node\n\t * that is the current \"current location\".\n\t * Future calls to methods of {@link DeltaVisitor} will assume that's the location where their effects are happening.\n\t * @param index - The index (within its Field) of the node that is being exited.\n\t *\n\t * @remarks This should only be called when the \"current location\" is a Node.\n\t */\n\texitNode(index: NodeIndex): void;\n\n\t/**\n\t * Tells the visitor that it should update its \"current location\" to be the Field with the specified key,\n\t * within the Node that is the current \"current location\".\n\t * Future calls to methods of {@link DeltaVisitor} will assume that's the location where their effects are happening.\n\t * @param key - The key of the field that should become the new \"current location\".\n\t *\n\t * @remarks This should only be called when the \"current location\" is a Node.\n\t */\n\tenterField(key: FieldKey): void;\n\n\t/**\n\t * Tells the visitor that it should update its \"current location\" to be the Node which contains the Field\n\t * that is the current \"current location\".\n\t * Future calls to methods of {@link DeltaVisitor} will assume that's the location where their effects are happening.\n\t * @param key - The key of the field that is being exited.\n\t *\n\t * @remarks This should only be called when the \"current location\" is a Field.\n\t */\n\texitField(key: FieldKey): void;\n}\n\ninterface PassConfig {\n\treadonly func: Pass;\n\n\t/**\n\t * The latest revision tag associated with the given delta. This is used to keep track\n\t * of when repair data should be garbage collected.\n\t */\n\treadonly latestRevision: RevisionTag | undefined;\n\n\treadonly detachedFieldIndex: DetachedFieldIndex;\n\t/**\n\t * A mapping between forest root id and trees that represent refresher data. Each entry is only\n\t * created in the forest once needed.\n\t */\n\treadonly refreshers: NestedMap<Major, Minor, ITreeCursorSynchronous>;\n\t/**\n\t * Nested changes on roots that need to be visited as part of the detach pass.\n\t * Each entry is removed when its associated changes are visited.\n\t */\n\treadonly detachPassRoots: Map<ForestRootId, Delta.FieldMap>;\n\t/**\n\t * Nested changes on roots that need to be visited as part of the attach pass.\n\t * Each entry is removed when its associated changes are visited.\n\t * Some of these roots will attached during the attach pass, in which case the nested changes are visited after\n\t * the node is attached.\n\t * Some of these nodes will never be attached, in which case we visit them in their detached fields at the end of\n\t * the attach pass. Note that such a visit might lead to more nodes being attached, including nodes were visited as\n\t * roots.\n\t */\n\treadonly attachPassRoots: Map<ForestRootId, Delta.FieldMap>;\n\t/**\n\t * Represents transfers of roots from one detached field to another.\n\t */\n\treadonly rootTransfers: Delta.DetachedNodeRename[];\n\t/**\n\t * Represents roots that need to be destroyed.\n\t * Collected as part of the detach pass.\n\t * Carried out at the end of the attach pass.\n\t */\n\treadonly rootDestructions: Delta.DetachedNodeDestruction[];\n}\n\ntype Pass = (delta: Delta.FieldChanges, visitor: DeltaVisitor, config: PassConfig) => void;\n\nfunction visitFieldMarks(\n\tfields: Delta.FieldMap | undefined,\n\tvisitor: DeltaVisitor,\n\tconfig: PassConfig,\n): void {\n\tif (fields !== undefined) {\n\t\tfor (const [key, field] of fields) {\n\t\t\tvisitor.enterField(key);\n\t\t\tconfig.func(field, visitor, config);\n\t\t\tvisitor.exitField(key);\n\t\t}\n\t}\n}\n\nfunction visitNode(\n\tindex: number,\n\tfields: Delta.FieldMap | undefined,\n\tvisitor: DeltaVisitor,\n\tconfig: PassConfig,\n): void {\n\tif (fields !== undefined) {\n\t\tvisitor.enterNode(index);\n\t\tvisitFieldMarks(fields, visitor, config);\n\t\tvisitor.exitNode(index);\n\t}\n}\n\n/**\n * Performs the following:\n * - Collects all roots that may need an attach pass\n * - Executes detaches (bottom-up)\n */\nfunction detachPass(\n\tfieldChanges: Delta.FieldChanges,\n\tvisitor: DeltaVisitor,\n\tconfig: PassConfig,\n): void {\n\tlet index = 0;\n\tfor (const mark of fieldChanges.marks) {\n\t\tif (mark.fields !== undefined) {\n\t\t\tassert(\n\t\t\t\tmark.attach === undefined || mark.detach !== undefined,\n\t\t\t\t0x7d0 /* Invalid nested changes on an additive mark */,\n\t\t\t);\n\t\t\tvisitNode(index, mark.fields, visitor, config);\n\t\t}\n\t\tif (mark.detach !== undefined) {\n\t\t\tfor (let i = 0; i < mark.count; i += 1) {\n\t\t\t\tconst id = offsetDetachId(mark.detach, i);\n\t\t\t\tconst root = config.detachedFieldIndex.createEntry(id, config.latestRevision);\n\t\t\t\tif (mark.fields !== undefined) {\n\t\t\t\t\tconfig.attachPassRoots.set(root, mark.fields);\n\t\t\t\t}\n\t\t\t\tconst field = config.detachedFieldIndex.toFieldKey(root);\n\t\t\t\tvisitor.detach({ start: index, end: index + 1 }, field, id, mark.attach !== undefined);\n\t\t\t}\n\t\t}\n\t\tif (mark.detach === undefined && mark.attach === undefined) {\n\t\t\tindex += mark.count;\n\t\t}\n\t}\n}\n\nfunction buildTrees(\n\tid: Delta.DetachedNodeId,\n\ttrees: readonly ITreeCursorSynchronous[],\n\tdetachedFieldIndex: DetachedFieldIndex,\n\tlatestRevision: RevisionTag | undefined,\n\tvisitor: DeltaVisitor,\n): void {\n\tfor (const [i, tree] of trees.entries()) {\n\t\tconst offsettedId = offsetDetachId(id, i);\n\t\tlet root = detachedFieldIndex.tryGetEntry(offsettedId);\n\t\tassert(root === undefined, 0x929 /* Unable to build tree that already exists */);\n\t\troot = detachedFieldIndex.createEntry(offsettedId, latestRevision);\n\t\tconst field = detachedFieldIndex.toFieldKey(root);\n\t\tvisitor.create([tree], field);\n\t}\n}\n\nfunction processBuilds(\n\tbuilds: readonly Delta.DetachedNodeBuild[] | undefined,\n\tconfig: PassConfig,\n\tvisitor: DeltaVisitor,\n): void {\n\tif (builds !== undefined) {\n\t\tfor (const { id, trees } of builds) {\n\t\t\tbuildTrees(\n\t\t\t\tid,\n\t\t\t\tnodeCursorsFromChunk(trees),\n\t\t\t\tconfig.detachedFieldIndex,\n\t\t\t\tconfig.latestRevision,\n\t\t\t\tvisitor,\n\t\t\t);\n\t\t}\n\t}\n}\n\nfunction processGlobal(\n\tglobal: readonly Delta.DetachedNodeChanges[] | undefined,\n\tconfig: PassConfig,\n\tvisitor: DeltaVisitor,\n): void {\n\tif (global !== undefined) {\n\t\tfor (const { id, fields } of global) {\n\t\t\tlet root = config.detachedFieldIndex.tryGetEntry(id);\n\t\t\tif (root === undefined) {\n\t\t\t\tconst tree = tryGetFromNestedMap(config.refreshers, id.major, id.minor);\n\t\t\t\tassert(tree !== undefined, 0x928 /* refresher data not found */);\n\t\t\t\tbuildTrees(id, [tree], config.detachedFieldIndex, config.latestRevision, visitor);\n\t\t\t\troot = config.detachedFieldIndex.getEntry(id);\n\t\t\t}\n\t\t\t// the revision is updated for any refresher data included in the delta that is used\n\t\t\tconfig.detachedFieldIndex.updateLatestRevision(id, config.latestRevision);\n\t\t\tconfig.detachPassRoots.set(root, fields);\n\t\t\tconfig.attachPassRoots.set(root, fields);\n\t\t}\n\t}\n}\n\nfunction processRename(\n\trename: readonly Delta.DetachedNodeRename[] | undefined,\n\tconfig: PassConfig,\n): void {\n\tif (rename !== undefined) {\n\t\tconfig.rootTransfers.push(...rename);\n\t}\n}\n\nfunction collectDestroys(\n\tdestroys: readonly Delta.DetachedNodeDestruction[] | undefined,\n\tconfig: PassConfig,\n): void {\n\tif (destroys !== undefined) {\n\t\tconfig.rootDestructions.push(...destroys);\n\t}\n}\n\n/**\n * Preforms the following:\n * - Executes attaches (top-down) applying nested changes on the attached nodes\n */\nfunction attachPass(\n\tfieldChanges: Delta.FieldChanges,\n\tvisitor: DeltaVisitor,\n\tconfig: PassConfig,\n): void {\n\tlet index = 0;\n\tfor (const mark of fieldChanges.marks) {\n\t\tif (mark.attach !== undefined) {\n\t\t\tfor (let i = 0; i < mark.count; i += 1) {\n\t\t\t\tconst offsetAttachId = offsetDetachId(mark.attach, i);\n\t\t\t\tlet sourceRoot = config.detachedFieldIndex.tryGetEntry(offsetAttachId);\n\t\t\t\tif (sourceRoot === undefined) {\n\t\t\t\t\tconst tree = tryGetFromNestedMap(\n\t\t\t\t\t\tconfig.refreshers,\n\t\t\t\t\t\toffsetAttachId.major,\n\t\t\t\t\t\toffsetAttachId.minor,\n\t\t\t\t\t);\n\t\t\t\t\tassert(tree !== undefined, 0x92a /* refresher data not found */);\n\t\t\t\t\tbuildTrees(\n\t\t\t\t\t\toffsetAttachId,\n\t\t\t\t\t\t[tree],\n\t\t\t\t\t\tconfig.detachedFieldIndex,\n\t\t\t\t\t\tconfig.latestRevision,\n\t\t\t\t\t\tvisitor,\n\t\t\t\t\t);\n\t\t\t\t\tsourceRoot = config.detachedFieldIndex.getEntry(offsetAttachId);\n\t\t\t\t}\n\t\t\t\tconst sourceField = config.detachedFieldIndex.toFieldKey(sourceRoot);\n\t\t\t\tconst offsetIndex = index + i;\n\t\t\t\tvisitor.attach(sourceField, 1, offsetIndex);\n\t\t\t\tconfig.detachedFieldIndex.deleteEntry(offsetAttachId);\n\t\t\t\tconst fields = config.attachPassRoots.get(sourceRoot);\n\t\t\t\tif (fields !== undefined) {\n\t\t\t\t\tconfig.attachPassRoots.delete(sourceRoot);\n\t\t\t\t\tvisitNode(offsetIndex, fields, visitor, config);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif (mark.detach === undefined && mark.fields !== undefined) {\n\t\t\tvisitNode(index, mark.fields, visitor, config);\n\t\t}\n\t\tif (mark.detach === undefined || mark.attach !== undefined) {\n\t\t\tindex += mark.count;\n\t\t}\n\t}\n}\n\n/**\n * Converts a chunk of trees into an array of cursors.\n *\n * TODO: Update the visitDelta logic and downstream APIs to avoid splitting up sequences into individual nodes.\n */\nfunction nodeCursorsFromChunk(trees: TreeChunk): ITreeCursorSynchronous[] {\n\treturn mapCursorField(trees.cursor(), (c) => c.fork());\n}\n"]}
@@ -3,7 +3,7 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
  import { type ChangeAtomId, type ChangesetLocalId, type RevisionTag } from "../core/index.js";
6
- import { type RangeQueryResult, type TupleBTree } from "../util/index.js";
6
+ import { type TupleBTree } from "../util/index.js";
7
7
  /**
8
8
  * A BTree which uses ChangeAtomId flattened into a tuple as the key.
9
9
  * @remarks
@@ -13,6 +13,5 @@ export type ChangeAtomIdBTree<V> = TupleBTree<readonly [RevisionTag | undefined,
13
13
  /** Creates a new {@link ChangeAtomIdBTree} */
14
14
  export declare function newChangeAtomIdBTree<V>(entries?: [readonly [RevisionTag | undefined, ChangesetLocalId], V][]): ChangeAtomIdBTree<V>;
15
15
  export declare function getFromChangeAtomIdMap<T>(map: ChangeAtomIdBTree<T>, id: ChangeAtomId): T | undefined;
16
- export declare function setInChangeAtomIdMap<T>(map: ChangeAtomIdBTree<T>, id: ChangeAtomId, value: T): boolean;
17
- export declare function rangeQueryChangeAtomIdMap<T>(map: ChangeAtomIdBTree<T>, id: ChangeAtomId, count: number): RangeQueryResult<T | undefined>;
16
+ export declare function setInChangeAtomIdMap<T>(map: ChangeAtomIdBTree<T>, id: ChangeAtomId, value: T): void;
18
17
  //# sourceMappingURL=changeAtomIdBTree.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"changeAtomIdBTree.d.ts","sourceRoot":"","sources":["../../src/feature-libraries/changeAtomIdBTree.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAIN,KAAK,YAAY,EACjB,KAAK,gBAAgB,EACrB,KAAK,WAAW,EAChB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAGN,KAAK,gBAAgB,EACrB,KAAK,UAAU,EACf,MAAM,kBAAkB,CAAC;AAE1B;;;;GAIG;AACH,MAAM,MAAM,iBAAiB,CAAC,CAAC,IAAI,UAAU,CAC5C,SAAS,CAAC,WAAW,GAAG,SAAS,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,EAAE,CAAC,CAAC,EAAE,GACnE,iBAAiB,CAAC,CAAC,CAAC,CAEtB;AAID,wBAAgB,sBAAsB,CAAC,CAAC,EACvC,GAAG,EAAE,iBAAiB,CAAC,CAAC,CAAC,EACzB,EAAE,EAAE,YAAY,GACd,CAAC,GAAG,SAAS,CAEf;AAED,wBAAgB,oBAAoB,CAAC,CAAC,EACrC,GAAG,EAAE,iBAAiB,CAAC,CAAC,CAAC,EACzB,EAAE,EAAE,YAAY,EAChB,KAAK,EAAE,CAAC,GACN,IAAI,CAEN"}
@@ -2,8 +2,8 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
- import { subtractChangeAtomIds, compareChangesetLocalIds, comparePartialRevisions, } from "../core/index.js";
6
- import { createTupleComparator, newTupleBTree, } from "../util/index.js";
5
+ import { compareChangesetLocalIds, comparePartialRevisions, } from "../core/index.js";
6
+ import { createTupleComparator, newTupleBTree } from "../util/index.js";
7
7
  /** Creates a new {@link ChangeAtomIdBTree} */
8
8
  export function newChangeAtomIdBTree(entries) {
9
9
  return newTupleBTree(compareKeys, entries);
@@ -13,18 +13,6 @@ export function getFromChangeAtomIdMap(map, id) {
13
13
  return map.get([id.revision, id.localId]);
14
14
  }
15
15
  export function setInChangeAtomIdMap(map, id, value) {
16
- return map.set([id.revision, id.localId], value);
17
- }
18
- export function rangeQueryChangeAtomIdMap(map, id, count) {
19
- const pair = map.getPairOrNextHigher([id.revision, id.localId]);
20
- if (pair === undefined) {
21
- return { value: undefined, length: count };
22
- }
23
- const [[revision, localId], value] = pair;
24
- const lengthBefore = subtractChangeAtomIds({ revision, localId }, id);
25
- if (lengthBefore === 0) {
26
- return { value, length: 1 };
27
- }
28
- return { value: undefined, length: Math.min(lengthBefore, count) };
16
+ map.set([id.revision, id.localId], value);
29
17
  }
30
18
  //# sourceMappingURL=changeAtomIdBTree.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"changeAtomIdBTree.js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,QAAQ,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC,CAAC;IACtE,IAAI,YAAY,KAAK,CAAC,EAAE,CAAC;QACxB,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC;IAC7B,CAAC;IAED,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,IAAI,CAAC,GAAG,CAAC,YAAY,EAAE,KAAK,CAAC,EAAE,CAAC;AACpE,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\tsubtractChangeAtomIds,\n\tcompareChangesetLocalIds,\n\tcomparePartialRevisions,\n\ttype ChangeAtomId,\n\ttype ChangesetLocalId,\n\ttype RevisionTag,\n} from \"../core/index.js\";\nimport {\n\tcreateTupleComparator,\n\tnewTupleBTree,\n\ttype RangeQueryResult,\n\ttype TupleBTree,\n} from \"../util/index.js\";\n\n/**\n * A BTree which uses ChangeAtomId flattened into a tuple as the key.\n * @remarks\n * Read values with {@link getFromChangeAtomIdMap} and write values with {@link setInChangeAtomIdMap}.\n */\nexport type ChangeAtomIdBTree<V> = TupleBTree<\n\treadonly [RevisionTag | undefined, ChangesetLocalId],\n\tV\n>;\n\n/** Creates a new {@link ChangeAtomIdBTree} */\nexport function newChangeAtomIdBTree<V>(\n\tentries?: [readonly [RevisionTag | undefined, ChangesetLocalId], V][],\n): ChangeAtomIdBTree<V> {\n\treturn newTupleBTree(compareKeys, entries);\n}\n\nconst compareKeys = createTupleComparator([comparePartialRevisions, compareChangesetLocalIds]);\n\nexport function getFromChangeAtomIdMap<T>(\n\tmap: ChangeAtomIdBTree<T>,\n\tid: ChangeAtomId,\n): T | undefined {\n\treturn map.get([id.revision, id.localId]);\n}\n\nexport function setInChangeAtomIdMap<T>(\n\tmap: ChangeAtomIdBTree<T>,\n\tid: ChangeAtomId,\n\tvalue: T,\n): boolean {\n\treturn map.set([id.revision, id.localId], value);\n}\n\nexport function rangeQueryChangeAtomIdMap<T>(\n\tmap: ChangeAtomIdBTree<T>,\n\tid: ChangeAtomId,\n\tcount: number,\n): RangeQueryResult<T | undefined> {\n\tconst pair = map.getPairOrNextHigher([id.revision, id.localId]);\n\tif (pair === undefined) {\n\t\treturn { value: undefined, length: count };\n\t}\n\n\tconst [[revision, localId], value] = pair;\n\tconst lengthBefore = subtractChangeAtomIds({ revision, localId }, id);\n\tif (lengthBefore === 0) {\n\t\treturn { value, length: 1 };\n\t}\n\n\treturn { value: undefined, length: Math.min(lengthBefore, count) };\n}\n"]}
1
+ {"version":3,"file":"changeAtomIdBTree.js","sourceRoot":"","sources":["../../src/feature-libraries/changeAtomIdBTree.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,wBAAwB,EACxB,uBAAuB,GAIvB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,qBAAqB,EAAE,aAAa,EAAmB,MAAM,kBAAkB,CAAC;AAYzF,8CAA8C;AAC9C,MAAM,UAAU,oBAAoB,CACnC,OAAqE;IAErE,OAAO,aAAa,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;AAC5C,CAAC;AAED,MAAM,WAAW,GAAG,qBAAqB,CAAC,CAAC,uBAAuB,EAAE,wBAAwB,CAAC,CAAC,CAAC;AAE/F,MAAM,UAAU,sBAAsB,CACrC,GAAyB,EACzB,EAAgB;IAEhB,OAAO,GAAG,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,QAAQ,EAAE,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC;AAC3C,CAAC;AAED,MAAM,UAAU,oBAAoB,CACnC,GAAyB,EACzB,EAAgB,EAChB,KAAQ;IAER,GAAG,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,QAAQ,EAAE,EAAE,CAAC,OAAO,CAAC,EAAE,KAAK,CAAC,CAAC;AAC3C,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\tcompareChangesetLocalIds,\n\tcomparePartialRevisions,\n\ttype ChangeAtomId,\n\ttype ChangesetLocalId,\n\ttype RevisionTag,\n} from \"../core/index.js\";\nimport { createTupleComparator, newTupleBTree, type TupleBTree } from \"../util/index.js\";\n\n/**\n * A BTree which uses ChangeAtomId flattened into a tuple as the key.\n * @remarks\n * Read values with {@link getFromChangeAtomIdMap} and write values with {@link setInChangeAtomIdMap}.\n */\nexport type ChangeAtomIdBTree<V> = TupleBTree<\n\treadonly [RevisionTag | undefined, ChangesetLocalId],\n\tV\n>;\n\n/** Creates a new {@link ChangeAtomIdBTree} */\nexport function newChangeAtomIdBTree<V>(\n\tentries?: [readonly [RevisionTag | undefined, ChangesetLocalId], V][],\n): ChangeAtomIdBTree<V> {\n\treturn newTupleBTree(compareKeys, entries);\n}\n\nconst compareKeys = createTupleComparator([comparePartialRevisions, compareChangesetLocalIds]);\n\nexport function getFromChangeAtomIdMap<T>(\n\tmap: ChangeAtomIdBTree<T>,\n\tid: ChangeAtomId,\n): T | undefined {\n\treturn map.get([id.revision, id.localId]);\n}\n\nexport function setInChangeAtomIdMap<T>(\n\tmap: ChangeAtomIdBTree<T>,\n\tid: ChangeAtomId,\n\tvalue: T,\n): void {\n\tmap.set([id.revision, id.localId], value);\n}\n"]}
@@ -3,13 +3,12 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
  import type { IIdCompressor, SessionId } from "@fluidframework/id-compressor";
6
- import type { MinimumVersionForCollab } from "@fluidframework/runtime-definitions/internal";
7
- import { type CodecTree, type CodecWriteOptions, type IJsonCodec } from "../../../codec/index.js";
6
+ import { ClientVersionDispatchingCodecBuilder } from "../../../codec/index.js";
8
7
  import { type ITreeCursorSynchronous, type SchemaAndPolicy, type TreeChunk } from "../../../core/index.js";
9
- import { type Brand, type JsonCompatibleReadOnly } from "../../../util/index.js";
8
+ import { type Brand } from "../../../util/index.js";
10
9
  import { TreeCompressionStrategy } from "../../treeCompressionUtils.js";
11
10
  import type { FieldBatch } from "./fieldBatch.js";
12
- import { EncodedFieldBatch } from "./format.js";
11
+ import { type EncodedFieldBatch } from "./format.js";
13
12
  import type { IncrementalEncodingPolicy } from "./incrementalEncodingPolicy.js";
14
13
  /**
15
14
  * Reference ID for a chunk that is incrementally encoded.
@@ -76,7 +75,9 @@ export interface FieldBatchEncodingContext {
76
75
  * @remarks
77
76
  * Fields in this batch currently don't have field schema for the root, which limits optimizations.
78
77
  */
79
- export type FieldBatchCodec = IJsonCodec<FieldBatch, EncodedFieldBatch, JsonCompatibleReadOnly, FieldBatchEncodingContext>;
80
- export declare function makeFieldBatchCodec(options: CodecWriteOptions): FieldBatchCodec;
81
- export declare function getCodecTreeForFieldBatchFormat(clientVersion: MinimumVersionForCollab): CodecTree;
78
+ export type FieldBatchCodec = ReturnType<typeof fieldBatchCodecBuilder.build>;
79
+ /**
80
+ * {@link ClientVersionDispatchingCodecBuilder} for field batch codecs.
81
+ */
82
+ export declare const fieldBatchCodecBuilder: ClientVersionDispatchingCodecBuilder<"FieldBatch", FieldBatch, FieldBatchEncodingContext, Brand<1, "FieldBatchFormatVersion"> | Brand<2, "FieldBatchFormatVersion">, import("../../../codec/codec.js").CodecWriteOptions>;
82
83
  //# sourceMappingURL=codecs.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"codecs.d.ts","sourceRoot":"","sources":["../../../../src/feature-libraries/chunked-forest/codec/codecs.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAC9E,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,8CAA8C,CAAC;AAM5F,OAAO,EACN,KAAK,SAAS,EACd,KAAK,iBAAiB,EAEtB,KAAK,UAAU,EAEf,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAEN,KAAK,sBAAsB,EAC3B,KAAK,eAAe,EACpB,KAAK,SAAS,EACd,MAAM,wBAAwB,CAAC;AAChC,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AAiB,EACjB,sBAAsB,EACtB,yBAAyB,CACzB,CAAC;AAiBF,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,iBAAiB,GAAG,eAAe,CA+F/E;AAED,wBAAgB,+BAA+B,CAC9C,aAAa,EAAE,uBAAuB,GACpC,SAAS,CAEX"}
1
+ {"version":3,"file":"codecs.d.ts","sourceRoot":"","sources":["../../../../src/feature-libraries/chunked-forest/codec/codecs.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAI9E,OAAO,EACN,oCAAoC,EAGpC,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAEN,KAAK,sBAAsB,EAC3B,KAAK,eAAe,EAGpB,KAAK,SAAS,EACd,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAqB,KAAK,KAAK,EAAE,MAAM,wBAAwB,CAAC;AACvE,OAAO,EAAE,uBAAuB,EAAE,MAAM,+BAA+B,CAAC;AAGxE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EACN,KAAK,iBAAiB,EAItB,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;AAIhF;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG,KAAK,CAAC,MAAM,EAAE,yBAAyB,CAAC,CAAC;AAGxE;;;;;;;;GAQG;AACH,MAAM,WAAW,kBAAkB;IAClC;;;OAGG;IACH,yBAAyB,EAAE,yBAAyB,CAAC;IACrD;;;;;;;OAOG;IACH,sBAAsB,CACrB,MAAM,EAAE,sBAAsB,EAC9B,YAAY,EAAE,CAAC,KAAK,EAAE,SAAS,KAAK,iBAAiB,GACnD,gBAAgB,EAAE,CAAC;CACtB;AAED;;;;;;GAMG;AACH,MAAM,WAAW,kBAAkB;IAClC;;;;;OAKG;IACH,sBAAsB,CACrB,WAAW,EAAE,gBAAgB,EAC7B,YAAY,EAAE,CAAC,OAAO,EAAE,iBAAiB,KAAK,SAAS,GACrD,SAAS,CAAC;CACb;AACD;;GAEG;AACH,MAAM,WAAW,yBAA0B,SAAQ,kBAAkB,EAAE,kBAAkB;CAAG;AAE5F,MAAM,WAAW,yBAAyB;IACzC,QAAQ,CAAC,UAAU,EAAE,uBAAuB,CAAC;IAC7C,QAAQ,CAAC,YAAY,EAAE,aAAa,CAAC;IACrC,QAAQ,CAAC,YAAY,EAAE,SAAS,CAAC;IACjC,QAAQ,CAAC,MAAM,CAAC,EAAE,eAAe,CAAC;IAClC;;;OAGG;IACH,QAAQ,CAAC,yBAAyB,CAAC,EAAE,yBAAyB,CAAC;CAC/D;AACD;;;GAGG;AACH,MAAM,MAAM,eAAe,GAAG,UAAU,CAAC,OAAO,sBAAsB,CAAC,KAAK,CAAC,CAAC;AAiF9E;;GAEG;AACH,eAAO,MAAM,sBAAsB,2NAwBlC,CAAC"}
@@ -3,53 +3,20 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
  import { assert, unreachableCase } from "@fluidframework/core-utils/internal";
6
- import { getConfigForMinVersionForCollab, lowestMinVersionForCollab, } from "@fluidframework/runtime-utils/internal";
7
- import { FluidClientVersion, makeVersionedValidatedCodec, } from "../../../codec/index.js";
8
- import { brand, brandedNumberType, unbrand, } from "../../../util/index.js";
6
+ import { lowestMinVersionForCollab } from "@fluidframework/runtime-utils/internal";
7
+ import { ClientVersionDispatchingCodecBuilder, FluidClientVersion, } from "../../../codec/index.js";
8
+ import { brandedNumberType } from "../../../util/index.js";
9
9
  import { TreeCompressionStrategy } from "../../treeCompressionUtils.js";
10
10
  import { decode } from "./chunkDecoding.js";
11
- import { EncodedFieldBatch, validVersions, FieldBatchFormatVersion } from "./format.js";
11
+ import { FieldBatchFormatVersion, EncodedFieldBatchV1, EncodedFieldBatchV2, } from "./format.js";
12
12
  import { schemaCompressedEncodeV1, schemaCompressedEncodeV2 } from "./schemaBasedEncode.js";
13
13
  import { uncompressedEncodeV1, uncompressedEncodeV2 } from "./uncompressedEncode.js";
14
14
  const ChunkReferenceId = brandedNumberType({ multipleOf: 1, minimum: 0 });
15
15
  /**
16
- * Convert a MinimumVersionForCollab to write version for {@link FieldBatchCodec}.
17
- * @param clientVersion - The MinimumVersionForCollab to convert.
16
+ * Creates the encode/decode functions for a specific FieldBatch format version.
18
17
  */
19
- function clientVersionToFieldBatchVersion(clientVersion) {
20
- return brand(getConfigForMinVersionForCollab(clientVersion, {
21
- [lowestMinVersionForCollab]: FieldBatchFormatVersion.v1,
22
- [FluidClientVersion.v2_73]: FieldBatchFormatVersion.v2,
23
- }));
24
- }
25
- export function makeFieldBatchCodec(options) {
26
- const writeVersion = clientVersionToFieldBatchVersion(options.minVersionForCollab);
27
- // Note: it's important that the decode function is schema-agnostic for this strategy/layering to work, since
28
- // the schema that an op was encoded in doesn't necessarily match the current schema for the document (e.g. if
29
- // decode is being run on a client that just submitted a schema change, but the op is from another client who has
30
- // yet to receive that change).
31
- assert(validVersions.has(writeVersion), 0x935 /* Invalid write version for FieldBatch codec */);
32
- let uncompressedEncodeFn;
33
- let schemaCompressedEncodeFn;
34
- switch (writeVersion) {
35
- case unbrand(FieldBatchFormatVersion.v1): {
36
- uncompressedEncodeFn = uncompressedEncodeV1;
37
- schemaCompressedEncodeFn = schemaCompressedEncodeV1;
38
- break;
39
- }
40
- case unbrand(FieldBatchFormatVersion.v2): {
41
- uncompressedEncodeFn = uncompressedEncodeV2;
42
- schemaCompressedEncodeFn = schemaCompressedEncodeV2;
43
- break;
44
- }
45
- default: {
46
- unreachableCase(writeVersion);
47
- }
48
- }
49
- // Both the encode and decode logic here support both v1 and v2, as does `validVersions` and `EncodedFieldBatch`.
50
- // This makes this use of makeVersionedValidatedCodec atypical as it is a single call being used to make a codec that supports all versions,
51
- // instead of one call per version, then using another utility to select between them based on version.
52
- return makeVersionedValidatedCodec(options, validVersions, EncodedFieldBatch, {
18
+ function makeFieldBatchCodecForVersion(version, uncompressedEncodeFn, schemaCompressedEncodeFn, encodedFieldBatchType) {
19
+ return {
53
20
  encode: (data, context) => {
54
21
  for (const cursor of data) {
55
22
  assert(cursor.mode === 1 /* CursorLocationType.Fields */, 0x8a3 /* FieldBatch expects fields cursors */);
@@ -62,7 +29,7 @@ export function makeFieldBatchCodec(options) {
62
29
  break;
63
30
  }
64
31
  case TreeCompressionStrategy.CompressedIncremental: {
65
- assert(writeVersion >= FieldBatchFormatVersion.v2, 0xca0 /* Unsupported FieldBatchFormatVersion for incremental encoding; must be v2 or higher */);
32
+ assert(version >= FieldBatchFormatVersion.v2, 0xca0 /* Unsupported FieldBatchFormatVersion for incremental encoding; must be v2 or higher */);
66
33
  // Incremental encoding is only supported for CompressedIncremental.
67
34
  incrementalEncoder = context.incrementalEncoderDecoder;
68
35
  }
@@ -92,9 +59,22 @@ export function makeFieldBatchCodec(options) {
92
59
  originatorId: context.originatorId,
93
60
  }, context.incrementalEncoderDecoder).map((chunk) => chunk.cursor());
94
61
  },
95
- });
96
- }
97
- export function getCodecTreeForFieldBatchFormat(clientVersion) {
98
- return { name: "FieldBatch", version: clientVersionToFieldBatchVersion(clientVersion) };
62
+ schema: encodedFieldBatchType,
63
+ };
99
64
  }
65
+ /**
66
+ * {@link ClientVersionDispatchingCodecBuilder} for field batch codecs.
67
+ */
68
+ export const fieldBatchCodecBuilder = ClientVersionDispatchingCodecBuilder.build("FieldBatch", [
69
+ {
70
+ minVersionForCollab: lowestMinVersionForCollab,
71
+ formatVersion: FieldBatchFormatVersion.v1,
72
+ codec: makeFieldBatchCodecForVersion(FieldBatchFormatVersion.v1, uncompressedEncodeV1, schemaCompressedEncodeV1, EncodedFieldBatchV1),
73
+ },
74
+ {
75
+ minVersionForCollab: FluidClientVersion.v2_73,
76
+ formatVersion: FieldBatchFormatVersion.v2,
77
+ codec: makeFieldBatchCodecForVersion(FieldBatchFormatVersion.v2, uncompressedEncodeV2, schemaCompressedEncodeV2, EncodedFieldBatchV2),
78
+ },
79
+ ]);
100
80
  //# sourceMappingURL=codecs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"codecs.js","sourceRoot":"","sources":["../../../../src/feature-libraries/chunked-forest/codec/codecs.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAC;AAG9E,OAAO,EACN,+BAA+B,EAC/B,yBAAyB,GACzB,MAAM,wCAAwC,CAAC;AAEhD,OAAO,EAGN,kBAAkB,EAElB,2BAA2B,GAC3B,MAAM,yBAAyB,CAAC;AAOjC,OAAO,EACN,KAAK,EACL,iBAAiB,EAGjB,OAAO,GACP,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,uBAAuB,EAAE,MAAM,+BAA+B,CAAC;AAExE,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAE5C,OAAO,EAAE,iBAAiB,EAAE,aAAa,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AAExF,OAAO,EAAE,wBAAwB,EAAE,wBAAwB,EAAE,MAAM,wBAAwB,CAAC;AAC5F,OAAO,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAMrF,MAAM,gBAAgB,GAAG,iBAAiB,CAAmB,EAAE,UAAU,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC,CAAC;AA6E5F;;;GAGG;AACH,SAAS,gCAAgC,CACxC,aAAsC;IAEtC,OAAO,KAAK,CACX,+BAA+B,CAAC,aAAa,EAAE;QAC9C,CAAC,yBAAyB,CAAC,EAAE,uBAAuB,CAAC,EAAE;QACvD,CAAC,kBAAkB,CAAC,KAAK,CAAC,EAAE,uBAAuB,CAAC,EAAE;KACtD,CAAC,CACF,CAAC;AACH,CAAC;AAED,MAAM,UAAU,mBAAmB,CAAC,OAA0B;IAC7D,MAAM,YAAY,GAAG,gCAAgC,CAAC,OAAO,CAAC,mBAAmB,CAAC,CAAC;IACnF,6GAA6G;IA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ent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, unreachableCase } from \"@fluidframework/core-utils/internal\";\nimport type { IIdCompressor, SessionId } from \"@fluidframework/id-compressor\";\nimport type { MinimumVersionForCollab } from \"@fluidframework/runtime-definitions/internal\";\nimport {\n\tgetConfigForMinVersionForCollab,\n\tlowestMinVersionForCollab,\n} from \"@fluidframework/runtime-utils/internal\";\n\nimport {\n\ttype CodecTree,\n\ttype CodecWriteOptions,\n\tFluidClientVersion,\n\ttype IJsonCodec,\n\tmakeVersionedValidatedCodec,\n} from \"../../../codec/index.js\";\nimport {\n\tCursorLocationType,\n\ttype ITreeCursorSynchronous,\n\ttype SchemaAndPolicy,\n\ttype TreeChunk,\n} from \"../../../core/index.js\";\nimport {\n\tbrand,\n\tbrandedNumberType,\n\ttype Brand,\n\ttype JsonCompatibleReadOnly,\n\tunbrand,\n} from \"../../../util/index.js\";\nimport { TreeCompressionStrategy } from \"../../treeCompressionUtils.js\";\n\nimport { decode } from \"./chunkDecoding.js\";\nimport type { FieldBatch } from \"./fieldBatch.js\";\nimport { EncodedFieldBatch, validVersions, FieldBatchFormatVersion } from \"./format.js\";\nimport type { IncrementalEncodingPolicy } from \"./incrementalEncodingPolicy.js\";\nimport { schemaCompressedEncodeV1, schemaCompressedEncodeV2 } from \"./schemaBasedEncode.js\";\nimport { uncompressedEncodeV1, uncompressedEncodeV2 } from \"./uncompressedEncode.js\";\n\n/**\n * Reference ID for a chunk that is incrementally encoded.\n */\nexport type ChunkReferenceId = Brand<number, \"forest.ChunkReferenceId\">;\nconst ChunkReferenceId = brandedNumberType<ChunkReferenceId>({ multipleOf: 1, minimum: 0 });\n\n/**\n * Properties for incremental encoding.\n * Fields that support incremental encoding will encode their chunks separately by calling `encodeIncrementalField`.\n * @remarks\n * This supports features like incremental summarization where the summary from these fields can be re-used if\n * unchanged between summaries.\n * Note that each of these chunks that are incrementally encoded is fully self-describing (contain its own shapes\n * list and identifier table) and does not rely on context from its parent.\n */\nexport interface IncrementalEncoder {\n\t/**\n\t * Returns whether a node / field should be incrementally encoded.\n\t * @remarks See {@link IncrementalEncodingPolicy}.\n\t */\n\tshouldEncodeIncrementally: IncrementalEncodingPolicy;\n\t/**\n\t * Called to encode an incremental field at the cursor.\n\t * The chunks for this field are encoded separately from the main buffer.\n\t * @param cursor - The cursor pointing to the field to encode.\n\t * @param chunkEncoder - A function that encodes the contents of the passed chunk in the field.\n\t * @returns The reference IDs of the encoded chunks in the field.\n\t * This is used to retrieve the encoded chunks later.\n\t */\n\tencodeIncrementalField(\n\t\tcursor: ITreeCursorSynchronous,\n\t\tchunkEncoder: (chunk: TreeChunk) => EncodedFieldBatch,\n\t): ChunkReferenceId[];\n}\n\n/**\n * Properties for incremental decoding.\n *\n * Fields that had their chunks incrementally encoded will retrieve them by calling `getEncodedIncrementalChunk`.\n * @remarks\n * See {@link IncrementalEncoder} for more details.\n */\nexport interface IncrementalDecoder {\n\t/**\n\t * Called to decode an incremental chunk with the given reference ID.\n\t * @param referenceId - The reference ID of the chunk to decode.\n\t * @param chunkDecoder - A function that decodes the chunk.\n\t * @returns The decoded chunk.\n\t */\n\tdecodeIncrementalChunk(\n\t\treferenceId: ChunkReferenceId,\n\t\tchunkDecoder: (encoded: EncodedFieldBatch) => TreeChunk,\n\t): TreeChunk;\n}\n/**\n * Combines the properties of {@link IncrementalEncoder} and {@link IncrementalDecoder}.\n */\nexport interface IncrementalEncoderDecoder extends IncrementalEncoder, IncrementalDecoder {}\n\nexport interface FieldBatchEncodingContext {\n\treadonly encodeType: TreeCompressionStrategy;\n\treadonly idCompressor: IIdCompressor;\n\treadonly originatorId: SessionId;\n\treadonly schema?: SchemaAndPolicy;\n\t/**\n\t * An encoder / decoder for encoding and decoding of incremental fields.\n\t * This will be defined if incremental encoding is supported and enabled.\n\t */\n\treadonly incrementalEncoderDecoder?: IncrementalEncoderDecoder;\n}\n/**\n * @remarks\n * Fields in this batch currently don't have field schema for the root, which limits optimizations.\n */\nexport type FieldBatchCodec = IJsonCodec<\n\tFieldBatch,\n\tEncodedFieldBatch,\n\tJsonCompatibleReadOnly,\n\tFieldBatchEncodingContext\n>;\n\n/**\n * Convert a MinimumVersionForCollab to write version for {@link FieldBatchCodec}.\n * @param clientVersion - The MinimumVersionForCollab to convert.\n */\nfunction clientVersionToFieldBatchVersion(\n\tclientVersion: MinimumVersionForCollab,\n): FieldBatchFormatVersion {\n\treturn brand(\n\t\tgetConfigForMinVersionForCollab(clientVersion, {\n\t\t\t[lowestMinVersionForCollab]: FieldBatchFormatVersion.v1,\n\t\t\t[FluidClientVersion.v2_73]: FieldBatchFormatVersion.v2,\n\t\t}),\n\t);\n}\n\nexport function makeFieldBatchCodec(options: CodecWriteOptions): FieldBatchCodec {\n\tconst writeVersion = clientVersionToFieldBatchVersion(options.minVersionForCollab);\n\t// Note: it's important that the decode function is schema-agnostic for this strategy/layering to work, since\n\t// the schema that an op was encoded in doesn't necessarily match the current schema for the document (e.g. if\n\t// decode is being run on a client that just submitted a schema change, but the op is from another client who has\n\t// yet to receive that change).\n\tassert(\n\t\tvalidVersions.has(writeVersion),\n\t\t0x935 /* Invalid write version for FieldBatch codec */,\n\t);\n\n\tlet uncompressedEncodeFn: typeof uncompressedEncodeV1 | typeof uncompressedEncodeV2;\n\tlet schemaCompressedEncodeFn:\n\t\t| typeof schemaCompressedEncodeV1\n\t\t| typeof schemaCompressedEncodeV2;\n\tswitch (writeVersion) {\n\t\tcase unbrand(FieldBatchFormatVersion.v1): {\n\t\t\tuncompressedEncodeFn = uncompressedEncodeV1;\n\t\t\tschemaCompressedEncodeFn = schemaCompressedEncodeV1;\n\t\t\tbreak;\n\t\t}\n\t\tcase unbrand(FieldBatchFormatVersion.v2): {\n\t\t\tuncompressedEncodeFn = uncompressedEncodeV2;\n\t\t\tschemaCompressedEncodeFn = schemaCompressedEncodeV2;\n\t\t\tbreak;\n\t\t}\n\t\tdefault: {\n\t\t\tunreachableCase(writeVersion);\n\t\t}\n\t}\n\n\t// Both the encode and decode logic here support both v1 and v2, as does `validVersions` and `EncodedFieldBatch`.\n\t// This makes this use of makeVersionedValidatedCodec atypical as it is a single call being used to make a codec that supports all versions,\n\t// instead of one call per version, then using another utility to select between them based on version.\n\treturn makeVersionedValidatedCodec(options, validVersions, EncodedFieldBatch, {\n\t\tencode: (data: FieldBatch, context: FieldBatchEncodingContext): EncodedFieldBatch => {\n\t\t\tfor (const cursor of data) {\n\t\t\t\tassert(\n\t\t\t\t\tcursor.mode === CursorLocationType.Fields,\n\t\t\t\t\t0x8a3 /* FieldBatch expects fields cursors */,\n\t\t\t\t);\n\t\t\t}\n\t\t\tlet encoded: EncodedFieldBatch;\n\t\t\tlet incrementalEncoder: IncrementalEncoder | undefined;\n\t\t\tswitch (context.encodeType) {\n\t\t\t\tcase TreeCompressionStrategy.Uncompressed: {\n\t\t\t\t\tencoded = uncompressedEncodeFn(data);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcase TreeCompressionStrategy.CompressedIncremental: {\n\t\t\t\t\tassert(\n\t\t\t\t\t\twriteVersion >= FieldBatchFormatVersion.v2,\n\t\t\t\t\t\t0xca0 /* Unsupported FieldBatchFormatVersion for incremental encoding; must be v2 or higher */,\n\t\t\t\t\t);\n\t\t\t\t\t// Incremental encoding is only supported for CompressedIncremental.\n\t\t\t\t\tincrementalEncoder = context.incrementalEncoderDecoder;\n\t\t\t\t}\n\t\t\t\t// fallthrough\n\t\t\t\tcase TreeCompressionStrategy.Compressed: {\n\t\t\t\t\t// eslint-disable-next-line unicorn/prefer-ternary\n\t\t\t\t\tif (context.schema === undefined) {\n\t\t\t\t\t\t// TODO: consider enabling a somewhat compressed but not schema accelerated encode.\n\t\t\t\t\t\tencoded = uncompressedEncodeFn(data);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tencoded = schemaCompressedEncodeFn(\n\t\t\t\t\t\t\tcontext.schema.schema,\n\t\t\t\t\t\t\tcontext.schema.policy,\n\t\t\t\t\t\t\tdata,\n\t\t\t\t\t\t\tcontext.idCompressor,\n\t\t\t\t\t\t\tincrementalEncoder,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tdefault: {\n\t\t\t\t\tunreachableCase(context.encodeType);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// TODO: consider checking input data was in schema.\n\t\t\treturn encoded;\n\t\t},\n\t\tdecode: (data: EncodedFieldBatch, context: FieldBatchEncodingContext): FieldBatch => {\n\t\t\t// TODO: consider checking data is in schema.\n\t\t\treturn decode(\n\t\t\t\tdata,\n\t\t\t\t{\n\t\t\t\t\tidCompressor: context.idCompressor,\n\t\t\t\t\toriginatorId: context.originatorId,\n\t\t\t\t},\n\t\t\t\tcontext.incrementalEncoderDecoder,\n\t\t\t).map((chunk) => chunk.cursor());\n\t\t},\n\t});\n}\n\nexport function getCodecTreeForFieldBatchFormat(\n\tclientVersion: MinimumVersionForCollab,\n): CodecTree {\n\treturn { name: \"FieldBatch\", version: clientVersionToFieldBatchVersion(clientVersion) };\n}\n"]}
1
+ {"version":3,"file":"codecs.js","sourceRoot":"","sources":["../../../../src/feature-libraries/chunked-forest/codec/codecs.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAC;AAE9E,OAAO,EAAE,yBAAyB,EAAE,MAAM,wCAAwC,CAAC;AAGnF,OAAO,EACN,oCAAoC,EAEpC,kBAAkB,GAClB,MAAM,yBAAyB,CAAC;AASjC,OAAO,EAAE,iBAAiB,EAAc,MAAM,wBAAwB,CAAC;AACvE,OAAO,EAAE,uBAAuB,EAAE,MAAM,+BAA+B,CAAC;AAExE,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAE5C,OAAO,EAEN,uBAAuB,EACvB,mBAAmB,EACnB,mBAAmB,GACnB,MAAM,aAAa,CAAC;AAErB,OAAO,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BAAwB,CACjC,OAAO,CAAC,MAAM,CAAC,MAAM,EACrB,OAAO,CAAC,MAAM,CAAC,MAAM,EACrB,IAAI,EACJ,OAAO,CAAC,YAAY,EACpB,kBAAkB,CAClB,CAAC;oBACH,CAAC;oBAED,MAAM;gBACP,CAAC;gBACD,OAAO,CAAC,CAAC,CAAC;oBACT,eAAe,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;gBACrC,CAAC;YACF,CAAC;YAED,oDAAoD;YACpD,OAAO,OAAO,CAAC;QAChB,CAAC;QACD,MAAM,EAAE,CAAC,IAAuB,EAAE,OAAkC,EAAc,EAAE;YACnF,6CAA6C;YAC7C,OAAO,MAAM,CACZ,IAAI,EACJ;gBACC,YAAY,EAAE,OAAO,CAAC,YAAY;gBAClC,YAAY,EAAE,OAAO,CAAC,YAAY;aAClC,EACD,OAAO,CAAC,yBAAyB,CACjC,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC;QAClC,CAAC;QACD,MAAM,EAAE,qBAAqB;KAC7B,CAAC;AACH,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,oCAAoC,CAAC,KAAK,CAC/E,YAAY,EACZ;IACC;QACC,mBAAmB,EAAE,yBAAyB;QAC9C,aAAa,EAAE,uBAAuB,CAAC,EAAE;QACzC,KAAK,EAAE,6BAA6B,CACnC,uBAAuB,CAAC,EAAE,EAC1B,oBAAoB,EACpB,wBAAwB,EACxB,mBAAmB,CACnB;KACD;IACD;QACC,mBAAmB,EAAE,kBAAkB,CAAC,KAAK;QAC7C,aAAa,EAAE,uBAAuB,CAAC,EAAE;QACzC,KAAK,EAAE,6BAA6B,CACnC,uBAAuB,CAAC,EAAE,EAC1B,oBAAoB,EACpB,wBAAwB,EACxB,mBAAmB,CACnB;KACD;CACD,CACD,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, unreachableCase } from \"@fluidframework/core-utils/internal\";\nimport type { IIdCompressor, SessionId } from \"@fluidframework/id-compressor\";\nimport { lowestMinVersionForCollab } from \"@fluidframework/runtime-utils/internal\";\nimport type { TSchema } from \"@sinclair/typebox\";\n\nimport {\n\tClientVersionDispatchingCodecBuilder,\n\ttype CodecAndSchema,\n\tFluidClientVersion,\n} from \"../../../codec/index.js\";\nimport {\n\tCursorLocationType,\n\ttype ITreeCursorSynchronous,\n\ttype SchemaAndPolicy,\n\ttype SchemaPolicy,\n\ttype StoredSchemaCollection,\n\ttype TreeChunk,\n} from \"../../../core/index.js\";\nimport { brandedNumberType, type Brand } from \"../../../util/index.js\";\nimport { TreeCompressionStrategy } from \"../../treeCompressionUtils.js\";\n\nimport { decode } from \"./chunkDecoding.js\";\nimport type { FieldBatch } from \"./fieldBatch.js\";\nimport {\n\ttype EncodedFieldBatch,\n\tFieldBatchFormatVersion,\n\tEncodedFieldBatchV1,\n\tEncodedFieldBatchV2,\n} from \"./format.js\";\nimport type { IncrementalEncodingPolicy } from \"./incrementalEncodingPolicy.js\";\nimport { schemaCompressedEncodeV1, schemaCompressedEncodeV2 } from \"./schemaBasedEncode.js\";\nimport { uncompressedEncodeV1, uncompressedEncodeV2 } from \"./uncompressedEncode.js\";\n\n/**\n * Reference ID for a chunk that is incrementally encoded.\n */\nexport type ChunkReferenceId = Brand<number, \"forest.ChunkReferenceId\">;\nconst ChunkReferenceId = brandedNumberType<ChunkReferenceId>({ multipleOf: 1, minimum: 0 });\n\n/**\n * Properties for incremental encoding.\n * Fields that support incremental encoding will encode their chunks separately by calling `encodeIncrementalField`.\n * @remarks\n * This supports features like incremental summarization where the summary from these fields can be re-used if\n * unchanged between summaries.\n * Note that each of these chunks that are incrementally encoded is fully self-describing (contain its own shapes\n * list and identifier table) and does not rely on context from its parent.\n */\nexport interface IncrementalEncoder {\n\t/**\n\t * Returns whether a node / field should be incrementally encoded.\n\t * @remarks See {@link IncrementalEncodingPolicy}.\n\t */\n\tshouldEncodeIncrementally: IncrementalEncodingPolicy;\n\t/**\n\t * Called to encode an incremental field at the cursor.\n\t * The chunks for this field are encoded separately from the main buffer.\n\t * @param cursor - The cursor pointing to the field to encode.\n\t * @param chunkEncoder - A function that encodes the contents of the passed chunk in the field.\n\t * @returns The reference IDs of the encoded chunks in the field.\n\t * This is used to retrieve the encoded chunks later.\n\t */\n\tencodeIncrementalField(\n\t\tcursor: ITreeCursorSynchronous,\n\t\tchunkEncoder: (chunk: TreeChunk) => EncodedFieldBatch,\n\t): ChunkReferenceId[];\n}\n\n/**\n * Properties for incremental decoding.\n *\n * Fields that had their chunks incrementally encoded will retrieve them by calling `getEncodedIncrementalChunk`.\n * @remarks\n * See {@link IncrementalEncoder} for more details.\n */\nexport interface IncrementalDecoder {\n\t/**\n\t * Called to decode an incremental chunk with the given reference ID.\n\t * @param referenceId - The reference ID of the chunk to decode.\n\t * @param chunkDecoder - A function that decodes the chunk.\n\t * @returns The decoded chunk.\n\t */\n\tdecodeIncrementalChunk(\n\t\treferenceId: ChunkReferenceId,\n\t\tchunkDecoder: (encoded: EncodedFieldBatch) => TreeChunk,\n\t): TreeChunk;\n}\n/**\n * Combines the properties of {@link IncrementalEncoder} and {@link IncrementalDecoder}.\n */\nexport interface IncrementalEncoderDecoder extends IncrementalEncoder, IncrementalDecoder {}\n\nexport interface FieldBatchEncodingContext {\n\treadonly encodeType: TreeCompressionStrategy;\n\treadonly idCompressor: IIdCompressor;\n\treadonly originatorId: SessionId;\n\treadonly schema?: SchemaAndPolicy;\n\t/**\n\t * An encoder / decoder for encoding and decoding of incremental fields.\n\t * This will be defined if incremental encoding is supported and enabled.\n\t */\n\treadonly incrementalEncoderDecoder?: IncrementalEncoderDecoder;\n}\n/**\n * @remarks\n * Fields in this batch currently don't have field schema for the root, which limits optimizations.\n */\nexport type FieldBatchCodec = ReturnType<typeof fieldBatchCodecBuilder.build>;\n\n/**\n * Creates the encode/decode functions for a specific FieldBatch format version.\n */\nfunction makeFieldBatchCodecForVersion(\n\tversion: FieldBatchFormatVersion,\n\tuncompressedEncodeFn: (batch: FieldBatch) => EncodedFieldBatch,\n\tschemaCompressedEncodeFn: (\n\t\tschema: StoredSchemaCollection,\n\t\tpolicy: SchemaPolicy,\n\t\tfieldBatch: FieldBatch,\n\t\tidCompressor: IIdCompressor,\n\t\tincrementalEncoder: IncrementalEncoder | undefined,\n\t) => EncodedFieldBatch,\n\tencodedFieldBatchType: TSchema,\n): CodecAndSchema<FieldBatch, FieldBatchEncodingContext> {\n\treturn {\n\t\tencode: (data: FieldBatch, context: FieldBatchEncodingContext): EncodedFieldBatch => {\n\t\t\tfor (const cursor of data) {\n\t\t\t\tassert(\n\t\t\t\t\tcursor.mode === CursorLocationType.Fields,\n\t\t\t\t\t0x8a3 /* FieldBatch expects fields cursors */,\n\t\t\t\t);\n\t\t\t}\n\t\t\tlet encoded: EncodedFieldBatch;\n\t\t\tlet incrementalEncoder: IncrementalEncoder | undefined;\n\t\t\tswitch (context.encodeType) {\n\t\t\t\tcase TreeCompressionStrategy.Uncompressed: {\n\t\t\t\t\tencoded = uncompressedEncodeFn(data);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcase TreeCompressionStrategy.CompressedIncremental: {\n\t\t\t\t\tassert(\n\t\t\t\t\t\tversion >= FieldBatchFormatVersion.v2,\n\t\t\t\t\t\t0xca0 /* Unsupported FieldBatchFormatVersion for incremental encoding; must be v2 or higher */,\n\t\t\t\t\t);\n\t\t\t\t\t// Incremental encoding is only supported for CompressedIncremental.\n\t\t\t\t\tincrementalEncoder = context.incrementalEncoderDecoder;\n\t\t\t\t}\n\t\t\t\t// fallthrough\n\t\t\t\tcase TreeCompressionStrategy.Compressed: {\n\t\t\t\t\t// eslint-disable-next-line unicorn/prefer-ternary\n\t\t\t\t\tif (context.schema === undefined) {\n\t\t\t\t\t\t// TODO: consider enabling a somewhat compressed but not schema accelerated encode.\n\t\t\t\t\t\tencoded = uncompressedEncodeFn(data);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tencoded = schemaCompressedEncodeFn(\n\t\t\t\t\t\t\tcontext.schema.schema,\n\t\t\t\t\t\t\tcontext.schema.policy,\n\t\t\t\t\t\t\tdata,\n\t\t\t\t\t\t\tcontext.idCompressor,\n\t\t\t\t\t\t\tincrementalEncoder,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tdefault: {\n\t\t\t\t\tunreachableCase(context.encodeType);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// TODO: consider checking input data was in schema.\n\t\t\treturn encoded;\n\t\t},\n\t\tdecode: (data: EncodedFieldBatch, context: FieldBatchEncodingContext): FieldBatch => {\n\t\t\t// TODO: consider checking data is in schema.\n\t\t\treturn decode(\n\t\t\t\tdata,\n\t\t\t\t{\n\t\t\t\t\tidCompressor: context.idCompressor,\n\t\t\t\t\toriginatorId: context.originatorId,\n\t\t\t\t},\n\t\t\t\tcontext.incrementalEncoderDecoder,\n\t\t\t).map((chunk) => chunk.cursor());\n\t\t},\n\t\tschema: encodedFieldBatchType,\n\t};\n}\n\n/**\n * {@link ClientVersionDispatchingCodecBuilder} for field batch codecs.\n */\nexport const fieldBatchCodecBuilder = ClientVersionDispatchingCodecBuilder.build(\n\t\"FieldBatch\",\n\t[\n\t\t{\n\t\t\tminVersionForCollab: lowestMinVersionForCollab,\n\t\t\tformatVersion: FieldBatchFormatVersion.v1,\n\t\t\tcodec: makeFieldBatchCodecForVersion(\n\t\t\t\tFieldBatchFormatVersion.v1,\n\t\t\t\tuncompressedEncodeV1,\n\t\t\t\tschemaCompressedEncodeV1,\n\t\t\t\tEncodedFieldBatchV1,\n\t\t\t),\n\t\t},\n\t\t{\n\t\t\tminVersionForCollab: FluidClientVersion.v2_73,\n\t\t\tformatVersion: FieldBatchFormatVersion.v2,\n\t\t\tcodec: makeFieldBatchCodecForVersion(\n\t\t\t\tFieldBatchFormatVersion.v2,\n\t\t\t\tuncompressedEncodeV2,\n\t\t\t\tschemaCompressedEncodeV2,\n\t\t\t\tEncodedFieldBatchV2,\n\t\t\t),\n\t\t},\n\t],\n);\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"format.d.ts","sourceRoot":"","sources":["../../../../src/feature-libraries/chunked-forest/codec/format.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,KAAK,MAAM,EAAQ,MAAM,mBAAmB,CAAC;AAGtD,OAAO,EAAc,KAAK,MAAM,EAAE,MAAM,wBAAwB,CAAC;AASjE;;GAEG;AACH,eAAO,MAAM,uBAAuB;;;CAGlC,CAAC;AACH,MAAM,MAAM,uBAAuB,GAAG,MAAM,CAAC,OAAO,uBAAuB,CAAC,CAAC;AAI7E,eAAO,MAAM,aAAa,kJAAuD,CAAC;AAElF;;;GAGG;AACH,eAAO,MAAM,uBAAuB,qCAAa,CAAC;AAElD;;GAEG;AACH,eAAO,MAAM,uBAAuB;;IAGlC;;OAEG;;EAIJ,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,eAAe,yCAAkB,CAAC;AAE/C;;;GAGG;AACH,eAAO,MAAM,4BAA4B,yCAAkB,CAAC;AAE5D;;;GAGG;AACH,eAAO,MAAM,iBAAiB,2LAS5B,CAAC;AAEH,MAAM,MAAM,iBAAiB,GAAG,MAAM,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAEjE,aAAK,iBAAiB;IAErB,qCAAqC,IAAA;CAErC;AAED,aAAK,WAAW;IACf,MAAM,IAAA;IAEN,IAAI,IAAA;CACJ;AAED;;GAEG;AACH,eAAO,MAAM,cAAc;;;;EAQ1B,CAAC;AAEF;;GAEG;AACH,oBAAY,YAAY;IACvB;;OAEG;IACH,UAAU,IAAI;CACd;AAED;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,eAAO,MAAM,iBAAiB,0MAM5B,CAAC;AACH,MAAM,MAAM,iBAAiB,GAAG,SAAS,GAAG,MAAM,CA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G;;QAEH;;WAEG;;;EAiBJ,CAAC;AACF,MAAM,MAAM,mBAAmB,GAAG,MAAM,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAErE,eAAO,MAAM,mBAAmB;;;;;QAtC9B;;WAEG;;QAEH;;WAEG;;;YArJH;;eAEG;;;QAqJH;;WAEG;;YA3CH;;eAEG;;;YAGH;;;;eAIG;;YAEH;;;eAGG;;;QA+BH;;WAEG;;QAEH;;WAEG;;;EAuBJ,CAAC;AACF,MAAM,MAAM,mBAAmB,GAAG,MAAM,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAErE,eAAO,MAAM,iBAAiB;;;;;QA5C5B;;WAEG;;QAEH;;WAEG;;;YArJH;;eAEG;;;QAqJH;;WAEG;;YA3CH;;eAEG;;;YAGH;;;;eAIG;;YAEH;;;eAGG;;;QA+BH;;WAEG;;QAEH;;WAEG;;;;;;;;QAlBH;;WAEG;;QAEH;;WAEG;;;YArJH;;eAEG;;;QAqJH;;WAEG;;YA3CH;;eAEG;;;YAGH;;;;eAIG;;YAEH;;;eAGG;;;QA+BH;;WAEG;;QAEH;;WAEG;;;IA0BkF,CAAC;AACxF,MAAM,MAAM,iBAAiB,GAAG,MAAM,CAAC,OAAO,iBAAiB,CAAC,CAAC"}
@@ -10,7 +10,18 @@ import { Count, EncodedFieldBatchGeneric, IdentifierOrIndex, ShapeIndex, } from
10
10
  * The format version for the field batch.
11
11
  */
12
12
  export const FieldBatchFormatVersion = strictEnum("FieldBatchFormatVersion", {
13
+ /**
14
+ * Initial version.
15
+ * @remarks
16
+ * For simplicity of implementation the format for this version allows the same chunk shapes as v2, but must not use {@link EncodedIncrementalChunkShape}
17
+ * as older clients will not know how to handle that shape but think they can handle this format.
18
+ */
13
19
  v1: 1,
20
+ /**
21
+ * Adds support for incremental encoding of chunks.
22
+ * @remarks
23
+ * {@link EncodedIncrementalChunkShape} was added in this version.
24
+ */
14
25
  v2: 2,
15
26
  });
16
27
  // Compatible versions used for format/version validation.
@@ -1 +1 @@
1
- {"version":3,"file":"format.js","sourceRoot":"","sources":["../../../../src/feature-libraries/chunked-forest/codec/format.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAe,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAEtD,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,UAAU,EAAe,MAAM,wBAAwB,CAAC;AAEjE,OAAO,EACN,KAAK,EACL,wBAAwB,EACxB,iBAAiB,EACjB,UAAU,GACV,MAAM,oBAAoB,CAAC;AAE5B;;GAEG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,UAAU,CAAC,yBAAyB,EAAE;IAC5E,EAAE,EAAE,CAAC;IACL,EAAE,EAAE,CAAC;CACL,CAAC,CAAC;AAGH,0DAA0D;AAC1D,mEAAmE;AACnE,MAAM,CAAC,MAAM,aAAa,GAAG,IAAI,GAAG,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,CAAC,uBAAuB,CAAC,CAAC,CAAC,CAAC;AAElF;;;GAGG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,UAAU,CAAC;AAElD;;GAEG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,IAAI,CAAC,MAAM,CACjD;IACC,MAAM,EAAE,KAAK;IACb;;OAEG;IACH,KAAK,EAAE,UAAU;CACjB,EACD,EAAE,oBAAoB,EAAE,KAAK,EAAE,CAC/B,CAAC;AAEF;;;;GAIG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;AAE/C;;;GAGG;AACH,MAAM,CAAC,MAAM,4BAA4B,GAAG,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;AAE5D;;;GAGG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,IAAI,CAAC,KAAK,CAAC;IAC3C;;OAEG;IACH,iBAAiB;IACjB;;OAEG;IACH,UAAU;CACV,CAAC,CAAC;AAIH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Q,CAAC,iBAAiB,CAAC;IACvC;;;;OAIG;IACH,MAAM,EAAE,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAAC;IACpD;;;OAGG;IACH,WAAW,EAAE,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC;CACtC,EACD,EAAE,oBAAoB,EAAE,KAAK,EAAE,CAC/B,CAAC;AAEF;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,IAAI,CAAC,MAAM,CAC3C;IACC;;OAEG;IACH,CAAC,EAAE,IAAI,CAAC,QAAQ,CAAC,uBAAuB,CAAC;IACzC;;OAEG;IACH,CAAC,EAAE,IAAI,CAAC,QAAQ,CAAC,uBAAuB,CAAC;IACzC;;OAEG;IACH,CAAC,EAAE,IAAI,CAAC,QAAQ,CAAC,gBAAgB,CAAC;IAClC;;OAEG;IACH,CAAC,EAAE,IAAI,CAAC,QAAQ,CAAC,eAAe,CAAC;IACjC;;OAEG;IACH,CAAC,EAAE,IAAI,CAAC,QAAQ,CAAC,4BAA4B,CAAC;CAC9C,EACD,YAAY,CACZ,CAAC;AAUF,MAAM,CAAC,MAAM,mBAAmB,GAAG,wBAAwB,CAC1D,uBAAuB,CAAC,EAAE,EAC1B,iBAAiB,CACjB,CAAC;AAGF,MAAM,CAAC,MAAM,mBAAmB,GAAG,wBAAwB,CAC1D,uBAAuB,CAAC,EAAE,EAC1B,iBAAiB,CACjB,CAAC;AAGF,MAAM,CAAC,MAAM,iBAAiB,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,mBAAmB,EAAE,mBAAmB,CAAC,CAAC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { type Static, Type } from \"@sinclair/typebox\";\n\nimport { unionOptions } from \"../../../codec/index.js\";\nimport { strictEnum, type Values } from \"../../../util/index.js\";\n\nimport {\n\tCount,\n\tEncodedFieldBatchGeneric,\n\tIdentifierOrIndex,\n\tShapeIndex,\n} from \"./formatGeneric.js\";\n\n/**\n * The format version for the field batch.\n */\nexport const FieldBatchFormatVersion = strictEnum(\"FieldBatchFormatVersion\", {\n\tv1: 1,\n\tv2: 2,\n});\nexport type FieldBatchFormatVersion = Values<typeof FieldBatchFormatVersion>;\n\n// Compatible versions used for format/version validation.\n// TODO: A proper version update policy will need to be documented.\nexport const validVersions = new Set([...Object.values(FieldBatchFormatVersion)]);\n\n/**\n * Top level length is implied from length of data array.\n * All content are of this shape.\n */\nexport const EncodedNestedArrayShape = ShapeIndex;\n\n/**\n * Inline array.\n */\nexport const EncodedInlineArrayShape = Type.Object(\n\t{\n\t\tlength: Count,\n\t\t/**\n\t\t * All entries are this shape.\n\t\t */\n\t\tshape: ShapeIndex,\n\t},\n\t{ additionalProperties: false },\n);\n\n/**\n * Encoded as `shape, ...[data for shape]`.\n *\n * Used for polymorphism.\n */\nexport const EncodedAnyShape = Type.Literal(0);\n\n/**\n * Encoded content is a {@link ChunkReferenceId}.\n * This represents the shape of a chunk that is encoded separately and is referenced by its {@link ChunkReferenceId}.\n */\nexport const EncodedIncrementalChunkShape = Type.Literal(0);\n\n/**\n * Content of the encoded field is specified by the Shape referenced by the ShapeIndex.\n * This is a tuple for conciseness.\n */\nexport const EncodedFieldShape = Type.Tuple([\n\t/**\n\t * Field key for this field.\n\t */\n\tIdentifierOrIndex,\n\t/**\n\t * Shape of data in this field.\n\t */\n\tShapeIndex,\n]);\n\nexport type EncodedFieldShape = Static<typeof EncodedFieldShape>;\n\nenum CounterRelativeTo {\n\t// Relative to previous node of same type in depth first pre-order traversal.\n\tPreviousNodeOfType_DepthFirstPreOrder,\n\t// TODO: add alternative relative mode relative to previous note at a path to allow delta encoded sequences (like points where x and y are delta encoded relative to previous points).\n}\n\nenum CounterMode {\n\tNumber,\n\t// TODO: document wrap modes and bit skipping. Note UUID subVersion here (ex: UUIDv4)\n\tUUID,\n}\n\n/**\n * Delta encoded value relative to a previous node's value.\n */\nexport const EncodedCounter = Type.Object(\n\t{\n\t\trelativeTo: Type.Enum(CounterRelativeTo),\n\t\t// If not provided, delta inline in data.\n\t\tdelta: Type.Optional(Type.Number()),\n\t\tmode: Type.Enum(CounterMode),\n\t},\n\t{ additionalProperties: false },\n);\n\n/**\n * Used in {@link EncodedValueShape} for special field kind handling.\n */\nexport enum SpecialField {\n\t/**\n\t * Special case for Identifier field kind.\n\t */\n\tIdentifier = 0,\n}\n\n/**\n * Shape of a value on a node.\n *\n * Due to limitations of TypeBox and differences between JavaScript objects, TypeScript types and JSON,\n * the case where no information about the value is captured in the shape is a bit confusing.\n * In TypeBox this is allowed by the user of this type putting it in an optional property.\n * In TypeScript it is modeled using `undefined`.\n * In JavaScript the property may be missing or explicitly `undefined`.\n * In JSON this will serialize as the property being omitted.\n * In this case, the value will be encoded as either:\n * - `false` (when there is no value) OR\n * - `true, value` when there is a value.\n *\n * For a more compact encoding, there are 4 options for the shape:\n * - `true`: there is a value, and it will simply be encoded by putting it in the output buffer (so `value`).\n * - `false`: there is never a value, and it takes up no space in the output buffer.\n * - `[value]`: there is a value, and its always the same.\n * - `SpecialField.Identifier`: special case for node identifier handling.\n * Takes up no space in the output buffer: the value comes from the shape arrays's content.\n * It is wrapped in an array to differentiate value shape types.\n *\n * In the future other value shape formats may be added, likely as objects.\n *\n * @remarks\n * See {@link EncodedNodeShape} for usage.\n */\nexport const EncodedValueShape = Type.Union([\n\tType.Boolean(),\n\tType.Array(Type.Any(), { minItems: 1, maxItems: 1 }),\n\tType.Enum(SpecialField),\n\t// TODO: support delta encoding and/or special node identifier handling\n\t// EncodedCounter,\n]);\nexport type EncodedValueShape = undefined | Static<typeof EncodedValueShape>;\n\nexport const EncodedNodeShape = Type.Object(\n\t{\n\t\t/**\n\t\t * If not provided, inlined in data.\n\t\t */\n\t\ttype: Type.Optional(IdentifierOrIndex),\n\t\tvalue: Type.Optional(EncodedValueShape),\n\t\t/**\n\t\t * Fields with fixed (per key) shapes.\n\t\t * They are encoded in the order they are specified here.\n\t\t * To ensure the order is preserved, this is an array instead of an object with keys.\n\t\t */\n\t\tfields: Type.Optional(Type.Array(EncodedFieldShape)),\n\t\t/**\n\t\t * If undefined, no data. Otherwise, nested array of `[key, ...data]*`\n\t\t * Covers any fields beyond those in `fields`.\n\t\t */\n\t\textraFields: Type.Optional(ShapeIndex),\n\t},\n\t{ additionalProperties: false },\n);\n\n/**\n * Discriminated union that represents the shapes of chunks in the encoded data.\n * \"Chunk\" here refers to a chunk of tree data, rooted at a range of nodes, that is encoded as a\n * single unit in a specific format represented by one of the shapes in this union.\n *\n * The concept of \"chunk\" is same for the tree data in memory and in the encoded wire format.\n * The physical representation of the chunk may differ, but the logical structure remains the same.\n * This is similar to other such concepts in the system.\n *\n * See {@link DiscriminatedUnionDispatcher} for more information on this pattern.\n */\nexport const EncodedChunkShape = Type.Object(\n\t{\n\t\t/**\n\t\t * {@link EncodedNestedArrayShape} union member.\n\t\t */\n\t\ta: Type.Optional(EncodedNestedArrayShape),\n\t\t/**\n\t\t * {@link EncodedInlineArrayShape} union member.\n\t\t */\n\t\tb: Type.Optional(EncodedInlineArrayShape),\n\t\t/**\n\t\t * {@link EncodedNodeShape} union member.\n\t\t */\n\t\tc: Type.Optional(EncodedNodeShape),\n\t\t/**\n\t\t * {@link EncodedAnyShape} union member.\n\t\t */\n\t\td: Type.Optional(EncodedAnyShape),\n\t\t/**\n\t\t * {@link EncodedIncrementalChunkShape} union member.\n\t\t */\n\t\te: Type.Optional(EncodedIncrementalChunkShape),\n\t},\n\tunionOptions,\n);\n\nexport type EncodedChunkShape = Static<typeof EncodedChunkShape>;\n\nexport type EncodedNestedArrayShape = Static<typeof EncodedNestedArrayShape>;\nexport type EncodedInlineArrayShape = Static<typeof EncodedInlineArrayShape>;\nexport type EncodedNodeShape = Static<typeof EncodedNodeShape>;\nexport type EncodedAnyShape = Static<typeof EncodedAnyShape>;\nexport type EncodedIncrementalChunkShape = Static<typeof EncodedIncrementalChunkShape>;\n\nexport const EncodedFieldBatchV1 = EncodedFieldBatchGeneric(\n\tFieldBatchFormatVersion.v1,\n\tEncodedChunkShape,\n);\nexport type EncodedFieldBatchV1 = Static<typeof EncodedFieldBatchV1>;\n\nexport const EncodedFieldBatchV2 = EncodedFieldBatchGeneric(\n\tFieldBatchFormatVersion.v2,\n\tEncodedChunkShape,\n);\nexport type EncodedFieldBatchV2 = Static<typeof EncodedFieldBatchV2>;\n\nexport const EncodedFieldBatch = Type.Union([EncodedFieldBatchV1, EncodedFieldBatchV2]);\nexport type EncodedFieldBatch = Static<typeof EncodedFieldBatch>;\n"]}
1
+ {"version":3,"file":"format.js","sourceRoot":"","sources":["../../../../src/feature-libraries/chunked-forest/codec/format.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAe,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAEtD,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,UAAU,EAAe,MAAM,wBAAwB,CAAC;AAEjE,OAAO,EACN,KAAK,EACL,wBAAwB,EACxB,iBAAiB,EACjB,UAAU,GACV,MAAM,oBAAoB,CAAC;AAE5B;;GAEG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,UAAU,CAAC,yBAAyB,EAAE;IAC5E;;;;;OAKG;IACH,EAAE,EAAE,CAAC;IACL;;;;OAIG;IACH,EAAE,EAAE,CAAC;CACL,CAAC,CAAC;AAGH,0DAA0D;AAC1D,mEAAmE;AACnE,MAAM,CAAC,MAAM,aAAa,GAAG,IAAI,GAAG,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,CAAC,uBAAuB,CAAC,CAAC,CAAC,CAAC;AAElF;;;GAGG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,UAAU,CAAC;AAElD;;GAEG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,IAAI,CAAC,MAAM,CACjD;IACC,MAAM,EAAE,KAAK;IACb;;OAEG;IACH,K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MAAM,CAAC,MAAM,mBAAmB,GAAG,wBAAwB,CAC1D,uBAAuB,CAAC,EAAE,EAC1B,iBAAiB,CACjB,CAAC;AAGF,MAAM,CAAC,MAAM,iBAAiB,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,mBAAmB,EAAE,mBAAmB,CAAC,CAAC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { type Static, Type } from \"@sinclair/typebox\";\n\nimport { unionOptions } from \"../../../codec/index.js\";\nimport { strictEnum, type Values } from \"../../../util/index.js\";\n\nimport {\n\tCount,\n\tEncodedFieldBatchGeneric,\n\tIdentifierOrIndex,\n\tShapeIndex,\n} from \"./formatGeneric.js\";\n\n/**\n * The format version for the field batch.\n */\nexport const FieldBatchFormatVersion = strictEnum(\"FieldBatchFormatVersion\", {\n\t/**\n\t * Initial version.\n\t * @remarks\n\t * For simplicity of implementation the format for this version allows the same chunk shapes as v2, but must not use {@link EncodedIncrementalChunkShape}\n\t * as older clients will not know how to handle that shape but think they can handle this format.\n\t */\n\tv1: 1,\n\t/**\n\t * Adds support for incremental encoding of chunks.\n\t * @remarks\n\t * {@link EncodedIncrementalChunkShape} was added in this version.\n\t */\n\tv2: 2,\n});\nexport type FieldBatchFormatVersion = Values<typeof FieldBatchFormatVersion>;\n\n// Compatible versions used for format/version validation.\n// TODO: A proper version update policy will need to be documented.\nexport const validVersions = new Set([...Object.values(FieldBatchFormatVersion)]);\n\n/**\n * Top level length is implied from length of data array.\n * All content are of this shape.\n */\nexport const EncodedNestedArrayShape = ShapeIndex;\n\n/**\n * Inline array.\n */\nexport const EncodedInlineArrayShape = Type.Object(\n\t{\n\t\tlength: Count,\n\t\t/**\n\t\t * All entries are this shape.\n\t\t */\n\t\tshape: ShapeIndex,\n\t},\n\t{ additionalProperties: false },\n);\n\n/**\n * Encoded as `shape, ...[data for shape]`.\n *\n * Used for polymorphism.\n */\nexport const EncodedAnyShape = Type.Literal(0);\n\n/**\n * Encoded content is a {@link ChunkReferenceId}.\n * This represents the shape of a chunk that is encoded separately and is referenced by its {@link ChunkReferenceId}.\n */\nexport const EncodedIncrementalChunkShape = Type.Literal(0);\n\n/**\n * Content of the encoded field is specified by the Shape referenced by the ShapeIndex.\n * This is a tuple for conciseness.\n */\nexport const EncodedFieldShape = Type.Tuple([\n\t/**\n\t * Field key for this field.\n\t */\n\tIdentifierOrIndex,\n\t/**\n\t * Shape of data in this field.\n\t */\n\tShapeIndex,\n]);\n\nexport type EncodedFieldShape = Static<typeof EncodedFieldShape>;\n\nenum CounterRelativeTo {\n\t// Relative to previous node of same type in depth first pre-order traversal.\n\tPreviousNodeOfType_DepthFirstPreOrder,\n\t// TODO: add alternative relative mode relative to previous note at a path to allow delta encoded sequences (like points where x and y are delta encoded relative to previous points).\n}\n\nenum CounterMode {\n\tNumber,\n\t// TODO: document wrap modes and bit skipping. Note UUID subVersion here (ex: UUIDv4)\n\tUUID,\n}\n\n/**\n * Delta encoded value relative to a previous node's value.\n */\nexport const EncodedCounter = Type.Object(\n\t{\n\t\trelativeTo: Type.Enum(CounterRelativeTo),\n\t\t// If not provided, delta inline in data.\n\t\tdelta: Type.Optional(Type.Number()),\n\t\tmode: Type.Enum(CounterMode),\n\t},\n\t{ additionalProperties: false },\n);\n\n/**\n * Used in {@link EncodedValueShape} for special field kind handling.\n */\nexport enum SpecialField {\n\t/**\n\t * Special case for Identifier field kind.\n\t */\n\tIdentifier = 0,\n}\n\n/**\n * Shape of a value on a node.\n *\n * Due to limitations of TypeBox and differences between JavaScript objects, TypeScript types and JSON,\n * the case where no information about the value is captured in the shape is a bit confusing.\n * In TypeBox this is allowed by the user of this type putting it in an optional property.\n * In TypeScript it is modeled using `undefined`.\n * In JavaScript the property may be missing or explicitly `undefined`.\n * In JSON this will serialize as the property being omitted.\n * In this case, the value will be encoded as either:\n * - `false` (when there is no value) OR\n * - `true, value` when there is a value.\n *\n * For a more compact encoding, there are 4 options for the shape:\n * - `true`: there is a value, and it will simply be encoded by putting it in the output buffer (so `value`).\n * - `false`: there is never a value, and it takes up no space in the output buffer.\n * - `[value]`: there is a value, and its always the same.\n * - `SpecialField.Identifier`: special case for node identifier handling.\n * Takes up no space in the output buffer: the value comes from the shape arrays's content.\n * It is wrapped in an array to differentiate value shape types.\n *\n * In the future other value shape formats may be added, likely as objects.\n *\n * @remarks\n * See {@link EncodedNodeShape} for usage.\n */\nexport const EncodedValueShape = Type.Union([\n\tType.Boolean(),\n\tType.Array(Type.Any(), { minItems: 1, maxItems: 1 }),\n\tType.Enum(SpecialField),\n\t// TODO: support delta encoding and/or special node identifier handling\n\t// EncodedCounter,\n]);\nexport type EncodedValueShape = undefined | Static<typeof EncodedValueShape>;\n\nexport const EncodedNodeShape = Type.Object(\n\t{\n\t\t/**\n\t\t * If not provided, inlined in data.\n\t\t */\n\t\ttype: Type.Optional(IdentifierOrIndex),\n\t\tvalue: Type.Optional(EncodedValueShape),\n\t\t/**\n\t\t * Fields with fixed (per key) shapes.\n\t\t * They are encoded in the order they are specified here.\n\t\t * To ensure the order is preserved, this is an array instead of an object with keys.\n\t\t */\n\t\tfields: Type.Optional(Type.Array(EncodedFieldShape)),\n\t\t/**\n\t\t * If undefined, no data. Otherwise, nested array of `[key, ...data]*`\n\t\t * Covers any fields beyond those in `fields`.\n\t\t */\n\t\textraFields: Type.Optional(ShapeIndex),\n\t},\n\t{ additionalProperties: false },\n);\n\n/**\n * Discriminated union that represents the shapes of chunks in the encoded data.\n * \"Chunk\" here refers to a chunk of tree data, rooted at a range of nodes, that is encoded as a\n * single unit in a specific format represented by one of the shapes in this union.\n *\n * The concept of \"chunk\" is same for the tree data in memory and in the encoded wire format.\n * The physical representation of the chunk may differ, but the logical structure remains the same.\n * This is similar to other such concepts in the system.\n *\n * See {@link DiscriminatedUnionDispatcher} for more information on this pattern.\n */\nexport const EncodedChunkShape = Type.Object(\n\t{\n\t\t/**\n\t\t * {@link EncodedNestedArrayShape} union member.\n\t\t */\n\t\ta: Type.Optional(EncodedNestedArrayShape),\n\t\t/**\n\t\t * {@link EncodedInlineArrayShape} union member.\n\t\t */\n\t\tb: Type.Optional(EncodedInlineArrayShape),\n\t\t/**\n\t\t * {@link EncodedNodeShape} union member.\n\t\t */\n\t\tc: Type.Optional(EncodedNodeShape),\n\t\t/**\n\t\t * {@link EncodedAnyShape} union member.\n\t\t */\n\t\td: Type.Optional(EncodedAnyShape),\n\t\t/**\n\t\t * {@link EncodedIncrementalChunkShape} union member.\n\t\t */\n\t\te: Type.Optional(EncodedIncrementalChunkShape),\n\t},\n\tunionOptions,\n);\n\nexport type EncodedChunkShape = Static<typeof EncodedChunkShape>;\n\nexport type EncodedNestedArrayShape = Static<typeof EncodedNestedArrayShape>;\nexport type EncodedInlineArrayShape = Static<typeof EncodedInlineArrayShape>;\nexport type EncodedNodeShape = Static<typeof EncodedNodeShape>;\nexport type EncodedAnyShape = Static<typeof EncodedAnyShape>;\nexport type EncodedIncrementalChunkShape = Static<typeof EncodedIncrementalChunkShape>;\n\nexport const EncodedFieldBatchV1 = EncodedFieldBatchGeneric(\n\tFieldBatchFormatVersion.v1,\n\tEncodedChunkShape,\n);\nexport type EncodedFieldBatchV1 = Static<typeof EncodedFieldBatchV1>;\n\nexport const EncodedFieldBatchV2 = EncodedFieldBatchGeneric(\n\tFieldBatchFormatVersion.v2,\n\tEncodedChunkShape,\n);\nexport type EncodedFieldBatchV2 = Static<typeof EncodedFieldBatchV2>;\n\nexport const EncodedFieldBatch = Type.Union([EncodedFieldBatchV1, EncodedFieldBatchV2]);\nexport type EncodedFieldBatch = Static<typeof EncodedFieldBatch>;\n"]}
@@ -2,8 +2,9 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
- export { EncodedFieldBatch, FieldBatchFormatVersion } from "./format.js";
5
+ export type { EncodedFieldBatch } from "./format.js";
6
+ export { FieldBatchFormatVersion } from "./format.js";
6
7
  export type { FieldBatch } from "./fieldBatch.js";
7
- export { type FieldBatchCodec, makeFieldBatchCodec, type FieldBatchEncodingContext, type IncrementalEncoderDecoder, type IncrementalEncoder, type IncrementalDecoder, type ChunkReferenceId, getCodecTreeForFieldBatchFormat, } from "./codecs.js";
8
+ export { type FieldBatchCodec, fieldBatchCodecBuilder, type FieldBatchEncodingContext, type IncrementalEncoderDecoder, type IncrementalEncoder, type IncrementalDecoder, type ChunkReferenceId, } from "./codecs.js";
8
9
  export { type IncrementalEncodingPolicy, defaultIncrementalEncodingPolicy, } from "./incrementalEncodingPolicy.js";
9
10
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/feature-libraries/chunked-forest/codec/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,iBAAiB,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AACzE,YAAY,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EACN,KAAK,eAAe,EACpB,mBAAmB,EACnB,KAAK,yBAAyB,EAC9B,KAAK,yBAAyB,EAC9B,KAAK,kBAAkB,EACvB,KAAK,kBAAkB,EACvB,KAAK,gBAAgB,EACrB,+BAA+B,GAC/B,MAAM,aAAa,CAAC;AACrB,OAAO,EACN,KAAK,yBAAyB,EAC9B,gCAAgC,GAChC,MAAM,gCAAgC,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/feature-libraries/chunked-forest/codec/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,YAAY,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AACtD,YAAY,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EACN,KAAK,eAAe,EACpB,sBAAsB,EACtB,KAAK,yBAAyB,EAC9B,KAAK,yBAAyB,EAC9B,KAAK,kBAAkB,EACvB,KAAK,kBAAkB,EACvB,KAAK,gBAAgB,GACrB,MAAM,aAAa,CAAC;AACrB,OAAO,EACN,KAAK,yBAAyB,EAC9B,gCAAgC,GAChC,MAAM,gCAAgC,CAAC"}
@@ -2,7 +2,7 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
- export { EncodedFieldBatch, FieldBatchFormatVersion } from "./format.js";
6
- export { makeFieldBatchCodec, getCodecTreeForFieldBatchFormat, } from "./codecs.js";
5
+ export { FieldBatchFormatVersion } from "./format.js";
6
+ export { fieldBatchCodecBuilder, } from "./codecs.js";
7
7
  export { defaultIncrementalEncodingPolicy, } from "./incrementalEncodingPolicy.js";
8
8
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/feature-libraries/chunked-forest/codec/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,iBAAiB,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AAEzE,OAAO,EAEN,mBAAmB,EAMnB,+BAA+B,GAC/B,MAAM,aAAa,CAAC;AACrB,OAAO,EAEN,gCAAgC,GAChC,MAAM,gCAAgC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport { EncodedFieldBatch, FieldBatchFormatVersion } from \"./format.js\";\nexport type { FieldBatch } from \"./fieldBatch.js\";\nexport {\n\ttype FieldBatchCodec,\n\tmakeFieldBatchCodec,\n\ttype FieldBatchEncodingContext,\n\ttype IncrementalEncoderDecoder,\n\ttype IncrementalEncoder,\n\ttype IncrementalDecoder,\n\ttype ChunkReferenceId,\n\tgetCodecTreeForFieldBatchFormat,\n} from \"./codecs.js\";\nexport {\n\ttype IncrementalEncodingPolicy,\n\tdefaultIncrementalEncodingPolicy,\n} from \"./incrementalEncodingPolicy.js\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/feature-libraries/chunked-forest/codec/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AAEtD,OAAO,EAEN,sBAAsB,GAMtB,MAAM,aAAa,CAAC;AACrB,OAAO,EAEN,gCAAgC,GAChC,MAAM,gCAAgC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport type { EncodedFieldBatch } from \"./format.js\";\nexport { FieldBatchFormatVersion } from \"./format.js\";\nexport type { FieldBatch } from \"./fieldBatch.js\";\nexport {\n\ttype FieldBatchCodec,\n\tfieldBatchCodecBuilder,\n\ttype FieldBatchEncodingContext,\n\ttype IncrementalEncoderDecoder,\n\ttype IncrementalEncoder,\n\ttype IncrementalDecoder,\n\ttype ChunkReferenceId,\n} from \"./codecs.js\";\nexport {\n\ttype IncrementalEncodingPolicy,\n\tdefaultIncrementalEncodingPolicy,\n} from \"./incrementalEncodingPolicy.js\";\n"]}
@@ -6,6 +6,6 @@ export { uniformChunk, ChunkShape } from "./uniformChunk.js";
6
6
  export { type TreeChunk, dummyRoot } from "../../core/index.js";
7
7
  export { chunkTree, defaultChunkPolicy, makeTreeChunker, type IChunker, chunkFieldSingle, chunkField, combineChunks, } from "./chunkTree.js";
8
8
  export { buildChunkedForest } from "./chunkedForest.js";
9
- export { EncodedFieldBatch, FieldBatchFormatVersion, getCodecTreeForFieldBatchFormat, type FieldBatch, type FieldBatchCodec, makeFieldBatchCodec, type FieldBatchEncodingContext, type IncrementalEncoderDecoder, type ChunkReferenceId, type IncrementalEncodingPolicy, defaultIncrementalEncodingPolicy, } from "./codec/index.js";
9
+ export { type EncodedFieldBatch, FieldBatchFormatVersion, type FieldBatch, type FieldBatchCodec, fieldBatchCodecBuilder, type FieldBatchEncodingContext, type IncrementalEncoderDecoder, type ChunkReferenceId, type IncrementalEncodingPolicy, defaultIncrementalEncodingPolicy, } from "./codec/index.js";
10
10
  export { emptyChunk } from "./emptyChunk.js";
11
11
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/feature-libraries/chunked-forest/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC7D,OAAO,EAAE,KAAK,SAAS,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAChE,OAAO,EACN,SAAS,EACT,kBAAkB,EAClB,eAAe,EACf,KAAK,QAAQ,EACb,gBAAgB,EAChB,UAAU,EACV,aAAa,GACb,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,EACN,iBAAiB,EACjB,uBAAuB,EACvB,+BAA+B,EAC/B,KAAK,UAAU,EACf,KAAK,eAAe,EACpB,mBAAmB,EACnB,KAAK,yBAAyB,EAC9B,KAAK,yBAAyB,EAC9B,KAAK,gBAAgB,EACrB,KAAK,yBAAyB,EAC9B,gCAAgC,GAChC,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/feature-libraries/chunked-forest/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC7D,OAAO,EAAE,KAAK,SAAS,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAChE,OAAO,EACN,SAAS,EACT,kBAAkB,EAClB,eAAe,EACf,KAAK,QAAQ,EACb,gBAAgB,EAChB,UAAU,EACV,aAAa,GACb,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,EACN,KAAK,iBAAiB,EACtB,uBAAuB,EACvB,KAAK,UAAU,EACf,KAAK,eAAe,EACpB,sBAAsB,EACtB,KAAK,yBAAyB,EAC9B,KAAK,yBAAyB,EAC9B,KAAK,gBAAgB,EACrB,KAAK,yBAAyB,EAC9B,gCAAgC,GAChC,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC"}
@@ -6,6 +6,6 @@ export { uniformChunk, ChunkShape } from "./uniformChunk.js";
6
6
  export { dummyRoot } from "../../core/index.js";
7
7
  export { chunkTree, defaultChunkPolicy, makeTreeChunker, chunkFieldSingle, chunkField, combineChunks, } from "./chunkTree.js";
8
8
  export { buildChunkedForest } from "./chunkedForest.js";
9
- export { EncodedFieldBatch, FieldBatchFormatVersion, getCodecTreeForFieldBatchFormat, makeFieldBatchCodec, defaultIncrementalEncodingPolicy, } from "./codec/index.js";
9
+ export { FieldBatchFormatVersion, fieldBatchCodecBuilder, defaultIncrementalEncodingPolicy, } from "./codec/index.js";
10
10
  export { emptyChunk } from "./emptyChunk.js";
11
11
  //# sourceMappingURL=index.js.map