@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
@@ -185,8 +185,6 @@ export const storedEmptyFieldSchema: TreeFieldStoredSchema = {
185
185
  */
186
186
  export const identifierFieldKindIdentifier = "Identifier";
187
187
 
188
- /**
189
- */
190
188
  export abstract class TreeNodeStoredSchema {
191
189
  protected _typeCheck!: MakeNominal;
192
190
 
@@ -213,8 +211,6 @@ export abstract class TreeNodeStoredSchema {
213
211
  public abstract getFieldSchema(field: FieldKey): TreeFieldStoredSchema;
214
212
  }
215
213
 
216
- /**
217
- */
218
214
  export class ObjectNodeStoredSchema extends TreeNodeStoredSchema {
219
215
  /**
220
216
  * @param objectNodeFields -
@@ -272,8 +268,6 @@ export class ObjectNodeStoredSchema extends TreeNodeStoredSchema {
272
268
  }
273
269
  }
274
270
 
275
- /**
276
- */
277
271
  export class MapNodeStoredSchema extends TreeNodeStoredSchema {
278
272
  /**
279
273
  * @param mapFields -
@@ -306,8 +300,6 @@ export class MapNodeStoredSchema extends TreeNodeStoredSchema {
306
300
  }
307
301
  }
308
302
 
309
- /**
310
- */
311
303
  export class LeafNodeStoredSchema extends TreeNodeStoredSchema {
312
304
  /**
313
305
  * @param leafValue -
@@ -9,8 +9,6 @@ import type { TreeNodeSchemaIdentifier, TreeStoredSchema } from "../schema-store
9
9
  * APIs for applying `view schema` to documents.
10
10
  */
11
11
 
12
- /**
13
- */
14
12
  export interface TreeAdapter {
15
13
  readonly output: TreeNodeSchemaIdentifier;
16
14
  readonly input: TreeNodeSchemaIdentifier;
@@ -312,8 +312,6 @@ export interface PathRootPrefix {
312
312
  indexOffset?: number;
313
313
  }
314
314
 
315
- /**
316
- */
317
315
  export const enum CursorLocationType {
318
316
  /**
319
317
  * Can iterate through nodes in a field.
@@ -158,8 +158,6 @@ export interface DetachedNodeId {
158
158
  readonly minor: number;
159
159
  }
160
160
 
161
- /**
162
- */
163
161
  export type FieldMap = ReadonlyMap<FieldKey, FieldChanges>;
164
162
 
165
163
  /**
@@ -18,8 +18,6 @@ import type {
18
18
  ValueSchema,
19
19
  } from "../schema-stored/index.js";
20
20
 
21
- /**
22
- */
23
21
  export type TreeType = TreeNodeSchemaIdentifier;
24
22
 
25
23
  /**
@@ -43,8 +41,6 @@ export const EmptyKey: FieldKey = brand("");
43
41
  */
44
42
  export const rootFieldKey: FieldKey = brand("rootFieldKey");
45
43
 
46
- /**
47
- */
48
44
  export const rootField = keyAsDetachedField(rootFieldKey);
49
45
 
50
46
  /**
@@ -410,8 +410,6 @@ export class DefaultEditBuilder implements ChangeFamilyEditor, IDefaultEditBuild
410
410
  }
411
411
  }
412
412
 
413
- /**
414
- */
415
413
  export interface ValueFieldEditBuilder<TContent> {
416
414
  /**
417
415
  * Issues a change which replaces the current newContent of the field with `newContent`.
@@ -421,8 +419,6 @@ export interface ValueFieldEditBuilder<TContent> {
421
419
  set(newContent: TContent): void;
422
420
  }
423
421
 
424
- /**
425
- */
426
422
  export interface OptionalFieldEditBuilder<TContent> {
427
423
  /**
428
424
  * Issues a change which replaces the current newContent of the field with `newContent`
@@ -257,20 +257,10 @@ export const fieldKinds: ReadonlyMap<FieldKindIdentifier, FieldKindWithEditor> =
257
257
  // TODO: Find a way to make docs like {@inheritDoc required} work in vscode.
258
258
  // TODO: ensure thy work in generated docs.
259
259
  // TODO: add these comments to the rest of the cases below.
260
- /**
261
- */
262
260
  export interface Required extends FlexFieldKind<"Value", Multiplicity.Single> {}
263
- /**
264
- */
265
261
  export interface Optional extends FlexFieldKind<"Optional", Multiplicity.Optional> {}
266
- /**
267
- */
268
262
  export interface Sequence extends FlexFieldKind<"Sequence", Multiplicity.Sequence> {}
269
- /**
270
- */
271
263
  export interface Identifier extends FlexFieldKind<"Identifier", Multiplicity.Single> {}
272
- /**
273
- */
274
264
  export interface Forbidden
275
265
  extends FlexFieldKind<typeof forbiddenFieldKindIdentifier, Multiplicity.Forbidden> {}
276
266
 
@@ -47,8 +47,6 @@ export function isFlexTreeNode(t: unknown): t is FlexTreeNode {
47
47
  return isFlexTreeEntity(t) && t[flexTreeMarker] === FlexTreeEntityKind.Node;
48
48
  }
49
49
 
50
- /**
51
- */
52
50
  export enum FlexTreeEntityKind {
53
51
  Node,
54
52
  Field,
@@ -44,8 +44,6 @@ export function getFirstFromCrossFieldMap<T>(
44
44
  return map.getFirst({ revision, localId: id }, count);
45
45
  }
46
46
 
47
- /**
48
- */
49
47
  export enum CrossFieldTarget {
50
48
  Source,
51
49
  Destination,
@@ -216,19 +216,13 @@ export interface FieldEditor<TChangeset> {
216
216
  */
217
217
  export type ToDelta = (child: NodeId) => DeltaFieldMap;
218
218
 
219
- /**
220
- */
221
219
  export type NodeChangeInverter = (change: NodeId) => NodeId;
222
220
 
223
- /**
224
- */
225
221
  export enum NodeAttachState {
226
222
  Attached,
227
223
  Detached,
228
224
  }
229
225
 
230
- /**
231
- */
232
226
  export type NodeChangeRebaser = (
233
227
  change: NodeId | undefined,
234
228
  baseChange: NodeId | undefined,
@@ -239,15 +233,11 @@ export type NodeChangeRebaser = (
239
233
  state?: NodeAttachState,
240
234
  ) => NodeId | undefined;
241
235
 
242
- /**
243
- */
244
236
  export type NodeChangeComposer = (
245
237
  change1: NodeId | undefined,
246
238
  change2: NodeId | undefined,
247
239
  ) => NodeId;
248
240
 
249
- /**
250
- */
251
241
  export type NodeChangePruner = (change: NodeId) => NodeId | undefined;
252
242
 
253
243
  /**
@@ -2285,8 +2285,6 @@ function newCrossFieldTable<T>(): CrossFieldTable<T> {
2285
2285
  };
2286
2286
  }
2287
2287
 
2288
- /**
2289
- */
2290
2288
  interface ConstraintState {
2291
2289
  violationCount: number;
2292
2290
  }
@@ -2913,8 +2911,6 @@ function buildModularChangesetFromNode(props: {
2913
2911
  });
2914
2912
  }
2915
2913
 
2916
- /**
2917
- */
2918
2914
  export interface FieldEditDescription {
2919
2915
  type: "field";
2920
2916
  field: FieldUpPath;
@@ -2923,16 +2919,12 @@ export interface FieldEditDescription {
2923
2919
  revision: RevisionTag;
2924
2920
  }
2925
2921
 
2926
- /**
2927
- */
2928
2922
  export interface GlobalEditDescription {
2929
2923
  type: "global";
2930
2924
  revision: RevisionTag;
2931
2925
  builds?: ChangeAtomIdBTree<TreeChunk>;
2932
2926
  }
2933
2927
 
2934
- /**
2935
- */
2936
2928
  export type EditDescription = FieldEditDescription | GlobalEditDescription;
2937
2929
 
2938
2930
  function getRevInfoFromTaggedChanges(changes: TaggedChange<ModularChangeset>[]): {
@@ -17,8 +17,6 @@ import type { TreeChunk } from "../chunked-forest/index.js";
17
17
 
18
18
  import type { CrossFieldTarget } from "./crossFieldQueries.js";
19
19
 
20
- /**
21
- */
22
20
  export interface ModularChangeset extends HasFieldChanges {
23
21
  /**
24
22
  * The numerically highest `ChangesetLocalId` used in this changeset.
@@ -110,8 +108,6 @@ export interface FieldId {
110
108
  readonly field: FieldKey;
111
109
  }
112
110
 
113
- /**
114
- */
115
111
  export interface NodeExistsConstraint {
116
112
  violated: boolean;
117
113
  }
@@ -128,23 +124,15 @@ export interface NodeChangeset extends HasFieldChanges {
128
124
 
129
125
  export type NodeId = ChangeAtomId;
130
126
 
131
- /**
132
- */
133
127
  export interface HasFieldChanges {
134
128
  fieldChanges?: FieldChangeMap;
135
129
  }
136
130
 
137
- /**
138
- */
139
131
  export type FieldChangeMap = Map<FieldKey, FieldChange>;
140
132
 
141
- /**
142
- */
143
133
  export interface FieldChange {
144
134
  fieldKind: FieldKindIdentifier;
145
135
  change: FieldChangeset;
146
136
  }
147
137
 
148
- /**
149
- */
150
138
  export type FieldChangeset = Brand<unknown, "FieldChangeset">;
@@ -24,8 +24,6 @@ export interface HasMoveId {
24
24
  id: MoveId;
25
25
  }
26
26
 
27
- /**
28
- */
29
27
  export interface CellId extends ChangeAtomId {}
30
28
 
31
29
  /**
package/src/index.ts CHANGED
@@ -130,6 +130,7 @@ export {
130
130
  type FieldSchemaAlphaUnsafe,
131
131
  type ArrayNodeCustomizableSchemaUnsafe,
132
132
  type MapNodeCustomizableSchemaUnsafe,
133
+ type TreeRecordNodeUnsafe,
133
134
  // System types (not in Internal types for various reasons, like doc links or cannot be named errors).
134
135
  type typeSchemaSymbol,
135
136
  type TreeNodeSchemaNonClass,
@@ -196,6 +197,8 @@ export {
196
197
  type JsonRefPath,
197
198
  type JsonSchemaType,
198
199
  type JsonLeafSchemaType,
200
+ type JsonRecordNodeSchema,
201
+ type JsonStringKeyPatternProperties,
199
202
  getJsonSchema,
200
203
  type LazyItem,
201
204
  type Unenforced,
@@ -209,6 +212,7 @@ export {
209
212
  type SimpleArrayNodeSchema,
210
213
  type SimpleObjectNodeSchema,
211
214
  type SimpleObjectFieldSchema,
215
+ type SimpleRecordNodeSchema,
212
216
  normalizeAllowedTypes,
213
217
  getSimpleSchema,
214
218
  type ReadonlyArrayNode,
@@ -249,6 +253,11 @@ export {
249
253
  type ObjectFromSchemaRecord,
250
254
  type ValidateRecursiveSchemaTemplate,
251
255
  type FixRecursiveRecursionLimit,
256
+ RecordNodeSchema,
257
+ type RecordNodeCustomizableSchema,
258
+ type RecordNodeInsertableData,
259
+ type RecordNodePojoEmulationSchema,
260
+ type TreeRecordNode,
252
261
  } from "./simple-tree/index.js";
253
262
  export {
254
263
  SharedTree,
@@ -3,7 +3,7 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
 
6
- import { SchemaFactory } from "./simple-tree/index.js";
6
+ import { SchemaFactory, SchemaFactoryAlpha } from "./simple-tree/index.js";
7
7
  import type {
8
8
  AllowedTypes,
9
9
  FixRecursiveArraySchema,
@@ -22,7 +22,7 @@ import type {
22
22
  // #endregion
23
23
  } from "./simple-tree/index.js";
24
24
 
25
- const sf = new SchemaFactory("com.fluidframework.json");
25
+ const sf = new SchemaFactoryAlpha("com.fluidframework.json");
26
26
 
27
27
  /**
28
28
  * Utilities for storing JSON data in {@link TreeNode}s.
@@ -80,7 +80,7 @@ export namespace JsonAsTree {
80
80
  * Do not use. Exists only as a workaround for {@link https://github.com/microsoft/TypeScript/issues/59550} and {@link https://github.com/microsoft/rushstack/issues/4429}.
81
81
  * @system @alpha
82
82
  */
83
- export const _APIExtractorWorkaroundObjectBase = sf.mapRecursive("object", Tree);
83
+ export const _APIExtractorWorkaroundObjectBase = sf.recordRecursive("object", Tree);
84
84
 
85
85
  /**
86
86
  * Arbitrary JSON object as a {@link TreeNode}.
@@ -6,4 +6,4 @@
6
6
  */
7
7
 
8
8
  export const pkgName = "@fluidframework/tree";
9
- export const pkgVersion = "2.43.0";
9
+ export const pkgVersion = "2.50.0";
@@ -592,6 +592,7 @@ export const TreeAlpha: TreeAlpha = {
592
592
  return undefined;
593
593
  }
594
594
  // Fall through
595
+ case NodeKind.Record:
595
596
  case NodeKind.Object: {
596
597
  let storedKey: string | number = propertyKey;
597
598
  if (isObjectNodeSchema(schema)) {
@@ -643,7 +644,8 @@ export const TreeAlpha: TreeAlpha = {
643
644
  }
644
645
  break;
645
646
  }
646
- case NodeKind.Map: {
647
+ case NodeKind.Map:
648
+ case NodeKind.Record: {
647
649
  for (const [key, flexField] of flexNode.fields) {
648
650
  const childTreeNode = tryGetTreeNodeForField(flexField);
649
651
  if (childTreeNode !== undefined) {
@@ -3,13 +3,25 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
 
6
- import { assert, oob } from "@fluidframework/core-utils/internal";
6
+ import {
7
+ assert,
8
+ DoublyLinkedList,
9
+ oob,
10
+ type ListNode,
11
+ type ListNodeRange,
12
+ } from "@fluidframework/core-utils/internal";
7
13
 
8
14
  import type { GraphCommit, TaggedChange } from "../core/index.js";
9
15
  import { disposeSymbol, hasSome } from "../util/index.js";
10
16
 
11
17
  import type { ChangeEnricherReadonlyCheckout, ResubmitMachine } from "./index.js";
12
18
 
19
+ interface PendingChange<TChange> {
20
+ commit: GraphCommit<TChange>;
21
+ lastEnrichment: number;
22
+ }
23
+ type PendingChangeNode<TChange> = ListNode<PendingChange<TChange>>;
24
+
13
25
  /**
14
26
  * Default implementation of {@link ResubmitMachine}.
15
27
  */
@@ -17,24 +29,20 @@ export class DefaultResubmitMachine<TChange> implements ResubmitMachine<TChange>
17
29
  /**
18
30
  * The list of commits (from oldest to most recent) that have been submitted but not sequenced.
19
31
  */
20
- private inFlightQueue: GraphCommit<TChange>[] = [];
32
+ private readonly inFlightQueue: DoublyLinkedList<PendingChange<TChange>> =
33
+ new DoublyLinkedList();
21
34
 
22
35
  /**
23
- * The list of commits (from oldest to most recent) that should be resubmitted.
36
+ * The range of in-flight commits that are currently being resubmitted.
37
+ * Defined only during the resubmit phase.
24
38
  */
25
- private resubmitQueue: GraphCommit<TChange>[] = [];
39
+ private pendingResubmitRange: ListNodeRange<PendingChange<TChange>> | undefined;
26
40
 
27
41
  /**
28
- * Represents the index in the `inFlightQueue` array of the most recent in flight commit that has
29
- * undergone rebasing but whose enrichments have not been updated.
30
- * All in-flight commits with an index inferior or equal to this number have stale enrichments.
31
- *
32
- * Is -1 when *any* of the following is true:
33
- * - There are no in-flight commits (i.e., no local commits have been made or they have all been sequenced)
34
- * - None of the in-flight commits have been rebased
35
- * - In-flight commits that have been rebased have all had their enrichments updated
42
+ * The current enrichment version for in-flight commits.
43
+ * Incremented when a peer commit is sequenced.
36
44
  */
37
- private latestInFlightCommitWithStaleEnrichments: number = -1;
45
+ private currentEnrichment: number = 0;
38
46
 
39
47
  public constructor(
40
48
  /**
@@ -49,14 +57,31 @@ export class DefaultResubmitMachine<TChange> implements ResubmitMachine<TChange>
49
57
  ) {}
50
58
 
51
59
  public onCommitSubmitted(commit: GraphCommit<TChange>): void {
52
- if (this.isInResubmitPhase) {
53
- const toResubmit = this.resubmitQueue.shift();
60
+ if (this.pendingResubmitRange !== undefined) {
61
+ const toResubmit = this.pendingResubmitRange?.first;
54
62
  assert(
55
- toResubmit === commit,
63
+ toResubmit?.data.commit === commit,
56
64
  0x981 /* Unexpected commit submitted during resubmit phase */,
57
65
  );
66
+ // If we are not at the last commit to resubmit, advance the range to the next node.
67
+ // Otherwise, clear the resubmit range as we are done resubmitting.
68
+ if (toResubmit !== this.pendingResubmitRange.last) {
69
+ assert(toResubmit.next !== undefined, 0xbd6 /* must be more in the list */);
70
+ this.pendingResubmitRange.first = toResubmit.next;
71
+ } else {
72
+ this.pendingResubmitRange = undefined;
73
+ }
74
+ toResubmit.remove();
58
75
  }
59
- this.inFlightQueue.push(commit);
76
+ this.inFlightQueue.push({ commit, lastEnrichment: this.currentEnrichment });
77
+ }
78
+
79
+ public onCommitRollback(commit: GraphCommit<TChange>): void {
80
+ assert(
81
+ commit.revision === this.inFlightQueue.last?.data.commit.revision,
82
+ 0xbd7 /* must rollback latest commit in the in flight queue */,
83
+ );
84
+ this.inFlightQueue.pop();
60
85
  }
61
86
 
62
87
  public prepareForResubmit(toResubmit: readonly GraphCommit<TChange>[]): void {
@@ -64,16 +89,33 @@ export class DefaultResubmitMachine<TChange> implements ResubmitMachine<TChange>
64
89
  !this.isInResubmitPhase,
65
90
  0x957 /* Invalid resubmit phase start during incomplete resubmit phase */,
66
91
  );
92
+
93
+ if (!hasSome(toResubmit)) {
94
+ return;
95
+ }
96
+
67
97
  assert(
68
- toResubmit.length === this.inFlightQueue.length,
69
- 0x958 /* Unexpected resubmit of more or fewer commits than are in flight */,
98
+ toResubmit.length <= this.inFlightQueue.length,
99
+ 0xbd8 /* Unexpected resubmit of more commits than are in flight */,
70
100
  );
71
- if (this.latestInFlightCommitWithStaleEnrichments === -1) {
72
- // No in-flight commits have stale enrichments, so we can resubmit them as is
73
- this.resubmitQueue = this.inFlightQueue;
74
- this.inFlightQueue = [];
75
- } else {
101
+
102
+ // Find the first in-flight commit to resubmit.
103
+ const first = this.inFlightQueue.find(
104
+ (v) => v.data.commit.revision === toResubmit[0].revision,
105
+ );
106
+ // Always resubmit to the end of all outstanding ops, but the list may grow during resubmit,
107
+ // so we must track the current end at the start of the phase.
108
+ const last = this.inFlightQueue.last;
109
+ assert(
110
+ first !== undefined && last !== undefined,
111
+ 0xbd9 /* there must be inflight commits to resubmit */,
112
+ );
113
+
114
+ this.pendingResubmitRange = { first, last };
115
+ // If any in-flight commits have stale enrichments, recompute them.
116
+ if (first.data.lastEnrichment < this.currentEnrichment) {
76
117
  const checkout = this.tip.fork();
118
+
77
119
  // Roll back the checkout to the state before the oldest commit
78
120
  for (let iCommit = toResubmit.length - 1; iCommit >= 0; iCommit -= 1) {
79
121
  const commit = toResubmit[iCommit] ?? oob();
@@ -83,32 +125,37 @@ export class DefaultResubmitMachine<TChange> implements ResubmitMachine<TChange>
83
125
  // forwards from an earlier fork instead of backwards.
84
126
  checkout.applyTipChange(rollback);
85
127
  }
86
- // Update the enrichments of the stale commits
87
- for (
88
- let iCommit = 0;
89
- iCommit <= this.latestInFlightCommitWithStaleEnrichments;
90
- iCommit += 1
91
- ) {
92
- const commit = toResubmit[iCommit] ?? oob();
93
- const enrichedChange = checkout.updateChangeEnrichments(
94
- commit.change,
95
- commit.revision,
128
+
129
+ // Update the enrichments of the stale commits in the in-flight queue.
130
+ let current: PendingChangeNode<TChange> | undefined = first;
131
+ for (const commit of toResubmit) {
132
+ assert(
133
+ current !== undefined,
134
+ 0xbda /* there must be an inflight commit for each resubmit commit */,
96
135
  );
97
- const enrichedCommit = { ...commit, change: enrichedChange };
98
- this.resubmitQueue.push(enrichedCommit);
99
- if (iCommit < this.latestInFlightCommitWithStaleEnrichments) {
100
- checkout.applyTipChange(enrichedChange, commit.revision);
136
+ current.data.commit = commit;
137
+ if (current.data.lastEnrichment < this.currentEnrichment) {
138
+ const enrichedChange = checkout.updateChangeEnrichments(
139
+ commit.change,
140
+ commit.revision,
141
+ );
142
+ const enrichedCommit = { ...commit, change: enrichedChange };
143
+
144
+ // Optimization: only apply the enriched change if the next commit also needs enrichment.
145
+ if (
146
+ current.next !== undefined &&
147
+ current.next.data.lastEnrichment < this.currentEnrichment
148
+ ) {
149
+ checkout.applyTipChange(enrichedChange, commit.revision);
150
+ }
151
+
152
+ current.data.commit = enrichedCommit;
153
+ current.data.lastEnrichment = this.currentEnrichment;
101
154
  }
102
- this.inFlightQueue.shift();
155
+ current = current.next;
103
156
  }
104
157
  checkout[disposeSymbol]();
105
- // Whatever commits are left do not have stale enrichments
106
- for (const commit of this.inFlightQueue) {
107
- this.resubmitQueue.push(commit);
108
- }
109
- this.inFlightQueue.length = 0;
110
158
  }
111
- this.latestInFlightCommitWithStaleEnrichments = -1;
112
159
  }
113
160
 
114
161
  public peekNextCommit(): GraphCommit<TChange> {
@@ -116,12 +163,15 @@ export class DefaultResubmitMachine<TChange> implements ResubmitMachine<TChange>
116
163
  this.isInResubmitPhase,
117
164
  0x982 /* No available commit to resubmit outside of resubmit phase */,
118
165
  );
119
- assert(hasSome(this.resubmitQueue), 0xa87 /* Expected resubmit queue to be non-empty */);
120
- return this.resubmitQueue[0];
166
+ assert(
167
+ this.pendingResubmitRange !== undefined,
168
+ 0xa87 /* Expected resubmit queue to be non-empty */,
169
+ );
170
+ return this.pendingResubmitRange.first.data.commit;
121
171
  }
122
172
 
123
173
  public get isInResubmitPhase(): boolean {
124
- return this.resubmitQueue.length !== 0;
174
+ return this.pendingResubmitRange !== undefined;
125
175
  }
126
176
 
127
177
  public onSequencedCommitApplied(isLocal: boolean): void {
@@ -129,12 +179,9 @@ export class DefaultResubmitMachine<TChange> implements ResubmitMachine<TChange>
129
179
  // The oldest in-flight commit has been sequenced
130
180
  assert(this.inFlightQueue.length > 0, 0x959 /* Sequencing of unknown local commit */);
131
181
  this.inFlightQueue.shift();
132
- if (this.latestInFlightCommitWithStaleEnrichments >= 0) {
133
- this.latestInFlightCommitWithStaleEnrichments -= 1;
134
- }
135
182
  } else {
136
183
  // A peer commit has been sequenced
137
- this.latestInFlightCommitWithStaleEnrichments = this.inFlightQueue.length - 1;
184
+ this.currentEnrichment++;
138
185
  }
139
186
  }
140
187
  }
@@ -37,6 +37,13 @@ export interface ResubmitMachine<TChange> {
37
37
  */
38
38
  onCommitSubmitted(commit: GraphCommit<TChange>): void;
39
39
 
40
+ /**
41
+ * Must be called on a commit after rollback, so it can be removed
42
+ * as it will never be (re)submitted.
43
+ * @param commit - The commit that was rolled back
44
+ */
45
+ onCommitRollback(commit: GraphCommit<TChange>): void;
46
+
40
47
  /**
41
48
  * Must be called after a sequenced commit is applied.
42
49
  * Note that this may be called multiples times in a row after a number of sequenced commits have been applied
@@ -397,14 +397,12 @@ export class SharedTreeCore<TEditor extends ChangeFamilyEditor, TChange>
397
397
  } = this.messageCodec.decode(this.serializer.decode(content), {
398
398
  idCompressor: this.idCompressor,
399
399
  });
400
- const [commit] = this.editManager.findLocalCommit(revision);
401
400
  // If a resubmit phase is not already in progress, then this must be the first commit of a new resubmit phase.
402
401
  if (this.resubmitMachine.isInResubmitPhase === false) {
403
- const toResubmit = this.editManager.getLocalCommits();
404
- assert(
405
- commit === toResubmit[0],
406
- 0x95d /* Resubmit phase should start with the oldest local commit */,
407
- );
402
+ const localCommits = this.editManager.getLocalCommits();
403
+ const revisionIndex = localCommits.findIndex((c) => c.revision === revision);
404
+ assert(revisionIndex >= 0, 0xbdb /* revision must exist in local commits */);
405
+ const toResubmit = localCommits.slice(revisionIndex);
408
406
  this.resubmitMachine.prepareForResubmit(toResubmit);
409
407
  }
410
408
  assert(
@@ -418,6 +416,20 @@ export class SharedTreeCore<TEditor extends ChangeFamilyEditor, TChange>
418
416
  const enrichedCommit = this.resubmitMachine.peekNextCommit();
419
417
  this.submitCommit(enrichedCommit, localOpMetadata, true);
420
418
  }
419
+ public rollback(content: JsonCompatibleReadOnly, localOpMetadata: unknown): void {
420
+ // Empty context object is passed in, as our decode function is schema-agnostic.
421
+ const {
422
+ commit: { revision },
423
+ } = this.messageCodec.decode(this.serializer.decode(content), {
424
+ idCompressor: this.idCompressor,
425
+ });
426
+ const [commit] = this.editManager.findLocalCommit(revision);
427
+ const { parent } = commit;
428
+ assert(parent !== undefined, 0xbdc /* must have parent */);
429
+ const [precedingCommit] = this.editManager.findLocalCommit(parent.revision);
430
+ this.editManager.localBranch.removeAfter(precedingCommit);
431
+ this.resubmitMachine.onCommitRollback(commit);
432
+ }
421
433
 
422
434
  public applyStashedOp(content: JsonCompatibleReadOnly): void {
423
435
  // Empty context object is passed in, as our decode function is schema-agnostic.