@fluidframework/tree 2.23.0 → 2.30.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 (619) hide show
  1. package/CHANGELOG.md +38 -0
  2. package/api-report/tree.alpha.api.md +28 -12
  3. package/dist/alpha.d.ts +6 -0
  4. package/dist/core/forest/editableForest.d.ts +1 -14
  5. package/dist/core/forest/editableForest.d.ts.map +1 -1
  6. package/dist/core/forest/editableForest.js +1 -28
  7. package/dist/core/forest/editableForest.js.map +1 -1
  8. package/dist/core/forest/forest.d.ts +16 -3
  9. package/dist/core/forest/forest.d.ts.map +1 -1
  10. package/dist/core/forest/forest.js +4 -1
  11. package/dist/core/forest/forest.js.map +1 -1
  12. package/dist/core/forest/index.d.ts +1 -1
  13. package/dist/core/forest/index.d.ts.map +1 -1
  14. package/dist/core/forest/index.js +1 -2
  15. package/dist/core/forest/index.js.map +1 -1
  16. package/dist/core/index.d.ts +2 -2
  17. package/dist/core/index.d.ts.map +1 -1
  18. package/dist/core/index.js +3 -3
  19. package/dist/core/index.js.map +1 -1
  20. package/dist/core/tree/anchorSet.d.ts +8 -3
  21. package/dist/core/tree/anchorSet.d.ts.map +1 -1
  22. package/dist/core/tree/anchorSet.js +12 -5
  23. package/dist/core/tree/anchorSet.js.map +1 -1
  24. package/dist/core/tree/delta.d.ts +8 -23
  25. package/dist/core/tree/delta.d.ts.map +1 -1
  26. package/dist/core/tree/delta.js.map +1 -1
  27. package/dist/core/tree/deltaUtil.d.ts +3 -3
  28. package/dist/core/tree/deltaUtil.d.ts.map +1 -1
  29. package/dist/core/tree/deltaUtil.js +2 -2
  30. package/dist/core/tree/deltaUtil.js.map +1 -1
  31. package/dist/core/tree/index.d.ts +2 -2
  32. package/dist/core/tree/index.d.ts.map +1 -1
  33. package/dist/core/tree/index.js +2 -1
  34. package/dist/core/tree/index.js.map +1 -1
  35. package/dist/core/tree/pathTree.d.ts +54 -1
  36. package/dist/core/tree/pathTree.d.ts.map +1 -1
  37. package/dist/core/tree/pathTree.js +8 -1
  38. package/dist/core/tree/pathTree.js.map +1 -1
  39. package/dist/core/tree/visitDelta.d.ts +7 -5
  40. package/dist/core/tree/visitDelta.d.ts.map +1 -1
  41. package/dist/core/tree/visitDelta.js +19 -9
  42. package/dist/core/tree/visitDelta.js.map +1 -1
  43. package/dist/core/tree/visitorUtils.d.ts +5 -23
  44. package/dist/core/tree/visitorUtils.d.ts.map +1 -1
  45. package/dist/core/tree/visitorUtils.js +8 -5
  46. package/dist/core/tree/visitorUtils.js.map +1 -1
  47. package/dist/feature-libraries/chunked-forest/basicChunk.d.ts +1 -1
  48. package/dist/feature-libraries/chunked-forest/basicChunk.js +1 -1
  49. package/dist/feature-libraries/chunked-forest/basicChunk.js.map +1 -1
  50. package/dist/feature-libraries/chunked-forest/chunkTree.d.ts +5 -3
  51. package/dist/feature-libraries/chunked-forest/chunkTree.d.ts.map +1 -1
  52. package/dist/feature-libraries/chunked-forest/chunkTree.js +10 -7
  53. package/dist/feature-libraries/chunked-forest/chunkTree.js.map +1 -1
  54. package/dist/feature-libraries/chunked-forest/chunkedForest.d.ts +1 -0
  55. package/dist/feature-libraries/chunked-forest/chunkedForest.d.ts.map +1 -1
  56. package/dist/feature-libraries/chunked-forest/chunkedForest.js +5 -2
  57. package/dist/feature-libraries/chunked-forest/chunkedForest.js.map +1 -1
  58. package/dist/feature-libraries/chunked-forest/codec/codecs.js +2 -2
  59. package/dist/feature-libraries/chunked-forest/codec/codecs.js.map +1 -1
  60. package/dist/feature-libraries/chunked-forest/codec/compressedEncode.d.ts +1 -1
  61. package/dist/feature-libraries/chunked-forest/codec/compressedEncode.js +1 -1
  62. package/dist/feature-libraries/chunked-forest/codec/compressedEncode.js.map +1 -1
  63. package/dist/feature-libraries/chunked-forest/codec/{schemaBasedEncoding.d.ts → schemaBasedEncode.d.ts} +1 -1
  64. package/dist/feature-libraries/chunked-forest/codec/schemaBasedEncode.d.ts.map +1 -0
  65. package/dist/feature-libraries/chunked-forest/codec/{schemaBasedEncoding.js → schemaBasedEncode.js} +1 -1
  66. package/dist/feature-libraries/chunked-forest/codec/schemaBasedEncode.js.map +1 -0
  67. package/dist/feature-libraries/chunked-forest/uniformChunk.d.ts +3 -2
  68. package/dist/feature-libraries/chunked-forest/uniformChunk.d.ts.map +1 -1
  69. package/dist/feature-libraries/chunked-forest/uniformChunk.js +3 -2
  70. package/dist/feature-libraries/chunked-forest/uniformChunk.js.map +1 -1
  71. package/dist/feature-libraries/default-schema/defaultEditBuilder.d.ts +12 -14
  72. package/dist/feature-libraries/default-schema/defaultEditBuilder.d.ts.map +1 -1
  73. package/dist/feature-libraries/default-schema/defaultEditBuilder.js +5 -6
  74. package/dist/feature-libraries/default-schema/defaultEditBuilder.js.map +1 -1
  75. package/dist/feature-libraries/default-schema/index.d.ts +1 -0
  76. package/dist/feature-libraries/default-schema/index.d.ts.map +1 -1
  77. package/dist/feature-libraries/default-schema/index.js +3 -1
  78. package/dist/feature-libraries/default-schema/index.js.map +1 -1
  79. package/dist/feature-libraries/default-schema/mappedEditBuilder.d.ts +21 -0
  80. package/dist/feature-libraries/default-schema/mappedEditBuilder.d.ts.map +1 -0
  81. package/dist/feature-libraries/default-schema/mappedEditBuilder.js +57 -0
  82. package/dist/feature-libraries/default-schema/mappedEditBuilder.js.map +1 -0
  83. package/dist/feature-libraries/deltaUtils.js +1 -1
  84. package/dist/feature-libraries/deltaUtils.js.map +1 -1
  85. package/dist/feature-libraries/flex-tree/context.d.ts +5 -5
  86. package/dist/feature-libraries/flex-tree/context.d.ts.map +1 -1
  87. package/dist/feature-libraries/flex-tree/context.js.map +1 -1
  88. package/dist/feature-libraries/flex-tree/flexTreeTypes.d.ts +2 -2
  89. package/dist/feature-libraries/flex-tree/flexTreeTypes.d.ts.map +1 -1
  90. package/dist/feature-libraries/flex-tree/flexTreeTypes.js.map +1 -1
  91. package/dist/feature-libraries/flex-tree/lazyField.d.ts +5 -4
  92. package/dist/feature-libraries/flex-tree/lazyField.d.ts.map +1 -1
  93. package/dist/feature-libraries/flex-tree/lazyField.js +9 -6
  94. package/dist/feature-libraries/flex-tree/lazyField.js.map +1 -1
  95. package/dist/feature-libraries/forest-summary/forestSummarizer.d.ts.map +1 -1
  96. package/dist/feature-libraries/forest-summary/forestSummarizer.js +4 -5
  97. package/dist/feature-libraries/forest-summary/forestSummarizer.js.map +1 -1
  98. package/dist/feature-libraries/index.d.ts +2 -1
  99. package/dist/feature-libraries/index.d.ts.map +1 -1
  100. package/dist/feature-libraries/index.js +9 -7
  101. package/dist/feature-libraries/index.js.map +1 -1
  102. package/dist/feature-libraries/indexing/anchorTreeIndex.js.map +1 -1
  103. package/dist/feature-libraries/initializeForest.d.ts +18 -0
  104. package/dist/feature-libraries/initializeForest.d.ts.map +1 -0
  105. package/dist/feature-libraries/initializeForest.js +35 -0
  106. package/dist/feature-libraries/initializeForest.js.map +1 -0
  107. package/dist/feature-libraries/modular-schema/modularChangeFamily.d.ts +5 -5
  108. package/dist/feature-libraries/modular-schema/modularChangeFamily.d.ts.map +1 -1
  109. package/dist/feature-libraries/modular-schema/modularChangeFamily.js +9 -15
  110. package/dist/feature-libraries/modular-schema/modularChangeFamily.js.map +1 -1
  111. package/dist/feature-libraries/node-identifier/index.d.ts +8 -0
  112. package/dist/feature-libraries/node-identifier/index.d.ts.map +1 -0
  113. package/dist/feature-libraries/node-identifier/index.js +16 -0
  114. package/dist/feature-libraries/node-identifier/index.js.map +1 -0
  115. package/dist/feature-libraries/node-identifier/mockNodeIdentifierManager.d.ts +22 -0
  116. package/dist/feature-libraries/node-identifier/mockNodeIdentifierManager.d.ts.map +1 -0
  117. package/dist/feature-libraries/{node-key/mockNodeKeyManager.js → node-identifier/mockNodeIdentifierManager.js} +18 -18
  118. package/dist/feature-libraries/node-identifier/mockNodeIdentifierManager.js.map +1 -0
  119. package/dist/feature-libraries/node-identifier/nodeIdentifier.d.ts +38 -0
  120. package/dist/feature-libraries/node-identifier/nodeIdentifier.d.ts.map +1 -0
  121. package/dist/feature-libraries/node-identifier/nodeIdentifier.js +26 -0
  122. package/dist/feature-libraries/node-identifier/nodeIdentifier.js.map +1 -0
  123. package/dist/feature-libraries/node-identifier/nodeIdentifierManager.d.ts +37 -0
  124. package/dist/feature-libraries/node-identifier/nodeIdentifierManager.d.ts.map +1 -0
  125. package/dist/feature-libraries/node-identifier/nodeIdentifierManager.js +48 -0
  126. package/dist/feature-libraries/node-identifier/nodeIdentifierManager.js.map +1 -0
  127. package/dist/feature-libraries/object-forest/objectForest.d.ts +2 -1
  128. package/dist/feature-libraries/object-forest/objectForest.d.ts.map +1 -1
  129. package/dist/feature-libraries/object-forest/objectForest.js +6 -2
  130. package/dist/feature-libraries/object-forest/objectForest.js.map +1 -1
  131. package/dist/feature-libraries/treeCursorUtils.js +1 -1
  132. package/dist/feature-libraries/treeCursorUtils.js.map +1 -1
  133. package/dist/index.d.ts +3 -3
  134. package/dist/index.d.ts.map +1 -1
  135. package/dist/index.js +9 -1
  136. package/dist/index.js.map +1 -1
  137. package/dist/packageVersion.d.ts +1 -1
  138. package/dist/packageVersion.js +1 -1
  139. package/dist/packageVersion.js.map +1 -1
  140. package/dist/shared-tree/checkoutFlexTreeView.d.ts +3 -3
  141. package/dist/shared-tree/checkoutFlexTreeView.d.ts.map +1 -1
  142. package/dist/shared-tree/checkoutFlexTreeView.js.map +1 -1
  143. package/dist/shared-tree/independentView.d.ts.map +1 -1
  144. package/dist/shared-tree/independentView.js +3 -18
  145. package/dist/shared-tree/independentView.js.map +1 -1
  146. package/dist/shared-tree/index.d.ts +1 -1
  147. package/dist/shared-tree/index.d.ts.map +1 -1
  148. package/dist/shared-tree/index.js +2 -1
  149. package/dist/shared-tree/index.js.map +1 -1
  150. package/dist/shared-tree/schematizeTree.d.ts.map +1 -1
  151. package/dist/shared-tree/schematizeTree.js +3 -2
  152. package/dist/shared-tree/schematizeTree.js.map +1 -1
  153. package/dist/shared-tree/schematizingTreeView.d.ts +4 -4
  154. package/dist/shared-tree/schematizingTreeView.d.ts.map +1 -1
  155. package/dist/shared-tree/schematizingTreeView.js.map +1 -1
  156. package/dist/shared-tree/sharedTree.d.ts +1 -0
  157. package/dist/shared-tree/sharedTree.d.ts.map +1 -1
  158. package/dist/shared-tree/sharedTree.js +11 -7
  159. package/dist/shared-tree/sharedTree.js.map +1 -1
  160. package/dist/shared-tree/sharedTreeChangeFamily.d.ts.map +1 -1
  161. package/dist/shared-tree/sharedTreeChangeFamily.js +1 -1
  162. package/dist/shared-tree/sharedTreeChangeFamily.js.map +1 -1
  163. package/dist/shared-tree/sharedTreeEditBuilder.d.ts +1 -2
  164. package/dist/shared-tree/sharedTreeEditBuilder.d.ts.map +1 -1
  165. package/dist/shared-tree/sharedTreeEditBuilder.js +2 -2
  166. package/dist/shared-tree/sharedTreeEditBuilder.js.map +1 -1
  167. package/dist/shared-tree/treeApiAlpha.d.ts +6 -31
  168. package/dist/shared-tree/treeApiAlpha.d.ts.map +1 -1
  169. package/dist/shared-tree/treeApiAlpha.js +3 -18
  170. package/dist/shared-tree/treeApiAlpha.js.map +1 -1
  171. package/dist/shared-tree/treeCheckout.js +1 -1
  172. package/dist/shared-tree/treeCheckout.js.map +1 -1
  173. package/dist/simple-tree/api/conciseTree.d.ts +8 -2
  174. package/dist/simple-tree/api/conciseTree.d.ts.map +1 -1
  175. package/dist/simple-tree/api/conciseTree.js +10 -1
  176. package/dist/simple-tree/api/conciseTree.js.map +1 -1
  177. package/dist/simple-tree/api/create.d.ts +3 -3
  178. package/dist/simple-tree/api/create.d.ts.map +1 -1
  179. package/dist/simple-tree/api/create.js.map +1 -1
  180. package/dist/simple-tree/api/customTree.d.ts +42 -12
  181. package/dist/simple-tree/api/customTree.d.ts.map +1 -1
  182. package/dist/simple-tree/api/customTree.js +30 -2
  183. package/dist/simple-tree/api/customTree.js.map +1 -1
  184. package/dist/simple-tree/api/index.d.ts +4 -3
  185. package/dist/simple-tree/api/index.d.ts.map +1 -1
  186. package/dist/simple-tree/api/index.js +6 -1
  187. package/dist/simple-tree/api/index.js.map +1 -1
  188. package/dist/simple-tree/api/schemaFactory.d.ts +12 -9
  189. package/dist/simple-tree/api/schemaFactory.d.ts.map +1 -1
  190. package/dist/simple-tree/api/schemaFactory.js +16 -26
  191. package/dist/simple-tree/api/schemaFactory.js.map +1 -1
  192. package/dist/simple-tree/api/schemaFactoryAlpha.d.ts +7 -0
  193. package/dist/simple-tree/api/schemaFactoryAlpha.d.ts.map +1 -1
  194. package/dist/simple-tree/api/schemaFactoryAlpha.js +9 -0
  195. package/dist/simple-tree/api/schemaFactoryAlpha.js.map +1 -1
  196. package/dist/simple-tree/api/schemaFromSimple.d.ts +19 -0
  197. package/dist/simple-tree/api/schemaFromSimple.d.ts.map +1 -0
  198. package/dist/simple-tree/api/schemaFromSimple.js +60 -0
  199. package/dist/simple-tree/api/schemaFromSimple.js.map +1 -0
  200. package/dist/simple-tree/api/simpleSchema.d.ts +3 -0
  201. package/dist/simple-tree/api/simpleSchema.d.ts.map +1 -1
  202. package/dist/simple-tree/api/simpleSchema.js.map +1 -1
  203. package/dist/simple-tree/api/tree.d.ts +11 -5
  204. package/dist/simple-tree/api/tree.d.ts.map +1 -1
  205. package/dist/simple-tree/api/tree.js +11 -2
  206. package/dist/simple-tree/api/tree.js.map +1 -1
  207. package/dist/simple-tree/api/treeNodeApi.d.ts.map +1 -1
  208. package/dist/simple-tree/api/treeNodeApi.js +2 -17
  209. package/dist/simple-tree/api/treeNodeApi.js.map +1 -1
  210. package/dist/simple-tree/api/typesUnsafe.d.ts +15 -15
  211. package/dist/simple-tree/api/typesUnsafe.js.map +1 -1
  212. package/dist/simple-tree/api/verboseTree.d.ts +16 -25
  213. package/dist/simple-tree/api/verboseTree.d.ts.map +1 -1
  214. package/dist/simple-tree/api/verboseTree.js +15 -10
  215. package/dist/simple-tree/api/verboseTree.js.map +1 -1
  216. package/dist/simple-tree/core/unhydratedFlexTree.d.ts +2 -2
  217. package/dist/simple-tree/core/unhydratedFlexTree.d.ts.map +1 -1
  218. package/dist/simple-tree/core/unhydratedFlexTree.js.map +1 -1
  219. package/dist/simple-tree/flexList.d.ts +4 -5
  220. package/dist/simple-tree/flexList.d.ts.map +1 -1
  221. package/dist/simple-tree/flexList.js +1 -14
  222. package/dist/simple-tree/flexList.js.map +1 -1
  223. package/dist/simple-tree/index.d.ts +2 -2
  224. package/dist/simple-tree/index.d.ts.map +1 -1
  225. package/dist/simple-tree/index.js +7 -2
  226. package/dist/simple-tree/index.js.map +1 -1
  227. package/dist/simple-tree/objectNode.d.ts.map +1 -1
  228. package/dist/simple-tree/objectNode.js +2 -0
  229. package/dist/simple-tree/objectNode.js.map +1 -1
  230. package/dist/simple-tree/schemaTypes.d.ts +34 -2
  231. package/dist/simple-tree/schemaTypes.d.ts.map +1 -1
  232. package/dist/simple-tree/schemaTypes.js +55 -2
  233. package/dist/simple-tree/schemaTypes.js.map +1 -1
  234. package/dist/simple-tree/toMapTree.d.ts +4 -4
  235. package/dist/simple-tree/toMapTree.d.ts.map +1 -1
  236. package/dist/simple-tree/toMapTree.js.map +1 -1
  237. package/dist/simple-tree/toStoredSchema.d.ts.map +1 -1
  238. package/dist/simple-tree/toStoredSchema.js +1 -5
  239. package/dist/simple-tree/toStoredSchema.js.map +1 -1
  240. package/dist/simple-tree/treeNodeValid.d.ts +7 -1
  241. package/dist/simple-tree/treeNodeValid.d.ts.map +1 -1
  242. package/dist/simple-tree/treeNodeValid.js +13 -5
  243. package/dist/simple-tree/treeNodeValid.js.map +1 -1
  244. package/dist/util/cloneWithReplacements.d.ts +21 -0
  245. package/dist/util/cloneWithReplacements.d.ts.map +1 -0
  246. package/dist/util/cloneWithReplacements.js +38 -0
  247. package/dist/util/cloneWithReplacements.js.map +1 -0
  248. package/dist/util/index.d.ts +1 -0
  249. package/dist/util/index.d.ts.map +1 -1
  250. package/dist/util/index.js +3 -1
  251. package/dist/util/index.js.map +1 -1
  252. package/dist/util/referenceCounting.d.ts +18 -0
  253. package/dist/util/referenceCounting.d.ts.map +1 -1
  254. package/dist/util/referenceCounting.js.map +1 -1
  255. package/lib/alpha.d.ts +6 -0
  256. package/lib/core/forest/editableForest.d.ts +1 -14
  257. package/lib/core/forest/editableForest.d.ts.map +1 -1
  258. package/lib/core/forest/editableForest.js +0 -26
  259. package/lib/core/forest/editableForest.js.map +1 -1
  260. package/lib/core/forest/forest.d.ts +16 -3
  261. package/lib/core/forest/forest.d.ts.map +1 -1
  262. package/lib/core/forest/forest.js +4 -1
  263. package/lib/core/forest/forest.js.map +1 -1
  264. package/lib/core/forest/index.d.ts +1 -1
  265. package/lib/core/forest/index.d.ts.map +1 -1
  266. package/lib/core/forest/index.js +1 -1
  267. package/lib/core/forest/index.js.map +1 -1
  268. package/lib/core/index.d.ts +2 -2
  269. package/lib/core/index.d.ts.map +1 -1
  270. package/lib/core/index.js +2 -2
  271. package/lib/core/index.js.map +1 -1
  272. package/lib/core/tree/anchorSet.d.ts +8 -3
  273. package/lib/core/tree/anchorSet.d.ts.map +1 -1
  274. package/lib/core/tree/anchorSet.js +12 -5
  275. package/lib/core/tree/anchorSet.js.map +1 -1
  276. package/lib/core/tree/delta.d.ts +8 -23
  277. package/lib/core/tree/delta.d.ts.map +1 -1
  278. package/lib/core/tree/delta.js.map +1 -1
  279. package/lib/core/tree/deltaUtil.d.ts +3 -3
  280. package/lib/core/tree/deltaUtil.d.ts.map +1 -1
  281. package/lib/core/tree/deltaUtil.js +2 -2
  282. package/lib/core/tree/deltaUtil.js.map +1 -1
  283. package/lib/core/tree/index.d.ts +2 -2
  284. package/lib/core/tree/index.d.ts.map +1 -1
  285. package/lib/core/tree/index.js +1 -1
  286. package/lib/core/tree/index.js.map +1 -1
  287. package/lib/core/tree/pathTree.d.ts +54 -1
  288. package/lib/core/tree/pathTree.d.ts.map +1 -1
  289. package/lib/core/tree/pathTree.js +6 -0
  290. package/lib/core/tree/pathTree.js.map +1 -1
  291. package/lib/core/tree/visitDelta.d.ts +7 -5
  292. package/lib/core/tree/visitDelta.d.ts.map +1 -1
  293. package/lib/core/tree/visitDelta.js +19 -9
  294. package/lib/core/tree/visitDelta.js.map +1 -1
  295. package/lib/core/tree/visitorUtils.d.ts +5 -23
  296. package/lib/core/tree/visitorUtils.d.ts.map +1 -1
  297. package/lib/core/tree/visitorUtils.js +8 -5
  298. package/lib/core/tree/visitorUtils.js.map +1 -1
  299. package/lib/feature-libraries/chunked-forest/basicChunk.d.ts +1 -1
  300. package/lib/feature-libraries/chunked-forest/basicChunk.js +1 -1
  301. package/lib/feature-libraries/chunked-forest/basicChunk.js.map +1 -1
  302. package/lib/feature-libraries/chunked-forest/chunkTree.d.ts +5 -3
  303. package/lib/feature-libraries/chunked-forest/chunkTree.d.ts.map +1 -1
  304. package/lib/feature-libraries/chunked-forest/chunkTree.js +11 -8
  305. package/lib/feature-libraries/chunked-forest/chunkTree.js.map +1 -1
  306. package/lib/feature-libraries/chunked-forest/chunkedForest.d.ts +1 -0
  307. package/lib/feature-libraries/chunked-forest/chunkedForest.d.ts.map +1 -1
  308. package/lib/feature-libraries/chunked-forest/chunkedForest.js +6 -3
  309. package/lib/feature-libraries/chunked-forest/chunkedForest.js.map +1 -1
  310. package/lib/feature-libraries/chunked-forest/codec/codecs.js +1 -1
  311. package/lib/feature-libraries/chunked-forest/codec/codecs.js.map +1 -1
  312. package/lib/feature-libraries/chunked-forest/codec/compressedEncode.d.ts +1 -1
  313. package/lib/feature-libraries/chunked-forest/codec/compressedEncode.js +1 -1
  314. package/lib/feature-libraries/chunked-forest/codec/compressedEncode.js.map +1 -1
  315. package/lib/feature-libraries/chunked-forest/codec/{schemaBasedEncoding.d.ts → schemaBasedEncode.d.ts} +1 -1
  316. package/lib/feature-libraries/chunked-forest/codec/schemaBasedEncode.d.ts.map +1 -0
  317. package/lib/feature-libraries/chunked-forest/codec/{schemaBasedEncoding.js → schemaBasedEncode.js} +1 -1
  318. package/lib/feature-libraries/chunked-forest/codec/schemaBasedEncode.js.map +1 -0
  319. package/lib/feature-libraries/chunked-forest/uniformChunk.d.ts +3 -2
  320. package/lib/feature-libraries/chunked-forest/uniformChunk.d.ts.map +1 -1
  321. package/lib/feature-libraries/chunked-forest/uniformChunk.js +3 -2
  322. package/lib/feature-libraries/chunked-forest/uniformChunk.js.map +1 -1
  323. package/lib/feature-libraries/default-schema/defaultEditBuilder.d.ts +12 -14
  324. package/lib/feature-libraries/default-schema/defaultEditBuilder.d.ts.map +1 -1
  325. package/lib/feature-libraries/default-schema/defaultEditBuilder.js +5 -6
  326. package/lib/feature-libraries/default-schema/defaultEditBuilder.js.map +1 -1
  327. package/lib/feature-libraries/default-schema/index.d.ts +1 -0
  328. package/lib/feature-libraries/default-schema/index.d.ts.map +1 -1
  329. package/lib/feature-libraries/default-schema/index.js +1 -0
  330. package/lib/feature-libraries/default-schema/index.js.map +1 -1
  331. package/lib/feature-libraries/default-schema/mappedEditBuilder.d.ts +21 -0
  332. package/lib/feature-libraries/default-schema/mappedEditBuilder.d.ts.map +1 -0
  333. package/lib/feature-libraries/default-schema/mappedEditBuilder.js +53 -0
  334. package/lib/feature-libraries/default-schema/mappedEditBuilder.js.map +1 -0
  335. package/lib/feature-libraries/deltaUtils.js +1 -1
  336. package/lib/feature-libraries/deltaUtils.js.map +1 -1
  337. package/lib/feature-libraries/flex-tree/context.d.ts +5 -5
  338. package/lib/feature-libraries/flex-tree/context.d.ts.map +1 -1
  339. package/lib/feature-libraries/flex-tree/context.js.map +1 -1
  340. package/lib/feature-libraries/flex-tree/flexTreeTypes.d.ts +2 -2
  341. package/lib/feature-libraries/flex-tree/flexTreeTypes.d.ts.map +1 -1
  342. package/lib/feature-libraries/flex-tree/flexTreeTypes.js.map +1 -1
  343. package/lib/feature-libraries/flex-tree/lazyField.d.ts +5 -4
  344. package/lib/feature-libraries/flex-tree/lazyField.d.ts.map +1 -1
  345. package/lib/feature-libraries/flex-tree/lazyField.js +11 -8
  346. package/lib/feature-libraries/flex-tree/lazyField.js.map +1 -1
  347. package/lib/feature-libraries/forest-summary/forestSummarizer.d.ts.map +1 -1
  348. package/lib/feature-libraries/forest-summary/forestSummarizer.js +6 -7
  349. package/lib/feature-libraries/forest-summary/forestSummarizer.js.map +1 -1
  350. package/lib/feature-libraries/index.d.ts +2 -1
  351. package/lib/feature-libraries/index.d.ts.map +1 -1
  352. package/lib/feature-libraries/index.js +2 -1
  353. package/lib/feature-libraries/index.js.map +1 -1
  354. package/lib/feature-libraries/indexing/anchorTreeIndex.js.map +1 -1
  355. package/lib/feature-libraries/initializeForest.d.ts +18 -0
  356. package/lib/feature-libraries/initializeForest.d.ts.map +1 -0
  357. package/lib/feature-libraries/initializeForest.js +31 -0
  358. package/lib/feature-libraries/initializeForest.js.map +1 -0
  359. package/lib/feature-libraries/modular-schema/modularChangeFamily.d.ts +5 -5
  360. package/lib/feature-libraries/modular-schema/modularChangeFamily.d.ts.map +1 -1
  361. package/lib/feature-libraries/modular-schema/modularChangeFamily.js +10 -16
  362. package/lib/feature-libraries/modular-schema/modularChangeFamily.js.map +1 -1
  363. package/lib/feature-libraries/node-identifier/index.d.ts +8 -0
  364. package/lib/feature-libraries/node-identifier/index.d.ts.map +1 -0
  365. package/lib/feature-libraries/node-identifier/index.js +8 -0
  366. package/lib/feature-libraries/node-identifier/index.js.map +1 -0
  367. package/lib/feature-libraries/node-identifier/mockNodeIdentifierManager.d.ts +22 -0
  368. package/lib/feature-libraries/node-identifier/mockNodeIdentifierManager.d.ts.map +1 -0
  369. package/lib/feature-libraries/{node-key/mockNodeKeyManager.js → node-identifier/mockNodeIdentifierManager.js} +16 -16
  370. package/lib/feature-libraries/node-identifier/mockNodeIdentifierManager.js.map +1 -0
  371. package/lib/feature-libraries/node-identifier/nodeIdentifier.d.ts +38 -0
  372. package/lib/feature-libraries/node-identifier/nodeIdentifier.d.ts.map +1 -0
  373. package/lib/feature-libraries/node-identifier/nodeIdentifier.js +22 -0
  374. package/lib/feature-libraries/node-identifier/nodeIdentifier.js.map +1 -0
  375. package/lib/feature-libraries/node-identifier/nodeIdentifierManager.d.ts +37 -0
  376. package/lib/feature-libraries/node-identifier/nodeIdentifierManager.d.ts.map +1 -0
  377. package/lib/feature-libraries/node-identifier/nodeIdentifierManager.js +43 -0
  378. package/lib/feature-libraries/node-identifier/nodeIdentifierManager.js.map +1 -0
  379. package/lib/feature-libraries/object-forest/objectForest.d.ts +2 -1
  380. package/lib/feature-libraries/object-forest/objectForest.d.ts.map +1 -1
  381. package/lib/feature-libraries/object-forest/objectForest.js +6 -2
  382. package/lib/feature-libraries/object-forest/objectForest.js.map +1 -1
  383. package/lib/feature-libraries/treeCursorUtils.js +1 -1
  384. package/lib/feature-libraries/treeCursorUtils.js.map +1 -1
  385. package/lib/index.d.ts +3 -3
  386. package/lib/index.d.ts.map +1 -1
  387. package/lib/index.js +2 -1
  388. package/lib/index.js.map +1 -1
  389. package/lib/packageVersion.d.ts +1 -1
  390. package/lib/packageVersion.js +1 -1
  391. package/lib/packageVersion.js.map +1 -1
  392. package/lib/shared-tree/checkoutFlexTreeView.d.ts +3 -3
  393. package/lib/shared-tree/checkoutFlexTreeView.d.ts.map +1 -1
  394. package/lib/shared-tree/checkoutFlexTreeView.js.map +1 -1
  395. package/lib/shared-tree/independentView.d.ts.map +1 -1
  396. package/lib/shared-tree/independentView.js +5 -20
  397. package/lib/shared-tree/independentView.js.map +1 -1
  398. package/lib/shared-tree/index.d.ts +1 -1
  399. package/lib/shared-tree/index.d.ts.map +1 -1
  400. package/lib/shared-tree/index.js +1 -1
  401. package/lib/shared-tree/index.js.map +1 -1
  402. package/lib/shared-tree/schematizeTree.d.ts.map +1 -1
  403. package/lib/shared-tree/schematizeTree.js +3 -2
  404. package/lib/shared-tree/schematizeTree.js.map +1 -1
  405. package/lib/shared-tree/schematizingTreeView.d.ts +4 -4
  406. package/lib/shared-tree/schematizingTreeView.d.ts.map +1 -1
  407. package/lib/shared-tree/schematizingTreeView.js.map +1 -1
  408. package/lib/shared-tree/sharedTree.d.ts +1 -0
  409. package/lib/shared-tree/sharedTree.d.ts.map +1 -1
  410. package/lib/shared-tree/sharedTree.js +9 -6
  411. package/lib/shared-tree/sharedTree.js.map +1 -1
  412. package/lib/shared-tree/sharedTreeChangeFamily.d.ts.map +1 -1
  413. package/lib/shared-tree/sharedTreeChangeFamily.js +1 -1
  414. package/lib/shared-tree/sharedTreeChangeFamily.js.map +1 -1
  415. package/lib/shared-tree/sharedTreeEditBuilder.d.ts +1 -2
  416. package/lib/shared-tree/sharedTreeEditBuilder.d.ts.map +1 -1
  417. package/lib/shared-tree/sharedTreeEditBuilder.js +2 -2
  418. package/lib/shared-tree/sharedTreeEditBuilder.js.map +1 -1
  419. package/lib/shared-tree/treeApiAlpha.d.ts +6 -31
  420. package/lib/shared-tree/treeApiAlpha.d.ts.map +1 -1
  421. package/lib/shared-tree/treeApiAlpha.js +3 -18
  422. package/lib/shared-tree/treeApiAlpha.js.map +1 -1
  423. package/lib/shared-tree/treeCheckout.js +2 -2
  424. package/lib/shared-tree/treeCheckout.js.map +1 -1
  425. package/lib/simple-tree/api/conciseTree.d.ts +8 -2
  426. package/lib/simple-tree/api/conciseTree.d.ts.map +1 -1
  427. package/lib/simple-tree/api/conciseTree.js +9 -1
  428. package/lib/simple-tree/api/conciseTree.js.map +1 -1
  429. package/lib/simple-tree/api/create.d.ts +3 -3
  430. package/lib/simple-tree/api/create.d.ts.map +1 -1
  431. package/lib/simple-tree/api/create.js.map +1 -1
  432. package/lib/simple-tree/api/customTree.d.ts +42 -12
  433. package/lib/simple-tree/api/customTree.d.ts.map +1 -1
  434. package/lib/simple-tree/api/customTree.js +29 -2
  435. package/lib/simple-tree/api/customTree.js.map +1 -1
  436. package/lib/simple-tree/api/index.d.ts +4 -3
  437. package/lib/simple-tree/api/index.d.ts.map +1 -1
  438. package/lib/simple-tree/api/index.js +4 -3
  439. package/lib/simple-tree/api/index.js.map +1 -1
  440. package/lib/simple-tree/api/schemaFactory.d.ts +12 -9
  441. package/lib/simple-tree/api/schemaFactory.d.ts.map +1 -1
  442. package/lib/simple-tree/api/schemaFactory.js +14 -23
  443. package/lib/simple-tree/api/schemaFactory.js.map +1 -1
  444. package/lib/simple-tree/api/schemaFactoryAlpha.d.ts +7 -0
  445. package/lib/simple-tree/api/schemaFactoryAlpha.d.ts.map +1 -1
  446. package/lib/simple-tree/api/schemaFactoryAlpha.js +9 -0
  447. package/lib/simple-tree/api/schemaFactoryAlpha.js.map +1 -1
  448. package/lib/simple-tree/api/schemaFromSimple.d.ts +19 -0
  449. package/lib/simple-tree/api/schemaFromSimple.d.ts.map +1 -0
  450. package/lib/simple-tree/api/schemaFromSimple.js +56 -0
  451. package/lib/simple-tree/api/schemaFromSimple.js.map +1 -0
  452. package/lib/simple-tree/api/simpleSchema.d.ts +3 -0
  453. package/lib/simple-tree/api/simpleSchema.d.ts.map +1 -1
  454. package/lib/simple-tree/api/simpleSchema.js.map +1 -1
  455. package/lib/simple-tree/api/tree.d.ts +11 -5
  456. package/lib/simple-tree/api/tree.d.ts.map +1 -1
  457. package/lib/simple-tree/api/tree.js +12 -3
  458. package/lib/simple-tree/api/tree.js.map +1 -1
  459. package/lib/simple-tree/api/treeNodeApi.d.ts.map +1 -1
  460. package/lib/simple-tree/api/treeNodeApi.js +4 -19
  461. package/lib/simple-tree/api/treeNodeApi.js.map +1 -1
  462. package/lib/simple-tree/api/typesUnsafe.d.ts +15 -15
  463. package/lib/simple-tree/api/typesUnsafe.js.map +1 -1
  464. package/lib/simple-tree/api/verboseTree.d.ts +16 -25
  465. package/lib/simple-tree/api/verboseTree.d.ts.map +1 -1
  466. package/lib/simple-tree/api/verboseTree.js +14 -10
  467. package/lib/simple-tree/api/verboseTree.js.map +1 -1
  468. package/lib/simple-tree/core/unhydratedFlexTree.d.ts +2 -2
  469. package/lib/simple-tree/core/unhydratedFlexTree.d.ts.map +1 -1
  470. package/lib/simple-tree/core/unhydratedFlexTree.js.map +1 -1
  471. package/lib/simple-tree/flexList.d.ts +4 -5
  472. package/lib/simple-tree/flexList.d.ts.map +1 -1
  473. package/lib/simple-tree/flexList.js +0 -12
  474. package/lib/simple-tree/flexList.js.map +1 -1
  475. package/lib/simple-tree/index.d.ts +2 -2
  476. package/lib/simple-tree/index.d.ts.map +1 -1
  477. package/lib/simple-tree/index.js +2 -2
  478. package/lib/simple-tree/index.js.map +1 -1
  479. package/lib/simple-tree/objectNode.d.ts.map +1 -1
  480. package/lib/simple-tree/objectNode.js +2 -0
  481. package/lib/simple-tree/objectNode.js.map +1 -1
  482. package/lib/simple-tree/schemaTypes.d.ts +34 -2
  483. package/lib/simple-tree/schemaTypes.d.ts.map +1 -1
  484. package/lib/simple-tree/schemaTypes.js +54 -3
  485. package/lib/simple-tree/schemaTypes.js.map +1 -1
  486. package/lib/simple-tree/toMapTree.d.ts +4 -4
  487. package/lib/simple-tree/toMapTree.d.ts.map +1 -1
  488. package/lib/simple-tree/toMapTree.js.map +1 -1
  489. package/lib/simple-tree/toStoredSchema.d.ts.map +1 -1
  490. package/lib/simple-tree/toStoredSchema.js +3 -7
  491. package/lib/simple-tree/toStoredSchema.js.map +1 -1
  492. package/lib/simple-tree/treeNodeValid.d.ts +7 -1
  493. package/lib/simple-tree/treeNodeValid.d.ts.map +1 -1
  494. package/lib/simple-tree/treeNodeValid.js +13 -5
  495. package/lib/simple-tree/treeNodeValid.js.map +1 -1
  496. package/lib/util/cloneWithReplacements.d.ts +21 -0
  497. package/lib/util/cloneWithReplacements.d.ts.map +1 -0
  498. package/lib/util/cloneWithReplacements.js +34 -0
  499. package/lib/util/cloneWithReplacements.js.map +1 -0
  500. package/lib/util/index.d.ts +1 -0
  501. package/lib/util/index.d.ts.map +1 -1
  502. package/lib/util/index.js +1 -0
  503. package/lib/util/index.js.map +1 -1
  504. package/lib/util/referenceCounting.d.ts +18 -0
  505. package/lib/util/referenceCounting.d.ts.map +1 -1
  506. package/lib/util/referenceCounting.js.map +1 -1
  507. package/package.json +22 -22
  508. package/src/core/forest/editableForest.ts +1 -52
  509. package/src/core/forest/forest.ts +17 -2
  510. package/src/core/forest/index.ts +0 -1
  511. package/src/core/index.ts +4 -2
  512. package/src/core/tree/anchorSet.ts +41 -10
  513. package/src/core/tree/delta.ts +8 -25
  514. package/src/core/tree/deltaUtil.ts +5 -5
  515. package/src/core/tree/index.ts +4 -1
  516. package/src/core/tree/pathTree.ts +72 -1
  517. package/src/core/tree/visitDelta.ts +38 -17
  518. package/src/core/tree/visitorUtils.ts +22 -36
  519. package/src/feature-libraries/chunked-forest/basicChunk.ts +1 -1
  520. package/src/feature-libraries/chunked-forest/chunkTree.ts +19 -8
  521. package/src/feature-libraries/chunked-forest/chunkedForest.ts +9 -4
  522. package/src/feature-libraries/chunked-forest/codec/README.md +3 -3
  523. package/src/feature-libraries/chunked-forest/codec/codecs.ts +1 -1
  524. package/src/feature-libraries/chunked-forest/codec/compressedEncode.ts +1 -1
  525. package/src/feature-libraries/chunked-forest/uniformChunk.ts +3 -2
  526. package/src/feature-libraries/default-schema/defaultEditBuilder.ts +21 -38
  527. package/src/feature-libraries/default-schema/index.ts +2 -0
  528. package/src/feature-libraries/default-schema/mappedEditBuilder.ts +68 -0
  529. package/src/feature-libraries/deltaUtils.ts +1 -1
  530. package/src/feature-libraries/flex-tree/context.ts +4 -4
  531. package/src/feature-libraries/flex-tree/flexTreeTypes.ts +2 -2
  532. package/src/feature-libraries/flex-tree/lazyField.ts +19 -10
  533. package/src/feature-libraries/forest-summary/forestSummarizer.ts +5 -9
  534. package/src/feature-libraries/index.ts +10 -8
  535. package/src/feature-libraries/indexing/anchorTreeIndex.ts +2 -2
  536. package/src/feature-libraries/initializeForest.ts +55 -0
  537. package/src/feature-libraries/modular-schema/modularChangeFamily.ts +12 -28
  538. package/src/feature-libraries/node-identifier/README.md +11 -0
  539. package/src/feature-libraries/node-identifier/index.ts +17 -0
  540. package/src/feature-libraries/node-identifier/mockNodeIdentifierManager.ts +59 -0
  541. package/src/feature-libraries/node-identifier/nodeIdentifier.ts +50 -0
  542. package/src/feature-libraries/node-identifier/nodeIdentifierManager.ts +95 -0
  543. package/src/feature-libraries/object-forest/objectForest.ts +10 -3
  544. package/src/feature-libraries/treeCursorUtils.ts +1 -1
  545. package/src/index.ts +17 -10
  546. package/src/packageVersion.ts +1 -1
  547. package/src/shared-tree/checkoutFlexTreeView.ts +2 -2
  548. package/src/shared-tree/independentView.ts +5 -29
  549. package/src/shared-tree/index.ts +1 -0
  550. package/src/shared-tree/schematizeTree.ts +3 -2
  551. package/src/shared-tree/schematizingTreeView.ts +3 -3
  552. package/src/shared-tree/sharedTree.ts +13 -9
  553. package/src/shared-tree/sharedTreeChangeFamily.ts +0 -1
  554. package/src/shared-tree/sharedTreeEditBuilder.ts +5 -11
  555. package/src/shared-tree/treeApiAlpha.ts +15 -78
  556. package/src/shared-tree/treeCheckout.ts +2 -2
  557. package/src/simple-tree/api/conciseTree.ts +25 -8
  558. package/src/simple-tree/api/create.ts +3 -3
  559. package/src/simple-tree/api/customTree.ts +59 -16
  560. package/src/simple-tree/api/index.ts +10 -1
  561. package/src/simple-tree/api/schemaFactory.ts +18 -32
  562. package/src/simple-tree/api/schemaFactoryAlpha.ts +12 -0
  563. package/src/simple-tree/api/schemaFromSimple.ts +68 -0
  564. package/src/simple-tree/api/simpleSchema.ts +10 -0
  565. package/src/simple-tree/api/tree.ts +13 -8
  566. package/src/simple-tree/api/treeNodeApi.ts +4 -17
  567. package/src/simple-tree/api/typesUnsafe.ts +15 -15
  568. package/src/simple-tree/api/verboseTree.ts +43 -55
  569. package/src/simple-tree/core/unhydratedFlexTree.ts +2 -2
  570. package/src/simple-tree/flexList.ts +4 -14
  571. package/src/simple-tree/index.ts +6 -0
  572. package/src/simple-tree/objectNode.ts +3 -0
  573. package/src/simple-tree/schemaTypes.ts +70 -4
  574. package/src/simple-tree/toMapTree.ts +6 -6
  575. package/src/simple-tree/toStoredSchema.ts +3 -6
  576. package/src/simple-tree/treeNodeValid.ts +16 -5
  577. package/src/util/cloneWithReplacements.ts +41 -0
  578. package/src/util/index.ts +2 -0
  579. package/src/util/referenceCounting.ts +18 -1
  580. package/dist/feature-libraries/chunked-forest/codec/schemaBasedEncoding.d.ts.map +0 -1
  581. package/dist/feature-libraries/chunked-forest/codec/schemaBasedEncoding.js.map +0 -1
  582. package/dist/feature-libraries/node-key/index.d.ts +0 -8
  583. package/dist/feature-libraries/node-key/index.d.ts.map +0 -1
  584. package/dist/feature-libraries/node-key/index.js +0 -16
  585. package/dist/feature-libraries/node-key/index.js.map +0 -1
  586. package/dist/feature-libraries/node-key/mockNodeKeyManager.d.ts +0 -22
  587. package/dist/feature-libraries/node-key/mockNodeKeyManager.d.ts.map +0 -1
  588. package/dist/feature-libraries/node-key/mockNodeKeyManager.js.map +0 -1
  589. package/dist/feature-libraries/node-key/nodeKey.d.ts +0 -38
  590. package/dist/feature-libraries/node-key/nodeKey.d.ts.map +0 -1
  591. package/dist/feature-libraries/node-key/nodeKey.js +0 -26
  592. package/dist/feature-libraries/node-key/nodeKey.js.map +0 -1
  593. package/dist/feature-libraries/node-key/nodeKeyManager.d.ts +0 -37
  594. package/dist/feature-libraries/node-key/nodeKeyManager.d.ts.map +0 -1
  595. package/dist/feature-libraries/node-key/nodeKeyManager.js +0 -48
  596. package/dist/feature-libraries/node-key/nodeKeyManager.js.map +0 -1
  597. package/lib/feature-libraries/chunked-forest/codec/schemaBasedEncoding.d.ts.map +0 -1
  598. package/lib/feature-libraries/chunked-forest/codec/schemaBasedEncoding.js.map +0 -1
  599. package/lib/feature-libraries/node-key/index.d.ts +0 -8
  600. package/lib/feature-libraries/node-key/index.d.ts.map +0 -1
  601. package/lib/feature-libraries/node-key/index.js +0 -8
  602. package/lib/feature-libraries/node-key/index.js.map +0 -1
  603. package/lib/feature-libraries/node-key/mockNodeKeyManager.d.ts +0 -22
  604. package/lib/feature-libraries/node-key/mockNodeKeyManager.d.ts.map +0 -1
  605. package/lib/feature-libraries/node-key/mockNodeKeyManager.js.map +0 -1
  606. package/lib/feature-libraries/node-key/nodeKey.d.ts +0 -38
  607. package/lib/feature-libraries/node-key/nodeKey.d.ts.map +0 -1
  608. package/lib/feature-libraries/node-key/nodeKey.js +0 -22
  609. package/lib/feature-libraries/node-key/nodeKey.js.map +0 -1
  610. package/lib/feature-libraries/node-key/nodeKeyManager.d.ts +0 -37
  611. package/lib/feature-libraries/node-key/nodeKeyManager.d.ts.map +0 -1
  612. package/lib/feature-libraries/node-key/nodeKeyManager.js +0 -43
  613. package/lib/feature-libraries/node-key/nodeKeyManager.js.map +0 -1
  614. package/src/feature-libraries/node-key/README.md +0 -11
  615. package/src/feature-libraries/node-key/index.ts +0 -17
  616. package/src/feature-libraries/node-key/mockNodeKeyManager.ts +0 -54
  617. package/src/feature-libraries/node-key/nodeKey.ts +0 -47
  618. package/src/feature-libraries/node-key/nodeKeyManager.ts +0 -93
  619. /package/src/feature-libraries/chunked-forest/codec/{schemaBasedEncoding.ts → schemaBasedEncode.ts} +0 -0
@@ -1 +1 @@
1
- {"version":3,"file":"sharedTreeChangeFamily.js","sourceRoot":"","sources":["../../src/shared-tree/sharedTreeChangeFamily.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAG7D,OAAO,EASN,eAAe,GACf,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAEN,mBAAmB,EAInB,uBAAuB,EACvB,UAAU,EACV,4BAA4B,GAC5B,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAGN,cAAc,EACd,IAAI,EACJ,SAAS,EACT,iBAAiB,GACjB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAAE,+BAA+B,EAAE,MAAM,6BAA6B,CAAC;AAE9E,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAGnE;;;;GAIG;AACH,MAAM,OAAO,sBAAsB;IAYlC,YACC,gBAAkC,EAClC,eAAgC,EAChC,YAA2B,EAC3B,wBAAkD,EACjC,YAA4B;QAA5B,iBAAY,GAAZ,YAAY,CAAgB;QAE7C,MAAM,kBAAkB,G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GAAG,EAAE,CAAC;IAC5E,SAAS,0BAA0B,CAAC,EAAuB;QAC1D,cAAc,CAAC,aAAa,EAAE,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,CAAC;QAClD,OAAO,eAAe,CAAC,EAAE,CAAC,CAAC;IAC5B,CAAC;IACD,QAAQ,CAAC,CAAC,mBAAmB,CAC5B,QAAuC;QAEvC,KAAK,MAAM,EAAE,IAAI,QAAQ,EAAE,CAAC;YAC3B,IAAI,CAAC,iBAAiB,CAAC,aAAa,EAAE,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC;gBAC3D,MAAM,EAAE,CAAC;YACV,CAAC;QACF,CAAC;IACF,CAAC;IACD,IAAI,iBAAiB,GAAG,IAAI,CAAC;IAC7B,OAAO,cAAc,CAAC,MAAM,EAAE,CAAC,UAAU,EAAE,EAAE;QAC5C,MAAM,YAAY,GAAG,kCAAkC,CAAC,UAAU,CAAC,CAAC;QACpE,IAAI,iBAAiB,EAAE,CAAC;YACvB,iBAAiB,GAAG,KAAK,CAAC;YAC1B,OAAO,0BAA0B,CAChC,UAAU,EACV,0BAA0B,EAC1B,YAAY,EACZ,IAAI,CACJ,CAAC;QACH,CAAC;aAAM,CAAC;YACP,OAAO,0BAA0B,CAChC,UAAU,EACV,0BAA0B,EAC1B,mBAAmB,CAAC,YAAY,CAAC,EACjC,KAAK,CACL,CAAC;QACH,CAAC;IACF,CAAC,CAAC,CAAC;AACJ,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\n\nimport type { ICodecFamily, ICodecOptions } from \"../codec/index.js\";\nimport {\n\ttype ChangeEncodingContext,\n\ttype ChangeFamily,\n\ttype ChangeRebaser,\n\ttype DeltaDetachedNodeId,\n\ttype RevisionMetadataSource,\n\ttype RevisionTag,\n\ttype RevisionTagCodec,\n\ttype TaggedChange,\n\tmapTaggedChange,\n} from \"../core/index.js\";\nimport {\n\ttype FieldBatchCodec,\n\tModularChangeFamily,\n\ttype ModularChangeset,\n\ttype TreeChunk,\n\ttype TreeCompressionStrategy,\n\tfieldKindConfigurations,\n\tfieldKinds,\n\tmakeModularChangeCodecFamily,\n} from \"../feature-libraries/index.js\";\nimport {\n\ttype Mutable,\n\ttype NestedSet,\n\taddToNestedSet,\n\tfail,\n\thasSingle,\n\tnestedSetContains,\n} from \"../util/index.js\";\n\nimport { makeSharedTreeChangeCodecFamily } from \"./sharedTreeChangeCodecs.js\";\nimport type { SharedTreeChange } from \"./sharedTreeChangeTypes.js\";\nimport { SharedTreeEditBuilder } from \"./sharedTreeEditBuilder.js\";\nimport type { IIdCompressor } from \"@fluidframework/id-compressor\";\n\n/**\n * Implementation of {@link ChangeFamily} that combines edits to fields and schema changes.\n *\n * @sealed\n */\nexport class SharedTreeChangeFamily\n\timplements\n\t\tChangeFamily<SharedTreeEditBuilder, SharedTreeChange>,\n\t\tChangeRebaser<SharedTreeChange>\n{\n\tpublic static readonly emptyChange: SharedTreeChange = {\n\t\tchanges: [],\n\t};\n\n\tpublic readonly codecs: ICodecFamily<SharedTreeChange, ChangeEncodingContext>;\n\tprivate readonly modularChangeFamily: ModularChangeFamily;\n\n\tpublic constructor(\n\t\trevisionTagCodec: RevisionTagCodec,\n\t\tfieldBatchCodec: FieldBatchCodec,\n\t\tcodecOptions: ICodecOptions,\n\t\tchunkCompressionStrategy?: TreeCompressionStrategy,\n\t\tprivate readonly idCompressor?: IIdCompressor,\n\t) {\n\t\tconst modularChangeCodec = makeModularChangeCodecFamily(\n\t\t\tfieldKindConfigurations,\n\t\t\trevisionTagCodec,\n\t\t\tfieldBatchCodec,\n\t\t\tcodecOptions,\n\t\t\tchunkCompressionStrategy,\n\t\t);\n\t\tthis.modularChangeFamily = new ModularChangeFamily(fieldKinds, modularChangeCodec);\n\t\tthis.codecs = makeSharedTreeChangeCodecFamily(\n\t\t\tthis.modularChangeFamily.codecs,\n\t\t\tcodecOptions,\n\t\t);\n\t}\n\n\tpublic buildEditor(\n\t\tmintRevisionTag: () => RevisionTag,\n\t\tchangeReceiver: (change: TaggedChange<SharedTreeChange>) => void,\n\t): SharedTreeEditBuilder {\n\t\treturn new SharedTreeEditBuilder(\n\t\t\tthis.modularChangeFamily,\n\t\t\tmintRevisionTag,\n\t\t\tchangeReceiver,\n\t\t\tthis.idCompressor,\n\t\t);\n\t}\n\n\tpublic compose(changes: TaggedChange<SharedTreeChange>[]): SharedTreeChange {\n\t\tconst newChanges: Mutable<SharedTreeChange[\"changes\"]> = [];\n\t\tconst dataChangeRun: TaggedChange<ModularChangeset>[] = [];\n\n\t\tconst flushDataChangeRun = (): void => {\n\t\t\tif (dataChangeRun.length > 0) {\n\t\t\t\tnewChanges.push({\n\t\t\t\t\ttype: \"data\",\n\t\t\t\t\tinnerChange: this.modularChangeFamily.compose(dataChangeRun),\n\t\t\t\t});\n\t\t\t\tdataChangeRun.length = 0;\n\t\t\t}\n\t\t};\n\n\t\tfor (const topChange of changes) {\n\t\t\tfor (const change of topChange.change.changes) {\n\t\t\t\tif (change.type === \"schema\") {\n\t\t\t\t\tflushDataChangeRun();\n\t\t\t\t\tnewChanges.push(change);\n\t\t\t\t} else {\n\t\t\t\t\tdataChangeRun.push(mapTaggedChange(topChange, change.innerChange));\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tflushDataChangeRun();\n\t\treturn { changes: newChanges };\n\t}\n\n\tpublic invert(\n\t\tchange: TaggedChange<SharedTreeChange>,\n\t\tisRollback: boolean,\n\t\trevision: RevisionTag,\n\t): SharedTreeChange {\n\t\tconst invertInnerChange: (\n\t\t\tinnerChange: SharedTreeChange[\"changes\"][number],\n\t\t) => SharedTreeChange[\"changes\"][number] = (innerChange) => {\n\t\t\tswitch (innerChange.type) {\n\t\t\t\tcase \"data\":\n\t\t\t\t\treturn {\n\t\t\t\t\t\ttype: \"data\",\n\t\t\t\t\t\tinnerChange: this.modularChangeFamily.invert(\n\t\t\t\t\t\t\tmapTaggedChange(change, innerChange.innerChange),\n\t\t\t\t\t\t\tisRollback,\n\t\t\t\t\t\t\trevision,\n\t\t\t\t\t\t),\n\t\t\t\t\t};\n\t\t\t\tcase \"schema\": {\n\t\t\t\t\treturn {\n\t\t\t\t\t\ttype: \"schema\",\n\t\t\t\t\t\tinnerChange: {\n\t\t\t\t\t\t\tschema: {\n\t\t\t\t\t\t\t\tnew: innerChange.innerChange.schema.old,\n\t\t\t\t\t\t\t\told: innerChange.innerChange.schema.new,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tisInverse: true,\n\t\t\t\t\t\t},\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t\tdefault:\n\t\t\t\t\tfail(0xacc /* Unknown SharedTree change type. */);\n\t\t\t}\n\t\t};\n\t\treturn {\n\t\t\tchanges: change.change.changes.map(invertInnerChange).reverse(),\n\t\t};\n\t}\n\n\tpublic rebase(\n\t\tchange: TaggedChange<SharedTreeChange>,\n\t\tover: TaggedChange<SharedTreeChange>,\n\t\trevisionMetadata: RevisionMetadataSource,\n\t): SharedTreeChange {\n\t\tif (change.change.changes.length === 0 || over.change.changes.length === 0) {\n\t\t\treturn change.change;\n\t\t}\n\n\t\tif (hasSchemaChange(change.change) || hasSchemaChange(over.change)) {\n\t\t\t// Any SharedTreeChange (a list of sub-changes) that contains a schema change will cause ANY change that rebases over it to conflict.\n\t\t\t// Similarly, any SharedTreeChange containing a schema change will fail to rebase over ANY change.\n\t\t\t// Those two combine to mean: no concurrency with schema changes is supported.\n\t\t\t// This is fine because it's an open problem. Example: a tree with an A at the root and a schema that allows an A | B at the root will\n\t\t\t// become out of schema if a schema changes to restrict root types to just A is concurrent with a data change that sets it to a B.\n\t\t\t// We don't have an efficient way to detect this document-wide and there are varying opinions on restricting schema changes to prevent this.\n\t\t\t// A SharedTreeChange containing a schema change will NOT conflict in a non-concurrency case, as the \"meatless sandwich\" optimization\n\t\t\t// will result in rebase never being called.\n\t\t\treturn SharedTreeChangeFamily.emptyChange;\n\t\t}\n\t\tassert(\n\t\t\thasSingle(change.change.changes) && hasSingle(over.change.changes),\n\t\t\t0x884 /* SharedTreeChange should have exactly one inner change if no schema change is present. */,\n\t\t);\n\n\t\tconst dataChangeIntention = change.change.changes[0];\n\t\tconst dataChangeOver = over.change.changes[0];\n\t\tassert(\n\t\t\tdataChangeIntention.type === \"data\" && dataChangeOver.type === \"data\",\n\t\t\t0x885 /* Data change should be present. */,\n\t\t);\n\n\t\treturn {\n\t\t\tchanges: [\n\t\t\t\t{\n\t\t\t\t\ttype: \"data\",\n\t\t\t\t\tinnerChange: this.modularChangeFamily.rebase(\n\t\t\t\t\t\tmapTaggedChange(change, dataChangeIntention.innerChange),\n\t\t\t\t\t\tmapTaggedChange(over, dataChangeOver.innerChange),\n\t\t\t\t\t\trevisionMetadata,\n\t\t\t\t\t),\n\t\t\t\t},\n\t\t\t],\n\t\t};\n\t}\n\n\tpublic changeRevision(\n\t\tchange: SharedTreeChange,\n\t\tnewRevision: RevisionTag | undefined,\n\t\trollbackOf?: RevisionTag,\n\t): SharedTreeChange {\n\t\treturn {\n\t\t\tchanges: change.changes.map((inner) => {\n\t\t\t\treturn inner.type === \"data\"\n\t\t\t\t\t? {\n\t\t\t\t\t\t\t...inner,\n\t\t\t\t\t\t\tinnerChange: this.modularChangeFamily.rebaser.changeRevision(\n\t\t\t\t\t\t\t\tinner.innerChange,\n\t\t\t\t\t\t\t\tnewRevision,\n\t\t\t\t\t\t\t\trollbackOf,\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t}\n\t\t\t\t\t: inner;\n\t\t\t}),\n\t\t};\n\t}\n\n\tpublic get rebaser(): ChangeRebaser<SharedTreeChange> {\n\t\treturn this;\n\t}\n}\n\nexport function hasSchemaChange(change: SharedTreeChange): boolean {\n\treturn change.changes.some((innerChange) => innerChange.type === \"schema\");\n}\n\nfunction mapDataChanges(\n\tchange: SharedTreeChange,\n\tmap: (change: ModularChangeset) => ModularChangeset,\n): SharedTreeChange {\n\treturn {\n\t\tchanges: change.changes.map((dataOrSchemaChange) => {\n\t\t\tif (dataOrSchemaChange.type === \"data\") {\n\t\t\t\treturn {\n\t\t\t\t\ttype: \"data\",\n\t\t\t\t\tinnerChange: map(dataOrSchemaChange.innerChange),\n\t\t\t\t};\n\t\t\t}\n\t\t\treturn dataOrSchemaChange;\n\t\t}),\n\t};\n}\n\n/**\n * Produces an equivalent change with an updated set of appropriate refreshers.\n * @param change - The change to compute refreshers for. Not mutated.\n * @param getDetachedNode - retrieves a {@link TreeChunk} for the corresponding detached node id.\n * Is expected to read from a forest in a state that corresponds to the input context of the given change.\n * @returns An equivalent change with an updated set of appropriate refreshers.\n */\nexport function updateRefreshers(\n\tchange: SharedTreeChange,\n\tgetDetachedNode: (id: DeltaDetachedNodeId) => TreeChunk | undefined,\n\trelevantRemovedRootsFromDataChange: (\n\t\ttaggedChange: ModularChangeset,\n\t) => Iterable<DeltaDetachedNodeId>,\n\tupdateDataChangeRefreshers: (\n\t\tchange: ModularChangeset,\n\t\tgetDetachedNode: (id: DeltaDetachedNodeId) => TreeChunk | undefined,\n\t\tremovedRoots: Iterable<DeltaDetachedNodeId>,\n\t\trequireRefreshers: boolean,\n\t) => ModularChangeset,\n): SharedTreeChange {\n\t// Adding refreshers to a SharedTreeChange is not as simple as adding refreshers to each of its data changes.\n\t// This is because earlier data changes affect the state of the forest in ways that can influence the refreshers\n\t// needed for later data changes. This can happen in two ways:\n\t// 1. By removing a tree that is a relevant root to a later data change.\n\t// 2. By changing the contents of a tree that is a relevant root to a later data change.\n\t// (Note that these two cases can compound)\n\t// Thankfully, in both of these cases, refreshers can be omitted from the later data changes because the forest\n\t// applying those data changes is guaranteed to still have have the relevant trees in memory.\n\t// This means that for the first data change, all required refreshers should be added (and none should be missing).\n\t// While for later data changes, we should not include refreshers that either:\n\t// A) were already included in the earlier data changes\n\t// B) correspond to trees that were removed by earlier data changes\n\t// Set A is excluded by tracking which roots have already been included in the earlier data changes, and filtering\n\t// them out from the relevant removed roots.\n\t// Set B is excluded because the `getDetachedNode` is bound to return `undefined` for them, which tell\n\t// `defaultUpdateRefreshers` to ignore. One downside of this approach is that it prevents `defaultUpdateRefreshers`\n\t// from detecting cases where a detached node is missing for another reason (which would be a bug).\n\n\t// The roots that have been included as refreshers across all data changes so far.\n\tconst includedRoots: NestedSet<RevisionTag | undefined, number> = new Map();\n\tfunction getAndRememberDetachedNode(id: DeltaDetachedNodeId): TreeChunk | undefined {\n\t\taddToNestedSet(includedRoots, id.major, id.minor);\n\t\treturn getDetachedNode(id);\n\t}\n\tfunction* filterIncludedRoots(\n\t\ttoFilter: Iterable<DeltaDetachedNodeId>,\n\t): Iterable<DeltaDetachedNodeId> {\n\t\tfor (const id of toFilter) {\n\t\t\tif (!nestedSetContains(includedRoots, id.major, id.minor)) {\n\t\t\t\tyield id;\n\t\t\t}\n\t\t}\n\t}\n\tlet isFirstDataChange = true;\n\treturn mapDataChanges(change, (dataChange) => {\n\t\tconst removedRoots = relevantRemovedRootsFromDataChange(dataChange);\n\t\tif (isFirstDataChange) {\n\t\t\tisFirstDataChange = false;\n\t\t\treturn updateDataChangeRefreshers(\n\t\t\t\tdataChange,\n\t\t\t\tgetAndRememberDetachedNode,\n\t\t\t\tremovedRoots,\n\t\t\t\ttrue,\n\t\t\t);\n\t\t} else {\n\t\t\treturn updateDataChangeRefreshers(\n\t\t\t\tdataChange,\n\t\t\t\tgetAndRememberDetachedNode,\n\t\t\t\tfilterIncludedRoots(removedRoots),\n\t\t\t\tfalse,\n\t\t\t);\n\t\t}\n\t});\n}\n"]}
1
+ {"version":3,"file":"sharedTreeChangeFamily.js","sourceRoot":"","sources":["../../src/shared-tree/sharedTreeChangeFamily.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAG7D,OAAO,EASN,eAAe,GACf,MAAM,kBAAkB,CAAC;AAC1B,OAAO,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CAChC,UAAU,EACV,0BAA0B,EAC1B,mBAAmB,CAAC,YAAY,CAAC,EACjC,KAAK,CACL,CAAC;QACH,CAAC;IACF,CAAC,CAAC,CAAC;AACJ,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\n\nimport type { ICodecFamily, ICodecOptions } from \"../codec/index.js\";\nimport {\n\ttype ChangeEncodingContext,\n\ttype ChangeFamily,\n\ttype ChangeRebaser,\n\ttype DeltaDetachedNodeId,\n\ttype RevisionMetadataSource,\n\ttype RevisionTag,\n\ttype RevisionTagCodec,\n\ttype TaggedChange,\n\tmapTaggedChange,\n} from \"../core/index.js\";\nimport {\n\ttype FieldBatchCodec,\n\tModularChangeFamily,\n\ttype ModularChangeset,\n\ttype TreeChunk,\n\ttype TreeCompressionStrategy,\n\tfieldKindConfigurations,\n\tfieldKinds,\n\tmakeModularChangeCodecFamily,\n} from \"../feature-libraries/index.js\";\nimport {\n\ttype Mutable,\n\ttype NestedSet,\n\taddToNestedSet,\n\tfail,\n\thasSingle,\n\tnestedSetContains,\n} from \"../util/index.js\";\n\nimport { makeSharedTreeChangeCodecFamily } from \"./sharedTreeChangeCodecs.js\";\nimport type { SharedTreeChange } from \"./sharedTreeChangeTypes.js\";\nimport { SharedTreeEditBuilder } from \"./sharedTreeEditBuilder.js\";\nimport type { IIdCompressor } from \"@fluidframework/id-compressor\";\n\n/**\n * Implementation of {@link ChangeFamily} that combines edits to fields and schema changes.\n *\n * @sealed\n */\nexport class SharedTreeChangeFamily\n\timplements\n\t\tChangeFamily<SharedTreeEditBuilder, SharedTreeChange>,\n\t\tChangeRebaser<SharedTreeChange>\n{\n\tpublic static readonly emptyChange: SharedTreeChange = {\n\t\tchanges: [],\n\t};\n\n\tpublic readonly codecs: ICodecFamily<SharedTreeChange, ChangeEncodingContext>;\n\tprivate readonly modularChangeFamily: ModularChangeFamily;\n\n\tpublic constructor(\n\t\trevisionTagCodec: RevisionTagCodec,\n\t\tfieldBatchCodec: FieldBatchCodec,\n\t\tcodecOptions: ICodecOptions,\n\t\tchunkCompressionStrategy?: TreeCompressionStrategy,\n\t\tprivate readonly idCompressor?: IIdCompressor,\n\t) {\n\t\tconst modularChangeCodec = makeModularChangeCodecFamily(\n\t\t\tfieldKindConfigurations,\n\t\t\trevisionTagCodec,\n\t\t\tfieldBatchCodec,\n\t\t\tcodecOptions,\n\t\t\tchunkCompressionStrategy,\n\t\t);\n\t\tthis.modularChangeFamily = new ModularChangeFamily(fieldKinds, modularChangeCodec);\n\t\tthis.codecs = makeSharedTreeChangeCodecFamily(\n\t\t\tthis.modularChangeFamily.codecs,\n\t\t\tcodecOptions,\n\t\t);\n\t}\n\n\tpublic buildEditor(\n\t\tmintRevisionTag: () => RevisionTag,\n\t\tchangeReceiver: (change: TaggedChange<SharedTreeChange>) => void,\n\t): SharedTreeEditBuilder {\n\t\treturn new SharedTreeEditBuilder(\n\t\t\tthis.modularChangeFamily,\n\t\t\tmintRevisionTag,\n\t\t\tchangeReceiver,\n\t\t);\n\t}\n\n\tpublic compose(changes: TaggedChange<SharedTreeChange>[]): SharedTreeChange {\n\t\tconst newChanges: Mutable<SharedTreeChange[\"changes\"]> = [];\n\t\tconst dataChangeRun: TaggedChange<ModularChangeset>[] = [];\n\n\t\tconst flushDataChangeRun = (): void => {\n\t\t\tif (dataChangeRun.length > 0) {\n\t\t\t\tnewChanges.push({\n\t\t\t\t\ttype: \"data\",\n\t\t\t\t\tinnerChange: this.modularChangeFamily.compose(dataChangeRun),\n\t\t\t\t});\n\t\t\t\tdataChangeRun.length = 0;\n\t\t\t}\n\t\t};\n\n\t\tfor (const topChange of changes) {\n\t\t\tfor (const change of topChange.change.changes) {\n\t\t\t\tif (change.type === \"schema\") {\n\t\t\t\t\tflushDataChangeRun();\n\t\t\t\t\tnewChanges.push(change);\n\t\t\t\t} else {\n\t\t\t\t\tdataChangeRun.push(mapTaggedChange(topChange, change.innerChange));\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tflushDataChangeRun();\n\t\treturn { changes: newChanges };\n\t}\n\n\tpublic invert(\n\t\tchange: TaggedChange<SharedTreeChange>,\n\t\tisRollback: boolean,\n\t\trevision: RevisionTag,\n\t): SharedTreeChange {\n\t\tconst invertInnerChange: (\n\t\t\tinnerChange: SharedTreeChange[\"changes\"][number],\n\t\t) => SharedTreeChange[\"changes\"][number] = (innerChange) => {\n\t\t\tswitch (innerChange.type) {\n\t\t\t\tcase \"data\":\n\t\t\t\t\treturn {\n\t\t\t\t\t\ttype: \"data\",\n\t\t\t\t\t\tinnerChange: this.modularChangeFamily.invert(\n\t\t\t\t\t\t\tmapTaggedChange(change, innerChange.innerChange),\n\t\t\t\t\t\t\tisRollback,\n\t\t\t\t\t\t\trevision,\n\t\t\t\t\t\t),\n\t\t\t\t\t};\n\t\t\t\tcase \"schema\": {\n\t\t\t\t\treturn {\n\t\t\t\t\t\ttype: \"schema\",\n\t\t\t\t\t\tinnerChange: {\n\t\t\t\t\t\t\tschema: {\n\t\t\t\t\t\t\t\tnew: innerChange.innerChange.schema.old,\n\t\t\t\t\t\t\t\told: innerChange.innerChange.schema.new,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tisInverse: true,\n\t\t\t\t\t\t},\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t\tdefault:\n\t\t\t\t\tfail(0xacc /* Unknown SharedTree change type. */);\n\t\t\t}\n\t\t};\n\t\treturn {\n\t\t\tchanges: change.change.changes.map(invertInnerChange).reverse(),\n\t\t};\n\t}\n\n\tpublic rebase(\n\t\tchange: TaggedChange<SharedTreeChange>,\n\t\tover: TaggedChange<SharedTreeChange>,\n\t\trevisionMetadata: RevisionMetadataSource,\n\t): SharedTreeChange {\n\t\tif (change.change.changes.length === 0 || over.change.changes.length === 0) {\n\t\t\treturn change.change;\n\t\t}\n\n\t\tif (hasSchemaChange(change.change) || hasSchemaChange(over.change)) {\n\t\t\t// Any SharedTreeChange (a list of sub-changes) that contains a schema change will cause ANY change that rebases over it to conflict.\n\t\t\t// Similarly, any SharedTreeChange containing a schema change will fail to rebase over ANY change.\n\t\t\t// Those two combine to mean: no concurrency with schema changes is supported.\n\t\t\t// This is fine because it's an open problem. Example: a tree with an A at the root and a schema that allows an A | B at the root will\n\t\t\t// become out of schema if a schema changes to restrict root types to just A is concurrent with a data change that sets it to a B.\n\t\t\t// We don't have an efficient way to detect this document-wide and there are varying opinions on restricting schema changes to prevent this.\n\t\t\t// A SharedTreeChange containing a schema change will NOT conflict in a non-concurrency case, as the \"meatless sandwich\" optimization\n\t\t\t// will result in rebase never being called.\n\t\t\treturn SharedTreeChangeFamily.emptyChange;\n\t\t}\n\t\tassert(\n\t\t\thasSingle(change.change.changes) && hasSingle(over.change.changes),\n\t\t\t0x884 /* SharedTreeChange should have exactly one inner change if no schema change is present. */,\n\t\t);\n\n\t\tconst dataChangeIntention = change.change.changes[0];\n\t\tconst dataChangeOver = over.change.changes[0];\n\t\tassert(\n\t\t\tdataChangeIntention.type === \"data\" && dataChangeOver.type === \"data\",\n\t\t\t0x885 /* Data change should be present. */,\n\t\t);\n\n\t\treturn {\n\t\t\tchanges: [\n\t\t\t\t{\n\t\t\t\t\ttype: \"data\",\n\t\t\t\t\tinnerChange: this.modularChangeFamily.rebase(\n\t\t\t\t\t\tmapTaggedChange(change, dataChangeIntention.innerChange),\n\t\t\t\t\t\tmapTaggedChange(over, dataChangeOver.innerChange),\n\t\t\t\t\t\trevisionMetadata,\n\t\t\t\t\t),\n\t\t\t\t},\n\t\t\t],\n\t\t};\n\t}\n\n\tpublic changeRevision(\n\t\tchange: SharedTreeChange,\n\t\tnewRevision: RevisionTag | undefined,\n\t\trollbackOf?: RevisionTag,\n\t): SharedTreeChange {\n\t\treturn {\n\t\t\tchanges: change.changes.map((inner) => {\n\t\t\t\treturn inner.type === \"data\"\n\t\t\t\t\t? {\n\t\t\t\t\t\t\t...inner,\n\t\t\t\t\t\t\tinnerChange: this.modularChangeFamily.rebaser.changeRevision(\n\t\t\t\t\t\t\t\tinner.innerChange,\n\t\t\t\t\t\t\t\tnewRevision,\n\t\t\t\t\t\t\t\trollbackOf,\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t}\n\t\t\t\t\t: inner;\n\t\t\t}),\n\t\t};\n\t}\n\n\tpublic get rebaser(): ChangeRebaser<SharedTreeChange> {\n\t\treturn this;\n\t}\n}\n\nexport function hasSchemaChange(change: SharedTreeChange): boolean {\n\treturn change.changes.some((innerChange) => innerChange.type === \"schema\");\n}\n\nfunction mapDataChanges(\n\tchange: SharedTreeChange,\n\tmap: (change: ModularChangeset) => ModularChangeset,\n): SharedTreeChange {\n\treturn {\n\t\tchanges: change.changes.map((dataOrSchemaChange) => {\n\t\t\tif (dataOrSchemaChange.type === \"data\") {\n\t\t\t\treturn {\n\t\t\t\t\ttype: \"data\",\n\t\t\t\t\tinnerChange: map(dataOrSchemaChange.innerChange),\n\t\t\t\t};\n\t\t\t}\n\t\t\treturn dataOrSchemaChange;\n\t\t}),\n\t};\n}\n\n/**\n * Produces an equivalent change with an updated set of appropriate refreshers.\n * @param change - The change to compute refreshers for. Not mutated.\n * @param getDetachedNode - retrieves a {@link TreeChunk} for the corresponding detached node id.\n * Is expected to read from a forest in a state that corresponds to the input context of the given change.\n * @returns An equivalent change with an updated set of appropriate refreshers.\n */\nexport function updateRefreshers(\n\tchange: SharedTreeChange,\n\tgetDetachedNode: (id: DeltaDetachedNodeId) => TreeChunk | undefined,\n\trelevantRemovedRootsFromDataChange: (\n\t\ttaggedChange: ModularChangeset,\n\t) => Iterable<DeltaDetachedNodeId>,\n\tupdateDataChangeRefreshers: (\n\t\tchange: ModularChangeset,\n\t\tgetDetachedNode: (id: DeltaDetachedNodeId) => TreeChunk | undefined,\n\t\tremovedRoots: Iterable<DeltaDetachedNodeId>,\n\t\trequireRefreshers: boolean,\n\t) => ModularChangeset,\n): SharedTreeChange {\n\t// Adding refreshers to a SharedTreeChange is not as simple as adding refreshers to each of its data changes.\n\t// This is because earlier data changes affect the state of the forest in ways that can influence the refreshers\n\t// needed for later data changes. This can happen in two ways:\n\t// 1. By removing a tree that is a relevant root to a later data change.\n\t// 2. By changing the contents of a tree that is a relevant root to a later data change.\n\t// (Note that these two cases can compound)\n\t// Thankfully, in both of these cases, refreshers can be omitted from the later data changes because the forest\n\t// applying those data changes is guaranteed to still have have the relevant trees in memory.\n\t// This means that for the first data change, all required refreshers should be added (and none should be missing).\n\t// While for later data changes, we should not include refreshers that either:\n\t// A) were already included in the earlier data changes\n\t// B) correspond to trees that were removed by earlier data changes\n\t// Set A is excluded by tracking which roots have already been included in the earlier data changes, and filtering\n\t// them out from the relevant removed roots.\n\t// Set B is excluded because the `getDetachedNode` is bound to return `undefined` for them, which tell\n\t// `defaultUpdateRefreshers` to ignore. One downside of this approach is that it prevents `defaultUpdateRefreshers`\n\t// from detecting cases where a detached node is missing for another reason (which would be a bug).\n\n\t// The roots that have been included as refreshers across all data changes so far.\n\tconst includedRoots: NestedSet<RevisionTag | undefined, number> = new Map();\n\tfunction getAndRememberDetachedNode(id: DeltaDetachedNodeId): TreeChunk | undefined {\n\t\taddToNestedSet(includedRoots, id.major, id.minor);\n\t\treturn getDetachedNode(id);\n\t}\n\tfunction* filterIncludedRoots(\n\t\ttoFilter: Iterable<DeltaDetachedNodeId>,\n\t): Iterable<DeltaDetachedNodeId> {\n\t\tfor (const id of toFilter) {\n\t\t\tif (!nestedSetContains(includedRoots, id.major, id.minor)) {\n\t\t\t\tyield id;\n\t\t\t}\n\t\t}\n\t}\n\tlet isFirstDataChange = true;\n\treturn mapDataChanges(change, (dataChange) => {\n\t\tconst removedRoots = relevantRemovedRootsFromDataChange(dataChange);\n\t\tif (isFirstDataChange) {\n\t\t\tisFirstDataChange = false;\n\t\t\treturn updateDataChangeRefreshers(\n\t\t\t\tdataChange,\n\t\t\t\tgetAndRememberDetachedNode,\n\t\t\t\tremovedRoots,\n\t\t\t\ttrue,\n\t\t\t);\n\t\t} else {\n\t\t\treturn updateDataChangeRefreshers(\n\t\t\t\tdataChange,\n\t\t\t\tgetAndRememberDetachedNode,\n\t\t\t\tfilterIncludedRoots(removedRoots),\n\t\t\t\tfalse,\n\t\t\t);\n\t\t}\n\t});\n}\n"]}
@@ -2,7 +2,6 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
- import type { IIdCompressor } from "@fluidframework/id-compressor";
6
5
  import type { ChangeFamilyEditor, RevisionTag, TaggedChange, TreeStoredSchema } from "../core/index.js";
7
6
  import { DefaultEditBuilder, type IDefaultEditBuilder, type ModularChangeFamily } from "../feature-libraries/index.js";
8
7
  import type { SharedTreeChange } from "./sharedTreeChangeTypes.js";
@@ -34,6 +33,6 @@ export interface ISharedTreeEditor extends IDefaultEditBuilder {
34
33
  export declare class SharedTreeEditBuilder extends DefaultEditBuilder implements ChangeFamilyEditor, ISharedTreeEditor {
35
34
  private readonly changeReceiver;
36
35
  readonly schema: ISchemaEditor;
37
- constructor(modularChangeFamily: ModularChangeFamily, mintRevisionTag: () => RevisionTag, changeReceiver: (change: TaggedChange<SharedTreeChange>) => void, idCompressor?: IIdCompressor);
36
+ constructor(modularChangeFamily: ModularChangeFamily, mintRevisionTag: () => RevisionTag, changeReceiver: (change: TaggedChange<SharedTreeChange>) => void);
38
37
  }
39
38
  //# sourceMappingURL=sharedTreeEditBuilder.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"sharedTreeEditBuilder.d.ts","sourceRoot":"","sources":["../../src/shared-tree/sharedTreeEditBuilder.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AACnE,OAAO,KAAK,EACX,kBAAkB,EAClB,WAAW,EACX,YAAY,EACZ,gBAAgB,EAChB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACN,kBAAkB,EAClB,KAAK,mBAA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,mBAAmB;IAC7D;;OAEG;IACH,MAAM,EAAE,aAAa,CAAC;CACtB;AAED;;;GAGG;AACH,qBAAa,qBACZ,SAAQ,kBACR,YAAW,kBAAkB,EAAE,iBAAiB;IAO/C,OAAO,CAAC,QAAQ,CAAC,cAAc;IALhC,SAAgB,MAAM,EAAE,aAAa,CAAC;gBAGrC,mBAAmB,EAAE,mBAAmB,EACxC,eAAe,EAAE,MAAM,WAAW,EACjB,cAAc,EAAE,CAAC,MAAM,EAAE,YAAY,CAAC,gBAAgB,CAAC,KAAK,IAAI;CA4BlF"}
@@ -8,11 +8,11 @@ import { DefaultEditBuilder, } from "../feature-libraries/index.js";
8
8
  * @sealed
9
9
  */
10
10
  export class SharedTreeEditBuilder extends DefaultEditBuilder {
11
- constructor(modularChangeFamily, mintRevisionTag, changeReceiver, idCompressor) {
11
+ constructor(modularChangeFamily, mintRevisionTag, changeReceiver) {
12
12
  super(modularChangeFamily, mintRevisionTag, (taggedChange) => changeReceiver({
13
13
  ...taggedChange,
14
14
  change: { changes: [{ type: "data", innerChange: taggedChange.change }] },
15
- }), idCompressor);
15
+ }));
16
16
  this.changeReceiver = changeReceiver;
17
17
  this.schema = {
18
18
  setStoredSchema: (oldSchema, newSchema) => {
@@ -1 +1 @@
1
- {"version":3,"file":"sharedTreeEditBuilder.js","sourceRoot":"","sources":["../../src/shared-tree/sharedTreeEditBuilder.ts"],"names":[],"mappings":"AAAA;;;GAGG;AASH,OAAO,EACN,kBAAkB,GAGlB,MAAM,+BAA+B,CAAC;AA2BvC;;;GAGG;AACH,MAAM,OAAO,qBACZ,SAAQ,kBAAkB;IAK1B,YACC,mBAAwC,EACxC,eAAkC,EACjB,cAAgE,EACjF,YAA4B;QAE5B,KAAK,CACJ,mBAAmB,EACnB,eAAe,EACf,CAAC,YAAY,EAAE,EAAE,CAChB,cAAc,CAAC;YACd,GAAG,YAAY;YACf,MAAM,EAAE,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,WAAW,EAAE,YAAY,CAAC,MAAM,EAAE,CAAC,EAAE;SACzE,CAAC,EACH,YAAY,CACZ,CAAC;QAZe,mBAAc,GAAd,cAAc,CAAkD;QAcjF,IAAI,CAAC,MAAM,GAAG;YACb,eAAe,EAAE,CAAC,SAAS,EAAE,SAAS,EAAE,EAAE;gBACzC,IAAI,CAAC,cAAc,CAAC;oBACnB,QAAQ,EAAE,eAAe,EAAE;oBAC3B,MAAM,EAAE;wBACP,OAAO,EAAE;4BACR;gCACC,IAAI,EAAE,QAAQ;gCACd,WAAW,EAAE;oCACZ,MAAM,EAAE,EAAE,GAAG,EAAE,SAAS,EAAE,GAAG,EAAE,SAAS,EAAE;oCAC1C,SAAS,EAAE,KAAK;iCAChB;6BACD;yBACD;qBACD;iBACD,CAAC,CAAC;YACJ,CAAC;SACD,CAAC;IACH,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { IIdCompressor } from \"@fluidframework/id-compressor\";\nimport type {\n\tChangeFamilyEditor,\n\tRevisionTag,\n\tTaggedChange,\n\tTreeStoredSchema,\n} from \"../core/index.js\";\nimport {\n\tDefaultEditBuilder,\n\ttype IDefaultEditBuilder,\n\ttype ModularChangeFamily,\n} from \"../feature-libraries/index.js\";\n\nimport type { SharedTreeChange } from \"./sharedTreeChangeTypes.js\";\n\n/**\n * Editor for schema changes.\n * The only currently supported operation is to replace the stored schema.\n */\nexport interface ISchemaEditor {\n\t/**\n\t * Updates the stored schema.\n\t * @param oldSchema - The schema being overwritten.\n\t * @param newSchema - The new schema to apply.\n\t */\n\tsetStoredSchema(oldSchema: TreeStoredSchema, newSchema: TreeStoredSchema): void;\n}\n\n/**\n * SharedTree editor for transactional tree data and schema changes.\n */\nexport interface ISharedTreeEditor extends IDefaultEditBuilder {\n\t/**\n\t * Editor for schema changes.\n\t */\n\tschema: ISchemaEditor;\n}\n\n/**\n * Implementation of {@link IDefaultEditBuilder} based on the default set of supported field kinds.\n * @sealed\n */\nexport class SharedTreeEditBuilder\n\textends DefaultEditBuilder\n\timplements ChangeFamilyEditor, ISharedTreeEditor\n{\n\tpublic readonly schema: ISchemaEditor;\n\n\tpublic constructor(\n\t\tmodularChangeFamily: ModularChangeFamily,\n\t\tmintRevisionTag: () => RevisionTag,\n\t\tprivate readonly changeReceiver: (change: TaggedChange<SharedTreeChange>) => void,\n\t\tidCompressor?: IIdCompressor,\n\t) {\n\t\tsuper(\n\t\t\tmodularChangeFamily,\n\t\t\tmintRevisionTag,\n\t\t\t(taggedChange) =>\n\t\t\t\tchangeReceiver({\n\t\t\t\t\t...taggedChange,\n\t\t\t\t\tchange: { changes: [{ type: \"data\", innerChange: taggedChange.change }] },\n\t\t\t\t}),\n\t\t\tidCompressor,\n\t\t);\n\n\t\tthis.schema = {\n\t\t\tsetStoredSchema: (oldSchema, newSchema) => {\n\t\t\t\tthis.changeReceiver({\n\t\t\t\t\trevision: mintRevisionTag(),\n\t\t\t\t\tchange: {\n\t\t\t\t\t\tchanges: [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\ttype: \"schema\",\n\t\t\t\t\t\t\t\tinnerChange: {\n\t\t\t\t\t\t\t\t\tschema: { new: newSchema, old: oldSchema },\n\t\t\t\t\t\t\t\t\tisInverse: false,\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t],\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t},\n\t\t};\n\t}\n}\n"]}
1
+ {"version":3,"file":"sharedTreeEditBuilder.js","sourceRoot":"","sources":["../../src/shared-tree/sharedTreeEditBuilder.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAQH,OAAO,EACN,kBAAkB,GAGlB,MAAM,+BAA+B,CAAC;AA2BvC;;;GAGG;AACH,MAAM,OAAO,qBACZ,SAAQ,kBAAkB;IAK1B,YACC,mBAAwC,EACxC,eAAkC,EACjB,cAAgE;QAEjF,KAAK,CAAC,mBAAmB,EAAE,eAAe,EAAE,CAAC,YAAY,EAAE,EAAE,CAC5D,cAAc,CAAC;YACd,GAAG,YAAY;YACf,MAAM,EAAE,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,WAAW,EAAE,YAAY,CAAC,MAAM,EAAE,CAAC,EAAE;SACzE,CAAC,CACF,CAAC;QAPe,mBAAc,GAAd,cAAc,CAAkD;QASjF,IAAI,CAAC,MAAM,GAAG;YACb,eAAe,EAAE,CAAC,SAAS,EAAE,SAAS,EAAE,EAAE;gBACzC,IAAI,CAAC,cAAc,CAAC;oBACnB,QAAQ,EAAE,eAAe,EAAE;oBAC3B,MAAM,EAAE;wBACP,OAAO,EAAE;4BACR;gCACC,IAAI,EAAE,QAAQ;gCACd,WAAW,EAAE;oCACZ,MAAM,EAAE,EAAE,GAAG,EAAE,SAAS,EAAE,GAAG,EAAE,SAAS,EAAE;oCAC1C,SAAS,EAAE,KAAK;iCAChB;6BACD;yBACD;qBACD;iBACD,CAAC,CAAC;YACJ,CAAC;SACD,CAAC;IACH,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type {\n\tChangeFamilyEditor,\n\tRevisionTag,\n\tTaggedChange,\n\tTreeStoredSchema,\n} from \"../core/index.js\";\nimport {\n\tDefaultEditBuilder,\n\ttype IDefaultEditBuilder,\n\ttype ModularChangeFamily,\n} from \"../feature-libraries/index.js\";\n\nimport type { SharedTreeChange } from \"./sharedTreeChangeTypes.js\";\n\n/**\n * Editor for schema changes.\n * The only currently supported operation is to replace the stored schema.\n */\nexport interface ISchemaEditor {\n\t/**\n\t * Updates the stored schema.\n\t * @param oldSchema - The schema being overwritten.\n\t * @param newSchema - The new schema to apply.\n\t */\n\tsetStoredSchema(oldSchema: TreeStoredSchema, newSchema: TreeStoredSchema): void;\n}\n\n/**\n * SharedTree editor for transactional tree data and schema changes.\n */\nexport interface ISharedTreeEditor extends IDefaultEditBuilder {\n\t/**\n\t * Editor for schema changes.\n\t */\n\tschema: ISchemaEditor;\n}\n\n/**\n * Implementation of {@link IDefaultEditBuilder} based on the default set of supported field kinds.\n * @sealed\n */\nexport class SharedTreeEditBuilder\n\textends DefaultEditBuilder\n\timplements ChangeFamilyEditor, ISharedTreeEditor\n{\n\tpublic readonly schema: ISchemaEditor;\n\n\tpublic constructor(\n\t\tmodularChangeFamily: ModularChangeFamily,\n\t\tmintRevisionTag: () => RevisionTag,\n\t\tprivate readonly changeReceiver: (change: TaggedChange<SharedTreeChange>) => void,\n\t) {\n\t\tsuper(modularChangeFamily, mintRevisionTag, (taggedChange) =>\n\t\t\tchangeReceiver({\n\t\t\t\t...taggedChange,\n\t\t\t\tchange: { changes: [{ type: \"data\", innerChange: taggedChange.change }] },\n\t\t\t}),\n\t\t);\n\n\t\tthis.schema = {\n\t\t\tsetStoredSchema: (oldSchema, newSchema) => {\n\t\t\t\tthis.changeReceiver({\n\t\t\t\t\trevision: mintRevisionTag(),\n\t\t\t\t\tchange: {\n\t\t\t\t\t\tchanges: [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\ttype: \"schema\",\n\t\t\t\t\t\t\t\tinnerChange: {\n\t\t\t\t\t\t\t\t\tschema: { new: newSchema, old: oldSchema },\n\t\t\t\t\t\t\t\t\tisInverse: false,\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t],\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t},\n\t\t};\n\t}\n}\n"]}
@@ -57,43 +57,18 @@ export declare const TreeAlpha: {
57
57
  * Construct tree content compatible with a field defined by the provided `schema`.
58
58
  * @param schema - The schema for what to construct. As this is an {@link ImplicitFieldSchema}, a {@link FieldSchema}, {@link TreeNodeSchema} or {@link AllowedTypes} array can be provided.
59
59
  * @param data - The data used to construct the field content. See {@link TreeAlpha.(exportVerbose:1)}.
60
- * @remarks
61
- * This overload requires that any {@link @fluidframework/core-interfaces#IFluidHandle|IFluidHandles} are encoded as actual {@link @fluidframework/core-interfaces#IFluidHandle|IFluidHandles} in the input.
62
- */
63
- importVerbose<const TSchema extends ImplicitFieldSchema>(schema: TSchema, data: VerboseTree | undefined, options?: Partial<ParseOptions<IFluidHandle>>): Unhydrated<TreeFieldFromImplicitField<TSchema>>;
64
- /**
65
- * Construct tree content compatible with a field defined by the provided `schema`.
66
- * @param schema - The schema for what to construct. As this is an {@link ImplicitFieldSchema}, a {@link FieldSchema}, {@link TreeNodeSchema} or {@link AllowedTypes} array can be provided.
67
- * @param data - The data used to construct the field content. See {@link TreeAlpha.(exportVerbose:2)}.
68
- *
69
- * @typeparam THandle - How {@link @fluidframework/core-interfaces#IFluidHandle|IFluidHandles} in the input `data` are encoded.
70
- * A converter from this encoding to {@link @fluidframework/core-interfaces#IFluidHandle} is required in `options`.
71
60
  */
72
- importVerbose<const TSchema extends ImplicitFieldSchema, THandle>(schema: TSchema, data: VerboseTree<THandle> | undefined, options: ParseOptions<THandle>): Unhydrated<TreeFieldFromImplicitField<TSchema>>;
73
- /**
74
- * Same as {@link TreeAlpha.(exportConcise:2)}, except leaves handles as is.
75
- */
76
- exportConcise(node: TreeNode | TreeLeafValue, options?: Partial<EncodeOptions<IFluidHandle>>): ConciseTree;
61
+ importVerbose<const TSchema extends ImplicitFieldSchema>(schema: TSchema, data: VerboseTree | undefined, options?: Partial<ParseOptions>): Unhydrated<TreeFieldFromImplicitField<TSchema>>;
77
62
  /**
78
63
  * Copy a snapshot of the current version of a TreeNode into a {@link ConciseTree}.
79
- *
80
- * @typeparam THandle - How {@link @fluidframework/core-interfaces#IFluidHandle|IFluidHandles} in the output should be encoded.
81
- * A converter from from {@link @fluidframework/core-interfaces#IFluidHandle} to this format is required in `options`.
82
64
  */
83
- exportConcise<THandle>(node: TreeNode | TreeLeafValue, options: EncodeOptions<THandle>): ConciseTree<THandle>;
65
+ exportConcise(node: TreeNode | TreeLeafValue, options?: EncodeOptions): ConciseTree;
84
66
  /**
85
- * Same {@link TreeAlpha.(exportVerbose:2)} except leaves handles as is.
86
- */
87
- exportVerbose(node: TreeNode | TreeLeafValue, options?: Partial<EncodeOptions<IFluidHandle>>): VerboseTree;
88
- /**
89
- * Copy a snapshot of the current version of a TreeNode into a JSON compatible plain old JavaScript Object.
90
- * Verbose tree format, with explicit type on every node.
91
- *
92
- * @typeparam THandle - How {@link @fluidframework/core-interfaces#IFluidHandle|IFluidHandles} in the output should be encoded.
93
- * A converter from from {@link @fluidframework/core-interfaces#IFluidHandle} to this format is required in `options`.
67
+ * Copy a snapshot of the current version of a TreeNode into a JSON compatible plain old JavaScript Object (except for {@link @fluidframework/core-interfaces#IFluidHandle|IFluidHandles}).
68
+ * Uses the {@link VerboseTree} format, with an explicit type on every node.
94
69
  *
95
70
  * @remarks
96
- * There are several cases this may be preferred to {@link TreeAlpha.(exportConcise:2)}:
71
+ * There are several cases this may be preferred to {@link TreeAlpha.exportConcise}:
97
72
  *
98
73
  * 1. When not using {@link ITreeConfigurationOptions.preventAmbiguity} (or when using `useStableFieldKeys`), `exportConcise` can produce ambiguous data (the type may be unclear on some nodes).
99
74
  * `exportVerbose` will always be unambiguous and thus lossless.
@@ -102,7 +77,7 @@ export declare const TreeAlpha: {
102
77
  *
103
78
  * 3. When easy access to the type is desired.
104
79
  */
105
- exportVerbose<T>(node: TreeNode | TreeLeafValue, options: EncodeOptions<T>): VerboseTree<T>;
80
+ exportVerbose(node: TreeNode | TreeLeafValue, options?: EncodeOptions): VerboseTree;
106
81
  /**
107
82
  * Export the content of the provided `tree` in a compressed JSON compatible format.
108
83
  * @remarks
@@ -1 +1 @@
1
- {"version":3,"file":"treeApiAlpha.d.ts","sourceRoot":"","sources":["../../src/shared-tree/treeApiAlpha.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AACpE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAE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AAC;IAEhC;;;;;;;;;;;;;;;;OAgBG;IACH,gBAAgB,CAAC,KAAK,CAAC,OAAO,SAAS,mBAAmB,EACzD,MAAM,EAAE,OAAO,EACf,cAAc,EAAE,cAAc,CAAC,YAAY,CAAC,EAC5C,OAAO,EAAE;QAAE,YAAY,CAAC,EAAE,aAAa,CAAA;KAAE,GAAG,aAAa,GACvD,UAAU,CAAC,0BAA0B,CAAC,OAAO,CAAC,CAAC,CAAC;CAsHnD,CAAC"}
@@ -30,12 +30,7 @@ export const TreeAlpha = {
30
30
  return createFromInsertable(schema, data);
31
31
  },
32
32
  importVerbose(schema, data, options) {
33
- const config = {
34
- valueConverter: (input) => {
35
- return input;
36
- },
37
- ...options,
38
- };
33
+ const config = { ...options };
39
34
  // Create a config which is standalone, and thus can be used without having to refer back to the schema.
40
35
  const schemalessConfig = applySchemaToParserOptions(schema, config);
41
36
  if (data === undefined) {
@@ -49,22 +44,12 @@ export const TreeAlpha = {
49
44
  return createFromCursor(schema, cursor);
50
45
  },
51
46
  exportConcise(node, options) {
52
- const config = {
53
- valueConverter(handle) {
54
- return handle;
55
- },
56
- ...options,
57
- };
47
+ const config = { ...options };
58
48
  const cursor = borrowCursorFromTreeNodeOrValue(node);
59
49
  return conciseFromCursor(cursor, tryGetSchema(node) ?? fail(0xacd /* invalid input */), config);
60
50
  },
61
51
  exportVerbose(node, options) {
62
- const config = {
63
- valueConverter(handle) {
64
- return handle;
65
- },
66
- ...options,
67
- };
52
+ const config = { ...options };
68
53
  const cursor = borrowCursorFromTreeNodeOrValue(node);
69
54
  return verboseFromCursor(cursor, tryGetSchema(node) ?? fail(0xace /* invalid input */), config);
70
55
  },
@@ -1 +1 @@
1
- {"version":3,"file":"treeApiAlpha.js","sourceRoot":"","sources":["../../src/shared-tree/treeApiAlpha.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAC7D,OAAO,EAAE,kBAAkB,EAAE,MA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qBAAqB,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC;QACrD,MAAM,IAAI,GAAG,0BAA0B,CAAC,MAAM,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;QAClE,OAAO,QAAQ,CAAC,KAAK,CAAU,IAAI,CAAC,IAAI,CAAC,CAAC;IAC3C,CAAC;CACD,CAAC;AAEF,SAAS,+BAA+B,CACvC,IAA8B;IAE9B,IAAI,WAAW,CAAC,IAAI,CAAC,EAAE,CAAC;QACvB,OAAO,oBAAoB,CAC1B,YAAY,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,KAAK,CAAC,oBAAoB,CAAC,EACtD,IAAI,CACJ,CAAC;IACH,CAAC;IACD,MAAM,MAAM,GAAG,SAAS,CAAC,IAAI,CAAC,CAAC;IAC/B,MAAM,MAAM,GAAG,MAAM,CAAC,oBAAoB,EAAE,CAAC,YAAY,EAAE,CAAC;IAC5D,OAAO,MAAM,CAAC;AACf,CAAC;AAED,SAAS,oCAAoC,CAC5C,IAA8B;IAE9B,MAAM,MAAM,GAAG,+BAA+B,CAAC,IAAI,CAAC,CAAC;IACrD,mBAAmB;IACnB,MAAM,OAAO,GAAG,iBAAiB,CAAC,MAAM,CAAC,CAAC;IAC1C,OAAO,qBAAqB,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC;AACzC,CAAC;AAED,MAAM,eAAe,GAAG;IACvB,IAAI,EAAE,CAAC;IACP,IAAI,EAAE,CAAC;IACP,IAAI,EAAE,CAAC;IACP,IAAI,EAAE,CAAC;CACP,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\";\nimport { createIdCompressor } from \"@fluidframework/id-compressor/internal\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\nimport type { IFluidHandle } from \"@fluidframework/core-interfaces\";\nimport type { IIdCompressor } from \"@fluidframework/id-compressor\";\n\nimport {\n\tgetKernel,\n\ttype TreeNode,\n\ttype Unhydrated,\n\tTreeBeta,\n\ttryGetSchema,\n\tcreateFromCursor,\n\tcreateFromInsertable,\n\tcursorFromInsertable,\n\tFieldKind,\n\tnormalizeFieldSchema,\n\ttype ImplicitFieldSchema,\n\ttype InsertableField,\n\ttype TreeFieldFromImplicitField,\n\ttype TreeLeafValue,\n\ttype UnsafeUnknownSchema,\n\tconciseFromCursor,\n\ttype ConciseTree,\n\tapplySchemaToParserOptions,\n\tcursorFromVerbose,\n\tverboseFromCursor,\n\ttype ParseOptions,\n\ttype VerboseTree,\n\ttype VerboseTreeNode,\n\ttoStoredSchema,\n\ttype EncodeOptions,\n\textractPersistedSchema,\n\tTreeViewConfiguration,\n\ttype TreeBranch,\n} from \"../simple-tree/index.js\";\nimport { fail, type JsonCompatible } from \"../util/index.js\";\nimport { noopValidator, type FluidClientVersion, type ICodecOptions } from \"../codec/index.js\";\nimport type { ITreeCursorSynchronous } from \"../core/index.js\";\nimport {\n\tcursorForMapTreeField,\n\tdefaultSchemaPolicy,\n\tisTreeValue,\n\tmakeFieldBatchCodec,\n\tmapTreeFromCursor,\n\tTreeCompressionStrategy,\n\ttype FieldBatch,\n\ttype FieldBatchEncodingContext,\n} from \"../feature-libraries/index.js\";\nimport { independentInitializedView, type ViewContent } from \"./independentView.js\";\nimport { SchematizingSimpleTreeView, ViewSlot } from \"./schematizingTreeView.js\";\n\n/**\n * Extensions to {@link Tree} and {@link TreeBeta} which are not yet stable.\n * @sealed @alpha\n */\nexport const TreeAlpha: {\n\t/**\n\t * Retrieve the {@link TreeBranch | branch}, if any, for the given node.\n\t * @param node - The node to query\n\t * @remarks If the node has already been inserted into the tree, this will return the branch associated with that node's {@link TreeView | view}.\n\t * Otherwise, it will return `undefined` (because the node has not yet been inserted and is therefore not part of a branch or view).\n\t *\n\t * This does not fork a new branch, but rather retrieves the _existing_ branch for the node.\n\t * To create a new branch, use e.g. {@link TreeBranch.fork | `myBranch.fork()`}.\n\t */\n\tbranch(node: TreeNode): TreeBranch | undefined;\n\n\t/**\n\t * Construct tree content that is compatible with the field defined by the provided `schema`.\n\t * @param schema - The schema for what to construct. As this is an {@link ImplicitFieldSchema}, a {@link FieldSchema}, {@link TreeNodeSchema} or {@link AllowedTypes} array can be provided.\n\t * @param data - The data used to construct the field content.\n\t * @remarks\n\t * When providing a {@link TreeNodeSchemaClass}, this is the same as invoking its constructor except that an unhydrated node can also be provided.\n\t * This function exists as a generalization that can be used in other cases as well,\n\t * such as when `undefined` might be allowed (for an optional field), or when the type should be inferred from the data when more than one type is possible.\n\t *\n\t * Like with {@link TreeNodeSchemaClass}'s constructor, it's an error to provide an existing node to this API.\n\t * For that case, use {@link TreeBeta.clone}.\n\t * @privateRemarks\n\t * There should be a way to provide a source for defaulted identifiers, wither via this API or some way to add them to its output later.\n\t */\n\tcreate<const TSchema extends ImplicitFieldSchema | UnsafeUnknownSchema>(\n\t\tschema: UnsafeUnknownSchema extends TSchema\n\t\t\t? ImplicitFieldSchema\n\t\t\t: TSchema & ImplicitFieldSchema,\n\t\tdata: InsertableField<TSchema>,\n\t): Unhydrated<\n\t\tTSchema extends ImplicitFieldSchema\n\t\t\t? TreeFieldFromImplicitField<TSchema>\n\t\t\t: TreeNode | TreeLeafValue | undefined\n\t>;\n\n\t/**\n\t * Less type safe version of {@link TreeAlpha.create}, suitable for importing data.\n\t * @remarks\n\t * Due to {@link ConciseTree} relying on type inference from the data, its use is somewhat limited.\n\t * This does not support {@link ConciseTree|ConciseTrees} with customized handle encodings or using persisted keys.\n\t * Use \"compressed\" or \"verbose\" formats for more flexibility.\n\t *\n\t * When using this function,\n\t * it is recommend to ensure your schema is unambiguous with {@link ITreeConfigurationOptions.preventAmbiguity}.\n\t * If the schema is ambiguous, consider using {@link TreeAlpha.create} and {@link Unhydrated} nodes where needed,\n\t * or using {@link TreeAlpha.(importVerbose:1)} and specify all types.\n\t *\n\t * Documented (and thus recoverable) error handling/reporting for this is not yet implemented,\n\t * but for now most invalid inputs will throw a recoverable error.\n\t */\n\timportConcise<const TSchema extends ImplicitFieldSchema | UnsafeUnknownSchema>(\n\t\tschema: UnsafeUnknownSchema extends TSchema\n\t\t\t? ImplicitFieldSchema\n\t\t\t: TSchema & ImplicitFieldSchema,\n\t\tdata: ConciseTree | undefined,\n\t): Unhydrated<\n\t\tTSchema extends ImplicitFieldSchema\n\t\t\t? TreeFieldFromImplicitField<TSchema>\n\t\t\t: TreeNode | TreeLeafValue | undefined\n\t>;\n\n\t/**\n\t * Construct tree content compatible with a field defined by the provided `schema`.\n\t * @param schema - The schema for what to construct. As this is an {@link ImplicitFieldSchema}, a {@link FieldSchema}, {@link TreeNodeSchema} or {@link AllowedTypes} array can be provided.\n\t * @param data - The data used to construct the field content. See {@link TreeAlpha.(exportVerbose:1)}.\n\t * @remarks\n\t * This overload requires that any {@link @fluidframework/core-interfaces#IFluidHandle|IFluidHandles} are encoded as actual {@link @fluidframework/core-interfaces#IFluidHandle|IFluidHandles} in the input.\n\t */\n\timportVerbose<const TSchema extends ImplicitFieldSchema>(\n\t\tschema: TSchema,\n\t\tdata: VerboseTree | undefined,\n\t\toptions?: Partial<ParseOptions<IFluidHandle>>,\n\t): Unhydrated<TreeFieldFromImplicitField<TSchema>>;\n\n\t/**\n\t * Construct tree content compatible with a field defined by the provided `schema`.\n\t * @param schema - The schema for what to construct. As this is an {@link ImplicitFieldSchema}, a {@link FieldSchema}, {@link TreeNodeSchema} or {@link AllowedTypes} array can be provided.\n\t * @param data - The data used to construct the field content. See {@link TreeAlpha.(exportVerbose:2)}.\n\t *\n\t * @typeparam THandle - How {@link @fluidframework/core-interfaces#IFluidHandle|IFluidHandles} in the input `data` are encoded.\n\t * A converter from this encoding to {@link @fluidframework/core-interfaces#IFluidHandle} is required in `options`.\n\t */\n\timportVerbose<const TSchema extends ImplicitFieldSchema, THandle>(\n\t\tschema: TSchema,\n\t\tdata: VerboseTree<THandle> | undefined,\n\t\toptions: ParseOptions<THandle>,\n\t): Unhydrated<TreeFieldFromImplicitField<TSchema>>;\n\n\t/**\n\t * Same as {@link TreeAlpha.(exportConcise:2)}, except leaves handles as is.\n\t */\n\texportConcise(\n\t\tnode: TreeNode | TreeLeafValue,\n\t\toptions?: Partial<EncodeOptions<IFluidHandle>>,\n\t): ConciseTree;\n\n\t/**\n\t * Copy a snapshot of the current version of a TreeNode into a {@link ConciseTree}.\n\t *\n\t * @typeparam THandle - How {@link @fluidframework/core-interfaces#IFluidHandle|IFluidHandles} in the output should be encoded.\n\t * A converter from from {@link @fluidframework/core-interfaces#IFluidHandle} to this format is required in `options`.\n\t */\n\texportConcise<THandle>(\n\t\tnode: TreeNode | TreeLeafValue,\n\t\toptions: EncodeOptions<THandle>,\n\t): ConciseTree<THandle>;\n\n\t/**\n\t * Same {@link TreeAlpha.(exportVerbose:2)} except leaves handles as is.\n\t */\n\texportVerbose(\n\t\tnode: TreeNode | TreeLeafValue,\n\t\toptions?: Partial<EncodeOptions<IFluidHandle>>,\n\t): VerboseTree;\n\n\t/**\n\t * Copy a snapshot of the current version of a TreeNode into a JSON compatible plain old JavaScript Object.\n\t * Verbose tree format, with explicit type on every node.\n\t *\n\t * @typeparam THandle - How {@link @fluidframework/core-interfaces#IFluidHandle|IFluidHandles} in the output should be encoded.\n\t * A converter from from {@link @fluidframework/core-interfaces#IFluidHandle} to this format is required in `options`.\n\t *\n\t * @remarks\n\t * There are several cases this may be preferred to {@link TreeAlpha.(exportConcise:2)}:\n\t *\n\t * 1. When not using {@link ITreeConfigurationOptions.preventAmbiguity} (or when using `useStableFieldKeys`), `exportConcise` can produce ambiguous data (the type may be unclear on some nodes).\n\t * `exportVerbose` will always be unambiguous and thus lossless.\n\t *\n\t * 2. When the data might be interpreted without access to the exact same view schema. In such cases, the types may be unknowable if not included.\n\t *\n\t * 3. When easy access to the type is desired.\n\t */\n\texportVerbose<T>(node: TreeNode | TreeLeafValue, options: EncodeOptions<T>): VerboseTree<T>;\n\n\t/**\n\t * Export the content of the provided `tree` in a compressed JSON compatible format.\n\t * @remarks\n\t * If an `idCompressor` is provided, it will be used to compress identifiers and thus will be needed to decompress the data.\n\t *\n\t * Always uses \"stored\" keys.\n\t * See {@link EncodeOptions.useStoredKeys} for details.\n\t * @privateRemarks\n\t * TODO: It is currently not clear how to work with the idCompressors correctly in the package API.\n\t * Better APIs should probably be provided as there is currently no way to associate an un-hydrated tree with an idCompressor,\n\t * Nor get the correct idCompressor from a subtree to use when exporting it.\n\t * Additionally using `createIdCompressor` to make an idCompressor is `@legacy` and thus not intended for use in this API surface.\n\t * It would probably make more sense if we provided a way to get an idCompressor from the context of a node,\n\t * which could be optional (and settable if missing) for un0hydrated nodes and required for hydrated ones.\n\t * Add in a stable public APi for creating idCompressors, and a way to get them from a tree (without view schema), and that should address the anticipated use-cases.\n\t */\n\texportCompressed(\n\t\ttree: TreeNode | TreeLeafValue,\n\t\toptions: { oldestCompatibleClient: FluidClientVersion; idCompressor?: IIdCompressor },\n\t): JsonCompatible<IFluidHandle>;\n\n\t/**\n\t * Import data encoded by {@link TreeAlpha.exportCompressed}.\n\t *\n\t * @param schema - Schema with which the data must be compatible. This compatibility is not verified and must be ensured by the caller.\n\t * @param compressedData - Data compressed by {@link TreeAlpha.exportCompressed}.\n\t * @param options - If {@link TreeAlpha.exportCompressed} was given an `idCompressor`, it must be provided here.\n\t *\n\t * @remarks\n\t * If the data could have been encoded with a different schema, consider encoding the schema along side it using {@link extractPersistedSchema} and loading the data using {@link independentView}.\n\t *\n\t * @privateRemarks\n\t * This API could be improved:\n\t *\n\t * 1. It could validate that the schema is compatible, and return or throw an error in the invalid case (maybe add a \"try\" version).\n\t * 2. A \"try\" version of this could return an error if the data isn't in a supported format (as determined by version and/or JasonValidator).\n\t * 3. Requiring the caller provide a JsonValidator isn't the most friendly API. It might be practical to provide a default.\n\t */\n\timportCompressed<const TSchema extends ImplicitFieldSchema>(\n\t\tschema: TSchema,\n\t\tcompressedData: JsonCompatible<IFluidHandle>,\n\t\toptions: { idCompressor?: IIdCompressor } & ICodecOptions,\n\t): Unhydrated<TreeFieldFromImplicitField<TSchema>>;\n} = {\n\tbranch(node: TreeNode): TreeBranch | undefined {\n\t\tconst kernel = getKernel(node);\n\t\tif (!kernel.isHydrated()) {\n\t\t\treturn undefined;\n\t\t}\n\t\tconst view = kernel.anchorNode.anchorSet.slots.get(ViewSlot);\n\t\tassert(\n\t\t\tview instanceof SchematizingSimpleTreeView,\n\t\t\t0xa5c /* Unexpected view implementation */,\n\t\t);\n\t\treturn view;\n\t},\n\n\tcreate: createFromInsertable,\n\n\timportConcise<TSchema extends ImplicitFieldSchema | UnsafeUnknownSchema>(\n\t\tschema: UnsafeUnknownSchema extends TSchema\n\t\t\t? ImplicitFieldSchema\n\t\t\t: TSchema & ImplicitFieldSchema,\n\t\tdata: ConciseTree | undefined,\n\t): Unhydrated<\n\t\tTSchema extends ImplicitFieldSchema\n\t\t\t? TreeFieldFromImplicitField<TSchema>\n\t\t\t: TreeNode | TreeLeafValue | undefined\n\t> {\n\t\treturn createFromInsertable<UnsafeUnknownSchema>(\n\t\t\tschema,\n\t\t\tdata as InsertableField<UnsafeUnknownSchema>,\n\t\t) as Unhydrated<\n\t\t\tTSchema extends ImplicitFieldSchema\n\t\t\t\t? TreeFieldFromImplicitField<TSchema>\n\t\t\t\t: TreeNode | TreeLeafValue | undefined\n\t\t>;\n\t},\n\n\timportVerbose<const TSchema extends ImplicitFieldSchema, THandle>(\n\t\tschema: TSchema,\n\t\tdata: VerboseTree<THandle> | undefined,\n\t\toptions?: Partial<ParseOptions<THandle>>,\n\t): Unhydrated<TreeFieldFromImplicitField<TSchema>> {\n\t\tconst config: ParseOptions<THandle> = {\n\t\t\tvalueConverter: (input: VerboseTree<THandle>) => {\n\t\t\t\treturn input as TreeLeafValue | VerboseTreeNode<THandle>;\n\t\t\t},\n\t\t\t...options,\n\t\t};\n\t\t// Create a config which is standalone, and thus can be used without having to refer back to the schema.\n\t\tconst schemalessConfig = applySchemaToParserOptions(schema, config);\n\t\tif (data === undefined) {\n\t\t\tconst field = normalizeFieldSchema(schema);\n\t\t\tif (field.kind !== FieldKind.Optional) {\n\t\t\t\tthrow new UsageError(\"undefined provided for non-optional field.\");\n\t\t\t}\n\t\t\treturn undefined as Unhydrated<TreeFieldFromImplicitField<TSchema>>;\n\t\t}\n\t\tconst cursor = cursorFromVerbose<THandle>(data, schemalessConfig);\n\t\treturn createFromCursor(schema, cursor);\n\t},\n\n\texportConcise<T>(\n\t\tnode: TreeNode | TreeLeafValue,\n\t\toptions?: Partial<EncodeOptions<T>>,\n\t): ConciseTree<T> {\n\t\tconst config: EncodeOptions<T> = {\n\t\t\tvalueConverter(handle: IFluidHandle): T {\n\t\t\t\treturn handle as T;\n\t\t\t},\n\t\t\t...options,\n\t\t};\n\n\t\tconst cursor = borrowCursorFromTreeNodeOrValue(node);\n\t\treturn conciseFromCursor(\n\t\t\tcursor,\n\t\t\ttryGetSchema(node) ?? fail(0xacd /* invalid input */),\n\t\t\tconfig,\n\t\t);\n\t},\n\n\texportVerbose<T>(\n\t\tnode: TreeNode | TreeLeafValue,\n\t\toptions?: Partial<EncodeOptions<T>>,\n\t): VerboseTree<T> {\n\t\tconst config: EncodeOptions<T> = {\n\t\t\tvalueConverter(handle: IFluidHandle): T {\n\t\t\t\treturn handle as T;\n\t\t\t},\n\t\t\t...options,\n\t\t};\n\n\t\tconst cursor = borrowCursorFromTreeNodeOrValue(node);\n\t\treturn verboseFromCursor(\n\t\t\tcursor,\n\t\t\ttryGetSchema(node) ?? fail(0xace /* invalid input */),\n\t\t\tconfig,\n\t\t);\n\t},\n\n\texportCompressed(\n\t\tnode: TreeNode | TreeLeafValue,\n\t\toptions: {\n\t\t\toldestCompatibleClient: FluidClientVersion;\n\t\t\tidCompressor?: IIdCompressor;\n\t\t},\n\t): JsonCompatible<IFluidHandle> {\n\t\tconst schema = tryGetSchema(node) ?? fail(0xacf /* invalid input */);\n\t\tconst format = versionToFormat[options.oldestCompatibleClient];\n\t\tconst codec = makeFieldBatchCodec({ jsonValidator: noopValidator }, format);\n\t\tconst cursor = borrowFieldCursorFromTreeNodeOrValue(node);\n\t\tconst batch: FieldBatch = [cursor];\n\t\t// If none provided, create a compressor which will not compress anything.\n\t\tconst idCompressor = options.idCompressor ?? createIdCompressor();\n\t\tconst context: FieldBatchEncodingContext = {\n\t\t\tencodeType: TreeCompressionStrategy.Compressed,\n\t\t\tidCompressor,\n\t\t\toriginatorId: idCompressor.localSessionId, // TODO: Why is this needed?\n\t\t\tschema: { schema: toStoredSchema(schema), policy: defaultSchemaPolicy },\n\t\t};\n\t\tconst result = codec.encode(batch, context);\n\t\treturn result;\n\t},\n\n\timportCompressed<const TSchema extends ImplicitFieldSchema>(\n\t\tschema: TSchema,\n\t\tcompressedData: JsonCompatible<IFluidHandle>,\n\t\toptions: {\n\t\t\tidCompressor?: IIdCompressor;\n\t\t} & ICodecOptions,\n\t): Unhydrated<TreeFieldFromImplicitField<TSchema>> {\n\t\tconst content: ViewContent = {\n\t\t\tschema: extractPersistedSchema(schema),\n\t\t\ttree: compressedData,\n\t\t\tidCompressor: options.idCompressor ?? createIdCompressor(),\n\t\t};\n\t\tconst config = new TreeViewConfiguration({ schema });\n\t\tconst view = independentInitializedView(config, options, content);\n\t\treturn TreeBeta.clone<TSchema>(view.root);\n\t},\n};\n\nfunction borrowCursorFromTreeNodeOrValue(\n\tnode: TreeNode | TreeLeafValue,\n): ITreeCursorSynchronous {\n\tif (isTreeValue(node)) {\n\t\treturn cursorFromInsertable<UnsafeUnknownSchema>(\n\t\t\ttryGetSchema(node) ?? fail(0xad0 /* missing schema */),\n\t\t\tnode,\n\t\t);\n\t}\n\tconst kernel = getKernel(node);\n\tconst cursor = kernel.getOrCreateInnerNode().borrowCursor();\n\treturn cursor;\n}\n\nfunction borrowFieldCursorFromTreeNodeOrValue(\n\tnode: TreeNode | TreeLeafValue,\n): ITreeCursorSynchronous {\n\tconst cursor = borrowCursorFromTreeNodeOrValue(node);\n\t// TODO: avoid copy\n\tconst mapTree = mapTreeFromCursor(cursor);\n\treturn cursorForMapTreeField([mapTree]);\n}\n\nconst versionToFormat = {\n\tv2_0: 1,\n\tv2_1: 1,\n\tv2_2: 1,\n\tv2_3: 1,\n};\n"]}
1
+ {"version":3,"file":"treeApiAlpha.js","sourceRoot":"","sources":["../../src/shared-tree/treeApiAlpha.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAC7D,OAAO,EAAE,kBAAkB,EAAE,MAAM,wCAAwC,CAAC;AAC5E,OAAO,EAAE,UAAU,EAAE,MAAM,0CAA0C,CAAC;AAItE,OAAO,EACN,SAAS,EAGT,QAAQ,EACR,YAAY,EACZ,gBAAgB,EAChB,oBAAoB,EACpB,oBAAoB,EACpB,SAAS,EACT,oBAAoB,EAMpB,iBAAiB,EAEjB,0BAA0B,EAC1B,iBAAiB,EACjB,iBAAiB,EAGjB,cAAc,EAEd,sBAAsB,EACtB,qBAAqB,GAErB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,IAAI,EAAuB,MAAM,kBAAkB,CAAC;AAC7D,OAAO,EAAE,aAAa,EAA+C,MAAM,mBAAmB,CAAC;AAE/F,OAAO,EACN,qBAAqB,EACrB,mBAAmB,EACnB,WAAW,EACX,mBAAmB,EACnB,iBAAiB,EACjB,uBAAuB,GAGvB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,0BAA0B,EAAoB,MAAM,sBAAsB,CAAC;AACpF,OAAO,EAAE,0BAA0B,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAEjF;;;GAGG;AACH,MAAM,CAAC,MAAM,SAAS,GA0IlB;IACH,MAAM,CAAC,IAAc;QACpB,MAAM,MAAM,GAAG,SAAS,CAAC,IAAI,CAAC,CAAC;QAC/B,IAAI,CAAC,MAAM,CAAC,UAAU,EAAE,EAAE,CAAC;YAC1B,OAAO,SAAS,CAAC;QAClB,CAAC;QACD,MAAM,IAAI,GAAG,MAAM,C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IAAI,EAAE,cAAc;YACpB,YAAY,EAAE,OAAO,CAAC,YAAY,IAAI,kBAAkB,EAAE;SAC1D,CAAC;QACF,MAAM,MAAM,GAAG,IAAI,qBAAqB,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC;QACrD,MAAM,IAAI,GAAG,0BAA0B,CAAC,MAAM,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;QAClE,OAAO,QAAQ,CAAC,KAAK,CAAU,IAAI,CAAC,IAAI,CAAC,CAAC;IAC3C,CAAC;CACD,CAAC;AAEF,SAAS,+BAA+B,CACvC,IAA8B;IAE9B,IAAI,WAAW,CAAC,IAAI,CAAC,EAAE,CAAC;QACvB,OAAO,oBAAoB,CAC1B,YAAY,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,KAAK,CAAC,oBAAoB,CAAC,EACtD,IAAI,CACJ,CAAC;IACH,CAAC;IACD,MAAM,MAAM,GAAG,SAAS,CAAC,IAAI,CAAC,CAAC;IAC/B,MAAM,MAAM,GAAG,MAAM,CAAC,oBAAoB,EAAE,CAAC,YAAY,EAAE,CAAC;IAC5D,OAAO,MAAM,CAAC;AACf,CAAC;AAED,SAAS,oCAAoC,CAC5C,IAA8B;IAE9B,MAAM,MAAM,GAAG,+BAA+B,CAAC,IAAI,CAAC,CAAC;IACrD,mBAAmB;IACnB,MAAM,OAAO,GAAG,iBAAiB,CAAC,MAAM,CAAC,CAAC;IAC1C,OAAO,qBAAqB,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC;AACzC,CAAC;AAED,MAAM,eAAe,GAAG;IACvB,IAAI,EAAE,CAAC;IACP,IAAI,EAAE,CAAC;IACP,IAAI,EAAE,CAAC;IACP,IAAI,EAAE,CAAC;CACP,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\";\nimport { createIdCompressor } from \"@fluidframework/id-compressor/internal\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\nimport type { IFluidHandle } from \"@fluidframework/core-interfaces\";\nimport type { IIdCompressor } from \"@fluidframework/id-compressor\";\n\nimport {\n\tgetKernel,\n\ttype TreeNode,\n\ttype Unhydrated,\n\tTreeBeta,\n\ttryGetSchema,\n\tcreateFromCursor,\n\tcreateFromInsertable,\n\tcursorFromInsertable,\n\tFieldKind,\n\tnormalizeFieldSchema,\n\ttype ImplicitFieldSchema,\n\ttype InsertableField,\n\ttype TreeFieldFromImplicitField,\n\ttype TreeLeafValue,\n\ttype UnsafeUnknownSchema,\n\tconciseFromCursor,\n\ttype ConciseTree,\n\tapplySchemaToParserOptions,\n\tcursorFromVerbose,\n\tverboseFromCursor,\n\ttype ParseOptions,\n\ttype VerboseTree,\n\ttoStoredSchema,\n\ttype EncodeOptions,\n\textractPersistedSchema,\n\tTreeViewConfiguration,\n\ttype TreeBranch,\n} from \"../simple-tree/index.js\";\nimport { fail, type JsonCompatible } from \"../util/index.js\";\nimport { noopValidator, type FluidClientVersion, type ICodecOptions } from \"../codec/index.js\";\nimport type { ITreeCursorSynchronous } from \"../core/index.js\";\nimport {\n\tcursorForMapTreeField,\n\tdefaultSchemaPolicy,\n\tisTreeValue,\n\tmakeFieldBatchCodec,\n\tmapTreeFromCursor,\n\tTreeCompressionStrategy,\n\ttype FieldBatch,\n\ttype FieldBatchEncodingContext,\n} from \"../feature-libraries/index.js\";\nimport { independentInitializedView, type ViewContent } from \"./independentView.js\";\nimport { SchematizingSimpleTreeView, ViewSlot } from \"./schematizingTreeView.js\";\n\n/**\n * Extensions to {@link Tree} and {@link TreeBeta} which are not yet stable.\n * @sealed @alpha\n */\nexport const TreeAlpha: {\n\t/**\n\t * Retrieve the {@link TreeBranch | branch}, if any, for the given node.\n\t * @param node - The node to query\n\t * @remarks If the node has already been inserted into the tree, this will return the branch associated with that node's {@link TreeView | view}.\n\t * Otherwise, it will return `undefined` (because the node has not yet been inserted and is therefore not part of a branch or view).\n\t *\n\t * This does not fork a new branch, but rather retrieves the _existing_ branch for the node.\n\t * To create a new branch, use e.g. {@link TreeBranch.fork | `myBranch.fork()`}.\n\t */\n\tbranch(node: TreeNode): TreeBranch | undefined;\n\n\t/**\n\t * Construct tree content that is compatible with the field defined by the provided `schema`.\n\t * @param schema - The schema for what to construct. As this is an {@link ImplicitFieldSchema}, a {@link FieldSchema}, {@link TreeNodeSchema} or {@link AllowedTypes} array can be provided.\n\t * @param data - The data used to construct the field content.\n\t * @remarks\n\t * When providing a {@link TreeNodeSchemaClass}, this is the same as invoking its constructor except that an unhydrated node can also be provided.\n\t * This function exists as a generalization that can be used in other cases as well,\n\t * such as when `undefined` might be allowed (for an optional field), or when the type should be inferred from the data when more than one type is possible.\n\t *\n\t * Like with {@link TreeNodeSchemaClass}'s constructor, it's an error to provide an existing node to this API.\n\t * For that case, use {@link TreeBeta.clone}.\n\t * @privateRemarks\n\t * There should be a way to provide a source for defaulted identifiers, wither via this API or some way to add them to its output later.\n\t */\n\tcreate<const TSchema extends ImplicitFieldSchema | UnsafeUnknownSchema>(\n\t\tschema: UnsafeUnknownSchema extends TSchema\n\t\t\t? ImplicitFieldSchema\n\t\t\t: TSchema & ImplicitFieldSchema,\n\t\tdata: InsertableField<TSchema>,\n\t): Unhydrated<\n\t\tTSchema extends ImplicitFieldSchema\n\t\t\t? TreeFieldFromImplicitField<TSchema>\n\t\t\t: TreeNode | TreeLeafValue | undefined\n\t>;\n\n\t/**\n\t * Less type safe version of {@link TreeAlpha.create}, suitable for importing data.\n\t * @remarks\n\t * Due to {@link ConciseTree} relying on type inference from the data, its use is somewhat limited.\n\t * This does not support {@link ConciseTree|ConciseTrees} with customized handle encodings or using persisted keys.\n\t * Use \"compressed\" or \"verbose\" formats for more flexibility.\n\t *\n\t * When using this function,\n\t * it is recommend to ensure your schema is unambiguous with {@link ITreeConfigurationOptions.preventAmbiguity}.\n\t * If the schema is ambiguous, consider using {@link TreeAlpha.create} and {@link Unhydrated} nodes where needed,\n\t * or using {@link TreeAlpha.(importVerbose:1)} and specify all types.\n\t *\n\t * Documented (and thus recoverable) error handling/reporting for this is not yet implemented,\n\t * but for now most invalid inputs will throw a recoverable error.\n\t */\n\timportConcise<const TSchema extends ImplicitFieldSchema | UnsafeUnknownSchema>(\n\t\tschema: UnsafeUnknownSchema extends TSchema\n\t\t\t? ImplicitFieldSchema\n\t\t\t: TSchema & ImplicitFieldSchema,\n\t\tdata: ConciseTree | undefined,\n\t): Unhydrated<\n\t\tTSchema extends ImplicitFieldSchema\n\t\t\t? TreeFieldFromImplicitField<TSchema>\n\t\t\t: TreeNode | TreeLeafValue | undefined\n\t>;\n\n\t/**\n\t * Construct tree content compatible with a field defined by the provided `schema`.\n\t * @param schema - The schema for what to construct. As this is an {@link ImplicitFieldSchema}, a {@link FieldSchema}, {@link TreeNodeSchema} or {@link AllowedTypes} array can be provided.\n\t * @param data - The data used to construct the field content. See {@link TreeAlpha.(exportVerbose:1)}.\n\t */\n\timportVerbose<const TSchema extends ImplicitFieldSchema>(\n\t\tschema: TSchema,\n\t\tdata: VerboseTree | undefined,\n\t\toptions?: Partial<ParseOptions>,\n\t): Unhydrated<TreeFieldFromImplicitField<TSchema>>;\n\n\t/**\n\t * Copy a snapshot of the current version of a TreeNode into a {@link ConciseTree}.\n\t */\n\texportConcise(node: TreeNode | TreeLeafValue, options?: EncodeOptions): ConciseTree;\n\n\t/**\n\t * Copy a snapshot of the current version of a TreeNode into a JSON compatible plain old JavaScript Object (except for {@link @fluidframework/core-interfaces#IFluidHandle|IFluidHandles}).\n\t * Uses the {@link VerboseTree} format, with an explicit type on every node.\n\t *\n\t * @remarks\n\t * There are several cases this may be preferred to {@link TreeAlpha.exportConcise}:\n\t *\n\t * 1. When not using {@link ITreeConfigurationOptions.preventAmbiguity} (or when using `useStableFieldKeys`), `exportConcise` can produce ambiguous data (the type may be unclear on some nodes).\n\t * `exportVerbose` will always be unambiguous and thus lossless.\n\t *\n\t * 2. When the data might be interpreted without access to the exact same view schema. In such cases, the types may be unknowable if not included.\n\t *\n\t * 3. When easy access to the type is desired.\n\t */\n\texportVerbose(node: TreeNode | TreeLeafValue, options?: EncodeOptions): VerboseTree;\n\n\t/**\n\t * Export the content of the provided `tree` in a compressed JSON compatible format.\n\t * @remarks\n\t * If an `idCompressor` is provided, it will be used to compress identifiers and thus will be needed to decompress the data.\n\t *\n\t * Always uses \"stored\" keys.\n\t * See {@link EncodeOptions.useStoredKeys} for details.\n\t * @privateRemarks\n\t * TODO: It is currently not clear how to work with the idCompressors correctly in the package API.\n\t * Better APIs should probably be provided as there is currently no way to associate an un-hydrated tree with an idCompressor,\n\t * Nor get the correct idCompressor from a subtree to use when exporting it.\n\t * Additionally using `createIdCompressor` to make an idCompressor is `@legacy` and thus not intended for use in this API surface.\n\t * It would probably make more sense if we provided a way to get an idCompressor from the context of a node,\n\t * which could be optional (and settable if missing) for un0hydrated nodes and required for hydrated ones.\n\t * Add in a stable public APi for creating idCompressors, and a way to get them from a tree (without view schema), and that should address the anticipated use-cases.\n\t */\n\texportCompressed(\n\t\ttree: TreeNode | TreeLeafValue,\n\t\toptions: { oldestCompatibleClient: FluidClientVersion; idCompressor?: IIdCompressor },\n\t): JsonCompatible<IFluidHandle>;\n\n\t/**\n\t * Import data encoded by {@link TreeAlpha.exportCompressed}.\n\t *\n\t * @param schema - Schema with which the data must be compatible. This compatibility is not verified and must be ensured by the caller.\n\t * @param compressedData - Data compressed by {@link TreeAlpha.exportCompressed}.\n\t * @param options - If {@link TreeAlpha.exportCompressed} was given an `idCompressor`, it must be provided here.\n\t *\n\t * @remarks\n\t * If the data could have been encoded with a different schema, consider encoding the schema along side it using {@link extractPersistedSchema} and loading the data using {@link independentView}.\n\t *\n\t * @privateRemarks\n\t * This API could be improved:\n\t *\n\t * 1. It could validate that the schema is compatible, and return or throw an error in the invalid case (maybe add a \"try\" version).\n\t * 2. A \"try\" version of this could return an error if the data isn't in a supported format (as determined by version and/or JasonValidator).\n\t * 3. Requiring the caller provide a JsonValidator isn't the most friendly API. It might be practical to provide a default.\n\t */\n\timportCompressed<const TSchema extends ImplicitFieldSchema>(\n\t\tschema: TSchema,\n\t\tcompressedData: JsonCompatible<IFluidHandle>,\n\t\toptions: { idCompressor?: IIdCompressor } & ICodecOptions,\n\t): Unhydrated<TreeFieldFromImplicitField<TSchema>>;\n} = {\n\tbranch(node: TreeNode): TreeBranch | undefined {\n\t\tconst kernel = getKernel(node);\n\t\tif (!kernel.isHydrated()) {\n\t\t\treturn undefined;\n\t\t}\n\t\tconst view = kernel.anchorNode.anchorSet.slots.get(ViewSlot);\n\t\tassert(\n\t\t\tview instanceof SchematizingSimpleTreeView,\n\t\t\t0xa5c /* Unexpected view implementation */,\n\t\t);\n\t\treturn view;\n\t},\n\n\tcreate: createFromInsertable,\n\n\timportConcise<TSchema extends ImplicitFieldSchema | UnsafeUnknownSchema>(\n\t\tschema: UnsafeUnknownSchema extends TSchema\n\t\t\t? ImplicitFieldSchema\n\t\t\t: TSchema & ImplicitFieldSchema,\n\t\tdata: ConciseTree | undefined,\n\t): Unhydrated<\n\t\tTSchema extends ImplicitFieldSchema\n\t\t\t? TreeFieldFromImplicitField<TSchema>\n\t\t\t: TreeNode | TreeLeafValue | undefined\n\t> {\n\t\treturn createFromInsertable<UnsafeUnknownSchema>(\n\t\t\tschema,\n\t\t\tdata as InsertableField<UnsafeUnknownSchema>,\n\t\t) as Unhydrated<\n\t\t\tTSchema extends ImplicitFieldSchema\n\t\t\t\t? TreeFieldFromImplicitField<TSchema>\n\t\t\t\t: TreeNode | TreeLeafValue | undefined\n\t\t>;\n\t},\n\n\timportVerbose<const TSchema extends ImplicitFieldSchema>(\n\t\tschema: TSchema,\n\t\tdata: VerboseTree | undefined,\n\t\toptions?: ParseOptions,\n\t): Unhydrated<TreeFieldFromImplicitField<TSchema>> {\n\t\tconst config: ParseOptions = { ...options };\n\t\t// Create a config which is standalone, and thus can be used without having to refer back to the schema.\n\t\tconst schemalessConfig = applySchemaToParserOptions(schema, config);\n\t\tif (data === undefined) {\n\t\t\tconst field = normalizeFieldSchema(schema);\n\t\t\tif (field.kind !== FieldKind.Optional) {\n\t\t\t\tthrow new UsageError(\"undefined provided for non-optional field.\");\n\t\t\t}\n\t\t\treturn undefined as Unhydrated<TreeFieldFromImplicitField<TSchema>>;\n\t\t}\n\t\tconst cursor = cursorFromVerbose(data, schemalessConfig);\n\t\treturn createFromCursor(schema, cursor);\n\t},\n\n\texportConcise(node: TreeNode | TreeLeafValue, options?: EncodeOptions): ConciseTree {\n\t\tconst config: EncodeOptions = { ...options };\n\n\t\tconst cursor = borrowCursorFromTreeNodeOrValue(node);\n\t\treturn conciseFromCursor(\n\t\t\tcursor,\n\t\t\ttryGetSchema(node) ?? fail(0xacd /* invalid input */),\n\t\t\tconfig,\n\t\t);\n\t},\n\n\texportVerbose(node: TreeNode | TreeLeafValue, options?: EncodeOptions): VerboseTree {\n\t\tconst config: EncodeOptions = { ...options };\n\n\t\tconst cursor = borrowCursorFromTreeNodeOrValue(node);\n\t\treturn verboseFromCursor(\n\t\t\tcursor,\n\t\t\ttryGetSchema(node) ?? fail(0xace /* invalid input */),\n\t\t\tconfig,\n\t\t);\n\t},\n\n\texportCompressed(\n\t\tnode: TreeNode | TreeLeafValue,\n\t\toptions: {\n\t\t\toldestCompatibleClient: FluidClientVersion;\n\t\t\tidCompressor?: IIdCompressor;\n\t\t},\n\t): JsonCompatible<IFluidHandle> {\n\t\tconst schema = tryGetSchema(node) ?? fail(0xacf /* invalid input */);\n\t\tconst format = versionToFormat[options.oldestCompatibleClient];\n\t\tconst codec = makeFieldBatchCodec({ jsonValidator: noopValidator }, format);\n\t\tconst cursor = borrowFieldCursorFromTreeNodeOrValue(node);\n\t\tconst batch: FieldBatch = [cursor];\n\t\t// If none provided, create a compressor which will not compress anything.\n\t\tconst idCompressor = options.idCompressor ?? createIdCompressor();\n\t\tconst context: FieldBatchEncodingContext = {\n\t\t\tencodeType: TreeCompressionStrategy.Compressed,\n\t\t\tidCompressor,\n\t\t\toriginatorId: idCompressor.localSessionId, // TODO: Why is this needed?\n\t\t\tschema: { schema: toStoredSchema(schema), policy: defaultSchemaPolicy },\n\t\t};\n\t\tconst result = codec.encode(batch, context);\n\t\treturn result;\n\t},\n\n\timportCompressed<const TSchema extends ImplicitFieldSchema>(\n\t\tschema: TSchema,\n\t\tcompressedData: JsonCompatible<IFluidHandle>,\n\t\toptions: {\n\t\t\tidCompressor?: IIdCompressor;\n\t\t} & ICodecOptions,\n\t): Unhydrated<TreeFieldFromImplicitField<TSchema>> {\n\t\tconst content: ViewContent = {\n\t\t\tschema: extractPersistedSchema(schema),\n\t\t\ttree: compressedData,\n\t\t\tidCompressor: options.idCompressor ?? createIdCompressor(),\n\t\t};\n\t\tconst config = new TreeViewConfiguration({ schema });\n\t\tconst view = independentInitializedView(config, options, content);\n\t\treturn TreeBeta.clone<TSchema>(view.root);\n\t},\n};\n\nfunction borrowCursorFromTreeNodeOrValue(\n\tnode: TreeNode | TreeLeafValue,\n): ITreeCursorSynchronous {\n\tif (isTreeValue(node)) {\n\t\treturn cursorFromInsertable<UnsafeUnknownSchema>(\n\t\t\ttryGetSchema(node) ?? fail(0xad0 /* missing schema */),\n\t\t\tnode,\n\t\t);\n\t}\n\tconst kernel = getKernel(node);\n\tconst cursor = kernel.getOrCreateInnerNode().borrowCursor();\n\treturn cursor;\n}\n\nfunction borrowFieldCursorFromTreeNodeOrValue(\n\tnode: TreeNode | TreeLeafValue,\n): ITreeCursorSynchronous {\n\tconst cursor = borrowCursorFromTreeNodeOrValue(node);\n\t// TODO: avoid copy\n\tconst mapTree = mapTreeFromCursor(cursor);\n\treturn cursorForMapTreeField([mapTree]);\n}\n\nconst versionToFormat = {\n\tv2_0: 1,\n\tv2_1: 1,\n\tv2_2: 1,\n\tv2_3: 1,\n};\n"]}
@@ -19,7 +19,7 @@ import { createEmitter } from "@fluid-internal/client-utils";
19
19
  import { UsageError, } from "@fluidframework/telemetry-utils/internal";
20
20
  import { noopValidator } from "../codec/index.js";
21
21
  import { AnchorSet, CommitKind, RevertibleStatus, TreeStoredSchemaRepository, combineVisitors, makeDetachedFieldIndex, rebaseChange, rootFieldKey, tagChange, visitDelta, isAncestor, } from "../core/index.js";
22
- import { buildForest, createNodeKeyManager, intoDelta, jsonableTreeFromCursor, makeFieldBatchCodec, } from "../feature-libraries/index.js";
22
+ import { buildForest, createNodeIdentifierManager, intoDelta, jsonableTreeFromCursor, makeFieldBatchCodec, } from "../feature-libraries/index.js";
23
23
  import { SquashingTransactionStack, SharedTreeBranch, TransactionResult, onForkTransitive, } from "../shared-tree-core/index.js";
24
24
  import { Breakable, disposeSymbol, fail, getOrCreate, } from "../util/index.js";
25
25
  import { SharedTreeChangeFamily, hasSchemaChange } from "./sharedTreeChangeFamily.js";
@@ -294,7 +294,7 @@ export class TreeCheckout {
294
294
  return revertible;
295
295
  }
296
296
  viewWith(config) {
297
- const view = new SchematizingSimpleTreeView(this, config, createNodeKeyManager(this.idCompressor), () => {
297
+ const view = new SchematizingSimpleTreeView(this, config, createNodeIdentifierManager(this.idCompressor), () => {
298
298
  this.views.delete(view);
299
299
  });
300
300
  this.views.add(view);