@fluidframework/tree 2.111.0 → 2.113.0-411909

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 (490) hide show
  1. package/CHANGELOG.md +145 -0
  2. package/api-report/tree.alpha.api.md +71 -7
  3. package/api-report/tree.beta.api.md +1 -1
  4. package/api-report/tree.legacy.beta.api.md +1 -1
  5. package/api-report/tree.legacy.public.api.md +1 -1
  6. package/api-report/tree.public.api.md +1 -1
  7. package/dist/componentApi.d.ts +198 -0
  8. package/dist/componentApi.d.ts.map +1 -0
  9. package/dist/componentApi.js +138 -0
  10. package/dist/componentApi.js.map +1 -0
  11. package/dist/entrypoints/alpha.d.ts +1 -1
  12. package/dist/entrypoints/alpha.d.ts.map +1 -1
  13. package/dist/entrypoints/alpha.js +5 -2
  14. package/dist/entrypoints/alpha.js.map +1 -1
  15. package/dist/feature-libraries/chunked-forest/codec/chunkDecoding.d.ts +1 -25
  16. package/dist/feature-libraries/chunked-forest/codec/chunkDecoding.d.ts.map +1 -1
  17. package/dist/feature-libraries/chunked-forest/codec/chunkDecoding.js.map +1 -1
  18. package/dist/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.d.ts +1 -2
  19. package/dist/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.d.ts.map +1 -1
  20. package/dist/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.js.map +1 -1
  21. package/dist/feature-libraries/chunked-forest/codec/codecs.d.ts +6 -18
  22. package/dist/feature-libraries/chunked-forest/codec/codecs.d.ts.map +1 -1
  23. package/dist/feature-libraries/chunked-forest/codec/codecs.js +9 -16
  24. package/dist/feature-libraries/chunked-forest/codec/codecs.js.map +1 -1
  25. package/dist/feature-libraries/default-schema/defaultFieldKinds.js +1 -1
  26. package/dist/feature-libraries/default-schema/defaultFieldKinds.js.map +1 -1
  27. package/dist/feature-libraries/index.d.ts +2 -2
  28. package/dist/feature-libraries/index.d.ts.map +1 -1
  29. package/dist/feature-libraries/index.js +3 -2
  30. package/dist/feature-libraries/index.js.map +1 -1
  31. package/dist/feature-libraries/modular-schema/fieldChangeHandler.d.ts +39 -7
  32. package/dist/feature-libraries/modular-schema/fieldChangeHandler.d.ts.map +1 -1
  33. package/dist/feature-libraries/modular-schema/fieldChangeHandler.js +22 -2
  34. package/dist/feature-libraries/modular-schema/fieldChangeHandler.js.map +1 -1
  35. package/dist/feature-libraries/modular-schema/genericFieldKind.js +1 -1
  36. package/dist/feature-libraries/modular-schema/genericFieldKind.js.map +1 -1
  37. package/dist/feature-libraries/modular-schema/index.d.ts +2 -1
  38. package/dist/feature-libraries/modular-schema/index.d.ts.map +1 -1
  39. package/dist/feature-libraries/modular-schema/index.js +4 -1
  40. package/dist/feature-libraries/modular-schema/index.js.map +1 -1
  41. package/dist/feature-libraries/modular-schema/minimizeModularChange.d.ts +25 -0
  42. package/dist/feature-libraries/modular-schema/minimizeModularChange.d.ts.map +1 -0
  43. package/dist/feature-libraries/modular-schema/minimizeModularChange.js +29 -0
  44. package/dist/feature-libraries/modular-schema/minimizeModularChange.js.map +1 -0
  45. package/dist/feature-libraries/modular-schema/modularChangeFamily.d.ts.map +1 -1
  46. package/dist/feature-libraries/modular-schema/modularChangeFamily.js +8 -1
  47. package/dist/feature-libraries/modular-schema/modularChangeFamily.js.map +1 -1
  48. package/dist/feature-libraries/optional-field/optionalField.d.ts.map +1 -1
  49. package/dist/feature-libraries/optional-field/optionalField.js +26 -3
  50. package/dist/feature-libraries/optional-field/optionalField.js.map +1 -1
  51. package/dist/feature-libraries/schemaChecker.d.ts +22 -3
  52. package/dist/feature-libraries/schemaChecker.d.ts.map +1 -1
  53. package/dist/feature-libraries/schemaChecker.js +48 -5
  54. package/dist/feature-libraries/schemaChecker.js.map +1 -1
  55. package/dist/feature-libraries/sequence-field/filterEdits.d.ts +12 -0
  56. package/dist/feature-libraries/sequence-field/filterEdits.d.ts.map +1 -0
  57. package/dist/feature-libraries/sequence-field/filterEdits.js +111 -0
  58. package/dist/feature-libraries/sequence-field/filterEdits.js.map +1 -0
  59. package/dist/feature-libraries/sequence-field/markQueue.d.ts +8 -3
  60. package/dist/feature-libraries/sequence-field/markQueue.d.ts.map +1 -1
  61. package/dist/feature-libraries/sequence-field/markQueue.js +22 -8
  62. package/dist/feature-libraries/sequence-field/markQueue.js.map +1 -1
  63. package/dist/feature-libraries/sequence-field/moveEffectTable.d.ts +1 -1
  64. package/dist/feature-libraries/sequence-field/moveEffectTable.d.ts.map +1 -1
  65. package/dist/feature-libraries/sequence-field/moveEffectTable.js +2 -6
  66. package/dist/feature-libraries/sequence-field/moveEffectTable.js.map +1 -1
  67. package/dist/feature-libraries/sequence-field/sequenceFieldChangeRebaser.d.ts +7 -6
  68. package/dist/feature-libraries/sequence-field/sequenceFieldChangeRebaser.d.ts.map +1 -1
  69. package/dist/feature-libraries/sequence-field/sequenceFieldChangeRebaser.js +2 -4
  70. package/dist/feature-libraries/sequence-field/sequenceFieldChangeRebaser.js.map +1 -1
  71. package/dist/index.d.ts +3 -2
  72. package/dist/index.d.ts.map +1 -1
  73. package/dist/index.js +6 -2
  74. package/dist/index.js.map +1 -1
  75. package/dist/packageVersion.d.ts +1 -1
  76. package/dist/packageVersion.d.ts.map +1 -1
  77. package/dist/packageVersion.js +1 -1
  78. package/dist/packageVersion.js.map +1 -1
  79. package/dist/shared-tree/independentView.d.ts +17 -4
  80. package/dist/shared-tree/independentView.d.ts.map +1 -1
  81. package/dist/shared-tree/independentView.js +11 -5
  82. package/dist/shared-tree/independentView.js.map +1 -1
  83. package/dist/shared-tree/index.d.ts +2 -1
  84. package/dist/shared-tree/index.d.ts.map +1 -1
  85. package/dist/shared-tree/index.js +3 -1
  86. package/dist/shared-tree/index.js.map +1 -1
  87. package/dist/shared-tree/schematizingTreeView.d.ts +9 -0
  88. package/dist/shared-tree/schematizingTreeView.d.ts.map +1 -1
  89. package/dist/shared-tree/schematizingTreeView.js +29 -14
  90. package/dist/shared-tree/schematizingTreeView.js.map +1 -1
  91. package/dist/shared-tree/serializedChange.d.ts +41 -0
  92. package/dist/shared-tree/serializedChange.d.ts.map +1 -0
  93. package/dist/shared-tree/serializedChange.js +87 -0
  94. package/dist/shared-tree/serializedChange.js.map +1 -0
  95. package/dist/shared-tree/sharedTree.d.ts +13 -0
  96. package/dist/shared-tree/sharedTree.d.ts.map +1 -1
  97. package/dist/shared-tree/sharedTree.js +2 -0
  98. package/dist/shared-tree/sharedTree.js.map +1 -1
  99. package/dist/shared-tree/sharedTreeChangeFamily.d.ts +7 -0
  100. package/dist/shared-tree/sharedTreeChangeFamily.d.ts.map +1 -1
  101. package/dist/shared-tree/sharedTreeChangeFamily.js +8 -1
  102. package/dist/shared-tree/sharedTreeChangeFamily.js.map +1 -1
  103. package/dist/shared-tree/transactionMinimize.d.ts +35 -0
  104. package/dist/shared-tree/transactionMinimize.d.ts.map +1 -0
  105. package/dist/shared-tree/transactionMinimize.js +65 -0
  106. package/dist/shared-tree/transactionMinimize.js.map +1 -0
  107. package/dist/shared-tree/treeCheckout.d.ts +3 -1
  108. package/dist/shared-tree/treeCheckout.d.ts.map +1 -1
  109. package/dist/shared-tree/treeCheckout.js +36 -62
  110. package/dist/shared-tree/treeCheckout.js.map +1 -1
  111. package/dist/shared-tree-core/editManager.d.ts +6 -3
  112. package/dist/shared-tree-core/editManager.d.ts.map +1 -1
  113. package/dist/shared-tree-core/editManager.js +35 -14
  114. package/dist/shared-tree-core/editManager.js.map +1 -1
  115. package/dist/shared-tree-core/editManagerFormatCommons.d.ts +1 -1
  116. package/dist/shared-tree-core/editManagerFormatCommons.js +1 -1
  117. package/dist/shared-tree-core/editManagerFormatCommons.js.map +1 -1
  118. package/dist/shared-tree-core/editManagerFormatVSharedBranches.d.ts +1 -1
  119. package/dist/shared-tree-core/messageCodecVSharedBranches.d.ts.map +1 -1
  120. package/dist/shared-tree-core/messageCodecVSharedBranches.js +8 -2
  121. package/dist/shared-tree-core/messageCodecVSharedBranches.js.map +1 -1
  122. package/dist/shared-tree-core/messageFormat.d.ts +1 -1
  123. package/dist/shared-tree-core/messageFormat.js +1 -1
  124. package/dist/shared-tree-core/messageFormat.js.map +1 -1
  125. package/dist/shared-tree-core/messageFormatVSharedBranches.d.ts +10 -1
  126. package/dist/shared-tree-core/messageFormatVSharedBranches.d.ts.map +1 -1
  127. package/dist/shared-tree-core/messageFormatVSharedBranches.js +1 -0
  128. package/dist/shared-tree-core/messageFormatVSharedBranches.js.map +1 -1
  129. package/dist/shared-tree-core/messageTypes.d.ts +1 -0
  130. package/dist/shared-tree-core/messageTypes.d.ts.map +1 -1
  131. package/dist/shared-tree-core/messageTypes.js.map +1 -1
  132. package/dist/shared-tree-core/sharedTreeCore.d.ts +9 -3
  133. package/dist/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
  134. package/dist/shared-tree-core/sharedTreeCore.js +24 -11
  135. package/dist/shared-tree-core/sharedTreeCore.js.map +1 -1
  136. package/dist/shared-tree-core/transaction.d.ts.map +1 -1
  137. package/dist/shared-tree-core/transaction.js +16 -2
  138. package/dist/shared-tree-core/transaction.js.map +1 -1
  139. package/dist/simple-tree/api/configuration.d.ts +32 -2
  140. package/dist/simple-tree/api/configuration.d.ts.map +1 -1
  141. package/dist/simple-tree/api/configuration.js +3 -1
  142. package/dist/simple-tree/api/configuration.js.map +1 -1
  143. package/dist/simple-tree/api/index.d.ts +2 -2
  144. package/dist/simple-tree/api/index.d.ts.map +1 -1
  145. package/dist/simple-tree/api/index.js +2 -2
  146. package/dist/simple-tree/api/index.js.map +1 -1
  147. package/dist/simple-tree/api/schemaCompatibilityTester.d.ts +13 -25
  148. package/dist/simple-tree/api/schemaCompatibilityTester.d.ts.map +1 -1
  149. package/dist/simple-tree/api/schemaCompatibilityTester.js +34 -45
  150. package/dist/simple-tree/api/schemaCompatibilityTester.js.map +1 -1
  151. package/dist/simple-tree/api/schemaFactoryAlpha.d.ts +56 -15
  152. package/dist/simple-tree/api/schemaFactoryAlpha.d.ts.map +1 -1
  153. package/dist/simple-tree/api/schemaFactoryAlpha.js.map +1 -1
  154. package/dist/simple-tree/api/schemaFactoryBeta.d.ts +0 -3
  155. package/dist/simple-tree/api/schemaFactoryBeta.d.ts.map +1 -1
  156. package/dist/simple-tree/api/schemaFactoryBeta.js.map +1 -1
  157. package/dist/simple-tree/api/snapshotCompatibilityChecker.d.ts.map +1 -1
  158. package/dist/simple-tree/api/snapshotCompatibilityChecker.js +1 -2
  159. package/dist/simple-tree/api/snapshotCompatibilityChecker.js.map +1 -1
  160. package/dist/simple-tree/api/storedSchema.d.ts.map +1 -1
  161. package/dist/simple-tree/api/storedSchema.js +1 -2
  162. package/dist/simple-tree/api/storedSchema.js.map +1 -1
  163. package/dist/simple-tree/api/tree.d.ts +80 -3
  164. package/dist/simple-tree/api/tree.d.ts.map +1 -1
  165. package/dist/simple-tree/api/tree.js.map +1 -1
  166. package/dist/simple-tree/api/typesUnsafe.d.ts +2 -2
  167. package/dist/simple-tree/api/typesUnsafe.d.ts.map +1 -1
  168. package/dist/simple-tree/api/typesUnsafe.js.map +1 -1
  169. package/dist/simple-tree/core/index.d.ts +1 -1
  170. package/dist/simple-tree/core/index.d.ts.map +1 -1
  171. package/dist/simple-tree/core/index.js +2 -1
  172. package/dist/simple-tree/core/index.js.map +1 -1
  173. package/dist/simple-tree/core/toStored.d.ts +72 -6
  174. package/dist/simple-tree/core/toStored.d.ts.map +1 -1
  175. package/dist/simple-tree/core/toStored.js +25 -1
  176. package/dist/simple-tree/core/toStored.js.map +1 -1
  177. package/dist/simple-tree/index.d.ts +3 -3
  178. package/dist/simple-tree/index.d.ts.map +1 -1
  179. package/dist/simple-tree/index.js +5 -6
  180. package/dist/simple-tree/index.js.map +1 -1
  181. package/dist/simple-tree/node-kinds/array/arrayNode.d.ts +83 -4
  182. package/dist/simple-tree/node-kinds/array/arrayNode.d.ts.map +1 -1
  183. package/dist/simple-tree/node-kinds/array/arrayNode.js +39 -0
  184. package/dist/simple-tree/node-kinds/array/arrayNode.js.map +1 -1
  185. package/dist/simple-tree/prepareForInsertion.d.ts.map +1 -1
  186. package/dist/simple-tree/prepareForInsertion.js +9 -0
  187. package/dist/simple-tree/prepareForInsertion.js.map +1 -1
  188. package/dist/simple-tree/simpleSchemaFormatV1.js +1 -1
  189. package/dist/simple-tree/simpleSchemaFormatV1.js.map +1 -1
  190. package/dist/simple-tree/toStoredSchema.d.ts +11 -27
  191. package/dist/simple-tree/toStoredSchema.d.ts.map +1 -1
  192. package/dist/simple-tree/toStoredSchema.js +25 -33
  193. package/dist/simple-tree/toStoredSchema.js.map +1 -1
  194. package/dist/treeFactory.js +1 -1
  195. package/dist/treeFactory.js.map +1 -1
  196. package/dist/util/breakable.d.ts +16 -1
  197. package/dist/util/breakable.d.ts.map +1 -1
  198. package/dist/util/breakable.js +9 -1
  199. package/dist/util/breakable.js.map +1 -1
  200. package/dist/util/compressedIds.d.ts +69 -2
  201. package/dist/util/compressedIds.d.ts.map +1 -1
  202. package/dist/util/compressedIds.js +32 -1
  203. package/dist/util/compressedIds.js.map +1 -1
  204. package/dist/util/index.d.ts +2 -2
  205. package/dist/util/index.d.ts.map +1 -1
  206. package/dist/util/index.js +2 -2
  207. package/dist/util/index.js.map +1 -1
  208. package/dist/util/nestedMap.d.ts.map +1 -1
  209. package/dist/util/nestedMap.js +16 -3
  210. package/dist/util/nestedMap.js.map +1 -1
  211. package/dist/util/nestedSet.d.ts +1 -1
  212. package/dist/util/nestedSet.d.ts.map +1 -1
  213. package/dist/util/nestedSet.js.map +1 -1
  214. package/dist/util/utils.d.ts +0 -6
  215. package/dist/util/utils.d.ts.map +1 -1
  216. package/dist/util/utils.js +1 -15
  217. package/dist/util/utils.js.map +1 -1
  218. package/docs/main/runtime-schema-upgrade.md +208 -0
  219. package/lib/componentApi.d.ts +198 -0
  220. package/lib/componentApi.d.ts.map +1 -0
  221. package/lib/componentApi.js +135 -0
  222. package/lib/componentApi.js.map +1 -0
  223. package/lib/entrypoints/alpha.d.ts +1 -1
  224. package/lib/entrypoints/alpha.d.ts.map +1 -1
  225. package/lib/entrypoints/alpha.js +1 -1
  226. package/lib/entrypoints/alpha.js.map +1 -1
  227. package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.d.ts +1 -25
  228. package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.d.ts.map +1 -1
  229. package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.js +1 -1
  230. package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.js.map +1 -1
  231. package/lib/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.d.ts +1 -2
  232. package/lib/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.d.ts.map +1 -1
  233. package/lib/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.js.map +1 -1
  234. package/lib/feature-libraries/chunked-forest/codec/codecs.d.ts +6 -18
  235. package/lib/feature-libraries/chunked-forest/codec/codecs.d.ts.map +1 -1
  236. package/lib/feature-libraries/chunked-forest/codec/codecs.js +10 -17
  237. package/lib/feature-libraries/chunked-forest/codec/codecs.js.map +1 -1
  238. package/lib/feature-libraries/default-schema/defaultFieldKinds.js +1 -1
  239. package/lib/feature-libraries/default-schema/defaultFieldKinds.js.map +1 -1
  240. package/lib/feature-libraries/index.d.ts +2 -2
  241. package/lib/feature-libraries/index.d.ts.map +1 -1
  242. package/lib/feature-libraries/index.js +1 -1
  243. package/lib/feature-libraries/index.js.map +1 -1
  244. package/lib/feature-libraries/modular-schema/fieldChangeHandler.d.ts +39 -7
  245. package/lib/feature-libraries/modular-schema/fieldChangeHandler.d.ts.map +1 -1
  246. package/lib/feature-libraries/modular-schema/fieldChangeHandler.js +21 -1
  247. package/lib/feature-libraries/modular-schema/fieldChangeHandler.js.map +1 -1
  248. package/lib/feature-libraries/modular-schema/genericFieldKind.js +1 -1
  249. package/lib/feature-libraries/modular-schema/genericFieldKind.js.map +1 -1
  250. package/lib/feature-libraries/modular-schema/index.d.ts +2 -1
  251. package/lib/feature-libraries/modular-schema/index.d.ts.map +1 -1
  252. package/lib/feature-libraries/modular-schema/index.js +2 -1
  253. package/lib/feature-libraries/modular-schema/index.js.map +1 -1
  254. package/lib/feature-libraries/modular-schema/minimizeModularChange.d.ts +25 -0
  255. package/lib/feature-libraries/modular-schema/minimizeModularChange.d.ts.map +1 -0
  256. package/lib/feature-libraries/modular-schema/minimizeModularChange.js +25 -0
  257. package/lib/feature-libraries/modular-schema/minimizeModularChange.js.map +1 -0
  258. package/lib/feature-libraries/modular-schema/modularChangeFamily.d.ts.map +1 -1
  259. package/lib/feature-libraries/modular-schema/modularChangeFamily.js +9 -2
  260. package/lib/feature-libraries/modular-schema/modularChangeFamily.js.map +1 -1
  261. package/lib/feature-libraries/optional-field/optionalField.d.ts.map +1 -1
  262. package/lib/feature-libraries/optional-field/optionalField.js +27 -4
  263. package/lib/feature-libraries/optional-field/optionalField.js.map +1 -1
  264. package/lib/feature-libraries/schemaChecker.d.ts +22 -3
  265. package/lib/feature-libraries/schemaChecker.d.ts.map +1 -1
  266. package/lib/feature-libraries/schemaChecker.js +48 -5
  267. package/lib/feature-libraries/schemaChecker.js.map +1 -1
  268. package/lib/feature-libraries/sequence-field/filterEdits.d.ts +12 -0
  269. package/lib/feature-libraries/sequence-field/filterEdits.d.ts.map +1 -0
  270. package/lib/feature-libraries/sequence-field/filterEdits.js +107 -0
  271. package/lib/feature-libraries/sequence-field/filterEdits.js.map +1 -0
  272. package/lib/feature-libraries/sequence-field/markQueue.d.ts +8 -3
  273. package/lib/feature-libraries/sequence-field/markQueue.d.ts.map +1 -1
  274. package/lib/feature-libraries/sequence-field/markQueue.js +22 -9
  275. package/lib/feature-libraries/sequence-field/markQueue.js.map +1 -1
  276. package/lib/feature-libraries/sequence-field/moveEffectTable.d.ts +1 -1
  277. package/lib/feature-libraries/sequence-field/moveEffectTable.d.ts.map +1 -1
  278. package/lib/feature-libraries/sequence-field/moveEffectTable.js +2 -6
  279. package/lib/feature-libraries/sequence-field/moveEffectTable.js.map +1 -1
  280. package/lib/feature-libraries/sequence-field/sequenceFieldChangeRebaser.d.ts +7 -6
  281. package/lib/feature-libraries/sequence-field/sequenceFieldChangeRebaser.d.ts.map +1 -1
  282. package/lib/feature-libraries/sequence-field/sequenceFieldChangeRebaser.js +2 -4
  283. package/lib/feature-libraries/sequence-field/sequenceFieldChangeRebaser.js.map +1 -1
  284. package/lib/index.d.ts +3 -2
  285. package/lib/index.d.ts.map +1 -1
  286. package/lib/index.js +3 -2
  287. package/lib/index.js.map +1 -1
  288. package/lib/packageVersion.d.ts +1 -1
  289. package/lib/packageVersion.d.ts.map +1 -1
  290. package/lib/packageVersion.js +1 -1
  291. package/lib/packageVersion.js.map +1 -1
  292. package/lib/shared-tree/independentView.d.ts +17 -4
  293. package/lib/shared-tree/independentView.d.ts.map +1 -1
  294. package/lib/shared-tree/independentView.js +9 -3
  295. package/lib/shared-tree/independentView.js.map +1 -1
  296. package/lib/shared-tree/index.d.ts +2 -1
  297. package/lib/shared-tree/index.d.ts.map +1 -1
  298. package/lib/shared-tree/index.js +1 -0
  299. package/lib/shared-tree/index.js.map +1 -1
  300. package/lib/shared-tree/schematizingTreeView.d.ts +9 -0
  301. package/lib/shared-tree/schematizingTreeView.d.ts.map +1 -1
  302. package/lib/shared-tree/schematizingTreeView.js +31 -16
  303. package/lib/shared-tree/schematizingTreeView.js.map +1 -1
  304. package/lib/shared-tree/serializedChange.d.ts +41 -0
  305. package/lib/shared-tree/serializedChange.d.ts.map +1 -0
  306. package/lib/shared-tree/serializedChange.js +84 -0
  307. package/lib/shared-tree/serializedChange.js.map +1 -0
  308. package/lib/shared-tree/sharedTree.d.ts +13 -0
  309. package/lib/shared-tree/sharedTree.d.ts.map +1 -1
  310. package/lib/shared-tree/sharedTree.js +2 -0
  311. package/lib/shared-tree/sharedTree.js.map +1 -1
  312. package/lib/shared-tree/sharedTreeChangeFamily.d.ts +7 -0
  313. package/lib/shared-tree/sharedTreeChangeFamily.d.ts.map +1 -1
  314. package/lib/shared-tree/sharedTreeChangeFamily.js +7 -1
  315. package/lib/shared-tree/sharedTreeChangeFamily.js.map +1 -1
  316. package/lib/shared-tree/transactionMinimize.d.ts +35 -0
  317. package/lib/shared-tree/transactionMinimize.d.ts.map +1 -0
  318. package/lib/shared-tree/transactionMinimize.js +62 -0
  319. package/lib/shared-tree/transactionMinimize.js.map +1 -0
  320. package/lib/shared-tree/treeCheckout.d.ts +3 -1
  321. package/lib/shared-tree/treeCheckout.d.ts.map +1 -1
  322. package/lib/shared-tree/treeCheckout.js +18 -44
  323. package/lib/shared-tree/treeCheckout.js.map +1 -1
  324. package/lib/shared-tree-core/editManager.d.ts +6 -3
  325. package/lib/shared-tree-core/editManager.d.ts.map +1 -1
  326. package/lib/shared-tree-core/editManager.js +36 -15
  327. package/lib/shared-tree-core/editManager.js.map +1 -1
  328. package/lib/shared-tree-core/editManagerFormatCommons.d.ts +1 -1
  329. package/lib/shared-tree-core/editManagerFormatCommons.js +1 -1
  330. package/lib/shared-tree-core/editManagerFormatCommons.js.map +1 -1
  331. package/lib/shared-tree-core/editManagerFormatVSharedBranches.d.ts +1 -1
  332. package/lib/shared-tree-core/messageCodecVSharedBranches.d.ts.map +1 -1
  333. package/lib/shared-tree-core/messageCodecVSharedBranches.js +8 -2
  334. package/lib/shared-tree-core/messageCodecVSharedBranches.js.map +1 -1
  335. package/lib/shared-tree-core/messageFormat.d.ts +1 -1
  336. package/lib/shared-tree-core/messageFormat.js +1 -1
  337. package/lib/shared-tree-core/messageFormat.js.map +1 -1
  338. package/lib/shared-tree-core/messageFormatVSharedBranches.d.ts +10 -1
  339. package/lib/shared-tree-core/messageFormatVSharedBranches.d.ts.map +1 -1
  340. package/lib/shared-tree-core/messageFormatVSharedBranches.js +1 -0
  341. package/lib/shared-tree-core/messageFormatVSharedBranches.js.map +1 -1
  342. package/lib/shared-tree-core/messageTypes.d.ts +1 -0
  343. package/lib/shared-tree-core/messageTypes.d.ts.map +1 -1
  344. package/lib/shared-tree-core/messageTypes.js.map +1 -1
  345. package/lib/shared-tree-core/sharedTreeCore.d.ts +9 -3
  346. package/lib/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
  347. package/lib/shared-tree-core/sharedTreeCore.js +25 -12
  348. package/lib/shared-tree-core/sharedTreeCore.js.map +1 -1
  349. package/lib/shared-tree-core/transaction.d.ts.map +1 -1
  350. package/lib/shared-tree-core/transaction.js +16 -2
  351. package/lib/shared-tree-core/transaction.js.map +1 -1
  352. package/lib/simple-tree/api/configuration.d.ts +32 -2
  353. package/lib/simple-tree/api/configuration.d.ts.map +1 -1
  354. package/lib/simple-tree/api/configuration.js +4 -2
  355. package/lib/simple-tree/api/configuration.js.map +1 -1
  356. package/lib/simple-tree/api/index.d.ts +2 -2
  357. package/lib/simple-tree/api/index.d.ts.map +1 -1
  358. package/lib/simple-tree/api/index.js +1 -1
  359. package/lib/simple-tree/api/index.js.map +1 -1
  360. package/lib/simple-tree/api/schemaCompatibilityTester.d.ts +13 -25
  361. package/lib/simple-tree/api/schemaCompatibilityTester.d.ts.map +1 -1
  362. package/lib/simple-tree/api/schemaCompatibilityTester.js +32 -43
  363. package/lib/simple-tree/api/schemaCompatibilityTester.js.map +1 -1
  364. package/lib/simple-tree/api/schemaFactoryAlpha.d.ts +56 -15
  365. package/lib/simple-tree/api/schemaFactoryAlpha.d.ts.map +1 -1
  366. package/lib/simple-tree/api/schemaFactoryAlpha.js.map +1 -1
  367. package/lib/simple-tree/api/schemaFactoryBeta.d.ts +0 -3
  368. package/lib/simple-tree/api/schemaFactoryBeta.d.ts.map +1 -1
  369. package/lib/simple-tree/api/schemaFactoryBeta.js.map +1 -1
  370. package/lib/simple-tree/api/snapshotCompatibilityChecker.d.ts.map +1 -1
  371. package/lib/simple-tree/api/snapshotCompatibilityChecker.js +2 -3
  372. package/lib/simple-tree/api/snapshotCompatibilityChecker.js.map +1 -1
  373. package/lib/simple-tree/api/storedSchema.d.ts.map +1 -1
  374. package/lib/simple-tree/api/storedSchema.js +2 -3
  375. package/lib/simple-tree/api/storedSchema.js.map +1 -1
  376. package/lib/simple-tree/api/tree.d.ts +80 -3
  377. package/lib/simple-tree/api/tree.d.ts.map +1 -1
  378. package/lib/simple-tree/api/tree.js.map +1 -1
  379. package/lib/simple-tree/api/typesUnsafe.d.ts +2 -2
  380. package/lib/simple-tree/api/typesUnsafe.d.ts.map +1 -1
  381. package/lib/simple-tree/api/typesUnsafe.js.map +1 -1
  382. package/lib/simple-tree/core/index.d.ts +1 -1
  383. package/lib/simple-tree/core/index.d.ts.map +1 -1
  384. package/lib/simple-tree/core/index.js +1 -1
  385. package/lib/simple-tree/core/index.js.map +1 -1
  386. package/lib/simple-tree/core/toStored.d.ts +72 -6
  387. package/lib/simple-tree/core/toStored.d.ts.map +1 -1
  388. package/lib/simple-tree/core/toStored.js +24 -0
  389. package/lib/simple-tree/core/toStored.js.map +1 -1
  390. package/lib/simple-tree/index.d.ts +3 -3
  391. package/lib/simple-tree/index.d.ts.map +1 -1
  392. package/lib/simple-tree/index.js +3 -3
  393. package/lib/simple-tree/index.js.map +1 -1
  394. package/lib/simple-tree/node-kinds/array/arrayNode.d.ts +83 -4
  395. package/lib/simple-tree/node-kinds/array/arrayNode.d.ts.map +1 -1
  396. package/lib/simple-tree/node-kinds/array/arrayNode.js +39 -0
  397. package/lib/simple-tree/node-kinds/array/arrayNode.js.map +1 -1
  398. package/lib/simple-tree/prepareForInsertion.d.ts.map +1 -1
  399. package/lib/simple-tree/prepareForInsertion.js +9 -0
  400. package/lib/simple-tree/prepareForInsertion.js.map +1 -1
  401. package/lib/simple-tree/simpleSchemaFormatV1.js +1 -1
  402. package/lib/simple-tree/simpleSchemaFormatV1.js.map +1 -1
  403. package/lib/simple-tree/toStoredSchema.d.ts +11 -27
  404. package/lib/simple-tree/toStoredSchema.d.ts.map +1 -1
  405. package/lib/simple-tree/toStoredSchema.js +24 -33
  406. package/lib/simple-tree/toStoredSchema.js.map +1 -1
  407. package/lib/treeFactory.js +1 -1
  408. package/lib/treeFactory.js.map +1 -1
  409. package/lib/util/breakable.d.ts +16 -1
  410. package/lib/util/breakable.d.ts.map +1 -1
  411. package/lib/util/breakable.js +9 -1
  412. package/lib/util/breakable.js.map +1 -1
  413. package/lib/util/compressedIds.d.ts +69 -2
  414. package/lib/util/compressedIds.d.ts.map +1 -1
  415. package/lib/util/compressedIds.js +30 -0
  416. package/lib/util/compressedIds.js.map +1 -1
  417. package/lib/util/index.d.ts +2 -2
  418. package/lib/util/index.d.ts.map +1 -1
  419. package/lib/util/index.js +2 -2
  420. package/lib/util/index.js.map +1 -1
  421. package/lib/util/nestedMap.d.ts.map +1 -1
  422. package/lib/util/nestedMap.js +17 -4
  423. package/lib/util/nestedMap.js.map +1 -1
  424. package/lib/util/nestedSet.d.ts +1 -1
  425. package/lib/util/nestedSet.d.ts.map +1 -1
  426. package/lib/util/nestedSet.js.map +1 -1
  427. package/lib/util/utils.d.ts +0 -6
  428. package/lib/util/utils.d.ts.map +1 -1
  429. package/lib/util/utils.js +0 -13
  430. package/lib/util/utils.js.map +1 -1
  431. package/package.json +22 -22
  432. package/src/componentApi.ts +354 -0
  433. package/src/entrypoints/alpha.ts +6 -0
  434. package/src/feature-libraries/chunked-forest/codec/chunkDecoding.ts +6 -27
  435. package/src/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.ts +1 -2
  436. package/src/feature-libraries/chunked-forest/codec/codecs.ts +17 -44
  437. package/src/feature-libraries/default-schema/defaultFieldKinds.ts +1 -1
  438. package/src/feature-libraries/index.ts +2 -0
  439. package/src/feature-libraries/modular-schema/fieldChangeHandler.ts +51 -7
  440. package/src/feature-libraries/modular-schema/genericFieldKind.ts +1 -1
  441. package/src/feature-libraries/modular-schema/index.ts +5 -2
  442. package/src/feature-libraries/modular-schema/minimizeModularChange.ts +33 -0
  443. package/src/feature-libraries/modular-schema/modularChangeFamily.ts +16 -1
  444. package/src/feature-libraries/optional-field/optionalField.ts +43 -3
  445. package/src/feature-libraries/schemaChecker.ts +86 -9
  446. package/src/feature-libraries/sequence-field/filterEdits.ts +143 -0
  447. package/src/feature-libraries/sequence-field/markQueue.ts +28 -11
  448. package/src/feature-libraries/sequence-field/moveEffectTable.ts +2 -7
  449. package/src/feature-libraries/sequence-field/sequenceFieldChangeRebaser.ts +3 -5
  450. package/src/index.ts +6 -0
  451. package/src/packageVersion.ts +1 -1
  452. package/src/shared-tree/independentView.ts +35 -5
  453. package/src/shared-tree/index.ts +3 -0
  454. package/src/shared-tree/schematizingTreeView.ts +52 -20
  455. package/src/shared-tree/serializedChange.ts +127 -0
  456. package/src/shared-tree/sharedTree.ts +16 -0
  457. package/src/shared-tree/sharedTreeChangeFamily.ts +7 -1
  458. package/src/shared-tree/transactionMinimize.ts +74 -0
  459. package/src/shared-tree/treeCheckout.ts +42 -57
  460. package/src/shared-tree-core/editManager.ts +42 -6
  461. package/src/shared-tree-core/editManagerFormatCommons.ts +1 -1
  462. package/src/shared-tree-core/messageCodecVSharedBranches.ts +8 -1
  463. package/src/shared-tree-core/messageFormat.ts +1 -1
  464. package/src/shared-tree-core/messageFormatVSharedBranches.ts +10 -0
  465. package/src/shared-tree-core/messageTypes.ts +1 -0
  466. package/src/shared-tree-core/sharedTreeCore.ts +33 -10
  467. package/src/shared-tree-core/transaction.ts +19 -2
  468. package/src/simple-tree/api/configuration.ts +40 -2
  469. package/src/simple-tree/api/index.ts +2 -1
  470. package/src/simple-tree/api/schemaCompatibilityTester.ts +41 -49
  471. package/src/simple-tree/api/schemaFactoryAlpha.ts +56 -15
  472. package/src/simple-tree/api/schemaFactoryBeta.ts +0 -3
  473. package/src/simple-tree/api/snapshotCompatibilityChecker.ts +2 -3
  474. package/src/simple-tree/api/storedSchema.ts +2 -3
  475. package/src/simple-tree/api/tree.ts +82 -3
  476. package/src/simple-tree/api/typesUnsafe.ts +2 -1
  477. package/src/simple-tree/core/index.ts +2 -1
  478. package/src/simple-tree/core/toStored.ts +95 -8
  479. package/src/simple-tree/index.ts +4 -3
  480. package/src/simple-tree/node-kinds/array/arrayNode.ts +168 -4
  481. package/src/simple-tree/prepareForInsertion.ts +12 -0
  482. package/src/simple-tree/simpleSchemaFormatV1.ts +1 -1
  483. package/src/simple-tree/toStoredSchema.ts +44 -39
  484. package/src/treeFactory.ts +1 -1
  485. package/src/util/breakable.ts +8 -1
  486. package/src/util/compressedIds.ts +90 -2
  487. package/src/util/index.ts +3 -1
  488. package/src/util/nestedMap.ts +21 -4
  489. package/src/util/nestedSet.ts +1 -1
  490. package/src/util/utils.ts +0 -18
@@ -464,6 +464,17 @@ export class SquashingTransactionStack<
464
464
  const change =
465
465
  postProcessor === undefined ? squash : postProcessor.processChange(squash);
466
466
 
467
+ if (change !== squash) {
468
+ // The post-processor produced a change that differs from the
469
+ // one that was applied to the view as the transaction's edits
470
+ // were made. Roll back the transaction's changes on the transaction
471
+ // branch (which rolls back the view) and apply the post-processed
472
+ // change in their place so that the view fully reflects the modified
473
+ // `change`.
474
+ transactionBranch.removeAfter(startHead);
475
+ transactionBranch.apply(tagChange(change, transactionRevision));
476
+ }
477
+
467
478
  if (targetPath.length === 0) {
468
479
  // No changes were made on the original branch since the transaction began
469
480
  // The transaction commit can be applied directly
@@ -548,8 +559,14 @@ export class SquashingTransactionStack<
548
559
  );
549
560
  const squash = rebaser.compose(nestedSteps);
550
561
  const processedSquash = nestedPostProcessor.processChange(squash);
551
- transactionBranch.removeAfter(nestedStartHead);
552
- transactionBranch.apply(tagChange(processedSquash, transactionRevision));
562
+ // Roll back the transaction branch to the nested start head and apply the
563
+ // processed change if it differs from the original change.
564
+ if (processedSquash !== squash) {
565
+ transactionBranch.removeAfter(nestedStartHead);
566
+ transactionBranch.apply(
567
+ tagChange(processedSquash, transactionRevision),
568
+ );
569
+ }
553
570
  }
554
571
  }
555
572
  break;
@@ -11,6 +11,7 @@ import type { MakeNominal } from "../../util/index.js";
11
11
  import {
12
12
  type AllowedTypesFullEvaluated,
13
13
  NodeKind,
14
+ StagedSchemaUpgradePolicy,
14
15
  type TreeNodeSchema,
15
16
  } from "../core/index.js";
16
17
  import { type FieldSchemaAlpha, type ImplicitFieldSchema, FieldKind } from "../fieldSchema.js";
@@ -155,6 +156,35 @@ export interface ITreeViewConfiguration<
155
156
  readonly schema: TSchema;
156
157
  }
157
158
 
159
+ /**
160
+ * Property-bag configuration for {@link TreeViewConfigurationAlpha} construction.
161
+ * @alpha
162
+ */
163
+ export interface ITreeViewConfigurationAlpha<
164
+ TSchema extends ImplicitFieldSchema = ImplicitFieldSchema,
165
+ > extends ITreeViewConfiguration<TSchema> {
166
+ /**
167
+ * Policy for generating stored schema from the view schema.
168
+ *
169
+ * @remarks
170
+ * If omitted or `undefined`, defaults to {@link StagedSchemaUpgradePolicyFactory.restrictive}
171
+ * which does not enable any staged schema upgrades.
172
+ *
173
+ * If provided, this policy is used when generating stored schema to include in documents via
174
+ * `initialize` / `upgradeSchema` as well as in {@link snapshotSchemaCompatibility} to validate
175
+ * the compatibility of such documents.
176
+ *
177
+ * @example Enabling specific staged upgrades
178
+ * ```typescript
179
+ * const config = new TreeViewConfigurationAlpha({
180
+ * schema: MySchema,
181
+ * stagedUpgradePolicy: StagedSchemaUpgradePolicy.enabledStagedUpgrades(myUpgrade),
182
+ * });
183
+ * ```
184
+ */
185
+ readonly stagedUpgradePolicy?: StagedSchemaUpgradePolicy;
186
+ }
187
+
158
188
  /**
159
189
  * Configuration for {@link ViewableTree.viewWith}.
160
190
  * @sealed @public
@@ -252,14 +282,22 @@ export class TreeViewConfigurationAlpha<
252
282
  SimpleNodeSchema<SchemaType.View> & TreeNodeSchema
253
283
  >;
254
284
 
255
- public constructor(props: ITreeViewConfiguration<TSchema>) {
285
+ /**
286
+ * {@inheritDoc ITreeViewConfigurationAlpha.stagedUpgradePolicy}
287
+ */
288
+ public readonly stagedUpgradePolicy: StagedSchemaUpgradePolicy;
289
+
290
+ public constructor(props: ITreeViewConfigurationAlpha<TSchema>) {
256
291
  super(props);
257
292
  const treeSchema = createTreeSchema(this.schema);
258
293
  this.root = treeSchema.root;
259
294
  this.definitions = treeSchema.definitions;
260
295
 
296
+ this.stagedUpgradePolicy =
297
+ props.stagedUpgradePolicy ?? StagedSchemaUpgradePolicy.restrictive;
298
+
261
299
  // Eagerly perform these conversions to surface errors sooner.
262
- toInitialSchema(this.root);
300
+ toInitialSchema(this.root, this.stagedUpgradePolicy);
263
301
  transformSimpleSchema(treeSchema, toUnhydratedSchema);
264
302
  }
265
303
  }
@@ -6,6 +6,7 @@
6
6
  export type {
7
7
  ITreeViewConfiguration,
8
8
  ITreeConfigurationOptions,
9
+ ITreeViewConfigurationAlpha,
9
10
  } from "./configuration.js";
10
11
  export {
11
12
  TreeViewConfiguration,
@@ -100,7 +101,7 @@ export {
100
101
  export type { TreeSchemaEncodingOptions } from "./getJsonSchema.js";
101
102
  export { getJsonSchema } from "./getJsonSchema.js";
102
103
  export { getSimpleSchema } from "./getSimpleSchema.js";
103
- export { SchemaCompatibilityTester } from "./schemaCompatibilityTester.js";
104
+ export { checkSchemaCompatibility } from "./schemaCompatibilityTester.js";
104
105
  export type {
105
106
  Unenforced,
106
107
  FieldSchemaAlphaUnsafe,
@@ -4,6 +4,7 @@
4
4
  */
5
5
 
6
6
  import type { TreeStoredSchema } from "../../core/index.js";
7
+ import type { SchemaUpgrade, StagedSchemaUpgradePolicy } from "../core/index.js";
7
8
  import { allowsRepoSuperset, defaultSchemaPolicy } from "../../feature-libraries/index.js";
8
9
  import { toUpgradeSchema } from "../toStoredSchema.js";
9
10
  import type { TreeSchema } from "../treeSchema.js";
@@ -12,58 +13,49 @@ import { getDiscrepanciesInAllowedContent } from "./discrepancies.js";
12
13
  import type { SchemaCompatibilityStatus } from "./tree.js";
13
14
 
14
15
  /**
15
- * A collection of View information for schema
16
- * @remarks
17
- * This contains everything needed to determine compatibility with a given stored schema.
16
+ * Determines the compatibility of a stored document (based on its stored schema) with a viewer (based on its view schema).
17
+ *
18
+ * Adapters can be provided to handle differences between the two schema.
19
+ * Adapters should only use to types in the `view` SchemaRepository.
20
+ *
21
+ * TODO: this API violates the parse don't validate design philosophy.
22
+ * It should be wrapped with (or replaced by) a parse style API.
23
+ *
24
+ * @param viewSchema - Schema for the view
25
+ * @param stored - The stored schema to check compatibility against
26
+ * @param stagedSchemaUpgrades - Staged schema upgrades enabled for this view, or explicit stored-schema generation options
18
27
  */
19
- export class SchemaCompatibilityTester {
20
- public constructor(
21
- /**
22
- * Schema for the view
23
- */
24
- public readonly viewSchema: TreeSchema,
25
- ) {}
26
-
27
- /**
28
- * Determines the compatibility of a stored document
29
- * (based on its stored schema) with a viewer (based on its view schema).
30
- *
31
- * Adapters can be provided to handle differences between the two schema.
32
- * Adapters should only use to types in the `view` SchemaRepository.
33
- *
34
- * TODO: this API violates the parse don't validate design philosophy.
35
- * It should be wrapped with (or replaced by) a parse style API.
36
- */
37
- public checkCompatibility(
38
- stored: TreeStoredSchema,
39
- ): Omit<SchemaCompatibilityStatus, "canInitialize"> {
40
- // The public API surface assumes defaultSchemaPolicy
41
- const policy = defaultSchemaPolicy;
42
-
43
- // View schema allows a subset of documents that stored schema does, and the discrepancies are allowed by policy
44
- // determined by the view schema (i.e. objects with extra optional fields in the stored schema have opted into allowing this.
45
- // In the future, this would also include things like:
46
- // - fields with more allowed types in the stored schema than in the view schema have out-of-schema "unknown content" adapters
47
- let canView = true;
48
-
49
- for (const _discrepancy of getDiscrepanciesInAllowedContent(this.viewSchema, stored)) {
50
- canView = false;
51
- break;
52
- }
28
+ export function checkSchemaCompatibility(
29
+ viewSchema: TreeSchema,
30
+ stored: TreeStoredSchema,
31
+ stagedSchemaUpgrades?: Iterable<SchemaUpgrade> | StagedSchemaUpgradePolicy,
32
+ ): Omit<SchemaCompatibilityStatus, "canInitialize"> {
33
+ // The public API surface assumes defaultSchemaPolicy
34
+ const policy = defaultSchemaPolicy;
35
+
36
+ // View schema allows a subset of documents that stored schema does, and the discrepancies are allowed by policy
37
+ // determined by the view schema (i.e. objects with extra optional fields in the stored schema have opted into allowing this.
38
+ // In the future, this would also include things like:
39
+ // - fields with more allowed types in the stored schema than in the view schema have out-of-schema "unknown content" adapters
40
+ let canView = true;
41
+
42
+ for (const _discrepancy of getDiscrepanciesInAllowedContent(viewSchema, stored)) {
43
+ canView = false;
44
+ break;
45
+ }
53
46
 
54
- const wouldUpgradeTo = toUpgradeSchema(this.viewSchema.root);
47
+ const wouldUpgradeTo = toUpgradeSchema(viewSchema.root, stagedSchemaUpgrades);
55
48
 
56
- const canUpgrade = allowsRepoSuperset(policy, stored, wouldUpgradeTo);
49
+ const canUpgrade = allowsRepoSuperset(policy, stored, wouldUpgradeTo);
57
50
 
58
- // If true, then upgrading has no effect on what can be stored in the document.
59
- // TODO: This should likely be changed to indicate up a schema upgrade would be a no-op, including stored schema metadata.
60
- const isEquivalent =
61
- canView && canUpgrade && allowsRepoSuperset(policy, wouldUpgradeTo, stored);
51
+ // If true, then upgrading has no effect on what can be stored in the document.
52
+ // TODO: This should likely be changed to indicate up a schema upgrade would be a no-op, including stored schema metadata.
53
+ const isEquivalent =
54
+ canView && canUpgrade && allowsRepoSuperset(policy, wouldUpgradeTo, stored);
62
55
 
63
- return {
64
- canView,
65
- canUpgrade,
66
- isEquivalent,
67
- };
68
- }
56
+ return {
57
+ canView,
58
+ canUpgrade,
59
+ isEquivalent,
60
+ };
69
61
  }
@@ -80,6 +80,8 @@ import type {
80
80
  * Values should be preferred over generator functions when possible, as they are simpler and more efficient.
81
81
  * Generator functions should be used when the default value needs to be dynamic or when it is not possible to provide a value directly.
82
82
  *
83
+ * See {@link SchemaStaticsAlpha.withDefault} for the primary API that uses this type.
84
+ *
83
85
  * @example
84
86
  * ```typescript
85
87
  * // Provide a value directly
@@ -102,27 +104,63 @@ export type NodeProvider<T> = T | (() => T);
102
104
  */
103
105
  export interface SchemaStaticsAlpha {
104
106
  /**
105
- * Creates a field schema with a default value. Fields with defaults (whether required or optional) are recognized by the type system as optional in constructors,
106
- * allowing them to be omitted when creating new nodes.
107
+ * Creates a field schema with a default value.
108
+ *
109
+ * @remarks
110
+ * Fields with defaults are optional in constructors, allowing them to be omitted when creating new nodes.
111
+ * This works with both {@link SchemaStatics.required | required} and {@link SchemaStatics.optional | optional} fields:
112
+ *
113
+ * - **Required fields with defaults**: The field is always present in the tree, but can be omitted from the constructor.
114
+ * The default value is used when the field is not provided.
115
+ *
116
+ * - **Optional fields with defaults**: Optional fields already default to `undefined`, but `withDefault` lets you
117
+ * specify a different default value.
118
+ *
119
+ * The default value can be provided in two ways (see {@link NodeProvider}):
120
+ *
121
+ * 1. **A value**: The value is deep-copied for each use, ensuring independence between instances.
122
+ * Prefer this when the default is a fixed value.
123
+ *
124
+ * 2. **A generator function**: A function called each time a default is needed. Use this for dynamic defaults
125
+ * (e.g., timestamps, UUIDs) or when explicit control over value creation is required.
126
+ *
127
+ * Defaults are evaluated eagerly during node construction.
128
+ *
129
+ * For recursive schemas, use {@link SchemaStaticsAlpha.withDefaultRecursive} instead.
130
+ *
131
+ * See the {@link https://fluidframework.com/docs/data-structures/tree/schema-definition/default-field-values | Default Field Values documentation}
132
+ * for a comprehensive guide with additional examples.
107
133
  *
108
134
  * @param fieldSchema - The field schema to add a default to (e.g., `factory.required(factory.string)` or `factory.optional(factory.number)`)
109
135
  * @param defaultValue - A {@link NodeProvider} specifying the default value.
110
136
  *
111
137
  * @example
138
+ * A schema with a mix of required, defaulted, and dynamic fields:
112
139
  * ```typescript
113
- * const MySchema = factory.objectAlpha("MyObject", {
114
- * // Provide values directly
115
- * name: factory.withDefault(factory.required(factory.string), "untitled"),
116
- * count: factory.withDefault(factory.required(factory.number), 0),
117
- * metadata: factory.withDefault(factory.optional(Metadata), new Metadata({ version: 1 })),
118
- *
119
- * // Use generator functions for dynamic values
120
- * timestamp: factory.withDefault(factory.required(factory.number), () => Date.now()),
121
- * id: factory.withDefault(factory.required(factory.string), () => crypto.randomUUID()),
122
- * });
123
- *
124
- * const obj1 = new MySchema({}); // All defaults applied
125
- * const obj2 = new MySchema({ name: "custom" }); // name="custom", other defaults applied
140
+ * const factory = new SchemaFactoryAlpha("example");
141
+ *
142
+ * class Task extends factory.objectAlpha("Task", {
143
+ * // No default — must always be provided in the constructor
144
+ * title: factory.required(factory.string),
145
+ *
146
+ * // Required field with a static default
147
+ * status: factory.withDefault(factory.required(factory.string), "todo"),
148
+ *
149
+ * // Optional field with a custom default (instead of `undefined`)
150
+ * priority: factory.withDefault(factory.optional(factory.number), 0),
151
+ *
152
+ * // Dynamic default using a generator function
153
+ * createdAt: factory.withDefault(factory.required(factory.number), () => Date.now()),
154
+ * }) {}
155
+ *
156
+ * // Only `title` is required in the constructor; the rest use their defaults
157
+ * const task = new Task({ title: "Write docs" });
158
+ * // task.status === "todo"
159
+ * // task.priority === 0
160
+ * // task.createdAt is set to the current timestamp
161
+ *
162
+ * // Defaults can be overridden by providing explicit values
163
+ * const urgentTask = new Task({ title: "Fix bug", status: "in-progress", priority: 1 });
126
164
  * ```
127
165
  *
128
166
  * @privateRemarks
@@ -208,6 +246,9 @@ export interface SchemaStaticsAlpha {
208
246
  * @remarks
209
247
  * This version of {@link SchemaStaticsAlpha.withDefault} has fewer type constraints to work around TypeScript limitations, see {@link Unenforced}.
210
248
  * See {@link ValidateRecursiveSchema} for additional information about using recursive schema.
249
+ *
250
+ * See the {@link https://fluidframework.com/docs/data-structures/tree/schema-definition/default-field-values#recursive-types | Default Field Values — Recursive Types documentation}
251
+ * for usage examples and guidance on avoiding infinite recursion with recursive defaults.
211
252
  */
212
253
  withDefaultRecursive: <
213
254
  Kind extends FieldKind,
@@ -94,9 +94,6 @@ export interface SchemaStaticsBeta {
94
94
  * A full code example of the schema migration process can be found in our {@link https://github.com/microsoft/FluidFramework/blob/main/packages/dds/tree/src/test/simple-tree/api/stagedSchemaUpgrade.spec.ts | tests}.
95
95
  *
96
96
  * @privateRemarks
97
- * TODO:#44317 staged allowed types rely on schema validation of stored schema to output errors, these errors are not very
98
- * user friendly and should be improved, particularly in the case of staged allowed types
99
- *
100
97
  * TODO: AB#45711: Update the docs above when recursive type support is added.
101
98
  */
102
99
  readonly staged: <const T extends LazyItem<TreeNodeSchema>>(
@@ -13,7 +13,7 @@ import { toInitialSchema } from "../toStoredSchema.js";
13
13
  import { createTreeSchema } from "../treeSchema.js";
14
14
 
15
15
  import { TreeViewConfigurationAlpha, TreeViewConfiguration } from "./configuration.js";
16
- import { SchemaCompatibilityTester } from "./schemaCompatibilityTester.js";
16
+ import { checkSchemaCompatibility } from "./schemaCompatibilityTester.js";
17
17
  import { generateSchemaFromSimpleSchema } from "./schemaFromSimple.js";
18
18
  import {
19
19
  decodeSchemaCompatibilitySnapshot,
@@ -78,8 +78,7 @@ export function checkCompatibility(
78
78
  ): Omit<SchemaCompatibilityStatus, "canInitialize"> {
79
79
  const viewAsAlpha = new TreeViewConfigurationAlpha({ schema: view.schema });
80
80
  const stored = toInitialSchema(viewWhichCreatedStoredSchema.schema);
81
- const tester = new SchemaCompatibilityTester(viewAsAlpha);
82
- return tester.checkCompatibility(stored);
81
+ return checkSchemaCompatibility(viewAsAlpha, stored);
83
82
  }
84
83
 
85
84
  /**
@@ -13,7 +13,7 @@ import { normalizeFieldSchema, type ImplicitFieldSchema } from "../fieldSchema.j
13
13
  import { toStoredSchema } from "../toStoredSchema.js";
14
14
 
15
15
  import { TreeViewConfigurationAlpha } from "./configuration.js";
16
- import { SchemaCompatibilityTester } from "./schemaCompatibilityTester.js";
16
+ import { checkSchemaCompatibility } from "./schemaCompatibilityTester.js";
17
17
  import type { SchemaCompatibilityStatus } from "./tree.js";
18
18
 
19
19
  /**
@@ -104,6 +104,5 @@ export function comparePersistedSchema(
104
104
  const config = new TreeViewConfigurationAlpha({
105
105
  schema: normalizeFieldSchema(view),
106
106
  });
107
- const viewSchema = new SchemaCompatibilityTester(config);
108
- return viewSchema.checkCompatibility(stored);
107
+ return checkSchemaCompatibility(config, stored);
109
108
  }
@@ -112,8 +112,20 @@ export interface ITreeAlpha extends ITree {
112
112
  /**
113
113
  * Creates a fork of the current state of the main branch.
114
114
  * This new branch will be shared with and editable by all clients.
115
+ * @param name - Optional name for the new branch.
116
+ * This name is not guaranteed to be unique.
117
+ * (Maximum {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/length | length}: 1024)
118
+ * @returns The ID of the new branch, which can be used to {@link ITreeAlpha.viewSharedBranchWith | view} the branch.
115
119
  */
116
- createSharedBranch(): string;
120
+ createSharedBranch(name?: string): string;
121
+
122
+ /**
123
+ * Retrieves the name, if any, of the shared branch with the given ID.
124
+ * @param branchId - The ID of the shared branch to retrieve the name of.
125
+ * @returns The name of the shared branch, or `undefined` if the branch has no assigned name.
126
+ * @throws if the branch with the given ID does not exist.
127
+ */
128
+ getSharedBranchName(branchId: string): string | undefined;
117
129
 
118
130
  /**
119
131
  * Returns a list of all shared branches that currently exist on this tree.
@@ -376,6 +388,16 @@ export interface TreeBranchAlpha extends TreeBranch, TreeContextAlpha {
376
388
  * @throws UsageError if the branches are unrelated.
377
389
  */
378
390
  isMissingEditsFrom(branch: TreeBranch): boolean;
391
+
392
+ /**
393
+ * Computes the net change that would result if this branch were {@link TreeBranch.rebaseOnto | rebased onto} the given branch.
394
+ * Note that this method does not actually perform the rebase and therefore has no effect on this branch.
395
+ *
396
+ * @param branch - The branch that would be rebased onto.
397
+ * @returns The net change that would result if this branch were rebased onto the given branch,
398
+ * or `undefined` if rebasing would have no impact.
399
+ */
400
+ computeNetChangeIfRebasedOnto(branch: TreeBranch): JsonCompatibleReadOnly | undefined;
379
401
  }
380
402
 
381
403
  /**
@@ -422,7 +444,7 @@ export interface TreeView<in out TSchema extends ImplicitFieldSchema> extends ID
422
444
  /**
423
445
  * Description of the current compatibility status between the view schema and stored schema.
424
446
  * @remarks
425
- * {@link TreeViewEvents.schemaChanged} is fired when the compatibility status changes.
447
+ * {@link TreeViewEvents.schemaChanged} is fired when the compatibility status of the document's stored schema changes.
426
448
  * See {@link https://fluidframework.com/docs/data-structures/tree/schema-evolution/ | schema-evolution} for more guidance on how to change schema while maintaining compatibility.
427
449
  * Use {@link snapshotSchemaCompatibility} to write tests to validate that this compatibility behaves as desired across schema changes.
428
450
  */
@@ -437,6 +459,44 @@ export interface TreeView<in out TSchema extends ImplicitFieldSchema> extends ID
437
459
  *
438
460
  * It is an error to call this when {@link SchemaCompatibilityStatus.canUpgrade} is false.
439
461
  * {@link SchemaCompatibilityStatus.canUpgrade} being true does not mean that an upgrade is required, nor that an upgrade will have any effect.
462
+ *
463
+ * When using {@link TreeViewConfigurationAlpha} with a {@link ITreeViewConfigurationAlpha.stagedUpgradePolicy},
464
+ * staged schema upgrades matching the configured policy are included in the target stored schema.
465
+ * Once a staged schema upgrade has been enabled in a document's stored schema, loading that document
466
+ * with a view that does not include equivalent staged members in its construction-time policy will cause
467
+ * `upgradeSchema` to throw a `UsageError` because the requested target would narrow the stored schema.
468
+ *
469
+ * @example Enabling a staged allowed type for documents, selected by a feature flag
470
+ *
471
+ * ```typescript
472
+ * const sf = new SchemaFactoryBeta("my-app");
473
+ *
474
+ * class TaskItem extends sf.object("TaskItem", { title: sf.string }) {}
475
+ * class ChecklistItem extends sf.object("ChecklistItem", { text: sf.string }) {}
476
+ *
477
+ * // `staged` wraps ChecklistItem so it can be enabled at runtime.
478
+ * const stagedChecklist = SchemaFactoryBeta.staged(ChecklistItem);
479
+ * const checklistUpgrade = stagedChecklist.metadata.stagedSchemaUpgrade;
480
+ *
481
+ * class AppSchema extends sf.object("AppSchema", {
482
+ * items: sf.array([TaskItem, stagedChecklist]),
483
+ * }) {}
484
+ *
485
+ * // Feature flag controls whether the upgrade is enabled for this session.
486
+ * const policy = featureFlags.enableChecklist
487
+ * ? StagedSchemaUpgradePolicy.enabledStagedUpgrades(checklistUpgrade)
488
+ * : undefined;
489
+ *
490
+ * const view = tree.viewWith(
491
+ * new TreeViewConfigurationAlpha({ schema: AppSchema, stagedUpgradePolicy: policy }),
492
+ * );
493
+ *
494
+ * if (view.compatibility.canUpgrade) {
495
+ * // Writes the staged type into the document's stored schema.
496
+ * view.upgradeSchema();
497
+ * }
498
+ * ```
499
+ *
440
500
  * @privateRemarks
441
501
  * In the future, more upgrade options could be provided here.
442
502
  * Some options that could be added:
@@ -454,8 +514,12 @@ export interface TreeView<in out TSchema extends ImplicitFieldSchema> extends ID
454
514
  /**
455
515
  * Initialize the tree, setting the stored schema to match this view's schema and setting the tree content.
456
516
  *
517
+ * @remarks
457
518
  * Only valid to call when this view's {@link SchemaCompatibilityStatus.canInitialize} is true.
458
519
  *
520
+ * When using {@link TreeViewConfigurationAlpha} with a {@link ITreeViewConfigurationAlpha.stagedUpgradePolicy},
521
+ * staged schema upgrades matching the configured policy are included in the initial stored schema.
522
+ *
459
523
  * Applications should typically call this function before attaching a `SharedTree`.
460
524
  * @param content - The content to initialize the tree with.
461
525
  */
@@ -563,6 +627,21 @@ export interface TreeViewAlpha<
563
627
 
564
628
  set root(newRoot: InsertableField<TSchema>);
565
629
 
630
+ /**
631
+ * Initialize the tree, setting the stored schema to match this view's schema and setting the tree content.
632
+ *
633
+ * @remarks
634
+ * Only valid to call when this view's {@link SchemaCompatibilityStatus.canInitialize} is true.
635
+ *
636
+ * Enables staged schema upgrades declared by {@link ITreeViewConfigurationAlpha.stagedUpgradePolicy} when generating the initial stored schema.
637
+ * Once a staged schema upgrade has been enabled in a document's stored schema, loading that document
638
+ * with a view that does not include equivalent staged members in its construction-time policy will cause
639
+ * a subsequent `upgradeSchema` call to throw a `UsageError` because the stored schema already contains
640
+ * the upgraded members and the new target would narrow it.
641
+ *
642
+ * Applications should typically call this function before attaching a `SharedTree`.
643
+ * @param content - The content to initialize the tree with.
644
+ */
566
645
  initialize(content: InsertableField<TSchema>): void;
567
646
 
568
647
  readonly events: Listenable<TreeViewEvents & TreeBranchEvents>;
@@ -578,7 +657,7 @@ export interface TreeViewAlpha<
578
657
  * See SharedTree's README for more information about choosing a compatibility policy.
579
658
  *
580
659
  * @privateRemarks
581
- * See {@link SchemaCompatibilityTester} for the implementation of this compatibility checking.
660
+ * See {@link checkSchemaCompatibility} for the implementation of this compatibility checking.
582
661
  *
583
662
  * @sealed @public
584
663
  */
@@ -21,6 +21,7 @@ import type {
21
21
  TreeLeafValue,
22
22
  FlexListToUnion,
23
23
  LazyItem,
24
+ NumberKeys,
24
25
  AnnotatedAllowedType,
25
26
  AnnotatedAllowedTypes,
26
27
  } from "../core/index.js";
@@ -260,7 +261,7 @@ export namespace System_Unsafe {
260
261
  >
261
262
  ? InsertableTypedNodeUnsafe<TSchema>
262
263
  : never;
263
- }[number];
264
+ }[NumberKeys<TList>];
264
265
 
265
266
  /**
266
267
  * {@link Unenforced} version of {@link InsertableTypedNode}.
@@ -115,7 +115,8 @@ export {
115
115
  export type { SimpleNodeSchemaBase } from "./simpleNodeSchemaBase.js";
116
116
  export {
117
117
  type StoredSchemaGenerationOptions,
118
- type StoredFromViewSchemaGenerationOptions,
118
+ StagedSchemaUpgradePolicy,
119
+ type StagedSchemaUpgradePolicyFactory,
119
120
  ExpectStored,
120
121
  type SimpleSchemaTransformationOptions,
121
122
  Unchanged,