@fluidframework/tree 2.81.1 → 2.83.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 (695) hide show
  1. package/CHANGELOG.md +168 -0
  2. package/README.md +33 -5
  3. package/api-report/tree.alpha.api.md +75 -39
  4. package/api-report/tree.beta.api.md +164 -3
  5. package/api-report/tree.legacy.beta.api.md +164 -3
  6. package/api-report/tree.legacy.public.api.md +2 -1
  7. package/api-report/tree.public.api.md +2 -1
  8. package/dist/alpha.d.ts +10 -4
  9. package/dist/beta.d.ts +4 -0
  10. package/dist/codec/codec.d.ts +18 -45
  11. package/dist/codec/codec.d.ts.map +1 -1
  12. package/dist/codec/codec.js +12 -50
  13. package/dist/codec/codec.js.map +1 -1
  14. package/dist/codec/index.d.ts +1 -1
  15. package/dist/codec/index.d.ts.map +1 -1
  16. package/dist/codec/index.js +2 -2
  17. package/dist/codec/index.js.map +1 -1
  18. package/dist/codec/versioned/codec.d.ts +20 -7
  19. package/dist/codec/versioned/codec.d.ts.map +1 -1
  20. package/dist/codec/versioned/codec.js +56 -30
  21. package/dist/codec/versioned/codec.js.map +1 -1
  22. package/dist/core/index.d.ts +1 -1
  23. package/dist/core/index.d.ts.map +1 -1
  24. package/dist/core/index.js +4 -2
  25. package/dist/core/index.js.map +1 -1
  26. package/dist/core/rebase/changeRebaser.d.ts +3 -2
  27. package/dist/core/rebase/changeRebaser.d.ts.map +1 -1
  28. package/dist/core/rebase/changeRebaser.js.map +1 -1
  29. package/dist/core/rebase/index.d.ts +1 -1
  30. package/dist/core/rebase/index.d.ts.map +1 -1
  31. package/dist/core/rebase/index.js +4 -2
  32. package/dist/core/rebase/index.js.map +1 -1
  33. package/dist/core/rebase/types.d.ts +23 -3
  34. package/dist/core/rebase/types.d.ts.map +1 -1
  35. package/dist/core/rebase/types.js +30 -16
  36. package/dist/core/rebase/types.js.map +1 -1
  37. package/dist/core/schema-stored/formatV1.d.ts +2 -2
  38. package/dist/core/schema-stored/formatV1.d.ts.map +1 -1
  39. package/dist/core/schema-stored/formatV1.js +0 -5
  40. package/dist/core/schema-stored/formatV1.js.map +1 -1
  41. package/dist/core/schema-stored/formatV2.d.ts +11 -10
  42. package/dist/core/schema-stored/formatV2.d.ts.map +1 -1
  43. package/dist/core/schema-stored/formatV2.js +1 -6
  44. package/dist/core/schema-stored/formatV2.js.map +1 -1
  45. package/dist/core/schema-stored/index.d.ts.map +1 -1
  46. package/dist/core/schema-stored/index.js.map +1 -1
  47. package/dist/core/schema-stored/schema.d.ts.map +1 -1
  48. package/dist/core/schema-stored/schema.js.map +1 -1
  49. package/dist/core/tree/anchorSet.d.ts.map +1 -1
  50. package/dist/core/tree/anchorSet.js.map +1 -1
  51. package/dist/core/tree/delta.d.ts +9 -7
  52. package/dist/core/tree/delta.d.ts.map +1 -1
  53. package/dist/core/tree/delta.js.map +1 -1
  54. package/dist/core/tree/deltaUtil.js +1 -1
  55. package/dist/core/tree/deltaUtil.js.map +1 -1
  56. package/dist/core/tree/detachedFieldIndexCodecs.d.ts.map +1 -1
  57. package/dist/core/tree/detachedFieldIndexCodecs.js +6 -4
  58. package/dist/core/tree/detachedFieldIndexCodecs.js.map +1 -1
  59. package/dist/core/tree/visitDelta.js +2 -2
  60. package/dist/core/tree/visitDelta.js.map +1 -1
  61. package/dist/extensibleUnionNode.d.ts +97 -0
  62. package/dist/extensibleUnionNode.d.ts.map +1 -0
  63. package/dist/extensibleUnionNode.js +89 -0
  64. package/dist/extensibleUnionNode.js.map +1 -0
  65. package/dist/feature-libraries/changeAtomIdBTree.d.ts +4 -2
  66. package/dist/feature-libraries/changeAtomIdBTree.d.ts.map +1 -1
  67. package/dist/feature-libraries/changeAtomIdBTree.js +9 -1
  68. package/dist/feature-libraries/changeAtomIdBTree.js.map +1 -1
  69. package/dist/feature-libraries/chunked-forest/codec/codecs.d.ts +1 -1
  70. package/dist/feature-libraries/chunked-forest/codec/codecs.d.ts.map +1 -1
  71. package/dist/feature-libraries/chunked-forest/codec/codecs.js +4 -4
  72. package/dist/feature-libraries/chunked-forest/codec/codecs.js.map +1 -1
  73. package/dist/feature-libraries/default-schema/defaultFieldKinds.d.ts +1 -3
  74. package/dist/feature-libraries/default-schema/defaultFieldKinds.d.ts.map +1 -1
  75. package/dist/feature-libraries/default-schema/defaultFieldKinds.js +20 -21
  76. package/dist/feature-libraries/default-schema/defaultFieldKinds.js.map +1 -1
  77. package/dist/feature-libraries/default-schema/index.d.ts +1 -1
  78. package/dist/feature-libraries/default-schema/index.d.ts.map +1 -1
  79. package/dist/feature-libraries/default-schema/index.js.map +1 -1
  80. package/dist/feature-libraries/forest-summary/codec.d.ts +2 -1
  81. package/dist/feature-libraries/forest-summary/codec.d.ts.map +1 -1
  82. package/dist/feature-libraries/forest-summary/codec.js +7 -1
  83. package/dist/feature-libraries/forest-summary/codec.js.map +1 -1
  84. package/dist/feature-libraries/forest-summary/forestSummarizer.d.ts.map +1 -1
  85. package/dist/feature-libraries/forest-summary/forestSummarizer.js +5 -2
  86. package/dist/feature-libraries/forest-summary/forestSummarizer.js.map +1 -1
  87. package/dist/feature-libraries/forest-summary/formatCommon.d.ts +4 -42
  88. package/dist/feature-libraries/forest-summary/formatCommon.d.ts.map +1 -1
  89. package/dist/feature-libraries/forest-summary/formatCommon.js +1 -2
  90. package/dist/feature-libraries/forest-summary/formatCommon.js.map +1 -1
  91. package/dist/feature-libraries/forest-summary/formatV1.d.ts +2 -41
  92. package/dist/feature-libraries/forest-summary/formatV1.d.ts.map +1 -1
  93. package/dist/feature-libraries/forest-summary/formatV1.js +1 -2
  94. package/dist/feature-libraries/forest-summary/formatV1.js.map +1 -1
  95. package/dist/feature-libraries/forest-summary/formatV2.d.ts +2 -41
  96. package/dist/feature-libraries/forest-summary/formatV2.d.ts.map +1 -1
  97. package/dist/feature-libraries/forest-summary/formatV2.js +1 -2
  98. package/dist/feature-libraries/forest-summary/formatV2.js.map +1 -1
  99. package/dist/feature-libraries/forest-summary/incrementalSummaryBuilder.d.ts +1 -1
  100. package/dist/feature-libraries/forest-summary/incrementalSummaryBuilder.d.ts.map +1 -1
  101. package/dist/feature-libraries/forest-summary/incrementalSummaryBuilder.js +1 -1
  102. package/dist/feature-libraries/forest-summary/incrementalSummaryBuilder.js.map +1 -1
  103. package/dist/feature-libraries/index.d.ts +3 -3
  104. package/dist/feature-libraries/index.d.ts.map +1 -1
  105. package/dist/feature-libraries/index.js +4 -3
  106. package/dist/feature-libraries/index.js.map +1 -1
  107. package/dist/feature-libraries/modular-schema/defaultRevisionReplacer.d.ts +2 -2
  108. package/dist/feature-libraries/modular-schema/defaultRevisionReplacer.d.ts.map +1 -1
  109. package/dist/feature-libraries/modular-schema/defaultRevisionReplacer.js +42 -22
  110. package/dist/feature-libraries/modular-schema/defaultRevisionReplacer.js.map +1 -1
  111. package/dist/feature-libraries/modular-schema/genericFieldKind.js +1 -1
  112. package/dist/feature-libraries/modular-schema/genericFieldKind.js.map +1 -1
  113. package/dist/feature-libraries/modular-schema/index.d.ts +1 -1
  114. package/dist/feature-libraries/modular-schema/index.d.ts.map +1 -1
  115. package/dist/feature-libraries/modular-schema/index.js +2 -1
  116. package/dist/feature-libraries/modular-schema/index.js.map +1 -1
  117. package/dist/feature-libraries/modular-schema/modularChangeCodecV1.d.ts +3 -3
  118. package/dist/feature-libraries/modular-schema/modularChangeCodecV1.d.ts.map +1 -1
  119. package/dist/feature-libraries/modular-schema/modularChangeCodecV1.js +13 -9
  120. package/dist/feature-libraries/modular-schema/modularChangeCodecV1.js.map +1 -1
  121. package/dist/feature-libraries/modular-schema/modularChangeCodecs.d.ts +11 -1
  122. package/dist/feature-libraries/modular-schema/modularChangeCodecs.d.ts.map +1 -1
  123. package/dist/feature-libraries/modular-schema/modularChangeCodecs.js +30 -7
  124. package/dist/feature-libraries/modular-schema/modularChangeCodecs.js.map +1 -1
  125. package/dist/feature-libraries/modular-schema/modularChangeFamily.d.ts.map +1 -1
  126. package/dist/feature-libraries/modular-schema/modularChangeFamily.js +38 -27
  127. package/dist/feature-libraries/modular-schema/modularChangeFamily.js.map +1 -1
  128. package/dist/feature-libraries/modular-schema/modularChangeFormatV1.d.ts +10 -127
  129. package/dist/feature-libraries/modular-schema/modularChangeFormatV1.d.ts.map +1 -1
  130. package/dist/feature-libraries/modular-schema/modularChangeFormatV1.js +2 -4
  131. package/dist/feature-libraries/modular-schema/modularChangeFormatV1.js.map +1 -1
  132. package/dist/feature-libraries/modular-schema/modularChangeFormatV2.d.ts +3 -79
  133. package/dist/feature-libraries/modular-schema/modularChangeFormatV2.d.ts.map +1 -1
  134. package/dist/feature-libraries/optional-field/optionalField.js +1 -1
  135. package/dist/feature-libraries/optional-field/optionalField.js.map +1 -1
  136. package/dist/feature-libraries/optional-field/requiredField.d.ts.map +1 -1
  137. package/dist/feature-libraries/optional-field/requiredField.js.map +1 -1
  138. package/dist/feature-libraries/schema-edits/schemaChangeFormat.d.ts +2 -2
  139. package/dist/feature-libraries/schema-index/codec.d.ts.map +1 -1
  140. package/dist/feature-libraries/schema-index/codec.js +6 -4
  141. package/dist/feature-libraries/schema-index/codec.js.map +1 -1
  142. package/dist/feature-libraries/schema-index/formatV2.d.ts +4 -4
  143. package/dist/feature-libraries/schema-index/schemaSummarizer.js +1 -1
  144. package/dist/feature-libraries/schema-index/schemaSummarizer.js.map +1 -1
  145. package/dist/feature-libraries/sequence-field/invert.js +2 -2
  146. package/dist/feature-libraries/sequence-field/invert.js.map +1 -1
  147. package/dist/feature-libraries/sequence-field/replaceRevisions.js +16 -16
  148. package/dist/feature-libraries/sequence-field/replaceRevisions.js.map +1 -1
  149. package/dist/feature-libraries/sequence-field/sequenceFieldToDelta.js +1 -1
  150. package/dist/feature-libraries/sequence-field/sequenceFieldToDelta.js.map +1 -1
  151. package/dist/index.d.ts +5 -5
  152. package/dist/index.d.ts.map +1 -1
  153. package/dist/index.js +5 -2
  154. package/dist/index.js.map +1 -1
  155. package/dist/legacy.d.ts +4 -0
  156. package/dist/packageVersion.d.ts +1 -1
  157. package/dist/packageVersion.js +1 -1
  158. package/dist/packageVersion.js.map +1 -1
  159. package/dist/shared-tree/independentView.d.ts +36 -13
  160. package/dist/shared-tree/independentView.d.ts.map +1 -1
  161. package/dist/shared-tree/independentView.js +1 -0
  162. package/dist/shared-tree/independentView.js.map +1 -1
  163. package/dist/shared-tree/index.d.ts +1 -1
  164. package/dist/shared-tree/index.d.ts.map +1 -1
  165. package/dist/shared-tree/index.js.map +1 -1
  166. package/dist/shared-tree/schematizingTreeView.d.ts +10 -0
  167. package/dist/shared-tree/schematizingTreeView.d.ts.map +1 -1
  168. package/dist/shared-tree/schematizingTreeView.js +25 -9
  169. package/dist/shared-tree/schematizingTreeView.js.map +1 -1
  170. package/dist/shared-tree/sharedTree.d.ts +3 -3
  171. package/dist/shared-tree/sharedTree.d.ts.map +1 -1
  172. package/dist/shared-tree/sharedTree.js +8 -32
  173. package/dist/shared-tree/sharedTree.js.map +1 -1
  174. package/dist/shared-tree/sharedTreeChangeCodecs.d.ts +11 -3
  175. package/dist/shared-tree/sharedTreeChangeCodecs.d.ts.map +1 -1
  176. package/dist/shared-tree/sharedTreeChangeCodecs.js +39 -5
  177. package/dist/shared-tree/sharedTreeChangeCodecs.js.map +1 -1
  178. package/dist/shared-tree/sharedTreeChangeFormat.d.ts +4 -4
  179. package/dist/shared-tree/tree.d.ts +1 -1
  180. package/dist/shared-tree/tree.js +1 -1
  181. package/dist/shared-tree/tree.js.map +1 -1
  182. package/dist/shared-tree/treeAlpha.d.ts +1 -1
  183. package/dist/shared-tree/treeAlpha.js.map +1 -1
  184. package/dist/shared-tree/treeCheckout.d.ts +20 -0
  185. package/dist/shared-tree/treeCheckout.d.ts.map +1 -1
  186. package/dist/shared-tree/treeCheckout.js +41 -7
  187. package/dist/shared-tree/treeCheckout.js.map +1 -1
  188. package/dist/shared-tree-core/editManagerCodecsCommons.d.ts +3 -3
  189. package/dist/shared-tree-core/editManagerCodecsCommons.d.ts.map +1 -1
  190. package/dist/shared-tree-core/editManagerCodecsCommons.js +2 -2
  191. package/dist/shared-tree-core/editManagerCodecsCommons.js.map +1 -1
  192. package/dist/shared-tree-core/editManagerCodecsV1toV4.d.ts +2 -2
  193. package/dist/shared-tree-core/editManagerCodecsV1toV4.d.ts.map +1 -1
  194. package/dist/shared-tree-core/editManagerCodecsV1toV4.js +1 -1
  195. package/dist/shared-tree-core/editManagerCodecsV1toV4.js.map +1 -1
  196. package/dist/shared-tree-core/editManagerCodecsVSharedBranches.d.ts +2 -2
  197. package/dist/shared-tree-core/editManagerCodecsVSharedBranches.d.ts.map +1 -1
  198. package/dist/shared-tree-core/editManagerCodecsVSharedBranches.js +1 -1
  199. package/dist/shared-tree-core/editManagerCodecsVSharedBranches.js.map +1 -1
  200. package/dist/shared-tree-core/editManagerSummarizer.js +1 -1
  201. package/dist/shared-tree-core/editManagerSummarizer.js.map +1 -1
  202. package/dist/shared-tree-core/messageCodecV1ToV4.d.ts.map +1 -1
  203. package/dist/shared-tree-core/messageCodecV1ToV4.js +2 -2
  204. package/dist/shared-tree-core/messageCodecV1ToV4.js.map +1 -1
  205. package/dist/shared-tree-core/messageCodecs.d.ts.map +1 -1
  206. package/dist/shared-tree-core/messageCodecs.js +2 -2
  207. package/dist/shared-tree-core/messageCodecs.js.map +1 -1
  208. package/dist/shared-tree-core/transaction.d.ts +14 -3
  209. package/dist/shared-tree-core/transaction.d.ts.map +1 -1
  210. package/dist/shared-tree-core/transaction.js +59 -16
  211. package/dist/shared-tree-core/transaction.js.map +1 -1
  212. package/dist/shared-tree-core/versionedSummarizer.d.ts.map +1 -1
  213. package/dist/shared-tree-core/versionedSummarizer.js +1 -1
  214. package/dist/shared-tree-core/versionedSummarizer.js.map +1 -1
  215. package/dist/simple-tree/api/index.d.ts +2 -2
  216. package/dist/simple-tree/api/index.d.ts.map +1 -1
  217. package/dist/simple-tree/api/index.js +4 -3
  218. package/dist/simple-tree/api/index.js.map +1 -1
  219. package/dist/simple-tree/api/schemaCreationUtilities.d.ts +9 -0
  220. package/dist/simple-tree/api/schemaCreationUtilities.d.ts.map +1 -1
  221. package/dist/simple-tree/api/schemaCreationUtilities.js +16 -1
  222. package/dist/simple-tree/api/schemaCreationUtilities.js.map +1 -1
  223. package/dist/simple-tree/api/simpleTreeIndex.js.map +1 -1
  224. package/dist/simple-tree/api/snapshotCompatibilityChecker.d.ts +148 -29
  225. package/dist/simple-tree/api/snapshotCompatibilityChecker.d.ts.map +1 -1
  226. package/dist/simple-tree/api/snapshotCompatibilityChecker.js +180 -99
  227. package/dist/simple-tree/api/snapshotCompatibilityChecker.js.map +1 -1
  228. package/dist/simple-tree/api/transactionTypes.d.ts +10 -0
  229. package/dist/simple-tree/api/transactionTypes.d.ts.map +1 -1
  230. package/dist/simple-tree/api/transactionTypes.js.map +1 -1
  231. package/dist/simple-tree/api/tree.d.ts +82 -7
  232. package/dist/simple-tree/api/tree.d.ts.map +1 -1
  233. package/dist/simple-tree/api/tree.js.map +1 -1
  234. package/dist/simple-tree/api/treeBeta.d.ts +1 -1
  235. package/dist/simple-tree/api/treeBeta.js.map +1 -1
  236. package/dist/simple-tree/core/allowedTypes.d.ts +1 -1
  237. package/dist/simple-tree/core/allowedTypes.js.map +1 -1
  238. package/dist/simple-tree/core/treeNodeSchema.d.ts.map +1 -1
  239. package/dist/simple-tree/core/treeNodeSchema.js.map +1 -1
  240. package/dist/simple-tree/core/unhydratedFlexTree.d.ts +1 -0
  241. package/dist/simple-tree/core/unhydratedFlexTree.d.ts.map +1 -1
  242. package/dist/simple-tree/core/unhydratedFlexTree.js +29 -0
  243. package/dist/simple-tree/core/unhydratedFlexTree.js.map +1 -1
  244. package/dist/simple-tree/index.d.ts +2 -2
  245. package/dist/simple-tree/index.d.ts.map +1 -1
  246. package/dist/simple-tree/index.js +5 -3
  247. package/dist/simple-tree/index.js.map +1 -1
  248. package/dist/simple-tree/leafNodeSchema.d.ts.map +1 -1
  249. package/dist/simple-tree/leafNodeSchema.js.map +1 -1
  250. package/dist/simple-tree/node-kinds/array/arrayNode.d.ts +63 -0
  251. package/dist/simple-tree/node-kinds/array/arrayNode.d.ts.map +1 -1
  252. package/dist/simple-tree/node-kinds/array/arrayNode.js +47 -14
  253. package/dist/simple-tree/node-kinds/array/arrayNode.js.map +1 -1
  254. package/dist/simple-tree/node-kinds/array/index.d.ts +1 -1
  255. package/dist/simple-tree/node-kinds/array/index.d.ts.map +1 -1
  256. package/dist/simple-tree/node-kinds/array/index.js +2 -1
  257. package/dist/simple-tree/node-kinds/array/index.js.map +1 -1
  258. package/dist/simple-tree/node-kinds/index.d.ts +1 -1
  259. package/dist/simple-tree/node-kinds/index.d.ts.map +1 -1
  260. package/dist/simple-tree/node-kinds/index.js +2 -1
  261. package/dist/simple-tree/node-kinds/index.js.map +1 -1
  262. package/dist/simple-tree/node-kinds/object/objectNode.d.ts.map +1 -1
  263. package/dist/simple-tree/node-kinds/object/objectNode.js.map +1 -1
  264. package/dist/simple-tree/unhydratedFlexTreeFromInsertable.d.ts.map +1 -1
  265. package/dist/simple-tree/unhydratedFlexTreeFromInsertable.js +33 -7
  266. package/dist/simple-tree/unhydratedFlexTreeFromInsertable.js.map +1 -1
  267. package/dist/tableSchema.d.ts +71 -48
  268. package/dist/tableSchema.d.ts.map +1 -1
  269. package/dist/tableSchema.js +200 -98
  270. package/dist/tableSchema.js.map +1 -1
  271. package/dist/text/textDomainFormatted.d.ts +3 -3
  272. package/dist/text/textDomainFormatted.d.ts.map +1 -1
  273. package/dist/text/textDomainFormatted.js +48 -32
  274. package/dist/text/textDomainFormatted.js.map +1 -1
  275. package/dist/util/bTreeUtils.d.ts +30 -4
  276. package/dist/util/bTreeUtils.d.ts.map +1 -1
  277. package/dist/util/bTreeUtils.js +35 -23
  278. package/dist/util/bTreeUtils.js.map +1 -1
  279. package/dist/util/brand.d.ts.map +1 -1
  280. package/dist/util/brand.js.map +1 -1
  281. package/dist/util/brandedMap.d.ts.map +1 -1
  282. package/dist/util/brandedMap.js.map +1 -1
  283. package/dist/util/breakable.d.ts.map +1 -1
  284. package/dist/util/breakable.js +2 -1
  285. package/dist/util/breakable.js.map +1 -1
  286. package/dist/util/index.d.ts +2 -2
  287. package/dist/util/index.d.ts.map +1 -1
  288. package/dist/util/index.js +6 -3
  289. package/dist/util/index.js.map +1 -1
  290. package/dist/util/opaque.d.ts.map +1 -1
  291. package/dist/util/opaque.js.map +1 -1
  292. package/dist/util/rangeMap.d.ts +3 -2
  293. package/dist/util/rangeMap.d.ts.map +1 -1
  294. package/dist/util/rangeMap.js +12 -7
  295. package/dist/util/rangeMap.js.map +1 -1
  296. package/dist/util/readSnapshotBlob.d.ts +1 -1
  297. package/dist/util/readSnapshotBlob.d.ts.map +1 -1
  298. package/dist/util/readSnapshotBlob.js.map +1 -1
  299. package/dist/util/typeCheck.d.ts.map +1 -1
  300. package/dist/util/typeCheck.js.map +1 -1
  301. package/dist/util/utils.d.ts +20 -16
  302. package/dist/util/utils.d.ts.map +1 -1
  303. package/dist/util/utils.js +49 -17
  304. package/dist/util/utils.js.map +1 -1
  305. package/eslint.config.mts +0 -9
  306. package/lib/alpha.d.ts +10 -4
  307. package/lib/beta.d.ts +4 -0
  308. package/lib/codec/codec.d.ts +18 -45
  309. package/lib/codec/codec.d.ts.map +1 -1
  310. package/lib/codec/codec.js +10 -47
  311. package/lib/codec/codec.js.map +1 -1
  312. package/lib/codec/index.d.ts +1 -1
  313. package/lib/codec/index.d.ts.map +1 -1
  314. package/lib/codec/index.js +1 -1
  315. package/lib/codec/index.js.map +1 -1
  316. package/lib/codec/versioned/codec.d.ts +20 -7
  317. package/lib/codec/versioned/codec.d.ts.map +1 -1
  318. package/lib/codec/versioned/codec.js +59 -33
  319. package/lib/codec/versioned/codec.js.map +1 -1
  320. package/lib/core/index.d.ts +1 -1
  321. package/lib/core/index.d.ts.map +1 -1
  322. package/lib/core/index.js +1 -1
  323. package/lib/core/index.js.map +1 -1
  324. package/lib/core/rebase/changeRebaser.d.ts +3 -2
  325. package/lib/core/rebase/changeRebaser.d.ts.map +1 -1
  326. package/lib/core/rebase/changeRebaser.js.map +1 -1
  327. package/lib/core/rebase/index.d.ts +1 -1
  328. package/lib/core/rebase/index.d.ts.map +1 -1
  329. package/lib/core/rebase/index.js +1 -1
  330. package/lib/core/rebase/index.js.map +1 -1
  331. package/lib/core/rebase/types.d.ts +23 -3
  332. package/lib/core/rebase/types.d.ts.map +1 -1
  333. package/lib/core/rebase/types.js +27 -15
  334. package/lib/core/rebase/types.js.map +1 -1
  335. package/lib/core/schema-stored/formatV1.d.ts +2 -2
  336. package/lib/core/schema-stored/formatV1.d.ts.map +1 -1
  337. package/lib/core/schema-stored/formatV1.js +0 -5
  338. package/lib/core/schema-stored/formatV1.js.map +1 -1
  339. package/lib/core/schema-stored/formatV2.d.ts +11 -10
  340. package/lib/core/schema-stored/formatV2.d.ts.map +1 -1
  341. package/lib/core/schema-stored/formatV2.js +1 -6
  342. package/lib/core/schema-stored/formatV2.js.map +1 -1
  343. package/lib/core/schema-stored/index.d.ts.map +1 -1
  344. package/lib/core/schema-stored/index.js +2 -0
  345. package/lib/core/schema-stored/index.js.map +1 -1
  346. package/lib/core/schema-stored/schema.d.ts.map +1 -1
  347. package/lib/core/schema-stored/schema.js.map +1 -1
  348. package/lib/core/tree/anchorSet.d.ts.map +1 -1
  349. package/lib/core/tree/anchorSet.js.map +1 -1
  350. package/lib/core/tree/delta.d.ts +9 -7
  351. package/lib/core/tree/delta.d.ts.map +1 -1
  352. package/lib/core/tree/delta.js.map +1 -1
  353. package/lib/core/tree/deltaUtil.js +1 -1
  354. package/lib/core/tree/deltaUtil.js.map +1 -1
  355. package/lib/core/tree/detachedFieldIndexCodecs.d.ts.map +1 -1
  356. package/lib/core/tree/detachedFieldIndexCodecs.js +6 -4
  357. package/lib/core/tree/detachedFieldIndexCodecs.js.map +1 -1
  358. package/lib/core/tree/visitDelta.js +2 -2
  359. package/lib/core/tree/visitDelta.js.map +1 -1
  360. package/lib/extensibleUnionNode.d.ts +97 -0
  361. package/lib/extensibleUnionNode.d.ts.map +1 -0
  362. package/lib/extensibleUnionNode.js +86 -0
  363. package/lib/extensibleUnionNode.js.map +1 -0
  364. package/lib/feature-libraries/changeAtomIdBTree.d.ts +4 -2
  365. package/lib/feature-libraries/changeAtomIdBTree.d.ts.map +1 -1
  366. package/lib/feature-libraries/changeAtomIdBTree.js +7 -0
  367. package/lib/feature-libraries/changeAtomIdBTree.js.map +1 -1
  368. package/lib/feature-libraries/chunked-forest/codec/codecs.d.ts +1 -1
  369. package/lib/feature-libraries/chunked-forest/codec/codecs.d.ts.map +1 -1
  370. package/lib/feature-libraries/chunked-forest/codec/codecs.js +5 -5
  371. package/lib/feature-libraries/chunked-forest/codec/codecs.js.map +1 -1
  372. package/lib/feature-libraries/default-schema/defaultFieldKinds.d.ts +1 -3
  373. package/lib/feature-libraries/default-schema/defaultFieldKinds.d.ts.map +1 -1
  374. package/lib/feature-libraries/default-schema/defaultFieldKinds.js +4 -5
  375. package/lib/feature-libraries/default-schema/defaultFieldKinds.js.map +1 -1
  376. package/lib/feature-libraries/default-schema/index.d.ts +1 -1
  377. package/lib/feature-libraries/default-schema/index.d.ts.map +1 -1
  378. package/lib/feature-libraries/default-schema/index.js.map +1 -1
  379. package/lib/feature-libraries/forest-summary/codec.d.ts +2 -1
  380. package/lib/feature-libraries/forest-summary/codec.d.ts.map +1 -1
  381. package/lib/feature-libraries/forest-summary/codec.js +8 -2
  382. package/lib/feature-libraries/forest-summary/codec.js.map +1 -1
  383. package/lib/feature-libraries/forest-summary/forestSummarizer.d.ts.map +1 -1
  384. package/lib/feature-libraries/forest-summary/forestSummarizer.js +6 -3
  385. package/lib/feature-libraries/forest-summary/forestSummarizer.js.map +1 -1
  386. package/lib/feature-libraries/forest-summary/formatCommon.d.ts +4 -42
  387. package/lib/feature-libraries/forest-summary/formatCommon.d.ts.map +1 -1
  388. package/lib/feature-libraries/forest-summary/formatCommon.js +2 -3
  389. package/lib/feature-libraries/forest-summary/formatCommon.js.map +1 -1
  390. package/lib/feature-libraries/forest-summary/formatV1.d.ts +2 -41
  391. package/lib/feature-libraries/forest-summary/formatV1.d.ts.map +1 -1
  392. package/lib/feature-libraries/forest-summary/formatV1.js +1 -2
  393. package/lib/feature-libraries/forest-summary/formatV1.js.map +1 -1
  394. package/lib/feature-libraries/forest-summary/formatV2.d.ts +2 -41
  395. package/lib/feature-libraries/forest-summary/formatV2.d.ts.map +1 -1
  396. package/lib/feature-libraries/forest-summary/formatV2.js +1 -2
  397. package/lib/feature-libraries/forest-summary/formatV2.js.map +1 -1
  398. package/lib/feature-libraries/forest-summary/incrementalSummaryBuilder.d.ts +1 -1
  399. package/lib/feature-libraries/forest-summary/incrementalSummaryBuilder.d.ts.map +1 -1
  400. package/lib/feature-libraries/forest-summary/incrementalSummaryBuilder.js +1 -1
  401. package/lib/feature-libraries/forest-summary/incrementalSummaryBuilder.js.map +1 -1
  402. package/lib/feature-libraries/index.d.ts +3 -3
  403. package/lib/feature-libraries/index.d.ts.map +1 -1
  404. package/lib/feature-libraries/index.js +3 -3
  405. package/lib/feature-libraries/index.js.map +1 -1
  406. package/lib/feature-libraries/modular-schema/defaultRevisionReplacer.d.ts +2 -2
  407. package/lib/feature-libraries/modular-schema/defaultRevisionReplacer.d.ts.map +1 -1
  408. package/lib/feature-libraries/modular-schema/defaultRevisionReplacer.js +41 -21
  409. package/lib/feature-libraries/modular-schema/defaultRevisionReplacer.js.map +1 -1
  410. package/lib/feature-libraries/modular-schema/genericFieldKind.js +1 -1
  411. package/lib/feature-libraries/modular-schema/genericFieldKind.js.map +1 -1
  412. package/lib/feature-libraries/modular-schema/index.d.ts +1 -1
  413. package/lib/feature-libraries/modular-schema/index.d.ts.map +1 -1
  414. package/lib/feature-libraries/modular-schema/index.js +1 -1
  415. package/lib/feature-libraries/modular-schema/index.js.map +1 -1
  416. package/lib/feature-libraries/modular-schema/modularChangeCodecV1.d.ts +3 -3
  417. package/lib/feature-libraries/modular-schema/modularChangeCodecV1.d.ts.map +1 -1
  418. package/lib/feature-libraries/modular-schema/modularChangeCodecV1.js +14 -10
  419. package/lib/feature-libraries/modular-schema/modularChangeCodecV1.js.map +1 -1
  420. package/lib/feature-libraries/modular-schema/modularChangeCodecs.d.ts +11 -1
  421. package/lib/feature-libraries/modular-schema/modularChangeCodecs.d.ts.map +1 -1
  422. package/lib/feature-libraries/modular-schema/modularChangeCodecs.js +29 -6
  423. package/lib/feature-libraries/modular-schema/modularChangeCodecs.js.map +1 -1
  424. package/lib/feature-libraries/modular-schema/modularChangeFamily.d.ts.map +1 -1
  425. package/lib/feature-libraries/modular-schema/modularChangeFamily.js +41 -30
  426. package/lib/feature-libraries/modular-schema/modularChangeFamily.js.map +1 -1
  427. package/lib/feature-libraries/modular-schema/modularChangeFormatV1.d.ts +10 -127
  428. package/lib/feature-libraries/modular-schema/modularChangeFormatV1.d.ts.map +1 -1
  429. package/lib/feature-libraries/modular-schema/modularChangeFormatV1.js +2 -4
  430. package/lib/feature-libraries/modular-schema/modularChangeFormatV1.js.map +1 -1
  431. package/lib/feature-libraries/modular-schema/modularChangeFormatV2.d.ts +3 -79
  432. package/lib/feature-libraries/modular-schema/modularChangeFormatV2.d.ts.map +1 -1
  433. package/lib/feature-libraries/optional-field/optionalField.js +1 -1
  434. package/lib/feature-libraries/optional-field/optionalField.js.map +1 -1
  435. package/lib/feature-libraries/optional-field/requiredField.d.ts.map +1 -1
  436. package/lib/feature-libraries/optional-field/requiredField.js.map +1 -1
  437. package/lib/feature-libraries/schema-edits/schemaChangeFormat.d.ts +2 -2
  438. package/lib/feature-libraries/schema-index/codec.d.ts.map +1 -1
  439. package/lib/feature-libraries/schema-index/codec.js +6 -4
  440. package/lib/feature-libraries/schema-index/codec.js.map +1 -1
  441. package/lib/feature-libraries/schema-index/formatV2.d.ts +4 -4
  442. package/lib/feature-libraries/schema-index/schemaSummarizer.js +1 -1
  443. package/lib/feature-libraries/schema-index/schemaSummarizer.js.map +1 -1
  444. package/lib/feature-libraries/sequence-field/invert.js +2 -2
  445. package/lib/feature-libraries/sequence-field/invert.js.map +1 -1
  446. package/lib/feature-libraries/sequence-field/replaceRevisions.js +16 -16
  447. package/lib/feature-libraries/sequence-field/replaceRevisions.js.map +1 -1
  448. package/lib/feature-libraries/sequence-field/sequenceFieldToDelta.js +1 -1
  449. package/lib/feature-libraries/sequence-field/sequenceFieldToDelta.js.map +1 -1
  450. package/lib/index.d.ts +5 -5
  451. package/lib/index.d.ts.map +1 -1
  452. package/lib/index.js +4 -3
  453. package/lib/index.js.map +1 -1
  454. package/lib/legacy.d.ts +4 -0
  455. package/lib/packageVersion.d.ts +1 -1
  456. package/lib/packageVersion.js +1 -1
  457. package/lib/packageVersion.js.map +1 -1
  458. package/lib/shared-tree/independentView.d.ts +36 -13
  459. package/lib/shared-tree/independentView.d.ts.map +1 -1
  460. package/lib/shared-tree/independentView.js +1 -0
  461. package/lib/shared-tree/independentView.js.map +1 -1
  462. package/lib/shared-tree/index.d.ts +1 -1
  463. package/lib/shared-tree/index.d.ts.map +1 -1
  464. package/lib/shared-tree/index.js.map +1 -1
  465. package/lib/shared-tree/schematizingTreeView.d.ts +10 -0
  466. package/lib/shared-tree/schematizingTreeView.d.ts.map +1 -1
  467. package/lib/shared-tree/schematizingTreeView.js +25 -9
  468. package/lib/shared-tree/schematizingTreeView.js.map +1 -1
  469. package/lib/shared-tree/sharedTree.d.ts +3 -3
  470. package/lib/shared-tree/sharedTree.d.ts.map +1 -1
  471. package/lib/shared-tree/sharedTree.js +10 -34
  472. package/lib/shared-tree/sharedTree.js.map +1 -1
  473. package/lib/shared-tree/sharedTreeChangeCodecs.d.ts +11 -3
  474. package/lib/shared-tree/sharedTreeChangeCodecs.d.ts.map +1 -1
  475. package/lib/shared-tree/sharedTreeChangeCodecs.js +40 -6
  476. package/lib/shared-tree/sharedTreeChangeCodecs.js.map +1 -1
  477. package/lib/shared-tree/sharedTreeChangeFormat.d.ts +4 -4
  478. package/lib/shared-tree/tree.d.ts +1 -1
  479. package/lib/shared-tree/tree.js +1 -1
  480. package/lib/shared-tree/tree.js.map +1 -1
  481. package/lib/shared-tree/treeAlpha.d.ts +1 -1
  482. package/lib/shared-tree/treeAlpha.js.map +1 -1
  483. package/lib/shared-tree/treeCheckout.d.ts +20 -0
  484. package/lib/shared-tree/treeCheckout.d.ts.map +1 -1
  485. package/lib/shared-tree/treeCheckout.js +41 -7
  486. package/lib/shared-tree/treeCheckout.js.map +1 -1
  487. package/lib/shared-tree-core/editManagerCodecsCommons.d.ts +3 -3
  488. package/lib/shared-tree-core/editManagerCodecsCommons.d.ts.map +1 -1
  489. package/lib/shared-tree-core/editManagerCodecsCommons.js +2 -2
  490. package/lib/shared-tree-core/editManagerCodecsCommons.js.map +1 -1
  491. package/lib/shared-tree-core/editManagerCodecsV1toV4.d.ts +2 -2
  492. package/lib/shared-tree-core/editManagerCodecsV1toV4.d.ts.map +1 -1
  493. package/lib/shared-tree-core/editManagerCodecsV1toV4.js +2 -2
  494. package/lib/shared-tree-core/editManagerCodecsV1toV4.js.map +1 -1
  495. package/lib/shared-tree-core/editManagerCodecsVSharedBranches.d.ts +2 -2
  496. package/lib/shared-tree-core/editManagerCodecsVSharedBranches.d.ts.map +1 -1
  497. package/lib/shared-tree-core/editManagerCodecsVSharedBranches.js +2 -2
  498. package/lib/shared-tree-core/editManagerCodecsVSharedBranches.js.map +1 -1
  499. package/lib/shared-tree-core/editManagerSummarizer.js +1 -1
  500. package/lib/shared-tree-core/editManagerSummarizer.js.map +1 -1
  501. package/lib/shared-tree-core/messageCodecV1ToV4.d.ts.map +1 -1
  502. package/lib/shared-tree-core/messageCodecV1ToV4.js +2 -2
  503. package/lib/shared-tree-core/messageCodecV1ToV4.js.map +1 -1
  504. package/lib/shared-tree-core/messageCodecs.d.ts.map +1 -1
  505. package/lib/shared-tree-core/messageCodecs.js +2 -2
  506. package/lib/shared-tree-core/messageCodecs.js.map +1 -1
  507. package/lib/shared-tree-core/transaction.d.ts +14 -3
  508. package/lib/shared-tree-core/transaction.d.ts.map +1 -1
  509. package/lib/shared-tree-core/transaction.js +61 -18
  510. package/lib/shared-tree-core/transaction.js.map +1 -1
  511. package/lib/shared-tree-core/versionedSummarizer.d.ts.map +1 -1
  512. package/lib/shared-tree-core/versionedSummarizer.js +1 -1
  513. package/lib/shared-tree-core/versionedSummarizer.js.map +1 -1
  514. package/lib/simple-tree/api/index.d.ts +2 -2
  515. package/lib/simple-tree/api/index.d.ts.map +1 -1
  516. package/lib/simple-tree/api/index.js +2 -2
  517. package/lib/simple-tree/api/index.js.map +1 -1
  518. package/lib/simple-tree/api/schemaCreationUtilities.d.ts +9 -0
  519. package/lib/simple-tree/api/schemaCreationUtilities.d.ts.map +1 -1
  520. package/lib/simple-tree/api/schemaCreationUtilities.js +14 -0
  521. package/lib/simple-tree/api/schemaCreationUtilities.js.map +1 -1
  522. package/lib/simple-tree/api/simpleTreeIndex.js.map +1 -1
  523. package/lib/simple-tree/api/snapshotCompatibilityChecker.d.ts +148 -29
  524. package/lib/simple-tree/api/snapshotCompatibilityChecker.d.ts.map +1 -1
  525. package/lib/simple-tree/api/snapshotCompatibilityChecker.js +179 -98
  526. package/lib/simple-tree/api/snapshotCompatibilityChecker.js.map +1 -1
  527. package/lib/simple-tree/api/transactionTypes.d.ts +10 -0
  528. package/lib/simple-tree/api/transactionTypes.d.ts.map +1 -1
  529. package/lib/simple-tree/api/transactionTypes.js.map +1 -1
  530. package/lib/simple-tree/api/tree.d.ts +82 -7
  531. package/lib/simple-tree/api/tree.d.ts.map +1 -1
  532. package/lib/simple-tree/api/tree.js.map +1 -1
  533. package/lib/simple-tree/api/treeBeta.d.ts +1 -1
  534. package/lib/simple-tree/api/treeBeta.js.map +1 -1
  535. package/lib/simple-tree/core/allowedTypes.d.ts +1 -1
  536. package/lib/simple-tree/core/allowedTypes.js.map +1 -1
  537. package/lib/simple-tree/core/treeNodeSchema.d.ts.map +1 -1
  538. package/lib/simple-tree/core/treeNodeSchema.js.map +1 -1
  539. package/lib/simple-tree/core/unhydratedFlexTree.d.ts +1 -0
  540. package/lib/simple-tree/core/unhydratedFlexTree.d.ts.map +1 -1
  541. package/lib/simple-tree/core/unhydratedFlexTree.js +29 -0
  542. package/lib/simple-tree/core/unhydratedFlexTree.js.map +1 -1
  543. package/lib/simple-tree/index.d.ts +2 -2
  544. package/lib/simple-tree/index.d.ts.map +1 -1
  545. package/lib/simple-tree/index.js +2 -2
  546. package/lib/simple-tree/index.js.map +1 -1
  547. package/lib/simple-tree/leafNodeSchema.d.ts.map +1 -1
  548. package/lib/simple-tree/leafNodeSchema.js.map +1 -1
  549. package/lib/simple-tree/node-kinds/array/arrayNode.d.ts +63 -0
  550. package/lib/simple-tree/node-kinds/array/arrayNode.d.ts.map +1 -1
  551. package/lib/simple-tree/node-kinds/array/arrayNode.js +46 -14
  552. package/lib/simple-tree/node-kinds/array/arrayNode.js.map +1 -1
  553. package/lib/simple-tree/node-kinds/array/index.d.ts +1 -1
  554. package/lib/simple-tree/node-kinds/array/index.d.ts.map +1 -1
  555. package/lib/simple-tree/node-kinds/array/index.js +1 -1
  556. package/lib/simple-tree/node-kinds/array/index.js.map +1 -1
  557. package/lib/simple-tree/node-kinds/index.d.ts +1 -1
  558. package/lib/simple-tree/node-kinds/index.d.ts.map +1 -1
  559. package/lib/simple-tree/node-kinds/index.js +1 -1
  560. package/lib/simple-tree/node-kinds/index.js.map +1 -1
  561. package/lib/simple-tree/node-kinds/object/objectNode.d.ts.map +1 -1
  562. package/lib/simple-tree/node-kinds/object/objectNode.js.map +1 -1
  563. package/lib/simple-tree/unhydratedFlexTreeFromInsertable.d.ts.map +1 -1
  564. package/lib/simple-tree/unhydratedFlexTreeFromInsertable.js +34 -8
  565. package/lib/simple-tree/unhydratedFlexTreeFromInsertable.js.map +1 -1
  566. package/lib/tableSchema.d.ts +71 -48
  567. package/lib/tableSchema.d.ts.map +1 -1
  568. package/lib/tableSchema.js +201 -99
  569. package/lib/tableSchema.js.map +1 -1
  570. package/lib/text/textDomainFormatted.d.ts +3 -3
  571. package/lib/text/textDomainFormatted.d.ts.map +1 -1
  572. package/lib/text/textDomainFormatted.js +30 -14
  573. package/lib/text/textDomainFormatted.js.map +1 -1
  574. package/lib/util/bTreeUtils.d.ts +30 -4
  575. package/lib/util/bTreeUtils.d.ts.map +1 -1
  576. package/lib/util/bTreeUtils.js +33 -22
  577. package/lib/util/bTreeUtils.js.map +1 -1
  578. package/lib/util/brand.d.ts.map +1 -1
  579. package/lib/util/brand.js.map +1 -1
  580. package/lib/util/brandedMap.d.ts.map +1 -1
  581. package/lib/util/brandedMap.js.map +1 -1
  582. package/lib/util/breakable.d.ts.map +1 -1
  583. package/lib/util/breakable.js +2 -1
  584. package/lib/util/breakable.js.map +1 -1
  585. package/lib/util/index.d.ts +2 -2
  586. package/lib/util/index.d.ts.map +1 -1
  587. package/lib/util/index.js +2 -2
  588. package/lib/util/index.js.map +1 -1
  589. package/lib/util/opaque.d.ts.map +1 -1
  590. package/lib/util/opaque.js.map +1 -1
  591. package/lib/util/rangeMap.d.ts +3 -2
  592. package/lib/util/rangeMap.d.ts.map +1 -1
  593. package/lib/util/rangeMap.js +12 -7
  594. package/lib/util/rangeMap.js.map +1 -1
  595. package/lib/util/readSnapshotBlob.d.ts +1 -1
  596. package/lib/util/readSnapshotBlob.d.ts.map +1 -1
  597. package/lib/util/readSnapshotBlob.js.map +1 -1
  598. package/lib/util/typeCheck.d.ts.map +1 -1
  599. package/lib/util/typeCheck.js.map +1 -1
  600. package/lib/util/utils.d.ts +20 -16
  601. package/lib/util/utils.d.ts.map +1 -1
  602. package/lib/util/utils.js +44 -15
  603. package/lib/util/utils.js.map +1 -1
  604. package/package.json +24 -24
  605. package/src/codec/codec.ts +33 -116
  606. package/src/codec/index.ts +2 -3
  607. package/src/codec/versioned/codec.ts +127 -95
  608. package/src/core/index.ts +3 -1
  609. package/src/core/rebase/changeRebaser.ts +3 -2
  610. package/src/core/rebase/index.ts +3 -1
  611. package/src/core/rebase/types.ts +51 -13
  612. package/src/core/schema-stored/formatV1.ts +2 -4
  613. package/src/core/schema-stored/formatV2.ts +9 -7
  614. package/src/core/schema-stored/index.ts +2 -0
  615. package/src/core/schema-stored/schema.ts +4 -1
  616. package/src/core/tree/anchorSet.ts +1 -3
  617. package/src/core/tree/delta.ts +9 -7
  618. package/src/core/tree/deltaUtil.ts +1 -1
  619. package/src/core/tree/detachedFieldIndexCodecs.ts +6 -4
  620. package/src/core/tree/visitDelta.ts +2 -2
  621. package/src/extensibleUnionNode.ts +177 -0
  622. package/src/feature-libraries/changeAtomIdBTree.ts +17 -2
  623. package/src/feature-libraries/chunked-forest/codec/codecs.ts +5 -11
  624. package/src/feature-libraries/default-schema/defaultFieldKinds.ts +5 -6
  625. package/src/feature-libraries/default-schema/index.ts +0 -1
  626. package/src/feature-libraries/forest-summary/codec.ts +15 -9
  627. package/src/feature-libraries/forest-summary/forestSummarizer.ts +15 -3
  628. package/src/feature-libraries/forest-summary/formatCommon.ts +7 -6
  629. package/src/feature-libraries/forest-summary/formatV1.ts +1 -3
  630. package/src/feature-libraries/forest-summary/formatV2.ts +1 -3
  631. package/src/feature-libraries/forest-summary/incrementalSummaryBuilder.ts +4 -5
  632. package/src/feature-libraries/index.ts +3 -2
  633. package/src/feature-libraries/modular-schema/defaultRevisionReplacer.ts +57 -31
  634. package/src/feature-libraries/modular-schema/genericFieldKind.ts +1 -1
  635. package/src/feature-libraries/modular-schema/index.ts +4 -1
  636. package/src/feature-libraries/modular-schema/modularChangeCodecV1.ts +12 -12
  637. package/src/feature-libraries/modular-schema/modularChangeCodecs.ts +32 -7
  638. package/src/feature-libraries/modular-schema/modularChangeFamily.ts +54 -33
  639. package/src/feature-libraries/modular-schema/modularChangeFormatV1.ts +2 -4
  640. package/src/feature-libraries/optional-field/optionalField.ts +1 -1
  641. package/src/feature-libraries/optional-field/requiredField.ts +2 -4
  642. package/src/feature-libraries/schema-index/codec.ts +7 -5
  643. package/src/feature-libraries/schema-index/schemaSummarizer.ts +1 -1
  644. package/src/feature-libraries/sequence-field/invert.ts +2 -2
  645. package/src/feature-libraries/sequence-field/replaceRevisions.ts +17 -10
  646. package/src/feature-libraries/sequence-field/sequenceFieldToDelta.ts +1 -1
  647. package/src/index.ts +14 -9
  648. package/src/packageVersion.ts +1 -1
  649. package/src/shared-tree/independentView.ts +42 -6
  650. package/src/shared-tree/index.ts +2 -0
  651. package/src/shared-tree/schematizingTreeView.ts +63 -18
  652. package/src/shared-tree/sharedTree.ts +19 -37
  653. package/src/shared-tree/sharedTreeChangeCodecs.ts +45 -11
  654. package/src/shared-tree/tree.ts +2 -2
  655. package/src/shared-tree/treeAlpha.ts +1 -1
  656. package/src/shared-tree/treeCheckout.ts +52 -7
  657. package/src/shared-tree-core/editManagerCodecsCommons.ts +7 -7
  658. package/src/shared-tree-core/editManagerCodecsV1toV4.ts +3 -10
  659. package/src/shared-tree-core/editManagerCodecsVSharedBranches.ts +3 -10
  660. package/src/shared-tree-core/editManagerSummarizer.ts +1 -1
  661. package/src/shared-tree-core/messageCodecV1ToV4.ts +4 -3
  662. package/src/shared-tree-core/messageCodecs.ts +2 -6
  663. package/src/shared-tree-core/transaction.ts +125 -23
  664. package/src/shared-tree-core/versionedSummarizer.ts +3 -2
  665. package/src/simple-tree/api/index.ts +3 -2
  666. package/src/simple-tree/api/schemaCreationUtilities.ts +35 -5
  667. package/src/simple-tree/api/simpleTreeIndex.ts +1 -1
  668. package/src/simple-tree/api/snapshotCompatibilityChecker.ts +344 -142
  669. package/src/simple-tree/api/transactionTypes.ts +10 -0
  670. package/src/simple-tree/api/tree.ts +89 -7
  671. package/src/simple-tree/api/treeBeta.ts +1 -1
  672. package/src/simple-tree/core/allowedTypes.ts +1 -1
  673. package/src/simple-tree/core/treeNodeSchema.ts +5 -8
  674. package/src/simple-tree/core/unhydratedFlexTree.ts +43 -1
  675. package/src/simple-tree/index.ts +5 -2
  676. package/src/simple-tree/leafNodeSchema.ts +3 -2
  677. package/src/simple-tree/node-kinds/array/arrayNode.ts +99 -19
  678. package/src/simple-tree/node-kinds/array/index.ts +2 -0
  679. package/src/simple-tree/node-kinds/index.ts +2 -0
  680. package/src/simple-tree/node-kinds/object/objectNode.ts +19 -18
  681. package/src/simple-tree/unhydratedFlexTreeFromInsertable.ts +51 -10
  682. package/src/tableSchema.ts +280 -140
  683. package/src/text/textDomainFormatted.ts +37 -17
  684. package/src/util/bTreeUtils.ts +55 -32
  685. package/src/util/brand.ts +4 -12
  686. package/src/util/brandedMap.ts +2 -6
  687. package/src/util/breakable.ts +3 -2
  688. package/src/util/index.ts +9 -3
  689. package/src/util/opaque.ts +2 -6
  690. package/src/util/rangeMap.ts +20 -11
  691. package/src/util/readSnapshotBlob.ts +3 -3
  692. package/src/util/typeCheck.ts +11 -9
  693. package/src/util/utils.ts +57 -28
  694. package/api-extractor-lint.json +0 -4
  695. package/biome.jsonc +0 -4
@@ -3,12 +3,12 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
  import { assert } from "@fluidframework/core-utils/internal";
6
- import { withSchemaValidation, } from "../codec/index.js";
6
+ import { withSchemaValidation } from "../codec/index.js";
7
7
  import { JsonCompatibleReadOnlySchema, } from "../util/index.js";
8
8
  import { decodeSharedBranch, encodeSharedBranch } from "./editManagerCodecsCommons.js";
9
9
  import { EncodedEditManager } from "./editManagerFormatVSharedBranches.js";
10
10
  export function makeSharedBranchesCodecWithVersion(changeCodec, revisionTagCodec, options, version) {
11
- const format = EncodedEditManager(changeCodec.json.encodedSchema ?? JsonCompatibleReadOnlySchema);
11
+ const format = EncodedEditManager(changeCodec.encodedSchema ?? JsonCompatibleReadOnlySchema);
12
12
  const codec = withSchemaValidation(format, {
13
13
  encode: (data, context) => {
14
14
  const mainBranch = encodeSharedBranch(changeCodec, revisionTagCodec, data.main, context, data.originator);
@@ -1 +1 @@
1
- {"version":3,"file":"editManagerCodecsVSharedBranches.js","sourceRoot":"","sources":["../../src/shared-tree-core/editManagerCodecsVSharedBranches.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,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License.\n */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport type { IIdCompressor } from \"@fluidframework/id-compressor\";\n\nimport {\n\ttype ICodecOptions,\n\ttype IJsonCodec,\n\ttype IMultiFormatCodec,\n\twithSchemaValidation,\n} from \"../codec/index.js\";\nimport type {\n\tChangeEncodingContext,\n\tEncodedRevisionTag,\n\tRevisionTag,\n\tSchemaAndPolicy,\n} from \"../core/index.js\";\nimport {\n\ttype JsonCompatibleReadOnly,\n\tJsonCompatibleReadOnlySchema,\n\ttype Mutable,\n} from \"../util/index.js\";\n\nimport type { BranchId } from \"./branch.js\";\nimport type { SharedBranchSummaryData, SummaryData } from \"./editManager.js\";\nimport { decodeSharedBranch, encodeSharedBranch } from \"./editManagerCodecsCommons.js\";\nimport type { EncodedSharedBranch } from \"./editManagerFormatCommons.js\";\nimport { EncodedEditManager } from \"./editManagerFormatVSharedBranches.js\";\n\nexport interface EditManagerEncodingContext {\n\tidCompressor: IIdCompressor;\n\treadonly schema?: SchemaAndPolicy;\n}\n\nexport function makeSharedBranchesCodecWithVersion<TChangeset>(\n\tchangeCodec: IMultiFormatCodec<\n\t\tTChangeset,\n\t\tJsonCompatibleReadOnly,\n\t\tJsonCompatibleReadOnly,\n\t\tChangeEncodingContext\n\t>,\n\trevisionTagCodec: IJsonCodec<\n\t\tRevisionTag,\n\t\tEncodedRevisionTag,\n\t\tEncodedRevisionTag,\n\t\tChangeEncodingContext\n\t>,\n\toptions: ICodecOptions,\n\tversion: EncodedEditManager<TChangeset>[\"version\"],\n): IJsonCodec<\n\tSummaryData<TChangeset>,\n\tJsonCompatibleReadOnly,\n\tJsonCompatibleReadOnly,\n\tEditManagerEncodingContext\n> {\n\tconst format = EncodedEditManager(\n\t\tchangeCodec.json.encodedSchema ?? JsonCompatibleReadOnlySchema,\n\t);\n\n\tconst codec: IJsonCodec<\n\t\tSummaryData<TChangeset>,\n\t\tEncodedEditManager<TChangeset>,\n\t\tEncodedEditManager<TChangeset>,\n\t\tEditManagerEncodingContext\n\t> = withSchemaValidation(\n\t\tformat,\n\t\t{\n\t\t\tencode: (data: SummaryData<TChangeset>, context: EditManagerEncodingContext) => {\n\t\t\t\tconst mainBranch = encodeSharedBranch(\n\t\t\t\t\tchangeCodec,\n\t\t\t\t\trevisionTagCodec,\n\t\t\t\t\tdata.main,\n\t\t\t\t\tcontext,\n\t\t\t\t\tdata.originator,\n\t\t\t\t);\n\t\t\t\tassert(\n\t\t\t\t\tdata.originator !== undefined,\n\t\t\t\t\t0xca5 /* Cannot encode vSharedBranches summary without originator */,\n\t\t\t\t);\n\t\t\t\tconst json: Mutable<EncodedEditManager<TChangeset>> = {\n\t\t\t\t\tmain: mainBranch,\n\t\t\t\t\toriginator: data.originator,\n\t\t\t\t\tversion,\n\t\t\t\t};\n\t\t\t\tif (data.branches !== undefined && data.branches.size > 0) {\n\t\t\t\t\tconst branches: EncodedSharedBranch<TChangeset>[] = [];\n\t\t\t\t\tfor (const [_, branch] of data.branches) {\n\t\t\t\t\t\tbranches.push(\n\t\t\t\t\t\t\tencodeSharedBranch(\n\t\t\t\t\t\t\t\tchangeCodec,\n\t\t\t\t\t\t\t\trevisionTagCodec,\n\t\t\t\t\t\t\t\tbranch,\n\t\t\t\t\t\t\t\tcontext,\n\t\t\t\t\t\t\t\tdata.originator,\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tjson.branches = branches;\n\t\t\t\t}\n\t\t\t\treturn json;\n\t\t\t},\n\t\t\tdecode: (\n\t\t\t\tjson: EncodedEditManager<TChangeset>,\n\t\t\t\tcontext: EditManagerEncodingContext,\n\t\t\t): SummaryData<TChangeset> => {\n\t\t\t\tconst mainBranch = decodeSharedBranch(\n\t\t\t\t\tchangeCodec,\n\t\t\t\t\trevisionTagCodec,\n\t\t\t\t\tjson.main,\n\t\t\t\t\tcontext,\n\t\t\t\t\tjson.originator,\n\t\t\t\t);\n\n\t\t\t\tconst decoded: Mutable<SummaryData<TChangeset>> = {\n\t\t\t\t\tmain: mainBranch,\n\t\t\t\t\toriginator: json.originator,\n\t\t\t\t};\n\n\t\t\t\tif (json.branches !== undefined) {\n\t\t\t\t\tconst branches = new Map<BranchId, SharedBranchSummaryData<TChangeset>>();\n\t\t\t\t\tfor (const branch of json.branches) {\n\t\t\t\t\t\tconst decodedBranch = decodeSharedBranch(\n\t\t\t\t\t\t\tchangeCodec,\n\t\t\t\t\t\t\trevisionTagCodec,\n\t\t\t\t\t\t\tbranch,\n\t\t\t\t\t\t\tcontext,\n\t\t\t\t\t\t\tjson.originator,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tassert(\n\t\t\t\t\t\t\tdecodedBranch.id !== undefined,\n\t\t\t\t\t\t\t0xc66 /* Shared branches must have an id */,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tassert(!branches.has(decodedBranch.id), 0xc67 /* Duplicate shared branch id */);\n\t\t\t\t\t\tbranches.set(decodedBranch.id, decodedBranch);\n\t\t\t\t\t}\n\n\t\t\t\t\tdecoded.branches = branches;\n\t\t\t\t}\n\t\t\t\treturn decoded;\n\t\t\t},\n\t\t},\n\t\toptions.jsonValidator,\n\t);\n\t// TODO: makeVersionedValidatedCodec and withSchemaValidation should allow the codec to decode JsonCompatibleReadOnly, or Versioned or something like that,\n\t// and not leak the internal encoded format in the API surface.\n\t// Fixing that would remove the need for this cast.\n\treturn codec as unknown as IJsonCodec<\n\t\tSummaryData<TChangeset>,\n\t\tJsonCompatibleReadOnly,\n\t\tJsonCompatibleReadOnly,\n\t\tEditManagerEncodingContext\n\t>;\n}\n"]}
1
+ {"version":3,"file":"editManagerCodecsVSharedBranches.js","sourceRoot":"","sources":["../../src/shared-tree-core/editManagerCodecsVSharedBranches.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAG7D,OAAO,EAAuC,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAO9F,OAAO,EAEN,4BA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AAoC,EACpC,OAAmC,EACT,EAAE;YAC5B,MAAM,UAAU,GAAG,kBAAkB,CACpC,WAAW,EACX,gBAAgB,EAChB,IAAI,CAAC,IAAI,EACT,OAAO,EACP,IAAI,CAAC,UAAU,CACf,CAAC;YAEF,MAAM,OAAO,GAAqC;gBACjD,IAAI,EAAE,UAAU;gBAChB,UAAU,EAAE,IAAI,CAAC,UAAU;aAC3B,CAAC;YAEF,IAAI,IAAI,CAAC,QAAQ,KAAK,SAAS,EAAE,CAAC;gBACjC,MAAM,QAAQ,GAAG,IAAI,GAAG,EAAiD,CAAC;gBAC1E,KAAK,MAAM,MAAM,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;oBACpC,MAAM,aAAa,GAAG,kBAAkB,CACvC,WAAW,EACX,gBAAgB,EAChB,MAAM,EACN,OAAO,EACP,IAAI,CAAC,UAAU,CACf,CAAC;oBACF,MAAM,CACL,aAAa,CAAC,EAAE,KAAK,SAAS,EAC9B,KAAK,CAAC,qCAAqC,CAC3C,CAAC;oBACF,MAAM,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,aAAa,CAAC,EAAE,CAAC,EAAE,KAAK,CAAC,gCAAgC,CAAC,CAAC;oBAChF,QAAQ,CAAC,GAAG,CAAC,aAAa,CAAC,EAAE,EAAE,aAAa,CAAC,CAAC;gBAC/C,CAAC;gBAED,OAAO,CAAC,QAAQ,GAAG,QAAQ,CAAC;YAC7B,CAAC;YACD,OAAO,OAAO,CAAC;QAChB,CAAC;KACD,EACD,OAAO,CAAC,aAAa,CACrB,CAAC;IACF,2JAA2J;IAC3J,+DAA+D;IAC/D,mDAAmD;IACnD,OAAO,KAKN,CAAC;AACH,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport type { IIdCompressor } from \"@fluidframework/id-compressor\";\n\nimport { type ICodecOptions, type IJsonCodec, withSchemaValidation } from \"../codec/index.js\";\nimport type {\n\tChangeEncodingContext,\n\tEncodedRevisionTag,\n\tRevisionTag,\n\tSchemaAndPolicy,\n} from \"../core/index.js\";\nimport {\n\ttype JsonCompatibleReadOnly,\n\tJsonCompatibleReadOnlySchema,\n\ttype Mutable,\n} from \"../util/index.js\";\n\nimport type { BranchId } from \"./branch.js\";\nimport type { SharedBranchSummaryData, SummaryData } from \"./editManager.js\";\nimport { decodeSharedBranch, encodeSharedBranch } from \"./editManagerCodecsCommons.js\";\nimport type { EncodedSharedBranch } from \"./editManagerFormatCommons.js\";\nimport { EncodedEditManager } from \"./editManagerFormatVSharedBranches.js\";\n\nexport interface EditManagerEncodingContext {\n\tidCompressor: IIdCompressor;\n\treadonly schema?: SchemaAndPolicy;\n}\n\nexport function makeSharedBranchesCodecWithVersion<TChangeset>(\n\tchangeCodec: IJsonCodec<\n\t\tTChangeset,\n\t\tJsonCompatibleReadOnly,\n\t\tJsonCompatibleReadOnly,\n\t\tChangeEncodingContext\n\t>,\n\trevisionTagCodec: IJsonCodec<\n\t\tRevisionTag,\n\t\tEncodedRevisionTag,\n\t\tEncodedRevisionTag,\n\t\tChangeEncodingContext\n\t>,\n\toptions: ICodecOptions,\n\tversion: EncodedEditManager<TChangeset>[\"version\"],\n): IJsonCodec<\n\tSummaryData<TChangeset>,\n\tJsonCompatibleReadOnly,\n\tJsonCompatibleReadOnly,\n\tEditManagerEncodingContext\n> {\n\tconst format = EncodedEditManager(changeCodec.encodedSchema ?? JsonCompatibleReadOnlySchema);\n\n\tconst codec: IJsonCodec<\n\t\tSummaryData<TChangeset>,\n\t\tEncodedEditManager<TChangeset>,\n\t\tEncodedEditManager<TChangeset>,\n\t\tEditManagerEncodingContext\n\t> = withSchemaValidation(\n\t\tformat,\n\t\t{\n\t\t\tencode: (data: SummaryData<TChangeset>, context: EditManagerEncodingContext) => {\n\t\t\t\tconst mainBranch = encodeSharedBranch(\n\t\t\t\t\tchangeCodec,\n\t\t\t\t\trevisionTagCodec,\n\t\t\t\t\tdata.main,\n\t\t\t\t\tcontext,\n\t\t\t\t\tdata.originator,\n\t\t\t\t);\n\t\t\t\tassert(\n\t\t\t\t\tdata.originator !== undefined,\n\t\t\t\t\t0xca5 /* Cannot encode vSharedBranches summary without originator */,\n\t\t\t\t);\n\t\t\t\tconst json: Mutable<EncodedEditManager<TChangeset>> = {\n\t\t\t\t\tmain: mainBranch,\n\t\t\t\t\toriginator: data.originator,\n\t\t\t\t\tversion,\n\t\t\t\t};\n\t\t\t\tif (data.branches !== undefined && data.branches.size > 0) {\n\t\t\t\t\tconst branches: EncodedSharedBranch<TChangeset>[] = [];\n\t\t\t\t\tfor (const [_, branch] of data.branches) {\n\t\t\t\t\t\tbranches.push(\n\t\t\t\t\t\t\tencodeSharedBranch(\n\t\t\t\t\t\t\t\tchangeCodec,\n\t\t\t\t\t\t\t\trevisionTagCodec,\n\t\t\t\t\t\t\t\tbranch,\n\t\t\t\t\t\t\t\tcontext,\n\t\t\t\t\t\t\t\tdata.originator,\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tjson.branches = branches;\n\t\t\t\t}\n\t\t\t\treturn json;\n\t\t\t},\n\t\t\tdecode: (\n\t\t\t\tjson: EncodedEditManager<TChangeset>,\n\t\t\t\tcontext: EditManagerEncodingContext,\n\t\t\t): SummaryData<TChangeset> => {\n\t\t\t\tconst mainBranch = decodeSharedBranch(\n\t\t\t\t\tchangeCodec,\n\t\t\t\t\trevisionTagCodec,\n\t\t\t\t\tjson.main,\n\t\t\t\t\tcontext,\n\t\t\t\t\tjson.originator,\n\t\t\t\t);\n\n\t\t\t\tconst decoded: Mutable<SummaryData<TChangeset>> = {\n\t\t\t\t\tmain: mainBranch,\n\t\t\t\t\toriginator: json.originator,\n\t\t\t\t};\n\n\t\t\t\tif (json.branches !== undefined) {\n\t\t\t\t\tconst branches = new Map<BranchId, SharedBranchSummaryData<TChangeset>>();\n\t\t\t\t\tfor (const branch of json.branches) {\n\t\t\t\t\t\tconst decodedBranch = decodeSharedBranch(\n\t\t\t\t\t\t\tchangeCodec,\n\t\t\t\t\t\t\trevisionTagCodec,\n\t\t\t\t\t\t\tbranch,\n\t\t\t\t\t\t\tcontext,\n\t\t\t\t\t\t\tjson.originator,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tassert(\n\t\t\t\t\t\t\tdecodedBranch.id !== undefined,\n\t\t\t\t\t\t\t0xc66 /* Shared branches must have an id */,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tassert(!branches.has(decodedBranch.id), 0xc67 /* Duplicate shared branch id */);\n\t\t\t\t\t\tbranches.set(decodedBranch.id, decodedBranch);\n\t\t\t\t\t}\n\n\t\t\t\t\tdecoded.branches = branches;\n\t\t\t\t}\n\t\t\t\treturn decoded;\n\t\t\t},\n\t\t},\n\t\toptions.jsonValidator,\n\t);\n\t// TODO: makeVersionedValidatedCodec and withSchemaValidation should allow the codec to decode JsonCompatibleReadOnly, or Versioned or something like that,\n\t// and not leak the internal encoded format in the API surface.\n\t// Fixing that would remove the need for this cast.\n\treturn codec as unknown as IJsonCodec<\n\t\tSummaryData<TChangeset>,\n\t\tJsonCompatibleReadOnly,\n\t\tJsonCompatibleReadOnly,\n\t\tEditManagerEncodingContext\n\t>;\n}\n"]}
@@ -61,7 +61,7 @@ export class EditManagerSummarizer extends VersionedSummarizer {
61
61
  // This detects any data that could have been accidentally added through
62
62
  // invalid means and is about to be overwritten.
63
63
  assert(this.editManager.isEmpty(), 0x42c /* There should not already be stored EditManager data when loading from summary */);
64
- const summary = parse(bufferToString(schemaBuffer, "utf-8"));
64
+ const summary = parse(bufferToString(schemaBuffer, "utf8"));
65
65
  const data = this.codec.decode(summary, { idCompressor: this.idCompressor });
66
66
  this.editManager.loadSummaryData(data);
67
67
  }
@@ -1 +1 @@
1
- {"version":3,"file":"editManagerSummarizer.js","sourceRoot":"","sources":["../../src/shared-tree-core/editManagerSummarizer.ts"],"names":[],"mappings":"AAAA;;;GAGG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AY,EAAE,IAAI,CAAC,YAAY,EAAE,CAAC;QACtE,MAAM,cAAc,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,cAAc,EAAE,EAAE,OAAO,CAAC,CAAC;QACrF,MAAM,UAAU,GAAG,SAAS,CAAC,cAAc,CAAC,CAAC;QAC7C,OAAO,CAAC,OAAO,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC;IACxC,CAAC;IAES,KAAK,CAAC,YAAY,CAC3B,QAAgC,EAChC,KAA2B;QAE3B,MAAM,YAAY,GAAoB,MAAM,QAAQ,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;QAEzE,gEAAgE;QAChE,wEAAwE;QACxE,gDAAgD;QAChD,MAAM,CACL,IAAI,CAAC,WAAW,CAAC,OAAO,EAAE,EAC1B,KAAK,CAAC,mFAAmF,CACzF,CAAC;QAEF,MAAM,OAAO,GAAG,KAAK,CAAC,cAAc,CAAC,YAAY,EAAE,OAAO,CAAC,CAA2B,CAAC;QACvF,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,OAAO,EAAE,EAAE,YAAY,EAAE,IAAI,CAAC,YAAY,EAAE,CAAC,CAAC;QAC7E,IAAI,CAAC,WAAW,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;IACxC,CAAC;;AA5DsB,yBAAG,GAAG,aAAa,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { bufferToString } from \"@fluid-internal/client-utils\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport type { IChannelStorageService } from \"@fluidframework/datastore-definitions/internal\";\nimport type { IIdCompressor } from \"@fluidframework/id-compressor\";\nimport type {\n\tIExperimentalIncrementalSummaryContext,\n\tITelemetryContext,\n\tMinimumVersionForCollab,\n} from \"@fluidframework/runtime-definitions/internal\";\nimport type { SummaryTreeBuilder } from \"@fluidframework/runtime-utils/internal\";\n\nimport type { IJsonCodec } from \"../codec/index.js\";\nimport type { ChangeFamily, ChangeFamilyEditor, SchemaAndPolicy } from \"../core/index.js\";\nimport type { JsonCompatibleReadOnly } from \"../util/index.js\";\n\nimport type { EditManager, SummaryData } from \"./editManager.js\";\nimport type { EditManagerEncodingContext } from \"./editManagerCodecs.js\";\nimport type {\n\tSummarizable,\n\tSummaryElementParser,\n\tSummaryElementStringifier,\n} from \"./summaryTypes.js\";\nimport { VersionedSummarizer } from \"./versionedSummarizer.js\";\n\nexport const stringKey = \"String\";\n\n/**\n * The versions for the edit manager summary format.\n */\nexport const enum EditManagerSummaryFormatVersion {\n\t/**\n\t * This version represents summary format before summary versioning was introduced.\n\t */\n\tv1 = 1,\n\t/**\n\t * This version adds metadata to the summary. This is backward compatible with version 1.\n\t */\n\tv2 = 2,\n\t/**\n\t * The latest version of the summary. Must be updated when a new version is added.\n\t */\n\tvLatest = v2,\n}\n\nconst supportedVersions = new Set<EditManagerSummaryFormatVersion>([\n\tEditManagerSummaryFormatVersion.v1,\n\tEditManagerSummaryFormatVersion.v2,\n]);\n\n/**\n * Returns the summary version to use as per the given minimum version for collab.\n */\nfunction minVersionToEditManagerSummaryFormatVersion(\n\tversion: MinimumVersionForCollab,\n): EditManagerSummaryFormatVersion {\n\t// Currently, version 2 is written which adds metadata blob to the summary.\n\treturn EditManagerSummaryFormatVersion.v2;\n}\n\n/**\n * Provides methods for summarizing and loading an `EditManager`\n */\nexport class EditManagerSummarizer<TChangeset>\n\textends VersionedSummarizer<EditManagerSummaryFormatVersion>\n\timplements Summarizable\n{\n\tpublic static readonly key = \"EditManager\";\n\tpublic constructor(\n\t\tprivate readonly editManager: EditManager<\n\t\t\tChangeFamilyEditor,\n\t\t\tTChangeset,\n\t\t\tChangeFamily<ChangeFamilyEditor, TChangeset>\n\t\t>,\n\t\tprivate readonly codec: IJsonCodec<\n\t\t\tSummaryData<TChangeset>,\n\t\t\tJsonCompatibleReadOnly,\n\t\t\tJsonCompatibleReadOnly,\n\t\t\tEditManagerEncodingContext\n\t\t>,\n\t\tprivate readonly idCompressor: IIdCompressor,\n\t\tminVersionForCollab: MinimumVersionForCollab,\n\t\tprivate readonly schemaAndPolicy?: SchemaAndPolicy,\n\t) {\n\t\tsuper(\n\t\t\tEditManagerSummarizer.key,\n\t\t\tminVersionToEditManagerSummaryFormatVersion(minVersionForCollab),\n\t\t\tsupportedVersions,\n\t\t\ttrue /* supportPreVersioningFormat */,\n\t\t);\n\t}\n\n\tprotected summarizeInternal(props: {\n\t\tstringify: SummaryElementStringifier;\n\t\tfullTree?: boolean;\n\t\ttrackState?: boolean;\n\t\ttelemetryContext?: ITelemetryContext;\n\t\tincrementalSummaryContext?: IExperimentalIncrementalSummaryContext;\n\t\tbuilder: SummaryTreeBuilder;\n\t}): void {\n\t\tconst { stringify, builder } = props;\n\t\tconst context: EditManagerEncodingContext =\n\t\t\tthis.schemaAndPolicy === undefined\n\t\t\t\t? { idCompressor: this.idCompressor }\n\t\t\t\t: { schema: this.schemaAndPolicy, idCompressor: this.idCompressor };\n\t\tconst jsonCompatible = this.codec.encode(this.editManager.getSummaryData(), context);\n\t\tconst dataString = stringify(jsonCompatible);\n\t\tbuilder.addBlob(stringKey, dataString);\n\t}\n\n\tprotected async loadInternal(\n\t\tservices: IChannelStorageService,\n\t\tparse: SummaryElementParser,\n\t): Promise<void> {\n\t\tconst schemaBuffer: ArrayBufferLike = await services.readBlob(stringKey);\n\n\t\t// After the awaits, validate that the data is in a clean state.\n\t\t// This detects any data that could have been accidentally added through\n\t\t// invalid means and is about to be overwritten.\n\t\tassert(\n\t\t\tthis.editManager.isEmpty(),\n\t\t\t0x42c /* There should not already be stored EditManager data when loading from summary */,\n\t\t);\n\n\t\tconst summary = parse(bufferToString(schemaBuffer, \"utf-8\")) as JsonCompatibleReadOnly;\n\t\tconst data = this.codec.decode(summary, { idCompressor: this.idCompressor });\n\t\tthis.editManager.loadSummaryData(data);\n\t}\n}\n"]}
1
+ {"version":3,"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AAE,IAAI,CAAC,YAAY,EAAE;YACrC,CAAC,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,eAAe,EAAE,YAAY,EAAE,IAAI,CAAC,YAAY,EAAE,CAAC;QACtE,MAAM,cAAc,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,cAAc,EAAE,EAAE,OAAO,CAAC,CAAC;QACrF,MAAM,UAAU,GAAG,SAAS,CAAC,cAAc,CAAC,CAAC;QAC7C,OAAO,CAAC,OAAO,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC;IACxC,CAAC;IAES,KAAK,CAAC,YAAY,CAC3B,QAAgC,EAChC,KAA2B;QAE3B,MAAM,YAAY,GAAoB,MAAM,QAAQ,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;QAEzE,gEAAgE;QAChE,wEAAwE;QACxE,gDAAgD;QAChD,MAAM,CACL,IAAI,CAAC,WAAW,CAAC,OAAO,EAAE,EAC1B,KAAK,CAAC,mFAAmF,CACzF,CAAC;QAEF,MAAM,OAAO,GAAG,KAAK,CAAC,cAAc,CAAC,YAAY,EAAE,MAAM,CAAC,CAA2B,CAAC;QACtF,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,OAAO,EAAE,EAAE,YAAY,EAAE,IAAI,CAAC,YAAY,EAAE,CAAC,CAAC;QAC7E,IAAI,CAAC,WAAW,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;IACxC,CAAC;;AA5DsB,yBAAG,GAAG,aAAa,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { bufferToString } from \"@fluid-internal/client-utils\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport type { IChannelStorageService } from \"@fluidframework/datastore-definitions/internal\";\nimport type { IIdCompressor } from \"@fluidframework/id-compressor\";\nimport type {\n\tIExperimentalIncrementalSummaryContext,\n\tITelemetryContext,\n\tMinimumVersionForCollab,\n} from \"@fluidframework/runtime-definitions/internal\";\nimport type { SummaryTreeBuilder } from \"@fluidframework/runtime-utils/internal\";\n\nimport type { IJsonCodec } from \"../codec/index.js\";\nimport type { ChangeFamily, ChangeFamilyEditor, SchemaAndPolicy } from \"../core/index.js\";\nimport type { JsonCompatibleReadOnly } from \"../util/index.js\";\n\nimport type { EditManager, SummaryData } from \"./editManager.js\";\nimport type { EditManagerEncodingContext } from \"./editManagerCodecs.js\";\nimport type {\n\tSummarizable,\n\tSummaryElementParser,\n\tSummaryElementStringifier,\n} from \"./summaryTypes.js\";\nimport { VersionedSummarizer } from \"./versionedSummarizer.js\";\n\nexport const stringKey = \"String\";\n\n/**\n * The versions for the edit manager summary format.\n */\nexport const enum EditManagerSummaryFormatVersion {\n\t/**\n\t * This version represents summary format before summary versioning was introduced.\n\t */\n\tv1 = 1,\n\t/**\n\t * This version adds metadata to the summary. This is backward compatible with version 1.\n\t */\n\tv2 = 2,\n\t/**\n\t * The latest version of the summary. Must be updated when a new version is added.\n\t */\n\tvLatest = v2,\n}\n\nconst supportedVersions = new Set<EditManagerSummaryFormatVersion>([\n\tEditManagerSummaryFormatVersion.v1,\n\tEditManagerSummaryFormatVersion.v2,\n]);\n\n/**\n * Returns the summary version to use as per the given minimum version for collab.\n */\nfunction minVersionToEditManagerSummaryFormatVersion(\n\tversion: MinimumVersionForCollab,\n): EditManagerSummaryFormatVersion {\n\t// Currently, version 2 is written which adds metadata blob to the summary.\n\treturn EditManagerSummaryFormatVersion.v2;\n}\n\n/**\n * Provides methods for summarizing and loading an `EditManager`\n */\nexport class EditManagerSummarizer<TChangeset>\n\textends VersionedSummarizer<EditManagerSummaryFormatVersion>\n\timplements Summarizable\n{\n\tpublic static readonly key = \"EditManager\";\n\tpublic constructor(\n\t\tprivate readonly editManager: EditManager<\n\t\t\tChangeFamilyEditor,\n\t\t\tTChangeset,\n\t\t\tChangeFamily<ChangeFamilyEditor, TChangeset>\n\t\t>,\n\t\tprivate readonly codec: IJsonCodec<\n\t\t\tSummaryData<TChangeset>,\n\t\t\tJsonCompatibleReadOnly,\n\t\t\tJsonCompatibleReadOnly,\n\t\t\tEditManagerEncodingContext\n\t\t>,\n\t\tprivate readonly idCompressor: IIdCompressor,\n\t\tminVersionForCollab: MinimumVersionForCollab,\n\t\tprivate readonly schemaAndPolicy?: SchemaAndPolicy,\n\t) {\n\t\tsuper(\n\t\t\tEditManagerSummarizer.key,\n\t\t\tminVersionToEditManagerSummaryFormatVersion(minVersionForCollab),\n\t\t\tsupportedVersions,\n\t\t\ttrue /* supportPreVersioningFormat */,\n\t\t);\n\t}\n\n\tprotected summarizeInternal(props: {\n\t\tstringify: SummaryElementStringifier;\n\t\tfullTree?: boolean;\n\t\ttrackState?: boolean;\n\t\ttelemetryContext?: ITelemetryContext;\n\t\tincrementalSummaryContext?: IExperimentalIncrementalSummaryContext;\n\t\tbuilder: SummaryTreeBuilder;\n\t}): void {\n\t\tconst { stringify, builder } = props;\n\t\tconst context: EditManagerEncodingContext =\n\t\t\tthis.schemaAndPolicy === undefined\n\t\t\t\t? { idCompressor: this.idCompressor }\n\t\t\t\t: { schema: this.schemaAndPolicy, idCompressor: this.idCompressor };\n\t\tconst jsonCompatible = this.codec.encode(this.editManager.getSummaryData(), context);\n\t\tconst dataString = stringify(jsonCompatible);\n\t\tbuilder.addBlob(stringKey, dataString);\n\t}\n\n\tprotected async loadInternal(\n\t\tservices: IChannelStorageService,\n\t\tparse: SummaryElementParser,\n\t): Promise<void> {\n\t\tconst schemaBuffer: ArrayBufferLike = await services.readBlob(stringKey);\n\n\t\t// After the awaits, validate that the data is in a clean state.\n\t\t// This detects any data that could have been accidentally added through\n\t\t// invalid means and is about to be overwritten.\n\t\tassert(\n\t\t\tthis.editManager.isEmpty(),\n\t\t\t0x42c /* There should not already be stored EditManager data when loading from summary */,\n\t\t);\n\n\t\tconst summary = parse(bufferToString(schemaBuffer, \"utf8\")) as JsonCompatibleReadOnly;\n\t\tconst data = this.codec.decode(summary, { idCompressor: this.idCompressor });\n\t\tthis.editManager.loadSummaryData(data);\n\t}\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"messageCodecV1ToV4.d.ts","sourceRoot":"","sources":["../../src/shared-tree-core/messageCodecV1ToV4.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,EAAE,KAAK,aAAa,EAAE,KAAK,UAAU,EAAwB,MAAM,mBAAmB,CAAC;AAC9F,OAAO,KAAK,EACX,qBAAqB,EACrB,iBAAiB,EACjB,kBAAkB,EAClB,WAAW,EACX,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAE/D,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AACjE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAE/D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAExD,wBAAgB,0BAA0B,CAAC,UAAU,EACpD,WAAW,EAAE,iBAAiB,CAAC,UAAU,CAAC,EAC1C,gBAAgB,EAAE,UAAU,CAC3B,WAAW,EACX,kBAAkB,EAClB,kBAAkB,EAClB,qBAAqB,CACrB,EACD,OAAO,EAAE,aAAa,EACtB,OAAO,EACJ,OAAO,oBAAoB,CAAC,EAAE,GAC9B,OAAO,oBAAoB,CAAC,EAAE,GAC9B,OAAO,oBAAoB,CAAC,EAAE,GAC9B,OAAO,oBAAoB,CAAC,EAAE,GAC9B,OAAO,oBAAoB,CAAC,EAAE,GAC/B,UAAU,CACZ,cAAc,CAAC,UAAU,CAAC,EAC1B,sBAAsB,EACtB,sBAAsB,EACtB,sBAAsB,CACtB,CAmEA"}
1
+ {"version":3,"file":"messageCodecV1ToV4.d.ts","sourceRoot":"","sources":["../../src/shared-tree-core/messageCodecV1ToV4.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,EAAE,KAAK,aAAa,EAAE,KAAK,UAAU,EAAwB,MAAM,mBAAmB,CAAC;AAC9F,OAAO,KAAK,EACX,qBAAqB,EACrB,iBAAiB,EACjB,kBAAkB,EAClB,WAAW,EACX,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAG/D,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AACjE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAE/D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAExD,wBAAgB,0BAA0B,CAAC,UAAU,EACpD,WAAW,EAAE,iBAAiB,CAAC,UAAU,CAAC,EAC1C,gBAAgB,EAAE,UAAU,CAC3B,WAAW,EACX,kBAAkB,EAClB,kBAAkB,EAClB,qBAAqB,CACrB,EACD,OAAO,EAAE,aAAa,EACtB,OAAO,EACJ,OAAO,oBAAoB,CAAC,EAAE,GAC9B,OAAO,oBAAoB,CAAC,EAAE,GAC9B,OAAO,oBAAoB,CAAC,EAAE,GAC9B,OAAO,oBAAoB,CAAC,EAAE,GAC9B,OAAO,oBAAoB,CAAC,EAAE,GAC/B,UAAU,CACZ,cAAc,CAAC,UAAU,CAAC,EAC1B,sBAAsB,EACtB,sBAAsB,EACtB,sBAAsB,CACtB,CAmEA"}
@@ -3,11 +3,11 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
  import { assert } from "@fluidframework/core-utils/internal";
6
- import { Type } from "@sinclair/typebox";
7
6
  import { withSchemaValidation } from "../codec/index.js";
7
+ import { JsonCompatibleReadOnlySchema } from "../util/index.js";
8
8
  import { Message } from "./messageFormatV1ToV4.js";
9
9
  export function makeV1ToV4CodecWithVersion(changeCodec, revisionTagCodec, options, version) {
10
- return withSchemaValidation(Message(changeCodec.encodedSchema ?? Type.Any()), {
10
+ return withSchemaValidation(Message(changeCodec.encodedSchema ?? JsonCompatibleReadOnlySchema), {
11
11
  encode: (decoded, context) => {
12
12
  assert(decoded.type === "commit", 0xc68 /* Only commit messages are supported */);
13
13
  assert(decoded.branchId === "main", 0xc69 /* Only commit messages to main are supported */);
@@ -1 +1 @@
1
- {"version":3,"file":"messageCodecV1ToV4.js","sourceRoot":"","sources":["../../src/shared-tree-core/messageCodecV1ToV4.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAC7D,OAAO,EAAmB,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAE1D,OAAO,EAAuC,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAW9F,OAAO,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAC;AAGnD,MAAM,UAAU,0BAA0B,CACzC,WAA0C,EAC1C,gBAKC,EACD,OAAsB,EACtB,OAKiC;IAOjC,OAAO,oBAAoB,CAO1B,OAAO,CAAC,WAAW,CAAC,aAAa,IAAI,IAAI,CAAC,GAAG,EAAE,CAAC,EAChD;QACC,MAAM,EAAE,CAAC,OAAmC,EAAE,OAA+B,EAAE,EAAE;YAChF,MAAM,CAAC,OAAO,CAAC,IAAI,KAAK,QAAQ,EAAE,KAAK,CAAC,wCAAwC,CAAC,CAAC;YAClF,MAAM,CACL,OAAO,CAAC,QAAQ,KAAK,MAAM,EAC3B,KAAK,CAAC,gDAAgD,CACtD,CAAC;YACF,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,YAAY,EAAE,GAAG,OAAO,CAAC;YACpD,MAAM,OAAO,GAAY;gBACxB,QAAQ,EAAE,gBAAgB,CAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,EAAE;oBAClD,YAAY;oBACZ,YAAY,EAAE,OAAO,CAAC,YAAY;oBAClC,QAAQ,EAAE,SAAS;iBACnB,CAAC;gBACF,YAAY;gBACZ,SAAS,EAAE,WAAW,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE;oBAC5C,YAAY;oBACZ,MAAM,EAAE,OAAO,CAAC,MAAM;oBACtB,YAAY,EAAE,OAAO,CAAC,YAAY;oBAClC,QAAQ,EAAE,MAAM,CAAC,QAAQ;iBACzB,CAAC;gBACF,OAAO;aACP,CAAC;YACF,OAAO,OAA4C,CAAC;QACrD,CAAC;QACD,MAAM,EAAE,CACP,OAA+B,EAC/B,OAA+B,EACF,EAAE;YAC/B,MAAM,EACL,QAAQ,EAAE,eAAe,EACzB,YAAY,EACZ,SAAS,GACT,GAAG,OAA6B,CAAC;YAElC,MAAM,QAAQ,GAAG,gBAAgB,CAAC,MAAM,CAAC,eAAe,EAAE;gBACzD,YAAY;gBACZ,QAAQ,EAAE,SAAS;gBACnB,YAAY,EAAE,OAAO,CAAC,YAAY;aAClC,CAAC,CAAC;YAEH,OAAO;gBACN,QAAQ,EAAE,MAAM;gBAChB,IAAI,EAAE,QAAQ;gBACd,MAAM,EAAE;oBACP,QAAQ;oBACR,MAAM,EAAE,WAAW,CAAC,MAAM,CAAC,SAAS,EAAE;wBACrC,YAAY;wBACZ,QAAQ;wBACR,YAAY,EAAE,OAAO,CAAC,YAAY;qBAClC,CAAC;iBACF;gBACD,SAAS,EAAE,YAAY;aACvB,CAAC;QACH,CAAC;KACD,EACD,OAAO,CAAC,aAAa,CACrB,CAAC;AACH,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport { type TAnySchema, Type } from \"@sinclair/typebox\";\n\nimport { type ICodecOptions, type IJsonCodec, withSchemaValidation } from \"../codec/index.js\";\nimport type {\n\tChangeEncodingContext,\n\tChangeFamilyCodec,\n\tEncodedRevisionTag,\n\tRevisionTag,\n} from \"../core/index.js\";\nimport type { JsonCompatibleReadOnly } from \"../util/index.js\";\n\nimport type { MessageEncodingContext } from \"./messageCodecs.js\";\nimport type { MessageFormatVersion } from \"./messageFormat.js\";\nimport { Message } from \"./messageFormatV1ToV4.js\";\nimport type { DecodedMessage } from \"./messageTypes.js\";\n\nexport function makeV1ToV4CodecWithVersion<TChangeset>(\n\tchangeCodec: ChangeFamilyCodec<TChangeset>,\n\trevisionTagCodec: IJsonCodec<\n\t\tRevisionTag,\n\t\tEncodedRevisionTag,\n\t\tEncodedRevisionTag,\n\t\tChangeEncodingContext\n\t>,\n\toptions: ICodecOptions,\n\tversion:\n\t\t| typeof MessageFormatVersion.v1\n\t\t| typeof MessageFormatVersion.v2\n\t\t| typeof MessageFormatVersion.v3\n\t\t| typeof MessageFormatVersion.v4\n\t\t| typeof MessageFormatVersion.v6,\n): IJsonCodec<\n\tDecodedMessage<TChangeset>,\n\tJsonCompatibleReadOnly,\n\tJsonCompatibleReadOnly,\n\tMessageEncodingContext\n> {\n\treturn withSchemaValidation<\n\t\tDecodedMessage<TChangeset>,\n\t\tTAnySchema,\n\t\tJsonCompatibleReadOnly,\n\t\tJsonCompatibleReadOnly,\n\t\tMessageEncodingContext\n\t>(\n\t\tMessage(changeCodec.encodedSchema ?? Type.Any()),\n\t\t{\n\t\t\tencode: (decoded: DecodedMessage<TChangeset>, context: MessageEncodingContext) => {\n\t\t\t\tassert(decoded.type === \"commit\", 0xc68 /* Only commit messages are supported */);\n\t\t\t\tassert(\n\t\t\t\t\tdecoded.branchId === \"main\",\n\t\t\t\t\t0xc69 /* Only commit messages to main are supported */,\n\t\t\t\t);\n\t\t\t\tconst { commit, sessionId: originatorId } = decoded;\n\t\t\t\tconst message: Message = {\n\t\t\t\t\trevision: revisionTagCodec.encode(commit.revision, {\n\t\t\t\t\t\toriginatorId,\n\t\t\t\t\t\tidCompressor: context.idCompressor,\n\t\t\t\t\t\trevision: undefined,\n\t\t\t\t\t}),\n\t\t\t\t\toriginatorId,\n\t\t\t\t\tchangeset: changeCodec.encode(commit.change, {\n\t\t\t\t\t\toriginatorId,\n\t\t\t\t\t\tschema: context.schema,\n\t\t\t\t\t\tidCompressor: context.idCompressor,\n\t\t\t\t\t\trevision: commit.revision,\n\t\t\t\t\t}),\n\t\t\t\t\tversion,\n\t\t\t\t};\n\t\t\t\treturn message as unknown as JsonCompatibleReadOnly;\n\t\t\t},\n\t\t\tdecode: (\n\t\t\t\tencoded: JsonCompatibleReadOnly,\n\t\t\t\tcontext: MessageEncodingContext,\n\t\t\t): DecodedMessage<TChangeset> => {\n\t\t\t\tconst {\n\t\t\t\t\trevision: encodedRevision,\n\t\t\t\t\toriginatorId,\n\t\t\t\t\tchangeset,\n\t\t\t\t} = encoded as unknown as Message;\n\n\t\t\t\tconst revision = revisionTagCodec.decode(encodedRevision, {\n\t\t\t\t\toriginatorId,\n\t\t\t\t\trevision: undefined,\n\t\t\t\t\tidCompressor: context.idCompressor,\n\t\t\t\t});\n\n\t\t\t\treturn {\n\t\t\t\t\tbranchId: \"main\",\n\t\t\t\t\ttype: \"commit\",\n\t\t\t\t\tcommit: {\n\t\t\t\t\t\trevision,\n\t\t\t\t\t\tchange: changeCodec.decode(changeset, {\n\t\t\t\t\t\t\toriginatorId,\n\t\t\t\t\t\t\trevision,\n\t\t\t\t\t\t\tidCompressor: context.idCompressor,\n\t\t\t\t\t\t}),\n\t\t\t\t\t},\n\t\t\t\t\tsessionId: originatorId,\n\t\t\t\t};\n\t\t\t},\n\t\t},\n\t\toptions.jsonValidator,\n\t);\n}\n"]}
1
+ {"version":3,"file":"messageCodecV1ToV4.js","sourceRoot":"","sources":["../../src/shared-tree-core/messageCodecV1ToV4.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAG7D,OAAO,EAAuC,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAQ9F,OAAO,EAAE,4BAA4B,EAAE,MAAM,kBAAkB,CAAC;AAIhE,OAAO,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAC;AAGnD,MAAM,UAAU,0BAA0B,CACzC,WAA0C,EAC1C,gBAKC,EACD,OAAsB,EACtB,OAKiC;IAOjC,OAAO,oB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oBACR,MAAM,EAAE,WAAW,CAAC,MAAM,CAAC,SAAS,EAAE;wBACrC,YAAY;wBACZ,QAAQ;wBACR,YAAY,EAAE,OAAO,CAAC,YAAY;qBAClC,CAAC;iBACF;gBACD,SAAS,EAAE,YAAY;aACvB,CAAC;QACH,CAAC;KACD,EACD,OAAO,CAAC,aAAa,CACrB,CAAC;AACH,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport type { TAnySchema } from \"@sinclair/typebox\";\n\nimport { type ICodecOptions, type IJsonCodec, withSchemaValidation } from \"../codec/index.js\";\nimport type {\n\tChangeEncodingContext,\n\tChangeFamilyCodec,\n\tEncodedRevisionTag,\n\tRevisionTag,\n} from \"../core/index.js\";\nimport type { JsonCompatibleReadOnly } from \"../util/index.js\";\nimport { JsonCompatibleReadOnlySchema } from \"../util/index.js\";\n\nimport type { MessageEncodingContext } from \"./messageCodecs.js\";\nimport type { MessageFormatVersion } from \"./messageFormat.js\";\nimport { Message } from \"./messageFormatV1ToV4.js\";\nimport type { DecodedMessage } from \"./messageTypes.js\";\n\nexport function makeV1ToV4CodecWithVersion<TChangeset>(\n\tchangeCodec: ChangeFamilyCodec<TChangeset>,\n\trevisionTagCodec: IJsonCodec<\n\t\tRevisionTag,\n\t\tEncodedRevisionTag,\n\t\tEncodedRevisionTag,\n\t\tChangeEncodingContext\n\t>,\n\toptions: ICodecOptions,\n\tversion:\n\t\t| typeof MessageFormatVersion.v1\n\t\t| typeof MessageFormatVersion.v2\n\t\t| typeof MessageFormatVersion.v3\n\t\t| typeof MessageFormatVersion.v4\n\t\t| typeof MessageFormatVersion.v6,\n): IJsonCodec<\n\tDecodedMessage<TChangeset>,\n\tJsonCompatibleReadOnly,\n\tJsonCompatibleReadOnly,\n\tMessageEncodingContext\n> {\n\treturn withSchemaValidation<\n\t\tDecodedMessage<TChangeset>,\n\t\tTAnySchema | typeof JsonCompatibleReadOnlySchema,\n\t\tJsonCompatibleReadOnly,\n\t\tJsonCompatibleReadOnly,\n\t\tMessageEncodingContext\n\t>(\n\t\tMessage(changeCodec.encodedSchema ?? JsonCompatibleReadOnlySchema),\n\t\t{\n\t\t\tencode: (decoded: DecodedMessage<TChangeset>, context: MessageEncodingContext) => {\n\t\t\t\tassert(decoded.type === \"commit\", 0xc68 /* Only commit messages are supported */);\n\t\t\t\tassert(\n\t\t\t\t\tdecoded.branchId === \"main\",\n\t\t\t\t\t0xc69 /* Only commit messages to main are supported */,\n\t\t\t\t);\n\t\t\t\tconst { commit, sessionId: originatorId } = decoded;\n\t\t\t\tconst message: Message = {\n\t\t\t\t\trevision: revisionTagCodec.encode(commit.revision, {\n\t\t\t\t\t\toriginatorId,\n\t\t\t\t\t\tidCompressor: context.idCompressor,\n\t\t\t\t\t\trevision: undefined,\n\t\t\t\t\t}),\n\t\t\t\t\toriginatorId,\n\t\t\t\t\tchangeset: changeCodec.encode(commit.change, {\n\t\t\t\t\t\toriginatorId,\n\t\t\t\t\t\tschema: context.schema,\n\t\t\t\t\t\tidCompressor: context.idCompressor,\n\t\t\t\t\t\trevision: commit.revision,\n\t\t\t\t\t}),\n\t\t\t\t\tversion,\n\t\t\t\t};\n\t\t\t\treturn message as unknown as JsonCompatibleReadOnly;\n\t\t\t},\n\t\t\tdecode: (\n\t\t\t\tencoded: JsonCompatibleReadOnly,\n\t\t\t\tcontext: MessageEncodingContext,\n\t\t\t): DecodedMessage<TChangeset> => {\n\t\t\t\tconst {\n\t\t\t\t\trevision: encodedRevision,\n\t\t\t\t\toriginatorId,\n\t\t\t\t\tchangeset,\n\t\t\t\t} = encoded as unknown as Message;\n\n\t\t\t\tconst revision = revisionTagCodec.decode(encodedRevision, {\n\t\t\t\t\toriginatorId,\n\t\t\t\t\trevision: undefined,\n\t\t\t\t\tidCompressor: context.idCompressor,\n\t\t\t\t});\n\n\t\t\t\treturn {\n\t\t\t\t\tbranchId: \"main\",\n\t\t\t\t\ttype: \"commit\",\n\t\t\t\t\tcommit: {\n\t\t\t\t\t\trevision,\n\t\t\t\t\t\tchange: changeCodec.decode(changeset, {\n\t\t\t\t\t\t\toriginatorId,\n\t\t\t\t\t\t\trevision,\n\t\t\t\t\t\t\tidCompressor: context.idCompressor,\n\t\t\t\t\t\t}),\n\t\t\t\t\t},\n\t\t\t\t\tsessionId: originatorId,\n\t\t\t\t};\n\t\t\t},\n\t\t},\n\t\toptions.jsonValidator,\n\t);\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"messageCodecs.d.ts","sourceRoot":"","sources":["../../src/shared-tree-core/messageCodecs.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AACnE,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,8CAA8C,CAAC;AAM5F,OAAO,EACN,KAAK,SAAS,EACd,KAAK,iBAAiB,EACtB,KAAK,sBAAsB,EAG3B,KAAK,YAAY,EACjB,KAAK,aAAa,EAClB,KAAK,UAAU,EAIf,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EACX,qBAAqB,EACrB,kBAAkB,EAClB,WAAW,EACX,eAAe,EACf,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAkB,KAAK,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAI/E,OAAO,EAAE,oBAAoB,EAAyB,MAAM,oBAAoB,CAAC;AACjF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAExD,MAAM,WAAW,sBAAsB;IACtC,YAAY,EAAE,aAAa,CAAC;IAC5B,MAAM,CAAC,EAAE,eAAe,CAAC;CACzB;AAED;;;;GAIG;AACH,wBAAgB,mCAAmC,CAClD,aAAa,EAAE,uBAAuB,EACtC,oBAAoB,CAAC,EAAE,oBAAoB,GACzC,oBAAoB,CAStB;AAED,MAAM,WAAW,mBAAmB;IACnC,QAAQ,CAAC,q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UAAU,EAAE,qBAAqB,CAAC,EAC7D,4BAA4B,EAAE,sBAAsB,CAAC,oBAAoB,CAAC,EAC1E,gBAAgB,EAAE,UAAU,CAC3B,WAAW,EACX,kBAAkB,EAClB,kBAAkB,EAClB,qBAAqB,CACrB,EACD,OAAO,EAAE,aAAa,GACpB,YAAY,CAAC,cAAc,CAAC,UAAU,CAAC,EAAE,sBAAsB,CAAC,CA8ClE;AAED,wBAAgB,sCAAsC,CACrD,aAAa,EAAE,uBAAuB,EACtC,YAAY,EAAE,SAAS,GACrB,SAAS,CAMX"}
@@ -55,7 +55,7 @@ export function makeMessageCodecs(changeCodecs, dependentChangeFormatVersion, re
55
55
  case unbrand(MessageFormatVersion.v3):
56
56
  case unbrand(MessageFormatVersion.v4):
57
57
  case unbrand(MessageFormatVersion.v6): {
58
- const changeCodec = changeCodecs.resolve(dependentChangeFormatVersion.lookup(version)).json;
58
+ const changeCodec = changeCodecs.resolve(dependentChangeFormatVersion.lookup(version));
59
59
  return [
60
60
  version,
61
61
  makeV1ToV4CodecWithVersion(changeCodec, revisionTagCodec, options, version),
@@ -65,7 +65,7 @@ export function makeMessageCodecs(changeCodecs, dependentChangeFormatVersion, re
65
65
  return [version, makeDiscontinuedCodecVersion(options, version, "2.74.0")];
66
66
  }
67
67
  case unbrand(MessageFormatVersion.vSharedBranches): {
68
- const changeCodec = changeCodecs.resolve(dependentChangeFormatVersion.lookup(version)).json;
68
+ const changeCodec = changeCodecs.resolve(dependentChangeFormatVersion.lookup(version));
69
69
  return [
70
70
  version,
71
71
  makeSharedBranchesCodecWithVersion(changeCodec, revisionTagCodec, options, version),
@@ -1 +1 @@
1
- {"version":3,"file":"messageCodecs.js","sourceRoot":"","sources":["../../src/shared-tree-core/messageCodecs.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAC;AAGtE,OAAO,EACN,+BAA+B,EAC/B,yBAAyB,GACzB,MAAM,wCAAwC,CAA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C,EAAE,CAAC,CAAC,CAAC,CAAC;gBACvC,OAAO,CAAC,OAAO,EAAE,4BAA4B,CAAC,OAAO,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC,CAAC;YAC5E,CAAC;YACD,KAAK,OAAO,CAAC,oBAAoB,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC;gBACpD,MAAM,WAAW,GAAG,YAAY,CAAC,OAAO,CACvC,4BAA4B,CAAC,MAAM,CAAC,OAAO,CAAC,CAC5C,CAAC,IAAI,CAAC;gBACP,OAAO;oBACN,OAAO;oBACP,kCAAkC,CAAC,WAAW,EAAE,gBAAgB,EAAE,OAAO,EAAE,OAAO,CAAC;iBACnF,CAAC;YACH,CAAC;YACD,OAAO,CAAC,CAAC,CAAC;gBACT,eAAe,CAAC,OAAO,CAAC,CAAC;YAC1B,CAAC;QACF,CAAC;IACF,CAAC,CAAC,CAAC;IACH,OAAO,eAAe,CAAC,QAAQ,CAAC,CAAC;AAClC,CAAC;AAED,MAAM,UAAU,sCAAsC,CACrD,aAAsC,EACtC,YAAuB;IAEvB,OAAO;QACN,IAAI,EAAE,SAAS;QACf,OAAO,EAAE,mCAAmC,CAAC,aAAa,CAAC;QAC3D,QAAQ,EAAE,CAAC,YAAY,CAAC;KACxB,CAAC;AACH,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { unreachableCase } from \"@fluidframework/core-utils/internal\";\nimport type { IIdCompressor } from \"@fluidframework/id-compressor\";\nimport type { MinimumVersionForCollab } from \"@fluidframework/runtime-definitions/internal\";\nimport {\n\tgetConfigForMinVersionForCollab,\n\tlowestMinVersionForCollab,\n} from \"@fluidframework/runtime-utils/internal\";\n\nimport {\n\ttype CodecTree,\n\ttype CodecWriteOptions,\n\ttype DependentFormatVersion,\n\tFluidClientVersion,\n\ttype FormatVersion,\n\ttype ICodecFamily,\n\ttype ICodecOptions,\n\ttype IJsonCodec,\n\tmakeCodecFamily,\n\tmakeDiscontinuedCodecVersion,\n\tmakeVersionDispatchingCodec,\n} from \"../codec/index.js\";\nimport type {\n\tChangeEncodingContext,\n\tEncodedRevisionTag,\n\tRevisionTag,\n\tSchemaAndPolicy,\n} from \"../core/index.js\";\nimport { brand, unbrand, type JsonCompatibleReadOnly } from \"../util/index.js\";\n\nimport { makeV1ToV4CodecWithVersion } from \"./messageCodecV1ToV4.js\";\nimport { makeSharedBranchesCodecWithVersion } from \"./messageCodecVSharedBranches.js\";\nimport { MessageFormatVersion, messageFormatVersions } from \"./messageFormat.js\";\nimport type { DecodedMessage } from \"./messageTypes.js\";\n\nexport interface MessageEncodingContext {\n\tidCompressor: IIdCompressor;\n\tschema?: SchemaAndPolicy;\n}\n\n/**\n * Convert a MinimumVersionForCollab to a MessageFormatVersion.\n * @param clientVersion - The MinimumVersionForCollab to convert.\n * @returns The MessageFormatVersion that corresponds to the provided MinimumVersionForCollab.\n */\nexport function clientVersionToMessageFormatVersion(\n\tclientVersion: MinimumVersionForCollab,\n\twriteVersionOverride?: MessageFormatVersion,\n): MessageFormatVersion {\n\tconst compatibleVersion: MessageFormatVersion = brand(\n\t\tgetConfigForMinVersionForCollab(clientVersion, {\n\t\t\t[lowestMinVersionForCollab]: MessageFormatVersion.v3,\n\t\t\t[FluidClientVersion.v2_43]: MessageFormatVersion.v4,\n\t\t\t[FluidClientVersion.v2_80]: MessageFormatVersion.v6,\n\t\t}),\n\t);\n\treturn writeVersionOverride ?? compatibleVersion;\n}\n\nexport interface MessageCodecOptions {\n\treadonly messageFormatSelector?: (\n\t\tminVersionForCollab: MinimumVersionForCollab,\n\t) => MessageFormatVersion;\n}\n\nfunction messageFormatVersionFromOptions(\n\toptions: MessageCodecOptions & CodecWriteOptions,\n): MessageFormatVersion {\n\tconst selector = options.messageFormatSelector ?? clientVersionToMessageFormatVersion;\n\treturn selector(options.minVersionForCollab);\n}\n\n/**\n * Returns the version that should be used for testing shared branches.\n */\nexport function messageFormatVersionSelectorForSharedBranches(\n\tclientVersion: MinimumVersionForCollab,\n): MessageFormatVersion {\n\treturn brand(MessageFormatVersion.vSharedBranches);\n}\n\nexport function makeMessageCodec<TChangeset>(\n\tchangeCodecs: ICodecFamily<TChangeset, ChangeEncodingContext>,\n\tdependentChangeFormatVersion: DependentFormatVersion<MessageFormatVersion>,\n\trevisionTagCodec: IJsonCodec<\n\t\tRevisionTag,\n\t\tEncodedRevisionTag,\n\t\tEncodedRevisionTag,\n\t\tChangeEncodingContext\n\t>,\n\toptions: MessageCodecOptions & CodecWriteOptions,\n): IJsonCodec<\n\tDecodedMessage<TChangeset>,\n\tJsonCompatibleReadOnly,\n\tJsonCompatibleReadOnly,\n\tMessageEncodingContext\n> {\n\tconst family = makeMessageCodecs(\n\t\tchangeCodecs,\n\t\tdependentChangeFormatVersion,\n\t\trevisionTagCodec,\n\t\toptions,\n\t);\n\tconst writeVersion = messageFormatVersionFromOptions(options);\n\treturn makeVersionDispatchingCodec(family, { ...options, writeVersion });\n}\n\n/**\n * @privateRemarks Exported for testing.\n */\nexport function makeMessageCodecs<TChangeset>(\n\tchangeCodecs: ICodecFamily<TChangeset, ChangeEncodingContext>,\n\tdependentChangeFormatVersion: DependentFormatVersion<MessageFormatVersion>,\n\trevisionTagCodec: IJsonCodec<\n\t\tRevisionTag,\n\t\tEncodedRevisionTag,\n\t\tEncodedRevisionTag,\n\t\tChangeEncodingContext\n\t>,\n\toptions: ICodecOptions,\n): ICodecFamily<DecodedMessage<TChangeset>, MessageEncodingContext> {\n\tconst registry: [\n\t\tFormatVersion,\n\t\tIJsonCodec<\n\t\t\tDecodedMessage<TChangeset>,\n\t\t\tJsonCompatibleReadOnly,\n\t\t\tJsonCompatibleReadOnly,\n\t\t\tMessageEncodingContext\n\t\t>,\n\t][] = [...messageFormatVersions].map((version) => {\n\t\tswitch (version) {\n\t\t\tcase unbrand(MessageFormatVersion.undefined):\n\t\t\tcase unbrand(MessageFormatVersion.v1):\n\t\t\tcase unbrand(MessageFormatVersion.v2): {\n\t\t\t\tconst versionOrUndefined =\n\t\t\t\t\tversion === unbrand(MessageFormatVersion.undefined) ? undefined : version;\n\t\t\t\treturn [\n\t\t\t\t\tversionOrUndefined,\n\t\t\t\t\tmakeDiscontinuedCodecVersion(options, versionOrUndefined, \"2.73.0\"),\n\t\t\t\t];\n\t\t\t}\n\t\t\tcase unbrand(MessageFormatVersion.v3):\n\t\t\tcase unbrand(MessageFormatVersion.v4):\n\t\t\tcase unbrand(MessageFormatVersion.v6): {\n\t\t\t\tconst changeCodec = changeCodecs.resolve(\n\t\t\t\t\tdependentChangeFormatVersion.lookup(version),\n\t\t\t\t).json;\n\t\t\t\treturn [\n\t\t\t\t\tversion,\n\t\t\t\t\tmakeV1ToV4CodecWithVersion(changeCodec, revisionTagCodec, options, version),\n\t\t\t\t];\n\t\t\t}\n\t\t\tcase unbrand(MessageFormatVersion.v5): {\n\t\t\t\treturn [version, makeDiscontinuedCodecVersion(options, version, \"2.74.0\")];\n\t\t\t}\n\t\t\tcase unbrand(MessageFormatVersion.vSharedBranches): {\n\t\t\t\tconst changeCodec = changeCodecs.resolve(\n\t\t\t\t\tdependentChangeFormatVersion.lookup(version),\n\t\t\t\t).json;\n\t\t\t\treturn [\n\t\t\t\t\tversion,\n\t\t\t\t\tmakeSharedBranchesCodecWithVersion(changeCodec, revisionTagCodec, options, version),\n\t\t\t\t];\n\t\t\t}\n\t\t\tdefault: {\n\t\t\t\tunreachableCase(version);\n\t\t\t}\n\t\t}\n\t});\n\treturn makeCodecFamily(registry);\n}\n\nexport function getCodecTreeForMessageFormatWithChange(\n\tclientVersion: MinimumVersionForCollab,\n\tchangeFormat: CodecTree,\n): CodecTree {\n\treturn {\n\t\tname: \"Message\",\n\t\tversion: clientVersionToMessageFormatVersion(clientVersion),\n\t\tchildren: [changeFormat],\n\t};\n}\n"]}
1
+ {"version":3,"file":"messageCodecs.js","sourceRoot":"","sources":["../../src/shared-tree-core/messageCodecs.ts"],"names":[],"mappings":"AAAA;;;GAG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W,EAAE,gBAAgB,EAAE,OAAO,EAAE,OAAO,CAAC;iBAC3E,CAAC;YACH,CAAC;YACD,KAAK,OAAO,CAAC,oBAAoB,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;gBACvC,OAAO,CAAC,OAAO,EAAE,4BAA4B,CAAC,OAAO,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC,CAAC;YAC5E,CAAC;YACD,KAAK,OAAO,CAAC,oBAAoB,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC;gBACpD,MAAM,WAAW,GAAG,YAAY,CAAC,OAAO,CAAC,4BAA4B,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC;gBACvF,OAAO;oBACN,OAAO;oBACP,kCAAkC,CAAC,WAAW,EAAE,gBAAgB,EAAE,OAAO,EAAE,OAAO,CAAC;iBACnF,CAAC;YACH,CAAC;YACD,OAAO,CAAC,CAAC,CAAC;gBACT,eAAe,CAAC,OAAO,CAAC,CAAC;YAC1B,CAAC;QACF,CAAC;IACF,CAAC,CAAC,CAAC;IACH,OAAO,eAAe,CAAC,QAAQ,CAAC,CAAC;AAClC,CAAC;AAED,MAAM,UAAU,sCAAsC,CACrD,aAAsC,EACtC,YAAuB;IAEvB,OAAO;QACN,IAAI,EAAE,SAAS;QACf,OAAO,EAAE,mCAAmC,CAAC,aAAa,CAAC;QAC3D,QAAQ,EAAE,CAAC,YAAY,CAAC;KACxB,CAAC;AACH,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { unreachableCase } from \"@fluidframework/core-utils/internal\";\nimport type { IIdCompressor } from \"@fluidframework/id-compressor\";\nimport type { MinimumVersionForCollab } from \"@fluidframework/runtime-definitions/internal\";\nimport {\n\tgetConfigForMinVersionForCollab,\n\tlowestMinVersionForCollab,\n} from \"@fluidframework/runtime-utils/internal\";\n\nimport {\n\ttype CodecTree,\n\ttype CodecWriteOptions,\n\ttype DependentFormatVersion,\n\tFluidClientVersion,\n\ttype FormatVersion,\n\ttype ICodecFamily,\n\ttype ICodecOptions,\n\ttype IJsonCodec,\n\tmakeCodecFamily,\n\tmakeDiscontinuedCodecVersion,\n\tmakeVersionDispatchingCodec,\n} from \"../codec/index.js\";\nimport type {\n\tChangeEncodingContext,\n\tEncodedRevisionTag,\n\tRevisionTag,\n\tSchemaAndPolicy,\n} from \"../core/index.js\";\nimport { brand, unbrand, type JsonCompatibleReadOnly } from \"../util/index.js\";\n\nimport { makeV1ToV4CodecWithVersion } from \"./messageCodecV1ToV4.js\";\nimport { makeSharedBranchesCodecWithVersion } from \"./messageCodecVSharedBranches.js\";\nimport { MessageFormatVersion, messageFormatVersions } from \"./messageFormat.js\";\nimport type { DecodedMessage } from \"./messageTypes.js\";\n\nexport interface MessageEncodingContext {\n\tidCompressor: IIdCompressor;\n\tschema?: SchemaAndPolicy;\n}\n\n/**\n * Convert a MinimumVersionForCollab to a MessageFormatVersion.\n * @param clientVersion - The MinimumVersionForCollab to convert.\n * @returns The MessageFormatVersion that corresponds to the provided MinimumVersionForCollab.\n */\nexport function clientVersionToMessageFormatVersion(\n\tclientVersion: MinimumVersionForCollab,\n\twriteVersionOverride?: MessageFormatVersion,\n): MessageFormatVersion {\n\tconst compatibleVersion: MessageFormatVersion = brand(\n\t\tgetConfigForMinVersionForCollab(clientVersion, {\n\t\t\t[lowestMinVersionForCollab]: MessageFormatVersion.v3,\n\t\t\t[FluidClientVersion.v2_43]: MessageFormatVersion.v4,\n\t\t\t[FluidClientVersion.v2_80]: MessageFormatVersion.v6,\n\t\t}),\n\t);\n\treturn writeVersionOverride ?? compatibleVersion;\n}\n\nexport interface MessageCodecOptions {\n\treadonly messageFormatSelector?: (\n\t\tminVersionForCollab: MinimumVersionForCollab,\n\t) => MessageFormatVersion;\n}\n\nfunction messageFormatVersionFromOptions(\n\toptions: MessageCodecOptions & CodecWriteOptions,\n): MessageFormatVersion {\n\tconst selector = options.messageFormatSelector ?? clientVersionToMessageFormatVersion;\n\treturn selector(options.minVersionForCollab);\n}\n\n/**\n * Returns the version that should be used for testing shared branches.\n */\nexport function messageFormatVersionSelectorForSharedBranches(\n\tclientVersion: MinimumVersionForCollab,\n): MessageFormatVersion {\n\treturn brand(MessageFormatVersion.vSharedBranches);\n}\n\nexport function makeMessageCodec<TChangeset>(\n\tchangeCodecs: ICodecFamily<TChangeset, ChangeEncodingContext>,\n\tdependentChangeFormatVersion: DependentFormatVersion<MessageFormatVersion>,\n\trevisionTagCodec: IJsonCodec<\n\t\tRevisionTag,\n\t\tEncodedRevisionTag,\n\t\tEncodedRevisionTag,\n\t\tChangeEncodingContext\n\t>,\n\toptions: MessageCodecOptions & CodecWriteOptions,\n): IJsonCodec<\n\tDecodedMessage<TChangeset>,\n\tJsonCompatibleReadOnly,\n\tJsonCompatibleReadOnly,\n\tMessageEncodingContext\n> {\n\tconst family = makeMessageCodecs(\n\t\tchangeCodecs,\n\t\tdependentChangeFormatVersion,\n\t\trevisionTagCodec,\n\t\toptions,\n\t);\n\tconst writeVersion = messageFormatVersionFromOptions(options);\n\treturn makeVersionDispatchingCodec(family, { ...options, writeVersion });\n}\n\n/**\n * @privateRemarks Exported for testing.\n */\nexport function makeMessageCodecs<TChangeset>(\n\tchangeCodecs: ICodecFamily<TChangeset, ChangeEncodingContext>,\n\tdependentChangeFormatVersion: DependentFormatVersion<MessageFormatVersion>,\n\trevisionTagCodec: IJsonCodec<\n\t\tRevisionTag,\n\t\tEncodedRevisionTag,\n\t\tEncodedRevisionTag,\n\t\tChangeEncodingContext\n\t>,\n\toptions: ICodecOptions,\n): ICodecFamily<DecodedMessage<TChangeset>, MessageEncodingContext> {\n\tconst registry: [\n\t\tFormatVersion,\n\t\tIJsonCodec<\n\t\t\tDecodedMessage<TChangeset>,\n\t\t\tJsonCompatibleReadOnly,\n\t\t\tJsonCompatibleReadOnly,\n\t\t\tMessageEncodingContext\n\t\t>,\n\t][] = [...messageFormatVersions].map((version) => {\n\t\tswitch (version) {\n\t\t\tcase unbrand(MessageFormatVersion.undefined):\n\t\t\tcase unbrand(MessageFormatVersion.v1):\n\t\t\tcase unbrand(MessageFormatVersion.v2): {\n\t\t\t\tconst versionOrUndefined =\n\t\t\t\t\tversion === unbrand(MessageFormatVersion.undefined) ? undefined : version;\n\t\t\t\treturn [\n\t\t\t\t\tversionOrUndefined,\n\t\t\t\t\tmakeDiscontinuedCodecVersion(options, versionOrUndefined, \"2.73.0\"),\n\t\t\t\t];\n\t\t\t}\n\t\t\tcase unbrand(MessageFormatVersion.v3):\n\t\t\tcase unbrand(MessageFormatVersion.v4):\n\t\t\tcase unbrand(MessageFormatVersion.v6): {\n\t\t\t\tconst changeCodec = changeCodecs.resolve(dependentChangeFormatVersion.lookup(version));\n\t\t\t\treturn [\n\t\t\t\t\tversion,\n\t\t\t\t\tmakeV1ToV4CodecWithVersion(changeCodec, revisionTagCodec, options, version),\n\t\t\t\t];\n\t\t\t}\n\t\t\tcase unbrand(MessageFormatVersion.v5): {\n\t\t\t\treturn [version, makeDiscontinuedCodecVersion(options, version, \"2.74.0\")];\n\t\t\t}\n\t\t\tcase unbrand(MessageFormatVersion.vSharedBranches): {\n\t\t\t\tconst changeCodec = changeCodecs.resolve(dependentChangeFormatVersion.lookup(version));\n\t\t\t\treturn [\n\t\t\t\t\tversion,\n\t\t\t\t\tmakeSharedBranchesCodecWithVersion(changeCodec, revisionTagCodec, options, version),\n\t\t\t\t];\n\t\t\t}\n\t\t\tdefault: {\n\t\t\t\tunreachableCase(version);\n\t\t\t}\n\t\t}\n\t});\n\treturn makeCodecFamily(registry);\n}\n\nexport function getCodecTreeForMessageFormatWithChange(\n\tclientVersion: MinimumVersionForCollab,\n\tchangeFormat: CodecTree,\n): CodecTree {\n\treturn {\n\t\tname: \"Message\",\n\t\tversion: clientVersionToMessageFormatVersion(clientVersion),\n\t\tchildren: [changeFormat],\n\t};\n}\n"]}
@@ -27,6 +27,8 @@ export interface Transactor {
27
27
  * Start a new transaction.
28
28
  * If a transaction is already in progress when this new transaction starts, then this transaction will be "nested" inside of it,
29
29
  * i.e. the outer transaction will still be in progress after this new transaction is committed or aborted.
30
+ * @param isAsync - Whether the transaction is asynchronous.
31
+ * An error will be thrown if an asynchronous transaction is started while a synchronous transaction is in progress.
30
32
  *
31
33
  * @remarks Asynchronous transactions are not supported on the root checkout,
32
34
  * since it is always kept up-to-date with the latest remote edits and the results of this rebasing (which might invalidate
@@ -40,7 +42,7 @@ export interface Transactor {
40
42
  * @privateRemarks There is currently no enforcement that asynchronous transactions don't happen on the root checkout.
41
43
  * AB#6488 tracks adding some enforcement to make it more clear to application authors that this is not supported.
42
44
  */
43
- start(): void;
45
+ start(isAsync: boolean): void;
44
46
  /**
45
47
  * Close this transaction by squashing its edits and committing them as a single edit.
46
48
  * If this is the root checkout and there are no ongoing transactions remaining, the squashed edit will be submitted to Fluid.
@@ -120,12 +122,21 @@ export declare class TransactionStack implements Transactor, IDisposable {
120
122
  */
121
123
  constructor(onPush?: OnPush);
122
124
  isInProgress(): boolean;
123
- start(): void;
125
+ start(isAsync: boolean): void;
124
126
  commit(): void;
125
127
  abort(): void;
126
128
  dispose(): void;
127
129
  private ensureNotDisposed;
128
130
  }
131
+ /**
132
+ * A function that will be called when a transaction is popped from the {@link SquashingTransactionStack | stack}.
133
+ * @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.
134
+ * @param result - The result of the transaction.
135
+ * @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.
136
+ * This is needed in asynchronous transactions where new commits have been added to the branch while the transaction was in progress.
137
+ * This will be `undefined` if no such change is necessary.
138
+ */
139
+ export type OnPopWithViewUpdate<TChange> = (result: TransactionResult, viewUpdate: TChange | undefined) => void;
129
140
  /**
130
141
  * An implementation of {@link Transactor} that {@link TransactionStack | uses a stack} and a {@link SharedTreeBranch | branch} to manage transactions.
131
142
  * @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.
@@ -156,7 +167,7 @@ export declare class SquashingTransactionStack<TEditor extends ChangeFamilyEdito
156
167
  * @param branch - The {@link SquashingTransactionStack.branch | branch} that will be forked off of when a transaction begins.
157
168
  * @param onPush - A function that will be called when a transaction is pushed to the {@link TransactionStack | stack}.
158
169
  */
159
- constructor(branch: SharedTreeBranch<TEditor, TChange>, mintRevisionTag: () => RevisionTag, onPush?: () => OnPop | void);
170
+ constructor(branch: SharedTreeBranch<TEditor, TChange>, mintRevisionTag: () => RevisionTag, onPush?: () => OnPopWithViewUpdate<TChange> | void);
160
171
  /** Updates the transaction branch (and therefore the active branch) and rebinds the branch events. */
161
172
  private setTransactionBranch;
162
173
  }
@@ -1 +1 @@
1
- {"version":3,"file":"transaction.d.ts","sourceRoot":"","sources":["../../src/shared-tree-core/transaction.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAI/E,OAAO,EAGN,KAAK,kBAAkB,EAEvB,KAAK,WAAW,EAChB,MAAM,kBAAkB,CAAC;AAG1B,OAAO,KAAK,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAE5E;;;GAGG;AACH,oBAAY,iBAAiB;IAC5B;;OAEG;IACH,KAAK,IAAA;IACL;;OAEG;IACH,MAAM,IAAA;CACN;AAED;;GAEG;AACH,MAAM,WAAW,UAAU;IAC1B;;;;;;;;;;;;;;;;OAgBG;IACH,KAAK,IAAI,IAAI,CAAC;IACd;;;OAGG;IACH,MAAM,IAAI,IAAI,CAAC;IACf;;OAEG;IACH,KAAK,IAAI,IAAI,CAAC;IACd;;OAEG;IACH,YAAY,IAAI,OAAO,CAAC;IACxB;;OAEG;IACH,MAAM,EAAE,UAAU,CAAC,iBAAiB,CAAC,CAAC;CACtC;AAED,MAAM,WAAW,iBAAiB;IACjC;;;OAGG;IACH,OAAO,IAAI,IAAI,CAAC;IAChB;;;O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C,EAC1D,eAAe,EAAE,MAAM,WAAW,EAClC,MAAM,CAAC,EAAE,MAAM,KAAK,GAAG,IAAI;IAqF5B,sGAAsG;IACtG,OAAO,CAAC,oBAAoB;CAY5B"}
1
+ {"version":3,"file":"transaction.d.ts","sourceRoot":"","sources":["../../src/shared-tree-core/transaction.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAI/E,OAAO,EAON,KAAK,kBAAkB,EAEvB,KAAK,WAAW,EAChB,MAAM,kBAAkB,CAAC;AAG1B,OAAO,KAAK,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAE5E;;;GAGG;AACH,oBAAY,iBAAiB;IAC5B;;OAEG;IACH,KAAK,IAAA;IACL;;OAEG;IACH,MAAM,IAAA;CACN;AAED;;GAEG;AACH,MAAM,WAAW,UAAU;IAC1B;;;;;;;;;;;;;;;;;;OAkBG;IACH,KAAK,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAAC;IAC9B;;;OAGG;IACH,MAAM,IAAI,IAAI,CAAC;IACf;;OAEG;IACH,KAAK,IAAI,IAAI,CAAC;IACd;;OAEG;IACH,YAAY,IAAI,OAAO,CAAC;IACxB;;OAEG;IACH,MAAM,EAAE,UAAU,CAAC,iBAAiB,CAAC,CAAC;CACtC;AAED,MAAM,WAAW,iBAAiB;IACjC;;;OAGG;IACH,OAAO,IAAI,IAAI,CAAC;IAChB;;;OAGG;IACH,QAAQ,IAAI,IAAI,CAAC;IACjB;;;OAGG;IACH,UAAU,IAAI,IAAI,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,SAAS;IACzB;;OAEG;IACH,QAAQ,CAAC,KAAK,CAAC,EAAE,KAAK,CAAC;IACvB;;;;;;;;OAQG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;CACzB;AAED;;;;GAIG;AACH,MAAM,MAAM,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AAsG;IACtG,OAAO,CAAC,oBAAoB;CAY5B"}
@@ -17,8 +17,8 @@ var _TransactionStack_stack, _TransactionStack_onPush, _TransactionStack_events,
17
17
  import { createEmitter } from "@fluid-internal/client-utils";
18
18
  import { assert, unreachableCase } from "@fluidframework/core-utils/internal";
19
19
  import { UsageError } from "@fluidframework/telemetry-utils/internal";
20
- import { findAncestor, tagChange, } from "../core/index.js";
21
- import { getLast, getOrCreate, hasSome } from "../util/index.js";
20
+ import { diffHistories, findAncestor, findCommonAncestor, mintCommit, rebaseBranch, tagChange, } from "../core/index.js";
21
+ import { getLast, getOrCreate } from "../util/index.js";
22
22
  /**
23
23
  * Describes the result of a transaction.
24
24
  * Transactions may either succeed and commit, or fail and abort.
@@ -60,11 +60,18 @@ export class TransactionStack {
60
60
  this.ensureNotDisposed();
61
61
  return __classPrivateFieldGet(this, _TransactionStack_stack, "f").length > 0;
62
62
  }
63
- start() {
63
+ start(isAsync) {
64
64
  this.ensureNotDisposed();
65
- const onPushCurrent = hasSome(__classPrivateFieldGet(this, _TransactionStack_stack, "f")) ? getLast(__classPrivateFieldGet(this, _TransactionStack_stack, "f")).onPush : __classPrivateFieldGet(this, _TransactionStack_onPush, "f");
65
+ const last = getLast(__classPrivateFieldGet(this, _TransactionStack_stack, "f"));
66
+ if (last !== undefined && !last.isAsync && isAsync) {
67
+ throw new UsageError("An asynchronous transaction cannot be started while a synchronous transaction is in progress.");
68
+ }
69
+ const onPushCurrent = last === undefined ? __classPrivateFieldGet(this, _TransactionStack_onPush, "f") : last.callbacks.onPush;
66
70
  const { onPush, onPop } = onPushCurrent?.() ?? {};
67
- __classPrivateFieldGet(this, _TransactionStack_stack, "f").push({ onPop, onPush: onPush ?? onPushCurrent });
71
+ __classPrivateFieldGet(this, _TransactionStack_stack, "f").push({
72
+ callbacks: { onPop, onPush: onPush ?? onPushCurrent },
73
+ isAsync,
74
+ });
68
75
  __classPrivateFieldGet(this, _TransactionStack_events, "f").emit("started");
69
76
  }
70
77
  commit() {
@@ -73,7 +80,7 @@ export class TransactionStack {
73
80
  throw new UsageError("No transaction to commit");
74
81
  }
75
82
  __classPrivateFieldGet(this, _TransactionStack_events, "f").emit("committing");
76
- __classPrivateFieldGet(this, _TransactionStack_stack, "f").pop()?.onPop?.(TransactionResult.Commit);
83
+ __classPrivateFieldGet(this, _TransactionStack_stack, "f").pop()?.callbacks.onPop?.(TransactionResult.Commit);
77
84
  }
78
85
  abort() {
79
86
  this.ensureNotDisposed();
@@ -81,7 +88,7 @@ export class TransactionStack {
81
88
  throw new UsageError("No transaction to abort");
82
89
  }
83
90
  __classPrivateFieldGet(this, _TransactionStack_events, "f").emit("aborting");
84
- __classPrivateFieldGet(this, _TransactionStack_stack, "f").pop()?.onPop?.(TransactionResult.Abort);
91
+ __classPrivateFieldGet(this, _TransactionStack_stack, "f").pop()?.callbacks.onPop?.(TransactionResult.Abort);
85
92
  }
86
93
  dispose() {
87
94
  this.ensureNotDisposed();
@@ -143,8 +150,8 @@ export class SquashingTransactionStack extends TransactionStack {
143
150
  // Invoked when an outer transaction starts
144
151
  () => {
145
152
  // Keep track of the commit that each transaction was on when it started
146
- // TODO:#8603: This may need to be computed differently if we allow rebasing during a transaction.
147
153
  const startHead = this.activeBranch.getHead();
154
+ const rebaser = this.branch.changeFamily.rebaser;
148
155
  const outerOnPop = onPush?.();
149
156
  let transactionRevision;
150
157
  const transactionBranch = this.branch.fork(startHead,
@@ -156,22 +163,58 @@ export class SquashingTransactionStack extends TransactionStack {
156
163
  const onOuterTransactionPop = (result) => {
157
164
  assert(!this.isInProgress(), 0xcae /* The outer transaction should be ending */);
158
165
  transactionBranch.editor.exitTransaction();
166
+ const sourcePath = [];
167
+ const targetPath = [];
168
+ const ancestor = findCommonAncestor([startHead, sourcePath], [branch.getHead(), targetPath]);
169
+ assert(ancestor !== undefined, 0xcce /* branches must be related */);
170
+ const transactionSteps = [];
171
+ findAncestor([transactionBranch.getHead(), transactionSteps], (c) => c === startHead);
172
+ let viewUpdate;
159
173
  switch (result) {
160
174
  case TransactionResult.Abort: {
161
- // When a transaction is aborted, roll back all the transaction's changes on the current branch
175
+ // When a transaction is aborted, roll back all the transaction's changes on the current branch.
176
+ // It is important that this happens before and separately from updating the view because the `TreeCheckout` needs to
177
+ // revert some internal (state to match what it was before the transaction began) before applying the view update (if any).
162
178
  transactionBranch.removeAfter(startHead);
179
+ // If changes were made on `branch` since the transaction began, the view will need to be updated to reflect those changes.
180
+ if (targetPath.length > 0) {
181
+ viewUpdate = diffHistories(rebaser, startHead, this.branch.getHead(), mintRevisionTag);
182
+ }
163
183
  break;
164
184
  }
165
185
  case TransactionResult.Commit: {
166
- // ...squash all the new commits on the transaction branch into a new commit on the original branch
167
- const removedCommits = [];
168
- findAncestor([transactionBranch.getHead(), removedCommits], (c) => c === startHead);
169
- if (removedCommits.length > 0) {
170
- for (const commit of removedCommits) {
186
+ if (transactionSteps.length > 0) {
187
+ assert(transactionRevision !== undefined, 0xccf /* Expected transaction revision in the presence of transaction steps */);
188
+ for (const commit of transactionSteps) {
171
189
  assert(commit.revision === transactionRevision, 0xcaf /* Unexpected commit in transaction */);
172
190
  }
173
- const squash = this.branch.changeFamily.rebaser.compose(removedCommits);
174
- this.branch.apply(tagChange(squash, transactionRevision));
191
+ // Squash all the new commits on the transaction branch into a new commit on the original branch
192
+ const squash = rebaser.compose(transactionSteps);
193
+ if (targetPath.length === 0) {
194
+ // No changes were made on the original branch since the transaction began
195
+ // The transaction commit can be applied directly
196
+ this.branch.apply(tagChange(squash, transactionRevision));
197
+ // The view is already up-to-date so there's nothing more to do
198
+ }
199
+ else {
200
+ // Some changes were made on `branch` since the transaction began
201
+ const unrebasedHead = mintCommit(startHead, {
202
+ change: squash,
203
+ revision: transactionRevision,
204
+ });
205
+ // We need to rebase the transaction commit on top of the new changes
206
+ const rebased = rebaseBranch(mintRevisionTag, rebaser, unrebasedHead, branch.getHead());
207
+ assert(rebased.newSourceHead.revision === transactionRevision, 0xcd0 /* The transaction commit should be rebased to the tip */);
208
+ this.branch.apply(rebased.newSourceHead);
209
+ viewUpdate = rebased.sourceChange;
210
+ }
211
+ }
212
+ else {
213
+ if (targetPath.length > 0) {
214
+ // Changes were made on `branch` since the transaction began.
215
+ // The view will need to be updated to reflect those changes.
216
+ viewUpdate = diffHistories(rebaser, startHead, this.branch.getHead(), mintRevisionTag);
217
+ }
175
218
  }
176
219
  break;
177
220
  }
@@ -181,7 +224,7 @@ export class SquashingTransactionStack extends TransactionStack {
181
224
  }
182
225
  transactionBranch.dispose();
183
226
  this.setTransactionBranch(undefined);
184
- outerOnPop?.(result);
227
+ outerOnPop?.(result, viewUpdate);
185
228
  };
186
229
  // Invoked when a nested transaction begins
187
230
  const onNestedTransactionPush = () => {
@@ -205,7 +248,7 @@ export class SquashingTransactionStack extends TransactionStack {
205
248
  unreachableCase(result);
206
249
  }
207
250
  }
208
- nestedOuterOnPop?.(result);
251
+ nestedOuterOnPop?.(result, undefined);
209
252
  },
210
253
  };
211
254
  };
@@ -1 +1 @@
1
- {"version":3,"file":"transaction.js","sourceRoot":"","sources":["../../src/shared-tree-core/transaction.ts"],"names":[],"mappings":"AAAA;;;GAGG;;;;;;;;;;;;;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAE7D,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAC;AAC9E,OAAO,EAAE,UAAU,EAAE,MAAM,0CAA0C,CAAC;AAEtE,OAAO,EACN,YAAY,EACZ,SAAS,GAIT,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAIjE;;;GAGG;AACH,MAAM,CAAN,IAAY,iBASX;AATD,WAAY,iBAAiB;IAC5B;;OAEG;IACH,2DAAK,CAAA;IACL;;OAEG;IACH,6DAAM,CAAA;AACP,CAAC,EATW,iBAAiB,KAAjB,iBAAiB,QAS5B;AA8FD;;;GAGG;AACH,MAA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B,IAAI,GAAG,EAKnC,EAAC;IA6FJ,CAAC;IAED,sGAAsG;IAC9F,oBAAoB,CAC3B,iBAAiE;QAEjE,MAAM,eAAe,GAAG,IAAI,CAAC,YAAY,CAAC;QAC1C,uBAAA,IAAI,gDAAsB,iBAAiB,MAAA,CAAC;QAC5C,KAAK,MAAM,CAAC,SAAS,EAAE,SAAS,CAAC,IAAI,uBAAA,IAAI,qDAAoB,EAAE,CAAC;YAC/D,KAAK,MAAM,QAAQ,IAAI,SAAS,EAAE,CAAC;gBAClC,eAAe,CAAC,MAAM,CAAC,GAAG,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;gBAChD,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,EAAE,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;YAClD,CAAC;QACF,CAAC;IACF,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { createEmitter } from \"@fluid-internal/client-utils\";\nimport type { IDisposable, Listenable } from \"@fluidframework/core-interfaces\";\nimport { assert, unreachableCase } from \"@fluidframework/core-utils/internal\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\n\nimport {\n\tfindAncestor,\n\ttagChange,\n\ttype ChangeFamilyEditor,\n\ttype GraphCommit,\n\ttype RevisionTag,\n} from \"../core/index.js\";\nimport { getLast, getOrCreate, hasSome } from \"../util/index.js\";\n\nimport type { SharedTreeBranch, SharedTreeBranchEvents } from \"./branch.js\";\n\n/**\n * Describes the result of a transaction.\n * Transactions may either succeed and commit, or fail and abort.\n */\nexport enum TransactionResult {\n\t/**\n\t * Indicates the transaction failed.\n\t */\n\tAbort,\n\t/**\n\t * Indicates the transaction succeeded.\n\t */\n\tCommit,\n}\n\n/**\n * A simple API for managing transactions.\n */\nexport interface Transactor {\n\t/**\n\t * Start a new transaction.\n\t * If a transaction is already in progress when this new transaction starts, then this transaction will be \"nested\" inside of it,\n\t * i.e. the outer transaction will still be in progress after this new transaction is committed or aborted.\n\t *\n\t * @remarks Asynchronous transactions are not supported on the root checkout,\n\t * since it is always kept up-to-date with the latest remote edits and the results of this rebasing (which might invalidate\n\t * the transaction) is not visible to the application author.\n\t * Instead,\n\t *\n\t * 1. fork the root checkout\n\t * 2. run the transaction on the fork\n\t * 3. merge the fork back into the root checkout\n\t *\n\t * @privateRemarks There is currently no enforcement that asynchronous transactions don't happen on the root checkout.\n\t * AB#6488 tracks adding some enforcement to make it more clear to application authors that this is not supported.\n\t */\n\tstart(): void;\n\t/**\n\t * Close this transaction by squashing its edits and committing them as a single edit.\n\t * If this is the root checkout and there are no ongoing transactions remaining, the squashed edit will be submitted to Fluid.\n\t */\n\tcommit(): void;\n\t/**\n\t * Close this transaction and revert the state of the tree to what it was before this transaction began.\n\t */\n\tabort(): void;\n\t/**\n\t * True if there is at least one transaction currently in progress on this view, otherwise false.\n\t */\n\tisInProgress(): boolean;\n\t/**\n\t * Provides events for changes in transaction progress.\n\t */\n\tevents: Listenable<TransactionEvents>;\n}\n\nexport interface TransactionEvents {\n\t/**\n\t * Raised just after a transaction has begun.\n\t * @remarks When this event fires, {@link Transactor.isInProgress} will be true because the transaction has already begun.\n\t */\n\tstarted(): void;\n\t/**\n\t * Raised just before a transaction is aborted.\n\t * @remarks When this event fires, {@link Transactor.isInProgress} will still be true because the transaction has not yet ended.\n\t */\n\taborting(): void;\n\t/**\n\t * Raised just before a transaction is committed.\n\t * @remarks When this event fires, {@link Transactor.isInProgress} will still be true because the transaction has not yet ended.\n\t */\n\tcommitting(): void;\n}\n\n/**\n * Callbacks for transaction lifecycle events.\n */\nexport interface Callbacks {\n\t/**\n\t * Called when the current transaction is popped from the {@link TransactionStack | stack}.\n\t */\n\treadonly onPop?: OnPop;\n\t/**\n\t * Called when a nested transaction is pushed onto the {@link TransactionStack | stack}.\n\t * @remarks\n\t * Transactions may be arbitrarily nested (by {@link TransactionStack.start | start}ing a transaction within a transaction that is already in progress).\n\t * The `OnPush` callback for an (outer) transaction may optionally return another `OnPush` callback that is associated with any nested (inner) transaction(s).\n\t * In that case, the inner `OnPush` will be called when those inner transactions are pushed and the outer `OnPush` will not be called.\n\t * Put another way, a transaction always results in a call to exactly one `OnPush` callback - whichever is closest to the transaction.\n\t * The event \"bubbles up\" to (and no further past) its first registered callback.\n\t */\n\treadonly onPush?: OnPush;\n}\n\n/**\n * A function that will be called when a transaction is pushed to the {@link TransactionStack | stack}.\n * @remarks This function may return other functions that will be called when the transaction is popped from the stack or a nested transaction is pushed onto the stack.\n * This function runs just before the transaction begins, so if this is the beginning of an outermost (not nested) transaction then {@link Transactor.isInProgress} will be false during its execution.\n */\nexport type OnPush = () => Callbacks | void;\n\n/**\n * A function that will be called when a transaction is popped from the {@link TransactionStack | stack}.\n * @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.\n */\nexport type OnPop = (result: TransactionResult) => void;\n\n/**\n * An implementation of {@link Transactor} that uses a stack to manage transactions.\n * @remarks Using a stack allows transactions to nest - i.e. an inner transaction may be started while an outer transaction is already in progress.\n */\nexport class TransactionStack implements Transactor, IDisposable {\n\treadonly #stack: Callbacks[] = [];\n\treadonly #onPush?: OnPush;\n\n\treadonly #events = createEmitter<TransactionEvents>();\n\tpublic get events(): Listenable<TransactionEvents> {\n\t\treturn this.#events;\n\t}\n\n\t#disposed = false;\n\tpublic get disposed(): boolean {\n\t\treturn this.#disposed;\n\t}\n\n\t/**\n\t * Construct a new {@link TransactionStack}.\n\t * @param onPush - A {@link OnPush | function} that will be called when a transaction begins.\n\t */\n\tpublic constructor(onPush?: OnPush) {\n\t\tthis.#onPush = onPush;\n\t}\n\n\tpublic isInProgress(): boolean {\n\t\tthis.ensureNotDisposed();\n\t\treturn this.#stack.length > 0;\n\t}\n\n\tpublic start(): void {\n\t\tthis.ensureNotDisposed();\n\t\tconst onPushCurrent = hasSome(this.#stack) ? getLast(this.#stack).onPush : this.#onPush;\n\t\tconst { onPush, onPop } = onPushCurrent?.() ?? {};\n\t\tthis.#stack.push({ onPop, onPush: onPush ?? onPushCurrent });\n\t\tthis.#events.emit(\"started\");\n\t}\n\n\tpublic commit(): void {\n\t\tthis.ensureNotDisposed();\n\t\tif (!this.isInProgress()) {\n\t\t\tthrow new UsageError(\"No transaction to commit\");\n\t\t}\n\t\tthis.#events.emit(\"committing\");\n\t\tthis.#stack.pop()?.onPop?.(TransactionResult.Commit);\n\t}\n\n\tpublic abort(): void {\n\t\tthis.ensureNotDisposed();\n\t\tif (!this.isInProgress()) {\n\t\t\tthrow new UsageError(\"No transaction to abort\");\n\t\t}\n\t\tthis.#events.emit(\"aborting\");\n\t\tthis.#stack.pop()?.onPop?.(TransactionResult.Abort);\n\t}\n\n\tpublic dispose(): void {\n\t\tthis.ensureNotDisposed();\n\t\twhile (this.isInProgress()) {\n\t\t\tthis.abort();\n\t\t}\n\t\tthis.#disposed = true;\n\t}\n\n\tprivate ensureNotDisposed(): void {\n\t\tif (this.disposed) {\n\t\t\tthrow new UsageError(\"Transactor is disposed\");\n\t\t}\n\t}\n}\n\n/**\n * An implementation of {@link Transactor} that {@link TransactionStack | uses a stack} and a {@link SharedTreeBranch | branch} to manage transactions.\n * @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.\n * This class provides conveniences for interacting with the {@link SquashingTransactionStack.activeBranch | active branch} in a way that is stable across transaction boundaries.\n * For example, see {@link SquashingTransactionStack.activeBranchEditor | activeBranchEditor} and {@link SquashingTransactionStack.activeBranchEvents | activeBranchEvents}.\n */\nexport class SquashingTransactionStack<\n\tTEditor extends ChangeFamilyEditor,\n\tTChange,\n> extends TransactionStack {\n\t#transactionBranch?: SharedTreeBranch<TEditor, TChange>;\n\n\t/**\n\t * An editor for whichever branch is currently the {@link SquashingTransactionStack.activeBranch | active branch}.\n\t * @remarks This editor can safely be held on to across transaction boundaries, as it will properly delegate to the correct branch.\n\t * In contrast, it is not safe to hold onto e.g. `activeBranch.editor` across transaction boundaries, since the active branch may change.\n\t */\n\tpublic readonly activeBranchEditor = new Proxy<TEditor>({} as unknown as TEditor, {\n\t\tget: (_, p, receiver) => {\n\t\t\treturn Reflect.get(this.activeBranch.editor, p, receiver);\n\t\t},\n\t});\n\n\t/**\n\t * Get the \"active branch\" for this transactor - either the transaction branch if a transaction is in progress, or the original branch otherwise.\n\t */\n\tpublic get activeBranch(): SharedTreeBranch<TEditor, TChange> {\n\t\treturn this.#transactionBranch ?? this.branch;\n\t}\n\n\t/**\n\t * Provides events for changes in the {@link SquashingTransactionStack.activeBranch | active branch}.\n\t * @remarks When the active branch changes, the listeners for these events will automatically be transferred to the new active branch.\n\t * In contrast, binding an event to the {@link SquashingTransactionStack.activeBranch | active branch} directly will not automatically transfer the listener when the active branch changes.\n\t */\n\tpublic get activeBranchEvents(): Listenable<SharedTreeBranchEvents<TEditor, TChange>> {\n\t\tconst off = (\n\t\t\teventName: keyof SharedTreeBranchEvents<TEditor, TChange>,\n\t\t\tlistener: SharedTreeBranchEvents<TEditor, TChange>[typeof eventName],\n\t\t): void => {\n\t\t\tthis.activeBranch.events.off(eventName, listener);\n\t\t\tconst listeners = this.#activeBranchEvents.get(eventName);\n\t\t\tif (listeners?.delete(listener) === true && listeners.size === 0) {\n\t\t\t\tthis.#activeBranchEvents.delete(eventName);\n\t\t\t}\n\t\t};\n\n\t\treturn {\n\t\t\ton: (eventName, listener) => {\n\t\t\t\tconst listeners = getOrCreate(this.#activeBranchEvents, eventName, () => new Set());\n\t\t\t\tlisteners.add(listener);\n\t\t\t\tthis.activeBranch.events.on(eventName, listener);\n\t\t\t\treturn () => off(eventName, listener);\n\t\t\t},\n\t\t\toff,\n\t\t};\n\t}\n\treadonly #activeBranchEvents = new Map<\n\t\tkeyof SharedTreeBranchEvents<TEditor, TChange>,\n\t\tSet<\n\t\t\tSharedTreeBranchEvents<TEditor, TChange>[keyof SharedTreeBranchEvents<TEditor, TChange>]\n\t\t>\n\t>();\n\n\t/**\n\t * Construct a new {@link SquashingTransactionStack}.\n\t * @param branch - The {@link SquashingTransactionStack.branch | branch} that will be forked off of when a transaction begins.\n\t * @param onPush - A function that will be called when a transaction is pushed to the {@link TransactionStack | stack}.\n\t */\n\tpublic constructor(\n\t\tpublic readonly branch: SharedTreeBranch<TEditor, TChange>,\n\t\tmintRevisionTag: () => RevisionTag,\n\t\tonPush?: () => OnPop | void,\n\t) {\n\t\tsuper(\n\t\t\t// Invoked when an outer transaction starts\n\t\t\t(): Callbacks => {\n\t\t\t\t// Keep track of the commit that each transaction was on when it started\n\t\t\t\t// TODO:#8603: This may need to be computed differently if we allow rebasing during a transaction.\n\t\t\t\tconst startHead = this.activeBranch.getHead();\n\t\t\t\tconst outerOnPop = onPush?.();\n\t\t\t\tlet transactionRevision: RevisionTag | undefined;\n\t\t\t\tconst transactionBranch = this.branch.fork(\n\t\t\t\t\tstartHead,\n\t\t\t\t\t// Lazily mint the revision tag for the transaction when it is first needed\n\t\t\t\t\t() => (transactionRevision ??= mintRevisionTag()),\n\t\t\t\t);\n\t\t\t\tthis.setTransactionBranch(transactionBranch);\n\t\t\t\ttransactionBranch.editor.enterTransaction();\n\t\t\t\t// Invoked when an outer transaction ends\n\t\t\t\tconst onOuterTransactionPop: OnPop = (result) => {\n\t\t\t\t\tassert(!this.isInProgress(), 0xcae /* The outer transaction should be ending */);\n\t\t\t\t\ttransactionBranch.editor.exitTransaction();\n\t\t\t\t\tswitch (result) {\n\t\t\t\t\t\tcase TransactionResult.Abort: {\n\t\t\t\t\t\t\t// When a transaction is aborted, roll back all the transaction's changes on the current branch\n\t\t\t\t\t\t\ttransactionBranch.removeAfter(startHead);\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcase TransactionResult.Commit: {\n\t\t\t\t\t\t\t// ...squash all the new commits on the transaction branch into a new commit on the original branch\n\t\t\t\t\t\t\tconst removedCommits: GraphCommit<TChange>[] = [];\n\t\t\t\t\t\t\tfindAncestor(\n\t\t\t\t\t\t\t\t[transactionBranch.getHead(), removedCommits],\n\t\t\t\t\t\t\t\t(c) => c === startHead,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tif (removedCommits.length > 0) {\n\t\t\t\t\t\t\t\tfor (const commit of removedCommits) {\n\t\t\t\t\t\t\t\t\tassert(\n\t\t\t\t\t\t\t\t\t\tcommit.revision === transactionRevision,\n\t\t\t\t\t\t\t\t\t\t0xcaf /* Unexpected commit in transaction */,\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tconst squash = this.branch.changeFamily.rebaser.compose(removedCommits);\n\t\t\t\t\t\t\t\tthis.branch.apply(tagChange(squash, transactionRevision));\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tdefault: {\n\t\t\t\t\t\t\tunreachableCase(result);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\ttransactionBranch.dispose();\n\t\t\t\t\tthis.setTransactionBranch(undefined);\n\t\t\t\t\touterOnPop?.(result);\n\t\t\t\t};\n\t\t\t\t// Invoked when a nested transaction begins\n\t\t\t\tconst onNestedTransactionPush: OnPush = () => {\n\t\t\t\t\tconst nestedStartHead = this.activeBranch.getHead();\n\t\t\t\t\tconst nestedOuterOnPop = onPush?.();\n\t\t\t\t\ttransactionBranch.editor.enterTransaction();\n\t\t\t\t\treturn {\n\t\t\t\t\t\t// Invoked when a nested transaction ends\n\t\t\t\t\t\tonPop: (result) => {\n\t\t\t\t\t\t\ttransactionBranch.editor.exitTransaction();\n\t\t\t\t\t\t\tswitch (result) {\n\t\t\t\t\t\t\t\tcase TransactionResult.Abort: {\n\t\t\t\t\t\t\t\t\t// When a transaction is aborted, roll back all the transaction's changes on the current branch\n\t\t\t\t\t\t\t\t\ttransactionBranch.removeAfter(nestedStartHead);\n\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tcase TransactionResult.Commit: {\n\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tdefault: {\n\t\t\t\t\t\t\t\t\tunreachableCase(result);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tnestedOuterOnPop?.(result);\n\t\t\t\t\t\t},\n\t\t\t\t\t};\n\t\t\t\t};\n\t\t\t\treturn { onPop: onOuterTransactionPop, onPush: onNestedTransactionPush };\n\t\t\t},\n\t\t);\n\t}\n\n\t/** Updates the transaction branch (and therefore the active branch) and rebinds the branch events. */\n\tprivate setTransactionBranch(\n\t\ttransactionBranch: SharedTreeBranch<TEditor, TChange> | undefined,\n\t): void {\n\t\tconst oldActiveBranch = this.activeBranch;\n\t\tthis.#transactionBranch = transactionBranch;\n\t\tfor (const [eventName, listeners] of this.#activeBranchEvents) {\n\t\t\tfor (const listener of listeners) {\n\t\t\t\toldActiveBranch.events.off(eventName, listener);\n\t\t\t\tthis.activeBranch.events.on(eventName, listener);\n\t\t\t}\n\t\t}\n\t}\n}\n"]}
1
+ {"version":3,"file":"transaction.js","sourceRoot":"","sources":["../../src/shared-tree-core/transaction.ts"],"names":[],"mappings":"AAAA;;;GAGG;;;;;;;;;;;;;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAE7D,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAC;AAC9E,OAAO,EAAE,UAAU,EAAE,MAAM,0CAA0C,CAAC;AAEtE,OAAO,EACN,aAAa,EACb,YAAY,EACZ,kBAAkB,EAClB,UAAU,EACV,YAAY,EACZ,SAAS,GAIT,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAIxD;;;GAGG;AACH,MAAM,CAAN,IAAY,iBASX;AATD,WAAY,iBAAiB;IAC5B;;OAEG;IACH,2DAA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All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { createEmitter } from \"@fluid-internal/client-utils\";\nimport type { IDisposable, Listenable } from \"@fluidframework/core-interfaces\";\nimport { assert, unreachableCase } from \"@fluidframework/core-utils/internal\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\n\nimport {\n\tdiffHistories,\n\tfindAncestor,\n\tfindCommonAncestor,\n\tmintCommit,\n\trebaseBranch,\n\ttagChange,\n\ttype ChangeFamilyEditor,\n\ttype GraphCommit,\n\ttype RevisionTag,\n} from \"../core/index.js\";\nimport { getLast, getOrCreate } from \"../util/index.js\";\n\nimport type { SharedTreeBranch, SharedTreeBranchEvents } from \"./branch.js\";\n\n/**\n * Describes the result of a transaction.\n * Transactions may either succeed and commit, or fail and abort.\n */\nexport enum TransactionResult {\n\t/**\n\t * Indicates the transaction failed.\n\t */\n\tAbort,\n\t/**\n\t * Indicates the transaction succeeded.\n\t */\n\tCommit,\n}\n\n/**\n * A simple API for managing transactions.\n */\nexport interface Transactor {\n\t/**\n\t * Start a new transaction.\n\t * If a transaction is already in progress when this new transaction starts, then this transaction will be \"nested\" inside of it,\n\t * i.e. the outer transaction will still be in progress after this new transaction is committed or aborted.\n\t * @param isAsync - Whether the transaction is asynchronous.\n\t * An error will be thrown if an asynchronous transaction is started while a synchronous transaction is in progress.\n\t *\n\t * @remarks Asynchronous transactions are not supported on the root checkout,\n\t * since it is always kept up-to-date with the latest remote edits and the results of this rebasing (which might invalidate\n\t * the transaction) is not visible to the application author.\n\t * Instead,\n\t *\n\t * 1. fork the root checkout\n\t * 2. run the transaction on the fork\n\t * 3. merge the fork back into the root checkout\n\t *\n\t * @privateRemarks There is currently no enforcement that asynchronous transactions don't happen on the root checkout.\n\t * AB#6488 tracks adding some enforcement to make it more clear to application authors that this is not supported.\n\t */\n\tstart(isAsync: boolean): void;\n\t/**\n\t * Close this transaction by squashing its edits and committing them as a single edit.\n\t * If this is the root checkout and there are no ongoing transactions remaining, the squashed edit will be submitted to Fluid.\n\t */\n\tcommit(): void;\n\t/**\n\t * Close this transaction and revert the state of the tree to what it was before this transaction began.\n\t */\n\tabort(): void;\n\t/**\n\t * True if there is at least one transaction currently in progress on this view, otherwise false.\n\t */\n\tisInProgress(): boolean;\n\t/**\n\t * Provides events for changes in transaction progress.\n\t */\n\tevents: Listenable<TransactionEvents>;\n}\n\nexport interface TransactionEvents {\n\t/**\n\t * Raised just after a transaction has begun.\n\t * @remarks When this event fires, {@link Transactor.isInProgress} will be true because the transaction has already begun.\n\t */\n\tstarted(): void;\n\t/**\n\t * Raised just before a transaction is aborted.\n\t * @remarks When this event fires, {@link Transactor.isInProgress} will still be true because the transaction has not yet ended.\n\t */\n\taborting(): void;\n\t/**\n\t * Raised just before a transaction is committed.\n\t * @remarks When this event fires, {@link Transactor.isInProgress} will still be true because the transaction has not yet ended.\n\t */\n\tcommitting(): void;\n}\n\n/**\n * Callbacks for transaction lifecycle events.\n */\nexport interface Callbacks {\n\t/**\n\t * Called when the current transaction is popped from the {@link TransactionStack | stack}.\n\t */\n\treadonly onPop?: OnPop;\n\t/**\n\t * Called when a nested transaction is pushed onto the {@link TransactionStack | stack}.\n\t * @remarks\n\t * Transactions may be arbitrarily nested (by {@link TransactionStack.start | start}ing a transaction within a transaction that is already in progress).\n\t * The `OnPush` callback for an (outer) transaction may optionally return another `OnPush` callback that is associated with any nested (inner) transaction(s).\n\t * In that case, the inner `OnPush` will be called when those inner transactions are pushed and the outer `OnPush` will not be called.\n\t * Put another way, a transaction always results in a call to exactly one `OnPush` callback - whichever is closest to the transaction.\n\t * The event \"bubbles up\" to (and no further past) its first registered callback.\n\t */\n\treadonly onPush?: OnPush;\n}\n\n/**\n * A function that will be called when a transaction is pushed to the {@link TransactionStack | stack}.\n * @remarks This function may return other functions that will be called when the transaction is popped from the stack or a nested transaction is pushed onto the stack.\n * This function runs just before the transaction begins, so if this is the beginning of an outermost (not nested) transaction then {@link Transactor.isInProgress} will be false during its execution.\n */\nexport type OnPush = () => Callbacks | void;\n\n/**\n * A function that will be called when a transaction is popped from the {@link TransactionStack | stack}.\n * @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.\n */\nexport type OnPop = (result: TransactionResult) => void;\n\n/**\n * A frame in the transaction stack.\n */\ninterface TransactionStackFrame {\n\t/** The callbacks provided when this transaction frame was pushed onto the stack. */\n\treadonly callbacks: Callbacks;\n\t/** Whether this transaction frame is asynchronous. */\n\treadonly isAsync: boolean;\n}\n\n/**\n * An implementation of {@link Transactor} that uses a stack to manage transactions.\n * @remarks Using a stack allows transactions to nest - i.e. an inner transaction may be started while an outer transaction is already in progress.\n */\nexport class TransactionStack implements Transactor, IDisposable {\n\treadonly #stack: TransactionStackFrame[] = [];\n\treadonly #onPush?: OnPush;\n\n\treadonly #events = createEmitter<TransactionEvents>();\n\tpublic get events(): Listenable<TransactionEvents> {\n\t\treturn this.#events;\n\t}\n\n\t#disposed = false;\n\tpublic get disposed(): boolean {\n\t\treturn this.#disposed;\n\t}\n\n\t/**\n\t * Construct a new {@link TransactionStack}.\n\t * @param onPush - A {@link OnPush | function} that will be called when a transaction begins.\n\t */\n\tpublic constructor(onPush?: OnPush) {\n\t\tthis.#onPush = onPush;\n\t}\n\n\tpublic isInProgress(): boolean {\n\t\tthis.ensureNotDisposed();\n\t\treturn this.#stack.length > 0;\n\t}\n\n\tpublic start(isAsync: boolean): void {\n\t\tthis.ensureNotDisposed();\n\t\tconst last = getLast(this.#stack);\n\t\tif (last !== undefined && !last.isAsync && isAsync) {\n\t\t\tthrow new UsageError(\n\t\t\t\t\"An asynchronous transaction cannot be started while a synchronous transaction is in progress.\",\n\t\t\t);\n\t\t}\n\t\tconst onPushCurrent = last === undefined ? this.#onPush : last.callbacks.onPush;\n\t\tconst { onPush, onPop } = onPushCurrent?.() ?? {};\n\t\tthis.#stack.push({\n\t\t\tcallbacks: { onPop, onPush: onPush ?? onPushCurrent },\n\t\t\tisAsync,\n\t\t});\n\t\tthis.#events.emit(\"started\");\n\t}\n\n\tpublic commit(): void {\n\t\tthis.ensureNotDisposed();\n\t\tif (!this.isInProgress()) {\n\t\t\tthrow new UsageError(\"No transaction to commit\");\n\t\t}\n\t\tthis.#events.emit(\"committing\");\n\t\tthis.#stack.pop()?.callbacks.onPop?.(TransactionResult.Commit);\n\t}\n\n\tpublic abort(): void {\n\t\tthis.ensureNotDisposed();\n\t\tif (!this.isInProgress()) {\n\t\t\tthrow new UsageError(\"No transaction to abort\");\n\t\t}\n\t\tthis.#events.emit(\"aborting\");\n\t\tthis.#stack.pop()?.callbacks.onPop?.(TransactionResult.Abort);\n\t}\n\n\tpublic dispose(): void {\n\t\tthis.ensureNotDisposed();\n\t\twhile (this.isInProgress()) {\n\t\t\tthis.abort();\n\t\t}\n\t\tthis.#disposed = true;\n\t}\n\n\tprivate ensureNotDisposed(): void {\n\t\tif (this.disposed) {\n\t\t\tthrow new UsageError(\"Transactor is disposed\");\n\t\t}\n\t}\n}\n\n/**\n * A function that will be called when a transaction is popped from the {@link SquashingTransactionStack | stack}.\n * @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.\n * @param result - The result of the transaction.\n * @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.\n * This is needed in asynchronous transactions where new commits have been added to the branch while the transaction was in progress.\n * This will be `undefined` if no such change is necessary.\n */\nexport type OnPopWithViewUpdate<TChange> = (\n\tresult: TransactionResult,\n\tviewUpdate: TChange | undefined,\n) => void;\n\n/**\n * An implementation of {@link Transactor} that {@link TransactionStack | uses a stack} and a {@link SharedTreeBranch | branch} to manage transactions.\n * @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.\n * This class provides conveniences for interacting with the {@link SquashingTransactionStack.activeBranch | active branch} in a way that is stable across transaction boundaries.\n * For example, see {@link SquashingTransactionStack.activeBranchEditor | activeBranchEditor} and {@link SquashingTransactionStack.activeBranchEvents | activeBranchEvents}.\n */\nexport class SquashingTransactionStack<\n\tTEditor extends ChangeFamilyEditor,\n\tTChange,\n> extends TransactionStack {\n\t#transactionBranch?: SharedTreeBranch<TEditor, TChange>;\n\n\t/**\n\t * An editor for whichever branch is currently the {@link SquashingTransactionStack.activeBranch | active branch}.\n\t * @remarks This editor can safely be held on to across transaction boundaries, as it will properly delegate to the correct branch.\n\t * In contrast, it is not safe to hold onto e.g. `activeBranch.editor` across transaction boundaries, since the active branch may change.\n\t */\n\tpublic readonly activeBranchEditor = new Proxy<TEditor>({} as unknown as TEditor, {\n\t\tget: (_, p, receiver) => {\n\t\t\treturn Reflect.get(this.activeBranch.editor, p, receiver);\n\t\t},\n\t});\n\n\t/**\n\t * Get the \"active branch\" for this transactor - either the transaction branch if a transaction is in progress, or the original branch otherwise.\n\t */\n\tpublic get activeBranch(): SharedTreeBranch<TEditor, TChange> {\n\t\treturn this.#transactionBranch ?? this.branch;\n\t}\n\n\t/**\n\t * Provides events for changes in the {@link SquashingTransactionStack.activeBranch | active branch}.\n\t * @remarks When the active branch changes, the listeners for these events will automatically be transferred to the new active branch.\n\t * In contrast, binding an event to the {@link SquashingTransactionStack.activeBranch | active branch} directly will not automatically transfer the listener when the active branch changes.\n\t */\n\tpublic get activeBranchEvents(): Listenable<SharedTreeBranchEvents<TEditor, TChange>> {\n\t\tconst off = (\n\t\t\teventName: keyof SharedTreeBranchEvents<TEditor, TChange>,\n\t\t\tlistener: SharedTreeBranchEvents<TEditor, TChange>[typeof eventName],\n\t\t): void => {\n\t\t\tthis.activeBranch.events.off(eventName, listener);\n\t\t\tconst listeners = this.#activeBranchEvents.get(eventName);\n\t\t\tif (listeners?.delete(listener) === true && listeners.size === 0) {\n\t\t\t\tthis.#activeBranchEvents.delete(eventName);\n\t\t\t}\n\t\t};\n\n\t\treturn {\n\t\t\ton: (eventName, listener) => {\n\t\t\t\tconst listeners = getOrCreate(this.#activeBranchEvents, eventName, () => new Set());\n\t\t\t\tlisteners.add(listener);\n\t\t\t\tthis.activeBranch.events.on(eventName, listener);\n\t\t\t\treturn () => off(eventName, listener);\n\t\t\t},\n\t\t\toff,\n\t\t};\n\t}\n\treadonly #activeBranchEvents = new Map<\n\t\tkeyof SharedTreeBranchEvents<TEditor, TChange>,\n\t\tSet<\n\t\t\tSharedTreeBranchEvents<TEditor, TChange>[keyof SharedTreeBranchEvents<TEditor, TChange>]\n\t\t>\n\t>();\n\n\t/**\n\t * Construct a new {@link SquashingTransactionStack}.\n\t * @param branch - The {@link SquashingTransactionStack.branch | branch} that will be forked off of when a transaction begins.\n\t * @param onPush - A function that will be called when a transaction is pushed to the {@link TransactionStack | stack}.\n\t */\n\tpublic constructor(\n\t\tpublic readonly branch: SharedTreeBranch<TEditor, TChange>,\n\t\tmintRevisionTag: () => RevisionTag,\n\t\tonPush?: () => OnPopWithViewUpdate<TChange> | void,\n\t) {\n\t\tsuper(\n\t\t\t// Invoked when an outer transaction starts\n\t\t\t(): Callbacks => {\n\t\t\t\t// Keep track of the commit that each transaction was on when it started\n\t\t\t\tconst startHead = this.activeBranch.getHead();\n\t\t\t\tconst rebaser = this.branch.changeFamily.rebaser;\n\t\t\t\tconst outerOnPop = onPush?.();\n\t\t\t\tlet transactionRevision: RevisionTag | undefined;\n\t\t\t\tconst transactionBranch = this.branch.fork(\n\t\t\t\t\tstartHead,\n\t\t\t\t\t// Lazily mint the revision tag for the transaction when it is first needed\n\t\t\t\t\t() => (transactionRevision ??= mintRevisionTag()),\n\t\t\t\t);\n\t\t\t\tthis.setTransactionBranch(transactionBranch);\n\t\t\t\ttransactionBranch.editor.enterTransaction();\n\n\t\t\t\t// Invoked when an outer transaction ends\n\t\t\t\tconst onOuterTransactionPop: OnPop = (result) => {\n\t\t\t\t\tassert(!this.isInProgress(), 0xcae /* The outer transaction should be ending */);\n\t\t\t\t\ttransactionBranch.editor.exitTransaction();\n\n\t\t\t\t\tconst sourcePath: GraphCommit<TChange>[] = [];\n\t\t\t\t\tconst targetPath: GraphCommit<TChange>[] = [];\n\t\t\t\t\tconst ancestor = findCommonAncestor(\n\t\t\t\t\t\t[startHead, sourcePath],\n\t\t\t\t\t\t[branch.getHead(), targetPath],\n\t\t\t\t\t);\n\t\t\t\t\tassert(ancestor !== undefined, 0xcce /* branches must be related */);\n\n\t\t\t\t\tconst transactionSteps: GraphCommit<TChange>[] = [];\n\t\t\t\t\tfindAncestor(\n\t\t\t\t\t\t[transactionBranch.getHead(), transactionSteps],\n\t\t\t\t\t\t(c) => c === startHead,\n\t\t\t\t\t);\n\n\t\t\t\t\tlet viewUpdate: TChange | undefined;\n\t\t\t\t\tswitch (result) {\n\t\t\t\t\t\tcase TransactionResult.Abort: {\n\t\t\t\t\t\t\t// When a transaction is aborted, roll back all the transaction's changes on the current branch.\n\t\t\t\t\t\t\t// It is important that this happens before and separately from updating the view because the `TreeCheckout` needs to\n\t\t\t\t\t\t\t// revert some internal (state to match what it was before the transaction began) before applying the view update (if any).\n\t\t\t\t\t\t\ttransactionBranch.removeAfter(startHead);\n\t\t\t\t\t\t\t// If changes were made on `branch` since the transaction began, the view will need to be updated to reflect those changes.\n\t\t\t\t\t\t\tif (targetPath.length > 0) {\n\t\t\t\t\t\t\t\tviewUpdate = diffHistories(\n\t\t\t\t\t\t\t\t\trebaser,\n\t\t\t\t\t\t\t\t\tstartHead,\n\t\t\t\t\t\t\t\t\tthis.branch.getHead(),\n\t\t\t\t\t\t\t\t\tmintRevisionTag,\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcase TransactionResult.Commit: {\n\t\t\t\t\t\t\tif (transactionSteps.length > 0) {\n\t\t\t\t\t\t\t\tassert(\n\t\t\t\t\t\t\t\t\ttransactionRevision !== undefined,\n\t\t\t\t\t\t\t\t\t0xccf /* Expected transaction revision in the presence of transaction steps */,\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\tfor (const commit of transactionSteps) {\n\t\t\t\t\t\t\t\t\tassert(\n\t\t\t\t\t\t\t\t\t\tcommit.revision === transactionRevision,\n\t\t\t\t\t\t\t\t\t\t0xcaf /* Unexpected commit in transaction */,\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t// Squash all the new commits on the transaction branch into a new commit on the original branch\n\t\t\t\t\t\t\t\tconst squash = rebaser.compose(transactionSteps);\n\n\t\t\t\t\t\t\t\tif (targetPath.length === 0) {\n\t\t\t\t\t\t\t\t\t// No changes were made on the original branch since the transaction began\n\t\t\t\t\t\t\t\t\t// The transaction commit can be applied directly\n\t\t\t\t\t\t\t\t\tthis.branch.apply(tagChange(squash, transactionRevision));\n\t\t\t\t\t\t\t\t\t// The view is already up-to-date so there's nothing more to do\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\t// Some changes were made on `branch` since the transaction began\n\t\t\t\t\t\t\t\t\tconst unrebasedHead = mintCommit(startHead, {\n\t\t\t\t\t\t\t\t\t\tchange: squash,\n\t\t\t\t\t\t\t\t\t\trevision: transactionRevision,\n\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\t// We need to rebase the transaction commit on top of the new changes\n\t\t\t\t\t\t\t\t\tconst rebased = rebaseBranch(\n\t\t\t\t\t\t\t\t\t\tmintRevisionTag,\n\t\t\t\t\t\t\t\t\t\trebaser,\n\t\t\t\t\t\t\t\t\t\tunrebasedHead,\n\t\t\t\t\t\t\t\t\t\tbranch.getHead(),\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\tassert(\n\t\t\t\t\t\t\t\t\t\trebased.newSourceHead.revision === transactionRevision,\n\t\t\t\t\t\t\t\t\t\t0xcd0 /* The transaction commit should be rebased to the tip */,\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\tthis.branch.apply(rebased.newSourceHead);\n\t\t\t\t\t\t\t\t\tviewUpdate = rebased.sourceChange;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tif (targetPath.length > 0) {\n\t\t\t\t\t\t\t\t\t// Changes were made on `branch` since the transaction began.\n\t\t\t\t\t\t\t\t\t// The view will need to be updated to reflect those changes.\n\t\t\t\t\t\t\t\t\tviewUpdate = diffHistories(\n\t\t\t\t\t\t\t\t\t\trebaser,\n\t\t\t\t\t\t\t\t\t\tstartHead,\n\t\t\t\t\t\t\t\t\t\tthis.branch.getHead(),\n\t\t\t\t\t\t\t\t\t\tmintRevisionTag,\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tdefault: {\n\t\t\t\t\t\t\tunreachableCase(result);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\ttransactionBranch.dispose();\n\t\t\t\t\tthis.setTransactionBranch(undefined);\n\t\t\t\t\touterOnPop?.(result, viewUpdate);\n\t\t\t\t};\n\t\t\t\t// Invoked when a nested transaction begins\n\t\t\t\tconst onNestedTransactionPush: OnPush = () => {\n\t\t\t\t\tconst nestedStartHead = this.activeBranch.getHead();\n\t\t\t\t\tconst nestedOuterOnPop = onPush?.();\n\t\t\t\t\ttransactionBranch.editor.enterTransaction();\n\t\t\t\t\treturn {\n\t\t\t\t\t\t// Invoked when a nested transaction ends\n\t\t\t\t\t\tonPop: (result) => {\n\t\t\t\t\t\t\ttransactionBranch.editor.exitTransaction();\n\t\t\t\t\t\t\tswitch (result) {\n\t\t\t\t\t\t\t\tcase TransactionResult.Abort: {\n\t\t\t\t\t\t\t\t\t// When a transaction is aborted, roll back all the transaction's changes on the current branch\n\t\t\t\t\t\t\t\t\ttransactionBranch.removeAfter(nestedStartHead);\n\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tcase TransactionResult.Commit: {\n\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tdefault: {\n\t\t\t\t\t\t\t\t\tunreachableCase(result);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tnestedOuterOnPop?.(result, undefined);\n\t\t\t\t\t\t},\n\t\t\t\t\t};\n\t\t\t\t};\n\t\t\t\treturn { onPop: onOuterTransactionPop, onPush: onNestedTransactionPush };\n\t\t\t},\n\t\t);\n\t}\n\n\t/** Updates the transaction branch (and therefore the active branch) and rebinds the branch events. */\n\tprivate setTransactionBranch(\n\t\ttransactionBranch: SharedTreeBranch<TEditor, TChange> | undefined,\n\t): void {\n\t\tconst oldActiveBranch = this.activeBranch;\n\t\tthis.#transactionBranch = transactionBranch;\n\t\tfor (const [eventName, listeners] of this.#activeBranchEvents) {\n\t\t\tfor (const listener of listeners) {\n\t\t\t\toldActiveBranch.events.off(eventName, listener);\n\t\t\t\tthis.activeBranch.events.on(eventName, listener);\n\t\t\t}\n\t\t}\n\t}\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"versionedSummarizer.d.ts","sourceRoot":"","sources":["../../src/shared-tree-core/versionedSummarizer.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,gDAAgD,CAAC;AAC7F,OAAO,KAAK,EACX,sCAAsC,EACtC,qBAAqB,EACrB,iBAAiB,EACjB,MAAM,8CAA8C,CAAC;AACtD,OAAO,EAAE,kBAAkB,EAAE,MAAM,wCAAwC,CAAC;AAK5E,OAAO,EAGN,KAAK,YAAY,EACjB,KAAK,oBAAoB,EACzB,KAAK,yBAAyB,EAC9B,MAAM,mBAAmB,CAAC;AAE3B;;;;GAIG;AACH,8BAAsB,mBAAmB,CAAC,QAAQ,SAAS,MAAM,CAAE,YAAW,YAAY;IAExF,+BAA+B;aACf,GAAG,EAAE,MAAM;IAC3B,0EAA0E;IAC1E,OAAO,CAAC,QA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;IACH,OAAO,EAAE,QAAQ,GAAG,SAAS,GAC3B,OAAO,CAAC,IAAI,CAAC;IAET,SAAS,CAAC,KAAK,EAAE;QACvB,SAAS,EAAE,yBAAyB,CAAC;QACrC,QAAQ,CAAC,EAAE,OAAO,CAAC;QACnB,UAAU,CAAC,EAAE,OAAO,CAAC;QACrB,gBAAgB,CAAC,EAAE,iBAAiB,CAAC;QACrC,yBAAyB,CAAC,EAAE,sCAAsC,CAAC;KACnE,GAAG,qBAAqB;IAUZ,IAAI,CAChB,QAAQ,EAAE,sBAAsB,EAChC,KAAK,EAAE,oBAAoB,GACzB,OAAO,CAAC,IAAI,CAAC;CAkBhB"}
@@ -45,7 +45,7 @@ export class VersionedSummarizer {
45
45
  async load(services, parse) {
46
46
  let version;
47
47
  if (await services.contains(summarizablesMetadataKey)) {
48
- const metadata = await readAndParseSnapshotBlob(summarizablesMetadataKey, services, (contents) => parse(contents));
48
+ const metadata = (await readAndParseSnapshotBlob(summarizablesMetadataKey, services, (contents) => parse(contents)));
49
49
  version = metadata.version;
50
50
  if (!this.supportedVersions.has(version)) {
51
51
  throw new UsageError(`Cannot read version ${version} of shared tree summary.`);