@fluidframework/tree 2.41.0-338401 → 2.41.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 (974) hide show
  1. package/CHANGELOG.md +341 -0
  2. package/api-report/tree.alpha.api.md +10 -0
  3. package/dist/alpha.d.ts +1 -0
  4. package/dist/codec/codec.d.ts +10 -0
  5. package/dist/codec/codec.d.ts.map +1 -1
  6. package/dist/codec/codec.js +13 -3
  7. package/dist/codec/codec.js.map +1 -1
  8. package/dist/core/index.d.ts +1 -1
  9. package/dist/core/index.d.ts.map +1 -1
  10. package/dist/core/index.js +2 -1
  11. package/dist/core/index.js.map +1 -1
  12. package/dist/core/rebase/types.d.ts +2 -2
  13. package/dist/core/rebase/types.js +2 -2
  14. package/dist/core/rebase/types.js.map +1 -1
  15. package/dist/core/rebase/utils.d.ts +0 -2
  16. package/dist/core/rebase/utils.d.ts.map +1 -1
  17. package/dist/core/rebase/utils.js +6 -10
  18. package/dist/core/rebase/utils.js.map +1 -1
  19. package/dist/core/schema-stored/formatV1.d.ts +0 -1
  20. package/dist/core/schema-stored/formatV1.d.ts.map +1 -1
  21. package/dist/core/schema-stored/formatV1.js +1 -2
  22. package/dist/core/schema-stored/formatV1.js.map +1 -1
  23. package/dist/core/schema-stored/index.d.ts +1 -1
  24. package/dist/core/schema-stored/index.d.ts.map +1 -1
  25. package/dist/core/schema-stored/index.js +2 -1
  26. package/dist/core/schema-stored/index.js.map +1 -1
  27. package/dist/core/schema-stored/schema.d.ts +6 -0
  28. package/dist/core/schema-stored/schema.d.ts.map +1 -1
  29. package/dist/core/schema-stored/schema.js +8 -1
  30. package/dist/core/schema-stored/schema.js.map +1 -1
  31. package/dist/core/tree/anchorSet.d.ts +2 -1
  32. package/dist/core/tree/anchorSet.d.ts.map +1 -1
  33. package/dist/core/tree/anchorSet.js +2 -1
  34. package/dist/core/tree/anchorSet.js.map +1 -1
  35. package/dist/core/tree/pathTree.d.ts +12 -11
  36. package/dist/core/tree/pathTree.d.ts.map +1 -1
  37. package/dist/core/tree/pathTree.js +8 -7
  38. package/dist/core/tree/pathTree.js.map +1 -1
  39. package/dist/core/tree/treeTextFormat.d.ts +1 -1
  40. package/dist/core/tree/treeTextFormat.js +1 -1
  41. package/dist/core/tree/treeTextFormat.js.map +1 -1
  42. package/dist/feature-libraries/chunked-forest/chunkedForest.d.ts +1 -1
  43. package/dist/feature-libraries/chunked-forest/chunkedForest.js +1 -1
  44. package/dist/feature-libraries/chunked-forest/chunkedForest.js.map +1 -1
  45. package/dist/feature-libraries/default-schema/defaultEditBuilder.js +1 -1
  46. package/dist/feature-libraries/default-schema/defaultEditBuilder.js.map +1 -1
  47. package/dist/feature-libraries/default-schema/index.d.ts +1 -1
  48. package/dist/feature-libraries/default-schema/index.d.ts.map +1 -1
  49. package/dist/feature-libraries/default-schema/index.js +2 -2
  50. package/dist/feature-libraries/default-schema/index.js.map +1 -1
  51. package/dist/feature-libraries/default-schema/schemaChecker.d.ts +15 -15
  52. package/dist/feature-libraries/default-schema/schemaChecker.d.ts.map +1 -1
  53. package/dist/feature-libraries/default-schema/schemaChecker.js +50 -35
  54. package/dist/feature-libraries/default-schema/schemaChecker.js.map +1 -1
  55. package/dist/feature-libraries/flex-tree/context.d.ts +18 -2
  56. package/dist/feature-libraries/flex-tree/context.d.ts.map +1 -1
  57. package/dist/feature-libraries/flex-tree/context.js +22 -6
  58. package/dist/feature-libraries/flex-tree/context.js.map +1 -1
  59. package/dist/feature-libraries/flex-tree/flexTreeTypes.d.ts +3 -2
  60. package/dist/feature-libraries/flex-tree/flexTreeTypes.d.ts.map +1 -1
  61. package/dist/feature-libraries/flex-tree/flexTreeTypes.js +3 -2
  62. package/dist/feature-libraries/flex-tree/flexTreeTypes.js.map +1 -1
  63. package/dist/feature-libraries/flex-tree/lazyField.d.ts.map +1 -1
  64. package/dist/feature-libraries/flex-tree/lazyField.js +1 -1
  65. package/dist/feature-libraries/flex-tree/lazyField.js.map +1 -1
  66. package/dist/feature-libraries/flex-tree/utilities.d.ts.map +1 -1
  67. package/dist/feature-libraries/flex-tree/utilities.js.map +1 -1
  68. package/dist/feature-libraries/forest-summary/forestSummarizer.d.ts +1 -1
  69. package/dist/feature-libraries/forest-summary/forestSummarizer.d.ts.map +1 -1
  70. package/dist/feature-libraries/forest-summary/forestSummarizer.js.map +1 -1
  71. package/dist/feature-libraries/index.d.ts +2 -2
  72. package/dist/feature-libraries/index.d.ts.map +1 -1
  73. package/dist/feature-libraries/index.js +3 -4
  74. package/dist/feature-libraries/index.js.map +1 -1
  75. package/dist/feature-libraries/indexing/anchorTreeIndex.d.ts +2 -2
  76. package/dist/feature-libraries/indexing/anchorTreeIndex.d.ts.map +1 -1
  77. package/dist/feature-libraries/indexing/anchorTreeIndex.js +15 -15
  78. package/dist/feature-libraries/indexing/anchorTreeIndex.js.map +1 -1
  79. package/dist/feature-libraries/modular-schema/crossFieldQueries.d.ts.map +1 -1
  80. package/dist/feature-libraries/modular-schema/crossFieldQueries.js.map +1 -1
  81. package/dist/feature-libraries/modular-schema/fieldChangeHandler.d.ts +1 -1
  82. package/dist/feature-libraries/modular-schema/fieldChangeHandler.d.ts.map +1 -1
  83. package/dist/feature-libraries/modular-schema/fieldChangeHandler.js.map +1 -1
  84. package/dist/feature-libraries/modular-schema/fieldKindWithEditor.d.ts +1 -1
  85. package/dist/feature-libraries/modular-schema/fieldKindWithEditor.js +1 -1
  86. package/dist/feature-libraries/modular-schema/fieldKindWithEditor.js.map +1 -1
  87. package/dist/feature-libraries/modular-schema/genericFieldKind.d.ts.map +1 -1
  88. package/dist/feature-libraries/modular-schema/genericFieldKind.js +2 -2
  89. package/dist/feature-libraries/modular-schema/genericFieldKind.js.map +1 -1
  90. package/dist/feature-libraries/modular-schema/genericFieldKindCodecs.d.ts.map +1 -1
  91. package/dist/feature-libraries/modular-schema/genericFieldKindCodecs.js.map +1 -1
  92. package/dist/feature-libraries/modular-schema/genericFieldKindTypes.d.ts.map +1 -1
  93. package/dist/feature-libraries/modular-schema/genericFieldKindTypes.js.map +1 -1
  94. package/dist/feature-libraries/modular-schema/isNeverTree.d.ts +0 -2
  95. package/dist/feature-libraries/modular-schema/isNeverTree.d.ts.map +1 -1
  96. package/dist/feature-libraries/modular-schema/isNeverTree.js +0 -2
  97. package/dist/feature-libraries/modular-schema/isNeverTree.js.map +1 -1
  98. package/dist/feature-libraries/modular-schema/modularChangeCodecs.d.ts.map +1 -1
  99. package/dist/feature-libraries/modular-schema/modularChangeCodecs.js.map +1 -1
  100. package/dist/feature-libraries/modular-schema/modularChangeFamily.d.ts +2 -0
  101. package/dist/feature-libraries/modular-schema/modularChangeFamily.d.ts.map +1 -1
  102. package/dist/feature-libraries/modular-schema/modularChangeFamily.js +2 -0
  103. package/dist/feature-libraries/modular-schema/modularChangeFamily.js.map +1 -1
  104. package/dist/feature-libraries/modular-schema/modularChangeTypes.d.ts.map +1 -1
  105. package/dist/feature-libraries/modular-schema/modularChangeTypes.js.map +1 -1
  106. package/dist/feature-libraries/node-identifier/mockNodeIdentifierManager.d.ts.map +1 -1
  107. package/dist/feature-libraries/node-identifier/mockNodeIdentifierManager.js +8 -3
  108. package/dist/feature-libraries/node-identifier/mockNodeIdentifierManager.js.map +1 -1
  109. package/dist/feature-libraries/object-forest/objectForest.d.ts +22 -5
  110. package/dist/feature-libraries/object-forest/objectForest.d.ts.map +1 -1
  111. package/dist/feature-libraries/object-forest/objectForest.js +296 -207
  112. package/dist/feature-libraries/object-forest/objectForest.js.map +1 -1
  113. package/dist/feature-libraries/schema-edits/schemaChangeCodecs.d.ts +2 -2
  114. package/dist/feature-libraries/schema-edits/schemaChangeCodecs.d.ts.map +1 -1
  115. package/dist/feature-libraries/schema-edits/schemaChangeCodecs.js +3 -2
  116. package/dist/feature-libraries/schema-edits/schemaChangeCodecs.js.map +1 -1
  117. package/dist/feature-libraries/schema-edits/schemaChangeFormat.d.ts +2 -2
  118. package/dist/feature-libraries/schema-index/codec.d.ts +6 -12
  119. package/dist/feature-libraries/schema-index/codec.d.ts.map +1 -1
  120. package/dist/feature-libraries/schema-index/codec.js +8 -15
  121. package/dist/feature-libraries/schema-index/codec.js.map +1 -1
  122. package/dist/feature-libraries/schema-index/formatV1.d.ts +2 -2
  123. package/dist/feature-libraries/schema-index/formatV1.d.ts.map +1 -1
  124. package/dist/feature-libraries/schema-index/formatV1.js +1 -1
  125. package/dist/feature-libraries/schema-index/formatV1.js.map +1 -1
  126. package/dist/feature-libraries/schema-index/index.d.ts +1 -1
  127. package/dist/feature-libraries/schema-index/index.d.ts.map +1 -1
  128. package/dist/feature-libraries/schema-index/index.js +1 -2
  129. package/dist/feature-libraries/schema-index/index.js.map +1 -1
  130. package/dist/feature-libraries/schema-index/schemaSummarizer.d.ts +1 -1
  131. package/dist/feature-libraries/schema-index/schemaSummarizer.d.ts.map +1 -1
  132. package/dist/feature-libraries/schema-index/schemaSummarizer.js.map +1 -1
  133. package/dist/feature-libraries/sequence-field/formatV3.d.ts.map +1 -1
  134. package/dist/feature-libraries/sequence-field/formatV3.js.map +1 -1
  135. package/dist/feature-libraries/sequence-field/markQueue.d.ts.map +1 -1
  136. package/dist/feature-libraries/sequence-field/markQueue.js.map +1 -1
  137. package/dist/feature-libraries/sequence-field/prune.d.ts.map +1 -1
  138. package/dist/feature-libraries/sequence-field/prune.js.map +1 -1
  139. package/dist/feature-libraries/sequence-field/rebase.js +1 -1
  140. package/dist/feature-libraries/sequence-field/rebase.js.map +1 -1
  141. package/dist/feature-libraries/sequence-field/relevantRemovedRoots.d.ts +1 -1
  142. package/dist/feature-libraries/sequence-field/relevantRemovedRoots.d.ts.map +1 -1
  143. package/dist/feature-libraries/sequence-field/relevantRemovedRoots.js.map +1 -1
  144. package/dist/feature-libraries/sequence-field/replaceRevisions.d.ts.map +1 -1
  145. package/dist/feature-libraries/sequence-field/replaceRevisions.js.map +1 -1
  146. package/dist/feature-libraries/sequence-field/sequenceFieldCodecV1.d.ts +1 -1
  147. package/dist/feature-libraries/sequence-field/sequenceFieldCodecV1.d.ts.map +1 -1
  148. package/dist/feature-libraries/sequence-field/sequenceFieldCodecV1.js +1 -1
  149. package/dist/feature-libraries/sequence-field/sequenceFieldCodecV1.js.map +1 -1
  150. package/dist/feature-libraries/sequence-field/sequenceFieldCodecV2.d.ts +2 -2
  151. package/dist/feature-libraries/sequence-field/sequenceFieldCodecV2.d.ts.map +1 -1
  152. package/dist/feature-libraries/sequence-field/sequenceFieldCodecV2.js +1 -1
  153. package/dist/feature-libraries/sequence-field/sequenceFieldCodecV2.js.map +1 -1
  154. package/dist/feature-libraries/sequence-field/sequenceFieldCodecV3.d.ts +1 -1
  155. package/dist/feature-libraries/sequence-field/sequenceFieldCodecV3.d.ts.map +1 -1
  156. package/dist/feature-libraries/sequence-field/sequenceFieldCodecV3.js +2 -2
  157. package/dist/feature-libraries/sequence-field/sequenceFieldCodecV3.js.map +1 -1
  158. package/dist/feature-libraries/sequence-field/sequenceFieldCodecs.d.ts +1 -1
  159. package/dist/feature-libraries/sequence-field/sequenceFieldCodecs.d.ts.map +1 -1
  160. package/dist/feature-libraries/sequence-field/sequenceFieldCodecs.js.map +1 -1
  161. package/dist/feature-libraries/sequence-field/sequenceFieldToDelta.d.ts +1 -1
  162. package/dist/feature-libraries/sequence-field/sequenceFieldToDelta.d.ts.map +1 -1
  163. package/dist/feature-libraries/sequence-field/sequenceFieldToDelta.js.map +1 -1
  164. package/dist/feature-libraries/sequence-field/utils.d.ts +7 -5
  165. package/dist/feature-libraries/sequence-field/utils.d.ts.map +1 -1
  166. package/dist/feature-libraries/sequence-field/utils.js +7 -5
  167. package/dist/feature-libraries/sequence-field/utils.js.map +1 -1
  168. package/dist/feature-libraries/treeCursorUtils.js +2 -2
  169. package/dist/feature-libraries/treeCursorUtils.js.map +1 -1
  170. package/dist/feature-libraries/treeTextCursor.d.ts +1 -1
  171. package/dist/feature-libraries/treeTextCursor.js +1 -1
  172. package/dist/feature-libraries/treeTextCursor.js.map +1 -1
  173. package/dist/index.d.ts +2 -2
  174. package/dist/index.d.ts.map +1 -1
  175. package/dist/index.js +2 -6
  176. package/dist/index.js.map +1 -1
  177. package/dist/packageVersion.d.ts +1 -1
  178. package/dist/packageVersion.d.ts.map +1 -1
  179. package/dist/packageVersion.js +1 -1
  180. package/dist/packageVersion.js.map +1 -1
  181. package/dist/shared-tree/checkoutFlexTreeView.d.ts.map +1 -1
  182. package/dist/shared-tree/checkoutFlexTreeView.js.map +1 -1
  183. package/dist/shared-tree/independentView.d.ts +1 -1
  184. package/dist/shared-tree/independentView.d.ts.map +1 -1
  185. package/dist/shared-tree/independentView.js +8 -3
  186. package/dist/shared-tree/independentView.js.map +1 -1
  187. package/dist/shared-tree/index.d.ts +1 -1
  188. package/dist/shared-tree/index.d.ts.map +1 -1
  189. package/dist/shared-tree/index.js.map +1 -1
  190. package/dist/shared-tree/schematizeTree.d.ts +1 -1
  191. package/dist/shared-tree/schematizeTree.d.ts.map +1 -1
  192. package/dist/shared-tree/schematizeTree.js.map +1 -1
  193. package/dist/shared-tree/schematizingTreeView.d.ts +1 -1
  194. package/dist/shared-tree/schematizingTreeView.d.ts.map +1 -1
  195. package/dist/shared-tree/schematizingTreeView.js +1 -1
  196. package/dist/shared-tree/schematizingTreeView.js.map +1 -1
  197. package/dist/shared-tree/sharedTree.d.ts +3 -3
  198. package/dist/shared-tree/sharedTree.d.ts.map +1 -1
  199. package/dist/shared-tree/sharedTree.js +8 -8
  200. package/dist/shared-tree/sharedTree.js.map +1 -1
  201. package/dist/shared-tree/sharedTreeChangeFamily.d.ts +1 -1
  202. package/dist/shared-tree/sharedTreeChangeFamily.d.ts.map +1 -1
  203. package/dist/shared-tree/sharedTreeChangeFamily.js.map +1 -1
  204. package/dist/shared-tree/tree.js +1 -1
  205. package/dist/shared-tree/tree.js.map +1 -1
  206. package/dist/shared-tree/treeAlpha.d.ts +76 -2
  207. package/dist/shared-tree/treeAlpha.d.ts.map +1 -1
  208. package/dist/shared-tree/treeAlpha.js +62 -16
  209. package/dist/shared-tree/treeAlpha.js.map +1 -1
  210. package/dist/shared-tree/treeCheckout.d.ts.map +1 -1
  211. package/dist/shared-tree/treeCheckout.js +3 -2
  212. package/dist/shared-tree/treeCheckout.js.map +1 -1
  213. package/dist/shared-tree-core/branch.d.ts +2 -2
  214. package/dist/shared-tree-core/branch.d.ts.map +1 -1
  215. package/dist/shared-tree-core/branch.js +2 -2
  216. package/dist/shared-tree-core/branch.js.map +1 -1
  217. package/dist/shared-tree-core/branchCommitEnricher.d.ts +1 -1
  218. package/dist/shared-tree-core/branchCommitEnricher.d.ts.map +1 -1
  219. package/dist/shared-tree-core/branchCommitEnricher.js.map +1 -1
  220. package/dist/shared-tree-core/defaultResubmitMachine.d.ts.map +1 -1
  221. package/dist/shared-tree-core/defaultResubmitMachine.js.map +1 -1
  222. package/dist/shared-tree-core/editManager.d.ts +3 -1
  223. package/dist/shared-tree-core/editManager.d.ts.map +1 -1
  224. package/dist/shared-tree-core/editManager.js +4 -2
  225. package/dist/shared-tree-core/editManager.js.map +1 -1
  226. package/dist/shared-tree-core/editManagerCodecs.d.ts.map +1 -1
  227. package/dist/shared-tree-core/editManagerCodecs.js.map +1 -1
  228. package/dist/shared-tree-core/editManagerSummarizer.d.ts +1 -1
  229. package/dist/shared-tree-core/editManagerSummarizer.d.ts.map +1 -1
  230. package/dist/shared-tree-core/editManagerSummarizer.js.map +1 -1
  231. package/dist/shared-tree-core/messageCodecs.d.ts +1 -1
  232. package/dist/shared-tree-core/messageCodecs.js +1 -1
  233. package/dist/shared-tree-core/messageCodecs.js.map +1 -1
  234. package/dist/shared-tree-core/sequenceIdUtils.d.ts.map +1 -1
  235. package/dist/shared-tree-core/sequenceIdUtils.js.map +1 -1
  236. package/dist/shared-tree-core/sharedTreeCore.d.ts +2 -2
  237. package/dist/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
  238. package/dist/shared-tree-core/sharedTreeCore.js +4 -4
  239. package/dist/shared-tree-core/sharedTreeCore.js.map +1 -1
  240. package/dist/shared-tree-core/transaction.d.ts.map +1 -1
  241. package/dist/shared-tree-core/transaction.js +1 -1
  242. package/dist/shared-tree-core/transaction.js.map +1 -1
  243. package/dist/shared-tree-core/transactionEnricher.d.ts.map +1 -1
  244. package/dist/shared-tree-core/transactionEnricher.js.map +1 -1
  245. package/dist/simple-tree/api/conciseTree.d.ts.map +1 -1
  246. package/dist/simple-tree/api/conciseTree.js +1 -1
  247. package/dist/simple-tree/api/conciseTree.js.map +1 -1
  248. package/dist/simple-tree/api/configuration.js +4 -4
  249. package/dist/simple-tree/api/configuration.js.map +1 -1
  250. package/dist/simple-tree/api/create.d.ts +2 -26
  251. package/dist/simple-tree/api/create.d.ts.map +1 -1
  252. package/dist/simple-tree/api/create.js +4 -41
  253. package/dist/simple-tree/api/create.js.map +1 -1
  254. package/dist/simple-tree/api/customTree.d.ts +1 -1
  255. package/dist/simple-tree/api/customTree.d.ts.map +1 -1
  256. package/dist/simple-tree/api/customTree.js +24 -24
  257. package/dist/simple-tree/api/customTree.js.map +1 -1
  258. package/dist/simple-tree/api/getSimpleSchema.d.ts.map +1 -1
  259. package/dist/simple-tree/api/getSimpleSchema.js.map +1 -1
  260. package/dist/simple-tree/api/identifierIndex.js +2 -2
  261. package/dist/simple-tree/api/identifierIndex.js.map +1 -1
  262. package/dist/simple-tree/api/index.d.ts +2 -3
  263. package/dist/simple-tree/api/index.d.ts.map +1 -1
  264. package/dist/simple-tree/api/index.js +2 -9
  265. package/dist/simple-tree/api/index.js.map +1 -1
  266. package/dist/simple-tree/api/schemaCompatibilityTester.d.ts.map +1 -1
  267. package/dist/simple-tree/api/schemaCompatibilityTester.js.map +1 -1
  268. package/dist/simple-tree/api/schemaFactory.d.ts +5 -5
  269. package/dist/simple-tree/api/schemaFactory.d.ts.map +1 -1
  270. package/dist/simple-tree/api/schemaFactory.js +8 -8
  271. package/dist/simple-tree/api/schemaFactory.js.map +1 -1
  272. package/dist/simple-tree/api/schemaFactoryAlpha.d.ts +1 -3
  273. package/dist/simple-tree/api/schemaFactoryAlpha.d.ts.map +1 -1
  274. package/dist/simple-tree/api/schemaFactoryAlpha.js +4 -6
  275. package/dist/simple-tree/api/schemaFactoryAlpha.js.map +1 -1
  276. package/dist/simple-tree/api/schemaFactoryRecursive.d.ts +2 -2
  277. package/dist/simple-tree/api/schemaFactoryRecursive.d.ts.map +1 -1
  278. package/dist/simple-tree/api/schemaFactoryRecursive.js.map +1 -1
  279. package/dist/simple-tree/api/schemaFromSimple.d.ts.map +1 -1
  280. package/dist/simple-tree/api/schemaFromSimple.js.map +1 -1
  281. package/dist/simple-tree/api/simpleSchemaToJsonSchema.d.ts +1 -1
  282. package/dist/simple-tree/api/simpleSchemaToJsonSchema.d.ts.map +1 -1
  283. package/dist/simple-tree/api/simpleSchemaToJsonSchema.js +4 -6
  284. package/dist/simple-tree/api/simpleSchemaToJsonSchema.js.map +1 -1
  285. package/dist/simple-tree/api/storedSchema.d.ts +1 -1
  286. package/dist/simple-tree/api/storedSchema.d.ts.map +1 -1
  287. package/dist/simple-tree/api/storedSchema.js +7 -6
  288. package/dist/simple-tree/api/storedSchema.js.map +1 -1
  289. package/dist/simple-tree/api/tree.d.ts +2 -2
  290. package/dist/simple-tree/api/tree.d.ts.map +1 -1
  291. package/dist/simple-tree/api/tree.js.map +1 -1
  292. package/dist/simple-tree/api/treeBeta.d.ts.map +1 -1
  293. package/dist/simple-tree/api/treeBeta.js +1 -1
  294. package/dist/simple-tree/api/treeBeta.js.map +1 -1
  295. package/dist/simple-tree/api/treeNodeApi.d.ts +30 -3
  296. package/dist/simple-tree/api/treeNodeApi.d.ts.map +1 -1
  297. package/dist/simple-tree/api/treeNodeApi.js +40 -28
  298. package/dist/simple-tree/api/treeNodeApi.js.map +1 -1
  299. package/dist/simple-tree/api/typesUnsafe.d.ts +1 -1
  300. package/dist/simple-tree/api/typesUnsafe.d.ts.map +1 -1
  301. package/dist/simple-tree/api/typesUnsafe.js.map +1 -1
  302. package/dist/simple-tree/api/verboseTree.js +3 -3
  303. package/dist/simple-tree/api/verboseTree.js.map +1 -1
  304. package/dist/simple-tree/api/viewSchemaToSimpleSchema.d.ts.map +1 -1
  305. package/dist/simple-tree/api/viewSchemaToSimpleSchema.js +4 -6
  306. package/dist/simple-tree/api/viewSchemaToSimpleSchema.js.map +1 -1
  307. package/dist/simple-tree/core/context.d.ts.map +1 -1
  308. package/dist/simple-tree/core/context.js.map +1 -1
  309. package/dist/simple-tree/core/getOrCreateNode.d.ts +1 -1
  310. package/dist/simple-tree/core/getOrCreateNode.d.ts.map +1 -1
  311. package/dist/simple-tree/core/getOrCreateNode.js.map +1 -1
  312. package/dist/simple-tree/core/treeNode.d.ts.map +1 -1
  313. package/dist/simple-tree/core/treeNode.js +1 -1
  314. package/dist/simple-tree/core/treeNode.js.map +1 -1
  315. package/dist/simple-tree/core/treeNodeKernel.d.ts +3 -3
  316. package/dist/simple-tree/core/treeNodeKernel.d.ts.map +1 -1
  317. package/dist/simple-tree/core/treeNodeKernel.js +2 -2
  318. package/dist/simple-tree/core/treeNodeKernel.js.map +1 -1
  319. package/dist/simple-tree/core/treeNodeSchema.d.ts.map +1 -1
  320. package/dist/simple-tree/core/treeNodeSchema.js.map +1 -1
  321. package/dist/simple-tree/core/types.d.ts.map +1 -1
  322. package/dist/simple-tree/core/types.js.map +1 -1
  323. package/dist/simple-tree/core/unhydratedFlexTree.d.ts.map +1 -1
  324. package/dist/simple-tree/core/unhydratedFlexTree.js +21 -21
  325. package/dist/simple-tree/core/unhydratedFlexTree.js.map +1 -1
  326. package/dist/simple-tree/core/withType.d.ts +1 -1
  327. package/dist/simple-tree/core/withType.d.ts.map +1 -1
  328. package/dist/simple-tree/core/withType.js.map +1 -1
  329. package/dist/simple-tree/createContext.d.ts.map +1 -1
  330. package/dist/simple-tree/createContext.js.map +1 -1
  331. package/dist/simple-tree/getTreeNodeForField.d.ts.map +1 -1
  332. package/dist/simple-tree/getTreeNodeForField.js.map +1 -1
  333. package/dist/simple-tree/index.d.ts +2 -9
  334. package/dist/simple-tree/index.d.ts.map +1 -1
  335. package/dist/simple-tree/index.js +13 -21
  336. package/dist/simple-tree/index.js.map +1 -1
  337. package/dist/simple-tree/leafNodeSchema.d.ts.map +1 -1
  338. package/dist/simple-tree/leafNodeSchema.js.map +1 -1
  339. package/dist/simple-tree/{arrayNode.d.ts → node-kinds/array/arrayNode.d.ts} +3 -3
  340. package/dist/simple-tree/node-kinds/array/arrayNode.d.ts.map +1 -0
  341. package/dist/simple-tree/{arrayNode.js → node-kinds/array/arrayNode.js} +9 -9
  342. package/dist/simple-tree/node-kinds/array/arrayNode.js.map +1 -0
  343. package/dist/simple-tree/{arrayNodeTypes.d.ts → node-kinds/array/arrayNodeTypes.d.ts} +3 -3
  344. package/dist/simple-tree/node-kinds/array/arrayNodeTypes.d.ts.map +1 -0
  345. package/dist/simple-tree/{arrayNodeTypes.js → node-kinds/array/arrayNodeTypes.js} +1 -1
  346. package/dist/simple-tree/node-kinds/array/arrayNodeTypes.js.map +1 -0
  347. package/dist/simple-tree/node-kinds/array/index.d.ts +7 -0
  348. package/dist/simple-tree/node-kinds/array/index.d.ts.map +1 -0
  349. package/dist/simple-tree/node-kinds/array/index.js +16 -0
  350. package/dist/simple-tree/node-kinds/array/index.js.map +1 -0
  351. package/dist/simple-tree/node-kinds/index.d.ts +8 -0
  352. package/dist/simple-tree/node-kinds/index.d.ts.map +1 -0
  353. package/dist/simple-tree/node-kinds/index.js +26 -0
  354. package/dist/simple-tree/node-kinds/index.js.map +1 -0
  355. package/dist/simple-tree/node-kinds/map/index.d.ts +7 -0
  356. package/dist/simple-tree/node-kinds/map/index.d.ts.map +1 -0
  357. package/dist/simple-tree/node-kinds/map/index.js +13 -0
  358. package/dist/simple-tree/node-kinds/map/index.js.map +1 -0
  359. package/{lib/simple-tree → dist/simple-tree/node-kinds/map}/mapNode.d.ts +3 -3
  360. package/dist/simple-tree/node-kinds/map/mapNode.d.ts.map +1 -0
  361. package/dist/simple-tree/{mapNode.js → node-kinds/map/mapNode.js} +8 -8
  362. package/dist/simple-tree/node-kinds/map/mapNode.js.map +1 -0
  363. package/dist/simple-tree/{mapNodeTypes.d.ts → node-kinds/map/mapNodeTypes.d.ts} +3 -3
  364. package/dist/simple-tree/node-kinds/map/mapNodeTypes.d.ts.map +1 -0
  365. package/dist/simple-tree/{mapNodeTypes.js → node-kinds/map/mapNodeTypes.js} +1 -1
  366. package/dist/simple-tree/node-kinds/map/mapNodeTypes.js.map +1 -0
  367. package/dist/simple-tree/node-kinds/object/index.d.ts +7 -0
  368. package/dist/simple-tree/node-kinds/object/index.d.ts.map +1 -0
  369. package/dist/simple-tree/node-kinds/object/index.js +16 -0
  370. package/dist/simple-tree/node-kinds/object/index.js.map +1 -0
  371. package/{lib/simple-tree → dist/simple-tree/node-kinds/object}/objectNode.d.ts +17 -6
  372. package/dist/simple-tree/node-kinds/object/objectNode.d.ts.map +1 -0
  373. package/dist/simple-tree/{objectNode.js → node-kinds/object/objectNode.js} +47 -24
  374. package/dist/simple-tree/node-kinds/object/objectNode.js.map +1 -0
  375. package/{lib/simple-tree → dist/simple-tree/node-kinds/object}/objectNodeTypes.d.ts +5 -5
  376. package/dist/simple-tree/node-kinds/object/objectNodeTypes.d.ts.map +1 -0
  377. package/dist/simple-tree/{objectNodeTypes.js → node-kinds/object/objectNodeTypes.js} +1 -1
  378. package/dist/simple-tree/node-kinds/object/objectNodeTypes.js.map +1 -0
  379. package/dist/simple-tree/prepareForInsertion.js.map +1 -1
  380. package/dist/simple-tree/schemaTypes.d.ts +2 -2
  381. package/dist/simple-tree/schemaTypes.d.ts.map +1 -1
  382. package/dist/simple-tree/schemaTypes.js.map +1 -1
  383. package/dist/simple-tree/simpleSchema.d.ts.map +1 -1
  384. package/dist/simple-tree/simpleSchema.js.map +1 -1
  385. package/dist/simple-tree/toMapTree.d.ts +1 -16
  386. package/dist/simple-tree/toMapTree.d.ts.map +1 -1
  387. package/dist/simple-tree/toMapTree.js +41 -1
  388. package/dist/simple-tree/toMapTree.js.map +1 -1
  389. package/dist/simple-tree/toStoredSchema.d.ts.map +1 -1
  390. package/dist/simple-tree/toStoredSchema.js +1 -1
  391. package/dist/simple-tree/toStoredSchema.js.map +1 -1
  392. package/dist/simple-tree/treeNodeValid.d.ts +1 -1
  393. package/dist/simple-tree/treeNodeValid.d.ts.map +1 -1
  394. package/dist/simple-tree/treeNodeValid.js +10 -10
  395. package/dist/simple-tree/treeNodeValid.js.map +1 -1
  396. package/dist/simple-tree/walkFieldSchema.d.ts.map +1 -1
  397. package/dist/simple-tree/walkFieldSchema.js.map +1 -1
  398. package/dist/tableSchema.d.ts +10 -10
  399. package/dist/treeFactory.d.ts +1 -1
  400. package/dist/treeFactory.js +1 -1
  401. package/dist/treeFactory.js.map +1 -1
  402. package/dist/util/bTreeUtils.d.ts.map +1 -1
  403. package/dist/util/bTreeUtils.js.map +1 -1
  404. package/dist/util/breakable.d.ts +23 -4
  405. package/dist/util/breakable.d.ts.map +1 -1
  406. package/dist/util/breakable.js +12 -3
  407. package/dist/util/breakable.js.map +1 -1
  408. package/docs/SharedTree Philosophy.md +5 -5
  409. package/lib/alpha.d.ts +1 -0
  410. package/lib/codec/codec.d.ts +10 -0
  411. package/lib/codec/codec.d.ts.map +1 -1
  412. package/lib/codec/codec.js +13 -3
  413. package/lib/codec/codec.js.map +1 -1
  414. package/lib/core/index.d.ts +1 -1
  415. package/lib/core/index.d.ts.map +1 -1
  416. package/lib/core/index.js +1 -1
  417. package/lib/core/index.js.map +1 -1
  418. package/lib/core/rebase/types.d.ts +2 -2
  419. package/lib/core/rebase/types.js +2 -2
  420. package/lib/core/rebase/types.js.map +1 -1
  421. package/lib/core/rebase/utils.d.ts +0 -2
  422. package/lib/core/rebase/utils.d.ts.map +1 -1
  423. package/lib/core/rebase/utils.js +6 -10
  424. package/lib/core/rebase/utils.js.map +1 -1
  425. package/lib/core/schema-stored/formatV1.d.ts +0 -1
  426. package/lib/core/schema-stored/formatV1.d.ts.map +1 -1
  427. package/lib/core/schema-stored/formatV1.js +0 -1
  428. package/lib/core/schema-stored/formatV1.js.map +1 -1
  429. package/lib/core/schema-stored/index.d.ts +1 -1
  430. package/lib/core/schema-stored/index.d.ts.map +1 -1
  431. package/lib/core/schema-stored/index.js +1 -1
  432. package/lib/core/schema-stored/index.js.map +1 -1
  433. package/lib/core/schema-stored/schema.d.ts +6 -0
  434. package/lib/core/schema-stored/schema.d.ts.map +1 -1
  435. package/lib/core/schema-stored/schema.js +7 -0
  436. package/lib/core/schema-stored/schema.js.map +1 -1
  437. package/lib/core/tree/anchorSet.d.ts +2 -1
  438. package/lib/core/tree/anchorSet.d.ts.map +1 -1
  439. package/lib/core/tree/anchorSet.js +2 -1
  440. package/lib/core/tree/anchorSet.js.map +1 -1
  441. package/lib/core/tree/pathTree.d.ts +12 -11
  442. package/lib/core/tree/pathTree.d.ts.map +1 -1
  443. package/lib/core/tree/pathTree.js +8 -7
  444. package/lib/core/tree/pathTree.js.map +1 -1
  445. package/lib/core/tree/treeTextFormat.d.ts +1 -1
  446. package/lib/core/tree/treeTextFormat.js +1 -1
  447. package/lib/core/tree/treeTextFormat.js.map +1 -1
  448. package/lib/feature-libraries/chunked-forest/chunkedForest.d.ts +1 -1
  449. package/lib/feature-libraries/chunked-forest/chunkedForest.js +1 -1
  450. package/lib/feature-libraries/chunked-forest/chunkedForest.js.map +1 -1
  451. package/lib/feature-libraries/default-schema/defaultEditBuilder.js +1 -1
  452. package/lib/feature-libraries/default-schema/defaultEditBuilder.js.map +1 -1
  453. package/lib/feature-libraries/default-schema/index.d.ts +1 -1
  454. package/lib/feature-libraries/default-schema/index.d.ts.map +1 -1
  455. package/lib/feature-libraries/default-schema/index.js +1 -1
  456. package/lib/feature-libraries/default-schema/index.js.map +1 -1
  457. package/lib/feature-libraries/default-schema/schemaChecker.d.ts +15 -15
  458. package/lib/feature-libraries/default-schema/schemaChecker.d.ts.map +1 -1
  459. package/lib/feature-libraries/default-schema/schemaChecker.js +49 -34
  460. package/lib/feature-libraries/default-schema/schemaChecker.js.map +1 -1
  461. package/lib/feature-libraries/flex-tree/context.d.ts +18 -2
  462. package/lib/feature-libraries/flex-tree/context.d.ts.map +1 -1
  463. package/lib/feature-libraries/flex-tree/context.js +23 -7
  464. package/lib/feature-libraries/flex-tree/context.js.map +1 -1
  465. package/lib/feature-libraries/flex-tree/flexTreeTypes.d.ts +3 -2
  466. package/lib/feature-libraries/flex-tree/flexTreeTypes.d.ts.map +1 -1
  467. package/lib/feature-libraries/flex-tree/flexTreeTypes.js +3 -2
  468. package/lib/feature-libraries/flex-tree/flexTreeTypes.js.map +1 -1
  469. package/lib/feature-libraries/flex-tree/lazyField.d.ts.map +1 -1
  470. package/lib/feature-libraries/flex-tree/lazyField.js +1 -1
  471. package/lib/feature-libraries/flex-tree/lazyField.js.map +1 -1
  472. package/lib/feature-libraries/flex-tree/utilities.d.ts.map +1 -1
  473. package/lib/feature-libraries/flex-tree/utilities.js.map +1 -1
  474. package/lib/feature-libraries/forest-summary/forestSummarizer.d.ts +1 -1
  475. package/lib/feature-libraries/forest-summary/forestSummarizer.d.ts.map +1 -1
  476. package/lib/feature-libraries/forest-summary/forestSummarizer.js.map +1 -1
  477. package/lib/feature-libraries/index.d.ts +2 -2
  478. package/lib/feature-libraries/index.d.ts.map +1 -1
  479. package/lib/feature-libraries/index.js +2 -2
  480. package/lib/feature-libraries/index.js.map +1 -1
  481. package/lib/feature-libraries/indexing/anchorTreeIndex.d.ts +2 -2
  482. package/lib/feature-libraries/indexing/anchorTreeIndex.d.ts.map +1 -1
  483. package/lib/feature-libraries/indexing/anchorTreeIndex.js +1 -1
  484. package/lib/feature-libraries/indexing/anchorTreeIndex.js.map +1 -1
  485. package/lib/feature-libraries/modular-schema/crossFieldQueries.d.ts.map +1 -1
  486. package/lib/feature-libraries/modular-schema/crossFieldQueries.js.map +1 -1
  487. package/lib/feature-libraries/modular-schema/fieldChangeHandler.d.ts +1 -1
  488. package/lib/feature-libraries/modular-schema/fieldChangeHandler.d.ts.map +1 -1
  489. package/lib/feature-libraries/modular-schema/fieldChangeHandler.js.map +1 -1
  490. package/lib/feature-libraries/modular-schema/fieldKindWithEditor.d.ts +1 -1
  491. package/lib/feature-libraries/modular-schema/fieldKindWithEditor.js +1 -1
  492. package/lib/feature-libraries/modular-schema/fieldKindWithEditor.js.map +1 -1
  493. package/lib/feature-libraries/modular-schema/genericFieldKind.d.ts.map +1 -1
  494. package/lib/feature-libraries/modular-schema/genericFieldKind.js +2 -2
  495. package/lib/feature-libraries/modular-schema/genericFieldKind.js.map +1 -1
  496. package/lib/feature-libraries/modular-schema/genericFieldKindCodecs.d.ts.map +1 -1
  497. package/lib/feature-libraries/modular-schema/genericFieldKindCodecs.js.map +1 -1
  498. package/lib/feature-libraries/modular-schema/genericFieldKindTypes.d.ts.map +1 -1
  499. package/lib/feature-libraries/modular-schema/genericFieldKindTypes.js.map +1 -1
  500. package/lib/feature-libraries/modular-schema/isNeverTree.d.ts +0 -2
  501. package/lib/feature-libraries/modular-schema/isNeverTree.d.ts.map +1 -1
  502. package/lib/feature-libraries/modular-schema/isNeverTree.js +0 -2
  503. package/lib/feature-libraries/modular-schema/isNeverTree.js.map +1 -1
  504. package/lib/feature-libraries/modular-schema/modularChangeCodecs.d.ts.map +1 -1
  505. package/lib/feature-libraries/modular-schema/modularChangeCodecs.js.map +1 -1
  506. package/lib/feature-libraries/modular-schema/modularChangeFamily.d.ts +2 -0
  507. package/lib/feature-libraries/modular-schema/modularChangeFamily.d.ts.map +1 -1
  508. package/lib/feature-libraries/modular-schema/modularChangeFamily.js +2 -0
  509. package/lib/feature-libraries/modular-schema/modularChangeFamily.js.map +1 -1
  510. package/lib/feature-libraries/modular-schema/modularChangeTypes.d.ts.map +1 -1
  511. package/lib/feature-libraries/modular-schema/modularChangeTypes.js.map +1 -1
  512. package/lib/feature-libraries/node-identifier/mockNodeIdentifierManager.d.ts.map +1 -1
  513. package/lib/feature-libraries/node-identifier/mockNodeIdentifierManager.js +8 -3
  514. package/lib/feature-libraries/node-identifier/mockNodeIdentifierManager.js.map +1 -1
  515. package/lib/feature-libraries/object-forest/objectForest.d.ts +22 -5
  516. package/lib/feature-libraries/object-forest/objectForest.d.ts.map +1 -1
  517. package/lib/feature-libraries/object-forest/objectForest.js +299 -209
  518. package/lib/feature-libraries/object-forest/objectForest.js.map +1 -1
  519. package/lib/feature-libraries/schema-edits/schemaChangeCodecs.d.ts +2 -2
  520. package/lib/feature-libraries/schema-edits/schemaChangeCodecs.d.ts.map +1 -1
  521. package/lib/feature-libraries/schema-edits/schemaChangeCodecs.js +4 -3
  522. package/lib/feature-libraries/schema-edits/schemaChangeCodecs.js.map +1 -1
  523. package/lib/feature-libraries/schema-edits/schemaChangeFormat.d.ts +2 -2
  524. package/lib/feature-libraries/schema-index/codec.d.ts +6 -12
  525. package/lib/feature-libraries/schema-index/codec.d.ts.map +1 -1
  526. package/lib/feature-libraries/schema-index/codec.js +8 -15
  527. package/lib/feature-libraries/schema-index/codec.js.map +1 -1
  528. package/lib/feature-libraries/schema-index/formatV1.d.ts +2 -2
  529. package/lib/feature-libraries/schema-index/formatV1.d.ts.map +1 -1
  530. package/lib/feature-libraries/schema-index/formatV1.js +2 -2
  531. package/lib/feature-libraries/schema-index/formatV1.js.map +1 -1
  532. package/lib/feature-libraries/schema-index/index.d.ts +1 -1
  533. package/lib/feature-libraries/schema-index/index.d.ts.map +1 -1
  534. package/lib/feature-libraries/schema-index/index.js +1 -1
  535. package/lib/feature-libraries/schema-index/index.js.map +1 -1
  536. package/lib/feature-libraries/schema-index/schemaSummarizer.d.ts +1 -1
  537. package/lib/feature-libraries/schema-index/schemaSummarizer.d.ts.map +1 -1
  538. package/lib/feature-libraries/schema-index/schemaSummarizer.js.map +1 -1
  539. package/lib/feature-libraries/sequence-field/formatV3.d.ts.map +1 -1
  540. package/lib/feature-libraries/sequence-field/formatV3.js.map +1 -1
  541. package/lib/feature-libraries/sequence-field/markQueue.d.ts.map +1 -1
  542. package/lib/feature-libraries/sequence-field/markQueue.js.map +1 -1
  543. package/lib/feature-libraries/sequence-field/prune.d.ts.map +1 -1
  544. package/lib/feature-libraries/sequence-field/prune.js.map +1 -1
  545. package/lib/feature-libraries/sequence-field/rebase.js +1 -1
  546. package/lib/feature-libraries/sequence-field/rebase.js.map +1 -1
  547. package/lib/feature-libraries/sequence-field/relevantRemovedRoots.d.ts +1 -1
  548. package/lib/feature-libraries/sequence-field/relevantRemovedRoots.d.ts.map +1 -1
  549. package/lib/feature-libraries/sequence-field/relevantRemovedRoots.js.map +1 -1
  550. package/lib/feature-libraries/sequence-field/replaceRevisions.d.ts.map +1 -1
  551. package/lib/feature-libraries/sequence-field/replaceRevisions.js.map +1 -1
  552. package/lib/feature-libraries/sequence-field/sequenceFieldCodecV1.d.ts +1 -1
  553. package/lib/feature-libraries/sequence-field/sequenceFieldCodecV1.d.ts.map +1 -1
  554. package/lib/feature-libraries/sequence-field/sequenceFieldCodecV1.js +1 -1
  555. package/lib/feature-libraries/sequence-field/sequenceFieldCodecV1.js.map +1 -1
  556. package/lib/feature-libraries/sequence-field/sequenceFieldCodecV2.d.ts +2 -2
  557. package/lib/feature-libraries/sequence-field/sequenceFieldCodecV2.d.ts.map +1 -1
  558. package/lib/feature-libraries/sequence-field/sequenceFieldCodecV2.js +1 -1
  559. package/lib/feature-libraries/sequence-field/sequenceFieldCodecV2.js.map +1 -1
  560. package/lib/feature-libraries/sequence-field/sequenceFieldCodecV3.d.ts +1 -1
  561. package/lib/feature-libraries/sequence-field/sequenceFieldCodecV3.d.ts.map +1 -1
  562. package/lib/feature-libraries/sequence-field/sequenceFieldCodecV3.js +2 -2
  563. package/lib/feature-libraries/sequence-field/sequenceFieldCodecV3.js.map +1 -1
  564. package/lib/feature-libraries/sequence-field/sequenceFieldCodecs.d.ts +1 -1
  565. package/lib/feature-libraries/sequence-field/sequenceFieldCodecs.d.ts.map +1 -1
  566. package/lib/feature-libraries/sequence-field/sequenceFieldCodecs.js.map +1 -1
  567. package/lib/feature-libraries/sequence-field/sequenceFieldToDelta.d.ts +1 -1
  568. package/lib/feature-libraries/sequence-field/sequenceFieldToDelta.d.ts.map +1 -1
  569. package/lib/feature-libraries/sequence-field/sequenceFieldToDelta.js.map +1 -1
  570. package/lib/feature-libraries/sequence-field/utils.d.ts +7 -5
  571. package/lib/feature-libraries/sequence-field/utils.d.ts.map +1 -1
  572. package/lib/feature-libraries/sequence-field/utils.js +7 -5
  573. package/lib/feature-libraries/sequence-field/utils.js.map +1 -1
  574. package/lib/feature-libraries/treeCursorUtils.js +2 -2
  575. package/lib/feature-libraries/treeCursorUtils.js.map +1 -1
  576. package/lib/feature-libraries/treeTextCursor.d.ts +1 -1
  577. package/lib/feature-libraries/treeTextCursor.js +1 -1
  578. package/lib/feature-libraries/treeTextCursor.js.map +1 -1
  579. package/lib/index.d.ts +2 -2
  580. package/lib/index.d.ts.map +1 -1
  581. package/lib/index.js +0 -2
  582. package/lib/index.js.map +1 -1
  583. package/lib/packageVersion.d.ts +1 -1
  584. package/lib/packageVersion.d.ts.map +1 -1
  585. package/lib/packageVersion.js +1 -1
  586. package/lib/packageVersion.js.map +1 -1
  587. package/lib/shared-tree/checkoutFlexTreeView.d.ts.map +1 -1
  588. package/lib/shared-tree/checkoutFlexTreeView.js.map +1 -1
  589. package/lib/shared-tree/independentView.d.ts +1 -1
  590. package/lib/shared-tree/independentView.d.ts.map +1 -1
  591. package/lib/shared-tree/independentView.js +10 -5
  592. package/lib/shared-tree/independentView.js.map +1 -1
  593. package/lib/shared-tree/index.d.ts +1 -1
  594. package/lib/shared-tree/index.d.ts.map +1 -1
  595. package/lib/shared-tree/index.js +1 -1
  596. package/lib/shared-tree/index.js.map +1 -1
  597. package/lib/shared-tree/schematizeTree.d.ts +1 -1
  598. package/lib/shared-tree/schematizeTree.d.ts.map +1 -1
  599. package/lib/shared-tree/schematizeTree.js.map +1 -1
  600. package/lib/shared-tree/schematizingTreeView.d.ts +1 -1
  601. package/lib/shared-tree/schematizingTreeView.d.ts.map +1 -1
  602. package/lib/shared-tree/schematizingTreeView.js +1 -1
  603. package/lib/shared-tree/schematizingTreeView.js.map +1 -1
  604. package/lib/shared-tree/sharedTree.d.ts +3 -3
  605. package/lib/shared-tree/sharedTree.d.ts.map +1 -1
  606. package/lib/shared-tree/sharedTree.js +10 -10
  607. package/lib/shared-tree/sharedTree.js.map +1 -1
  608. package/lib/shared-tree/sharedTreeChangeFamily.d.ts +1 -1
  609. package/lib/shared-tree/sharedTreeChangeFamily.d.ts.map +1 -1
  610. package/lib/shared-tree/sharedTreeChangeFamily.js.map +1 -1
  611. package/lib/shared-tree/tree.js +1 -1
  612. package/lib/shared-tree/tree.js.map +1 -1
  613. package/lib/shared-tree/treeAlpha.d.ts +76 -2
  614. package/lib/shared-tree/treeAlpha.d.ts.map +1 -1
  615. package/lib/shared-tree/treeAlpha.js +50 -4
  616. package/lib/shared-tree/treeAlpha.js.map +1 -1
  617. package/lib/shared-tree/treeCheckout.d.ts.map +1 -1
  618. package/lib/shared-tree/treeCheckout.js +3 -2
  619. package/lib/shared-tree/treeCheckout.js.map +1 -1
  620. package/lib/shared-tree-core/branch.d.ts +2 -2
  621. package/lib/shared-tree-core/branch.d.ts.map +1 -1
  622. package/lib/shared-tree-core/branch.js +2 -2
  623. package/lib/shared-tree-core/branch.js.map +1 -1
  624. package/lib/shared-tree-core/branchCommitEnricher.d.ts +1 -1
  625. package/lib/shared-tree-core/branchCommitEnricher.d.ts.map +1 -1
  626. package/lib/shared-tree-core/branchCommitEnricher.js.map +1 -1
  627. package/lib/shared-tree-core/defaultResubmitMachine.d.ts.map +1 -1
  628. package/lib/shared-tree-core/defaultResubmitMachine.js.map +1 -1
  629. package/lib/shared-tree-core/editManager.d.ts +3 -1
  630. package/lib/shared-tree-core/editManager.d.ts.map +1 -1
  631. package/lib/shared-tree-core/editManager.js +4 -2
  632. package/lib/shared-tree-core/editManager.js.map +1 -1
  633. package/lib/shared-tree-core/editManagerCodecs.d.ts.map +1 -1
  634. package/lib/shared-tree-core/editManagerCodecs.js.map +1 -1
  635. package/lib/shared-tree-core/editManagerSummarizer.d.ts +1 -1
  636. package/lib/shared-tree-core/editManagerSummarizer.d.ts.map +1 -1
  637. package/lib/shared-tree-core/editManagerSummarizer.js.map +1 -1
  638. package/lib/shared-tree-core/messageCodecs.d.ts +1 -1
  639. package/lib/shared-tree-core/messageCodecs.js +1 -1
  640. package/lib/shared-tree-core/messageCodecs.js.map +1 -1
  641. package/lib/shared-tree-core/sequenceIdUtils.d.ts.map +1 -1
  642. package/lib/shared-tree-core/sequenceIdUtils.js.map +1 -1
  643. package/lib/shared-tree-core/sharedTreeCore.d.ts +2 -2
  644. package/lib/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
  645. package/lib/shared-tree-core/sharedTreeCore.js +4 -4
  646. package/lib/shared-tree-core/sharedTreeCore.js.map +1 -1
  647. package/lib/shared-tree-core/transaction.d.ts.map +1 -1
  648. package/lib/shared-tree-core/transaction.js +1 -1
  649. package/lib/shared-tree-core/transaction.js.map +1 -1
  650. package/lib/shared-tree-core/transactionEnricher.d.ts.map +1 -1
  651. package/lib/shared-tree-core/transactionEnricher.js.map +1 -1
  652. package/lib/simple-tree/api/conciseTree.d.ts.map +1 -1
  653. package/lib/simple-tree/api/conciseTree.js +1 -1
  654. package/lib/simple-tree/api/conciseTree.js.map +1 -1
  655. package/lib/simple-tree/api/configuration.js +1 -1
  656. package/lib/simple-tree/api/configuration.js.map +1 -1
  657. package/lib/simple-tree/api/create.d.ts +2 -26
  658. package/lib/simple-tree/api/create.d.ts.map +1 -1
  659. package/lib/simple-tree/api/create.js +2 -37
  660. package/lib/simple-tree/api/create.js.map +1 -1
  661. package/lib/simple-tree/api/customTree.d.ts +1 -1
  662. package/lib/simple-tree/api/customTree.d.ts.map +1 -1
  663. package/lib/simple-tree/api/customTree.js +3 -3
  664. package/lib/simple-tree/api/customTree.js.map +1 -1
  665. package/lib/simple-tree/api/getSimpleSchema.d.ts.map +1 -1
  666. package/lib/simple-tree/api/getSimpleSchema.js.map +1 -1
  667. package/lib/simple-tree/api/identifierIndex.js +1 -1
  668. package/lib/simple-tree/api/identifierIndex.js.map +1 -1
  669. package/lib/simple-tree/api/index.d.ts +2 -3
  670. package/lib/simple-tree/api/index.d.ts.map +1 -1
  671. package/lib/simple-tree/api/index.js +2 -5
  672. package/lib/simple-tree/api/index.js.map +1 -1
  673. package/lib/simple-tree/api/schemaCompatibilityTester.d.ts.map +1 -1
  674. package/lib/simple-tree/api/schemaCompatibilityTester.js.map +1 -1
  675. package/lib/simple-tree/api/schemaFactory.d.ts +5 -5
  676. package/lib/simple-tree/api/schemaFactory.d.ts.map +1 -1
  677. package/lib/simple-tree/api/schemaFactory.js +5 -5
  678. package/lib/simple-tree/api/schemaFactory.js.map +1 -1
  679. package/lib/simple-tree/api/schemaFactoryAlpha.d.ts +1 -3
  680. package/lib/simple-tree/api/schemaFactoryAlpha.d.ts.map +1 -1
  681. package/lib/simple-tree/api/schemaFactoryAlpha.js +1 -3
  682. package/lib/simple-tree/api/schemaFactoryAlpha.js.map +1 -1
  683. package/lib/simple-tree/api/schemaFactoryRecursive.d.ts +2 -2
  684. package/lib/simple-tree/api/schemaFactoryRecursive.d.ts.map +1 -1
  685. package/lib/simple-tree/api/schemaFactoryRecursive.js.map +1 -1
  686. package/lib/simple-tree/api/schemaFromSimple.d.ts.map +1 -1
  687. package/lib/simple-tree/api/schemaFromSimple.js.map +1 -1
  688. package/lib/simple-tree/api/simpleSchemaToJsonSchema.d.ts +1 -1
  689. package/lib/simple-tree/api/simpleSchemaToJsonSchema.d.ts.map +1 -1
  690. package/lib/simple-tree/api/simpleSchemaToJsonSchema.js +1 -3
  691. package/lib/simple-tree/api/simpleSchemaToJsonSchema.js.map +1 -1
  692. package/lib/simple-tree/api/storedSchema.d.ts +1 -1
  693. package/lib/simple-tree/api/storedSchema.d.ts.map +1 -1
  694. package/lib/simple-tree/api/storedSchema.js +3 -2
  695. package/lib/simple-tree/api/storedSchema.js.map +1 -1
  696. package/lib/simple-tree/api/tree.d.ts +2 -2
  697. package/lib/simple-tree/api/tree.d.ts.map +1 -1
  698. package/lib/simple-tree/api/tree.js.map +1 -1
  699. package/lib/simple-tree/api/treeBeta.d.ts.map +1 -1
  700. package/lib/simple-tree/api/treeBeta.js +1 -1
  701. package/lib/simple-tree/api/treeBeta.js.map +1 -1
  702. package/lib/simple-tree/api/treeNodeApi.d.ts +30 -3
  703. package/lib/simple-tree/api/treeNodeApi.d.ts.map +1 -1
  704. package/lib/simple-tree/api/treeNodeApi.js +37 -26
  705. package/lib/simple-tree/api/treeNodeApi.js.map +1 -1
  706. package/lib/simple-tree/api/typesUnsafe.d.ts +1 -1
  707. package/lib/simple-tree/api/typesUnsafe.d.ts.map +1 -1
  708. package/lib/simple-tree/api/typesUnsafe.js.map +1 -1
  709. package/lib/simple-tree/api/verboseTree.js +1 -1
  710. package/lib/simple-tree/api/verboseTree.js.map +1 -1
  711. package/lib/simple-tree/api/viewSchemaToSimpleSchema.d.ts.map +1 -1
  712. package/lib/simple-tree/api/viewSchemaToSimpleSchema.js +1 -3
  713. package/lib/simple-tree/api/viewSchemaToSimpleSchema.js.map +1 -1
  714. package/lib/simple-tree/core/context.d.ts.map +1 -1
  715. package/lib/simple-tree/core/context.js.map +1 -1
  716. package/lib/simple-tree/core/getOrCreateNode.d.ts +1 -1
  717. package/lib/simple-tree/core/getOrCreateNode.d.ts.map +1 -1
  718. package/lib/simple-tree/core/getOrCreateNode.js.map +1 -1
  719. package/lib/simple-tree/core/treeNode.d.ts.map +1 -1
  720. package/lib/simple-tree/core/treeNode.js +1 -1
  721. package/lib/simple-tree/core/treeNode.js.map +1 -1
  722. package/lib/simple-tree/core/treeNodeKernel.d.ts +3 -3
  723. package/lib/simple-tree/core/treeNodeKernel.d.ts.map +1 -1
  724. package/lib/simple-tree/core/treeNodeKernel.js +2 -2
  725. package/lib/simple-tree/core/treeNodeKernel.js.map +1 -1
  726. package/lib/simple-tree/core/treeNodeSchema.d.ts.map +1 -1
  727. package/lib/simple-tree/core/treeNodeSchema.js.map +1 -1
  728. package/lib/simple-tree/core/types.d.ts.map +1 -1
  729. package/lib/simple-tree/core/types.js.map +1 -1
  730. package/lib/simple-tree/core/unhydratedFlexTree.d.ts.map +1 -1
  731. package/lib/simple-tree/core/unhydratedFlexTree.js +3 -3
  732. package/lib/simple-tree/core/unhydratedFlexTree.js.map +1 -1
  733. package/lib/simple-tree/core/withType.d.ts +1 -1
  734. package/lib/simple-tree/core/withType.d.ts.map +1 -1
  735. package/lib/simple-tree/core/withType.js.map +1 -1
  736. package/lib/simple-tree/createContext.d.ts.map +1 -1
  737. package/lib/simple-tree/createContext.js.map +1 -1
  738. package/lib/simple-tree/getTreeNodeForField.d.ts.map +1 -1
  739. package/lib/simple-tree/getTreeNodeForField.js.map +1 -1
  740. package/lib/simple-tree/index.d.ts +2 -9
  741. package/lib/simple-tree/index.d.ts.map +1 -1
  742. package/lib/simple-tree/index.js +2 -6
  743. package/lib/simple-tree/index.js.map +1 -1
  744. package/lib/simple-tree/leafNodeSchema.d.ts.map +1 -1
  745. package/lib/simple-tree/leafNodeSchema.js.map +1 -1
  746. package/lib/simple-tree/{arrayNode.d.ts → node-kinds/array/arrayNode.d.ts} +3 -3
  747. package/lib/simple-tree/node-kinds/array/arrayNode.d.ts.map +1 -0
  748. package/lib/simple-tree/{arrayNode.js → node-kinds/array/arrayNode.js} +9 -9
  749. package/lib/simple-tree/node-kinds/array/arrayNode.js.map +1 -0
  750. package/lib/simple-tree/{arrayNodeTypes.d.ts → node-kinds/array/arrayNodeTypes.d.ts} +3 -3
  751. package/lib/simple-tree/node-kinds/array/arrayNodeTypes.d.ts.map +1 -0
  752. package/lib/simple-tree/{arrayNodeTypes.js → node-kinds/array/arrayNodeTypes.js} +1 -1
  753. package/{dist/simple-tree → lib/simple-tree/node-kinds/array}/arrayNodeTypes.js.map +1 -1
  754. package/lib/simple-tree/node-kinds/array/index.d.ts +7 -0
  755. package/lib/simple-tree/node-kinds/array/index.d.ts.map +1 -0
  756. package/lib/simple-tree/node-kinds/array/index.js +7 -0
  757. package/lib/simple-tree/node-kinds/array/index.js.map +1 -0
  758. package/lib/simple-tree/node-kinds/index.d.ts +8 -0
  759. package/lib/simple-tree/node-kinds/index.d.ts.map +1 -0
  760. package/lib/simple-tree/node-kinds/index.js +8 -0
  761. package/lib/simple-tree/node-kinds/index.js.map +1 -0
  762. package/lib/simple-tree/node-kinds/map/index.d.ts +7 -0
  763. package/lib/simple-tree/node-kinds/map/index.d.ts.map +1 -0
  764. package/lib/simple-tree/node-kinds/map/index.js +7 -0
  765. package/lib/simple-tree/node-kinds/map/index.js.map +1 -0
  766. package/{dist/simple-tree → lib/simple-tree/node-kinds/map}/mapNode.d.ts +3 -3
  767. package/lib/simple-tree/node-kinds/map/mapNode.d.ts.map +1 -0
  768. package/lib/simple-tree/{mapNode.js → node-kinds/map/mapNode.js} +8 -8
  769. package/lib/simple-tree/node-kinds/map/mapNode.js.map +1 -0
  770. package/lib/simple-tree/{mapNodeTypes.d.ts → node-kinds/map/mapNodeTypes.d.ts} +3 -3
  771. package/lib/simple-tree/node-kinds/map/mapNodeTypes.d.ts.map +1 -0
  772. package/lib/simple-tree/{mapNodeTypes.js → node-kinds/map/mapNodeTypes.js} +1 -1
  773. package/lib/simple-tree/node-kinds/map/mapNodeTypes.js.map +1 -0
  774. package/lib/simple-tree/node-kinds/object/index.d.ts +7 -0
  775. package/lib/simple-tree/node-kinds/object/index.d.ts.map +1 -0
  776. package/lib/simple-tree/node-kinds/object/index.js +7 -0
  777. package/lib/simple-tree/node-kinds/object/index.js.map +1 -0
  778. package/{dist/simple-tree → lib/simple-tree/node-kinds/object}/objectNode.d.ts +17 -6
  779. package/lib/simple-tree/node-kinds/object/objectNode.d.ts.map +1 -0
  780. package/lib/simple-tree/{objectNode.js → node-kinds/object/objectNode.js} +35 -13
  781. package/lib/simple-tree/node-kinds/object/objectNode.js.map +1 -0
  782. package/{dist/simple-tree → lib/simple-tree/node-kinds/object}/objectNodeTypes.d.ts +5 -5
  783. package/lib/simple-tree/node-kinds/object/objectNodeTypes.d.ts.map +1 -0
  784. package/lib/simple-tree/{objectNodeTypes.js → node-kinds/object/objectNodeTypes.js} +1 -1
  785. package/lib/simple-tree/node-kinds/object/objectNodeTypes.js.map +1 -0
  786. package/lib/simple-tree/prepareForInsertion.js.map +1 -1
  787. package/lib/simple-tree/schemaTypes.d.ts +2 -2
  788. package/lib/simple-tree/schemaTypes.d.ts.map +1 -1
  789. package/lib/simple-tree/schemaTypes.js.map +1 -1
  790. package/lib/simple-tree/simpleSchema.d.ts.map +1 -1
  791. package/lib/simple-tree/simpleSchema.js.map +1 -1
  792. package/lib/simple-tree/toMapTree.d.ts +1 -16
  793. package/lib/simple-tree/toMapTree.d.ts.map +1 -1
  794. package/lib/simple-tree/toMapTree.js +41 -1
  795. package/lib/simple-tree/toMapTree.js.map +1 -1
  796. package/lib/simple-tree/toStoredSchema.d.ts.map +1 -1
  797. package/lib/simple-tree/toStoredSchema.js +1 -1
  798. package/lib/simple-tree/toStoredSchema.js.map +1 -1
  799. package/lib/simple-tree/treeNodeValid.d.ts +1 -1
  800. package/lib/simple-tree/treeNodeValid.d.ts.map +1 -1
  801. package/lib/simple-tree/treeNodeValid.js +2 -2
  802. package/lib/simple-tree/treeNodeValid.js.map +1 -1
  803. package/lib/simple-tree/walkFieldSchema.d.ts.map +1 -1
  804. package/lib/simple-tree/walkFieldSchema.js.map +1 -1
  805. package/lib/tableSchema.d.ts +10 -10
  806. package/lib/treeFactory.d.ts +1 -1
  807. package/lib/treeFactory.js +1 -1
  808. package/lib/treeFactory.js.map +1 -1
  809. package/lib/util/bTreeUtils.d.ts.map +1 -1
  810. package/lib/util/bTreeUtils.js.map +1 -1
  811. package/lib/util/breakable.d.ts +23 -4
  812. package/lib/util/breakable.d.ts.map +1 -1
  813. package/lib/util/breakable.js +12 -3
  814. package/lib/util/breakable.js.map +1 -1
  815. package/package.json +21 -21
  816. package/src/codec/codec.ts +13 -3
  817. package/src/core/index.ts +1 -0
  818. package/src/core/rebase/types.ts +2 -2
  819. package/src/core/rebase/utils.ts +10 -10
  820. package/src/core/schema-stored/formatV1.ts +0 -2
  821. package/src/core/schema-stored/index.ts +1 -0
  822. package/src/core/schema-stored/schema.ts +7 -0
  823. package/src/core/tree/anchorSet.ts +2 -1
  824. package/src/core/tree/pathTree.ts +12 -11
  825. package/src/core/tree/treeTextFormat.ts +1 -1
  826. package/src/feature-libraries/chunked-forest/chunkedForest.ts +1 -1
  827. package/src/feature-libraries/default-schema/defaultEditBuilder.ts +1 -1
  828. package/src/feature-libraries/default-schema/index.ts +1 -1
  829. package/src/feature-libraries/default-schema/schemaChecker.ts +44 -29
  830. package/src/feature-libraries/flex-tree/context.ts +29 -8
  831. package/src/feature-libraries/flex-tree/flexTreeTypes.ts +3 -2
  832. package/src/feature-libraries/flex-tree/lazyField.ts +1 -1
  833. package/src/feature-libraries/flex-tree/utilities.ts +1 -1
  834. package/src/feature-libraries/forest-summary/forestSummarizer.ts +1 -1
  835. package/src/feature-libraries/index.ts +1 -2
  836. package/src/feature-libraries/indexing/anchorTreeIndex.ts +4 -2
  837. package/src/feature-libraries/modular-schema/crossFieldQueries.ts +1 -0
  838. package/src/feature-libraries/modular-schema/fieldChangeHandler.ts +1 -1
  839. package/src/feature-libraries/modular-schema/fieldKindWithEditor.ts +1 -1
  840. package/src/feature-libraries/modular-schema/genericFieldKind.ts +4 -2
  841. package/src/feature-libraries/modular-schema/genericFieldKindCodecs.ts +1 -0
  842. package/src/feature-libraries/modular-schema/genericFieldKindTypes.ts +1 -0
  843. package/src/feature-libraries/modular-schema/isNeverTree.ts +0 -2
  844. package/src/feature-libraries/modular-schema/modularChangeCodecs.ts +1 -1
  845. package/src/feature-libraries/modular-schema/modularChangeFamily.ts +2 -0
  846. package/src/feature-libraries/modular-schema/modularChangeTypes.ts +1 -0
  847. package/src/feature-libraries/node-identifier/mockNodeIdentifierManager.ts +11 -5
  848. package/src/feature-libraries/object-forest/objectForest.ts +65 -7
  849. package/src/feature-libraries/schema-edits/schemaChangeCodecs.ts +5 -8
  850. package/src/feature-libraries/schema-index/codec.ts +13 -21
  851. package/src/feature-libraries/schema-index/formatV1.ts +2 -2
  852. package/src/feature-libraries/schema-index/index.ts +0 -1
  853. package/src/feature-libraries/schema-index/schemaSummarizer.ts +1 -1
  854. package/src/feature-libraries/sequence-field/formatV3.ts +1 -0
  855. package/src/feature-libraries/sequence-field/markQueue.ts +1 -0
  856. package/src/feature-libraries/sequence-field/prune.ts +1 -0
  857. package/src/feature-libraries/sequence-field/rebase.ts +1 -1
  858. package/src/feature-libraries/sequence-field/relevantRemovedRoots.ts +1 -1
  859. package/src/feature-libraries/sequence-field/replaceRevisions.ts +3 -1
  860. package/src/feature-libraries/sequence-field/sequenceFieldCodecV1.ts +2 -2
  861. package/src/feature-libraries/sequence-field/sequenceFieldCodecV2.ts +3 -3
  862. package/src/feature-libraries/sequence-field/sequenceFieldCodecV3.ts +3 -3
  863. package/src/feature-libraries/sequence-field/sequenceFieldCodecs.ts +2 -2
  864. package/src/feature-libraries/sequence-field/sequenceFieldToDelta.ts +1 -1
  865. package/src/feature-libraries/sequence-field/utils.ts +7 -5
  866. package/src/feature-libraries/treeCursorUtils.ts +2 -2
  867. package/src/feature-libraries/treeTextCursor.ts +1 -1
  868. package/src/index.ts +1 -4
  869. package/src/packageVersion.ts +1 -1
  870. package/src/shared-tree/checkoutFlexTreeView.ts +1 -0
  871. package/src/shared-tree/independentView.ts +10 -3
  872. package/src/shared-tree/index.ts +4 -1
  873. package/src/shared-tree/schematizeTree.ts +2 -1
  874. package/src/shared-tree/schematizingTreeView.ts +2 -2
  875. package/src/shared-tree/sharedTree.ts +26 -19
  876. package/src/shared-tree/sharedTreeChangeFamily.ts +1 -1
  877. package/src/shared-tree/tree.ts +1 -1
  878. package/src/shared-tree/treeAlpha.ts +142 -18
  879. package/src/shared-tree/treeCheckout.ts +3 -2
  880. package/src/shared-tree-core/branch.ts +3 -4
  881. package/src/shared-tree-core/branchCommitEnricher.ts +3 -1
  882. package/src/shared-tree-core/defaultResubmitMachine.ts +2 -0
  883. package/src/shared-tree-core/editManager.ts +4 -2
  884. package/src/shared-tree-core/editManagerCodecs.ts +1 -0
  885. package/src/shared-tree-core/editManagerSummarizer.ts +1 -1
  886. package/src/shared-tree-core/messageCodecs.ts +1 -1
  887. package/src/shared-tree-core/sequenceIdUtils.ts +1 -0
  888. package/src/shared-tree-core/sharedTreeCore.ts +5 -5
  889. package/src/shared-tree-core/transaction.ts +4 -2
  890. package/src/shared-tree-core/transactionEnricher.ts +2 -0
  891. package/src/simple-tree/api/conciseTree.ts +3 -2
  892. package/src/simple-tree/api/configuration.ts +1 -1
  893. package/src/simple-tree/api/create.ts +3 -80
  894. package/src/simple-tree/api/customTree.ts +4 -4
  895. package/src/simple-tree/api/getSimpleSchema.ts +1 -0
  896. package/src/simple-tree/api/identifierIndex.ts +1 -1
  897. package/src/simple-tree/api/index.ts +1 -10
  898. package/src/simple-tree/api/schemaCompatibilityTester.ts +2 -0
  899. package/src/simple-tree/api/schemaFactory.ts +28 -23
  900. package/src/simple-tree/api/schemaFactoryAlpha.ts +8 -6
  901. package/src/simple-tree/api/schemaFactoryRecursive.ts +3 -3
  902. package/src/simple-tree/api/schemaFromSimple.ts +3 -1
  903. package/src/simple-tree/api/simpleSchemaToJsonSchema.ts +1 -3
  904. package/src/simple-tree/api/storedSchema.ts +5 -4
  905. package/src/simple-tree/api/tree.ts +3 -4
  906. package/src/simple-tree/api/treeBeta.ts +3 -2
  907. package/src/simple-tree/api/treeNodeApi.ts +89 -40
  908. package/src/simple-tree/api/typesUnsafe.ts +1 -1
  909. package/src/simple-tree/api/verboseTree.ts +1 -1
  910. package/src/simple-tree/api/viewSchemaToSimpleSchema.ts +1 -3
  911. package/src/simple-tree/core/context.ts +1 -0
  912. package/src/simple-tree/core/getOrCreateNode.ts +2 -1
  913. package/src/simple-tree/core/treeNode.ts +1 -1
  914. package/src/simple-tree/core/treeNodeKernel.ts +10 -8
  915. package/src/simple-tree/core/treeNodeSchema.ts +1 -0
  916. package/src/simple-tree/core/types.ts +1 -1
  917. package/src/simple-tree/core/unhydratedFlexTree.ts +4 -3
  918. package/src/simple-tree/core/withType.ts +1 -1
  919. package/src/simple-tree/createContext.ts +1 -0
  920. package/src/simple-tree/getTreeNodeForField.ts +2 -0
  921. package/src/simple-tree/index.ts +14 -21
  922. package/src/simple-tree/leafNodeSchema.ts +1 -0
  923. package/src/simple-tree/{arrayNode.ts → node-kinds/array/arrayNode.ts} +10 -10
  924. package/src/simple-tree/{arrayNodeTypes.ts → node-kinds/array/arrayNodeTypes.ts} +3 -3
  925. package/src/simple-tree/node-kinds/array/index.ts +18 -0
  926. package/src/simple-tree/node-kinds/index.ts +40 -0
  927. package/src/simple-tree/node-kinds/map/index.ts +16 -0
  928. package/src/simple-tree/{mapNode.ts → node-kinds/map/mapNode.ts} +10 -10
  929. package/src/simple-tree/{mapNodeTypes.ts → node-kinds/map/mapNodeTypes.ts} +3 -3
  930. package/src/simple-tree/node-kinds/object/index.ts +17 -0
  931. package/src/simple-tree/{objectNode.ts → node-kinds/object/objectNode.ts} +63 -34
  932. package/src/simple-tree/{objectNodeTypes.ts → node-kinds/object/objectNodeTypes.ts} +5 -5
  933. package/src/simple-tree/prepareForInsertion.ts +1 -1
  934. package/src/simple-tree/schemaTypes.ts +4 -3
  935. package/src/simple-tree/simpleSchema.ts +1 -0
  936. package/src/simple-tree/toMapTree.ts +11 -30
  937. package/src/simple-tree/toStoredSchema.ts +3 -2
  938. package/src/simple-tree/treeNodeValid.ts +3 -3
  939. package/src/simple-tree/walkFieldSchema.ts +0 -1
  940. package/src/treeFactory.ts +1 -1
  941. package/src/util/bTreeUtils.ts +1 -0
  942. package/src/util/breakable.ts +19 -4
  943. package/dist/simple-tree/api/testRecursiveDomain.d.ts +0 -62
  944. package/dist/simple-tree/api/testRecursiveDomain.d.ts.map +0 -1
  945. package/dist/simple-tree/api/testRecursiveDomain.js +0 -45
  946. package/dist/simple-tree/api/testRecursiveDomain.js.map +0 -1
  947. package/dist/simple-tree/arrayNode.d.ts.map +0 -1
  948. package/dist/simple-tree/arrayNode.js.map +0 -1
  949. package/dist/simple-tree/arrayNodeTypes.d.ts.map +0 -1
  950. package/dist/simple-tree/mapNode.d.ts.map +0 -1
  951. package/dist/simple-tree/mapNode.js.map +0 -1
  952. package/dist/simple-tree/mapNodeTypes.d.ts.map +0 -1
  953. package/dist/simple-tree/mapNodeTypes.js.map +0 -1
  954. package/dist/simple-tree/objectNode.d.ts.map +0 -1
  955. package/dist/simple-tree/objectNode.js.map +0 -1
  956. package/dist/simple-tree/objectNodeTypes.d.ts.map +0 -1
  957. package/dist/simple-tree/objectNodeTypes.js.map +0 -1
  958. package/lib/simple-tree/api/testRecursiveDomain.d.ts +0 -62
  959. package/lib/simple-tree/api/testRecursiveDomain.d.ts.map +0 -1
  960. package/lib/simple-tree/api/testRecursiveDomain.js +0 -41
  961. package/lib/simple-tree/api/testRecursiveDomain.js.map +0 -1
  962. package/lib/simple-tree/arrayNode.d.ts.map +0 -1
  963. package/lib/simple-tree/arrayNode.js.map +0 -1
  964. package/lib/simple-tree/arrayNodeTypes.d.ts.map +0 -1
  965. package/lib/simple-tree/arrayNodeTypes.js.map +0 -1
  966. package/lib/simple-tree/mapNode.d.ts.map +0 -1
  967. package/lib/simple-tree/mapNode.js.map +0 -1
  968. package/lib/simple-tree/mapNodeTypes.d.ts.map +0 -1
  969. package/lib/simple-tree/mapNodeTypes.js.map +0 -1
  970. package/lib/simple-tree/objectNode.d.ts.map +0 -1
  971. package/lib/simple-tree/objectNode.js.map +0 -1
  972. package/lib/simple-tree/objectNodeTypes.d.ts.map +0 -1
  973. package/lib/simple-tree/objectNodeTypes.js.map +0 -1
  974. package/src/simple-tree/api/testRecursiveDomain.ts +0 -53
@@ -1 +1 @@
1
- {"version":3,"file":"sharedTreeChangeFamily.js","sourceRoot":"","sources":["../../src/shared-tree/sharedTreeChangeFamily.ts"],"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AC,EACjC,KAAK,CACL,CAAC;QACH,CAAC;IACF,CAAC,CAAC,CAAC;AACJ,CAAC;AAlED,4CAkEC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, fail } from \"@fluidframework/core-utils/internal\";\n\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\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"]}
1
+ {"version":3,"file":"sharedTreeChangeFamily.js","sourceRoot":"","sources":["../../src/shared-tree/sharedTreeChangeFamily.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAAmE;AAInE,+CAU0B;AAC1B,4DASuC;AACvC,+CAM0B;AAE1B,2EAA8E;AAE9E,yEAAmE;AAEnE;;;;GAIG;AACH,MAAa,sBAAsB;IAYlC,YACC,gBAAkC,EAClC,eAAgC,EAChC,YAA2B,EAC3B,wBAAkD,EACjC,YAA4B;QAA5B,iBAAY,GAAZ,YAAY,CAAgB;QAE7C,MAAM,kBAAkB,GAAG,IAAA,uCAA4B,EACtD,kCAAuB,EACvB,gBAAgB,EAChB,eAAe,EACf,YAAY,EACZ,wBAAwB,CACxB,CAAC;QACF,IAAI,CAAC,mBAAmB,GAAG,IAAI,8BAAmB,CAAC,qBAAU,EAAE,kBAAkB,CAAC,CAAC;QACnF,IAAI,CAAC,MAAM,GAAG,IAAA,2DAA+B,EAC5C,IAAI,CAAC,mBAAmB,CAAC,MAAM,EAC/B,YAAY,CACZ,CAAC;IACH,CAAC;IAEM,WAAW,CACjB,eAAkC,EAClC,cAAgE;QAEhE,OAAO,IAAI,gDAAqB,CAC/B,IAAI,CAAC,mBAAmB,EACxB,eAAe,EACf,cAAc,CACd,CAAC;IACH,CAAC;IAEM,OAAO,CAAC,OAAyC;QACvD,MAAM,UAAU,GAAyC,EAAE,CAAC;QAC5D,MAAM,aAAa,GAAqC,EAAE,CAAC;QAE3D,MAAM,kBAAkB,GAAG,GAAS,EAAE;YACrC,IAAI,aAAa,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBAC9B,UAAU,CAAC,IAAI,CAAC;oBACf,IAAI,EAAE,MAAM;oBACZ,WAAW,EAAE,IAAI,CAA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,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;AAlED,4CAkEC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, fail } from \"@fluidframework/core-utils/internal\";\nimport type { IIdCompressor } from \"@fluidframework/id-compressor\";\n\nimport type { 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\thasSingle,\n\tnestedSetContains,\n} from \"../util/index.js\";\n\nimport { makeSharedTreeChangeCodecFamily } from \"./sharedTreeChangeCodecs.js\";\nimport type { SharedTreeChange } from \"./sharedTreeChangeTypes.js\";\nimport { SharedTreeEditBuilder } from \"./sharedTreeEditBuilder.js\";\n\n/**\n * Implementation of {@link ChangeFamily} that combines edits to fields and schema changes.\n *\n * @sealed\n */\nexport class SharedTreeChangeFamily\n\timplements\n\t\tChangeFamily<SharedTreeEditBuilder, SharedTreeChange>,\n\t\tChangeRebaser<SharedTreeChange>\n{\n\tpublic static readonly emptyChange: SharedTreeChange = {\n\t\tchanges: [],\n\t};\n\n\tpublic readonly codecs: ICodecFamily<SharedTreeChange, ChangeEncodingContext>;\n\tprivate readonly modularChangeFamily: ModularChangeFamily;\n\n\tpublic constructor(\n\t\trevisionTagCodec: RevisionTagCodec,\n\t\tfieldBatchCodec: FieldBatchCodec,\n\t\tcodecOptions: 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"]}
@@ -9,8 +9,8 @@ const internal_1 = require("@fluidframework/core-utils/internal");
9
9
  const internal_2 = require("@fluidframework/telemetry-utils/internal");
10
10
  const index_js_1 = require("../feature-libraries/index.js");
11
11
  const index_js_2 = require("../simple-tree/index.js");
12
- const schematizingTreeView_js_1 = require("./schematizingTreeView.js");
13
12
  const checkoutFlexTreeView_js_1 = require("./checkoutFlexTreeView.js");
13
+ const schematizingTreeView_js_1 = require("./schematizingTreeView.js");
14
14
  /**
15
15
  * The {@link (Tree:interface)} singleton which holds various functions for interacting with {@link TreeNode}s.
16
16
  * @public
@@ -1 +1 @@
1
- {"version":3,"file":"tree.js","sourceRoot":"","sources":["../../src/shared-tree/tree.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAAsE;AACtE,uEAAsE;AAEtE,4DAA2D;AAC3D,sDASiC;AAEjC,uEAAuE;AAEvE,uEAAoE;AA+BpE;;;GAGG;AACU,QAAA,IAAI,GAAS;IACzB,GAAG,sBAAW;IAEd,cAAc,EAAE,oBAAoB,EAAE;IAEtC,QAAQ,CAAC,MAAgB,EAAE,KAAe;QACzC,IAAI,OAAO,GAAyB,KAAK,CAAC;QAC1C,OAAO,OAAO,KAAK,SAAS,EAAE,CAAC;YAC9B,IAAI,OAAO,KAAK,MAAM,EAAE,CAAC;gBACxB,OAAO,IAAI,CAAC;YACb,CAAC;YACD,OAAO,GAAG,YAAI,CAAC,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.\n * Licensed under the MIT License.\n */\n\nimport { unreachableCase } from \"@fluidframework/core-utils/internal\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\n\nimport { TreeStatus } from \"../feature-libraries/index.js\";\nimport {\n\ttype ImplicitFieldSchema,\n\ttype TreeNode,\n\ttype TreeNodeApi,\n\ttype TreeView,\n\tgetOrCreateInnerNode,\n\ttreeNodeApi,\n\trollback,\n\ttype TransactionConstraint,\n} from \"../simple-tree/index.js\";\n\nimport { SchematizingSimpleTreeView } from \"./schematizingTreeView.js\";\nimport type { ITreeCheckout } from \"./treeCheckout.js\";\nimport { getCheckoutFlexTreeView } from \"./checkoutFlexTreeView.js\";\n\n/**\n * Provides various functions for interacting with {@link TreeNode}s.\n * @remarks\n * This type should only be used via the {@link (Tree:variable)} export.\n * @system @sealed @public\n */\nexport interface Tree extends TreeNodeApi {\n\t/**\n\t * Run a {@link RunTransaction | transaction}.\n\t */\n\treadonly runTransaction: RunTransaction;\n\t/**\n\t * Check if the subtree defined by `node` contains `other`.\n\t *\n\t * @returns true if `other` is an inclusive descendant of `node`, and false otherwise.\n\t * @remarks\n\t * This includes direct and indirect children:\n\t * as long as `node` is an ancestor of `other` (occurs in its parentage chain), this returns true, regardless of the number of levels of the tree between.\n\t *\n\t * `node` is considered to contain itself, so the case where `node === other` returns true.\n\t *\n\t * This is handy when checking if moving `node` into `other` would create a cycle and would thus be invalid.\n\t *\n\t * This check walks the parents of `other` looking for `node`,\n\t * and thus runs in time proportional to the depth of child in the tree.\n\t */\n\tcontains(node: TreeNode, other: TreeNode): boolean;\n}\n\n/**\n * The {@link (Tree:interface)} singleton which holds various functions for interacting with {@link TreeNode}s.\n * @public\n */\nexport const Tree: Tree = {\n\t...treeNodeApi,\n\n\trunTransaction: createRunTransaction(),\n\n\tcontains(parent: TreeNode, child: TreeNode): boolean {\n\t\tlet toCheck: TreeNode | undefined = child;\n\t\twhile (toCheck !== undefined) {\n\t\t\tif (toCheck === parent) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\ttoCheck = Tree.parent(toCheck);\n\t\t}\n\t\treturn false;\n\t},\n};\n\n/**\n * A function which runs a transaction in a SharedTree.\n * @privateRemarks\n * This interface exists so that the (generously) overloaded `Tree.runTransaction` function can have the \"rollback\" property hanging off of it.\n * The rollback property being available on the function itself gives users a convenient option for rolling back a transaction without having to import another symbol.\n * @sealed @public\n */\nexport interface RunTransaction {\n\t/**\n\t * The {@link rollback} object used to roll back a transaction.\n\t */\n\treadonly rollback: typeof rollback;\n\n\t/**\n\t * Apply one or more edits to the tree as a single atomic unit.\n\t * @param node - The node that will be passed to `transaction`.\n\t * This is typically the root node of the subtree that will be modified by the transaction.\n\t * @param transaction - The function to run as the body of the transaction.\n\t * This function is passed the provided `node`.\n\t * @returns The value returned by the inner `transaction` function.\n\t * @remarks\n\t * All of the changes in the transaction are applied synchronously and therefore no other changes (either from this client or from a remote client) can be interleaved with those changes.\n\t * Note that this is guaranteed by Fluid for any sequence of changes that are submitted synchronously, whether in a transaction or not.\n\t * However, using a transaction has the following additional consequences:\n\t *\n\t * - If reverted (e.g. via an \"undo\" operation), all the changes in the transaction are reverted together.\n\t *\n\t * - The internal data representation of a transaction with many changes is generally smaller and more efficient than that of the changes when separate.\n\t *\n\t * Local change events will be emitted for each change as the transaction is being applied.\n\t * If the transaction function throws an error then the transaction will be automatically rolled back (discarding any changes made to the tree so far) before the error is propagated up from this function.\n\t * If the transaction is rolled back, a corresponding change event will also be emitted for the rollback.\n\t */\n\t<TNode extends TreeNode, TResult>(\n\t\tnode: TNode,\n\t\ttransaction: (node: TNode) => TResult,\n\t): TResult;\n\t/**\n\t * Apply one or more edits to the tree as a single atomic unit.\n\t * @param tree - The tree which will be edited by the transaction\n\t * @param transaction - The function to run as the body of the transaction.\n\t * This function is passed the root of the tree.\n\t * @returns The value returned by the inner `transaction` function.\n\t * @remarks\n\t * All of the changes in the transaction are applied synchronously and therefore no other changes (either from this client or from a remote client) can be interleaved with those changes.\n\t * Note that this is guaranteed by Fluid for any sequence of changes that are submitted synchronously, whether in a transaction or not.\n\t * However, using a transaction has the following additional consequences:\n\t *\n\t * - If reverted (e.g. via an \"undo\" operation), all the changes in the transaction are reverted together.\n\t *\n\t * - The internal data representation of a transaction with many changes is generally smaller and more efficient than that of the changes when separate.\n\t *\n\t * Local change events will be emitted for each change as the transaction is being applied.\n\t * If the transaction function throws an error then the transaction will be automatically rolled back (discarding any changes made to the tree so far) before the error is propagated up from this function.\n\t * If the transaction is rolled back, a corresponding change event will also be emitted for the rollback.\n\t */\n\t// TODO: TreeView is invariant over the schema, so to accept any view, `any` is the only real option unless a non generic (or covariant) base type for view is introduced (which is planned).\n\t// This use of any is actually type safe as it is only used as a constraint, and the actual strongly typed view (TView) is passed to the callback.\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t<TView extends TreeView<any>, TResult>(\n\t\ttree: TView,\n\t\ttransaction: (root: TView[\"root\"]) => TResult,\n\t): TResult;\n\t/**\n\t * Apply one or more edits to the tree as a single atomic unit.\n\t * @param node - The node that will be passed to `transaction`.\n\t * This is typically the root node of the subtree that will be modified by the transaction.\n\t * @param transaction - The function to run as the body of the transaction.\n\t * This function is passed the provided `node`.\n\t * At any point during the transaction, the function may return the special {@link RunTransaction.rollback | rollback value} (`Tree.runTransaction.rollback`) to abort the transaction and discard any changes it made so far.\n\t * @returns The value returned by the inner `transaction` function.\n\t * @remarks\n\t * All of the changes in the transaction are applied synchronously and therefore no other changes (either from this client or from a remote client) can be interleaved with those changes.\n\t * Note that this is guaranteed by Fluid for any sequence of changes that are submitted synchronously, whether in a transaction or not.\n\t * However, using a transaction has the following additional consequences:\n\t *\n\t * - If reverted (e.g. via an \"undo\" operation), all the changes in the transaction are reverted together.\n\t *\n\t * - The internal data representation of a transaction with many changes is generally smaller and more efficient than that of the changes when separate.\n\t *\n\t * Local change events will be emitted for each change as the transaction is being applied.\n\t * If the transaction function throws an error then the transaction will be automatically rolled back (discarding any changes made to the tree so far) before the error is propagated up from this function.\n\t * If the transaction is rolled back (whether by an error or by returning the {@link RunTransaction.rollback} | rollback value), a corresponding change event will also be emitted for the rollback.\n\t */\n\t<TNode extends TreeNode, TResult>(\n\t\tnode: TNode,\n\t\ttransaction: (node: TNode) => TResult | typeof rollback,\n\t): TResult | typeof rollback;\n\t/**\n\t * Apply one or more edits to the tree as a single atomic unit.\n\t * @param tree - The tree which will be edited by the transaction\n\t * @param transaction - The function to run as the body of the transaction.\n\t * This function is passed the root of the tree.\n\t * At any point during the transaction, the function may return the special {@link RunTransaction.rollback | rollback value} (`Tree.runTransaction.rollback`) to abort the transaction and discard any changes it made so far.\n\t * @returns The value returned by the inner `transaction` function.\n\t * @remarks\n\t * All of the changes in the transaction are applied synchronously and therefore no other changes (either from this client or from a remote client) can be interleaved with those changes.\n\t * Note that this is guaranteed by Fluid for any sequence of changes that are submitted synchronously, whether in a transaction or not.\n\t * However, using a transaction has the following additional consequences:\n\t *\n\t * - If reverted (e.g. via an \"undo\" operation), all the changes in the transaction are reverted together.\n\t *\n\t * - The internal data representation of a transaction with many changes is generally smaller and more efficient than that of the changes when separate.\n\t *\n\t * Local change events will be emitted for each change as the transaction is being applied.\n\t * If the transaction function throws an error then the transaction will be automatically rolled back (discarding any changes made to the tree so far) before the error is propagated up from this function.\n\t * If the transaction is rolled back (whether by an error or by returning the {@link RunTransaction.rollback} | rollback value), a corresponding change event will also be emitted for the rollback.\n\t */\n\t// See comment on previous overload about use of any here.\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t<TView extends TreeView<any>, TResult>(\n\t\ttree: TView,\n\t\ttransaction: (root: TView[\"root\"]) => TResult | typeof rollback,\n\t): TResult | typeof rollback;\n\t/**\n\t * Apply one or more edits to the tree as a single atomic unit.\n\t * @param node - The node that will be passed to `transaction`.\n\t * This is typically the root node of the subtree that will be modified by the transaction.\n\t * @param transaction - The function to run as the body of the transaction.\n\t * This function is passed the provided `node`.\n\t * @remarks\n\t * All of the changes in the transaction are applied synchronously and therefore no other changes (either from this client or from a remote client) can be interleaved with those changes.\n\t * Note that this is guaranteed by Fluid for any sequence of changes that are submitted synchronously, whether in a transaction or not.\n\t * However, using a transaction has the following additional consequences:\n\t *\n\t * - If reverted (e.g. via an \"undo\" operation), all the changes in the transaction are reverted together.\n\t *\n\t * - The internal data representation of a transaction with many changes is generally smaller and more efficient than that of the changes when separate.\n\t *\n\t * Local change events will be emitted for each change as the transaction is being applied.\n\t * If the transaction function throws an error then the transaction will be automatically rolled back (discarding any changes made to the tree so far) before the error is propagated up from this function.\n\t * If the transaction is rolled back, a corresponding change event will also be emitted for the rollback.\n\t */\n\t<TNode extends TreeNode>(node: TNode, transaction: (node: TNode) => void): void;\n\t/**\n\t * Apply one or more edits to the tree as a single atomic unit.\n\t * @param tree - The tree which will be edited by the transaction\n\t * @param transaction - The function to run as the body of the transaction.\n\t * This function is passed the root of the tree.\n\t * @remarks\n\t * All of the changes in the transaction are applied synchronously and therefore no other changes (either from this client or from a remote client) can be interleaved with those changes.\n\t * Note that this is guaranteed by Fluid for any sequence of changes that are submitted synchronously, whether in a transaction or not.\n\t * However, using a transaction has the following additional consequences:\n\t *\n\t * - If reverted (e.g. via an \"undo\" operation), all the changes in the transaction are reverted together.\n\t *\n\t * - The internal data representation of a transaction with many changes is generally smaller and more efficient than that of the changes when separate.\n\t *\n\t * Local change events will be emitted for each change as the transaction is being applied.\n\t * If the transaction function throws an error then the transaction will be automatically rolled back (discarding any changes made to the tree so far) before the error is propagated up from this function.\n\t * If the transaction is rolled back, a corresponding change event will also be emitted for the rollback.\n\t */\n\t// See comment on previous overload about use of any here.\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t<TView extends TreeView<any>>(tree: TView, transaction: (root: TView[\"root\"]) => void): void;\n\t/**\n\t * Apply one or more edits to the tree as a single atomic unit.\n\t * @param node - The node that will be passed to `transaction`.\n\t * This is typically the root node of the subtree that will be modified by the transaction.\n\t * @param transaction - The function to run as the body of the transaction.\n\t * This function is passed the provided `node`.\n\t * @param preconditions - An optional list of {@link TransactionConstraint | constraints} that are checked just before the transaction begins.\n\t * If any of the constraints are not met when `runTransaction` is called, it will throw an error.\n\t * If any of the constraints are not met after the transaction has been ordered by the service, it will be rolled back on this client and ignored by all other clients.\n\t * @returns The value returned by the inner `transaction` function.\n\t * @remarks\n\t * All of the changes in the transaction are applied synchronously and therefore no other changes (either from this client or from a remote client) can be interleaved with those changes.\n\t * Note that this is guaranteed by Fluid for any sequence of changes that are submitted synchronously, whether in a transaction or not.\n\t * However, using a transaction has the following additional consequences:\n\t *\n\t * - If reverted (e.g. via an \"undo\" operation), all the changes in the transaction are reverted together.\n\t *\n\t * - The internal data representation of a transaction with many changes is generally smaller and more efficient than that of the changes when separate.\n\t *\n\t * Local change events will be emitted for each change as the transaction is being applied.\n\t * If the transaction function throws an error then the transaction will be automatically rolled back (discarding any changes made to the tree so far) before the error is propagated up from this function.\n\t * If the transaction is rolled back, a corresponding change event will also be emitted for the rollback.\n\t */\n\t<TNode extends TreeNode, TResult>(\n\t\tnode: TNode,\n\t\ttransaction: (node: TNode) => TResult,\n\t\tpreconditions?: readonly TransactionConstraint[],\n\t): TResult;\n\t/**\n\t * Apply one or more edits to the tree as a single atomic unit.\n\t * @param tree - The tree which will be edited by the transaction\n\t * @param transaction - The function to run as the body of the transaction.\n\t * This function is passed the root of the tree.\n\t * @param preconditions - An optional list of {@link TransactionConstraint | constraints} that are checked just before the transaction begins.\n\t * If any of the constraints are not met when `runTransaction` is called, it will throw an error.\n\t * If any of the constraints are not met after the transaction has been ordered by the service, it will be rolled back on this client and ignored by all other clients.\n\t * @returns The value returned by the inner `transaction` function.\n\t * @remarks\n\t * All of the changes in the transaction are applied synchronously and therefore no other changes (either from this client or from a remote client) can be interleaved with those changes.\n\t * Note that this is guaranteed by Fluid for any sequence of changes that are submitted synchronously, whether in a transaction or not.\n\t * However, using a transaction has the following additional consequences:\n\t *\n\t * - If reverted (e.g. via an \"undo\" operation), all the changes in the transaction are reverted together.\n\t *\n\t * - The internal data representation of a transaction with many changes is generally smaller and more efficient than that of the changes when separate.\n\t *\n\t * Local change events will be emitted for each change as the transaction is being applied.\n\t * If the transaction function throws an error then the transaction will be automatically rolled back (discarding any changes made to the tree so far) before the error is propagated up from this function.\n\t * If the transaction is rolled back, a corresponding change event will also be emitted for the rollback.\n\t */\n\t// See comment on previous overload about use of any here.\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t<TView extends TreeView<any>, TResult>(\n\t\ttree: TView,\n\t\ttransaction: (root: TView[\"root\"]) => TResult,\n\t\tpreconditions?: readonly TransactionConstraint[],\n\t): TResult;\n\t/**\n\t * Apply one or more edits to the tree as a single atomic unit.\n\t * @param node - The node that will be passed to `transaction`.\n\t * This is typically the root node of the subtree that will be modified by the transaction.\n\t * @param transaction - The function to run as the body of the transaction.\n\t * This function is passed the provided `node`.\n\t * At any point during the transaction, the function may return the special {@link RunTransaction.rollback | rollback value} (`Tree.runTransaction.rollback`) to abort the transaction and discard any changes it made so far.\n\t * @param preconditions - An optional list of {@link TransactionConstraint | constraints} that are checked just before the transaction begins.\n\t * If any of the constraints are not met when `runTransaction` is called, it will throw an error.\n\t * If any of the constraints are not met after the transaction has been ordered by the service, it will be rolled back on this client and ignored by all other clients.\n\t * @returns The value returned by the inner `transaction` function.\n\t * @remarks\n\t * All of the changes in the transaction are applied synchronously and therefore no other changes (either from this client or from a remote client) can be interleaved with those changes.\n\t * Note that this is guaranteed by Fluid for any sequence of changes that are submitted synchronously, whether in a transaction or not.\n\t * However, using a transaction has the following additional consequences:\n\t *\n\t * - If reverted (e.g. via an \"undo\" operation), all the changes in the transaction are reverted together.\n\t *\n\t * - The internal data representation of a transaction with many changes is generally smaller and more efficient than that of the changes when separate.\n\t *\n\t * Local change events will be emitted for each change as the transaction is being applied.\n\t * If the transaction function throws an error then the transaction will be automatically rolled back (discarding any changes made to the tree so far) before the error is propagated up from this function.\n\t * If the transaction is rolled back (whether by an error or by returning the {@link RunTransaction.rollback} | rollback value), a corresponding change event will also be emitted for the rollback.\n\t */\n\t<TNode extends TreeNode, TResult>(\n\t\tnode: TNode,\n\t\ttransaction: (node: TNode) => TResult | typeof rollback,\n\t\tpreconditions?: readonly TransactionConstraint[],\n\t): TResult | typeof rollback;\n\t/**\n\t * Apply one or more edits to the tree as a single atomic unit.\n\t * @param tree - The tree which will be edited by the transaction\n\t * @param transaction - The function to run as the body of the transaction.\n\t * This function is passed the root of the tree.\n\t * At any point during the transaction, the function may return the special {@link RunTransaction.rollback | rollback value} (`Tree.runTransaction.rollback`) to abort the transaction and discard any changes it made so far.\n\t * @param preconditions - An optional list of {@link TransactionConstraint | constraints} that are checked just before the transaction begins.\n\t * If any of the constraints are not met when `runTransaction` is called, it will throw an error.\n\t * If any of the constraints are not met after the transaction has been ordered by the service, it will be rolled back on this client and ignored by all other clients.\n\t * @returns The value returned by the inner `transaction` function.\n\t * @remarks\n\t * All of the changes in the transaction are applied synchronously and therefore no other changes (either from this client or from a remote client) can be interleaved with those changes.\n\t * Note that this is guaranteed by Fluid for any sequence of changes that are submitted synchronously, whether in a transaction or not.\n\t * However, using a transaction has the following additional consequences:\n\t *\n\t * - If reverted (e.g. via an \"undo\" operation), all the changes in the transaction are reverted together.\n\t *\n\t * - The internal data representation of a transaction with many changes is generally smaller and more efficient than that of the changes when separate.\n\t *\n\t * Local change events will be emitted for each change as the transaction is being applied.\n\t * If the transaction function throws an error then the transaction will be automatically rolled back (discarding any changes made to the tree so far) before the error is propagated up from this function.\n\t * If the transaction is rolled back (whether by an error or by returning the {@link RunTransaction.rollback} | rollback value), a corresponding change event will also be emitted for the rollback.\n\t */\n\t// See comment on previous overload about use of any here.\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t<TView extends TreeView<any>, TResult>(\n\t\ttree: TView,\n\t\ttransaction: (root: TView[\"root\"]) => TResult | typeof rollback,\n\t\tpreconditions?: readonly TransactionConstraint[],\n\t): TResult | typeof rollback;\n\t/**\n\t * Apply one or more edits to the tree as a single atomic unit.\n\t * @param node - The node that will be passed to `transaction`.\n\t * This is typically the root node of the subtree that will be modified by the transaction.\n\t * @param transaction - The function to run as the body of the transaction.\n\t * This function is passed the provided `node`.\n\t * @param preconditions - An optional list of {@link TransactionConstraint | constraints} that are checked just before the transaction begins.\n\t * If any of the constraints are not met when `runTransaction` is called, it will throw an error.\n\t * If any of the constraints are not met after the transaction has been ordered by the service, it will be rolled back on this client and ignored by all other clients.\n\t * @remarks\n\t * All of the changes in the transaction are applied synchronously and therefore no other changes (either from this client or from a remote client) can be interleaved with those changes.\n\t * Note that this is guaranteed by Fluid for any sequence of changes that are submitted synchronously, whether in a transaction or not.\n\t * However, using a transaction has the following additional consequences:\n\t *\n\t * - If reverted (e.g. via an \"undo\" operation), all the changes in the transaction are reverted together.\n\t *\n\t * - The internal data representation of a transaction with many changes is generally smaller and more efficient than that of the changes when separate.\n\t *\n\t * Local change events will be emitted for each change as the transaction is being applied.\n\t * If the transaction function throws an error then the transaction will be automatically rolled back (discarding any changes made to the tree so far) before the error is propagated up from this function.\n\t * If the transaction is rolled back, a corresponding change event will also be emitted for the rollback.\n\t */\n\t<TNode extends TreeNode>(\n\t\tnode: TNode,\n\t\ttransaction: (node: TNode) => void,\n\t\tpreconditions?: readonly TransactionConstraint[],\n\t): void;\n\t/**\n\t * Apply one or more edits to the tree as a single atomic unit.\n\t * @param tree - The tree which will be edited by the transaction\n\t * @param transaction - The function to run as the body of the transaction.\n\t * This function is passed the root of the tree.\n\t * @param preconditions - An optional list of {@link TransactionConstraint | constraints} that are checked just before the transaction begins.\n\t * If any of the constraints are not met when `runTransaction` is called, it will throw an error.\n\t * If any of the constraints are not met after the transaction has been ordered by the service, it will be rolled back on this client and ignored by all other clients.\n\t * @remarks\n\t * All of the changes in the transaction are applied synchronously and therefore no other changes (either from this client or from a remote client) can be interleaved with those changes.\n\t * Note that this is guaranteed by Fluid for any sequence of changes that are submitted synchronously, whether in a transaction or not.\n\t * However, using a transaction has the following additional consequences:\n\t *\n\t * - If reverted (e.g. via an \"undo\" operation), all the changes in the transaction are reverted together.\n\t *\n\t * - The internal data representation of a transaction with many changes is generally smaller and more efficient than that of the changes when separate.\n\t *\n\t * Local change events will be emitted for each change as the transaction is being applied.\n\t * If the transaction function throws an error then the transaction will be automatically rolled back (discarding any changes made to the tree so far) before the error is propagated up from this function.\n\t * If the transaction is rolled back, a corresponding change event will also be emitted for the rollback.\n\t */\n\t// See comment on previous overload about use of any here.\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t<TView extends TreeView<any>>(\n\t\ttree: TView,\n\t\ttransaction: (root: TView[\"root\"]) => void,\n\t\tpreconditions?: readonly TransactionConstraint[],\n\t): void;\n}\n\n// TODO: Add more constraint types here\n\n/** Creates a copy of `runTransaction` with the `rollback` property added so as to satisfy the `RunTransaction` interface. */\nfunction createRunTransaction(): RunTransaction {\n\t/** A type-safe helper to add a \"rollback\" property (as required by the `RunTransaction` interface) to a given object */\n\tfunction defineRollbackProperty<T extends object>(\n\t\ttarget: T,\n\t): T & { rollback: typeof rollback } {\n\t\tReflect.defineProperty(target, \"rollback\", { value: rollback });\n\t\treturn target as T & { readonly rollback: typeof rollback };\n\t}\n\n\treturn defineRollbackProperty(runTransaction.bind({}));\n}\n\n/**\n * Run the given transaction.\n * @remarks\n * This API is not publicly exported but is exported outside of this module so that test code may unit test the `Tree.runTransaction` function directly without being restricted to its public API overloads.\n * @deprecated This API catches exceptions then tries to modify the tree before rethrowing: this is not robust. Use {@link TreeViewAlpha.runTransaction} instead which does not try to edit content in the error case.\n */\nexport function runTransaction<\n\tTNode extends TreeNode,\n\tTRoot extends ImplicitFieldSchema,\n\tTResult,\n>(\n\ttreeOrNode: TNode | TreeView<TRoot>,\n\ttransaction:\n\t\t| ((node: TNode) => TResult | typeof rollback)\n\t\t| ((root: TRoot) => TResult | typeof rollback),\n\tpreconditions: readonly TransactionConstraint[] = [],\n): TResult | typeof rollback {\n\tif (treeOrNode instanceof SchematizingSimpleTreeView) {\n\t\tconst t = transaction as (root: TRoot) => TResult | typeof rollback;\n\t\treturn runTransactionInCheckout(\n\t\t\ttreeOrNode.checkout,\n\t\t\t() => t(treeOrNode.root as TRoot),\n\t\t\tpreconditions,\n\t\t);\n\t} else {\n\t\tconst node = treeOrNode as TNode;\n\t\tconst t = transaction as (node: TNode) => TResult | typeof rollback;\n\t\tconst context = getOrCreateInnerNode(node).context;\n\t\tif (context.isHydrated() === false) {\n\t\t\tthrow new UsageError(\n\t\t\t\t\"Transactions cannot be run on Unhydrated nodes. Transactions apply to a TreeView and Unhydrated nodes are not part of a TreeView.\",\n\t\t\t);\n\t\t}\n\t\tconst treeView = getCheckoutFlexTreeView(context);\n\t\treturn runTransactionInCheckout(treeView.checkout, () => t(node), preconditions);\n\t}\n}\n\n/**\n * Run the given transaction.\n * @deprecated This API catches exceptions then tries to modify the tree before rethrowing: this is not robust. Use {@link TreeViewAlpha.runTransaction} instead which does not try to editing content in the error case.\n */\nfunction runTransactionInCheckout<TResult>(\n\tcheckout: ITreeCheckout,\n\ttransaction: () => TResult | typeof rollback,\n\tpreconditions: readonly TransactionConstraint[],\n): TResult | typeof rollback {\n\tcheckout.transaction.start();\n\tfor (const constraint of preconditions) {\n\t\tswitch (constraint.type) {\n\t\t\tcase \"nodeInDocument\": {\n\t\t\t\tconst node = getOrCreateInnerNode(constraint.node);\n\t\t\t\tconst nodeStatus = Tree.status(constraint.node);\n\t\t\t\tif (nodeStatus !== TreeStatus.InDocument) {\n\t\t\t\t\tthrow new UsageError(\n\t\t\t\t\t\t`Attempted to add a \"nodeInDocument\" constraint, but the node is not currently in the document. Node status: ${nodeStatus}`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tcheckout.editor.addNodeExistsConstraint(node.anchorNode);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tdefault:\n\t\t\t\tunreachableCase(constraint.type);\n\t\t}\n\t}\n\n\tlet result: ReturnType<typeof transaction>;\n\ttry {\n\t\tresult = transaction();\n\t} catch (error) {\n\t\t// If the transaction has an unhandled error, abort and rollback the transaction but continue to propagate the error.\n\t\t// This might try and modify the tree or trigger events while things are in an inconsistent state.\n\t\t// It is up to the user of runTransaction to ensure that does not cause problems (and they have no robust way to do that, which is why its deprecated).\n\t\tcheckout.transaction.abort();\n\t\tthrow error;\n\t}\n\n\tif (result === rollback) {\n\t\tcheckout.transaction.abort();\n\t} else {\n\t\tcheckout.transaction.commit();\n\t}\n\n\treturn result;\n}\n"]}
1
+ {"version":3,"file":"tree.js","sourceRoot":"","sources":["../../src/shared-tree/tree.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAAsE;AACtE,uEAAsE;AAEtE,4DAA2D;AAC3D,sDASiC;AAEjC,uEAAoE;AACpE,uEAAuE;AAgCvE;;;GAGG;AACU,QAAA,IAAI,GAAS;IACzB,GAAG,sBAAW;IAEd,cAAc,EAAE,oBAAoB,EAAE;IAEtC,QAAQ,CAAC,MAAgB,EAAE,KAAe;QACzC,IAAI,OAAO,GAAyB,KAAK,CAAC;QAC1C,OAAO,OAAO,KAAK,SAAS,EAAE,CAAC;YAC9B,IAAI,OAAO,KAAK,MAAM,EAAE,CAAC;gBACxB,OAAO,IAAI,CAAC;YACb,CAAC;YACD,OAAO,GAAG,YAAI,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QAChC,CAAC;QACD,OAAO,KAAK,CAAC;IACd,CAAC;CACD,CAAC;AA0UF,uCAAuC;AAEvC,6HAA6H;AAC7H,SAAS,oBAAoB;IAC5B,wHAAwH;IACxH,SAAS,sBAAsB,CAC9B,MAAS;QAET,OAAO,CAAC,cAAc,CAAC,MAAM,EAAE,UAAU,EAAE,EAAE,KAAK,EAAE,mBAAQ,EAAE,CAAC,CAAC;QAChE,OAAO,MAAoD,CAAC;IAC7D,CAAC;IAED,OAAO,sBAAsB,CAAC,cAAc,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC;AACxD,CAAC;AAED;;;;;GAKG;AACH,SAAgB,cAAc,CA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E,CAAC;oBAC1C,MAAM,IAAI,qBAAU,CACnB,+GAA+G,UAAU,EAAE,CAC3H,CAAC;gBACH,CAAC;gBACD,QAAQ,CAAC,MAAM,CAAC,uBAAuB,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;gBACzD,MAAM;YACP,CAAC;YACD;gBACC,IAAA,0BAAe,EAAC,UAAU,CAAC,IAAI,CAAC,CAAC;QACnC,CAAC;IACF,CAAC;IAED,IAAI,MAAsC,CAAC;IAC3C,IAAI,CAAC;QACJ,MAAM,GAAG,WAAW,EAAE,CAAC;IACxB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QAChB,qHAAqH;QACrH,kGAAkG;QAClG,uJAAuJ;QACvJ,QAAQ,CAAC,WAAW,CAAC,KAAK,EAAE,CAAC;QAC7B,MAAM,KAAK,CAAC;IACb,CAAC;IAED,IAAI,MAAM,KAAK,mBAAQ,EAAE,CAAC;QACzB,QAAQ,CAAC,WAAW,CAAC,KAAK,EAAE,CAAC;IAC9B,CAAC;SAAM,CAAC;QACP,QAAQ,CAAC,WAAW,CAAC,MAAM,EAAE,CAAC;IAC/B,CAAC;IAED,OAAO,MAAM,CAAC;AACf,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { unreachableCase } from \"@fluidframework/core-utils/internal\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\n\nimport { TreeStatus } from \"../feature-libraries/index.js\";\nimport {\n\ttype ImplicitFieldSchema,\n\ttype TreeNode,\n\ttype TreeNodeApi,\n\ttype TreeView,\n\tgetOrCreateInnerNode,\n\ttreeNodeApi,\n\trollback,\n\ttype TransactionConstraint,\n} from \"../simple-tree/index.js\";\n\nimport { getCheckoutFlexTreeView } from \"./checkoutFlexTreeView.js\";\nimport { SchematizingSimpleTreeView } from \"./schematizingTreeView.js\";\nimport type { ITreeCheckout } from \"./treeCheckout.js\";\n\n/**\n * Provides various functions for interacting with {@link TreeNode}s.\n * @remarks\n * This type should only be used via the {@link (Tree:variable)} export.\n * @system @sealed @public\n */\nexport interface Tree extends TreeNodeApi {\n\t/**\n\t * Run a {@link RunTransaction | transaction}.\n\t */\n\treadonly runTransaction: RunTransaction;\n\t/**\n\t * Check if the subtree defined by `node` contains `other`.\n\t *\n\t * @returns true if `other` is an inclusive descendant of `node`, and false otherwise.\n\t * @remarks\n\t * This includes direct and indirect children:\n\t * as long as `node` is an ancestor of `other` (occurs in its parentage chain), this returns true, regardless of the number of levels of the tree between.\n\t *\n\t * `node` is considered to contain itself, so the case where `node === other` returns true.\n\t *\n\t * This is handy when checking if moving `node` into `other` would create a cycle and would thus be invalid.\n\t *\n\t * This check walks the parents of `other` looking for `node`,\n\t * and thus runs in time proportional to the depth of child in the tree.\n\t */\n\tcontains(node: TreeNode, other: TreeNode): boolean;\n}\n\n/**\n * The {@link (Tree:interface)} singleton which holds various functions for interacting with {@link TreeNode}s.\n * @public\n */\nexport const Tree: Tree = {\n\t...treeNodeApi,\n\n\trunTransaction: createRunTransaction(),\n\n\tcontains(parent: TreeNode, child: TreeNode): boolean {\n\t\tlet toCheck: TreeNode | undefined = child;\n\t\twhile (toCheck !== undefined) {\n\t\t\tif (toCheck === parent) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\ttoCheck = Tree.parent(toCheck);\n\t\t}\n\t\treturn false;\n\t},\n};\n\n/**\n * A function which runs a transaction in a SharedTree.\n * @privateRemarks\n * This interface exists so that the (generously) overloaded `Tree.runTransaction` function can have the \"rollback\" property hanging off of it.\n * The rollback property being available on the function itself gives users a convenient option for rolling back a transaction without having to import another symbol.\n * @sealed @public\n */\nexport interface RunTransaction {\n\t/**\n\t * The {@link rollback} object used to roll back a transaction.\n\t */\n\treadonly rollback: typeof rollback;\n\n\t/**\n\t * Apply one or more edits to the tree as a single atomic unit.\n\t * @param node - The node that will be passed to `transaction`.\n\t * This is typically the root node of the subtree that will be modified by the transaction.\n\t * @param transaction - The function to run as the body of the transaction.\n\t * This function is passed the provided `node`.\n\t * @returns The value returned by the inner `transaction` function.\n\t * @remarks\n\t * All of the changes in the transaction are applied synchronously and therefore no other changes (either from this client or from a remote client) can be interleaved with those changes.\n\t * Note that this is guaranteed by Fluid for any sequence of changes that are submitted synchronously, whether in a transaction or not.\n\t * However, using a transaction has the following additional consequences:\n\t *\n\t * - If reverted (e.g. via an \"undo\" operation), all the changes in the transaction are reverted together.\n\t *\n\t * - The internal data representation of a transaction with many changes is generally smaller and more efficient than that of the changes when separate.\n\t *\n\t * Local change events will be emitted for each change as the transaction is being applied.\n\t * If the transaction function throws an error then the transaction will be automatically rolled back (discarding any changes made to the tree so far) before the error is propagated up from this function.\n\t * If the transaction is rolled back, a corresponding change event will also be emitted for the rollback.\n\t */\n\t<TNode extends TreeNode, TResult>(\n\t\tnode: TNode,\n\t\ttransaction: (node: TNode) => TResult,\n\t): TResult;\n\t/**\n\t * Apply one or more edits to the tree as a single atomic unit.\n\t * @param tree - The tree which will be edited by the transaction\n\t * @param transaction - The function to run as the body of the transaction.\n\t * This function is passed the root of the tree.\n\t * @returns The value returned by the inner `transaction` function.\n\t * @remarks\n\t * All of the changes in the transaction are applied synchronously and therefore no other changes (either from this client or from a remote client) can be interleaved with those changes.\n\t * Note that this is guaranteed by Fluid for any sequence of changes that are submitted synchronously, whether in a transaction or not.\n\t * However, using a transaction has the following additional consequences:\n\t *\n\t * - If reverted (e.g. via an \"undo\" operation), all the changes in the transaction are reverted together.\n\t *\n\t * - The internal data representation of a transaction with many changes is generally smaller and more efficient than that of the changes when separate.\n\t *\n\t * Local change events will be emitted for each change as the transaction is being applied.\n\t * If the transaction function throws an error then the transaction will be automatically rolled back (discarding any changes made to the tree so far) before the error is propagated up from this function.\n\t * If the transaction is rolled back, a corresponding change event will also be emitted for the rollback.\n\t */\n\t// TODO: TreeView is invariant over the schema, so to accept any view, `any` is the only real option unless a non generic (or covariant) base type for view is introduced (which is planned).\n\t// This use of any is actually type safe as it is only used as a constraint, and the actual strongly typed view (TView) is passed to the callback.\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t<TView extends TreeView<any>, TResult>(\n\t\ttree: TView,\n\t\ttransaction: (root: TView[\"root\"]) => TResult,\n\t): TResult;\n\t/**\n\t * Apply one or more edits to the tree as a single atomic unit.\n\t * @param node - The node that will be passed to `transaction`.\n\t * This is typically the root node of the subtree that will be modified by the transaction.\n\t * @param transaction - The function to run as the body of the transaction.\n\t * This function is passed the provided `node`.\n\t * At any point during the transaction, the function may return the special {@link RunTransaction.rollback | rollback value} (`Tree.runTransaction.rollback`) to abort the transaction and discard any changes it made so far.\n\t * @returns The value returned by the inner `transaction` function.\n\t * @remarks\n\t * All of the changes in the transaction are applied synchronously and therefore no other changes (either from this client or from a remote client) can be interleaved with those changes.\n\t * Note that this is guaranteed by Fluid for any sequence of changes that are submitted synchronously, whether in a transaction or not.\n\t * However, using a transaction has the following additional consequences:\n\t *\n\t * - If reverted (e.g. via an \"undo\" operation), all the changes in the transaction are reverted together.\n\t *\n\t * - The internal data representation of a transaction with many changes is generally smaller and more efficient than that of the changes when separate.\n\t *\n\t * Local change events will be emitted for each change as the transaction is being applied.\n\t * If the transaction function throws an error then the transaction will be automatically rolled back (discarding any changes made to the tree so far) before the error is propagated up from this function.\n\t * If the transaction is rolled back (whether by an error or by returning the {@link RunTransaction.rollback} | rollback value), a corresponding change event will also be emitted for the rollback.\n\t */\n\t<TNode extends TreeNode, TResult>(\n\t\tnode: TNode,\n\t\ttransaction: (node: TNode) => TResult | typeof rollback,\n\t): TResult | typeof rollback;\n\t/**\n\t * Apply one or more edits to the tree as a single atomic unit.\n\t * @param tree - The tree which will be edited by the transaction\n\t * @param transaction - The function to run as the body of the transaction.\n\t * This function is passed the root of the tree.\n\t * At any point during the transaction, the function may return the special {@link RunTransaction.rollback | rollback value} (`Tree.runTransaction.rollback`) to abort the transaction and discard any changes it made so far.\n\t * @returns The value returned by the inner `transaction` function.\n\t * @remarks\n\t * All of the changes in the transaction are applied synchronously and therefore no other changes (either from this client or from a remote client) can be interleaved with those changes.\n\t * Note that this is guaranteed by Fluid for any sequence of changes that are submitted synchronously, whether in a transaction or not.\n\t * However, using a transaction has the following additional consequences:\n\t *\n\t * - If reverted (e.g. via an \"undo\" operation), all the changes in the transaction are reverted together.\n\t *\n\t * - The internal data representation of a transaction with many changes is generally smaller and more efficient than that of the changes when separate.\n\t *\n\t * Local change events will be emitted for each change as the transaction is being applied.\n\t * If the transaction function throws an error then the transaction will be automatically rolled back (discarding any changes made to the tree so far) before the error is propagated up from this function.\n\t * If the transaction is rolled back (whether by an error or by returning the {@link RunTransaction.rollback} | rollback value), a corresponding change event will also be emitted for the rollback.\n\t */\n\t// See comment on previous overload about use of any here.\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t<TView extends TreeView<any>, TResult>(\n\t\ttree: TView,\n\t\ttransaction: (root: TView[\"root\"]) => TResult | typeof rollback,\n\t): TResult | typeof rollback;\n\t/**\n\t * Apply one or more edits to the tree as a single atomic unit.\n\t * @param node - The node that will be passed to `transaction`.\n\t * This is typically the root node of the subtree that will be modified by the transaction.\n\t * @param transaction - The function to run as the body of the transaction.\n\t * This function is passed the provided `node`.\n\t * @remarks\n\t * All of the changes in the transaction are applied synchronously and therefore no other changes (either from this client or from a remote client) can be interleaved with those changes.\n\t * Note that this is guaranteed by Fluid for any sequence of changes that are submitted synchronously, whether in a transaction or not.\n\t * However, using a transaction has the following additional consequences:\n\t *\n\t * - If reverted (e.g. via an \"undo\" operation), all the changes in the transaction are reverted together.\n\t *\n\t * - The internal data representation of a transaction with many changes is generally smaller and more efficient than that of the changes when separate.\n\t *\n\t * Local change events will be emitted for each change as the transaction is being applied.\n\t * If the transaction function throws an error then the transaction will be automatically rolled back (discarding any changes made to the tree so far) before the error is propagated up from this function.\n\t * If the transaction is rolled back, a corresponding change event will also be emitted for the rollback.\n\t */\n\t<TNode extends TreeNode>(node: TNode, transaction: (node: TNode) => void): void;\n\t/**\n\t * Apply one or more edits to the tree as a single atomic unit.\n\t * @param tree - The tree which will be edited by the transaction\n\t * @param transaction - The function to run as the body of the transaction.\n\t * This function is passed the root of the tree.\n\t * @remarks\n\t * All of the changes in the transaction are applied synchronously and therefore no other changes (either from this client or from a remote client) can be interleaved with those changes.\n\t * Note that this is guaranteed by Fluid for any sequence of changes that are submitted synchronously, whether in a transaction or not.\n\t * However, using a transaction has the following additional consequences:\n\t *\n\t * - If reverted (e.g. via an \"undo\" operation), all the changes in the transaction are reverted together.\n\t *\n\t * - The internal data representation of a transaction with many changes is generally smaller and more efficient than that of the changes when separate.\n\t *\n\t * Local change events will be emitted for each change as the transaction is being applied.\n\t * If the transaction function throws an error then the transaction will be automatically rolled back (discarding any changes made to the tree so far) before the error is propagated up from this function.\n\t * If the transaction is rolled back, a corresponding change event will also be emitted for the rollback.\n\t */\n\t// See comment on previous overload about use of any here.\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t<TView extends TreeView<any>>(tree: TView, transaction: (root: TView[\"root\"]) => void): void;\n\t/**\n\t * Apply one or more edits to the tree as a single atomic unit.\n\t * @param node - The node that will be passed to `transaction`.\n\t * This is typically the root node of the subtree that will be modified by the transaction.\n\t * @param transaction - The function to run as the body of the transaction.\n\t * This function is passed the provided `node`.\n\t * @param preconditions - An optional list of {@link TransactionConstraint | constraints} that are checked just before the transaction begins.\n\t * If any of the constraints are not met when `runTransaction` is called, it will throw an error.\n\t * If any of the constraints are not met after the transaction has been ordered by the service, it will be rolled back on this client and ignored by all other clients.\n\t * @returns The value returned by the inner `transaction` function.\n\t * @remarks\n\t * All of the changes in the transaction are applied synchronously and therefore no other changes (either from this client or from a remote client) can be interleaved with those changes.\n\t * Note that this is guaranteed by Fluid for any sequence of changes that are submitted synchronously, whether in a transaction or not.\n\t * However, using a transaction has the following additional consequences:\n\t *\n\t * - If reverted (e.g. via an \"undo\" operation), all the changes in the transaction are reverted together.\n\t *\n\t * - The internal data representation of a transaction with many changes is generally smaller and more efficient than that of the changes when separate.\n\t *\n\t * Local change events will be emitted for each change as the transaction is being applied.\n\t * If the transaction function throws an error then the transaction will be automatically rolled back (discarding any changes made to the tree so far) before the error is propagated up from this function.\n\t * If the transaction is rolled back, a corresponding change event will also be emitted for the rollback.\n\t */\n\t<TNode extends TreeNode, TResult>(\n\t\tnode: TNode,\n\t\ttransaction: (node: TNode) => TResult,\n\t\tpreconditions?: readonly TransactionConstraint[],\n\t): TResult;\n\t/**\n\t * Apply one or more edits to the tree as a single atomic unit.\n\t * @param tree - The tree which will be edited by the transaction\n\t * @param transaction - The function to run as the body of the transaction.\n\t * This function is passed the root of the tree.\n\t * @param preconditions - An optional list of {@link TransactionConstraint | constraints} that are checked just before the transaction begins.\n\t * If any of the constraints are not met when `runTransaction` is called, it will throw an error.\n\t * If any of the constraints are not met after the transaction has been ordered by the service, it will be rolled back on this client and ignored by all other clients.\n\t * @returns The value returned by the inner `transaction` function.\n\t * @remarks\n\t * All of the changes in the transaction are applied synchronously and therefore no other changes (either from this client or from a remote client) can be interleaved with those changes.\n\t * Note that this is guaranteed by Fluid for any sequence of changes that are submitted synchronously, whether in a transaction or not.\n\t * However, using a transaction has the following additional consequences:\n\t *\n\t * - If reverted (e.g. via an \"undo\" operation), all the changes in the transaction are reverted together.\n\t *\n\t * - The internal data representation of a transaction with many changes is generally smaller and more efficient than that of the changes when separate.\n\t *\n\t * Local change events will be emitted for each change as the transaction is being applied.\n\t * If the transaction function throws an error then the transaction will be automatically rolled back (discarding any changes made to the tree so far) before the error is propagated up from this function.\n\t * If the transaction is rolled back, a corresponding change event will also be emitted for the rollback.\n\t */\n\t// See comment on previous overload about use of any here.\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t<TView extends TreeView<any>, TResult>(\n\t\ttree: TView,\n\t\ttransaction: (root: TView[\"root\"]) => TResult,\n\t\tpreconditions?: readonly TransactionConstraint[],\n\t): TResult;\n\t/**\n\t * Apply one or more edits to the tree as a single atomic unit.\n\t * @param node - The node that will be passed to `transaction`.\n\t * This is typically the root node of the subtree that will be modified by the transaction.\n\t * @param transaction - The function to run as the body of the transaction.\n\t * This function is passed the provided `node`.\n\t * At any point during the transaction, the function may return the special {@link RunTransaction.rollback | rollback value} (`Tree.runTransaction.rollback`) to abort the transaction and discard any changes it made so far.\n\t * @param preconditions - An optional list of {@link TransactionConstraint | constraints} that are checked just before the transaction begins.\n\t * If any of the constraints are not met when `runTransaction` is called, it will throw an error.\n\t * If any of the constraints are not met after the transaction has been ordered by the service, it will be rolled back on this client and ignored by all other clients.\n\t * @returns The value returned by the inner `transaction` function.\n\t * @remarks\n\t * All of the changes in the transaction are applied synchronously and therefore no other changes (either from this client or from a remote client) can be interleaved with those changes.\n\t * Note that this is guaranteed by Fluid for any sequence of changes that are submitted synchronously, whether in a transaction or not.\n\t * However, using a transaction has the following additional consequences:\n\t *\n\t * - If reverted (e.g. via an \"undo\" operation), all the changes in the transaction are reverted together.\n\t *\n\t * - The internal data representation of a transaction with many changes is generally smaller and more efficient than that of the changes when separate.\n\t *\n\t * Local change events will be emitted for each change as the transaction is being applied.\n\t * If the transaction function throws an error then the transaction will be automatically rolled back (discarding any changes made to the tree so far) before the error is propagated up from this function.\n\t * If the transaction is rolled back (whether by an error or by returning the {@link RunTransaction.rollback} | rollback value), a corresponding change event will also be emitted for the rollback.\n\t */\n\t<TNode extends TreeNode, TResult>(\n\t\tnode: TNode,\n\t\ttransaction: (node: TNode) => TResult | typeof rollback,\n\t\tpreconditions?: readonly TransactionConstraint[],\n\t): TResult | typeof rollback;\n\t/**\n\t * Apply one or more edits to the tree as a single atomic unit.\n\t * @param tree - The tree which will be edited by the transaction\n\t * @param transaction - The function to run as the body of the transaction.\n\t * This function is passed the root of the tree.\n\t * At any point during the transaction, the function may return the special {@link RunTransaction.rollback | rollback value} (`Tree.runTransaction.rollback`) to abort the transaction and discard any changes it made so far.\n\t * @param preconditions - An optional list of {@link TransactionConstraint | constraints} that are checked just before the transaction begins.\n\t * If any of the constraints are not met when `runTransaction` is called, it will throw an error.\n\t * If any of the constraints are not met after the transaction has been ordered by the service, it will be rolled back on this client and ignored by all other clients.\n\t * @returns The value returned by the inner `transaction` function.\n\t * @remarks\n\t * All of the changes in the transaction are applied synchronously and therefore no other changes (either from this client or from a remote client) can be interleaved with those changes.\n\t * Note that this is guaranteed by Fluid for any sequence of changes that are submitted synchronously, whether in a transaction or not.\n\t * However, using a transaction has the following additional consequences:\n\t *\n\t * - If reverted (e.g. via an \"undo\" operation), all the changes in the transaction are reverted together.\n\t *\n\t * - The internal data representation of a transaction with many changes is generally smaller and more efficient than that of the changes when separate.\n\t *\n\t * Local change events will be emitted for each change as the transaction is being applied.\n\t * If the transaction function throws an error then the transaction will be automatically rolled back (discarding any changes made to the tree so far) before the error is propagated up from this function.\n\t * If the transaction is rolled back (whether by an error or by returning the {@link RunTransaction.rollback} | rollback value), a corresponding change event will also be emitted for the rollback.\n\t */\n\t// See comment on previous overload about use of any here.\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t<TView extends TreeView<any>, TResult>(\n\t\ttree: TView,\n\t\ttransaction: (root: TView[\"root\"]) => TResult | typeof rollback,\n\t\tpreconditions?: readonly TransactionConstraint[],\n\t): TResult | typeof rollback;\n\t/**\n\t * Apply one or more edits to the tree as a single atomic unit.\n\t * @param node - The node that will be passed to `transaction`.\n\t * This is typically the root node of the subtree that will be modified by the transaction.\n\t * @param transaction - The function to run as the body of the transaction.\n\t * This function is passed the provided `node`.\n\t * @param preconditions - An optional list of {@link TransactionConstraint | constraints} that are checked just before the transaction begins.\n\t * If any of the constraints are not met when `runTransaction` is called, it will throw an error.\n\t * If any of the constraints are not met after the transaction has been ordered by the service, it will be rolled back on this client and ignored by all other clients.\n\t * @remarks\n\t * All of the changes in the transaction are applied synchronously and therefore no other changes (either from this client or from a remote client) can be interleaved with those changes.\n\t * Note that this is guaranteed by Fluid for any sequence of changes that are submitted synchronously, whether in a transaction or not.\n\t * However, using a transaction has the following additional consequences:\n\t *\n\t * - If reverted (e.g. via an \"undo\" operation), all the changes in the transaction are reverted together.\n\t *\n\t * - The internal data representation of a transaction with many changes is generally smaller and more efficient than that of the changes when separate.\n\t *\n\t * Local change events will be emitted for each change as the transaction is being applied.\n\t * If the transaction function throws an error then the transaction will be automatically rolled back (discarding any changes made to the tree so far) before the error is propagated up from this function.\n\t * If the transaction is rolled back, a corresponding change event will also be emitted for the rollback.\n\t */\n\t<TNode extends TreeNode>(\n\t\tnode: TNode,\n\t\ttransaction: (node: TNode) => void,\n\t\tpreconditions?: readonly TransactionConstraint[],\n\t): void;\n\t/**\n\t * Apply one or more edits to the tree as a single atomic unit.\n\t * @param tree - The tree which will be edited by the transaction\n\t * @param transaction - The function to run as the body of the transaction.\n\t * This function is passed the root of the tree.\n\t * @param preconditions - An optional list of {@link TransactionConstraint | constraints} that are checked just before the transaction begins.\n\t * If any of the constraints are not met when `runTransaction` is called, it will throw an error.\n\t * If any of the constraints are not met after the transaction has been ordered by the service, it will be rolled back on this client and ignored by all other clients.\n\t * @remarks\n\t * All of the changes in the transaction are applied synchronously and therefore no other changes (either from this client or from a remote client) can be interleaved with those changes.\n\t * Note that this is guaranteed by Fluid for any sequence of changes that are submitted synchronously, whether in a transaction or not.\n\t * However, using a transaction has the following additional consequences:\n\t *\n\t * - If reverted (e.g. via an \"undo\" operation), all the changes in the transaction are reverted together.\n\t *\n\t * - The internal data representation of a transaction with many changes is generally smaller and more efficient than that of the changes when separate.\n\t *\n\t * Local change events will be emitted for each change as the transaction is being applied.\n\t * If the transaction function throws an error then the transaction will be automatically rolled back (discarding any changes made to the tree so far) before the error is propagated up from this function.\n\t * If the transaction is rolled back, a corresponding change event will also be emitted for the rollback.\n\t */\n\t// See comment on previous overload about use of any here.\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t<TView extends TreeView<any>>(\n\t\ttree: TView,\n\t\ttransaction: (root: TView[\"root\"]) => void,\n\t\tpreconditions?: readonly TransactionConstraint[],\n\t): void;\n}\n\n// TODO: Add more constraint types here\n\n/** Creates a copy of `runTransaction` with the `rollback` property added so as to satisfy the `RunTransaction` interface. */\nfunction createRunTransaction(): RunTransaction {\n\t/** A type-safe helper to add a \"rollback\" property (as required by the `RunTransaction` interface) to a given object */\n\tfunction defineRollbackProperty<T extends object>(\n\t\ttarget: T,\n\t): T & { rollback: typeof rollback } {\n\t\tReflect.defineProperty(target, \"rollback\", { value: rollback });\n\t\treturn target as T & { readonly rollback: typeof rollback };\n\t}\n\n\treturn defineRollbackProperty(runTransaction.bind({}));\n}\n\n/**\n * Run the given transaction.\n * @remarks\n * This API is not publicly exported but is exported outside of this module so that test code may unit test the `Tree.runTransaction` function directly without being restricted to its public API overloads.\n * @deprecated This API catches exceptions then tries to modify the tree before rethrowing: this is not robust. Use {@link TreeViewAlpha.runTransaction} instead which does not try to edit content in the error case.\n */\nexport function runTransaction<\n\tTNode extends TreeNode,\n\tTRoot extends ImplicitFieldSchema,\n\tTResult,\n>(\n\ttreeOrNode: TNode | TreeView<TRoot>,\n\ttransaction:\n\t\t| ((node: TNode) => TResult | typeof rollback)\n\t\t| ((root: TRoot) => TResult | typeof rollback),\n\tpreconditions: readonly TransactionConstraint[] = [],\n): TResult | typeof rollback {\n\tif (treeOrNode instanceof SchematizingSimpleTreeView) {\n\t\tconst t = transaction as (root: TRoot) => TResult | typeof rollback;\n\t\treturn runTransactionInCheckout(\n\t\t\ttreeOrNode.checkout,\n\t\t\t() => t(treeOrNode.root as TRoot),\n\t\t\tpreconditions,\n\t\t);\n\t} else {\n\t\tconst node = treeOrNode as TNode;\n\t\tconst t = transaction as (node: TNode) => TResult | typeof rollback;\n\t\tconst context = getOrCreateInnerNode(node).context;\n\t\tif (context.isHydrated() === false) {\n\t\t\tthrow new UsageError(\n\t\t\t\t\"Transactions cannot be run on Unhydrated nodes. Transactions apply to a TreeView and Unhydrated nodes are not part of a TreeView.\",\n\t\t\t);\n\t\t}\n\t\tconst treeView = getCheckoutFlexTreeView(context);\n\t\treturn runTransactionInCheckout(treeView.checkout, () => t(node), preconditions);\n\t}\n}\n\n/**\n * Run the given transaction.\n * @deprecated This API catches exceptions then tries to modify the tree before rethrowing: this is not robust. Use {@link TreeViewAlpha.runTransaction} instead which does not try to editing content in the error case.\n */\nfunction runTransactionInCheckout<TResult>(\n\tcheckout: ITreeCheckout,\n\ttransaction: () => TResult | typeof rollback,\n\tpreconditions: readonly TransactionConstraint[],\n): TResult | typeof rollback {\n\tcheckout.transaction.start();\n\tfor (const constraint of preconditions) {\n\t\tswitch (constraint.type) {\n\t\t\tcase \"nodeInDocument\": {\n\t\t\t\tconst node = getOrCreateInnerNode(constraint.node);\n\t\t\t\tconst nodeStatus = Tree.status(constraint.node);\n\t\t\t\tif (nodeStatus !== TreeStatus.InDocument) {\n\t\t\t\t\tthrow new UsageError(\n\t\t\t\t\t\t`Attempted to add a \"nodeInDocument\" constraint, but the node is not currently in the document. Node status: ${nodeStatus}`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tcheckout.editor.addNodeExistsConstraint(node.anchorNode);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tdefault:\n\t\t\t\tunreachableCase(constraint.type);\n\t\t}\n\t}\n\n\tlet result: ReturnType<typeof transaction>;\n\ttry {\n\t\tresult = transaction();\n\t} catch (error) {\n\t\t// If the transaction has an unhandled error, abort and rollback the transaction but continue to propagate the error.\n\t\t// This might try and modify the tree or trigger events while things are in an inconsistent state.\n\t\t// It is up to the user of runTransaction to ensure that does not cause problems (and they have no robust way to do that, which is why its deprecated).\n\t\tcheckout.transaction.abort();\n\t\tthrow error;\n\t}\n\n\tif (result === rollback) {\n\t\tcheckout.transaction.abort();\n\t} else {\n\t\tcheckout.transaction.commit();\n\t}\n\n\treturn result;\n}\n"]}
@@ -5,8 +5,78 @@
5
5
  import type { IFluidHandle } from "@fluidframework/core-interfaces";
6
6
  import type { IIdCompressor } from "@fluidframework/id-compressor";
7
7
  import { type TreeNode, type Unhydrated, type ImplicitFieldSchema, type InsertableField, type TreeFieldFromImplicitField, type TreeLeafValue, type UnsafeUnknownSchema, type ConciseTree, type TreeEncodingOptions, type VerboseTree, type TreeBranch } from "../simple-tree/index.js";
8
- import type { JsonCompatible } from "../util/index.js";
8
+ import { type JsonCompatible } from "../util/index.js";
9
9
  import { type FluidClientVersion, type ICodecOptions } from "../codec/index.js";
10
+ /**
11
+ * A utility interface for retrieving or converting node identifiers.
12
+ *
13
+ * @remarks
14
+ * This provides methods to:
15
+ *
16
+ * - Retrieve long or short identifiers from nodes
17
+ *
18
+ * - Convert between long identifiers and short identifiers
19
+ *
20
+ * - Generates long identifiers
21
+ *
22
+ * @alpha @sealed
23
+ */
24
+ export interface TreeIdentifierUtils {
25
+ /**
26
+ * Returns the contents of a node's {@link SchemaFactory.identifier} field as a stable identifier.
27
+ * If the identifier field does not exist, returns undefined.
28
+ *
29
+ * @param node - The TreeNode you want to get the identifier from,
30
+ */
31
+ (node: TreeNode): string | undefined;
32
+ /**
33
+ * Returns the shortened identifier as a number given long identifier known by the id compressor on the branch if possible.
34
+ * Otherwise, it will return the original string identifier provided.
35
+ * If the id does not exist, or is unknown by the id compressor, it returns undefined.
36
+ *
37
+ * This method is the inverse of {@link TreeIdentifierUtils.lengthen}. If you shorten an identifier
38
+ * and then immediately pass it to {@link TreeIdentifierUtils.lengthen}, you will get the original string back.
39
+ *
40
+ * @param branch - TreeBranch from where you get the idCompressor to do the decompression.
41
+ * @param nodeIdentifier - the stable identifier that needs to be shortened.
42
+ */
43
+ shorten(branch: TreeBranch, nodeIdentifier: string): number | undefined;
44
+ /**
45
+ * Returns the stable id as a string if the identifier is decompressible and known by the id compressor. Otherwise, it will throw an error.
46
+ *
47
+ * This method is the inverse of {@link TreeIdentifierUtils.shorten}. If you lengthen an identifier
48
+ * and then immediately pass it to {@link TreeIdentifierUtils.shorten}, you will get the original short identifier back.
49
+ *
50
+ * @param branch - TreeBranch from where you want to get the id compressor to do the decompression.
51
+ * @param nodeIdentifier - The local identifier that needs to be expanded.
52
+ */
53
+ lengthen(branch: TreeBranch, nodeIdentifier: number): string;
54
+ /**
55
+ * Returns the {@link SchemaFactory.identifier | identifier} of the given node in the most compressed form possible.
56
+ * @remarks
57
+ * If the node is {@link Unhydrated | hydrated} and its identifier is a valid UUID that was automatically generated by the SharedTree it is part of (or something else using the same {@link @fluidframework/id-compressor#IIdCompressor}), then this will return a process-unique integer corresponding to that identifier.
58
+ * This is useful for performance-sensitive scenarios involving many nodes with identifiers that need to be compactly retained in memory or used for efficient lookup.
59
+ * Note that automatically generated identifiers that were accessed before the node was hydrated will return the generated UUID, not the process-unique integer.
60
+ *
61
+ * If the node's identifier is any other user-provided string, then this will return undefined.
62
+ *
63
+ * If the node has no identifier (that is, it has no {@link SchemaFactory.identifier | identifier} field), then this returns `undefined`.
64
+ *
65
+ * If the node has more than one identifier, then this will throw an error.
66
+ *
67
+ * The returned integer should not be serialized or preserved outside of the current process.
68
+ * Its lifetime is that of the current in-memory instance of the FF container for this client, and it is not guaranteed to be unique or stable outside of that context.
69
+ * The same node's identifier may, for example, be different across multiple sessions for the same client and document, or different across two clients in the same session.
70
+ */
71
+ getShort(node: TreeNode): number | undefined;
72
+ /**
73
+ * Creates and returns a long identifier.
74
+ * The long identifier is a compressible, stable identifier generated by the tree's ID compressor.
75
+ *
76
+ * @param branch - TreeBranch from where you want to get the id compressor to generate the identifier from.
77
+ */
78
+ create(branch: TreeBranch): string;
79
+ }
10
80
  /**
11
81
  * Extensions to {@link (Tree:interface)} and {@link (TreeBeta:interface)} which are not yet stable.
12
82
  * @remarks
@@ -95,7 +165,7 @@ export interface TreeAlpha {
95
165
  * Additionally using `createIdCompressor` to make an idCompressor is `@legacy` and thus not intended for use in this API surface.
96
166
  * It would probably make more sense if we provided a way to get an idCompressor from the context of a node,
97
167
  * which could be optional (and settable if missing) for un0hydrated nodes and required for hydrated ones.
98
- * 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.
168
+ * 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.
99
169
  */
100
170
  exportCompressed(tree: TreeNode | TreeLeafValue, options: {
101
171
  oldestCompatibleClient: FluidClientVersion;
@@ -123,6 +193,10 @@ export interface TreeAlpha {
123
193
  importCompressed<const TSchema extends ImplicitFieldSchema>(schema: TSchema, compressedData: JsonCompatible<IFluidHandle>, options: {
124
194
  idCompressor?: IIdCompressor;
125
195
  } & ICodecOptions): Unhydrated<TreeFieldFromImplicitField<TSchema>>;
196
+ /**
197
+ * APIs for creating, converting, and retrieving identifiers.
198
+ */
199
+ readonly identifier: TreeIdentifierUtils;
126
200
  /**
127
201
  * The key of the given node under its parent.
128
202
  * @remarks
@@ -1 +1 @@
1
- {"version":3,"file":"treeAlpha.d.ts","sourceRoot":"","sources":["../../src/shared-tree/treeAlpha.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AACpE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAEnE,OAAO,EAEN,KAAK,QAAQ,EACb,KAAK,UAAU,EAQf,KAAK,mBAAmB,EACxB,KAAK,eAAe,EACpB,KAAK,0BAA0B,EAC/B,KAAK,aAAa,EAClB,KAAK,mBAAmB,EAExB,KAAK,WAAW,EAIhB,KAAK,mBAAmB,EACxB,KAAK,WAAW,EAGhB,KAAK,UAAU,EAMf,MAAM,yBAAyB,CAAC;AACjC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAiB,KAAK,kBAAkB,EAAE,KAAK,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAkB/F;;;;;GAKG;AACH,MAAM,WAAW,SAAS;IACzB;;;;;;;;OAQG;IACH,MAAM,CAAC,IAAI,EAAE,QAAQ,GAAG,UAAU,GAAG,SAAS,CAAC;IAE/C;;;;;;;;;;OAUG;IACH,MAAM,CAAC,KAAK,CAAC,OAAO,SAAS,mBAAm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AEzC;;;;;;OAMG;IACH,IAAI,CAAC,IAAI,EAAE,QAAQ,GAAG,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;CAClD;AAED;;;;GAIG;AACH,eAAO,MAAM,SAAS,EAAE,SA0IvB,CAAC"}
@@ -9,12 +9,41 @@ const internal_1 = require("@fluidframework/core-utils/internal");
9
9
  const internal_2 = require("@fluidframework/id-compressor/internal");
10
10
  const internal_3 = require("@fluidframework/telemetry-utils/internal");
11
11
  const index_js_1 = require("../simple-tree/index.js");
12
- const index_js_2 = require("../codec/index.js");
13
- const index_js_3 = require("../feature-libraries/index.js");
12
+ const index_js_2 = require("../util/index.js");
13
+ const index_js_3 = require("../codec/index.js");
14
+ const index_js_4 = require("../feature-libraries/index.js");
14
15
  const independentView_js_1 = require("./independentView.js");
15
16
  const schematizingTreeView_js_1 = require("./schematizingTreeView.js");
16
- const index_js_4 = require("../codec/index.js");
17
- const index_js_5 = require("../simple-tree/index.js");
17
+ const index_js_5 = require("../codec/index.js");
18
+ const index_js_6 = require("../simple-tree/index.js");
19
+ const identifier = (node) => {
20
+ const nodeIdentifier = (0, index_js_1.getIdentifierFromNode)(node, "uncompressed");
21
+ if (typeof nodeIdentifier === "number") {
22
+ throw new TypeError("identifier should be uncompressed.");
23
+ }
24
+ return nodeIdentifier;
25
+ };
26
+ identifier.shorten = (branch, nodeIdentifier) => {
27
+ const nodeKeyManager = branch
28
+ .nodeKeyManager;
29
+ const localNodeKey = nodeKeyManager.tryLocalizeNodeIdentifier(nodeIdentifier);
30
+ return localNodeKey !== undefined ? (0, index_js_2.extractFromOpaque)(localNodeKey) : undefined;
31
+ };
32
+ identifier.lengthen = (branch, nodeIdentifier) => {
33
+ const nodeKeyManager = branch
34
+ .nodeKeyManager;
35
+ return nodeKeyManager.stabilizeNodeIdentifier(nodeIdentifier);
36
+ };
37
+ identifier.getShort = (node) => {
38
+ const shortIdentifier = (0, index_js_1.getIdentifierFromNode)(node, "compressed");
39
+ return typeof shortIdentifier === "number" ? shortIdentifier : undefined;
40
+ };
41
+ identifier.create = (branch) => {
42
+ const nodeKeyManager = branch
43
+ .nodeKeyManager;
44
+ return nodeKeyManager.stabilizeNodeIdentifier(nodeKeyManager.generateLocalNodeIdentifier());
45
+ };
46
+ Object.freeze(identifier);
18
47
  /**
19
48
  * Extensions to {@link (Tree:variable)} and {@link (TreeBeta:variable)} which are not yet stable.
20
49
  * @see {@link (TreeAlpha:interface)}.
@@ -32,11 +61,14 @@ exports.TreeAlpha = {
32
61
  },
33
62
  create(schema, data) {
34
63
  const mapTree = (0, index_js_1.mapTreeFromNodeData)(data, schema);
35
- const result = mapTree === undefined ? undefined : (0, index_js_5.createFromMapTree)(schema, mapTree);
64
+ const result = mapTree === undefined ? undefined : (0, index_js_6.createFromMapTree)(schema, mapTree);
36
65
  return result;
37
66
  },
38
67
  importConcise(schema, data) {
39
- return (0, index_js_1.createFromInsertable)(schema, data);
68
+ // `importConcise` does not need to support all the formats that `create` does.
69
+ // Perhaps it should error instead of hydrating nodes for example.
70
+ // For now however, it is a simple wrapper around `create`.
71
+ return this.create(schema, data);
40
72
  },
41
73
  importVerbose(schema, data, options) {
42
74
  const config = { ...options };
@@ -60,17 +92,17 @@ exports.TreeAlpha = {
60
92
  },
61
93
  exportCompressed(node, options) {
62
94
  const schema = (0, index_js_1.tryGetSchema)(node) ?? (0, internal_1.fail)(0xacf /* invalid input */);
63
- const format = (0, index_js_3.fluidVersionToFieldBatchCodecWriteVersion)(options.oldestCompatibleClient);
64
- const codec = (0, index_js_3.makeFieldBatchCodec)({ jsonValidator: index_js_2.noopValidator }, format);
95
+ const format = (0, index_js_4.fluidVersionToFieldBatchCodecWriteVersion)(options.oldestCompatibleClient);
96
+ const codec = (0, index_js_4.makeFieldBatchCodec)({ jsonValidator: index_js_3.noopValidator }, format);
65
97
  const cursor = borrowFieldCursorFromTreeNodeOrValue(node);
66
98
  const batch = [cursor];
67
99
  // If none provided, create a compressor which will not compress anything.
68
100
  const idCompressor = options.idCompressor ?? (0, internal_2.createIdCompressor)();
69
101
  const context = {
70
- encodeType: index_js_3.TreeCompressionStrategy.Compressed,
102
+ encodeType: index_js_4.TreeCompressionStrategy.Compressed,
71
103
  idCompressor,
72
104
  originatorId: idCompressor.localSessionId, // TODO: Why is this needed?
73
- schema: { schema: (0, index_js_1.toStoredSchema)(schema), policy: index_js_3.defaultSchemaPolicy },
105
+ schema: { schema: (0, index_js_1.toStoredSchema)(schema), policy: index_js_4.defaultSchemaPolicy },
74
106
  };
75
107
  const result = codec.encode(batch, context);
76
108
  return result;
@@ -78,13 +110,14 @@ exports.TreeAlpha = {
78
110
  importCompressed(schema, compressedData, options) {
79
111
  const config = new index_js_1.TreeViewConfigurationAlpha({ schema });
80
112
  const content = {
81
- schema: (0, index_js_1.extractPersistedSchema)(config, index_js_4.currentVersion),
113
+ schema: (0, index_js_1.extractPersistedSchema)(config, index_js_5.currentVersion),
82
114
  tree: compressedData,
83
115
  idCompressor: options.idCompressor ?? (0, internal_2.createIdCompressor)(),
84
116
  };
85
117
  const view = (0, independentView_js_1.independentInitializedView)(config, options, content);
86
118
  return index_js_1.TreeBeta.clone(view.root);
87
119
  },
120
+ identifier,
88
121
  key2(node) {
89
122
  // If the parent is undefined, then this node is under the root field,
90
123
  const parent = index_js_1.treeNodeApi.parent(node);
@@ -107,18 +140,31 @@ function exportConcise(node, options) {
107
140
  const cursor = borrowCursorFromTreeNodeOrValue(node);
108
141
  return (0, index_js_1.conciseFromCursor)(cursor, (0, index_js_1.tryGetSchema)(node) ?? (0, internal_1.fail)(0xacd /* invalid input */), config);
109
142
  }
143
+ /**
144
+ * Borrow a cursor from a node.
145
+ * @remarks
146
+ * The cursor must be put back to its original location before the node is used again.
147
+ */
110
148
  function borrowCursorFromTreeNodeOrValue(node) {
111
- if ((0, index_js_3.isTreeValue)(node)) {
112
- return (0, index_js_1.cursorFromInsertable)((0, index_js_1.tryGetSchema)(node) ?? (0, internal_1.fail)(0xad0 /* missing schema */), node);
149
+ if ((0, index_js_4.isTreeValue)(node)) {
150
+ return (0, index_js_1.cursorFromVerbose)(node, {});
113
151
  }
114
152
  const kernel = (0, index_js_1.getKernel)(node);
115
153
  const cursor = kernel.getOrCreateInnerNode().borrowCursor();
116
154
  return cursor;
117
155
  }
156
+ /**
157
+ * Borrow a cursor from a field.
158
+ * @remarks
159
+ * The cursor must be put back to its original location before the node is used again.
160
+ */
118
161
  function borrowFieldCursorFromTreeNodeOrValue(node) {
162
+ if (node === undefined) {
163
+ return (0, index_js_4.cursorForMapTreeField)([]);
164
+ }
119
165
  const cursor = borrowCursorFromTreeNodeOrValue(node);
120
- // TODO: avoid copy
121
- const mapTree = (0, index_js_3.mapTreeFromCursor)(cursor);
122
- return (0, index_js_3.cursorForMapTreeField)([mapTree]);
166
+ // TODO: avoid copy: borrow cursor from field instead.
167
+ const mapTree = (0, index_js_4.mapTreeFromCursor)(cursor);
168
+ return (0, index_js_4.cursorForMapTreeField)([mapTree]);
123
169
  }
124
170
  //# sourceMappingURL=treeAlpha.js.map