@fluidframework/tree 2.81.0 → 2.82.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 (579) hide show
  1. package/CHANGELOG.md +125 -0
  2. package/api-report/tree.alpha.api.md +54 -22
  3. package/api-report/tree.beta.api.md +150 -1
  4. package/api-report/tree.legacy.beta.api.md +150 -1
  5. package/api-report/tree.legacy.public.api.md +1 -0
  6. package/api-report/tree.public.api.md +1 -0
  7. package/dist/alpha.d.ts +8 -2
  8. package/dist/beta.d.ts +3 -0
  9. package/dist/codec/codec.d.ts +17 -8
  10. package/dist/codec/codec.d.ts.map +1 -1
  11. package/dist/codec/codec.js +8 -1
  12. package/dist/codec/codec.js.map +1 -1
  13. package/dist/codec/index.d.ts +1 -1
  14. package/dist/codec/index.d.ts.map +1 -1
  15. package/dist/codec/index.js +2 -1
  16. package/dist/codec/index.js.map +1 -1
  17. package/dist/codec/versioned/codec.d.ts +1 -1
  18. package/dist/codec/versioned/codec.d.ts.map +1 -1
  19. package/dist/codec/versioned/codec.js.map +1 -1
  20. package/dist/core/index.d.ts +1 -1
  21. package/dist/core/index.d.ts.map +1 -1
  22. package/dist/core/index.js +4 -2
  23. package/dist/core/index.js.map +1 -1
  24. package/dist/core/rebase/changeRebaser.d.ts +3 -2
  25. package/dist/core/rebase/changeRebaser.d.ts.map +1 -1
  26. package/dist/core/rebase/changeRebaser.js.map +1 -1
  27. package/dist/core/rebase/index.d.ts +1 -1
  28. package/dist/core/rebase/index.d.ts.map +1 -1
  29. package/dist/core/rebase/index.js +4 -2
  30. package/dist/core/rebase/index.js.map +1 -1
  31. package/dist/core/rebase/types.d.ts +23 -3
  32. package/dist/core/rebase/types.d.ts.map +1 -1
  33. package/dist/core/rebase/types.js +30 -16
  34. package/dist/core/rebase/types.js.map +1 -1
  35. package/dist/core/schema-stored/formatV1.d.ts +2 -2
  36. package/dist/core/schema-stored/formatV1.d.ts.map +1 -1
  37. package/dist/core/schema-stored/formatV1.js +0 -5
  38. package/dist/core/schema-stored/formatV1.js.map +1 -1
  39. package/dist/core/schema-stored/formatV2.d.ts +11 -10
  40. package/dist/core/schema-stored/formatV2.d.ts.map +1 -1
  41. package/dist/core/schema-stored/formatV2.js +1 -6
  42. package/dist/core/schema-stored/formatV2.js.map +1 -1
  43. package/dist/core/schema-stored/index.d.ts.map +1 -1
  44. package/dist/core/schema-stored/index.js.map +1 -1
  45. package/dist/core/schema-stored/schema.d.ts.map +1 -1
  46. package/dist/core/schema-stored/schema.js.map +1 -1
  47. package/dist/core/tree/anchorSet.d.ts.map +1 -1
  48. package/dist/core/tree/anchorSet.js.map +1 -1
  49. package/dist/core/tree/delta.d.ts +9 -7
  50. package/dist/core/tree/delta.d.ts.map +1 -1
  51. package/dist/core/tree/delta.js.map +1 -1
  52. package/dist/core/tree/deltaUtil.js +1 -1
  53. package/dist/core/tree/deltaUtil.js.map +1 -1
  54. package/dist/core/tree/visitDelta.js +2 -2
  55. package/dist/core/tree/visitDelta.js.map +1 -1
  56. package/dist/extensibleSchemaUnion.d.ts +72 -0
  57. package/dist/extensibleSchemaUnion.d.ts.map +1 -0
  58. package/dist/extensibleSchemaUnion.js +79 -0
  59. package/dist/extensibleSchemaUnion.js.map +1 -0
  60. package/dist/feature-libraries/changeAtomIdBTree.d.ts +4 -2
  61. package/dist/feature-libraries/changeAtomIdBTree.d.ts.map +1 -1
  62. package/dist/feature-libraries/changeAtomIdBTree.js +9 -1
  63. package/dist/feature-libraries/changeAtomIdBTree.js.map +1 -1
  64. package/dist/feature-libraries/default-schema/defaultFieldKinds.d.ts +1 -3
  65. package/dist/feature-libraries/default-schema/defaultFieldKinds.d.ts.map +1 -1
  66. package/dist/feature-libraries/default-schema/defaultFieldKinds.js +20 -21
  67. package/dist/feature-libraries/default-schema/defaultFieldKinds.js.map +1 -1
  68. package/dist/feature-libraries/default-schema/index.d.ts +1 -1
  69. package/dist/feature-libraries/default-schema/index.d.ts.map +1 -1
  70. package/dist/feature-libraries/default-schema/index.js.map +1 -1
  71. package/dist/feature-libraries/forest-summary/codec.d.ts +2 -1
  72. package/dist/feature-libraries/forest-summary/codec.d.ts.map +1 -1
  73. package/dist/feature-libraries/forest-summary/codec.js.map +1 -1
  74. package/dist/feature-libraries/forest-summary/forestSummarizer.d.ts.map +1 -1
  75. package/dist/feature-libraries/forest-summary/forestSummarizer.js +5 -2
  76. package/dist/feature-libraries/forest-summary/forestSummarizer.js.map +1 -1
  77. package/dist/feature-libraries/forest-summary/formatCommon.d.ts +1 -39
  78. package/dist/feature-libraries/forest-summary/formatCommon.d.ts.map +1 -1
  79. package/dist/feature-libraries/forest-summary/formatCommon.js +1 -2
  80. package/dist/feature-libraries/forest-summary/formatCommon.js.map +1 -1
  81. package/dist/feature-libraries/forest-summary/formatV1.d.ts +1 -39
  82. package/dist/feature-libraries/forest-summary/formatV1.d.ts.map +1 -1
  83. package/dist/feature-libraries/forest-summary/formatV2.d.ts +1 -39
  84. package/dist/feature-libraries/forest-summary/formatV2.d.ts.map +1 -1
  85. package/dist/feature-libraries/forest-summary/incrementalSummaryBuilder.d.ts +1 -1
  86. package/dist/feature-libraries/forest-summary/incrementalSummaryBuilder.d.ts.map +1 -1
  87. package/dist/feature-libraries/forest-summary/incrementalSummaryBuilder.js +1 -1
  88. package/dist/feature-libraries/forest-summary/incrementalSummaryBuilder.js.map +1 -1
  89. package/dist/feature-libraries/index.d.ts +3 -3
  90. package/dist/feature-libraries/index.d.ts.map +1 -1
  91. package/dist/feature-libraries/index.js +4 -3
  92. package/dist/feature-libraries/index.js.map +1 -1
  93. package/dist/feature-libraries/modular-schema/defaultRevisionReplacer.d.ts +2 -2
  94. package/dist/feature-libraries/modular-schema/defaultRevisionReplacer.d.ts.map +1 -1
  95. package/dist/feature-libraries/modular-schema/defaultRevisionReplacer.js +42 -22
  96. package/dist/feature-libraries/modular-schema/defaultRevisionReplacer.js.map +1 -1
  97. package/dist/feature-libraries/modular-schema/genericFieldKind.js +1 -1
  98. package/dist/feature-libraries/modular-schema/genericFieldKind.js.map +1 -1
  99. package/dist/feature-libraries/modular-schema/index.d.ts +1 -1
  100. package/dist/feature-libraries/modular-schema/index.d.ts.map +1 -1
  101. package/dist/feature-libraries/modular-schema/index.js +2 -1
  102. package/dist/feature-libraries/modular-schema/index.js.map +1 -1
  103. package/dist/feature-libraries/modular-schema/modularChangeCodecV1.d.ts +1 -1
  104. package/dist/feature-libraries/modular-schema/modularChangeCodecV1.d.ts.map +1 -1
  105. package/dist/feature-libraries/modular-schema/modularChangeCodecV1.js +9 -5
  106. package/dist/feature-libraries/modular-schema/modularChangeCodecV1.js.map +1 -1
  107. package/dist/feature-libraries/modular-schema/modularChangeCodecs.d.ts +11 -1
  108. package/dist/feature-libraries/modular-schema/modularChangeCodecs.d.ts.map +1 -1
  109. package/dist/feature-libraries/modular-schema/modularChangeCodecs.js +30 -7
  110. package/dist/feature-libraries/modular-schema/modularChangeCodecs.js.map +1 -1
  111. package/dist/feature-libraries/modular-schema/modularChangeFamily.d.ts.map +1 -1
  112. package/dist/feature-libraries/modular-schema/modularChangeFamily.js +38 -27
  113. package/dist/feature-libraries/modular-schema/modularChangeFamily.js.map +1 -1
  114. package/dist/feature-libraries/modular-schema/modularChangeFormatV1.d.ts +10 -127
  115. package/dist/feature-libraries/modular-schema/modularChangeFormatV1.d.ts.map +1 -1
  116. package/dist/feature-libraries/modular-schema/modularChangeFormatV1.js +2 -4
  117. package/dist/feature-libraries/modular-schema/modularChangeFormatV1.js.map +1 -1
  118. package/dist/feature-libraries/modular-schema/modularChangeFormatV2.d.ts +3 -79
  119. package/dist/feature-libraries/modular-schema/modularChangeFormatV2.d.ts.map +1 -1
  120. package/dist/feature-libraries/optional-field/optionalField.js +1 -1
  121. package/dist/feature-libraries/optional-field/optionalField.js.map +1 -1
  122. package/dist/feature-libraries/optional-field/requiredField.d.ts.map +1 -1
  123. package/dist/feature-libraries/optional-field/requiredField.js.map +1 -1
  124. package/dist/feature-libraries/schema-edits/schemaChangeFormat.d.ts +2 -2
  125. package/dist/feature-libraries/schema-index/codec.js.map +1 -1
  126. package/dist/feature-libraries/schema-index/formatV2.d.ts +4 -4
  127. package/dist/feature-libraries/schema-index/schemaSummarizer.js +1 -1
  128. package/dist/feature-libraries/schema-index/schemaSummarizer.js.map +1 -1
  129. package/dist/feature-libraries/sequence-field/invert.js +2 -2
  130. package/dist/feature-libraries/sequence-field/invert.js.map +1 -1
  131. package/dist/feature-libraries/sequence-field/replaceRevisions.js +16 -16
  132. package/dist/feature-libraries/sequence-field/replaceRevisions.js.map +1 -1
  133. package/dist/feature-libraries/sequence-field/sequenceFieldToDelta.js +1 -1
  134. package/dist/feature-libraries/sequence-field/sequenceFieldToDelta.js.map +1 -1
  135. package/dist/index.d.ts +5 -5
  136. package/dist/index.d.ts.map +1 -1
  137. package/dist/index.js +4 -1
  138. package/dist/index.js.map +1 -1
  139. package/dist/legacy.d.ts +3 -0
  140. package/dist/packageVersion.d.ts +1 -1
  141. package/dist/packageVersion.js +1 -1
  142. package/dist/packageVersion.js.map +1 -1
  143. package/dist/shared-tree/independentView.d.ts +36 -13
  144. package/dist/shared-tree/independentView.d.ts.map +1 -1
  145. package/dist/shared-tree/independentView.js +1 -0
  146. package/dist/shared-tree/independentView.js.map +1 -1
  147. package/dist/shared-tree/index.d.ts +1 -1
  148. package/dist/shared-tree/index.d.ts.map +1 -1
  149. package/dist/shared-tree/index.js.map +1 -1
  150. package/dist/shared-tree/schematizingTreeView.d.ts +10 -0
  151. package/dist/shared-tree/schematizingTreeView.d.ts.map +1 -1
  152. package/dist/shared-tree/schematizingTreeView.js +25 -9
  153. package/dist/shared-tree/schematizingTreeView.js.map +1 -1
  154. package/dist/shared-tree/sharedTree.d.ts +3 -3
  155. package/dist/shared-tree/sharedTree.d.ts.map +1 -1
  156. package/dist/shared-tree/sharedTree.js +8 -32
  157. package/dist/shared-tree/sharedTree.js.map +1 -1
  158. package/dist/shared-tree/sharedTreeChangeCodecs.d.ts +11 -3
  159. package/dist/shared-tree/sharedTreeChangeCodecs.d.ts.map +1 -1
  160. package/dist/shared-tree/sharedTreeChangeCodecs.js +38 -4
  161. package/dist/shared-tree/sharedTreeChangeCodecs.js.map +1 -1
  162. package/dist/shared-tree/sharedTreeChangeFormat.d.ts +4 -4
  163. package/dist/shared-tree/tree.js +1 -1
  164. package/dist/shared-tree/tree.js.map +1 -1
  165. package/dist/shared-tree/treeCheckout.d.ts +20 -0
  166. package/dist/shared-tree/treeCheckout.d.ts.map +1 -1
  167. package/dist/shared-tree/treeCheckout.js +39 -3
  168. package/dist/shared-tree/treeCheckout.js.map +1 -1
  169. package/dist/shared-tree-core/editManagerSummarizer.js +1 -1
  170. package/dist/shared-tree-core/editManagerSummarizer.js.map +1 -1
  171. package/dist/shared-tree-core/messageCodecV1ToV4.d.ts.map +1 -1
  172. package/dist/shared-tree-core/messageCodecV1ToV4.js +2 -2
  173. package/dist/shared-tree-core/messageCodecV1ToV4.js.map +1 -1
  174. package/dist/shared-tree-core/transaction.d.ts +14 -3
  175. package/dist/shared-tree-core/transaction.d.ts.map +1 -1
  176. package/dist/shared-tree-core/transaction.js +59 -16
  177. package/dist/shared-tree-core/transaction.js.map +1 -1
  178. package/dist/shared-tree-core/versionedSummarizer.d.ts.map +1 -1
  179. package/dist/shared-tree-core/versionedSummarizer.js +1 -1
  180. package/dist/shared-tree-core/versionedSummarizer.js.map +1 -1
  181. package/dist/simple-tree/api/index.d.ts +1 -1
  182. package/dist/simple-tree/api/index.d.ts.map +1 -1
  183. package/dist/simple-tree/api/index.js +3 -2
  184. package/dist/simple-tree/api/index.js.map +1 -1
  185. package/dist/simple-tree/api/schemaCreationUtilities.d.ts +9 -0
  186. package/dist/simple-tree/api/schemaCreationUtilities.d.ts.map +1 -1
  187. package/dist/simple-tree/api/schemaCreationUtilities.js +16 -1
  188. package/dist/simple-tree/api/schemaCreationUtilities.js.map +1 -1
  189. package/dist/simple-tree/api/simpleTreeIndex.js.map +1 -1
  190. package/dist/simple-tree/api/transactionTypes.d.ts +10 -0
  191. package/dist/simple-tree/api/transactionTypes.d.ts.map +1 -1
  192. package/dist/simple-tree/api/transactionTypes.js.map +1 -1
  193. package/dist/simple-tree/api/tree.d.ts +81 -6
  194. package/dist/simple-tree/api/tree.d.ts.map +1 -1
  195. package/dist/simple-tree/api/tree.js.map +1 -1
  196. package/dist/simple-tree/core/treeNodeSchema.d.ts.map +1 -1
  197. package/dist/simple-tree/core/treeNodeSchema.js.map +1 -1
  198. package/dist/simple-tree/index.d.ts +2 -2
  199. package/dist/simple-tree/index.d.ts.map +1 -1
  200. package/dist/simple-tree/index.js +4 -2
  201. package/dist/simple-tree/index.js.map +1 -1
  202. package/dist/simple-tree/leafNodeSchema.d.ts.map +1 -1
  203. package/dist/simple-tree/leafNodeSchema.js.map +1 -1
  204. package/dist/simple-tree/node-kinds/array/arrayNode.d.ts +63 -0
  205. package/dist/simple-tree/node-kinds/array/arrayNode.d.ts.map +1 -1
  206. package/dist/simple-tree/node-kinds/array/arrayNode.js +43 -1
  207. package/dist/simple-tree/node-kinds/array/arrayNode.js.map +1 -1
  208. package/dist/simple-tree/node-kinds/array/index.d.ts +1 -1
  209. package/dist/simple-tree/node-kinds/array/index.d.ts.map +1 -1
  210. package/dist/simple-tree/node-kinds/array/index.js +2 -1
  211. package/dist/simple-tree/node-kinds/array/index.js.map +1 -1
  212. package/dist/simple-tree/node-kinds/index.d.ts +1 -1
  213. package/dist/simple-tree/node-kinds/index.d.ts.map +1 -1
  214. package/dist/simple-tree/node-kinds/index.js +2 -1
  215. package/dist/simple-tree/node-kinds/index.js.map +1 -1
  216. package/dist/simple-tree/node-kinds/object/objectNode.d.ts.map +1 -1
  217. package/dist/simple-tree/node-kinds/object/objectNode.js.map +1 -1
  218. package/dist/tableSchema.d.ts +71 -48
  219. package/dist/tableSchema.d.ts.map +1 -1
  220. package/dist/tableSchema.js +200 -98
  221. package/dist/tableSchema.js.map +1 -1
  222. package/dist/text/textDomainFormatted.js +1 -1
  223. package/dist/text/textDomainFormatted.js.map +1 -1
  224. package/dist/util/bTreeUtils.d.ts +30 -4
  225. package/dist/util/bTreeUtils.d.ts.map +1 -1
  226. package/dist/util/bTreeUtils.js +29 -17
  227. package/dist/util/bTreeUtils.js.map +1 -1
  228. package/dist/util/brand.d.ts.map +1 -1
  229. package/dist/util/brand.js.map +1 -1
  230. package/dist/util/brandedMap.d.ts.map +1 -1
  231. package/dist/util/brandedMap.js.map +1 -1
  232. package/dist/util/breakable.d.ts.map +1 -1
  233. package/dist/util/breakable.js +2 -1
  234. package/dist/util/breakable.js.map +1 -1
  235. package/dist/util/index.d.ts +2 -2
  236. package/dist/util/index.d.ts.map +1 -1
  237. package/dist/util/index.js +6 -3
  238. package/dist/util/index.js.map +1 -1
  239. package/dist/util/opaque.d.ts.map +1 -1
  240. package/dist/util/opaque.js.map +1 -1
  241. package/dist/util/rangeMap.d.ts +3 -2
  242. package/dist/util/rangeMap.d.ts.map +1 -1
  243. package/dist/util/rangeMap.js +7 -1
  244. package/dist/util/rangeMap.js.map +1 -1
  245. package/dist/util/readSnapshotBlob.d.ts +1 -1
  246. package/dist/util/readSnapshotBlob.d.ts.map +1 -1
  247. package/dist/util/readSnapshotBlob.js.map +1 -1
  248. package/dist/util/typeCheck.d.ts.map +1 -1
  249. package/dist/util/typeCheck.js.map +1 -1
  250. package/dist/util/utils.d.ts +20 -16
  251. package/dist/util/utils.d.ts.map +1 -1
  252. package/dist/util/utils.js +49 -17
  253. package/dist/util/utils.js.map +1 -1
  254. package/eslint.config.mts +0 -9
  255. package/lib/alpha.d.ts +8 -2
  256. package/lib/beta.d.ts +3 -0
  257. package/lib/codec/codec.d.ts +17 -8
  258. package/lib/codec/codec.d.ts.map +1 -1
  259. package/lib/codec/codec.js +6 -0
  260. package/lib/codec/codec.js.map +1 -1
  261. package/lib/codec/index.d.ts +1 -1
  262. package/lib/codec/index.d.ts.map +1 -1
  263. package/lib/codec/index.js +1 -1
  264. package/lib/codec/index.js.map +1 -1
  265. package/lib/codec/versioned/codec.d.ts +1 -1
  266. package/lib/codec/versioned/codec.d.ts.map +1 -1
  267. package/lib/codec/versioned/codec.js.map +1 -1
  268. package/lib/core/index.d.ts +1 -1
  269. package/lib/core/index.d.ts.map +1 -1
  270. package/lib/core/index.js +1 -1
  271. package/lib/core/index.js.map +1 -1
  272. package/lib/core/rebase/changeRebaser.d.ts +3 -2
  273. package/lib/core/rebase/changeRebaser.d.ts.map +1 -1
  274. package/lib/core/rebase/changeRebaser.js.map +1 -1
  275. package/lib/core/rebase/index.d.ts +1 -1
  276. package/lib/core/rebase/index.d.ts.map +1 -1
  277. package/lib/core/rebase/index.js +1 -1
  278. package/lib/core/rebase/index.js.map +1 -1
  279. package/lib/core/rebase/types.d.ts +23 -3
  280. package/lib/core/rebase/types.d.ts.map +1 -1
  281. package/lib/core/rebase/types.js +27 -15
  282. package/lib/core/rebase/types.js.map +1 -1
  283. package/lib/core/schema-stored/formatV1.d.ts +2 -2
  284. package/lib/core/schema-stored/formatV1.d.ts.map +1 -1
  285. package/lib/core/schema-stored/formatV1.js +0 -5
  286. package/lib/core/schema-stored/formatV1.js.map +1 -1
  287. package/lib/core/schema-stored/formatV2.d.ts +11 -10
  288. package/lib/core/schema-stored/formatV2.d.ts.map +1 -1
  289. package/lib/core/schema-stored/formatV2.js +1 -6
  290. package/lib/core/schema-stored/formatV2.js.map +1 -1
  291. package/lib/core/schema-stored/index.d.ts.map +1 -1
  292. package/lib/core/schema-stored/index.js +2 -0
  293. package/lib/core/schema-stored/index.js.map +1 -1
  294. package/lib/core/schema-stored/schema.d.ts.map +1 -1
  295. package/lib/core/schema-stored/schema.js.map +1 -1
  296. package/lib/core/tree/anchorSet.d.ts.map +1 -1
  297. package/lib/core/tree/anchorSet.js.map +1 -1
  298. package/lib/core/tree/delta.d.ts +9 -7
  299. package/lib/core/tree/delta.d.ts.map +1 -1
  300. package/lib/core/tree/delta.js.map +1 -1
  301. package/lib/core/tree/deltaUtil.js +1 -1
  302. package/lib/core/tree/deltaUtil.js.map +1 -1
  303. package/lib/core/tree/visitDelta.js +2 -2
  304. package/lib/core/tree/visitDelta.js.map +1 -1
  305. package/lib/extensibleSchemaUnion.d.ts +72 -0
  306. package/lib/extensibleSchemaUnion.d.ts.map +1 -0
  307. package/lib/extensibleSchemaUnion.js +76 -0
  308. package/lib/extensibleSchemaUnion.js.map +1 -0
  309. package/lib/feature-libraries/changeAtomIdBTree.d.ts +4 -2
  310. package/lib/feature-libraries/changeAtomIdBTree.d.ts.map +1 -1
  311. package/lib/feature-libraries/changeAtomIdBTree.js +7 -0
  312. package/lib/feature-libraries/changeAtomIdBTree.js.map +1 -1
  313. package/lib/feature-libraries/default-schema/defaultFieldKinds.d.ts +1 -3
  314. package/lib/feature-libraries/default-schema/defaultFieldKinds.d.ts.map +1 -1
  315. package/lib/feature-libraries/default-schema/defaultFieldKinds.js +4 -5
  316. package/lib/feature-libraries/default-schema/defaultFieldKinds.js.map +1 -1
  317. package/lib/feature-libraries/default-schema/index.d.ts +1 -1
  318. package/lib/feature-libraries/default-schema/index.d.ts.map +1 -1
  319. package/lib/feature-libraries/default-schema/index.js.map +1 -1
  320. package/lib/feature-libraries/forest-summary/codec.d.ts +2 -1
  321. package/lib/feature-libraries/forest-summary/codec.d.ts.map +1 -1
  322. package/lib/feature-libraries/forest-summary/codec.js.map +1 -1
  323. package/lib/feature-libraries/forest-summary/forestSummarizer.d.ts.map +1 -1
  324. package/lib/feature-libraries/forest-summary/forestSummarizer.js +6 -3
  325. package/lib/feature-libraries/forest-summary/forestSummarizer.js.map +1 -1
  326. package/lib/feature-libraries/forest-summary/formatCommon.d.ts +1 -39
  327. package/lib/feature-libraries/forest-summary/formatCommon.d.ts.map +1 -1
  328. package/lib/feature-libraries/forest-summary/formatCommon.js +2 -3
  329. package/lib/feature-libraries/forest-summary/formatCommon.js.map +1 -1
  330. package/lib/feature-libraries/forest-summary/formatV1.d.ts +1 -39
  331. package/lib/feature-libraries/forest-summary/formatV1.d.ts.map +1 -1
  332. package/lib/feature-libraries/forest-summary/formatV2.d.ts +1 -39
  333. package/lib/feature-libraries/forest-summary/formatV2.d.ts.map +1 -1
  334. package/lib/feature-libraries/forest-summary/incrementalSummaryBuilder.d.ts +1 -1
  335. package/lib/feature-libraries/forest-summary/incrementalSummaryBuilder.d.ts.map +1 -1
  336. package/lib/feature-libraries/forest-summary/incrementalSummaryBuilder.js +1 -1
  337. package/lib/feature-libraries/forest-summary/incrementalSummaryBuilder.js.map +1 -1
  338. package/lib/feature-libraries/index.d.ts +3 -3
  339. package/lib/feature-libraries/index.d.ts.map +1 -1
  340. package/lib/feature-libraries/index.js +3 -3
  341. package/lib/feature-libraries/index.js.map +1 -1
  342. package/lib/feature-libraries/modular-schema/defaultRevisionReplacer.d.ts +2 -2
  343. package/lib/feature-libraries/modular-schema/defaultRevisionReplacer.d.ts.map +1 -1
  344. package/lib/feature-libraries/modular-schema/defaultRevisionReplacer.js +41 -21
  345. package/lib/feature-libraries/modular-schema/defaultRevisionReplacer.js.map +1 -1
  346. package/lib/feature-libraries/modular-schema/genericFieldKind.js +1 -1
  347. package/lib/feature-libraries/modular-schema/genericFieldKind.js.map +1 -1
  348. package/lib/feature-libraries/modular-schema/index.d.ts +1 -1
  349. package/lib/feature-libraries/modular-schema/index.d.ts.map +1 -1
  350. package/lib/feature-libraries/modular-schema/index.js +1 -1
  351. package/lib/feature-libraries/modular-schema/index.js.map +1 -1
  352. package/lib/feature-libraries/modular-schema/modularChangeCodecV1.d.ts +1 -1
  353. package/lib/feature-libraries/modular-schema/modularChangeCodecV1.d.ts.map +1 -1
  354. package/lib/feature-libraries/modular-schema/modularChangeCodecV1.js +10 -6
  355. package/lib/feature-libraries/modular-schema/modularChangeCodecV1.js.map +1 -1
  356. package/lib/feature-libraries/modular-schema/modularChangeCodecs.d.ts +11 -1
  357. package/lib/feature-libraries/modular-schema/modularChangeCodecs.d.ts.map +1 -1
  358. package/lib/feature-libraries/modular-schema/modularChangeCodecs.js +29 -6
  359. package/lib/feature-libraries/modular-schema/modularChangeCodecs.js.map +1 -1
  360. package/lib/feature-libraries/modular-schema/modularChangeFamily.d.ts.map +1 -1
  361. package/lib/feature-libraries/modular-schema/modularChangeFamily.js +41 -30
  362. package/lib/feature-libraries/modular-schema/modularChangeFamily.js.map +1 -1
  363. package/lib/feature-libraries/modular-schema/modularChangeFormatV1.d.ts +10 -127
  364. package/lib/feature-libraries/modular-schema/modularChangeFormatV1.d.ts.map +1 -1
  365. package/lib/feature-libraries/modular-schema/modularChangeFormatV1.js +2 -4
  366. package/lib/feature-libraries/modular-schema/modularChangeFormatV1.js.map +1 -1
  367. package/lib/feature-libraries/modular-schema/modularChangeFormatV2.d.ts +3 -79
  368. package/lib/feature-libraries/modular-schema/modularChangeFormatV2.d.ts.map +1 -1
  369. package/lib/feature-libraries/optional-field/optionalField.js +1 -1
  370. package/lib/feature-libraries/optional-field/optionalField.js.map +1 -1
  371. package/lib/feature-libraries/optional-field/requiredField.d.ts.map +1 -1
  372. package/lib/feature-libraries/optional-field/requiredField.js.map +1 -1
  373. package/lib/feature-libraries/schema-edits/schemaChangeFormat.d.ts +2 -2
  374. package/lib/feature-libraries/schema-index/codec.js.map +1 -1
  375. package/lib/feature-libraries/schema-index/formatV2.d.ts +4 -4
  376. package/lib/feature-libraries/schema-index/schemaSummarizer.js +1 -1
  377. package/lib/feature-libraries/schema-index/schemaSummarizer.js.map +1 -1
  378. package/lib/feature-libraries/sequence-field/invert.js +2 -2
  379. package/lib/feature-libraries/sequence-field/invert.js.map +1 -1
  380. package/lib/feature-libraries/sequence-field/replaceRevisions.js +16 -16
  381. package/lib/feature-libraries/sequence-field/replaceRevisions.js.map +1 -1
  382. package/lib/feature-libraries/sequence-field/sequenceFieldToDelta.js +1 -1
  383. package/lib/feature-libraries/sequence-field/sequenceFieldToDelta.js.map +1 -1
  384. package/lib/index.d.ts +5 -5
  385. package/lib/index.d.ts.map +1 -1
  386. package/lib/index.js +4 -3
  387. package/lib/index.js.map +1 -1
  388. package/lib/legacy.d.ts +3 -0
  389. package/lib/packageVersion.d.ts +1 -1
  390. package/lib/packageVersion.js +1 -1
  391. package/lib/packageVersion.js.map +1 -1
  392. package/lib/shared-tree/independentView.d.ts +36 -13
  393. package/lib/shared-tree/independentView.d.ts.map +1 -1
  394. package/lib/shared-tree/independentView.js +1 -0
  395. package/lib/shared-tree/independentView.js.map +1 -1
  396. package/lib/shared-tree/index.d.ts +1 -1
  397. package/lib/shared-tree/index.d.ts.map +1 -1
  398. package/lib/shared-tree/index.js.map +1 -1
  399. package/lib/shared-tree/schematizingTreeView.d.ts +10 -0
  400. package/lib/shared-tree/schematizingTreeView.d.ts.map +1 -1
  401. package/lib/shared-tree/schematizingTreeView.js +25 -9
  402. package/lib/shared-tree/schematizingTreeView.js.map +1 -1
  403. package/lib/shared-tree/sharedTree.d.ts +3 -3
  404. package/lib/shared-tree/sharedTree.d.ts.map +1 -1
  405. package/lib/shared-tree/sharedTree.js +10 -34
  406. package/lib/shared-tree/sharedTree.js.map +1 -1
  407. package/lib/shared-tree/sharedTreeChangeCodecs.d.ts +11 -3
  408. package/lib/shared-tree/sharedTreeChangeCodecs.d.ts.map +1 -1
  409. package/lib/shared-tree/sharedTreeChangeCodecs.js +39 -5
  410. package/lib/shared-tree/sharedTreeChangeCodecs.js.map +1 -1
  411. package/lib/shared-tree/sharedTreeChangeFormat.d.ts +4 -4
  412. package/lib/shared-tree/tree.js +1 -1
  413. package/lib/shared-tree/tree.js.map +1 -1
  414. package/lib/shared-tree/treeCheckout.d.ts +20 -0
  415. package/lib/shared-tree/treeCheckout.d.ts.map +1 -1
  416. package/lib/shared-tree/treeCheckout.js +39 -3
  417. package/lib/shared-tree/treeCheckout.js.map +1 -1
  418. package/lib/shared-tree-core/editManagerSummarizer.js +1 -1
  419. package/lib/shared-tree-core/editManagerSummarizer.js.map +1 -1
  420. package/lib/shared-tree-core/messageCodecV1ToV4.d.ts.map +1 -1
  421. package/lib/shared-tree-core/messageCodecV1ToV4.js +2 -2
  422. package/lib/shared-tree-core/messageCodecV1ToV4.js.map +1 -1
  423. package/lib/shared-tree-core/transaction.d.ts +14 -3
  424. package/lib/shared-tree-core/transaction.d.ts.map +1 -1
  425. package/lib/shared-tree-core/transaction.js +61 -18
  426. package/lib/shared-tree-core/transaction.js.map +1 -1
  427. package/lib/shared-tree-core/versionedSummarizer.d.ts.map +1 -1
  428. package/lib/shared-tree-core/versionedSummarizer.js +1 -1
  429. package/lib/shared-tree-core/versionedSummarizer.js.map +1 -1
  430. package/lib/simple-tree/api/index.d.ts +1 -1
  431. package/lib/simple-tree/api/index.d.ts.map +1 -1
  432. package/lib/simple-tree/api/index.js +1 -1
  433. package/lib/simple-tree/api/index.js.map +1 -1
  434. package/lib/simple-tree/api/schemaCreationUtilities.d.ts +9 -0
  435. package/lib/simple-tree/api/schemaCreationUtilities.d.ts.map +1 -1
  436. package/lib/simple-tree/api/schemaCreationUtilities.js +14 -0
  437. package/lib/simple-tree/api/schemaCreationUtilities.js.map +1 -1
  438. package/lib/simple-tree/api/simpleTreeIndex.js.map +1 -1
  439. package/lib/simple-tree/api/transactionTypes.d.ts +10 -0
  440. package/lib/simple-tree/api/transactionTypes.d.ts.map +1 -1
  441. package/lib/simple-tree/api/transactionTypes.js.map +1 -1
  442. package/lib/simple-tree/api/tree.d.ts +81 -6
  443. package/lib/simple-tree/api/tree.d.ts.map +1 -1
  444. package/lib/simple-tree/api/tree.js.map +1 -1
  445. package/lib/simple-tree/core/treeNodeSchema.d.ts.map +1 -1
  446. package/lib/simple-tree/core/treeNodeSchema.js.map +1 -1
  447. package/lib/simple-tree/index.d.ts +2 -2
  448. package/lib/simple-tree/index.d.ts.map +1 -1
  449. package/lib/simple-tree/index.js +2 -2
  450. package/lib/simple-tree/index.js.map +1 -1
  451. package/lib/simple-tree/leafNodeSchema.d.ts.map +1 -1
  452. package/lib/simple-tree/leafNodeSchema.js.map +1 -1
  453. package/lib/simple-tree/node-kinds/array/arrayNode.d.ts +63 -0
  454. package/lib/simple-tree/node-kinds/array/arrayNode.d.ts.map +1 -1
  455. package/lib/simple-tree/node-kinds/array/arrayNode.js +41 -0
  456. package/lib/simple-tree/node-kinds/array/arrayNode.js.map +1 -1
  457. package/lib/simple-tree/node-kinds/array/index.d.ts +1 -1
  458. package/lib/simple-tree/node-kinds/array/index.d.ts.map +1 -1
  459. package/lib/simple-tree/node-kinds/array/index.js +1 -1
  460. package/lib/simple-tree/node-kinds/array/index.js.map +1 -1
  461. package/lib/simple-tree/node-kinds/index.d.ts +1 -1
  462. package/lib/simple-tree/node-kinds/index.d.ts.map +1 -1
  463. package/lib/simple-tree/node-kinds/index.js +1 -1
  464. package/lib/simple-tree/node-kinds/index.js.map +1 -1
  465. package/lib/simple-tree/node-kinds/object/objectNode.d.ts.map +1 -1
  466. package/lib/simple-tree/node-kinds/object/objectNode.js.map +1 -1
  467. package/lib/tableSchema.d.ts +71 -48
  468. package/lib/tableSchema.d.ts.map +1 -1
  469. package/lib/tableSchema.js +201 -99
  470. package/lib/tableSchema.js.map +1 -1
  471. package/lib/text/textDomainFormatted.js +1 -1
  472. package/lib/text/textDomainFormatted.js.map +1 -1
  473. package/lib/util/bTreeUtils.d.ts +30 -4
  474. package/lib/util/bTreeUtils.d.ts.map +1 -1
  475. package/lib/util/bTreeUtils.js +27 -16
  476. package/lib/util/bTreeUtils.js.map +1 -1
  477. package/lib/util/brand.d.ts.map +1 -1
  478. package/lib/util/brand.js.map +1 -1
  479. package/lib/util/brandedMap.d.ts.map +1 -1
  480. package/lib/util/brandedMap.js.map +1 -1
  481. package/lib/util/breakable.d.ts.map +1 -1
  482. package/lib/util/breakable.js +2 -1
  483. package/lib/util/breakable.js.map +1 -1
  484. package/lib/util/index.d.ts +2 -2
  485. package/lib/util/index.d.ts.map +1 -1
  486. package/lib/util/index.js +2 -2
  487. package/lib/util/index.js.map +1 -1
  488. package/lib/util/opaque.d.ts.map +1 -1
  489. package/lib/util/opaque.js.map +1 -1
  490. package/lib/util/rangeMap.d.ts +3 -2
  491. package/lib/util/rangeMap.d.ts.map +1 -1
  492. package/lib/util/rangeMap.js +7 -1
  493. package/lib/util/rangeMap.js.map +1 -1
  494. package/lib/util/readSnapshotBlob.d.ts +1 -1
  495. package/lib/util/readSnapshotBlob.d.ts.map +1 -1
  496. package/lib/util/readSnapshotBlob.js.map +1 -1
  497. package/lib/util/typeCheck.d.ts.map +1 -1
  498. package/lib/util/typeCheck.js.map +1 -1
  499. package/lib/util/utils.d.ts +20 -16
  500. package/lib/util/utils.d.ts.map +1 -1
  501. package/lib/util/utils.js +44 -15
  502. package/lib/util/utils.js.map +1 -1
  503. package/package.json +23 -23
  504. package/src/codec/codec.ts +30 -11
  505. package/src/codec/index.ts +2 -0
  506. package/src/codec/versioned/codec.ts +9 -13
  507. package/src/core/index.ts +3 -1
  508. package/src/core/rebase/changeRebaser.ts +3 -2
  509. package/src/core/rebase/index.ts +3 -1
  510. package/src/core/rebase/types.ts +51 -13
  511. package/src/core/schema-stored/formatV1.ts +2 -4
  512. package/src/core/schema-stored/formatV2.ts +9 -7
  513. package/src/core/schema-stored/index.ts +2 -0
  514. package/src/core/schema-stored/schema.ts +4 -1
  515. package/src/core/tree/anchorSet.ts +1 -3
  516. package/src/core/tree/delta.ts +9 -7
  517. package/src/core/tree/deltaUtil.ts +1 -1
  518. package/src/core/tree/visitDelta.ts +2 -2
  519. package/src/extensibleSchemaUnion.ts +135 -0
  520. package/src/feature-libraries/changeAtomIdBTree.ts +17 -2
  521. package/src/feature-libraries/default-schema/defaultFieldKinds.ts +5 -6
  522. package/src/feature-libraries/default-schema/index.ts +0 -1
  523. package/src/feature-libraries/forest-summary/codec.ts +7 -2
  524. package/src/feature-libraries/forest-summary/forestSummarizer.ts +15 -3
  525. package/src/feature-libraries/forest-summary/formatCommon.ts +2 -3
  526. package/src/feature-libraries/forest-summary/incrementalSummaryBuilder.ts +4 -5
  527. package/src/feature-libraries/index.ts +3 -2
  528. package/src/feature-libraries/modular-schema/defaultRevisionReplacer.ts +57 -31
  529. package/src/feature-libraries/modular-schema/genericFieldKind.ts +1 -1
  530. package/src/feature-libraries/modular-schema/index.ts +4 -1
  531. package/src/feature-libraries/modular-schema/modularChangeCodecV1.ts +7 -6
  532. package/src/feature-libraries/modular-schema/modularChangeCodecs.ts +32 -7
  533. package/src/feature-libraries/modular-schema/modularChangeFamily.ts +54 -33
  534. package/src/feature-libraries/modular-schema/modularChangeFormatV1.ts +2 -4
  535. package/src/feature-libraries/optional-field/optionalField.ts +1 -1
  536. package/src/feature-libraries/optional-field/requiredField.ts +2 -4
  537. package/src/feature-libraries/schema-index/codec.ts +1 -1
  538. package/src/feature-libraries/schema-index/schemaSummarizer.ts +1 -1
  539. package/src/feature-libraries/sequence-field/invert.ts +2 -2
  540. package/src/feature-libraries/sequence-field/replaceRevisions.ts +17 -10
  541. package/src/feature-libraries/sequence-field/sequenceFieldToDelta.ts +1 -1
  542. package/src/index.ts +12 -7
  543. package/src/packageVersion.ts +1 -1
  544. package/src/shared-tree/independentView.ts +42 -6
  545. package/src/shared-tree/index.ts +2 -0
  546. package/src/shared-tree/schematizingTreeView.ts +63 -18
  547. package/src/shared-tree/sharedTree.ts +19 -37
  548. package/src/shared-tree/sharedTreeChangeCodecs.ts +43 -9
  549. package/src/shared-tree/tree.ts +1 -1
  550. package/src/shared-tree/treeCheckout.ts +50 -3
  551. package/src/shared-tree-core/editManagerSummarizer.ts +1 -1
  552. package/src/shared-tree-core/messageCodecV1ToV4.ts +4 -3
  553. package/src/shared-tree-core/transaction.ts +125 -23
  554. package/src/shared-tree-core/versionedSummarizer.ts +3 -2
  555. package/src/simple-tree/api/index.ts +1 -0
  556. package/src/simple-tree/api/schemaCreationUtilities.ts +35 -5
  557. package/src/simple-tree/api/simpleTreeIndex.ts +1 -1
  558. package/src/simple-tree/api/transactionTypes.ts +10 -0
  559. package/src/simple-tree/api/tree.ts +88 -6
  560. package/src/simple-tree/core/treeNodeSchema.ts +5 -8
  561. package/src/simple-tree/index.ts +3 -0
  562. package/src/simple-tree/leafNodeSchema.ts +3 -2
  563. package/src/simple-tree/node-kinds/array/arrayNode.ts +86 -0
  564. package/src/simple-tree/node-kinds/array/index.ts +2 -0
  565. package/src/simple-tree/node-kinds/index.ts +2 -0
  566. package/src/simple-tree/node-kinds/object/objectNode.ts +19 -18
  567. package/src/tableSchema.ts +280 -140
  568. package/src/text/textDomainFormatted.ts +1 -1
  569. package/src/util/bTreeUtils.ts +45 -26
  570. package/src/util/brand.ts +4 -12
  571. package/src/util/brandedMap.ts +2 -6
  572. package/src/util/breakable.ts +3 -2
  573. package/src/util/index.ts +9 -3
  574. package/src/util/opaque.ts +2 -6
  575. package/src/util/rangeMap.ts +11 -5
  576. package/src/util/readSnapshotBlob.ts +3 -3
  577. package/src/util/typeCheck.ts +11 -9
  578. package/src/util/utils.ts +57 -28
  579. package/biome.jsonc +0 -4
@@ -9,13 +9,17 @@ import { assert, unreachableCase } from "@fluidframework/core-utils/internal";
9
9
  import { UsageError } from "@fluidframework/telemetry-utils/internal";
10
10
 
11
11
  import {
12
+ diffHistories,
12
13
  findAncestor,
14
+ findCommonAncestor,
15
+ mintCommit,
16
+ rebaseBranch,
13
17
  tagChange,
14
18
  type ChangeFamilyEditor,
15
19
  type GraphCommit,
16
20
  type RevisionTag,
17
21
  } from "../core/index.js";
18
- import { getLast, getOrCreate, hasSome } from "../util/index.js";
22
+ import { getLast, getOrCreate } from "../util/index.js";
19
23
 
20
24
  import type { SharedTreeBranch, SharedTreeBranchEvents } from "./branch.js";
21
25
 
@@ -42,6 +46,8 @@ export interface Transactor {
42
46
  * Start a new transaction.
43
47
  * If a transaction is already in progress when this new transaction starts, then this transaction will be "nested" inside of it,
44
48
  * i.e. the outer transaction will still be in progress after this new transaction is committed or aborted.
49
+ * @param isAsync - Whether the transaction is asynchronous.
50
+ * An error will be thrown if an asynchronous transaction is started while a synchronous transaction is in progress.
45
51
  *
46
52
  * @remarks Asynchronous transactions are not supported on the root checkout,
47
53
  * since it is always kept up-to-date with the latest remote edits and the results of this rebasing (which might invalidate
@@ -55,7 +61,7 @@ export interface Transactor {
55
61
  * @privateRemarks There is currently no enforcement that asynchronous transactions don't happen on the root checkout.
56
62
  * AB#6488 tracks adding some enforcement to make it more clear to application authors that this is not supported.
57
63
  */
58
- start(): void;
64
+ start(isAsync: boolean): void;
59
65
  /**
60
66
  * Close this transaction by squashing its edits and committing them as a single edit.
61
67
  * If this is the root checkout and there are no ongoing transactions remaining, the squashed edit will be submitted to Fluid.
@@ -126,12 +132,22 @@ export type OnPush = () => Callbacks | void;
126
132
  */
127
133
  export type OnPop = (result: TransactionResult) => void;
128
134
 
135
+ /**
136
+ * A frame in the transaction stack.
137
+ */
138
+ interface TransactionStackFrame {
139
+ /** The callbacks provided when this transaction frame was pushed onto the stack. */
140
+ readonly callbacks: Callbacks;
141
+ /** Whether this transaction frame is asynchronous. */
142
+ readonly isAsync: boolean;
143
+ }
144
+
129
145
  /**
130
146
  * An implementation of {@link Transactor} that uses a stack to manage transactions.
131
147
  * @remarks Using a stack allows transactions to nest - i.e. an inner transaction may be started while an outer transaction is already in progress.
132
148
  */
133
149
  export class TransactionStack implements Transactor, IDisposable {
134
- readonly #stack: Callbacks[] = [];
150
+ readonly #stack: TransactionStackFrame[] = [];
135
151
  readonly #onPush?: OnPush;
136
152
 
137
153
  readonly #events = createEmitter<TransactionEvents>();
@@ -157,11 +173,20 @@ export class TransactionStack implements Transactor, IDisposable {
157
173
  return this.#stack.length > 0;
158
174
  }
159
175
 
160
- public start(): void {
176
+ public start(isAsync: boolean): void {
161
177
  this.ensureNotDisposed();
162
- const onPushCurrent = hasSome(this.#stack) ? getLast(this.#stack).onPush : this.#onPush;
178
+ const last = getLast(this.#stack);
179
+ if (last !== undefined && !last.isAsync && isAsync) {
180
+ throw new UsageError(
181
+ "An asynchronous transaction cannot be started while a synchronous transaction is in progress.",
182
+ );
183
+ }
184
+ const onPushCurrent = last === undefined ? this.#onPush : last.callbacks.onPush;
163
185
  const { onPush, onPop } = onPushCurrent?.() ?? {};
164
- this.#stack.push({ onPop, onPush: onPush ?? onPushCurrent });
186
+ this.#stack.push({
187
+ callbacks: { onPop, onPush: onPush ?? onPushCurrent },
188
+ isAsync,
189
+ });
165
190
  this.#events.emit("started");
166
191
  }
167
192
 
@@ -171,7 +196,7 @@ export class TransactionStack implements Transactor, IDisposable {
171
196
  throw new UsageError("No transaction to commit");
172
197
  }
173
198
  this.#events.emit("committing");
174
- this.#stack.pop()?.onPop?.(TransactionResult.Commit);
199
+ this.#stack.pop()?.callbacks.onPop?.(TransactionResult.Commit);
175
200
  }
176
201
 
177
202
  public abort(): void {
@@ -180,7 +205,7 @@ export class TransactionStack implements Transactor, IDisposable {
180
205
  throw new UsageError("No transaction to abort");
181
206
  }
182
207
  this.#events.emit("aborting");
183
- this.#stack.pop()?.onPop?.(TransactionResult.Abort);
208
+ this.#stack.pop()?.callbacks.onPop?.(TransactionResult.Abort);
184
209
  }
185
210
 
186
211
  public dispose(): void {
@@ -198,6 +223,19 @@ export class TransactionStack implements Transactor, IDisposable {
198
223
  }
199
224
  }
200
225
 
226
+ /**
227
+ * A function that will be called when a transaction is popped from the {@link SquashingTransactionStack | stack}.
228
+ * @remarks This function runs just after the transaction ends, so if this is the end of an outermost (not nested) transaction then {@link Transactor.isInProgress} will be false during its execution.
229
+ * @param result - The result of the transaction.
230
+ * @param viewUpdate - The change that needs to be applied to the view to keep it up-to-date with the branch after the transaction ends.
231
+ * This is needed in asynchronous transactions where new commits have been added to the branch while the transaction was in progress.
232
+ * This will be `undefined` if no such change is necessary.
233
+ */
234
+ export type OnPopWithViewUpdate<TChange> = (
235
+ result: TransactionResult,
236
+ viewUpdate: TChange | undefined,
237
+ ) => void;
238
+
201
239
  /**
202
240
  * An implementation of {@link Transactor} that {@link TransactionStack | uses a stack} and a {@link SharedTreeBranch | branch} to manage transactions.
203
241
  * @remarks Given a branch, this class will fork the branch when a transaction begins and squash the forked branch back into the original branch when the transaction ends.
@@ -270,14 +308,14 @@ export class SquashingTransactionStack<
270
308
  public constructor(
271
309
  public readonly branch: SharedTreeBranch<TEditor, TChange>,
272
310
  mintRevisionTag: () => RevisionTag,
273
- onPush?: () => OnPop | void,
311
+ onPush?: () => OnPopWithViewUpdate<TChange> | void,
274
312
  ) {
275
313
  super(
276
314
  // Invoked when an outer transaction starts
277
315
  (): Callbacks => {
278
316
  // Keep track of the commit that each transaction was on when it started
279
- // TODO:#8603: This may need to be computed differently if we allow rebasing during a transaction.
280
317
  const startHead = this.activeBranch.getHead();
318
+ const rebaser = this.branch.changeFamily.rebaser;
281
319
  const outerOnPop = onPush?.();
282
320
  let transactionRevision: RevisionTag | undefined;
283
321
  const transactionBranch = this.branch.fork(
@@ -287,33 +325,97 @@ export class SquashingTransactionStack<
287
325
  );
288
326
  this.setTransactionBranch(transactionBranch);
289
327
  transactionBranch.editor.enterTransaction();
328
+
290
329
  // Invoked when an outer transaction ends
291
330
  const onOuterTransactionPop: OnPop = (result) => {
292
331
  assert(!this.isInProgress(), 0xcae /* The outer transaction should be ending */);
293
332
  transactionBranch.editor.exitTransaction();
333
+
334
+ const sourcePath: GraphCommit<TChange>[] = [];
335
+ const targetPath: GraphCommit<TChange>[] = [];
336
+ const ancestor = findCommonAncestor(
337
+ [startHead, sourcePath],
338
+ [branch.getHead(), targetPath],
339
+ );
340
+ assert(ancestor !== undefined, 0xcce /* branches must be related */);
341
+
342
+ const transactionSteps: GraphCommit<TChange>[] = [];
343
+ findAncestor(
344
+ [transactionBranch.getHead(), transactionSteps],
345
+ (c) => c === startHead,
346
+ );
347
+
348
+ let viewUpdate: TChange | undefined;
294
349
  switch (result) {
295
350
  case TransactionResult.Abort: {
296
- // When a transaction is aborted, roll back all the transaction's changes on the current branch
351
+ // When a transaction is aborted, roll back all the transaction's changes on the current branch.
352
+ // It is important that this happens before and separately from updating the view because the `TreeCheckout` needs to
353
+ // revert some internal (state to match what it was before the transaction began) before applying the view update (if any).
297
354
  transactionBranch.removeAfter(startHead);
355
+ // If changes were made on `branch` since the transaction began, the view will need to be updated to reflect those changes.
356
+ if (targetPath.length > 0) {
357
+ viewUpdate = diffHistories(
358
+ rebaser,
359
+ startHead,
360
+ this.branch.getHead(),
361
+ mintRevisionTag,
362
+ );
363
+ }
298
364
  break;
299
365
  }
300
366
  case TransactionResult.Commit: {
301
- // ...squash all the new commits on the transaction branch into a new commit on the original branch
302
- const removedCommits: GraphCommit<TChange>[] = [];
303
- findAncestor(
304
- [transactionBranch.getHead(), removedCommits],
305
- (c) => c === startHead,
306
- );
307
- if (removedCommits.length > 0) {
308
- for (const commit of removedCommits) {
367
+ if (transactionSteps.length > 0) {
368
+ assert(
369
+ transactionRevision !== undefined,
370
+ 0xccf /* Expected transaction revision in the presence of transaction steps */,
371
+ );
372
+ for (const commit of transactionSteps) {
309
373
  assert(
310
374
  commit.revision === transactionRevision,
311
375
  0xcaf /* Unexpected commit in transaction */,
312
376
  );
313
377
  }
314
- const squash = this.branch.changeFamily.rebaser.compose(removedCommits);
315
- this.branch.apply(tagChange(squash, transactionRevision));
378
+ // Squash all the new commits on the transaction branch into a new commit on the original branch
379
+ const squash = rebaser.compose(transactionSteps);
380
+
381
+ if (targetPath.length === 0) {
382
+ // No changes were made on the original branch since the transaction began
383
+ // The transaction commit can be applied directly
384
+ this.branch.apply(tagChange(squash, transactionRevision));
385
+ // The view is already up-to-date so there's nothing more to do
386
+ } else {
387
+ // Some changes were made on `branch` since the transaction began
388
+ const unrebasedHead = mintCommit(startHead, {
389
+ change: squash,
390
+ revision: transactionRevision,
391
+ });
392
+ // We need to rebase the transaction commit on top of the new changes
393
+ const rebased = rebaseBranch(
394
+ mintRevisionTag,
395
+ rebaser,
396
+ unrebasedHead,
397
+ branch.getHead(),
398
+ );
399
+ assert(
400
+ rebased.newSourceHead.revision === transactionRevision,
401
+ 0xcd0 /* The transaction commit should be rebased to the tip */,
402
+ );
403
+ this.branch.apply(rebased.newSourceHead);
404
+ viewUpdate = rebased.sourceChange;
405
+ }
406
+ } else {
407
+ if (targetPath.length > 0) {
408
+ // Changes were made on `branch` since the transaction began.
409
+ // The view will need to be updated to reflect those changes.
410
+ viewUpdate = diffHistories(
411
+ rebaser,
412
+ startHead,
413
+ this.branch.getHead(),
414
+ mintRevisionTag,
415
+ );
416
+ }
316
417
  }
418
+
317
419
  break;
318
420
  }
319
421
  default: {
@@ -322,7 +424,7 @@ export class SquashingTransactionStack<
322
424
  }
323
425
  transactionBranch.dispose();
324
426
  this.setTransactionBranch(undefined);
325
- outerOnPop?.(result);
427
+ outerOnPop?.(result, viewUpdate);
326
428
  };
327
429
  // Invoked when a nested transaction begins
328
430
  const onNestedTransactionPush: OnPush = () => {
@@ -346,7 +448,7 @@ export class SquashingTransactionStack<
346
448
  unreachableCase(result);
347
449
  }
348
450
  }
349
- nestedOuterOnPop?.(result);
451
+ nestedOuterOnPop?.(result, undefined);
350
452
  },
351
453
  };
352
454
  };
@@ -99,11 +99,12 @@ export abstract class VersionedSummarizer<TVersion extends number> implements Su
99
99
  ): Promise<void> {
100
100
  let version: TVersion | undefined;
101
101
  if (await services.contains(summarizablesMetadataKey)) {
102
- const metadata = await readAndParseSnapshotBlob<SharedTreeSummarizableMetadata>(
102
+ const metadata = (await readAndParseSnapshotBlob(
103
103
  summarizablesMetadataKey,
104
104
  services,
105
105
  (contents) => parse(contents),
106
- );
106
+ // TODO: this type cast should use a codec to validate the data instead of just type casting.
107
+ )) as SharedTreeSummarizableMetadata;
107
108
  version = metadata.version as TVersion;
108
109
  if (!this.supportedVersions.has(version)) {
109
110
  throw new UsageError(`Cannot read version ${version} of shared tree summary.`);
@@ -53,6 +53,7 @@ export {
53
53
  adaptEnum,
54
54
  enumFromStrings,
55
55
  singletonSchema,
56
+ createCustomizedFluidFrameworkScopedFactory,
56
57
  } from "./schemaCreationUtilities.js";
57
58
  export {
58
59
  getIdentifierFromNode,
@@ -17,6 +17,7 @@ import type {
17
17
  } from "../core/index.js";
18
18
 
19
19
  import type { SchemaFactory, ScopedSchemaName } from "./schemaFactory.js";
20
+ import { SchemaFactoryBeta } from "./schemaFactoryBeta.js";
20
21
 
21
22
  /*
22
23
  * This file does two things:
@@ -247,9 +248,8 @@ export function enumFromStrings<
247
248
  type MembersUnion = Members[number];
248
249
 
249
250
  // Get all keys of the Members tuple which are numeric strings as union of numbers:
250
- type Indexes = Extract<keyof Members, `${number}`> extends `${infer N extends number}`
251
- ? N
252
- : never;
251
+ type Indexes =
252
+ Extract<keyof Members, `${number}`> extends `${infer N extends number}` ? N : never;
253
253
 
254
254
  type TOut = {
255
255
  [Index in Indexes as Members[Index]]: ReturnType<
@@ -298,11 +298,11 @@ function _enumFromStrings2<TScope extends string, const Members extends readonly
298
298
  factory: SchemaFactory<TScope>,
299
299
  members: Members,
300
300
  ) {
301
- const enumObject: {
301
+ const enumObject = Object.create(null) as {
302
302
  [key in keyof Members as Members[key] extends string
303
303
  ? Members[key]
304
304
  : string]: Members[key] extends string ? Members[key] : string;
305
- } = Object.create(null);
305
+ };
306
306
  for (const name of members) {
307
307
  Object.defineProperty(enumObject, name, {
308
308
  enumerable: true,
@@ -314,3 +314,33 @@ function _enumFromStrings2<TScope extends string, const Members extends readonly
314
314
 
315
315
  return adaptEnum(factory, enumObject);
316
316
  }
317
+
318
+ function createCustomizedScopedFactory<
319
+ TUserScope extends string,
320
+ TCreatorDomain extends string,
321
+ >(
322
+ inputSchemaFactory: SchemaFactoryBeta<TUserScope>,
323
+ creatorDomain: TCreatorDomain,
324
+ ): SchemaFactoryBeta<`${TCreatorDomain}<${TUserScope}>`> {
325
+ return new SchemaFactoryBeta(`${creatorDomain}<${inputSchemaFactory.scope}>`);
326
+ }
327
+
328
+ /**
329
+ * Declare a SchemaFactory for use in cases where the Fluid Framework's code creates the schema and owns its schema compatibility (and thus scope)
330
+ * but it is parameterized by user provided data, the `TUserScope`.
331
+ * @remarks
332
+ * This should allow future logic in {@link generateSchemaFromSimpleSchema} to recognize these schema as ones defined by Fluid Framework,
333
+ * and special case them to provide better APIs and maintain data invariants.
334
+ */
335
+ export function createCustomizedFluidFrameworkScopedFactory<
336
+ TUserScope extends string,
337
+ TCreatorDomain extends string,
338
+ >(
339
+ inputSchemaFactory: SchemaFactoryBeta<TUserScope>,
340
+ fluidDomainSuffix: TCreatorDomain,
341
+ ): SchemaFactoryBeta<`com.fluidframework.${TCreatorDomain}<${TUserScope}>`> {
342
+ return createCustomizedScopedFactory(
343
+ inputSchemaFactory,
344
+ `com.fluidframework.${fluidDomainSuffix}` as const,
345
+ );
346
+ }
@@ -149,7 +149,7 @@ export function createSimpleTreeIndex<
149
149
  isKeyValid: (key: TreeIndexKey) => key is TKey,
150
150
  indexableSchema?: readonly TreeNodeSchema[],
151
151
  ): SimpleTreeIndex<TKey, TValue> {
152
- const indexableSchemaMap = new Map();
152
+ const indexableSchemaMap = new Map<string, TreeNodeSchema>();
153
153
  if (indexableSchema === undefined) {
154
154
  walkFieldSchema(view.schema, {
155
155
  node: (schemus) => indexableSchemaMap.set(schemus.identifier, schemus),
@@ -138,4 +138,14 @@ export interface RunTransactionParams {
138
138
  * this client and ignored by all other clients.
139
139
  */
140
140
  readonly preconditions?: readonly TransactionConstraintAlpha[];
141
+ /**
142
+ * A label for this transaction that allows it to be correlated with later edits (e.g. for controlling undo/redo grouping).
143
+ *
144
+ * @remarks
145
+ * This label is associated with the commit produced by this transaction, and is surfaced through the
146
+ * `label` property of {@link ChangeMetadata} in the `commitApplied` or `changed` event.
147
+ *
148
+ * If there is a nested transaction, only the outermost transaction label will be used.
149
+ */
150
+ readonly label?: unknown;
141
151
  }
@@ -6,8 +6,8 @@
6
6
  import type { IFluidLoadable, IDisposable, Listenable } from "@fluidframework/core-interfaces";
7
7
 
8
8
  import type {
9
- CommitMetadata,
10
9
  ChangeMetadata,
10
+ CommitMetadata,
11
11
  RevertibleAlphaFactory,
12
12
  RevertibleFactory,
13
13
  } from "../../core/index.js";
@@ -211,7 +211,7 @@ export interface TreeBranchAlpha extends TreeBranch {
211
211
  fork(): TreeBranchAlpha;
212
212
 
213
213
  /**
214
- * Run a transaction which applies one or more edits to the tree as a single atomic unit.
214
+ * Run a synchronous transaction which applies one or more edits to the tree as a single atomic unit.
215
215
  * @param transaction - The function to run as the body of the transaction.
216
216
  * It should return a status object of {@link TransactionCallbackStatus | TransactionCallbackStatus } type.
217
217
  * It includes a "rollback" property which may be returned as true at any point during the transaction. This will
@@ -236,19 +236,20 @@ export interface TreeBranchAlpha extends TreeBranch {
236
236
  * If the transaction is rolled back, a corresponding change event will also be emitted for the rollback.
237
237
  *
238
238
  * Nested transactions:
239
- * This API can be called from within the transaction callback of another runTransaction call. That will have slightly different behavior:
239
+ * This API can be called from within the transaction callback of another `runTransaction` or `runTransactionAsync` call. That will have slightly different behavior:
240
240
  *
241
241
  * - If the inner transaction fails, only the inner transaction will be rolled back and the outer transaction will continue.
242
242
  * - Constraints will apply to the outermost transaction. Constraints are applied per commit and there will be one commit generated
243
243
  * for the outermost transaction which includes all inner transactions.
244
244
  * - Undo will undo the outermost transaction and all inner transactions.
245
+ * - If a label is provided in the params, only the label for the outermost transaction will be used. All other labels will be ignored.
245
246
  */
246
247
  runTransaction<TSuccessValue, TFailureValue>(
247
248
  transaction: () => TransactionCallbackStatus<TSuccessValue, TFailureValue>,
248
249
  params?: RunTransactionParams,
249
250
  ): TransactionResultExt<TSuccessValue, TFailureValue>;
250
251
  /**
251
- * Run a transaction which applies one or more edits to the tree as a single atomic unit.
252
+ * Run a synchronous transaction which applies one or more edits to the tree as a single atomic unit.
252
253
  * @param transaction - The function to run as the body of the transaction. It may return the following:
253
254
  *
254
255
  * - Nothing to indicate that the body of the transaction has successfully run.
@@ -273,7 +274,7 @@ export interface TreeBranchAlpha extends TreeBranch {
273
274
  * If the transaction is rolled back, a corresponding change event will also be emitted for the rollback.
274
275
  *
275
276
  * Nested transactions:
276
- * This API can be called from within the transaction callback of another runTransaction call. That will have slightly different behavior:
277
+ * This API can be called from within the transaction callback of another `runTransaction` or `runTransactionAsync` call. That will have slightly different behavior:
277
278
  *
278
279
  * - If the inner transaction fails, only the inner transaction will be rolled back and the outer transaction will continue.
279
280
  * - Constraints will apply to the outermost transaction. Constraints are applied per commit and there will be one commit generated
@@ -285,6 +286,87 @@ export interface TreeBranchAlpha extends TreeBranch {
285
286
  params?: RunTransactionParams,
286
287
  ): TransactionResult;
287
288
 
289
+ /**
290
+ * Run an asynchronous transaction which applies one or more edits to the tree as a single atomic unit.
291
+ * @param transaction - The function to run as the body of the transaction.
292
+ * It should return a promise that resolves to a status object of {@link TransactionCallbackStatus | TransactionCallbackStatus } type.
293
+ * It includes a "rollback" property which may be returned as true at any point during the transaction. This will
294
+ * abort the transaction and discard any changes it made so far.
295
+ * "rollback" can be set to false or left undefined to indicate that the body of the transaction has successfully run.
296
+ * @param params - The optional parameters for the transaction. It includes the constraints that will be checked before the transaction begins.
297
+ * @returns A promise that resolves to a result object of {@link TransactionResultExt | TransactionResultExt} type. It includes the following:
298
+ *
299
+ * - A "success" flag indicating whether the transaction was successful or not.
300
+ * - The success or failure value as returned by the transaction function.
301
+ *
302
+ * The promise will reject if the constraints are not met or something unexpected happens.
303
+ *
304
+ * @remarks
305
+ * As with synchronous transactions, using an asynchronous transaction has the following consequences:
306
+ * - All of the changes in the transaction are treated as a unit, therefore no other changes (either from this client or from a remote client) can be interleaved with the transaction changes.
307
+ * - If reverted (e.g. via an "undo" operation), all the changes in the transaction are reverted together.
308
+ * - The internal data representation of a transaction with many changes is generally smaller and more efficient than that of the changes when separate.
309
+ *
310
+ * Unlike with synchronous transactions, using an asynchronous transaction has the following consequences:
311
+ * - It is possible that other changes (either from this client by merging a branch or from a remote client) may be applied to the branch while this transaction is in progress.
312
+ * These other changes will be not be reflected on the branch until after this transaction completes,
313
+ * at which point the transaction changes will be applied after these other changes.
314
+ *
315
+ * Local change events will be emitted for each change as the transaction is being applied.
316
+ * If the transaction is rolled back, a corresponding change event will also be emitted for the rollback.
317
+ *
318
+ * Nested transactions:
319
+ * This API can be called from within the transaction callback of another `runTransactionAsync` call. That will have slightly different behavior:
320
+ *
321
+ * - If the inner transaction fails, only the inner transaction will be rolled back and the outer transaction will continue.
322
+ * - Constraints will apply to the outermost transaction. Constraints are applied per commit and there will be one commit generated
323
+ * for the outermost transaction which includes all inner transactions.
324
+ * - Undo will undo the outermost transaction and all inner transactions.
325
+ */
326
+ runTransactionAsync<TSuccessValue, TFailureValue>(
327
+ transaction: () => Promise<TransactionCallbackStatus<TSuccessValue, TFailureValue>>,
328
+ params?: RunTransactionParams,
329
+ ): Promise<TransactionResultExt<TSuccessValue, TFailureValue>>;
330
+ /**
331
+ * Run an asynchronous transaction which applies one or more edits to the tree as a single atomic unit.
332
+ * @param transaction - The function to run as the body of the transaction. It must return a promise that can resolve to any of the following:
333
+ *
334
+ * - Nothing to indicate that the body of the transaction has successfully run.
335
+ * - A status object of {@link VoidTransactionCallbackStatus | VoidTransactionCallbackStatus } type. It includes a "rollback" property which
336
+ * may be returned as true at any point during the transaction. This will abort the transaction and discard any changes it made so
337
+ * far. "rollback" can be set to false or left undefined to indicate that the body of the transaction has successfully run.
338
+ *
339
+ * @param params - The optional parameters for the transaction. It includes the constraints that will be checked before the transaction begins.
340
+ * @returns A promise that resolves to a result object of {@link TransactionResult | TransactionResult} type. It includes a "success" flag indicating whether the
341
+ * transaction was successful or not. The promise will reject if the constraints are not met or something unexpected happens.
342
+ *
343
+ * @remarks
344
+ * As with synchronous transactions, using an asynchronous transaction has the following consequences:
345
+ * - All of the changes in the transaction are treated as a unit, therefore no other changes (either from this client or from a remote client) can be interleaved with the transaction changes.
346
+ * - If reverted (e.g. via an "undo" operation), all the changes in the transaction are reverted together.
347
+ * - The internal data representation of a transaction with many changes is generally smaller and more efficient than that of the changes when separate.
348
+ *
349
+ * Unlike with synchronous transactions, using an asynchronous transaction has the following consequences:
350
+ * - It is possible that other changes (either from this client by merging a branch or from a remote client) may be applied to the branch while this transaction is in progress.
351
+ * These other changes will be not be reflected on the branch until after this transaction completes,
352
+ * at which point the transaction changes will be applied after these other changes.
353
+ *
354
+ * Local change events will be emitted for each change as the transaction is being applied.
355
+ * If the transaction is rolled back, a corresponding change event will also be emitted for the rollback.
356
+ *
357
+ * Nested transactions:
358
+ * This API can be called from within the transaction callback of another `runTransactionAsync` call. That will have slightly different behavior:
359
+ *
360
+ * - If the inner transaction fails, only the inner transaction will be rolled back and the outer transaction will continue.
361
+ * - Constraints will apply to the outermost transaction. Constraints are applied per commit and there will be one commit generated
362
+ * for the outermost transaction which includes all inner transactions.
363
+ * - Undo will undo the outermost transaction and all inner transactions.
364
+ */
365
+ runTransactionAsync(
366
+ transaction: () => Promise<VoidTransactionCallbackStatus | void>,
367
+ params?: RunTransactionParams,
368
+ ): Promise<TransactionResult>;
369
+
288
370
  /**
289
371
  * Apply a serialized change to this branch.
290
372
  * @param change - the change to apply.
@@ -544,7 +626,7 @@ export interface TreeBranchEvents extends Omit<TreeViewEvents, "commitApplied">
544
626
  * @param getRevertible - a function provided that allows users to get a revertible for the commit that was applied. If not provided,
545
627
  * this commit is not revertible.
546
628
  */
547
- commitApplied(data: CommitMetadata, getRevertible?: RevertibleAlphaFactory): void;
629
+ commitApplied(data: ChangeMetadata, getRevertible?: RevertibleAlphaFactory): void;
548
630
  }
549
631
 
550
632
  /**
@@ -575,15 +575,12 @@ export function isTreeNodeSchemaClass<
575
575
  * If a schema is both TreeNodeSchemaClass and TreeNodeSchemaNonClass, prefer TreeNodeSchemaClass since that includes subclasses properly.
576
576
  * @public
577
577
  */
578
- export type NodeFromSchema<T extends TreeNodeSchema> = T extends TreeNodeSchemaClass<
579
- string,
580
- NodeKind,
581
- infer TNode
582
- >
583
- ? TNode
584
- : T extends TreeNodeSchemaNonClass<string, NodeKind, infer TNode>
578
+ export type NodeFromSchema<T extends TreeNodeSchema> =
579
+ T extends TreeNodeSchemaClass<string, NodeKind, infer TNode>
585
580
  ? TNode
586
- : never;
581
+ : T extends TreeNodeSchemaNonClass<string, NodeKind, infer TNode>
582
+ ? TNode
583
+ : never;
587
584
 
588
585
  /**
589
586
  * Data which can be used as a node to be inserted.
@@ -200,6 +200,7 @@ export {
200
200
  checkSchemaCompatibilitySnapshots,
201
201
  type SnapshotFileSystem,
202
202
  type SchemaCompatibilitySnapshotsOptions,
203
+ createCustomizedFluidFrameworkScopedFactory,
203
204
  } from "./api/index.js";
204
205
  export type {
205
206
  SimpleTreeSchema,
@@ -266,6 +267,8 @@ export {
266
267
  type RecordNodePojoEmulationSchema,
267
268
  RecordNodeSchema,
268
269
  type TreeRecordNode,
270
+ type ArrayPlaceAnchor,
271
+ createArrayInsertionAnchor,
269
272
  } from "./node-kinds/index.js";
270
273
  export {
271
274
  unhydratedFlexTreeFromInsertable,
@@ -7,7 +7,7 @@ import { assert } from "@fluidframework/core-utils/internal";
7
7
  import { isFluidHandle } from "@fluidframework/runtime-utils/internal";
8
8
  import { UsageError } from "@fluidframework/telemetry-utils/internal";
9
9
 
10
- import { type TreeValue, ValueSchema } from "../core/index.js";
10
+ import { type FieldKey, type TreeValue, ValueSchema } from "../core/index.js";
11
11
  import {
12
12
  type FlexTreeNode,
13
13
  isFlexTreeNode,
@@ -28,6 +28,7 @@ import {
28
28
  type TreeNodeSchemaInitializedData,
29
29
  CompatibilityLevel,
30
30
  type FlexContent,
31
+ type UnhydratedFlexTreeField,
31
32
  } from "./core/index.js";
32
33
  import { getTreeNodeSchemaInitializedData } from "./createContext.js";
33
34
  import type { SimpleLeafNodeSchema } from "./simpleSchema.js";
@@ -185,7 +186,7 @@ export function leafToFlexContent(
185
186
  value: mappedValue,
186
187
  type: brand(mappedSchema.identifier),
187
188
  },
188
- new Map(),
189
+ new Map<FieldKey, UnhydratedFlexTreeField>(),
189
190
  ];
190
191
 
191
192
  return result;