@fluidframework/tree 2.43.0 → 2.50.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 (415) hide show
  1. package/CHANGELOG.md +100 -0
  2. package/api-report/tree.alpha.api.md +73 -16
  3. package/api-report/tree.beta.api.md +9 -3
  4. package/api-report/tree.legacy.alpha.api.md +8 -2
  5. package/api-report/tree.legacy.public.api.md +8 -2
  6. package/api-report/tree.public.api.md +8 -2
  7. package/dist/alpha.d.ts +9 -0
  8. package/dist/core/forest/editableForest.d.ts +0 -2
  9. package/dist/core/forest/editableForest.d.ts.map +1 -1
  10. package/dist/core/forest/editableForest.js.map +1 -1
  11. package/dist/core/forest/forest.d.ts +0 -4
  12. package/dist/core/forest/forest.d.ts.map +1 -1
  13. package/dist/core/forest/forest.js +0 -4
  14. package/dist/core/forest/forest.js.map +1 -1
  15. package/dist/core/rebase/changeRebaser.d.ts +0 -6
  16. package/dist/core/rebase/changeRebaser.d.ts.map +1 -1
  17. package/dist/core/rebase/changeRebaser.js.map +1 -1
  18. package/dist/core/rebase/types.d.ts +0 -2
  19. package/dist/core/rebase/types.d.ts.map +1 -1
  20. package/dist/core/rebase/types.js.map +1 -1
  21. package/dist/core/schema-stored/schema.d.ts +0 -8
  22. package/dist/core/schema-stored/schema.d.ts.map +1 -1
  23. package/dist/core/schema-stored/schema.js +0 -8
  24. package/dist/core/schema-stored/schema.js.map +1 -1
  25. package/dist/core/schema-view/view.d.ts +0 -2
  26. package/dist/core/schema-view/view.d.ts.map +1 -1
  27. package/dist/core/schema-view/view.js.map +1 -1
  28. package/dist/core/tree/cursor.d.ts +0 -2
  29. package/dist/core/tree/cursor.d.ts.map +1 -1
  30. package/dist/core/tree/cursor.js +0 -2
  31. package/dist/core/tree/cursor.js.map +1 -1
  32. package/dist/core/tree/delta.d.ts +0 -2
  33. package/dist/core/tree/delta.d.ts.map +1 -1
  34. package/dist/core/tree/delta.js.map +1 -1
  35. package/dist/core/tree/types.d.ts +0 -4
  36. package/dist/core/tree/types.d.ts.map +1 -1
  37. package/dist/core/tree/types.js +0 -2
  38. package/dist/core/tree/types.js.map +1 -1
  39. package/dist/feature-libraries/default-schema/defaultEditBuilder.d.ts +0 -4
  40. package/dist/feature-libraries/default-schema/defaultEditBuilder.d.ts.map +1 -1
  41. package/dist/feature-libraries/default-schema/defaultEditBuilder.js.map +1 -1
  42. package/dist/feature-libraries/default-schema/defaultFieldKinds.d.ts +0 -10
  43. package/dist/feature-libraries/default-schema/defaultFieldKinds.d.ts.map +1 -1
  44. package/dist/feature-libraries/default-schema/defaultFieldKinds.js.map +1 -1
  45. package/dist/feature-libraries/flex-tree/flexTreeTypes.d.ts +0 -2
  46. package/dist/feature-libraries/flex-tree/flexTreeTypes.d.ts.map +1 -1
  47. package/dist/feature-libraries/flex-tree/flexTreeTypes.js +0 -2
  48. package/dist/feature-libraries/flex-tree/flexTreeTypes.js.map +1 -1
  49. package/dist/feature-libraries/modular-schema/crossFieldQueries.d.ts +0 -2
  50. package/dist/feature-libraries/modular-schema/crossFieldQueries.d.ts.map +1 -1
  51. package/dist/feature-libraries/modular-schema/crossFieldQueries.js +0 -2
  52. package/dist/feature-libraries/modular-schema/crossFieldQueries.js.map +1 -1
  53. package/dist/feature-libraries/modular-schema/fieldChangeHandler.d.ts +0 -10
  54. package/dist/feature-libraries/modular-schema/fieldChangeHandler.d.ts.map +1 -1
  55. package/dist/feature-libraries/modular-schema/fieldChangeHandler.js +0 -2
  56. package/dist/feature-libraries/modular-schema/fieldChangeHandler.js.map +1 -1
  57. package/dist/feature-libraries/modular-schema/modularChangeFamily.d.ts +0 -6
  58. package/dist/feature-libraries/modular-schema/modularChangeFamily.d.ts.map +1 -1
  59. package/dist/feature-libraries/modular-schema/modularChangeFamily.js.map +1 -1
  60. package/dist/feature-libraries/modular-schema/modularChangeTypes.d.ts +0 -12
  61. package/dist/feature-libraries/modular-schema/modularChangeTypes.d.ts.map +1 -1
  62. package/dist/feature-libraries/modular-schema/modularChangeTypes.js.map +1 -1
  63. package/dist/feature-libraries/sequence-field/types.d.ts +0 -2
  64. package/dist/feature-libraries/sequence-field/types.d.ts.map +1 -1
  65. package/dist/feature-libraries/sequence-field/types.js.map +1 -1
  66. package/dist/index.d.ts +1 -1
  67. package/dist/index.d.ts.map +1 -1
  68. package/dist/index.js +3 -2
  69. package/dist/index.js.map +1 -1
  70. package/dist/jsonDomainSchema.d.ts +2 -6
  71. package/dist/jsonDomainSchema.d.ts.map +1 -1
  72. package/dist/jsonDomainSchema.js +2 -2
  73. package/dist/jsonDomainSchema.js.map +1 -1
  74. package/dist/packageVersion.d.ts +1 -1
  75. package/dist/packageVersion.js +1 -1
  76. package/dist/packageVersion.js.map +1 -1
  77. package/dist/shared-tree/treeAlpha.d.ts.map +1 -1
  78. package/dist/shared-tree/treeAlpha.js +3 -1
  79. package/dist/shared-tree/treeAlpha.js.map +1 -1
  80. package/dist/shared-tree-core/defaultResubmitMachine.d.ts +8 -12
  81. package/dist/shared-tree-core/defaultResubmitMachine.d.ts.map +1 -1
  82. package/dist/shared-tree-core/defaultResubmitMachine.js +54 -46
  83. package/dist/shared-tree-core/defaultResubmitMachine.js.map +1 -1
  84. package/dist/shared-tree-core/resubmitMachine.d.ts +6 -0
  85. package/dist/shared-tree-core/resubmitMachine.d.ts.map +1 -1
  86. package/dist/shared-tree-core/resubmitMachine.js.map +1 -1
  87. package/dist/shared-tree-core/sharedTreeCore.d.ts +1 -0
  88. package/dist/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
  89. package/dist/shared-tree-core/sharedTreeCore.js +16 -3
  90. package/dist/shared-tree-core/sharedTreeCore.js.map +1 -1
  91. package/dist/simple-tree/api/configuration.d.ts.map +1 -1
  92. package/dist/simple-tree/api/configuration.js +49 -17
  93. package/dist/simple-tree/api/configuration.js.map +1 -1
  94. package/dist/simple-tree/api/customTree.d.ts +1 -1
  95. package/dist/simple-tree/api/customTree.d.ts.map +1 -1
  96. package/dist/simple-tree/api/customTree.js +3 -4
  97. package/dist/simple-tree/api/customTree.js.map +1 -1
  98. package/dist/simple-tree/api/index.d.ts +2 -2
  99. package/dist/simple-tree/api/index.d.ts.map +1 -1
  100. package/dist/simple-tree/api/index.js.map +1 -1
  101. package/dist/simple-tree/api/jsonSchema.d.ts +32 -8
  102. package/dist/simple-tree/api/jsonSchema.d.ts.map +1 -1
  103. package/dist/simple-tree/api/jsonSchema.js.map +1 -1
  104. package/dist/simple-tree/api/schemaFactory.d.ts +2 -2
  105. package/dist/simple-tree/api/schemaFactory.d.ts.map +1 -1
  106. package/dist/simple-tree/api/schemaFactory.js +1 -1
  107. package/dist/simple-tree/api/schemaFactory.js.map +1 -1
  108. package/dist/simple-tree/api/schemaFactoryAlpha.d.ts +97 -3
  109. package/dist/simple-tree/api/schemaFactoryAlpha.d.ts.map +1 -1
  110. package/dist/simple-tree/api/schemaFactoryAlpha.js +75 -0
  111. package/dist/simple-tree/api/schemaFactoryAlpha.js.map +1 -1
  112. package/dist/simple-tree/api/schemaFactoryRecursive.d.ts +5 -1
  113. package/dist/simple-tree/api/schemaFactoryRecursive.d.ts.map +1 -1
  114. package/dist/simple-tree/api/schemaFactoryRecursive.js.map +1 -1
  115. package/dist/simple-tree/api/schemaFromSimple.js +2 -0
  116. package/dist/simple-tree/api/schemaFromSimple.js.map +1 -1
  117. package/dist/simple-tree/api/simpleSchemaToJsonSchema.d.ts.map +1 -1
  118. package/dist/simple-tree/api/simpleSchemaToJsonSchema.js +4 -4
  119. package/dist/simple-tree/api/simpleSchemaToJsonSchema.js.map +1 -1
  120. package/dist/simple-tree/api/treeBeta.d.ts +1 -1
  121. package/dist/simple-tree/api/treeBeta.d.ts.map +1 -1
  122. package/dist/simple-tree/api/treeBeta.js.map +1 -1
  123. package/dist/simple-tree/api/treeNodeApi.js +1 -1
  124. package/dist/simple-tree/api/treeNodeApi.js.map +1 -1
  125. package/dist/simple-tree/api/typesUnsafe.d.ts +12 -0
  126. package/dist/simple-tree/api/typesUnsafe.d.ts.map +1 -1
  127. package/dist/simple-tree/api/typesUnsafe.js.map +1 -1
  128. package/dist/simple-tree/api/viewSchemaToSimpleSchema.d.ts.map +1 -1
  129. package/dist/simple-tree/api/viewSchemaToSimpleSchema.js +5 -3
  130. package/dist/simple-tree/api/viewSchemaToSimpleSchema.js.map +1 -1
  131. package/dist/simple-tree/core/index.d.ts +1 -1
  132. package/dist/simple-tree/core/index.d.ts.map +1 -1
  133. package/dist/simple-tree/core/index.js +2 -1
  134. package/dist/simple-tree/core/index.js.map +1 -1
  135. package/dist/simple-tree/core/treeNodeSchema.d.ts +5 -1
  136. package/dist/simple-tree/core/treeNodeSchema.d.ts.map +1 -1
  137. package/dist/simple-tree/core/treeNodeSchema.js +4 -0
  138. package/dist/simple-tree/core/treeNodeSchema.js.map +1 -1
  139. package/dist/simple-tree/index.d.ts +3 -3
  140. package/dist/simple-tree/index.d.ts.map +1 -1
  141. package/dist/simple-tree/index.js +3 -1
  142. package/dist/simple-tree/index.js.map +1 -1
  143. package/dist/simple-tree/node-kinds/index.d.ts +2 -1
  144. package/dist/simple-tree/node-kinds/index.d.ts.map +1 -1
  145. package/dist/simple-tree/node-kinds/index.js +5 -1
  146. package/dist/simple-tree/node-kinds/index.js.map +1 -1
  147. package/dist/simple-tree/node-kinds/object/index.d.ts +1 -1
  148. package/dist/simple-tree/node-kinds/object/index.d.ts.map +1 -1
  149. package/dist/simple-tree/node-kinds/object/index.js.map +1 -1
  150. package/dist/simple-tree/node-kinds/object/objectNode.d.ts.map +1 -1
  151. package/dist/simple-tree/node-kinds/object/objectNode.js.map +1 -1
  152. package/dist/simple-tree/node-kinds/object/objectNodeTypes.d.ts +5 -1
  153. package/dist/simple-tree/node-kinds/object/objectNodeTypes.d.ts.map +1 -1
  154. package/dist/simple-tree/node-kinds/object/objectNodeTypes.js.map +1 -1
  155. package/dist/simple-tree/node-kinds/record/index.d.ts +7 -0
  156. package/dist/simple-tree/node-kinds/record/index.d.ts.map +1 -0
  157. package/dist/simple-tree/node-kinds/record/index.js +13 -0
  158. package/dist/simple-tree/node-kinds/record/index.js.map +1 -0
  159. package/dist/simple-tree/node-kinds/record/recordNode.d.ts +39 -0
  160. package/dist/simple-tree/node-kinds/record/recordNode.d.ts.map +1 -0
  161. package/dist/simple-tree/node-kinds/record/recordNode.js +234 -0
  162. package/dist/simple-tree/node-kinds/record/recordNode.js.map +1 -0
  163. package/dist/simple-tree/node-kinds/record/recordNodeTypes.d.ts +70 -0
  164. package/dist/simple-tree/node-kinds/record/recordNodeTypes.d.ts.map +1 -0
  165. package/dist/simple-tree/node-kinds/record/recordNodeTypes.js +30 -0
  166. package/dist/simple-tree/node-kinds/record/recordNodeTypes.js.map +1 -0
  167. package/dist/simple-tree/simpleSchema.d.ts +16 -1
  168. package/dist/simple-tree/simpleSchema.d.ts.map +1 -1
  169. package/dist/simple-tree/simpleSchema.js.map +1 -1
  170. package/dist/simple-tree/toStoredSchema.d.ts.map +1 -1
  171. package/dist/simple-tree/toStoredSchema.js +4 -2
  172. package/dist/simple-tree/toStoredSchema.js.map +1 -1
  173. package/dist/simple-tree/unhydratedFlexTreeFromInsertable.d.ts +1 -1
  174. package/dist/simple-tree/unhydratedFlexTreeFromInsertable.d.ts.map +1 -1
  175. package/dist/simple-tree/unhydratedFlexTreeFromInsertable.js +56 -32
  176. package/dist/simple-tree/unhydratedFlexTreeFromInsertable.js.map +1 -1
  177. package/dist/tableSchema.d.ts +7 -2
  178. package/dist/tableSchema.d.ts.map +1 -1
  179. package/dist/tableSchema.js +21 -7
  180. package/dist/tableSchema.js.map +1 -1
  181. package/dist/util/brandedMap.d.ts +0 -2
  182. package/dist/util/brandedMap.d.ts.map +1 -1
  183. package/dist/util/brandedMap.js.map +1 -1
  184. package/docs/main/compatibility.md +15 -1
  185. package/lib/alpha.d.ts +9 -0
  186. package/lib/core/forest/editableForest.d.ts +0 -2
  187. package/lib/core/forest/editableForest.d.ts.map +1 -1
  188. package/lib/core/forest/editableForest.js.map +1 -1
  189. package/lib/core/forest/forest.d.ts +0 -4
  190. package/lib/core/forest/forest.d.ts.map +1 -1
  191. package/lib/core/forest/forest.js +0 -4
  192. package/lib/core/forest/forest.js.map +1 -1
  193. package/lib/core/rebase/changeRebaser.d.ts +0 -6
  194. package/lib/core/rebase/changeRebaser.d.ts.map +1 -1
  195. package/lib/core/rebase/changeRebaser.js.map +1 -1
  196. package/lib/core/rebase/types.d.ts +0 -2
  197. package/lib/core/rebase/types.d.ts.map +1 -1
  198. package/lib/core/rebase/types.js.map +1 -1
  199. package/lib/core/schema-stored/schema.d.ts +0 -8
  200. package/lib/core/schema-stored/schema.d.ts.map +1 -1
  201. package/lib/core/schema-stored/schema.js +0 -8
  202. package/lib/core/schema-stored/schema.js.map +1 -1
  203. package/lib/core/schema-view/view.d.ts +0 -2
  204. package/lib/core/schema-view/view.d.ts.map +1 -1
  205. package/lib/core/schema-view/view.js.map +1 -1
  206. package/lib/core/tree/cursor.d.ts +0 -2
  207. package/lib/core/tree/cursor.d.ts.map +1 -1
  208. package/lib/core/tree/cursor.js +0 -2
  209. package/lib/core/tree/cursor.js.map +1 -1
  210. package/lib/core/tree/delta.d.ts +0 -2
  211. package/lib/core/tree/delta.d.ts.map +1 -1
  212. package/lib/core/tree/delta.js.map +1 -1
  213. package/lib/core/tree/types.d.ts +0 -4
  214. package/lib/core/tree/types.d.ts.map +1 -1
  215. package/lib/core/tree/types.js +0 -2
  216. package/lib/core/tree/types.js.map +1 -1
  217. package/lib/feature-libraries/default-schema/defaultEditBuilder.d.ts +0 -4
  218. package/lib/feature-libraries/default-schema/defaultEditBuilder.d.ts.map +1 -1
  219. package/lib/feature-libraries/default-schema/defaultEditBuilder.js.map +1 -1
  220. package/lib/feature-libraries/default-schema/defaultFieldKinds.d.ts +0 -10
  221. package/lib/feature-libraries/default-schema/defaultFieldKinds.d.ts.map +1 -1
  222. package/lib/feature-libraries/default-schema/defaultFieldKinds.js.map +1 -1
  223. package/lib/feature-libraries/flex-tree/flexTreeTypes.d.ts +0 -2
  224. package/lib/feature-libraries/flex-tree/flexTreeTypes.d.ts.map +1 -1
  225. package/lib/feature-libraries/flex-tree/flexTreeTypes.js +0 -2
  226. package/lib/feature-libraries/flex-tree/flexTreeTypes.js.map +1 -1
  227. package/lib/feature-libraries/modular-schema/crossFieldQueries.d.ts +0 -2
  228. package/lib/feature-libraries/modular-schema/crossFieldQueries.d.ts.map +1 -1
  229. package/lib/feature-libraries/modular-schema/crossFieldQueries.js +0 -2
  230. package/lib/feature-libraries/modular-schema/crossFieldQueries.js.map +1 -1
  231. package/lib/feature-libraries/modular-schema/fieldChangeHandler.d.ts +0 -10
  232. package/lib/feature-libraries/modular-schema/fieldChangeHandler.d.ts.map +1 -1
  233. package/lib/feature-libraries/modular-schema/fieldChangeHandler.js +0 -2
  234. package/lib/feature-libraries/modular-schema/fieldChangeHandler.js.map +1 -1
  235. package/lib/feature-libraries/modular-schema/modularChangeFamily.d.ts +0 -6
  236. package/lib/feature-libraries/modular-schema/modularChangeFamily.d.ts.map +1 -1
  237. package/lib/feature-libraries/modular-schema/modularChangeFamily.js.map +1 -1
  238. package/lib/feature-libraries/modular-schema/modularChangeTypes.d.ts +0 -12
  239. package/lib/feature-libraries/modular-schema/modularChangeTypes.d.ts.map +1 -1
  240. package/lib/feature-libraries/modular-schema/modularChangeTypes.js.map +1 -1
  241. package/lib/feature-libraries/sequence-field/types.d.ts +0 -2
  242. package/lib/feature-libraries/sequence-field/types.d.ts.map +1 -1
  243. package/lib/feature-libraries/sequence-field/types.js.map +1 -1
  244. package/lib/index.d.ts +1 -1
  245. package/lib/index.d.ts.map +1 -1
  246. package/lib/index.js +1 -1
  247. package/lib/index.js.map +1 -1
  248. package/lib/jsonDomainSchema.d.ts +2 -6
  249. package/lib/jsonDomainSchema.d.ts.map +1 -1
  250. package/lib/jsonDomainSchema.js +3 -3
  251. package/lib/jsonDomainSchema.js.map +1 -1
  252. package/lib/packageVersion.d.ts +1 -1
  253. package/lib/packageVersion.js +1 -1
  254. package/lib/packageVersion.js.map +1 -1
  255. package/lib/shared-tree/treeAlpha.d.ts.map +1 -1
  256. package/lib/shared-tree/treeAlpha.js +3 -1
  257. package/lib/shared-tree/treeAlpha.js.map +1 -1
  258. package/lib/shared-tree-core/defaultResubmitMachine.d.ts +8 -12
  259. package/lib/shared-tree-core/defaultResubmitMachine.d.ts.map +1 -1
  260. package/lib/shared-tree-core/defaultResubmitMachine.js +55 -47
  261. package/lib/shared-tree-core/defaultResubmitMachine.js.map +1 -1
  262. package/lib/shared-tree-core/resubmitMachine.d.ts +6 -0
  263. package/lib/shared-tree-core/resubmitMachine.d.ts.map +1 -1
  264. package/lib/shared-tree-core/resubmitMachine.js.map +1 -1
  265. package/lib/shared-tree-core/sharedTreeCore.d.ts +1 -0
  266. package/lib/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
  267. package/lib/shared-tree-core/sharedTreeCore.js +16 -3
  268. package/lib/shared-tree-core/sharedTreeCore.js.map +1 -1
  269. package/lib/simple-tree/api/configuration.d.ts.map +1 -1
  270. package/lib/simple-tree/api/configuration.js +51 -19
  271. package/lib/simple-tree/api/configuration.js.map +1 -1
  272. package/lib/simple-tree/api/customTree.d.ts +1 -1
  273. package/lib/simple-tree/api/customTree.d.ts.map +1 -1
  274. package/lib/simple-tree/api/customTree.js +2 -3
  275. package/lib/simple-tree/api/customTree.js.map +1 -1
  276. package/lib/simple-tree/api/index.d.ts +2 -2
  277. package/lib/simple-tree/api/index.d.ts.map +1 -1
  278. package/lib/simple-tree/api/index.js.map +1 -1
  279. package/lib/simple-tree/api/jsonSchema.d.ts +32 -8
  280. package/lib/simple-tree/api/jsonSchema.d.ts.map +1 -1
  281. package/lib/simple-tree/api/jsonSchema.js.map +1 -1
  282. package/lib/simple-tree/api/schemaFactory.d.ts +2 -2
  283. package/lib/simple-tree/api/schemaFactory.d.ts.map +1 -1
  284. package/lib/simple-tree/api/schemaFactory.js +1 -1
  285. package/lib/simple-tree/api/schemaFactory.js.map +1 -1
  286. package/lib/simple-tree/api/schemaFactoryAlpha.d.ts +97 -3
  287. package/lib/simple-tree/api/schemaFactoryAlpha.d.ts.map +1 -1
  288. package/lib/simple-tree/api/schemaFactoryAlpha.js +77 -2
  289. package/lib/simple-tree/api/schemaFactoryAlpha.js.map +1 -1
  290. package/lib/simple-tree/api/schemaFactoryRecursive.d.ts +5 -1
  291. package/lib/simple-tree/api/schemaFactoryRecursive.d.ts.map +1 -1
  292. package/lib/simple-tree/api/schemaFactoryRecursive.js.map +1 -1
  293. package/lib/simple-tree/api/schemaFromSimple.js +2 -0
  294. package/lib/simple-tree/api/schemaFromSimple.js.map +1 -1
  295. package/lib/simple-tree/api/simpleSchemaToJsonSchema.d.ts.map +1 -1
  296. package/lib/simple-tree/api/simpleSchemaToJsonSchema.js +5 -5
  297. package/lib/simple-tree/api/simpleSchemaToJsonSchema.js.map +1 -1
  298. package/lib/simple-tree/api/treeBeta.d.ts +1 -1
  299. package/lib/simple-tree/api/treeBeta.d.ts.map +1 -1
  300. package/lib/simple-tree/api/treeBeta.js.map +1 -1
  301. package/lib/simple-tree/api/treeNodeApi.js +2 -2
  302. package/lib/simple-tree/api/treeNodeApi.js.map +1 -1
  303. package/lib/simple-tree/api/typesUnsafe.d.ts +12 -0
  304. package/lib/simple-tree/api/typesUnsafe.d.ts.map +1 -1
  305. package/lib/simple-tree/api/typesUnsafe.js.map +1 -1
  306. package/lib/simple-tree/api/viewSchemaToSimpleSchema.d.ts.map +1 -1
  307. package/lib/simple-tree/api/viewSchemaToSimpleSchema.js +6 -4
  308. package/lib/simple-tree/api/viewSchemaToSimpleSchema.js.map +1 -1
  309. package/lib/simple-tree/core/index.d.ts +1 -1
  310. package/lib/simple-tree/core/index.d.ts.map +1 -1
  311. package/lib/simple-tree/core/index.js +1 -1
  312. package/lib/simple-tree/core/index.js.map +1 -1
  313. package/lib/simple-tree/core/treeNodeSchema.d.ts +5 -1
  314. package/lib/simple-tree/core/treeNodeSchema.d.ts.map +1 -1
  315. package/lib/simple-tree/core/treeNodeSchema.js +4 -0
  316. package/lib/simple-tree/core/treeNodeSchema.js.map +1 -1
  317. package/lib/simple-tree/index.d.ts +3 -3
  318. package/lib/simple-tree/index.d.ts.map +1 -1
  319. package/lib/simple-tree/index.js +1 -1
  320. package/lib/simple-tree/index.js.map +1 -1
  321. package/lib/simple-tree/node-kinds/index.d.ts +2 -1
  322. package/lib/simple-tree/node-kinds/index.d.ts.map +1 -1
  323. package/lib/simple-tree/node-kinds/index.js +1 -0
  324. package/lib/simple-tree/node-kinds/index.js.map +1 -1
  325. package/lib/simple-tree/node-kinds/object/index.d.ts +1 -1
  326. package/lib/simple-tree/node-kinds/object/index.d.ts.map +1 -1
  327. package/lib/simple-tree/node-kinds/object/index.js +1 -1
  328. package/lib/simple-tree/node-kinds/object/index.js.map +1 -1
  329. package/lib/simple-tree/node-kinds/object/objectNode.d.ts.map +1 -1
  330. package/lib/simple-tree/node-kinds/object/objectNode.js.map +1 -1
  331. package/lib/simple-tree/node-kinds/object/objectNodeTypes.d.ts +5 -1
  332. package/lib/simple-tree/node-kinds/object/objectNodeTypes.d.ts.map +1 -1
  333. package/lib/simple-tree/node-kinds/object/objectNodeTypes.js.map +1 -1
  334. package/lib/simple-tree/node-kinds/record/index.d.ts +7 -0
  335. package/lib/simple-tree/node-kinds/record/index.d.ts.map +1 -0
  336. package/lib/simple-tree/node-kinds/record/index.js +7 -0
  337. package/lib/simple-tree/node-kinds/record/index.js.map +1 -0
  338. package/lib/simple-tree/node-kinds/record/recordNode.d.ts +39 -0
  339. package/lib/simple-tree/node-kinds/record/recordNode.d.ts.map +1 -0
  340. package/lib/simple-tree/node-kinds/record/recordNode.js +232 -0
  341. package/lib/simple-tree/node-kinds/record/recordNode.js.map +1 -0
  342. package/lib/simple-tree/node-kinds/record/recordNodeTypes.d.ts +70 -0
  343. package/lib/simple-tree/node-kinds/record/recordNodeTypes.d.ts.map +1 -0
  344. package/lib/simple-tree/node-kinds/record/recordNodeTypes.js +26 -0
  345. package/lib/simple-tree/node-kinds/record/recordNodeTypes.js.map +1 -0
  346. package/lib/simple-tree/simpleSchema.d.ts +16 -1
  347. package/lib/simple-tree/simpleSchema.d.ts.map +1 -1
  348. package/lib/simple-tree/simpleSchema.js.map +1 -1
  349. package/lib/simple-tree/toStoredSchema.d.ts.map +1 -1
  350. package/lib/simple-tree/toStoredSchema.js +4 -2
  351. package/lib/simple-tree/toStoredSchema.js.map +1 -1
  352. package/lib/simple-tree/unhydratedFlexTreeFromInsertable.d.ts +1 -1
  353. package/lib/simple-tree/unhydratedFlexTreeFromInsertable.d.ts.map +1 -1
  354. package/lib/simple-tree/unhydratedFlexTreeFromInsertable.js +58 -34
  355. package/lib/simple-tree/unhydratedFlexTreeFromInsertable.js.map +1 -1
  356. package/lib/tableSchema.d.ts +7 -2
  357. package/lib/tableSchema.d.ts.map +1 -1
  358. package/lib/tableSchema.js +22 -8
  359. package/lib/tableSchema.js.map +1 -1
  360. package/lib/util/brandedMap.d.ts +0 -2
  361. package/lib/util/brandedMap.d.ts.map +1 -1
  362. package/lib/util/brandedMap.js.map +1 -1
  363. package/package.json +34 -22
  364. package/src/core/forest/editableForest.ts +0 -2
  365. package/src/core/forest/forest.ts +0 -4
  366. package/src/core/rebase/changeRebaser.ts +0 -6
  367. package/src/core/rebase/types.ts +0 -2
  368. package/src/core/schema-stored/schema.ts +0 -8
  369. package/src/core/schema-view/view.ts +0 -2
  370. package/src/core/tree/cursor.ts +0 -2
  371. package/src/core/tree/delta.ts +0 -2
  372. package/src/core/tree/types.ts +0 -4
  373. package/src/feature-libraries/default-schema/defaultEditBuilder.ts +0 -4
  374. package/src/feature-libraries/default-schema/defaultFieldKinds.ts +0 -10
  375. package/src/feature-libraries/flex-tree/flexTreeTypes.ts +0 -2
  376. package/src/feature-libraries/modular-schema/crossFieldQueries.ts +0 -2
  377. package/src/feature-libraries/modular-schema/fieldChangeHandler.ts +0 -10
  378. package/src/feature-libraries/modular-schema/modularChangeFamily.ts +0 -8
  379. package/src/feature-libraries/modular-schema/modularChangeTypes.ts +0 -12
  380. package/src/feature-libraries/sequence-field/types.ts +0 -2
  381. package/src/index.ts +9 -0
  382. package/src/jsonDomainSchema.ts +3 -3
  383. package/src/packageVersion.ts +1 -1
  384. package/src/shared-tree/treeAlpha.ts +3 -1
  385. package/src/shared-tree-core/defaultResubmitMachine.ts +99 -52
  386. package/src/shared-tree-core/resubmitMachine.ts +7 -0
  387. package/src/shared-tree-core/sharedTreeCore.ts +18 -6
  388. package/src/simple-tree/api/configuration.ts +73 -19
  389. package/src/simple-tree/api/customTree.ts +3 -3
  390. package/src/simple-tree/api/index.ts +3 -0
  391. package/src/simple-tree/api/jsonSchema.ts +35 -8
  392. package/src/simple-tree/api/schemaFactory.ts +5 -13
  393. package/src/simple-tree/api/schemaFactoryAlpha.ts +268 -1
  394. package/src/simple-tree/api/schemaFactoryRecursive.ts +5 -1
  395. package/src/simple-tree/api/schemaFromSimple.ts +6 -0
  396. package/src/simple-tree/api/simpleSchemaToJsonSchema.ts +16 -7
  397. package/src/simple-tree/api/treeBeta.ts +2 -2
  398. package/src/simple-tree/api/treeNodeApi.ts +2 -2
  399. package/src/simple-tree/api/typesUnsafe.ts +15 -0
  400. package/src/simple-tree/api/viewSchemaToSimpleSchema.ts +14 -6
  401. package/src/simple-tree/core/index.ts +1 -0
  402. package/src/simple-tree/core/treeNodeSchema.ts +8 -4
  403. package/src/simple-tree/index.ts +11 -0
  404. package/src/simple-tree/node-kinds/index.ts +11 -0
  405. package/src/simple-tree/node-kinds/object/index.ts +5 -1
  406. package/src/simple-tree/node-kinds/object/objectNode.ts +3 -2
  407. package/src/simple-tree/node-kinds/object/objectNodeTypes.ts +6 -3
  408. package/src/simple-tree/node-kinds/record/index.ts +14 -0
  409. package/src/simple-tree/node-kinds/record/recordNode.ts +410 -0
  410. package/src/simple-tree/node-kinds/record/recordNodeTypes.ts +136 -0
  411. package/src/simple-tree/simpleSchema.ts +19 -1
  412. package/src/simple-tree/toStoredSchema.ts +4 -2
  413. package/src/simple-tree/unhydratedFlexTreeFromInsertable.ts +83 -40
  414. package/src/tableSchema.ts +27 -8
  415. package/src/util/brandedMap.ts +0 -2
@@ -1 +1 @@
1
- {"version":3,"file":"treeAlpha.js","sourceRoot":"","sources":["../../src/shared-tree/treeAlpha.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,MAAM,EACN,WAAW,EACX,IAAI,EACJ,eAAe,GACf,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EAAE,kBAAkB,EAAE,MAAM,wCAAwC,CAAC;AAC5E,OAAO,EAAE,UAAU,EAAE,MAAM,0CAA0C,CAAC;AAItE,OAAO,EACN,OAAO,EACP,SAAS,EAGT,QAAQ,EACR,YAAY,EACZ,gBAAgB,EAChB,SAAS,EACT,oBAAoB,EAMpB,iBAAiB,EAEjB,0BAA0B,EAC1B,iBAAiB,EACjB,iBAAiB,EAGjB,cAAc,EACd,sBAAsB,EAEtB,0BAA0B,EAC1B,YAAY,EACZ,2BAA2B,EAC3B,WAAW,EACX,qBAAqB,EACrB,gCAAgC,EAChC,4BAA4B,EAC5B,mCAAmC,EACnC,oBAAoB,EACpB,QAAQ,EACR,sBAAsB,EACtB,kBAAkB,GAClB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,KAAK,EAAE,iBAAiB,EAAuB,MAAM,kBAAkB,CAAC;AACjF,OAAO,EACN,kBAAkB,EAClB,aAAa,GAGb,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,QAAQ,EAA+B,MAAM,kBAAkB,CAAC;AACzE,OAAO,EACN,qBAAqB,EACrB,mBAAmB,EACnB,WAAW,EACX,mBAAmB,EACnB,iBAAiB,EACjB,uBAAuB,EAGvB,yCAAyC,GAGzC,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,0BAA0B,EAAoB,MAAM,sBAAsB,CAAC;AACpF,OAAO,EAAE,0BAA0B,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAE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,CAAC,CAAC;IAClC,CAAC;IACD,MAAM,MAAM,GAAG,+BAA+B,CAAC,IAAI,CAAC,CAAC;IACrD,sDAAsD;IACtD,MAAM,OAAO,GAAG,iBAAiB,CAAC,MAAM,CAAC,CAAC;IAC1C,OAAO,qBAAqB,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC;AACzC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\tassert,\n\tdebugAssert,\n\tfail,\n\tunreachableCase,\n} from \"@fluidframework/core-utils/internal\";\nimport { createIdCompressor } from \"@fluidframework/id-compressor/internal\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\nimport type { IFluidHandle } from \"@fluidframework/core-interfaces\";\nimport type { IIdCompressor } from \"@fluidframework/id-compressor\";\n\nimport {\n\tasIndex,\n\tgetKernel,\n\ttype TreeNode,\n\ttype Unhydrated,\n\tTreeBeta,\n\ttryGetSchema,\n\tcreateFromCursor,\n\tFieldKind,\n\tnormalizeFieldSchema,\n\ttype ImplicitFieldSchema,\n\ttype InsertableField,\n\ttype TreeFieldFromImplicitField,\n\ttype TreeLeafValue,\n\ttype UnsafeUnknownSchema,\n\tconciseFromCursor,\n\ttype ConciseTree,\n\tapplySchemaToParserOptions,\n\tcursorFromVerbose,\n\tverboseFromCursor,\n\ttype TreeEncodingOptions,\n\ttype VerboseTree,\n\ttoStoredSchema,\n\textractPersistedSchema,\n\ttype TreeBranch,\n\tTreeViewConfigurationAlpha,\n\tgetStoredKey,\n\tgetPropertyKeyFromStoredKey,\n\ttreeNodeApi,\n\tgetIdentifierFromNode,\n\tunhydratedFlexTreeFromInsertable,\n\tgetOrCreateNodeFromInnerNode,\n\tgetOrCreateNodeFromInnerUnboxedNode,\n\tgetOrCreateInnerNode,\n\tNodeKind,\n\ttryGetTreeNodeForField,\n\tisObjectNodeSchema,\n} from \"../simple-tree/index.js\";\nimport { brand, extractFromOpaque, type JsonCompatible } from \"../util/index.js\";\nimport {\n\tFluidClientVersion,\n\tnoopValidator,\n\ttype ICodecOptions,\n\ttype CodecWriteOptions,\n} from \"../codec/index.js\";\nimport { EmptyKey, type ITreeCursorSynchronous } from \"../core/index.js\";\nimport {\n\tcursorForMapTreeField,\n\tdefaultSchemaPolicy,\n\tisTreeValue,\n\tmakeFieldBatchCodec,\n\tmapTreeFromCursor,\n\tTreeCompressionStrategy,\n\ttype FieldBatch,\n\ttype FieldBatchEncodingContext,\n\tfluidVersionToFieldBatchCodecWriteVersion,\n\ttype LocalNodeIdentifier,\n\ttype FlexTreeSequenceField,\n} from \"../feature-libraries/index.js\";\nimport { independentInitializedView, type ViewContent } from \"./independentView.js\";\nimport { SchematizingSimpleTreeView, ViewSlot } from \"./schematizingTreeView.js\";\n\nconst identifier: TreeIdentifierUtils = (node: TreeNode): string | undefined => {\n\tconst nodeIdentifier = getIdentifierFromNode(node, \"uncompressed\");\n\tif (typeof nodeIdentifier === \"number\") {\n\t\tthrow new TypeError(\"identifier should be uncompressed.\");\n\t}\n\treturn nodeIdentifier;\n};\n\nidentifier.shorten = (branch: TreeBranch, nodeIdentifier: string): number | undefined => {\n\tconst nodeKeyManager = (branch as SchematizingSimpleTreeView<ImplicitFieldSchema>)\n\t\t.nodeKeyManager;\n\tconst localNodeKey = nodeKeyManager.tryLocalizeNodeIdentifier(nodeIdentifier);\n\treturn localNodeKey !== undefined ? extractFromOpaque(localNodeKey) : undefined;\n};\n\nidentifier.lengthen = (branch: TreeBranch, nodeIdentifier: number): string => {\n\tconst nodeKeyManager = (branch as SchematizingSimpleTreeView<ImplicitFieldSchema>)\n\t\t.nodeKeyManager;\n\treturn nodeKeyManager.stabilizeNodeIdentifier(\n\t\tnodeIdentifier as unknown as LocalNodeIdentifier,\n\t);\n};\n\nidentifier.getShort = (node: TreeNode): number | undefined => {\n\tconst shortIdentifier = getIdentifierFromNode(node, \"compressed\");\n\treturn typeof shortIdentifier === \"number\" ? shortIdentifier : undefined;\n};\n\nidentifier.create = (branch: TreeBranch): string => {\n\tconst nodeKeyManager = (branch as SchematizingSimpleTreeView<ImplicitFieldSchema>)\n\t\t.nodeKeyManager;\n\treturn nodeKeyManager.stabilizeNodeIdentifier(nodeKeyManager.generateLocalNodeIdentifier());\n};\n\nObject.freeze(identifier);\n\n/**\n * A utility interface for retrieving or converting node identifiers.\n *\n * @remarks\n * This provides methods to:\n *\n * - Retrieve long or short identifiers from nodes\n *\n * - Convert between long identifiers and short identifiers\n *\n * - Generates long identifiers\n *\n * @alpha @sealed\n */\nexport interface TreeIdentifierUtils {\n\t/**\n\t * Returns the contents of a node's {@link SchemaFactory.identifier} field as a stable identifier.\n\t * If the identifier field does not exist, returns undefined.\n\t *\n\t * @param node - The TreeNode you want to get the identifier from,\n\t */\n\t(node: TreeNode): string | undefined;\n\n\t/**\n\t * Returns the shortened identifier as a number given long identifier known by the id compressor on the branch if possible.\n\t * Otherwise, it will return the original string identifier provided.\n\t * If the id does not exist, or is unknown by the id compressor, it returns undefined.\n\t *\n\t * This method is the inverse of {@link TreeIdentifierUtils.lengthen}. If you shorten an identifier\n\t * and then immediately pass it to {@link TreeIdentifierUtils.lengthen}, you will get the original string back.\n\t *\n\t * @param branch - TreeBranch from where you get the idCompressor to do the decompression.\n\t * @param nodeIdentifier - the stable identifier that needs to be shortened.\n\t */\n\tshorten(branch: TreeBranch, nodeIdentifier: string): number | undefined;\n\n\t/**\n\t * Returns the stable id as a string if the identifier is decompressible and known by the id compressor. Otherwise, it will throw an error.\n\t *\n\t * This method is the inverse of {@link TreeIdentifierUtils.shorten}. If you lengthen an identifier\n\t * and then immediately pass it to {@link TreeIdentifierUtils.shorten}, you will get the original short identifier back.\n\t *\n\t * @param branch - TreeBranch from where you want to get the id compressor to do the decompression.\n\t * @param nodeIdentifier - The local identifier that needs to be expanded.\n\t */\n\tlengthen(branch: TreeBranch, nodeIdentifier: number): string;\n\n\t/**\n\t * Returns the {@link SchemaFactory.identifier | identifier} of the given node in the most compressed form possible.\n\t * @remarks\n\t * 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.\n\t * 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.\n\t * Note that automatically generated identifiers that were accessed before the node was hydrated will return the generated UUID, not the process-unique integer.\n\t *\n\t * If the node's identifier is any other user-provided string, then this will return undefined.\n\t *\n\t * If the node has no identifier (that is, it has no {@link SchemaFactory.identifier | identifier} field), then this returns `undefined`.\n\t *\n\t * If the node has more than one identifier, then this will throw an error.\n\t *\n\t * The returned integer should not be serialized or preserved outside of the current process.\n\t * 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.\n\t * 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.\n\t */\n\tgetShort(node: TreeNode): number | undefined;\n\n\t/**\n\t * Creates and returns a long identifier.\n\t * The long identifier is a compressible, stable identifier generated by the tree's ID compressor.\n\t *\n\t * @param branch - TreeBranch from where you want to get the id compressor to generate the identifier from.\n\t */\n\tcreate(branch: TreeBranch): string;\n}\n\n/**\n * Extensions to {@link (Tree:interface)} and {@link (TreeBeta:interface)} which are not yet stable.\n * @remarks\n * Use via the {@link (TreeAlpha:variable)} singleton.\n * @system @sealed @alpha\n */\nexport interface TreeAlpha {\n\t/**\n\t * Retrieve the {@link TreeBranch | branch}, if any, for the given node.\n\t * @param node - The node to query\n\t * @remarks If the node has already been inserted into the tree, this will return the branch associated with that node's {@link TreeView | view}.\n\t * Otherwise, it will return `undefined` (because the node has not yet been inserted and is therefore not part of a branch or view).\n\t *\n\t * This does not fork a new branch, but rather retrieves the _existing_ branch for the node.\n\t * To create a new branch, use e.g. {@link TreeBranch.fork | `myBranch.fork()`}.\n\t */\n\tbranch(node: TreeNode): TreeBranch | undefined;\n\n\t/**\n\t * Construct tree content that is compatible with the field defined by the provided `schema`.\n\t * @param schema - The schema for what to construct. As this is an {@link ImplicitFieldSchema}, a {@link FieldSchema}, {@link TreeNodeSchema} or {@link AllowedTypes} array can be provided.\n\t * @param data - The data used to construct the field content.\n\t * @remarks\n\t * When providing a {@link TreeNodeSchemaClass}, this is the same as invoking its constructor except that an unhydrated node can also be provided.\n\t * This function exists as a generalization that can be used in other cases as well,\n\t * such as when `undefined` might be allowed (for an optional field), or when the type should be inferred from the data when more than one type is possible.\n\t * @privateRemarks\n\t * There should be a way to provide a source for defaulted identifiers, either via this API or some way to add them to its output later.\n\t */\n\tcreate<const TSchema extends ImplicitFieldSchema | UnsafeUnknownSchema>(\n\t\tschema: UnsafeUnknownSchema extends TSchema\n\t\t\t? ImplicitFieldSchema\n\t\t\t: TSchema & ImplicitFieldSchema,\n\t\tdata: InsertableField<TSchema>,\n\t): Unhydrated<\n\t\tTSchema extends ImplicitFieldSchema\n\t\t\t? TreeFieldFromImplicitField<TSchema>\n\t\t\t: TreeNode | TreeLeafValue | undefined\n\t>;\n\n\t/**\n\t * Less type safe version of {@link (TreeAlpha:interface).create}, suitable for importing data.\n\t * @remarks\n\t * Due to {@link ConciseTree} relying on type inference from the data, its use is somewhat limited.\n\t * This does not support {@link ConciseTree|ConciseTrees} with customized handle encodings or using persisted keys.\n\t * Use \"compressed\" or \"verbose\" formats for more flexibility.\n\t *\n\t * When using this function,\n\t * it is recommend to ensure your schema is unambiguous with {@link ITreeConfigurationOptions.preventAmbiguity}.\n\t * If the schema is ambiguous, consider using {@link (TreeAlpha:interface).create} and {@link Unhydrated} nodes where needed,\n\t * or using {@link (TreeAlpha:interface).(importVerbose:1)} and specify all types.\n\t *\n\t * Documented (and thus recoverable) error handling/reporting for this is not yet implemented,\n\t * but for now most invalid inputs will throw a recoverable error.\n\t */\n\timportConcise<const TSchema extends ImplicitFieldSchema | UnsafeUnknownSchema>(\n\t\tschema: UnsafeUnknownSchema extends TSchema\n\t\t\t? ImplicitFieldSchema\n\t\t\t: TSchema & ImplicitFieldSchema,\n\t\tdata: ConciseTree | undefined,\n\t): Unhydrated<\n\t\tTSchema extends ImplicitFieldSchema\n\t\t\t? TreeFieldFromImplicitField<TSchema>\n\t\t\t: TreeNode | TreeLeafValue | undefined\n\t>;\n\n\t/**\n\t * Construct tree content compatible with a field defined by the provided `schema`.\n\t * @param schema - The schema for what to construct. As this is an {@link ImplicitFieldSchema}, a {@link FieldSchema}, {@link TreeNodeSchema} or {@link AllowedTypes} array can be provided.\n\t * @param data - The data used to construct the field content. See {@link (TreeAlpha:interface).(exportVerbose:1)}.\n\t */\n\timportVerbose<const TSchema extends ImplicitFieldSchema>(\n\t\tschema: TSchema,\n\t\tdata: VerboseTree | undefined,\n\t\toptions?: Partial<TreeEncodingOptions>,\n\t): Unhydrated<TreeFieldFromImplicitField<TSchema>>;\n\n\t/**\n\t * Copy a snapshot of the current version of a TreeNode into a {@link ConciseTree}.\n\t */\n\texportConcise(node: TreeNode | TreeLeafValue, options?: TreeEncodingOptions): ConciseTree;\n\n\t/**\n\t * Copy a snapshot of the current version of a TreeNode into a {@link ConciseTree}, allowing undefined.\n\t */\n\texportConcise(\n\t\tnode: TreeNode | TreeLeafValue | undefined,\n\t\toptions?: TreeEncodingOptions,\n\t): ConciseTree | undefined;\n\n\t/**\n\t * Copy a snapshot of the current version of a TreeNode into a JSON compatible plain old JavaScript Object (except for {@link @fluidframework/core-interfaces#IFluidHandle|IFluidHandles}).\n\t * Uses the {@link VerboseTree} format, with an explicit type on every node.\n\t *\n\t * @remarks\n\t * There are several cases this may be preferred to {@link (TreeAlpha:interface).(exportConcise:1)}:\n\t *\n\t * 1. When not using {@link ITreeConfigurationOptions.preventAmbiguity} (or when using `useStableFieldKeys`), `exportConcise` can produce ambiguous data (the type may be unclear on some nodes).\n\t * `exportVerbose` will always be unambiguous and thus lossless.\n\t *\n\t * 2. When the data might be interpreted without access to the exact same view schema. In such cases, the types may be unknowable if not included.\n\t *\n\t * 3. When easy access to the type is desired.\n\t */\n\texportVerbose(node: TreeNode | TreeLeafValue, options?: TreeEncodingOptions): VerboseTree;\n\n\t/**\n\t * Export the content of the provided `tree` in a compressed JSON compatible format.\n\t * @remarks\n\t * If an `idCompressor` is provided, it will be used to compress identifiers and thus will be needed to decompress the data.\n\t *\n\t * Always uses \"stored\" keys.\n\t * See {@link TreeEncodingOptions.useStoredKeys} for details.\n\t * @privateRemarks\n\t * TODO: It is currently not clear how to work with the idCompressors correctly in the package API.\n\t * Better APIs should probably be provided as there is currently no way to associate an un-hydrated tree with an idCompressor,\n\t * Nor get the correct idCompressor from a subtree to use when exporting it.\n\t * Additionally using `createIdCompressor` to make an idCompressor is `@legacy` and thus not intended for use in this API surface.\n\t * It would probably make more sense if we provided a way to get an idCompressor from the context of a node,\n\t * which could be optional (and settable if missing) for un0hydrated nodes and required for hydrated ones.\n\t * Add in a stable public API for creating idCompressors, and a way to get them from a tree (without view schema), and that should address the anticipated use-cases.\n\t */\n\texportCompressed(\n\t\ttree: TreeNode | TreeLeafValue,\n\t\toptions: { idCompressor?: IIdCompressor } & Pick<\n\t\t\tCodecWriteOptions,\n\t\t\t\"oldestCompatibleClient\"\n\t\t>,\n\t): JsonCompatible<IFluidHandle>;\n\n\t/**\n\t * Import data encoded by {@link (TreeAlpha:interface).exportCompressed}.\n\t *\n\t * @param schema - Schema with which the data must be compatible. This compatibility is not verified and must be ensured by the caller.\n\t * @param compressedData - Data compressed by {@link (TreeAlpha:interface).exportCompressed}.\n\t * @param options - If {@link (TreeAlpha:interface).exportCompressed} was given an `idCompressor`, it must be provided here.\n\t *\n\t * @remarks\n\t * If the data could have been encoded with a different schema, consider encoding the schema along side it using {@link extractPersistedSchema} and loading the data using {@link independentView}.\n\t *\n\t * @privateRemarks\n\t * This API could be improved:\n\t *\n\t * 1. It could validate that the schema is compatible, and return or throw an error in the invalid case (maybe add a \"try\" version).\n\t *\n\t * 2. A \"try\" version of this could return an error if the data isn't in a supported format (as determined by version and/or JasonValidator).\n\t *\n\t * 3. Requiring the caller provide a JsonValidator isn't the most friendly API. It might be practical to provide a default.\n\t */\n\timportCompressed<const TSchema extends ImplicitFieldSchema>(\n\t\tschema: TSchema,\n\t\tcompressedData: JsonCompatible<IFluidHandle>,\n\t\toptions: { idCompressor?: IIdCompressor } & ICodecOptions,\n\t): Unhydrated<TreeFieldFromImplicitField<TSchema>>;\n\n\t/**\n\t * APIs for creating, converting, and retrieving identifiers.\n\t */\n\treadonly identifier: TreeIdentifierUtils;\n\n\t/**\n\t * The key of the given node under its parent.\n\t * @remarks\n\t * If `node` is an element in a {@link (TreeArrayNode:interface)}, this returns the index of `node` in the array node (a `number`).\n\t * If `node` is the root node, this returns undefined.\n\t * Otherwise, this returns the key of the field that it is under (a `string`).\n\t */\n\tkey2(node: TreeNode): string | number | undefined;\n\n\t/**\n\t * Gets the child of the given node with the given property key if a child exists under that key.\n\t *\n\t * @remarks {@link SchemaFactoryObjectOptions.allowUnknownOptionalFields | Unknown optional fields} of Object nodes will not be returned by this method.\n\t *\n\t * @param node - The parent node whose child is being requested.\n\t * @param key - The property key under the node under which the child is being requested.\n\t * For Object nodes, this is the developer-facing \"property key\", not the \"{@link SimpleObjectFieldSchema.storedKey | stored keys}\".\n\t *\n\t * @returns The child node or leaf value under the given key, or `undefined` if no such child exists.\n\t *\n\t * @see {@link (TreeAlpha:interface).key2}\n\t * @see {@link (TreeNodeApi:interface).parent}\n\t */\n\tchild(node: TreeNode, key: string | number): TreeNode | TreeLeafValue | undefined;\n\n\t/**\n\t * Gets the children of the provided node, paired with their property keys under the node.\n\t *\n\t * @remarks\n\t * No guarantees are made regarding the order of the children in the returned array.\n\t *\n\t * Optional properties of Object nodes with no value are not included in the result.\n\t *\n\t * {@link SchemaFactoryObjectOptions.allowUnknownOptionalFields | Unknown optional fields} of Object nodes are not included in the result.\n\t *\n\t * @param node - The node whose children are being requested.\n\t *\n\t * @returns\n\t * An array of pairs of the form `[propertyKey, child]`.\n\t *\n\t * For Array nodes, the `propertyKey` is the index of the child in the array.\n\t *\n\t * For Object nodes, the returned `propertyKey`s are the developer-facing \"property keys\", not the \"{@link SimpleObjectFieldSchema.storedKey | stored keys}\".\n\t *\n\t * @see {@link (TreeAlpha:interface).key2}\n\t * @see {@link (TreeNodeApi:interface).parent}\n\t */\n\tchildren(\n\t\tnode: TreeNode,\n\t): Iterable<[propertyKey: string | number, child: TreeNode | TreeLeafValue]>;\n}\n\n/**\n * Extensions to {@link (Tree:variable)} and {@link (TreeBeta:variable)} which are not yet stable.\n * @see {@link (TreeAlpha:interface)}.\n * @alpha\n */\nexport const TreeAlpha: TreeAlpha = {\n\tbranch(node: TreeNode): TreeBranch | undefined {\n\t\tconst kernel = getKernel(node);\n\t\tif (!kernel.isHydrated()) {\n\t\t\treturn undefined;\n\t\t}\n\t\tconst view = kernel.anchorNode.anchorSet.slots.get(ViewSlot);\n\t\tassert(\n\t\t\tview instanceof SchematizingSimpleTreeView,\n\t\t\t0xa5c /* Unexpected view implementation */,\n\t\t);\n\t\treturn view;\n\t},\n\n\tcreate<const TSchema extends ImplicitFieldSchema | UnsafeUnknownSchema>(\n\t\tschema: UnsafeUnknownSchema extends TSchema\n\t\t\t? ImplicitFieldSchema\n\t\t\t: TSchema & ImplicitFieldSchema,\n\t\tdata: InsertableField<TSchema>,\n\t): Unhydrated<\n\t\tTSchema extends ImplicitFieldSchema\n\t\t\t? TreeFieldFromImplicitField<TSchema>\n\t\t\t: TreeNode | TreeLeafValue | undefined\n\t> {\n\t\tconst mapTree = unhydratedFlexTreeFromInsertable(\n\t\t\tdata as InsertableField<UnsafeUnknownSchema>,\n\t\t\tschema,\n\t\t);\n\t\tconst result = mapTree === undefined ? undefined : getOrCreateNodeFromInnerNode(mapTree);\n\t\treturn result as Unhydrated<\n\t\t\tTSchema extends ImplicitFieldSchema\n\t\t\t\t? TreeFieldFromImplicitField<TSchema>\n\t\t\t\t: TreeNode | TreeLeafValue | undefined\n\t\t>;\n\t},\n\n\timportConcise<TSchema extends ImplicitFieldSchema | UnsafeUnknownSchema>(\n\t\tschema: UnsafeUnknownSchema extends TSchema\n\t\t\t? ImplicitFieldSchema\n\t\t\t: TSchema & ImplicitFieldSchema,\n\t\tdata: ConciseTree | undefined,\n\t): Unhydrated<\n\t\tTSchema extends ImplicitFieldSchema\n\t\t\t? TreeFieldFromImplicitField<TSchema>\n\t\t\t: TreeNode | TreeLeafValue | undefined\n\t> {\n\t\t// `importConcise` does not need to support all the formats that `create` does.\n\t\t// Perhaps it should error instead of hydrating nodes for example.\n\t\t// For now however, it is a simple wrapper around `create`.\n\t\treturn this.create(schema, data as InsertableField<TSchema>);\n\t},\n\n\timportVerbose<const TSchema extends ImplicitFieldSchema>(\n\t\tschema: TSchema,\n\t\tdata: VerboseTree | undefined,\n\t\toptions?: TreeEncodingOptions,\n\t): Unhydrated<TreeFieldFromImplicitField<TSchema>> {\n\t\tconst config: TreeEncodingOptions = { ...options };\n\t\t// Create a config which is standalone, and thus can be used without having to refer back to the schema.\n\t\tconst schemalessConfig = applySchemaToParserOptions(schema, config);\n\t\tif (data === undefined) {\n\t\t\tconst field = normalizeFieldSchema(schema);\n\t\t\tif (field.kind !== FieldKind.Optional) {\n\t\t\t\tthrow new UsageError(\"undefined provided for non-optional field.\");\n\t\t\t}\n\t\t\treturn undefined as Unhydrated<TreeFieldFromImplicitField<TSchema>>;\n\t\t}\n\t\tconst cursor = cursorFromVerbose(data, schemalessConfig);\n\t\treturn createFromCursor(schema, cursor);\n\t},\n\n\texportConcise,\n\n\texportVerbose(node: TreeNode | TreeLeafValue, options?: TreeEncodingOptions): VerboseTree {\n\t\tconst config: TreeEncodingOptions = { ...options };\n\n\t\tconst cursor = borrowCursorFromTreeNodeOrValue(node);\n\t\treturn verboseFromCursor(\n\t\t\tcursor,\n\t\t\ttryGetSchema(node) ?? fail(0xace /* invalid input */),\n\t\t\tconfig,\n\t\t);\n\t},\n\n\texportCompressed(\n\t\tnode: TreeNode | TreeLeafValue,\n\t\toptions: { idCompressor?: IIdCompressor } & Pick<\n\t\t\tCodecWriteOptions,\n\t\t\t\"oldestCompatibleClient\"\n\t\t>,\n\t): JsonCompatible<IFluidHandle> {\n\t\tconst schema = tryGetSchema(node) ?? fail(0xacf /* invalid input */);\n\t\tconst format = fluidVersionToFieldBatchCodecWriteVersion(options.oldestCompatibleClient);\n\t\tconst codec = makeFieldBatchCodec({ jsonValidator: noopValidator }, format);\n\t\tconst cursor = borrowFieldCursorFromTreeNodeOrValue(node);\n\t\tconst batch: FieldBatch = [cursor];\n\t\t// If none provided, create a compressor which will not compress anything.\n\t\tconst idCompressor = options.idCompressor ?? createIdCompressor();\n\t\tconst context: FieldBatchEncodingContext = {\n\t\t\tencodeType: TreeCompressionStrategy.Compressed,\n\t\t\tidCompressor,\n\t\t\toriginatorId: idCompressor.localSessionId, // TODO: Why is this needed?\n\t\t\tschema: { schema: toStoredSchema(schema), policy: defaultSchemaPolicy },\n\t\t};\n\t\tconst result = codec.encode(batch, context);\n\t\treturn result;\n\t},\n\n\timportCompressed<const TSchema extends ImplicitFieldSchema>(\n\t\tschema: TSchema,\n\t\tcompressedData: JsonCompatible<IFluidHandle>,\n\t\toptions: {\n\t\t\tidCompressor?: IIdCompressor;\n\t\t} & ICodecOptions,\n\t): Unhydrated<TreeFieldFromImplicitField<TSchema>> {\n\t\tconst config = new TreeViewConfigurationAlpha({ schema });\n\t\tconst content: ViewContent = {\n\t\t\t// Always use a v1 schema codec for consistency.\n\t\t\tschema: extractPersistedSchema(config, FluidClientVersion.v2_0),\n\t\t\ttree: compressedData,\n\t\t\tidCompressor: options.idCompressor ?? createIdCompressor(),\n\t\t};\n\t\tconst view = independentInitializedView(config, options, content);\n\t\treturn TreeBeta.clone<TSchema>(view.root);\n\t},\n\n\tidentifier,\n\n\tkey2(node: TreeNode): string | number | undefined {\n\t\t// If the parent is undefined, then this node is under the root field,\n\t\tconst parent = treeNodeApi.parent(node);\n\t\tif (parent === undefined) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\t// The flex-domain strictly operates in terms of \"stored keys\".\n\t\t// To find the associated developer-facing \"property key\", we need to look up the field associated with\n\t\t// the stored key from the flex-domain, and get property key its simple-domain counterpart was created with.\n\t\tconst storedKey = getStoredKey(node);\n\t\tconst parentSchema = treeNodeApi.schema(parent);\n\t\treturn getPropertyKeyFromStoredKey(parentSchema, storedKey);\n\t},\n\n\tchild: (\n\t\tnode: TreeNode,\n\t\tpropertyKey: string | number,\n\t): TreeNode | TreeLeafValue | undefined => {\n\t\tconst flexNode = getOrCreateInnerNode(node);\n\t\tdebugAssert(\n\t\t\t() => !flexNode.context.isDisposed() || \"The provided tree node has been disposed.\",\n\t\t);\n\n\t\tconst schema = treeNodeApi.schema(node);\n\n\t\tswitch (schema.kind) {\n\t\t\tcase NodeKind.Array: {\n\t\t\t\tconst sequence = flexNode.tryGetField(EmptyKey) as FlexTreeSequenceField | undefined;\n\n\t\t\t\t// Empty sequence - cannot have children.\n\t\t\t\tif (sequence === undefined) {\n\t\t\t\t\treturn undefined;\n\t\t\t\t}\n\n\t\t\t\tconst index =\n\t\t\t\t\ttypeof propertyKey === \"number\"\n\t\t\t\t\t\t? propertyKey\n\t\t\t\t\t\t: asIndex(propertyKey, Number.POSITIVE_INFINITY);\n\n\t\t\t\t// If the key is not a valid index, then there is no corresponding child.\n\t\t\t\tif (index === undefined) {\n\t\t\t\t\treturn undefined;\n\t\t\t\t}\n\n\t\t\t\tconst childFlexTree = sequence.at(index);\n\n\t\t\t\t// No child at the given index.\n\t\t\t\tif (childFlexTree === undefined) {\n\t\t\t\t\treturn undefined;\n\t\t\t\t}\n\n\t\t\t\treturn getOrCreateNodeFromInnerUnboxedNode(childFlexTree);\n\t\t\t}\n\t\t\tcase NodeKind.Map:\n\t\t\t\tif (typeof propertyKey !== \"string\") {\n\t\t\t\t\t// Map nodes only support string keys.\n\t\t\t\t\treturn undefined;\n\t\t\t\t}\n\t\t\t// Fall through\n\t\t\tcase NodeKind.Object: {\n\t\t\t\tlet storedKey: string | number = propertyKey;\n\t\t\t\tif (isObjectNodeSchema(schema)) {\n\t\t\t\t\tconst fieldSchema = schema.fields.get(String(propertyKey));\n\t\t\t\t\tif (fieldSchema === undefined) {\n\t\t\t\t\t\treturn undefined;\n\t\t\t\t\t}\n\n\t\t\t\t\tstoredKey = fieldSchema.storedKey;\n\t\t\t\t}\n\n\t\t\t\tconst field = flexNode.tryGetField(brand(String(storedKey)));\n\t\t\t\tif (field !== undefined) {\n\t\t\t\t\treturn tryGetTreeNodeForField(field);\n\t\t\t\t}\n\n\t\t\t\treturn undefined;\n\t\t\t}\n\t\t\tcase NodeKind.Leaf: {\n\t\t\t\tfail(0xbc3 /* Leaf schema associated with non-leaf tree node. */);\n\t\t\t}\n\t\t\tdefault: {\n\t\t\t\tunreachableCase(schema.kind);\n\t\t\t}\n\t\t}\n\t},\n\n\tchildren(node: TreeNode): [propertyKey: string | number, child: TreeNode | TreeLeafValue][] {\n\t\tconst flexNode = getOrCreateInnerNode(node);\n\t\tdebugAssert(\n\t\t\t() => !flexNode.context.isDisposed() || \"The provided tree node has been disposed.\",\n\t\t);\n\n\t\tconst schema = treeNodeApi.schema(node);\n\n\t\tconst result: [string | number, TreeNode | TreeLeafValue][] = [];\n\t\tswitch (schema.kind) {\n\t\t\tcase NodeKind.Array: {\n\t\t\t\tconst sequence = flexNode.tryGetField(EmptyKey) as FlexTreeSequenceField | undefined;\n\t\t\t\tif (sequence === undefined) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tfor (let index = 0; index < sequence.length; index++) {\n\t\t\t\t\tconst childFlexTree = sequence.at(index);\n\t\t\t\t\tassert(childFlexTree !== undefined, 0xbc4 /* Sequence child was undefined. */);\n\t\t\t\t\tconst childTree = getOrCreateNodeFromInnerUnboxedNode(childFlexTree);\n\t\t\t\t\tresult.push([index, childTree]);\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase NodeKind.Map: {\n\t\t\t\tfor (const [key, flexField] of flexNode.fields) {\n\t\t\t\t\tconst childTreeNode = tryGetTreeNodeForField(flexField);\n\t\t\t\t\tif (childTreeNode !== undefined) {\n\t\t\t\t\t\tresult.push([key, childTreeNode]);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase NodeKind.Object: {\n\t\t\t\tassert(isObjectNodeSchema(schema), 0xbc5 /* Expected object schema. */);\n\t\t\t\tfor (const [propertyKey, fieldSchema] of schema.fields) {\n\t\t\t\t\tconst storedKey = fieldSchema.storedKey;\n\t\t\t\t\tconst flexField = flexNode.tryGetField(brand(String(storedKey)));\n\t\t\t\t\tif (flexField !== undefined) {\n\t\t\t\t\t\tconst childTreeNode = tryGetTreeNodeForField(flexField);\n\t\t\t\t\t\tassert(\n\t\t\t\t\t\t\tchildTreeNode !== undefined,\n\t\t\t\t\t\t\t0xbc6 /* Expected child tree node for field. */,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tresult.push([propertyKey, childTreeNode]);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase NodeKind.Leaf: {\n\t\t\t\tfail(0xbc7 /* Leaf schema associated with non-leaf tree node. */);\n\t\t\t}\n\t\t\tdefault: {\n\t\t\t\tunreachableCase(schema.kind);\n\t\t\t}\n\t\t}\n\t\treturn result;\n\t},\n};\n\nfunction exportConcise(\n\tnode: TreeNode | TreeLeafValue,\n\toptions?: TreeEncodingOptions,\n): ConciseTree;\n\nfunction exportConcise(\n\tnode: TreeNode | TreeLeafValue | undefined,\n\toptions?: TreeEncodingOptions,\n): ConciseTree | undefined;\n\nfunction exportConcise(\n\tnode: TreeNode | TreeLeafValue | undefined,\n\toptions?: TreeEncodingOptions,\n): ConciseTree | undefined {\n\tif (node === undefined) {\n\t\treturn undefined;\n\t}\n\tconst config: TreeEncodingOptions = { ...options };\n\n\tconst cursor = borrowCursorFromTreeNodeOrValue(node);\n\treturn conciseFromCursor(\n\t\tcursor,\n\t\ttryGetSchema(node) ?? fail(0xacd /* invalid input */),\n\t\tconfig,\n\t);\n}\n\n/**\n * Borrow a cursor from a node.\n * @remarks\n * The cursor must be put back to its original location before the node is used again.\n */\nfunction borrowCursorFromTreeNodeOrValue(\n\tnode: TreeNode | TreeLeafValue,\n): ITreeCursorSynchronous {\n\tif (isTreeValue(node)) {\n\t\treturn cursorFromVerbose(node, {});\n\t}\n\tconst kernel = getKernel(node);\n\tconst cursor = kernel.getOrCreateInnerNode().borrowCursor();\n\treturn cursor;\n}\n\n/**\n * Borrow a cursor from a field.\n * @remarks\n * The cursor must be put back to its original location before the node is used again.\n */\nfunction borrowFieldCursorFromTreeNodeOrValue(\n\tnode: TreeNode | TreeLeafValue | undefined,\n): ITreeCursorSynchronous {\n\tif (node === undefined) {\n\t\treturn cursorForMapTreeField([]);\n\t}\n\tconst cursor = borrowCursorFromTreeNodeOrValue(node);\n\t// TODO: avoid copy: borrow cursor from field instead.\n\tconst mapTree = mapTreeFromCursor(cursor);\n\treturn cursorForMapTreeField([mapTree]);\n}\n"]}
1
+ {"version":3,"file":"treeAlpha.js","sourceRoot":"","sources":["../../src/shared-tree/treeAlpha.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,MAAM,EACN,WAAW,EACX,IAAI,EACJ,eAAe,GACf,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EAAE,kBAAkB,EAAE,MAAM,wCAAwC,CAAC;AAC5E,OAAO,EAAE,UAAU,EAAE,MAAM,0CAA0C,CAAC;AAItE,OAAO,EACN,OAAO,EACP,SAAS,EAGT,QAAQ,EACR,YAAY,EACZ,gBAAgB,EAChB,SAAS,EACT,oBAAoB,EAMpB,iBAAiB,EAEjB,0BAA0B,EAC1B,iBAAiB,EACjB,iBAAiB,EAGjB,cAAc,EACd,sBAAsB,EAEtB,0BAA0B,EAC1B,YAAY,EACZ,2BAA2B,EAC3B,WAAW,EACX,qBAAqB,EACrB,gCAAgC,EAChC,4BAA4B,EAC5B,mCAAmC,EACnC,oBAA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ACrD,OAAO,iBAAiB,CACvB,MAAM,EACN,YAAY,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,KAAK,CAAC,mBAAmB,CAAC,EACrD,MAAM,CACN,CAAC;AACH,CAAC;AAED;;;;GAIG;AACH,SAAS,+BAA+B,CACvC,IAA8B;IAE9B,IAAI,WAAW,CAAC,IAAI,CAAC,EAAE,CAAC;QACvB,OAAO,iBAAiB,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;IACpC,CAAC;IACD,MAAM,MAAM,GAAG,SAAS,CAAC,IAAI,CAAC,CAAC;IAC/B,MAAM,MAAM,GAAG,MAAM,CAAC,oBAAoB,EAAE,CAAC,YAAY,EAAE,CAAC;IAC5D,OAAO,MAAM,CAAC;AACf,CAAC;AAED;;;;GAIG;AACH,SAAS,oCAAoC,CAC5C,IAA0C;IAE1C,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;QACxB,OAAO,qBAAqB,CAAC,EAAE,CAAC,CAAC;IAClC,CAAC;IACD,MAAM,MAAM,GAAG,+BAA+B,CAAC,IAAI,CAAC,CAAC;IACrD,sDAAsD;IACtD,MAAM,OAAO,GAAG,iBAAiB,CAAC,MAAM,CAAC,CAAC;IAC1C,OAAO,qBAAqB,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC;AACzC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\tassert,\n\tdebugAssert,\n\tfail,\n\tunreachableCase,\n} from \"@fluidframework/core-utils/internal\";\nimport { createIdCompressor } from \"@fluidframework/id-compressor/internal\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\nimport type { IFluidHandle } from \"@fluidframework/core-interfaces\";\nimport type { IIdCompressor } from \"@fluidframework/id-compressor\";\n\nimport {\n\tasIndex,\n\tgetKernel,\n\ttype TreeNode,\n\ttype Unhydrated,\n\tTreeBeta,\n\ttryGetSchema,\n\tcreateFromCursor,\n\tFieldKind,\n\tnormalizeFieldSchema,\n\ttype ImplicitFieldSchema,\n\ttype InsertableField,\n\ttype TreeFieldFromImplicitField,\n\ttype TreeLeafValue,\n\ttype UnsafeUnknownSchema,\n\tconciseFromCursor,\n\ttype ConciseTree,\n\tapplySchemaToParserOptions,\n\tcursorFromVerbose,\n\tverboseFromCursor,\n\ttype TreeEncodingOptions,\n\ttype VerboseTree,\n\ttoStoredSchema,\n\textractPersistedSchema,\n\ttype TreeBranch,\n\tTreeViewConfigurationAlpha,\n\tgetStoredKey,\n\tgetPropertyKeyFromStoredKey,\n\ttreeNodeApi,\n\tgetIdentifierFromNode,\n\tunhydratedFlexTreeFromInsertable,\n\tgetOrCreateNodeFromInnerNode,\n\tgetOrCreateNodeFromInnerUnboxedNode,\n\tgetOrCreateInnerNode,\n\tNodeKind,\n\ttryGetTreeNodeForField,\n\tisObjectNodeSchema,\n} from \"../simple-tree/index.js\";\nimport { brand, extractFromOpaque, type JsonCompatible } from \"../util/index.js\";\nimport {\n\tFluidClientVersion,\n\tnoopValidator,\n\ttype ICodecOptions,\n\ttype CodecWriteOptions,\n} from \"../codec/index.js\";\nimport { EmptyKey, type ITreeCursorSynchronous } from \"../core/index.js\";\nimport {\n\tcursorForMapTreeField,\n\tdefaultSchemaPolicy,\n\tisTreeValue,\n\tmakeFieldBatchCodec,\n\tmapTreeFromCursor,\n\tTreeCompressionStrategy,\n\ttype FieldBatch,\n\ttype FieldBatchEncodingContext,\n\tfluidVersionToFieldBatchCodecWriteVersion,\n\ttype LocalNodeIdentifier,\n\ttype FlexTreeSequenceField,\n} from \"../feature-libraries/index.js\";\nimport { independentInitializedView, type ViewContent } from \"./independentView.js\";\nimport { SchematizingSimpleTreeView, ViewSlot } from \"./schematizingTreeView.js\";\n\nconst identifier: TreeIdentifierUtils = (node: TreeNode): string | undefined => {\n\tconst nodeIdentifier = getIdentifierFromNode(node, \"uncompressed\");\n\tif (typeof nodeIdentifier === \"number\") {\n\t\tthrow new TypeError(\"identifier should be uncompressed.\");\n\t}\n\treturn nodeIdentifier;\n};\n\nidentifier.shorten = (branch: TreeBranch, nodeIdentifier: string): number | undefined => {\n\tconst nodeKeyManager = (branch as SchematizingSimpleTreeView<ImplicitFieldSchema>)\n\t\t.nodeKeyManager;\n\tconst localNodeKey = nodeKeyManager.tryLocalizeNodeIdentifier(nodeIdentifier);\n\treturn localNodeKey !== undefined ? extractFromOpaque(localNodeKey) : undefined;\n};\n\nidentifier.lengthen = (branch: TreeBranch, nodeIdentifier: number): string => {\n\tconst nodeKeyManager = (branch as SchematizingSimpleTreeView<ImplicitFieldSchema>)\n\t\t.nodeKeyManager;\n\treturn nodeKeyManager.stabilizeNodeIdentifier(\n\t\tnodeIdentifier as unknown as LocalNodeIdentifier,\n\t);\n};\n\nidentifier.getShort = (node: TreeNode): number | undefined => {\n\tconst shortIdentifier = getIdentifierFromNode(node, \"compressed\");\n\treturn typeof shortIdentifier === \"number\" ? shortIdentifier : undefined;\n};\n\nidentifier.create = (branch: TreeBranch): string => {\n\tconst nodeKeyManager = (branch as SchematizingSimpleTreeView<ImplicitFieldSchema>)\n\t\t.nodeKeyManager;\n\treturn nodeKeyManager.stabilizeNodeIdentifier(nodeKeyManager.generateLocalNodeIdentifier());\n};\n\nObject.freeze(identifier);\n\n/**\n * A utility interface for retrieving or converting node identifiers.\n *\n * @remarks\n * This provides methods to:\n *\n * - Retrieve long or short identifiers from nodes\n *\n * - Convert between long identifiers and short identifiers\n *\n * - Generates long identifiers\n *\n * @alpha @sealed\n */\nexport interface TreeIdentifierUtils {\n\t/**\n\t * Returns the contents of a node's {@link SchemaFactory.identifier} field as a stable identifier.\n\t * If the identifier field does not exist, returns undefined.\n\t *\n\t * @param node - The TreeNode you want to get the identifier from,\n\t */\n\t(node: TreeNode): string | undefined;\n\n\t/**\n\t * Returns the shortened identifier as a number given long identifier known by the id compressor on the branch if possible.\n\t * Otherwise, it will return the original string identifier provided.\n\t * If the id does not exist, or is unknown by the id compressor, it returns undefined.\n\t *\n\t * This method is the inverse of {@link TreeIdentifierUtils.lengthen}. If you shorten an identifier\n\t * and then immediately pass it to {@link TreeIdentifierUtils.lengthen}, you will get the original string back.\n\t *\n\t * @param branch - TreeBranch from where you get the idCompressor to do the decompression.\n\t * @param nodeIdentifier - the stable identifier that needs to be shortened.\n\t */\n\tshorten(branch: TreeBranch, nodeIdentifier: string): number | undefined;\n\n\t/**\n\t * Returns the stable id as a string if the identifier is decompressible and known by the id compressor. Otherwise, it will throw an error.\n\t *\n\t * This method is the inverse of {@link TreeIdentifierUtils.shorten}. If you lengthen an identifier\n\t * and then immediately pass it to {@link TreeIdentifierUtils.shorten}, you will get the original short identifier back.\n\t *\n\t * @param branch - TreeBranch from where you want to get the id compressor to do the decompression.\n\t * @param nodeIdentifier - The local identifier that needs to be expanded.\n\t */\n\tlengthen(branch: TreeBranch, nodeIdentifier: number): string;\n\n\t/**\n\t * Returns the {@link SchemaFactory.identifier | identifier} of the given node in the most compressed form possible.\n\t * @remarks\n\t * 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.\n\t * 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.\n\t * Note that automatically generated identifiers that were accessed before the node was hydrated will return the generated UUID, not the process-unique integer.\n\t *\n\t * If the node's identifier is any other user-provided string, then this will return undefined.\n\t *\n\t * If the node has no identifier (that is, it has no {@link SchemaFactory.identifier | identifier} field), then this returns `undefined`.\n\t *\n\t * If the node has more than one identifier, then this will throw an error.\n\t *\n\t * The returned integer should not be serialized or preserved outside of the current process.\n\t * 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.\n\t * 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.\n\t */\n\tgetShort(node: TreeNode): number | undefined;\n\n\t/**\n\t * Creates and returns a long identifier.\n\t * The long identifier is a compressible, stable identifier generated by the tree's ID compressor.\n\t *\n\t * @param branch - TreeBranch from where you want to get the id compressor to generate the identifier from.\n\t */\n\tcreate(branch: TreeBranch): string;\n}\n\n/**\n * Extensions to {@link (Tree:interface)} and {@link (TreeBeta:interface)} which are not yet stable.\n * @remarks\n * Use via the {@link (TreeAlpha:variable)} singleton.\n * @system @sealed @alpha\n */\nexport interface TreeAlpha {\n\t/**\n\t * Retrieve the {@link TreeBranch | branch}, if any, for the given node.\n\t * @param node - The node to query\n\t * @remarks If the node has already been inserted into the tree, this will return the branch associated with that node's {@link TreeView | view}.\n\t * Otherwise, it will return `undefined` (because the node has not yet been inserted and is therefore not part of a branch or view).\n\t *\n\t * This does not fork a new branch, but rather retrieves the _existing_ branch for the node.\n\t * To create a new branch, use e.g. {@link TreeBranch.fork | `myBranch.fork()`}.\n\t */\n\tbranch(node: TreeNode): TreeBranch | undefined;\n\n\t/**\n\t * Construct tree content that is compatible with the field defined by the provided `schema`.\n\t * @param schema - The schema for what to construct. As this is an {@link ImplicitFieldSchema}, a {@link FieldSchema}, {@link TreeNodeSchema} or {@link AllowedTypes} array can be provided.\n\t * @param data - The data used to construct the field content.\n\t * @remarks\n\t * When providing a {@link TreeNodeSchemaClass}, this is the same as invoking its constructor except that an unhydrated node can also be provided.\n\t * This function exists as a generalization that can be used in other cases as well,\n\t * such as when `undefined` might be allowed (for an optional field), or when the type should be inferred from the data when more than one type is possible.\n\t * @privateRemarks\n\t * There should be a way to provide a source for defaulted identifiers, either via this API or some way to add them to its output later.\n\t */\n\tcreate<const TSchema extends ImplicitFieldSchema | UnsafeUnknownSchema>(\n\t\tschema: UnsafeUnknownSchema extends TSchema\n\t\t\t? ImplicitFieldSchema\n\t\t\t: TSchema & ImplicitFieldSchema,\n\t\tdata: InsertableField<TSchema>,\n\t): Unhydrated<\n\t\tTSchema extends ImplicitFieldSchema\n\t\t\t? TreeFieldFromImplicitField<TSchema>\n\t\t\t: TreeNode | TreeLeafValue | undefined\n\t>;\n\n\t/**\n\t * Less type safe version of {@link (TreeAlpha:interface).create}, suitable for importing data.\n\t * @remarks\n\t * Due to {@link ConciseTree} relying on type inference from the data, its use is somewhat limited.\n\t * This does not support {@link ConciseTree|ConciseTrees} with customized handle encodings or using persisted keys.\n\t * Use \"compressed\" or \"verbose\" formats for more flexibility.\n\t *\n\t * When using this function,\n\t * it is recommend to ensure your schema is unambiguous with {@link ITreeConfigurationOptions.preventAmbiguity}.\n\t * If the schema is ambiguous, consider using {@link (TreeAlpha:interface).create} and {@link Unhydrated} nodes where needed,\n\t * or using {@link (TreeAlpha:interface).(importVerbose:1)} and specify all types.\n\t *\n\t * Documented (and thus recoverable) error handling/reporting for this is not yet implemented,\n\t * but for now most invalid inputs will throw a recoverable error.\n\t */\n\timportConcise<const TSchema extends ImplicitFieldSchema | UnsafeUnknownSchema>(\n\t\tschema: UnsafeUnknownSchema extends TSchema\n\t\t\t? ImplicitFieldSchema\n\t\t\t: TSchema & ImplicitFieldSchema,\n\t\tdata: ConciseTree | undefined,\n\t): Unhydrated<\n\t\tTSchema extends ImplicitFieldSchema\n\t\t\t? TreeFieldFromImplicitField<TSchema>\n\t\t\t: TreeNode | TreeLeafValue | undefined\n\t>;\n\n\t/**\n\t * Construct tree content compatible with a field defined by the provided `schema`.\n\t * @param schema - The schema for what to construct. As this is an {@link ImplicitFieldSchema}, a {@link FieldSchema}, {@link TreeNodeSchema} or {@link AllowedTypes} array can be provided.\n\t * @param data - The data used to construct the field content. See {@link (TreeAlpha:interface).(exportVerbose:1)}.\n\t */\n\timportVerbose<const TSchema extends ImplicitFieldSchema>(\n\t\tschema: TSchema,\n\t\tdata: VerboseTree | undefined,\n\t\toptions?: Partial<TreeEncodingOptions>,\n\t): Unhydrated<TreeFieldFromImplicitField<TSchema>>;\n\n\t/**\n\t * Copy a snapshot of the current version of a TreeNode into a {@link ConciseTree}.\n\t */\n\texportConcise(node: TreeNode | TreeLeafValue, options?: TreeEncodingOptions): ConciseTree;\n\n\t/**\n\t * Copy a snapshot of the current version of a TreeNode into a {@link ConciseTree}, allowing undefined.\n\t */\n\texportConcise(\n\t\tnode: TreeNode | TreeLeafValue | undefined,\n\t\toptions?: TreeEncodingOptions,\n\t): ConciseTree | undefined;\n\n\t/**\n\t * Copy a snapshot of the current version of a TreeNode into a JSON compatible plain old JavaScript Object (except for {@link @fluidframework/core-interfaces#IFluidHandle|IFluidHandles}).\n\t * Uses the {@link VerboseTree} format, with an explicit type on every node.\n\t *\n\t * @remarks\n\t * There are several cases this may be preferred to {@link (TreeAlpha:interface).(exportConcise:1)}:\n\t *\n\t * 1. When not using {@link ITreeConfigurationOptions.preventAmbiguity} (or when using `useStableFieldKeys`), `exportConcise` can produce ambiguous data (the type may be unclear on some nodes).\n\t * `exportVerbose` will always be unambiguous and thus lossless.\n\t *\n\t * 2. When the data might be interpreted without access to the exact same view schema. In such cases, the types may be unknowable if not included.\n\t *\n\t * 3. When easy access to the type is desired.\n\t */\n\texportVerbose(node: TreeNode | TreeLeafValue, options?: TreeEncodingOptions): VerboseTree;\n\n\t/**\n\t * Export the content of the provided `tree` in a compressed JSON compatible format.\n\t * @remarks\n\t * If an `idCompressor` is provided, it will be used to compress identifiers and thus will be needed to decompress the data.\n\t *\n\t * Always uses \"stored\" keys.\n\t * See {@link TreeEncodingOptions.useStoredKeys} for details.\n\t * @privateRemarks\n\t * TODO: It is currently not clear how to work with the idCompressors correctly in the package API.\n\t * Better APIs should probably be provided as there is currently no way to associate an un-hydrated tree with an idCompressor,\n\t * Nor get the correct idCompressor from a subtree to use when exporting it.\n\t * Additionally using `createIdCompressor` to make an idCompressor is `@legacy` and thus not intended for use in this API surface.\n\t * It would probably make more sense if we provided a way to get an idCompressor from the context of a node,\n\t * which could be optional (and settable if missing) for un0hydrated nodes and required for hydrated ones.\n\t * Add in a stable public API for creating idCompressors, and a way to get them from a tree (without view schema), and that should address the anticipated use-cases.\n\t */\n\texportCompressed(\n\t\ttree: TreeNode | TreeLeafValue,\n\t\toptions: { idCompressor?: IIdCompressor } & Pick<\n\t\t\tCodecWriteOptions,\n\t\t\t\"oldestCompatibleClient\"\n\t\t>,\n\t): JsonCompatible<IFluidHandle>;\n\n\t/**\n\t * Import data encoded by {@link (TreeAlpha:interface).exportCompressed}.\n\t *\n\t * @param schema - Schema with which the data must be compatible. This compatibility is not verified and must be ensured by the caller.\n\t * @param compressedData - Data compressed by {@link (TreeAlpha:interface).exportCompressed}.\n\t * @param options - If {@link (TreeAlpha:interface).exportCompressed} was given an `idCompressor`, it must be provided here.\n\t *\n\t * @remarks\n\t * If the data could have been encoded with a different schema, consider encoding the schema along side it using {@link extractPersistedSchema} and loading the data using {@link independentView}.\n\t *\n\t * @privateRemarks\n\t * This API could be improved:\n\t *\n\t * 1. It could validate that the schema is compatible, and return or throw an error in the invalid case (maybe add a \"try\" version).\n\t *\n\t * 2. A \"try\" version of this could return an error if the data isn't in a supported format (as determined by version and/or JasonValidator).\n\t *\n\t * 3. Requiring the caller provide a JsonValidator isn't the most friendly API. It might be practical to provide a default.\n\t */\n\timportCompressed<const TSchema extends ImplicitFieldSchema>(\n\t\tschema: TSchema,\n\t\tcompressedData: JsonCompatible<IFluidHandle>,\n\t\toptions: { idCompressor?: IIdCompressor } & ICodecOptions,\n\t): Unhydrated<TreeFieldFromImplicitField<TSchema>>;\n\n\t/**\n\t * APIs for creating, converting, and retrieving identifiers.\n\t */\n\treadonly identifier: TreeIdentifierUtils;\n\n\t/**\n\t * The key of the given node under its parent.\n\t * @remarks\n\t * If `node` is an element in a {@link (TreeArrayNode:interface)}, this returns the index of `node` in the array node (a `number`).\n\t * If `node` is the root node, this returns undefined.\n\t * Otherwise, this returns the key of the field that it is under (a `string`).\n\t */\n\tkey2(node: TreeNode): string | number | undefined;\n\n\t/**\n\t * Gets the child of the given node with the given property key if a child exists under that key.\n\t *\n\t * @remarks {@link SchemaFactoryObjectOptions.allowUnknownOptionalFields | Unknown optional fields} of Object nodes will not be returned by this method.\n\t *\n\t * @param node - The parent node whose child is being requested.\n\t * @param key - The property key under the node under which the child is being requested.\n\t * For Object nodes, this is the developer-facing \"property key\", not the \"{@link SimpleObjectFieldSchema.storedKey | stored keys}\".\n\t *\n\t * @returns The child node or leaf value under the given key, or `undefined` if no such child exists.\n\t *\n\t * @see {@link (TreeAlpha:interface).key2}\n\t * @see {@link (TreeNodeApi:interface).parent}\n\t */\n\tchild(node: TreeNode, key: string | number): TreeNode | TreeLeafValue | undefined;\n\n\t/**\n\t * Gets the children of the provided node, paired with their property keys under the node.\n\t *\n\t * @remarks\n\t * No guarantees are made regarding the order of the children in the returned array.\n\t *\n\t * Optional properties of Object nodes with no value are not included in the result.\n\t *\n\t * {@link SchemaFactoryObjectOptions.allowUnknownOptionalFields | Unknown optional fields} of Object nodes are not included in the result.\n\t *\n\t * @param node - The node whose children are being requested.\n\t *\n\t * @returns\n\t * An array of pairs of the form `[propertyKey, child]`.\n\t *\n\t * For Array nodes, the `propertyKey` is the index of the child in the array.\n\t *\n\t * For Object nodes, the returned `propertyKey`s are the developer-facing \"property keys\", not the \"{@link SimpleObjectFieldSchema.storedKey | stored keys}\".\n\t *\n\t * @see {@link (TreeAlpha:interface).key2}\n\t * @see {@link (TreeNodeApi:interface).parent}\n\t */\n\tchildren(\n\t\tnode: TreeNode,\n\t): Iterable<[propertyKey: string | number, child: TreeNode | TreeLeafValue]>;\n}\n\n/**\n * Extensions to {@link (Tree:variable)} and {@link (TreeBeta:variable)} which are not yet stable.\n * @see {@link (TreeAlpha:interface)}.\n * @alpha\n */\nexport const TreeAlpha: TreeAlpha = {\n\tbranch(node: TreeNode): TreeBranch | undefined {\n\t\tconst kernel = getKernel(node);\n\t\tif (!kernel.isHydrated()) {\n\t\t\treturn undefined;\n\t\t}\n\t\tconst view = kernel.anchorNode.anchorSet.slots.get(ViewSlot);\n\t\tassert(\n\t\t\tview instanceof SchematizingSimpleTreeView,\n\t\t\t0xa5c /* Unexpected view implementation */,\n\t\t);\n\t\treturn view;\n\t},\n\n\tcreate<const TSchema extends ImplicitFieldSchema | UnsafeUnknownSchema>(\n\t\tschema: UnsafeUnknownSchema extends TSchema\n\t\t\t? ImplicitFieldSchema\n\t\t\t: TSchema & ImplicitFieldSchema,\n\t\tdata: InsertableField<TSchema>,\n\t): Unhydrated<\n\t\tTSchema extends ImplicitFieldSchema\n\t\t\t? TreeFieldFromImplicitField<TSchema>\n\t\t\t: TreeNode | TreeLeafValue | undefined\n\t> {\n\t\tconst mapTree = unhydratedFlexTreeFromInsertable(\n\t\t\tdata as InsertableField<UnsafeUnknownSchema>,\n\t\t\tschema,\n\t\t);\n\t\tconst result = mapTree === undefined ? undefined : getOrCreateNodeFromInnerNode(mapTree);\n\t\treturn result as Unhydrated<\n\t\t\tTSchema extends ImplicitFieldSchema\n\t\t\t\t? TreeFieldFromImplicitField<TSchema>\n\t\t\t\t: TreeNode | TreeLeafValue | undefined\n\t\t>;\n\t},\n\n\timportConcise<TSchema extends ImplicitFieldSchema | UnsafeUnknownSchema>(\n\t\tschema: UnsafeUnknownSchema extends TSchema\n\t\t\t? ImplicitFieldSchema\n\t\t\t: TSchema & ImplicitFieldSchema,\n\t\tdata: ConciseTree | undefined,\n\t): Unhydrated<\n\t\tTSchema extends ImplicitFieldSchema\n\t\t\t? TreeFieldFromImplicitField<TSchema>\n\t\t\t: TreeNode | TreeLeafValue | undefined\n\t> {\n\t\t// `importConcise` does not need to support all the formats that `create` does.\n\t\t// Perhaps it should error instead of hydrating nodes for example.\n\t\t// For now however, it is a simple wrapper around `create`.\n\t\treturn this.create(schema, data as InsertableField<TSchema>);\n\t},\n\n\timportVerbose<const TSchema extends ImplicitFieldSchema>(\n\t\tschema: TSchema,\n\t\tdata: VerboseTree | undefined,\n\t\toptions?: TreeEncodingOptions,\n\t): Unhydrated<TreeFieldFromImplicitField<TSchema>> {\n\t\tconst config: TreeEncodingOptions = { ...options };\n\t\t// Create a config which is standalone, and thus can be used without having to refer back to the schema.\n\t\tconst schemalessConfig = applySchemaToParserOptions(schema, config);\n\t\tif (data === undefined) {\n\t\t\tconst field = normalizeFieldSchema(schema);\n\t\t\tif (field.kind !== FieldKind.Optional) {\n\t\t\t\tthrow new UsageError(\"undefined provided for non-optional field.\");\n\t\t\t}\n\t\t\treturn undefined as Unhydrated<TreeFieldFromImplicitField<TSchema>>;\n\t\t}\n\t\tconst cursor = cursorFromVerbose(data, schemalessConfig);\n\t\treturn createFromCursor(schema, cursor);\n\t},\n\n\texportConcise,\n\n\texportVerbose(node: TreeNode | TreeLeafValue, options?: TreeEncodingOptions): VerboseTree {\n\t\tconst config: TreeEncodingOptions = { ...options };\n\n\t\tconst cursor = borrowCursorFromTreeNodeOrValue(node);\n\t\treturn verboseFromCursor(\n\t\t\tcursor,\n\t\t\ttryGetSchema(node) ?? fail(0xace /* invalid input */),\n\t\t\tconfig,\n\t\t);\n\t},\n\n\texportCompressed(\n\t\tnode: TreeNode | TreeLeafValue,\n\t\toptions: { idCompressor?: IIdCompressor } & Pick<\n\t\t\tCodecWriteOptions,\n\t\t\t\"oldestCompatibleClient\"\n\t\t>,\n\t): JsonCompatible<IFluidHandle> {\n\t\tconst schema = tryGetSchema(node) ?? fail(0xacf /* invalid input */);\n\t\tconst format = fluidVersionToFieldBatchCodecWriteVersion(options.oldestCompatibleClient);\n\t\tconst codec = makeFieldBatchCodec({ jsonValidator: noopValidator }, format);\n\t\tconst cursor = borrowFieldCursorFromTreeNodeOrValue(node);\n\t\tconst batch: FieldBatch = [cursor];\n\t\t// If none provided, create a compressor which will not compress anything.\n\t\tconst idCompressor = options.idCompressor ?? createIdCompressor();\n\t\tconst context: FieldBatchEncodingContext = {\n\t\t\tencodeType: TreeCompressionStrategy.Compressed,\n\t\t\tidCompressor,\n\t\t\toriginatorId: idCompressor.localSessionId, // TODO: Why is this needed?\n\t\t\tschema: { schema: toStoredSchema(schema), policy: defaultSchemaPolicy },\n\t\t};\n\t\tconst result = codec.encode(batch, context);\n\t\treturn result;\n\t},\n\n\timportCompressed<const TSchema extends ImplicitFieldSchema>(\n\t\tschema: TSchema,\n\t\tcompressedData: JsonCompatible<IFluidHandle>,\n\t\toptions: {\n\t\t\tidCompressor?: IIdCompressor;\n\t\t} & ICodecOptions,\n\t): Unhydrated<TreeFieldFromImplicitField<TSchema>> {\n\t\tconst config = new TreeViewConfigurationAlpha({ schema });\n\t\tconst content: ViewContent = {\n\t\t\t// Always use a v1 schema codec for consistency.\n\t\t\tschema: extractPersistedSchema(config, FluidClientVersion.v2_0),\n\t\t\ttree: compressedData,\n\t\t\tidCompressor: options.idCompressor ?? createIdCompressor(),\n\t\t};\n\t\tconst view = independentInitializedView(config, options, content);\n\t\treturn TreeBeta.clone<TSchema>(view.root);\n\t},\n\n\tidentifier,\n\n\tkey2(node: TreeNode): string | number | undefined {\n\t\t// If the parent is undefined, then this node is under the root field,\n\t\tconst parent = treeNodeApi.parent(node);\n\t\tif (parent === undefined) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\t// The flex-domain strictly operates in terms of \"stored keys\".\n\t\t// To find the associated developer-facing \"property key\", we need to look up the field associated with\n\t\t// the stored key from the flex-domain, and get property key its simple-domain counterpart was created with.\n\t\tconst storedKey = getStoredKey(node);\n\t\tconst parentSchema = treeNodeApi.schema(parent);\n\t\treturn getPropertyKeyFromStoredKey(parentSchema, storedKey);\n\t},\n\n\tchild: (\n\t\tnode: TreeNode,\n\t\tpropertyKey: string | number,\n\t): TreeNode | TreeLeafValue | undefined => {\n\t\tconst flexNode = getOrCreateInnerNode(node);\n\t\tdebugAssert(\n\t\t\t() => !flexNode.context.isDisposed() || \"The provided tree node has been disposed.\",\n\t\t);\n\n\t\tconst schema = treeNodeApi.schema(node);\n\n\t\tswitch (schema.kind) {\n\t\t\tcase NodeKind.Array: {\n\t\t\t\tconst sequence = flexNode.tryGetField(EmptyKey) as FlexTreeSequenceField | undefined;\n\n\t\t\t\t// Empty sequence - cannot have children.\n\t\t\t\tif (sequence === undefined) {\n\t\t\t\t\treturn undefined;\n\t\t\t\t}\n\n\t\t\t\tconst index =\n\t\t\t\t\ttypeof propertyKey === \"number\"\n\t\t\t\t\t\t? propertyKey\n\t\t\t\t\t\t: asIndex(propertyKey, Number.POSITIVE_INFINITY);\n\n\t\t\t\t// If the key is not a valid index, then there is no corresponding child.\n\t\t\t\tif (index === undefined) {\n\t\t\t\t\treturn undefined;\n\t\t\t\t}\n\n\t\t\t\tconst childFlexTree = sequence.at(index);\n\n\t\t\t\t// No child at the given index.\n\t\t\t\tif (childFlexTree === undefined) {\n\t\t\t\t\treturn undefined;\n\t\t\t\t}\n\n\t\t\t\treturn getOrCreateNodeFromInnerUnboxedNode(childFlexTree);\n\t\t\t}\n\t\t\tcase NodeKind.Map:\n\t\t\t\tif (typeof propertyKey !== \"string\") {\n\t\t\t\t\t// Map nodes only support string keys.\n\t\t\t\t\treturn undefined;\n\t\t\t\t}\n\t\t\t// Fall through\n\t\t\tcase NodeKind.Record:\n\t\t\tcase NodeKind.Object: {\n\t\t\t\tlet storedKey: string | number = propertyKey;\n\t\t\t\tif (isObjectNodeSchema(schema)) {\n\t\t\t\t\tconst fieldSchema = schema.fields.get(String(propertyKey));\n\t\t\t\t\tif (fieldSchema === undefined) {\n\t\t\t\t\t\treturn undefined;\n\t\t\t\t\t}\n\n\t\t\t\t\tstoredKey = fieldSchema.storedKey;\n\t\t\t\t}\n\n\t\t\t\tconst field = flexNode.tryGetField(brand(String(storedKey)));\n\t\t\t\tif (field !== undefined) {\n\t\t\t\t\treturn tryGetTreeNodeForField(field);\n\t\t\t\t}\n\n\t\t\t\treturn undefined;\n\t\t\t}\n\t\t\tcase NodeKind.Leaf: {\n\t\t\t\tfail(0xbc3 /* Leaf schema associated with non-leaf tree node. */);\n\t\t\t}\n\t\t\tdefault: {\n\t\t\t\tunreachableCase(schema.kind);\n\t\t\t}\n\t\t}\n\t},\n\n\tchildren(node: TreeNode): [propertyKey: string | number, child: TreeNode | TreeLeafValue][] {\n\t\tconst flexNode = getOrCreateInnerNode(node);\n\t\tdebugAssert(\n\t\t\t() => !flexNode.context.isDisposed() || \"The provided tree node has been disposed.\",\n\t\t);\n\n\t\tconst schema = treeNodeApi.schema(node);\n\n\t\tconst result: [string | number, TreeNode | TreeLeafValue][] = [];\n\t\tswitch (schema.kind) {\n\t\t\tcase NodeKind.Array: {\n\t\t\t\tconst sequence = flexNode.tryGetField(EmptyKey) as FlexTreeSequenceField | undefined;\n\t\t\t\tif (sequence === undefined) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tfor (let index = 0; index < sequence.length; index++) {\n\t\t\t\t\tconst childFlexTree = sequence.at(index);\n\t\t\t\t\tassert(childFlexTree !== undefined, 0xbc4 /* Sequence child was undefined. */);\n\t\t\t\t\tconst childTree = getOrCreateNodeFromInnerUnboxedNode(childFlexTree);\n\t\t\t\t\tresult.push([index, childTree]);\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase NodeKind.Map:\n\t\t\tcase NodeKind.Record: {\n\t\t\t\tfor (const [key, flexField] of flexNode.fields) {\n\t\t\t\t\tconst childTreeNode = tryGetTreeNodeForField(flexField);\n\t\t\t\t\tif (childTreeNode !== undefined) {\n\t\t\t\t\t\tresult.push([key, childTreeNode]);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase NodeKind.Object: {\n\t\t\t\tassert(isObjectNodeSchema(schema), 0xbc5 /* Expected object schema. */);\n\t\t\t\tfor (const [propertyKey, fieldSchema] of schema.fields) {\n\t\t\t\t\tconst storedKey = fieldSchema.storedKey;\n\t\t\t\t\tconst flexField = flexNode.tryGetField(brand(String(storedKey)));\n\t\t\t\t\tif (flexField !== undefined) {\n\t\t\t\t\t\tconst childTreeNode = tryGetTreeNodeForField(flexField);\n\t\t\t\t\t\tassert(\n\t\t\t\t\t\t\tchildTreeNode !== undefined,\n\t\t\t\t\t\t\t0xbc6 /* Expected child tree node for field. */,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tresult.push([propertyKey, childTreeNode]);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase NodeKind.Leaf: {\n\t\t\t\tfail(0xbc7 /* Leaf schema associated with non-leaf tree node. */);\n\t\t\t}\n\t\t\tdefault: {\n\t\t\t\tunreachableCase(schema.kind);\n\t\t\t}\n\t\t}\n\t\treturn result;\n\t},\n};\n\nfunction exportConcise(\n\tnode: TreeNode | TreeLeafValue,\n\toptions?: TreeEncodingOptions,\n): ConciseTree;\n\nfunction exportConcise(\n\tnode: TreeNode | TreeLeafValue | undefined,\n\toptions?: TreeEncodingOptions,\n): ConciseTree | undefined;\n\nfunction exportConcise(\n\tnode: TreeNode | TreeLeafValue | undefined,\n\toptions?: TreeEncodingOptions,\n): ConciseTree | undefined {\n\tif (node === undefined) {\n\t\treturn undefined;\n\t}\n\tconst config: TreeEncodingOptions = { ...options };\n\n\tconst cursor = borrowCursorFromTreeNodeOrValue(node);\n\treturn conciseFromCursor(\n\t\tcursor,\n\t\ttryGetSchema(node) ?? fail(0xacd /* invalid input */),\n\t\tconfig,\n\t);\n}\n\n/**\n * Borrow a cursor from a node.\n * @remarks\n * The cursor must be put back to its original location before the node is used again.\n */\nfunction borrowCursorFromTreeNodeOrValue(\n\tnode: TreeNode | TreeLeafValue,\n): ITreeCursorSynchronous {\n\tif (isTreeValue(node)) {\n\t\treturn cursorFromVerbose(node, {});\n\t}\n\tconst kernel = getKernel(node);\n\tconst cursor = kernel.getOrCreateInnerNode().borrowCursor();\n\treturn cursor;\n}\n\n/**\n * Borrow a cursor from a field.\n * @remarks\n * The cursor must be put back to its original location before the node is used again.\n */\nfunction borrowFieldCursorFromTreeNodeOrValue(\n\tnode: TreeNode | TreeLeafValue | undefined,\n): ITreeCursorSynchronous {\n\tif (node === undefined) {\n\t\treturn cursorForMapTreeField([]);\n\t}\n\tconst cursor = borrowCursorFromTreeNodeOrValue(node);\n\t// TODO: avoid copy: borrow cursor from field instead.\n\tconst mapTree = mapTreeFromCursor(cursor);\n\treturn cursorForMapTreeField([mapTree]);\n}\n"]}
@@ -20,22 +20,17 @@ export declare class DefaultResubmitMachine<TChange> implements ResubmitMachine<
20
20
  /**
21
21
  * The list of commits (from oldest to most recent) that have been submitted but not sequenced.
22
22
  */
23
- private inFlightQueue;
23
+ private readonly inFlightQueue;
24
24
  /**
25
- * The list of commits (from oldest to most recent) that should be resubmitted.
25
+ * The range of in-flight commits that are currently being resubmitted.
26
+ * Defined only during the resubmit phase.
26
27
  */
27
- private resubmitQueue;
28
+ private pendingResubmitRange;
28
29
  /**
29
- * Represents the index in the `inFlightQueue` array of the most recent in flight commit that has
30
- * undergone rebasing but whose enrichments have not been updated.
31
- * All in-flight commits with an index inferior or equal to this number have stale enrichments.
32
- *
33
- * Is -1 when *any* of the following is true:
34
- * - There are no in-flight commits (i.e., no local commits have been made or they have all been sequenced)
35
- * - None of the in-flight commits have been rebased
36
- * - In-flight commits that have been rebased have all had their enrichments updated
30
+ * The current enrichment version for in-flight commits.
31
+ * Incremented when a peer commit is sequenced.
37
32
  */
38
- private latestInFlightCommitWithStaleEnrichments;
33
+ private currentEnrichment;
39
34
  constructor(
40
35
  /**
41
36
  * A function that can create a rollback for a given change.
@@ -47,6 +42,7 @@ export declare class DefaultResubmitMachine<TChange> implements ResubmitMachine<
47
42
  */
48
43
  tip: ChangeEnricherReadonlyCheckout<TChange>);
49
44
  onCommitSubmitted(commit: GraphCommit<TChange>): void;
45
+ onCommitRollback(commit: GraphCommit<TChange>): void;
50
46
  prepareForResubmit(toResubmit: readonly GraphCommit<TChange>[]): void;
51
47
  peekNextCommit(): GraphCommit<TChange>;
52
48
  get isInResubmitPhase(): boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"defaultResubmitMachine.d.ts","sourceRoot":"","sources":["../../src/shared-tree-core/defaultResubmitMachine.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAGlE,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IACH,OAAO,CAAC,QAAQ,CAAC,GAAG;IA3BrB;;OAEG;IACH,OAAO,CAAC,QAAQ,CAAC,aAAa,CACN;IAExB;;;OAGG;IACH,OAAO,CAAC,oBAAoB,CAAoD;IAEhF;;;OAGG;IACH,OAAO,CAAC,iBAAiB,CAAa;;IAGrC;;OAEG;IACc,YAAY,EAAE,CAAC,MAAM,EAAE,YAAY,CAAC,OAAO,CAAC,KAAK,OAAO;IACzE;;;OAGG;IACc,GAAG,EAAE,8BAA8B,CAAC,OAAO,CAAC;IAGvD,iBAAiB,CAAC,MAAM,EAAE,WAAW,CAAC,OAAO,CAAC,GAAG,IAAI;IAoBrD,gBAAgB,CAAC,MAAM,EAAE,WAAW,CAAC,OAAO,CAAC,GAAG,IAAI;IAQpD,kBAAkB,CAAC,UAAU,EAAE,SAAS,WAAW,CAAC,OAAO,CAAC,EAAE,GAAG,IAAI;IA0ErE,cAAc,IAAI,WAAW,CAAC,OAAO,CAAC;IAY7C,IAAW,iBAAiB,IAAI,OAAO,CAEtC;IAEM,wBAAwB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI;CAUvD"}
@@ -2,7 +2,7 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
- import { assert, oob } from "@fluidframework/core-utils/internal";
5
+ import { assert, DoublyLinkedList, oob, } from "@fluidframework/core-utils/internal";
6
6
  import { disposeSymbol, hasSome } from "../util/index.js";
7
7
  /**
8
8
  * Default implementation of {@link ResubmitMachine}.
@@ -23,39 +23,49 @@ export class DefaultResubmitMachine {
23
23
  /**
24
24
  * The list of commits (from oldest to most recent) that have been submitted but not sequenced.
25
25
  */
26
- this.inFlightQueue = [];
26
+ this.inFlightQueue = new DoublyLinkedList();
27
27
  /**
28
- * The list of commits (from oldest to most recent) that should be resubmitted.
28
+ * The current enrichment version for in-flight commits.
29
+ * Incremented when a peer commit is sequenced.
29
30
  */
30
- this.resubmitQueue = [];
31
- /**
32
- * Represents the index in the `inFlightQueue` array of the most recent in flight commit that has
33
- * undergone rebasing but whose enrichments have not been updated.
34
- * All in-flight commits with an index inferior or equal to this number have stale enrichments.
35
- *
36
- * Is -1 when *any* of the following is true:
37
- * - There are no in-flight commits (i.e., no local commits have been made or they have all been sequenced)
38
- * - None of the in-flight commits have been rebased
39
- * - In-flight commits that have been rebased have all had their enrichments updated
40
- */
41
- this.latestInFlightCommitWithStaleEnrichments = -1;
31
+ this.currentEnrichment = 0;
42
32
  }
43
33
  onCommitSubmitted(commit) {
44
- if (this.isInResubmitPhase) {
45
- const toResubmit = this.resubmitQueue.shift();
46
- assert(toResubmit === commit, 0x981 /* Unexpected commit submitted during resubmit phase */);
34
+ if (this.pendingResubmitRange !== undefined) {
35
+ const toResubmit = this.pendingResubmitRange?.first;
36
+ assert(toResubmit?.data.commit === commit, 0x981 /* Unexpected commit submitted during resubmit phase */);
37
+ // If we are not at the last commit to resubmit, advance the range to the next node.
38
+ // Otherwise, clear the resubmit range as we are done resubmitting.
39
+ if (toResubmit !== this.pendingResubmitRange.last) {
40
+ assert(toResubmit.next !== undefined, 0xbd6 /* must be more in the list */);
41
+ this.pendingResubmitRange.first = toResubmit.next;
42
+ }
43
+ else {
44
+ this.pendingResubmitRange = undefined;
45
+ }
46
+ toResubmit.remove();
47
47
  }
48
- this.inFlightQueue.push(commit);
48
+ this.inFlightQueue.push({ commit, lastEnrichment: this.currentEnrichment });
49
+ }
50
+ onCommitRollback(commit) {
51
+ assert(commit.revision === this.inFlightQueue.last?.data.commit.revision, 0xbd7 /* must rollback latest commit in the in flight queue */);
52
+ this.inFlightQueue.pop();
49
53
  }
50
54
  prepareForResubmit(toResubmit) {
51
55
  assert(!this.isInResubmitPhase, 0x957 /* Invalid resubmit phase start during incomplete resubmit phase */);
52
- assert(toResubmit.length === this.inFlightQueue.length, 0x958 /* Unexpected resubmit of more or fewer commits than are in flight */);
53
- if (this.latestInFlightCommitWithStaleEnrichments === -1) {
54
- // No in-flight commits have stale enrichments, so we can resubmit them as is
55
- this.resubmitQueue = this.inFlightQueue;
56
- this.inFlightQueue = [];
56
+ if (!hasSome(toResubmit)) {
57
+ return;
57
58
  }
58
- else {
59
+ assert(toResubmit.length <= this.inFlightQueue.length, 0xbd8 /* Unexpected resubmit of more commits than are in flight */);
60
+ // Find the first in-flight commit to resubmit.
61
+ const first = this.inFlightQueue.find((v) => v.data.commit.revision === toResubmit[0].revision);
62
+ // Always resubmit to the end of all outstanding ops, but the list may grow during resubmit,
63
+ // so we must track the current end at the start of the phase.
64
+ const last = this.inFlightQueue.last;
65
+ assert(first !== undefined && last !== undefined, 0xbd9 /* there must be inflight commits to resubmit */);
66
+ this.pendingResubmitRange = { first, last };
67
+ // If any in-flight commits have stale enrichments, recompute them.
68
+ if (first.data.lastEnrichment < this.currentEnrichment) {
59
69
  const checkout = this.tip.fork();
60
70
  // Roll back the checkout to the state before the oldest commit
61
71
  for (let iCommit = toResubmit.length - 1; iCommit >= 0; iCommit -= 1) {
@@ -66,46 +76,44 @@ export class DefaultResubmitMachine {
66
76
  // forwards from an earlier fork instead of backwards.
67
77
  checkout.applyTipChange(rollback);
68
78
  }
69
- // Update the enrichments of the stale commits
70
- for (let iCommit = 0; iCommit <= this.latestInFlightCommitWithStaleEnrichments; iCommit += 1) {
71
- const commit = toResubmit[iCommit] ?? oob();
72
- const enrichedChange = checkout.updateChangeEnrichments(commit.change, commit.revision);
73
- const enrichedCommit = { ...commit, change: enrichedChange };
74
- this.resubmitQueue.push(enrichedCommit);
75
- if (iCommit < this.latestInFlightCommitWithStaleEnrichments) {
76
- checkout.applyTipChange(enrichedChange, commit.revision);
79
+ // Update the enrichments of the stale commits in the in-flight queue.
80
+ let current = first;
81
+ for (const commit of toResubmit) {
82
+ assert(current !== undefined, 0xbda /* there must be an inflight commit for each resubmit commit */);
83
+ current.data.commit = commit;
84
+ if (current.data.lastEnrichment < this.currentEnrichment) {
85
+ const enrichedChange = checkout.updateChangeEnrichments(commit.change, commit.revision);
86
+ const enrichedCommit = { ...commit, change: enrichedChange };
87
+ // Optimization: only apply the enriched change if the next commit also needs enrichment.
88
+ if (current.next !== undefined &&
89
+ current.next.data.lastEnrichment < this.currentEnrichment) {
90
+ checkout.applyTipChange(enrichedChange, commit.revision);
91
+ }
92
+ current.data.commit = enrichedCommit;
93
+ current.data.lastEnrichment = this.currentEnrichment;
77
94
  }
78
- this.inFlightQueue.shift();
95
+ current = current.next;
79
96
  }
80
97
  checkout[disposeSymbol]();
81
- // Whatever commits are left do not have stale enrichments
82
- for (const commit of this.inFlightQueue) {
83
- this.resubmitQueue.push(commit);
84
- }
85
- this.inFlightQueue.length = 0;
86
98
  }
87
- this.latestInFlightCommitWithStaleEnrichments = -1;
88
99
  }
89
100
  peekNextCommit() {
90
101
  assert(this.isInResubmitPhase, 0x982 /* No available commit to resubmit outside of resubmit phase */);
91
- assert(hasSome(this.resubmitQueue), 0xa87 /* Expected resubmit queue to be non-empty */);
92
- return this.resubmitQueue[0];
102
+ assert(this.pendingResubmitRange !== undefined, 0xa87 /* Expected resubmit queue to be non-empty */);
103
+ return this.pendingResubmitRange.first.data.commit;
93
104
  }
94
105
  get isInResubmitPhase() {
95
- return this.resubmitQueue.length !== 0;
106
+ return this.pendingResubmitRange !== undefined;
96
107
  }
97
108
  onSequencedCommitApplied(isLocal) {
98
109
  if (isLocal) {
99
110
  // The oldest in-flight commit has been sequenced
100
111
  assert(this.inFlightQueue.length > 0, 0x959 /* Sequencing of unknown local commit */);
101
112
  this.inFlightQueue.shift();
102
- if (this.latestInFlightCommitWithStaleEnrichments >= 0) {
103
- this.latestInFlightCommitWithStaleEnrichments -= 1;
104
- }
105
113
  }
106
114
  else {
107
115
  // A peer commit has been sequenced
108
- this.latestInFlightCommitWithStaleEnrichments = this.inFlightQueue.length - 1;
116
+ this.currentEnrichment++;
109
117
  }
110
118
  }
111
119
  }
@@ -1 +1 @@
1
- {"version":3,"file":"defaultResubmitMachine.js","sourceRoot":"","sources":["../../src/shared-tree-core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AC,aAAa,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;YACjC,CAAC;YACD,IAAI,CAAC,aAAa,CAAC,MAAM,GAAG,CAAC,CAAC;QAC/B,CAAC;QACD,IAAI,CAAC,wCAAwC,GAAG,CAAC,CAAC,CAAC;IACpD,CAAC;IAEM,cAAc;QACpB,MAAM,CACL,IAAI,CAAC,iBAAiB,EACtB,KAAK,CAAC,+DAA+D,CACrE,CAAC;QACF,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,aAAa,CAAC,EAAE,KAAK,CAAC,6CAA6C,CAAC,CAAC;QACzF,OAAO,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC;IAC9B,CAAC;IAED,IAAW,iBAAiB;QAC3B,OAAO,IAAI,CAAC,aAAa,CAAC,MAAM,KAAK,CAAC,CAAC;IACxC,CAAC;IAEM,wBAAwB,CAAC,OAAgB;QAC/C,IAAI,OAAO,EAAE,CAAC;YACb,iDAAiD;YACjD,MAAM,CAAC,IAAI,CAAC,aAAa,CAAC,MAAM,GAAG,CAAC,EAAE,KAAK,CAAC,wCAAwC,CAAC,CAAC;YACtF,IAAI,CAAC,aAAa,CAAC,KAAK,EAAE,CAAC;YAC3B,IAAI,IAAI,CAAC,wCAAwC,IAAI,CAAC,EAAE,CAAC;gBACxD,IAAI,CAAC,wCAAwC,IAAI,CAAC,CAAC;YACpD,CAAC;QACF,CAAC;aAAM,CAAC;YACP,mCAAmC;YACnC,IAAI,CAAC,wCAAwC,GAAG,IAAI,CAAC,aAAa,CAAC,MAAM,GAAG,CAAC,CAAC;QAC/E,CAAC;IACF,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, oob } from \"@fluidframework/core-utils/internal\";\n\nimport type { GraphCommit, TaggedChange } from \"../core/index.js\";\nimport { disposeSymbol, hasSome } from \"../util/index.js\";\n\nimport type { ChangeEnricherReadonlyCheckout, ResubmitMachine } from \"./index.js\";\n\n/**\n * Default implementation of {@link ResubmitMachine}.\n */\nexport class DefaultResubmitMachine<TChange> implements ResubmitMachine<TChange> {\n\t/**\n\t * The list of commits (from oldest to most recent) that have been submitted but not sequenced.\n\t */\n\tprivate inFlightQueue: GraphCommit<TChange>[] = [];\n\n\t/**\n\t * The list of commits (from oldest to most recent) that should be resubmitted.\n\t */\n\tprivate resubmitQueue: GraphCommit<TChange>[] = [];\n\n\t/**\n\t * Represents the index in the `inFlightQueue` array of the most recent in flight commit that has\n\t * undergone rebasing but whose enrichments have not been updated.\n\t * All in-flight commits with an index inferior or equal to this number have stale enrichments.\n\t *\n\t * Is -1 when *any* of the following is true:\n\t * - There are no in-flight commits (i.e., no local commits have been made or they have all been sequenced)\n\t * - None of the in-flight commits have been rebased\n\t * - In-flight commits that have been rebased have all had their enrichments updated\n\t */\n\tprivate latestInFlightCommitWithStaleEnrichments: number = -1;\n\n\tpublic constructor(\n\t\t/**\n\t\t * A function that can create a rollback for a given change.\n\t\t */\n\t\tprivate readonly makeRollback: (change: TaggedChange<TChange>) => TChange,\n\t\t/**\n\t\t * Change enricher that represent the tip of the top-level local branch (i.e., the branch on which in-flight\n\t\t * commits are applied and automatically rebased).\n\t\t */\n\t\tprivate readonly tip: ChangeEnricherReadonlyCheckout<TChange>,\n\t) {}\n\n\tpublic onCommitSubmitted(commit: GraphCommit<TChange>): void {\n\t\tif (this.isInResubmitPhase) {\n\t\t\tconst toResubmit = this.resubmitQueue.shift();\n\t\t\tassert(\n\t\t\t\ttoResubmit === commit,\n\t\t\t\t0x981 /* Unexpected commit submitted during resubmit phase */,\n\t\t\t);\n\t\t}\n\t\tthis.inFlightQueue.push(commit);\n\t}\n\n\tpublic prepareForResubmit(toResubmit: readonly GraphCommit<TChange>[]): void {\n\t\tassert(\n\t\t\t!this.isInResubmitPhase,\n\t\t\t0x957 /* Invalid resubmit phase start during incomplete resubmit phase */,\n\t\t);\n\t\tassert(\n\t\t\ttoResubmit.length === this.inFlightQueue.length,\n\t\t\t0x958 /* Unexpected resubmit of more or fewer commits than are in flight */,\n\t\t);\n\t\tif (this.latestInFlightCommitWithStaleEnrichments === -1) {\n\t\t\t// No in-flight commits have stale enrichments, so we can resubmit them as is\n\t\t\tthis.resubmitQueue = this.inFlightQueue;\n\t\t\tthis.inFlightQueue = [];\n\t\t} else {\n\t\t\tconst checkout = this.tip.fork();\n\t\t\t// Roll back the checkout to the state before the oldest commit\n\t\t\tfor (let iCommit = toResubmit.length - 1; iCommit >= 0; iCommit -= 1) {\n\t\t\t\tconst commit = toResubmit[iCommit] ?? oob();\n\t\t\t\tconst rollback = this.makeRollback(commit);\n\t\t\t\t// WARNING: it's not currently possible to roll back past a schema change (see AB#7265).\n\t\t\t\t// Either we have to make it possible to do so, or this logic will have to change to work\n\t\t\t\t// forwards from an earlier fork instead of backwards.\n\t\t\t\tcheckout.applyTipChange(rollback);\n\t\t\t}\n\t\t\t// Update the enrichments of the stale commits\n\t\t\tfor (\n\t\t\t\tlet iCommit = 0;\n\t\t\t\tiCommit <= this.latestInFlightCommitWithStaleEnrichments;\n\t\t\t\tiCommit += 1\n\t\t\t) {\n\t\t\t\tconst commit = toResubmit[iCommit] ?? oob();\n\t\t\t\tconst enrichedChange = checkout.updateChangeEnrichments(\n\t\t\t\t\tcommit.change,\n\t\t\t\t\tcommit.revision,\n\t\t\t\t);\n\t\t\t\tconst enrichedCommit = { ...commit, change: enrichedChange };\n\t\t\t\tthis.resubmitQueue.push(enrichedCommit);\n\t\t\t\tif (iCommit < this.latestInFlightCommitWithStaleEnrichments) {\n\t\t\t\t\tcheckout.applyTipChange(enrichedChange, commit.revision);\n\t\t\t\t}\n\t\t\t\tthis.inFlightQueue.shift();\n\t\t\t}\n\t\t\tcheckout[disposeSymbol]();\n\t\t\t// Whatever commits are left do not have stale enrichments\n\t\t\tfor (const commit of this.inFlightQueue) {\n\t\t\t\tthis.resubmitQueue.push(commit);\n\t\t\t}\n\t\t\tthis.inFlightQueue.length = 0;\n\t\t}\n\t\tthis.latestInFlightCommitWithStaleEnrichments = -1;\n\t}\n\n\tpublic peekNextCommit(): GraphCommit<TChange> {\n\t\tassert(\n\t\t\tthis.isInResubmitPhase,\n\t\t\t0x982 /* No available commit to resubmit outside of resubmit phase */,\n\t\t);\n\t\tassert(hasSome(this.resubmitQueue), 0xa87 /* Expected resubmit queue to be non-empty */);\n\t\treturn this.resubmitQueue[0];\n\t}\n\n\tpublic get isInResubmitPhase(): boolean {\n\t\treturn this.resubmitQueue.length !== 0;\n\t}\n\n\tpublic onSequencedCommitApplied(isLocal: boolean): void {\n\t\tif (isLocal) {\n\t\t\t// The oldest in-flight commit has been sequenced\n\t\t\tassert(this.inFlightQueue.length > 0, 0x959 /* Sequencing of unknown local commit */);\n\t\t\tthis.inFlightQueue.shift();\n\t\t\tif (this.latestInFlightCommitWithStaleEnrichments >= 0) {\n\t\t\t\tthis.latestInFlightCommitWithStaleEnrichments -= 1;\n\t\t\t}\n\t\t} else {\n\t\t\t// A peer commit has been sequenced\n\t\t\tthis.latestInFlightCommitWithStaleEnrichments = this.inFlightQueue.length - 1;\n\t\t}\n\t}\n}\n"]}
1
+ {"version":3,"file":"defaultResubmitMachine.js","sourceRoot":"","sources":["../../src/shared-tree-core/defaultResubmitMachine.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,MAAM,EACN,gBAAgB,EAChB,GAAG,GAGH,MAAM,qCAAqC,CAAC;AAG7C,OAAO,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAU1D;;GAEG;AACH,MAAM,OAAO,sBAAsB;IAmBlC;IACC;;OAEG;IACc,YAAwD;IACzE;;;OAGG;IACc,GAA4C;QAL5C,iBAAY,GAAZ,YAAY,CAA4C;QAKxD,QAAG,GAAH,GAAG,CAAyC;QA3B9D;;WAEG;QACc,kBAAa,GAC7B,IAAI,gBAAgB,EAAE,CAAC;QAQxB;;;WAGG;QACK,sBAAiB,GAAW,CAAC,CAAC;IAY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AAE,CAAC;YACb,iDAAiD;YACjD,MAAM,CAAC,IAAI,CAAC,aAAa,CAAC,MAAM,GAAG,CAAC,EAAE,KAAK,CAAC,wCAAwC,CAAC,CAAC;YACtF,IAAI,CAAC,aAAa,CAAC,KAAK,EAAE,CAAC;QAC5B,CAAC;aAAM,CAAC;YACP,mCAAmC;YACnC,IAAI,CAAC,iBAAiB,EAAE,CAAC;QAC1B,CAAC;IACF,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\tassert,\n\tDoublyLinkedList,\n\toob,\n\ttype ListNode,\n\ttype ListNodeRange,\n} from \"@fluidframework/core-utils/internal\";\n\nimport type { GraphCommit, TaggedChange } from \"../core/index.js\";\nimport { disposeSymbol, hasSome } from \"../util/index.js\";\n\nimport type { ChangeEnricherReadonlyCheckout, ResubmitMachine } from \"./index.js\";\n\ninterface PendingChange<TChange> {\n\tcommit: GraphCommit<TChange>;\n\tlastEnrichment: number;\n}\ntype PendingChangeNode<TChange> = ListNode<PendingChange<TChange>>;\n\n/**\n * Default implementation of {@link ResubmitMachine}.\n */\nexport class DefaultResubmitMachine<TChange> implements ResubmitMachine<TChange> {\n\t/**\n\t * The list of commits (from oldest to most recent) that have been submitted but not sequenced.\n\t */\n\tprivate readonly inFlightQueue: DoublyLinkedList<PendingChange<TChange>> =\n\t\tnew DoublyLinkedList();\n\n\t/**\n\t * The range of in-flight commits that are currently being resubmitted.\n\t * Defined only during the resubmit phase.\n\t */\n\tprivate pendingResubmitRange: ListNodeRange<PendingChange<TChange>> | undefined;\n\n\t/**\n\t * The current enrichment version for in-flight commits.\n\t * Incremented when a peer commit is sequenced.\n\t */\n\tprivate currentEnrichment: number = 0;\n\n\tpublic constructor(\n\t\t/**\n\t\t * A function that can create a rollback for a given change.\n\t\t */\n\t\tprivate readonly makeRollback: (change: TaggedChange<TChange>) => TChange,\n\t\t/**\n\t\t * Change enricher that represent the tip of the top-level local branch (i.e., the branch on which in-flight\n\t\t * commits are applied and automatically rebased).\n\t\t */\n\t\tprivate readonly tip: ChangeEnricherReadonlyCheckout<TChange>,\n\t) {}\n\n\tpublic onCommitSubmitted(commit: GraphCommit<TChange>): void {\n\t\tif (this.pendingResubmitRange !== undefined) {\n\t\t\tconst toResubmit = this.pendingResubmitRange?.first;\n\t\t\tassert(\n\t\t\t\ttoResubmit?.data.commit === commit,\n\t\t\t\t0x981 /* Unexpected commit submitted during resubmit phase */,\n\t\t\t);\n\t\t\t// If we are not at the last commit to resubmit, advance the range to the next node.\n\t\t\t// Otherwise, clear the resubmit range as we are done resubmitting.\n\t\t\tif (toResubmit !== this.pendingResubmitRange.last) {\n\t\t\t\tassert(toResubmit.next !== undefined, 0xbd6 /* must be more in the list */);\n\t\t\t\tthis.pendingResubmitRange.first = toResubmit.next;\n\t\t\t} else {\n\t\t\t\tthis.pendingResubmitRange = undefined;\n\t\t\t}\n\t\t\ttoResubmit.remove();\n\t\t}\n\t\tthis.inFlightQueue.push({ commit, lastEnrichment: this.currentEnrichment });\n\t}\n\n\tpublic onCommitRollback(commit: GraphCommit<TChange>): void {\n\t\tassert(\n\t\t\tcommit.revision === this.inFlightQueue.last?.data.commit.revision,\n\t\t\t0xbd7 /* must rollback latest commit in the in flight queue */,\n\t\t);\n\t\tthis.inFlightQueue.pop();\n\t}\n\n\tpublic prepareForResubmit(toResubmit: readonly GraphCommit<TChange>[]): void {\n\t\tassert(\n\t\t\t!this.isInResubmitPhase,\n\t\t\t0x957 /* Invalid resubmit phase start during incomplete resubmit phase */,\n\t\t);\n\n\t\tif (!hasSome(toResubmit)) {\n\t\t\treturn;\n\t\t}\n\n\t\tassert(\n\t\t\ttoResubmit.length <= this.inFlightQueue.length,\n\t\t\t0xbd8 /* Unexpected resubmit of more commits than are in flight */,\n\t\t);\n\n\t\t// Find the first in-flight commit to resubmit.\n\t\tconst first = this.inFlightQueue.find(\n\t\t\t(v) => v.data.commit.revision === toResubmit[0].revision,\n\t\t);\n\t\t// Always resubmit to the end of all outstanding ops, but the list may grow during resubmit,\n\t\t// so we must track the current end at the start of the phase.\n\t\tconst last = this.inFlightQueue.last;\n\t\tassert(\n\t\t\tfirst !== undefined && last !== undefined,\n\t\t\t0xbd9 /* there must be inflight commits to resubmit */,\n\t\t);\n\n\t\tthis.pendingResubmitRange = { first, last };\n\t\t// If any in-flight commits have stale enrichments, recompute them.\n\t\tif (first.data.lastEnrichment < this.currentEnrichment) {\n\t\t\tconst checkout = this.tip.fork();\n\n\t\t\t// Roll back the checkout to the state before the oldest commit\n\t\t\tfor (let iCommit = toResubmit.length - 1; iCommit >= 0; iCommit -= 1) {\n\t\t\t\tconst commit = toResubmit[iCommit] ?? oob();\n\t\t\t\tconst rollback = this.makeRollback(commit);\n\t\t\t\t// WARNING: it's not currently possible to roll back past a schema change (see AB#7265).\n\t\t\t\t// Either we have to make it possible to do so, or this logic will have to change to work\n\t\t\t\t// forwards from an earlier fork instead of backwards.\n\t\t\t\tcheckout.applyTipChange(rollback);\n\t\t\t}\n\n\t\t\t// Update the enrichments of the stale commits in the in-flight queue.\n\t\t\tlet current: PendingChangeNode<TChange> | undefined = first;\n\t\t\tfor (const commit of toResubmit) {\n\t\t\t\tassert(\n\t\t\t\t\tcurrent !== undefined,\n\t\t\t\t\t0xbda /* there must be an inflight commit for each resubmit commit */,\n\t\t\t\t);\n\t\t\t\tcurrent.data.commit = commit;\n\t\t\t\tif (current.data.lastEnrichment < this.currentEnrichment) {\n\t\t\t\t\tconst enrichedChange = checkout.updateChangeEnrichments(\n\t\t\t\t\t\tcommit.change,\n\t\t\t\t\t\tcommit.revision,\n\t\t\t\t\t);\n\t\t\t\t\tconst enrichedCommit = { ...commit, change: enrichedChange };\n\n\t\t\t\t\t// Optimization: only apply the enriched change if the next commit also needs enrichment.\n\t\t\t\t\tif (\n\t\t\t\t\t\tcurrent.next !== undefined &&\n\t\t\t\t\t\tcurrent.next.data.lastEnrichment < this.currentEnrichment\n\t\t\t\t\t) {\n\t\t\t\t\t\tcheckout.applyTipChange(enrichedChange, commit.revision);\n\t\t\t\t\t}\n\n\t\t\t\t\tcurrent.data.commit = enrichedCommit;\n\t\t\t\t\tcurrent.data.lastEnrichment = this.currentEnrichment;\n\t\t\t\t}\n\t\t\t\tcurrent = current.next;\n\t\t\t}\n\t\t\tcheckout[disposeSymbol]();\n\t\t}\n\t}\n\n\tpublic peekNextCommit(): GraphCommit<TChange> {\n\t\tassert(\n\t\t\tthis.isInResubmitPhase,\n\t\t\t0x982 /* No available commit to resubmit outside of resubmit phase */,\n\t\t);\n\t\tassert(\n\t\t\tthis.pendingResubmitRange !== undefined,\n\t\t\t0xa87 /* Expected resubmit queue to be non-empty */,\n\t\t);\n\t\treturn this.pendingResubmitRange.first.data.commit;\n\t}\n\n\tpublic get isInResubmitPhase(): boolean {\n\t\treturn this.pendingResubmitRange !== undefined;\n\t}\n\n\tpublic onSequencedCommitApplied(isLocal: boolean): void {\n\t\tif (isLocal) {\n\t\t\t// The oldest in-flight commit has been sequenced\n\t\t\tassert(this.inFlightQueue.length > 0, 0x959 /* Sequencing of unknown local commit */);\n\t\t\tthis.inFlightQueue.shift();\n\t\t} else {\n\t\t\t// A peer commit has been sequenced\n\t\t\tthis.currentEnrichment++;\n\t\t}\n\t}\n}\n"]}
@@ -31,6 +31,12 @@ export interface ResubmitMachine<TChange> {
31
31
  * @param commit - the (enriched) commit (re)submitted. Not mutated.
32
32
  */
33
33
  onCommitSubmitted(commit: GraphCommit<TChange>): void;
34
+ /**
35
+ * Must be called on a commit after rollback, so it can be removed
36
+ * as it will never be (re)submitted.
37
+ * @param commit - The commit that was rolled back
38
+ */
39
+ onCommitRollback(commit: GraphCommit<TChange>): void;
34
40
  /**
35
41
  * Must be called after a sequenced commit is applied.
36
42
  * Note that this may be called multiples times in a row after a number of sequenced commits have been applied
@@ -1 +1 @@
1
- {"version":3,"file":"resubmitMachine.d.ts","sourceRoot":"","sources":["../../src/shared-tree-core/resubmitMachine.ts"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@ -1 +1 @@
1
- {"version":3,"file":"resubmitMachine.js","sourceRoot":"","sources":["../../src/shared-tree-core/resubmitMachine.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { GraphCommit } from \"../core/index.js\";\n\n/**\n * Encapsulates a state machine that can be used by a {@link SharedTreeCore} manage resubmit phases,\n * especially dealing with the proper updating of enrichments on resubmitted commits.\n */\nexport interface ResubmitMachine<TChange> {\n\t/**\n\t * Must be called before calling `enrichCommit` as part of a resubmit phase.\n\t * @param toResubmit - the commits that will be resubmitted (from oldest to newest).\n\t * This must be the most rebased version of these commits (i.e., rebased over all known concurrent edits)\n\t * as opposed to the version which was last submitted.\n\t * `toResubmit` can be safely mutated by the caller after this call returns.\n\t */\n\tprepareForResubmit(toResubmit: readonly GraphCommit<TChange>[]): void;\n\n\t/**\n\t * @returns the next commit that should be resubmitted.\n\t *\n\t * Throws when invoked outside of a resubmit phase.\n\t */\n\tpeekNextCommit(): GraphCommit<TChange>;\n\n\t/**\n\t * Is true iff the commit enricher is currently in a resubmit phase.\n\t */\n\treadonly isInResubmitPhase: boolean;\n\n\t/**\n\t * Must be when a commit is submitted or resubmitted.\n\t * @param commit - the (enriched) commit (re)submitted. Not mutated.\n\t */\n\tonCommitSubmitted(commit: GraphCommit<TChange>): void;\n\n\t/**\n\t * Must be called after a sequenced commit is applied.\n\t * Note that this may be called multiples times in a row after a number of sequenced commits have been applied\n\t * (as opposed to always being called before the next sequenced commit is applied).\n\t * @param isLocal - whether the sequenced commit was generated by the local session.\n\t */\n\tonSequencedCommitApplied(isLocal: boolean): void;\n}\n"]}
1
+ {"version":3,"file":"resubmitMachine.js","sourceRoot":"","sources":["../../src/shared-tree-core/resubmitMachine.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { GraphCommit } from \"../core/index.js\";\n\n/**\n * Encapsulates a state machine that can be used by a {@link SharedTreeCore} manage resubmit phases,\n * especially dealing with the proper updating of enrichments on resubmitted commits.\n */\nexport interface ResubmitMachine<TChange> {\n\t/**\n\t * Must be called before calling `enrichCommit` as part of a resubmit phase.\n\t * @param toResubmit - the commits that will be resubmitted (from oldest to newest).\n\t * This must be the most rebased version of these commits (i.e., rebased over all known concurrent edits)\n\t * as opposed to the version which was last submitted.\n\t * `toResubmit` can be safely mutated by the caller after this call returns.\n\t */\n\tprepareForResubmit(toResubmit: readonly GraphCommit<TChange>[]): void;\n\n\t/**\n\t * @returns the next commit that should be resubmitted.\n\t *\n\t * Throws when invoked outside of a resubmit phase.\n\t */\n\tpeekNextCommit(): GraphCommit<TChange>;\n\n\t/**\n\t * Is true iff the commit enricher is currently in a resubmit phase.\n\t */\n\treadonly isInResubmitPhase: boolean;\n\n\t/**\n\t * Must be when a commit is submitted or resubmitted.\n\t * @param commit - the (enriched) commit (re)submitted. Not mutated.\n\t */\n\tonCommitSubmitted(commit: GraphCommit<TChange>): void;\n\n\t/**\n\t * Must be called on a commit after rollback, so it can be removed\n\t * as it will never be (re)submitted.\n\t * @param commit - The commit that was rolled back\n\t */\n\tonCommitRollback(commit: GraphCommit<TChange>): void;\n\n\t/**\n\t * Must be called after a sequenced commit is applied.\n\t * Note that this may be called multiples times in a row after a number of sequenced commits have been applied\n\t * (as opposed to always being called before the next sequenced commit is applied).\n\t * @param isLocal - whether the sequenced commit was generated by the local session.\n\t */\n\tonSequencedCommitApplied(isLocal: boolean): void;\n}\n"]}
@@ -79,6 +79,7 @@ export declare class SharedTreeCore<TEditor extends ChangeFamilyEditor, TChange>
79
79
  getLocalBranch(): SharedTreeBranch<TEditor, TChange>;
80
80
  didAttach(): void;
81
81
  reSubmitCore(content: JsonCompatibleReadOnly, localOpMetadata: unknown): void;
82
+ rollback(content: JsonCompatibleReadOnly, localOpMetadata: unknown): void;
82
83
  applyStashedOp(content: JsonCompatibleReadOnly): void;
83
84
  }
84
85
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"sharedTreeCore.d.ts","sourceRoot":"","sources":["../../src/shared-tree-core/sharedTreeCore.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AAE5F,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,gDAAgD,CAAC;AAC7F,OAAO,KAAK,EAAE,aAAa,EAAa,MAAM,+BAA+B,CAAC;AAC9E,OAAO,KAAK,EACX,sCAAsC,EACtC,yBAAyB,EACzB,qBAAqB,EACrB,iBAAiB,EACjB,MAAM,8CAA8C,CAAC;AAEtD,OAAO,KAAK,EACX,YAAY,EACZ,gBAAgB,EAChB,MAAM,6CAA6C,CAAC;AAGrD,OAAO,KAAK,EAAE,aAAa,EAAc,MAAM,mBAAmB,CAAC;AACnE,OAAO,EACN,KAAK,YAAY,EACjB,KAAK,kBAAkB,EAEvB,KAAK,WAAW,EAChB,KAAK,WAAW,EAEhB,KAAK,eAAe,EACpB,KAAK,YAAY,EAEjB,KAAK,0BAA0B,EAC/B,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACN,KAAK,sBAAsB,EAE3B,KAAK,SAAS,EACd,KAAK,aAAa,EAGlB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,EAAE,KAAK,8BAA8B,EAAsB,MAAM,qBAAqB,CAAC;AAQ9F,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAK5D,MAAM,WAAW,yBAAyB;IACzC,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,uBAAwB,SAAQ,eAAe;IAC/D,MAAM,EAAE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EAAE,OAAO,CAAC;QACnB,UAAU,CAAC,EAAE,OAAO,CAAC;QACrB,gBAAgB,CAAC,EAAE,iBAAiB,CAAC;QACrC,yBAAyB,CAAC,EAAE,sCAAsC,CAAC;KACnE,GAAG,qBAAqB,CAAC;IAE1B;;;;;OAKG;IACH,IAAI,CAAC,OAAO,EAAE,sBAAsB,EAAE,KAAK,EAAE,oBAAoB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAClF;AAED;;;GAGG;AACH,MAAM,MAAM,yBAAyB,GAAG,CAAC,QAAQ,EAAE,OAAO,KAAK,MAAM,CAAC;AAEtE;;GAEG;AACH,MAAM,MAAM,oBAAoB,GAAG,CAAC,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC"}
@@ -255,11 +255,12 @@ let SharedTreeCore = (() => {
255
255
  const { commit: { revision }, } = this.messageCodec.decode(this.serializer.decode(content), {
256
256
  idCompressor: this.idCompressor,
257
257
  });
258
- const [commit] = this.editManager.findLocalCommit(revision);
259
258
  // If a resubmit phase is not already in progress, then this must be the first commit of a new resubmit phase.
260
259
  if (this.resubmitMachine.isInResubmitPhase === false) {
261
- const toResubmit = this.editManager.getLocalCommits();
262
- assert(commit === toResubmit[0], 0x95d /* Resubmit phase should start with the oldest local commit */);
260
+ const localCommits = this.editManager.getLocalCommits();
261
+ const revisionIndex = localCommits.findIndex((c) => c.revision === revision);
262
+ assert(revisionIndex >= 0, 0xbdb /* revision must exist in local commits */);
263
+ const toResubmit = localCommits.slice(revisionIndex);
263
264
  this.resubmitMachine.prepareForResubmit(toResubmit);
264
265
  }
265
266
  assert(isClonableSchemaPolicy(localOpMetadata), 0x95e /* Local metadata must contain schema and policy. */);
@@ -267,6 +268,18 @@ let SharedTreeCore = (() => {
267
268
  const enrichedCommit = this.resubmitMachine.peekNextCommit();
268
269
  this.submitCommit(enrichedCommit, localOpMetadata, true);
269
270
  }
271
+ rollback(content, localOpMetadata) {
272
+ // Empty context object is passed in, as our decode function is schema-agnostic.
273
+ const { commit: { revision }, } = this.messageCodec.decode(this.serializer.decode(content), {
274
+ idCompressor: this.idCompressor,
275
+ });
276
+ const [commit] = this.editManager.findLocalCommit(revision);
277
+ const { parent } = commit;
278
+ assert(parent !== undefined, 0xbdc /* must have parent */);
279
+ const [precedingCommit] = this.editManager.findLocalCommit(parent.revision);
280
+ this.editManager.localBranch.removeAfter(precedingCommit);
281
+ this.resubmitMachine.onCommitRollback(commit);
282
+ }
270
283
  applyStashedOp(content) {
271
284
  // Empty context object is passed in, as our decode function is schema-agnostic.
272
285
  const { commit: { revision, change }, } = this.messageCodec.decode(content, { idCompressor: this.idCompressor });