@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
@@ -6,18 +6,20 @@
6
6
  import type { SchemaUpgrade } from "./allowedTypes.js";
7
7
 
8
8
  /**
9
- * Options for transforming a view simple-schema to a stored simple-schema (See {@link TreeStoredSchema}).
9
+ * Policy controlling which staged schema upgrades are included when generating stored schema from a view schema.
10
+ * @input
11
+ * @alpha
10
12
  */
11
- export interface StoredFromViewSchemaGenerationOptions {
13
+ export interface StagedSchemaUpgradePolicy {
12
14
  /**
13
- * Determines whether to include {@link SchemaStaticsBeta.staged | staged} allowed types in the resulting stored schema.
15
+ * Determines whether to include staged allowed types in the resulting stored schema.
14
16
  * @remarks
15
17
  * Due to caching, the behavior of this function must be pure.
16
18
  */
17
19
  includeStaged(upgrade: SchemaUpgrade): boolean;
18
20
 
19
21
  /**
20
- * Determines whether to treat a {@link SchemaFactoryAlpha.stagedOptional | staged optional} field as optional
22
+ * Determines whether to treat a staged optional field as optional
21
23
  * (rather than required) in the resulting stored schema.
22
24
  * @remarks
23
25
  * Due to caching, the behavior of this function must be pure.
@@ -25,6 +27,93 @@ export interface StoredFromViewSchemaGenerationOptions {
25
27
  includeStagedOptional(upgrade: SchemaUpgrade): boolean;
26
28
  }
27
29
 
30
+ /**
31
+ * Provides factory methods for creating {@link (StagedSchemaUpgradePolicy:interface)} instances.
32
+ *
33
+ * @remarks
34
+ * Use the properties and methods on this object to obtain staged-schema generation options
35
+ * for different scenarios:
36
+ *
37
+ * - {@link StagedSchemaUpgradePolicyFactory.restrictive} — no staged upgrades (default)
38
+ *
39
+ * - {@link StagedSchemaUpgradePolicyFactory.permissive} — all staged upgrades enabled
40
+ *
41
+ * - {@link StagedSchemaUpgradePolicyFactory.enabledStagedUpgrades} — only specific upgrades enabled
42
+ *
43
+ * @example
44
+ * ```typescript
45
+ * // Enable specific upgrades:
46
+ * const options = StagedSchemaUpgradePolicy.enabledStagedUpgrades(myUpgrade);
47
+ *
48
+ * // Use restrictive (default, no staged upgrades):
49
+ * const options = StagedSchemaUpgradePolicy.restrictive;
50
+ *
51
+ * // Use permissive (all staged upgrades, useful for testing):
52
+ * const options = StagedSchemaUpgradePolicy.permissive;
53
+ * ```
54
+ *
55
+ * @sealed
56
+ * @alpha
57
+ */
58
+ export interface StagedSchemaUpgradePolicyFactory {
59
+ /**
60
+ * Restrictive policy — excludes all staged schema members.
61
+ *
62
+ * @remarks
63
+ * Use this when you want the most conservative stored schema for compatibility-sensitive
64
+ * scenarios, or when staged schema upgrades should remain disabled.
65
+ *
66
+ * This is the default behavior when no staged upgrades are enabled.
67
+ */
68
+ readonly restrictive: StagedSchemaUpgradePolicy;
69
+ /**
70
+ * Permissive policy — includes all staged schema upgrades.
71
+ *
72
+ * @remarks
73
+ * Use this for testing, validation, and rollout rehearsal scenarios where you want to exercise
74
+ * future document shapes before enabling staged upgrades broadly.
75
+ */
76
+ readonly permissive: StagedSchemaUpgradePolicy;
77
+ /**
78
+ * Creates options that include only the specified staged schema upgrades.
79
+ *
80
+ * @param upgrades - The staged schema upgrades to enable.
81
+ * @returns Options that include only the specified upgrades.
82
+ *
83
+ * @remarks
84
+ * If an empty set of upgrades is passed, the result is equivalent to
85
+ * `StagedSchemaUpgradePolicy.restrictive`.
86
+ */
87
+ enabledStagedUpgrades(...upgrades: SchemaUpgrade[]): StagedSchemaUpgradePolicy;
88
+ }
89
+
90
+ /**
91
+ * {@inheritDoc (StagedSchemaUpgradePolicyFactory:interface)}
92
+ * @alpha
93
+ */
94
+ export const StagedSchemaUpgradePolicy: StagedSchemaUpgradePolicyFactory = {
95
+ restrictive: {
96
+ includeStaged: () => false,
97
+ includeStagedOptional: () => false,
98
+ },
99
+
100
+ permissive: {
101
+ includeStaged: () => true,
102
+ includeStagedOptional: () => true,
103
+ },
104
+
105
+ enabledStagedUpgrades(...upgrades: SchemaUpgrade[]): StagedSchemaUpgradePolicy {
106
+ if (upgrades.length === 0) {
107
+ return StagedSchemaUpgradePolicy.restrictive;
108
+ }
109
+ const enabledUpgradeSet = new Set(upgrades);
110
+ return {
111
+ includeStaged: (upgrade) => enabledUpgradeSet.has(upgrade),
112
+ includeStagedOptional: (upgrade) => enabledUpgradeSet.has(upgrade),
113
+ };
114
+ },
115
+ };
116
+
28
117
  /**
29
118
  * Marker type indicating that the input schema is already a stored schema.
30
119
  */
@@ -42,9 +131,7 @@ export type Unchanged = typeof Unchanged;
42
131
  /**
43
132
  * Subset of {@link SimpleSchemaTransformationOptions} for when the output is a known to be a stored schema.
44
133
  */
45
- export type StoredSchemaGenerationOptions =
46
- | StoredFromViewSchemaGenerationOptions
47
- | ExpectStored;
134
+ export type StoredSchemaGenerationOptions = StagedSchemaUpgradePolicy | ExpectStored;
48
135
 
49
136
  /**
50
137
  * Options for transforming a schema.
@@ -54,6 +141,6 @@ export type StoredSchemaGenerationOptions =
54
141
  * we will need to add a "ToView" option here.
55
142
  */
56
143
  export type SimpleSchemaTransformationOptions =
57
- | StoredFromViewSchemaGenerationOptions
144
+ | StagedSchemaUpgradePolicy
58
145
  | ExpectStored
59
146
  | Unchanged;
@@ -59,6 +59,8 @@ export {
59
59
  type AllowedTypesFullFromMixed,
60
60
  AnnotatedAllowedTypesInternal,
61
61
  type NumberKeys,
62
+ StagedSchemaUpgradePolicy,
63
+ type StagedSchemaUpgradePolicyFactory,
62
64
  ExpectStored,
63
65
  createSchemaUpgrade,
64
66
  } from "./core/index.js";
@@ -72,6 +74,7 @@ export {
72
74
  TreeViewConfiguration,
73
75
  TreeViewConfigurationAlpha,
74
76
  type ITreeViewConfiguration,
77
+ type ITreeViewConfigurationAlpha,
75
78
  type SchemaCompatibilityStatus,
76
79
  type ITreeConfigurationOptions,
77
80
  SchemaFactory,
@@ -140,7 +143,7 @@ export {
140
143
  extractPersistedSchema,
141
144
  comparePersistedSchema,
142
145
  type ConciseTree,
143
- SchemaCompatibilityTester,
146
+ checkSchemaCompatibility,
144
147
  type Unenforced,
145
148
  type System_Unsafe,
146
149
  type ArrayNodeCustomizableSchemaUnsafe,
@@ -317,8 +320,6 @@ export {
317
320
  toUpgradeSchema,
318
321
  toInitialSchema,
319
322
  toUnhydratedSchema,
320
- restrictiveStoredSchemaGenerationOptions,
321
- permissiveStoredSchemaGenerationOptions,
322
323
  } from "./toStoredSchema.js";
323
324
  export {
324
325
  numberSchema,
@@ -109,6 +109,14 @@ export interface TreeArrayNode<
109
109
  > extends ReadonlyArrayNode<T> {
110
110
  /**
111
111
  * Inserts new item(s) at a specified location.
112
+ *
113
+ * @remarks
114
+ * All items inserted by a single call to this method are inserted consecutively.
115
+ * The order of the inserted items relative to other concurrently inserted items at the same location is only partially specified:
116
+ * Concurrently inserting `[A, B]` and `[X, Y]` at the same location may yield
117
+ * either `[A, B, X, Y]` or `[X, Y, A, B]`, regardless of the order in which those edits are sequenced.
118
+ * No other interleavings are possible. (e.g. `[A, X, B, Y]` is not possible.)
119
+ *
112
120
  * @param index - The index at which to insert `value`.
113
121
  * @param value - The content to insert.
114
122
  * @throws Throws if `index` is not in the range [0, `array.length`).
@@ -117,12 +125,18 @@ export interface TreeArrayNode<
117
125
 
118
126
  /**
119
127
  * Inserts new item(s) at the start of the array.
128
+ * @remarks
129
+ * Equivalent to `insertAt(0, ...value)`:
130
+ * see {@link (TreeArrayNode:interface).insertAt} for details, including merge semantics with concurrent edits.
120
131
  * @param value - The content to insert.
121
132
  */
122
133
  insertAtStart(...value: readonly (TNew | IterableTreeArrayContent<TNew>)[]): void;
123
134
 
124
135
  /**
125
136
  * Inserts new item(s) at the end of the array.
137
+ * @remarks
138
+ * Equivalent to `insertAt(array.length, ...value)`:
139
+ * see {@link (TreeArrayNode:interface).insertAt} for details, including merge semantics with concurrent edits.
126
140
  * @param value - The content to insert.
127
141
  */
128
142
  insertAtEnd(...value: readonly (TNew | IterableTreeArrayContent<TNew>)[]): void;
@@ -131,10 +145,10 @@ export interface TreeArrayNode<
131
145
  * Inserts new item(s) at the end of the array.
132
146
  *
133
147
  * @remarks
134
- * The order of the inserted items relative to other concurrently inserted items at the same location is only partially specified:
135
- * Concurrently inserting `[A, B]` and `[X, Y]` at the same location may yield
136
- * either `[A, B, X, Y]` or `[X, Y, A, B]`, regardless of the order in which those edits are sequenced.
137
- * No other interleavings are possible. (e.g. `[A, X, B, Y]` is not possible.)
148
+ * Unlike `Array.prototype.push`, this method does not return the new length of the array.
149
+ *
150
+ * Equivalent to `insertAt(array.length, ...value)`:
151
+ * see {@link (TreeArrayNode:interface).insertAt} for details, including merge semantics with concurrent edits.
138
152
  *
139
153
  * @param value - The content to insert.
140
154
  */
@@ -460,6 +474,87 @@ export interface TreeArrayNodeAlpha<
460
474
  ? InsertableTreeNodeFromImplicitAllowedTypes<TAllowedTypes>
461
475
  : InsertableTreeNodeFromImplicitAllowedTypes<ImplicitAllowedTypes>,
462
476
  > extends TreeArrayNode<TAllowedTypes, T, TNew> {
477
+ /**
478
+ * Returns the item located at the specified index.
479
+ * @param index - The zero-based index of the item to retrieve.
480
+ * Negative indices count back from the last item in the array: for `index < 0`, `index + array.length` is used.
481
+ * @returns The item at the specified index, or `undefined` if the index is out of bounds.
482
+ */
483
+ at(index: number): T | undefined;
484
+
485
+ /**
486
+ * Returns the last item in the array for which the given type guard returns `true`,
487
+ * searching from the last item to the first.
488
+ * @remarks
489
+ * The array's length is captured when the search begins; items are read live as the search progresses.
490
+ * If `predicate` edits the array, behavior matches {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/findLast | Array.prototype.findLast}.
491
+ * @typeParam S - The subtype of `T` asserted by the `predicate` type guard.
492
+ * @param predicate - Evaluated once per item, starting from the last item and moving towards the first, until it returns `true`.
493
+ * Receives the item, its index, and the array being searched.
494
+ * @param thisArg - If provided, used as `this` when invoking `predicate`.
495
+ * @returns The last item for which `predicate` returns `true` (narrowed to the guarded type), or `undefined` if there is no such item.
496
+ */
497
+ findLast<S extends T>(
498
+ predicate: (value: T, index: number, array: readonly T[]) => value is S,
499
+ thisArg?: unknown,
500
+ ): S | undefined;
501
+
502
+ /**
503
+ * Returns the last item in the array for which the given predicate returns a truthy value,
504
+ * searching from the last item to the first.
505
+ * @remarks
506
+ * The array's length is captured when the search begins; items are read live as the search progresses.
507
+ * If `predicate` edits the array, behavior matches {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/findLast | Array.prototype.findLast}.
508
+ * @param predicate - Evaluated once per item, starting from the last item and moving towards the first, until it returns a truthy value.
509
+ * Receives the item, its index, and the array being searched.
510
+ * @param thisArg - If provided, used as `this` when invoking `predicate`.
511
+ * @returns The last item for which `predicate` returns a truthy value, or `undefined` if there is no such item.
512
+ */
513
+ findLast(
514
+ predicate: (value: T, index: number, array: readonly T[]) => unknown,
515
+ thisArg?: unknown,
516
+ ): T | undefined;
517
+
518
+ /**
519
+ * Returns the index of the last item in the array for which the given predicate returns a truthy value,
520
+ * searching from the last item to the first.
521
+ * @remarks
522
+ * The array's length is captured when the search begins; items are read live as the search progresses.
523
+ * If `predicate` edits the array, behavior matches {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/findLastIndex | Array.prototype.findLastIndex}.
524
+ * @param predicate - Evaluated once per item, starting from the last item and moving towards the first, until it returns a truthy value.
525
+ * Receives the item, its index, and the array being searched.
526
+ * @param thisArg - If provided, used as `this` when invoking `predicate`.
527
+ * @returns The index of the last item for which `predicate` returns a truthy value, or `-1` if there is no such item.
528
+ */
529
+ findLastIndex(
530
+ predicate: (value: T, index: number, array: readonly T[]) => unknown,
531
+ thisArg?: unknown,
532
+ ): number;
533
+
534
+ /**
535
+ * Removes the last item from the array and returns it.
536
+ * @returns The removed item, or `undefined` if the array is empty (in which case the array is not modified).
537
+ */
538
+ pop(): T | undefined;
539
+
540
+ /**
541
+ * Removes the first item from the array and returns it.
542
+ * @returns The removed item, or `undefined` if the array is empty (in which case the array is not modified).
543
+ */
544
+ shift(): T | undefined;
545
+
546
+ /**
547
+ * Inserts new item(s) at the start of the array.
548
+ *
549
+ * @param value - The content to insert.
550
+ * @remarks
551
+ * Unlike `Array.prototype.unshift`, this method does not return the new length of the array.
552
+ *
553
+ * Equivalent to `insertAt(0, ...value)`:
554
+ * see {@link (TreeArrayNode:interface).insertAt} for details, including merge semantics with concurrent edits.
555
+ */
556
+ unshift(...value: readonly (TNew | IterableTreeArrayContent<TNew>)[]): void;
557
+
463
558
  /**
464
559
  * Removes existing item(s) and/or adds new item(s).
465
560
  * @param start - The index at which to start changing the array. If negative, it is treated as `array.length + start`.
@@ -995,6 +1090,58 @@ abstract class CustomArrayNodeBase<const T extends ImplicitAllowedTypes>
995
1090
 
996
1091
  return getOrCreateNodeFromInnerNode(val) as TreeNodeFromImplicitAllowedTypes<T>;
997
1092
  }
1093
+ public findLast<S extends TreeNodeFromImplicitAllowedTypes<T>>(
1094
+ predicate: (
1095
+ value: TreeNodeFromImplicitAllowedTypes<T>,
1096
+ index: number,
1097
+ array: readonly TreeNodeFromImplicitAllowedTypes<T>[],
1098
+ ) => value is S,
1099
+ thisArg?: unknown,
1100
+ ): S | undefined;
1101
+ public findLast(
1102
+ predicate: (
1103
+ value: TreeNodeFromImplicitAllowedTypes<T>,
1104
+ index: number,
1105
+ array: readonly TreeNodeFromImplicitAllowedTypes<T>[],
1106
+ ) => unknown,
1107
+ thisArg?: unknown,
1108
+ ): TreeNodeFromImplicitAllowedTypes<T> | undefined;
1109
+ public findLast(
1110
+ predicate: (
1111
+ value: TreeNodeFromImplicitAllowedTypes<T>,
1112
+ index: number,
1113
+ array: readonly TreeNodeFromImplicitAllowedTypes<T>[],
1114
+ ) => unknown,
1115
+ thisArg?: unknown,
1116
+ ): TreeNodeFromImplicitAllowedTypes<T> | undefined {
1117
+ const array = this as readonly TreeNodeFromImplicitAllowedTypes<T>[];
1118
+ for (let index = this.length - 1; index >= 0; index--) {
1119
+ const value = this.at(index) as TreeNodeFromImplicitAllowedTypes<T>;
1120
+ const matched = Boolean(predicate.call(thisArg, value, index, array));
1121
+ if (matched) {
1122
+ return value;
1123
+ }
1124
+ }
1125
+ return undefined;
1126
+ }
1127
+ public findLastIndex(
1128
+ predicate: (
1129
+ value: TreeNodeFromImplicitAllowedTypes<T>,
1130
+ index: number,
1131
+ array: readonly TreeNodeFromImplicitAllowedTypes<T>[],
1132
+ ) => unknown,
1133
+ thisArg?: unknown,
1134
+ ): number {
1135
+ const array = this as readonly TreeNodeFromImplicitAllowedTypes<T>[];
1136
+ for (let index = this.length - 1; index >= 0; index--) {
1137
+ const value = this.at(index) as TreeNodeFromImplicitAllowedTypes<T>;
1138
+ const matched = Boolean(predicate.call(thisArg, value, index, array));
1139
+ if (matched) {
1140
+ return index;
1141
+ }
1142
+ }
1143
+ return -1;
1144
+ }
998
1145
  public insertAt(index: number, ...value: Insertable<T>): void {
999
1146
  const field = getSequenceField(this);
1000
1147
  validateIndex(index, field, "TreeArrayNode.insertAt", true);
@@ -1010,6 +1157,23 @@ abstract class CustomArrayNodeBase<const T extends ImplicitAllowedTypes>
1010
1157
  public push(...value: Insertable<T>): void {
1011
1158
  this.insertAt(this.length, ...value);
1012
1159
  }
1160
+ public unshift(...value: Insertable<T>): void {
1161
+ this.insertAt(0, ...value);
1162
+ }
1163
+ public pop(): TreeNodeFromImplicitAllowedTypes<T> | undefined {
1164
+ const value = this.at(-1);
1165
+ if (value !== undefined) {
1166
+ this.removeAt(this.length - 1);
1167
+ }
1168
+ return value;
1169
+ }
1170
+ public shift(): TreeNodeFromImplicitAllowedTypes<T> | undefined {
1171
+ const value = this.at(0);
1172
+ if (value !== undefined) {
1173
+ this.removeAt(0);
1174
+ }
1175
+ return value;
1176
+ }
1013
1177
  public removeAt(index: number): void {
1014
1178
  const field = getSequenceField(this);
1015
1179
  validateIndex(index, field, "TreeArrayNode.removeAt");
@@ -155,6 +155,18 @@ function validateAndPrepare(
155
155
  mapTrees: readonly UnhydratedFlexTreeNode[],
156
156
  scheduleHydrationOverride?: HydrationScheduler,
157
157
  ): void {
158
+ // Detecting duplicates here is the lowest level spot which is the same for hydrated and un-hydrated parents,
159
+ // and is also responsible for other validation, so it seem like the best layer to do this check.
160
+ const seenRoots = new Set<UnhydratedFlexTreeNode>();
161
+ for (const node of mapTrees) {
162
+ if (seenRoots.has(node)) {
163
+ throw new UsageError(
164
+ `A ${JSON.stringify(node.type)} node was provided more than once in a single insertion. A node may not be in more than one place in the tree.`,
165
+ );
166
+ }
167
+ seenRoots.add(node);
168
+ }
169
+
158
170
  if (hydratedData !== undefined) {
159
171
  // Run `prepareContentForHydration` before walking the tree in `isFieldInSchema`.
160
172
  // This ensures that when `isFieldInSchema` requests identifiers (or any other contextual defaults),
@@ -7,7 +7,7 @@
7
7
  * This file contains a format for serializing the compatibility impacting subset of simple schema.
8
8
 
9
9
  * This format can be used for both view and stored simple schema.
10
- * This only includes all parts of the schema that impact compatibility according to SchemaCompatibilityTester.
10
+ * This only includes all parts of the schema that impact compatibility according to {@link checkSchemaCompatibility}.
11
11
  * It may not include some details which impact maintenance of application enforced invariants (like persisted metadata or logic in view schema).
12
12
  */
13
13
 
@@ -37,9 +37,9 @@ import {
37
37
  ExpectStored,
38
38
  NodeKind,
39
39
  SchemaUpgrade,
40
+ StagedSchemaUpgradePolicy,
40
41
  Unchanged,
41
42
  type SimpleSchemaTransformationOptions,
42
- type StoredFromViewSchemaGenerationOptions,
43
43
  type StoredSchemaGenerationOptions,
44
44
  } from "./core/index.js";
45
45
  import { FieldKind, normalizeFieldSchema, type ImplicitFieldSchema } from "./fieldSchema.js";
@@ -64,63 +64,68 @@ import { createTreeSchema } from "./treeSchema.js";
64
64
  // The simple-schema related logic from this file and src/simple-tree/core/toStored.ts can be unified and `toStoredSchema` and its other ImplicitFieldSchema consuming variants should probably be removed in favor of acting on TreeSchema and SimpleTreeSchema directly.
65
65
 
66
66
  const viewToStoredCache = new WeakMap<
67
- StoredFromViewSchemaGenerationOptions,
67
+ StagedSchemaUpgradePolicy,
68
68
  WeakMap<ImplicitFieldSchema, TreeStoredSchema>
69
69
  >();
70
70
 
71
- /**
72
- * Maximally restrictive transformation of a view to stored schema.
73
- * @remarks
74
- * This should only be used when the intent is to produce a stored schema is as restrictive as possible while still being compatible with the input view schema.
75
- * This is typically used for cases where backwards compatibility with past versions of an application is required, like {@link toUpgradeSchema} or {@link toInitialSchema}.
76
- */
77
- export const restrictiveStoredSchemaGenerationOptions: StoredFromViewSchemaGenerationOptions =
78
- {
79
- includeStaged: () => false,
80
- includeStagedOptional: () => false,
81
- };
71
+ function isStagedSchemaUpgradePolicy(
72
+ stagedSchemaUpgrades: Iterable<SchemaUpgrade> | StagedSchemaUpgradePolicy,
73
+ ): stagedSchemaUpgrades is StagedSchemaUpgradePolicy {
74
+ return (
75
+ typeof stagedSchemaUpgrades === "object" &&
76
+ "includeStaged" in stagedSchemaUpgrades &&
77
+ "includeStagedOptional" in stagedSchemaUpgrades
78
+ );
79
+ }
82
80
 
83
81
  /**
84
- * Maximally permissive transformation of a view to stored schema.
82
+ * Resolves a collection of staged schema upgrades into stored-schema generation options.
85
83
  * @remarks
86
- * This should only be used when the intent is to produce a stored schema which allows as much as possible while still being compatible with the input view schema.
87
- * This is typically used for cases where forwards compatibility with future versions of an application is required, like {@link toUnhydratedSchema}.
88
- *
89
- * This is unable to include unknown optional fields in the output, which makes it not truly maximally permissive.
90
- *
91
- * TODO: {@link StoredFromViewSchemaGenerationOptions} could be updated to allow a way to inject extra optional fields.
92
- * If done, then this could take in an existing stored schema, and attempt to generate a valid superset.
93
- * This could be useful to use as the schema for unhydrated content cloned from hydrated content.
84
+ * If `stagedSchemaUpgrades` is omitted, returns restrictive options.
94
85
  */
95
- export const permissiveStoredSchemaGenerationOptions: StoredFromViewSchemaGenerationOptions = {
96
- includeStaged: () => true,
97
- includeStagedOptional: () => true,
98
- };
86
+ export function resolveStoredSchemaGenerationOptions(
87
+ stagedSchemaUpgrades?: Iterable<SchemaUpgrade> | StagedSchemaUpgradePolicy,
88
+ ): StagedSchemaUpgradePolicy {
89
+ if (stagedSchemaUpgrades === undefined) {
90
+ return StagedSchemaUpgradePolicy.restrictive;
91
+ }
92
+
93
+ if (isStagedSchemaUpgradePolicy(stagedSchemaUpgrades)) {
94
+ return stagedSchemaUpgrades;
95
+ }
96
+
97
+ return StagedSchemaUpgradePolicy.enabledStagedUpgrades(...stagedSchemaUpgrades);
98
+ }
99
99
 
100
100
  /**
101
101
  * Converts a {@link ImplicitFieldSchema} into a {@link TreeStoredSchema} for use in schema upgrades.
102
- *
103
- * TODO: once upgrades are more flexible, this should take in more options, including the old schema and specific upgrades to enable.
104
102
  */
105
- export function toUpgradeSchema(root: ImplicitFieldSchema): TreeStoredSchema {
106
- return toStoredSchema(root, restrictiveStoredSchemaGenerationOptions);
103
+ export function toUpgradeSchema(
104
+ root: ImplicitFieldSchema,
105
+ stagedSchemaUpgrades?: Iterable<SchemaUpgrade> | StagedSchemaUpgradePolicy,
106
+ ): TreeStoredSchema {
107
+ return toStoredSchema(root, resolveStoredSchemaGenerationOptions(stagedSchemaUpgrades));
107
108
  }
108
109
 
109
110
  /**
110
111
  * Converts a {@link ImplicitFieldSchema} into a {@link TreeStoredSchema} for use as initial document schema.
111
112
  */
112
- export function toInitialSchema(root: ImplicitFieldSchema): TreeStoredSchema {
113
- return toStoredSchema(root, restrictiveStoredSchemaGenerationOptions);
113
+ export function toInitialSchema(
114
+ root: ImplicitFieldSchema,
115
+ stagedSchemaUpgrades?: Iterable<SchemaUpgrade> | StagedSchemaUpgradePolicy,
116
+ ): TreeStoredSchema {
117
+ return toStoredSchema(root, resolveStoredSchemaGenerationOptions(stagedSchemaUpgrades));
114
118
  }
115
119
 
116
120
  /**
117
- * Converts a {@link ImplicitFieldSchema} into a {@link TreeStoredSchema} to used for unhydrated nodes.
121
+ * Permissive staged schema upgrade policy used for unhydrated node schema generation.
118
122
  * @remarks
119
123
  * This allows as much as possible, relying on further validation when inserting the content.
120
124
  *
121
125
  * TODO: this should get additional options to enable support for unknown optional fields.
122
126
  */
123
- export const toUnhydratedSchema = permissiveStoredSchemaGenerationOptions;
127
+ export const toUnhydratedSchema: StagedSchemaUpgradePolicy =
128
+ StagedSchemaUpgradePolicy.permissive;
124
129
 
125
130
  /**
126
131
  * Converts a {@link ImplicitFieldSchema} into a {@link TreeStoredSchema}.
@@ -137,7 +142,7 @@ export const toUnhydratedSchema = permissiveStoredSchemaGenerationOptions;
137
142
  */
138
143
  export function toStoredSchema(
139
144
  root: ImplicitFieldSchema,
140
- options: StoredFromViewSchemaGenerationOptions,
145
+ options: StagedSchemaUpgradePolicy,
141
146
  ): TreeStoredSchema {
142
147
  const cache = getOrCreate(viewToStoredCache, options, () => new WeakMap());
143
148
  return getOrCreate(cache, root, () => {
@@ -152,7 +157,7 @@ export function toStoredSchema(
152
157
  */
153
158
  export function transformSimpleSchema(
154
159
  schema: SimpleTreeSchema<SchemaType.View>,
155
- options: StoredFromViewSchemaGenerationOptions,
160
+ options: StagedSchemaUpgradePolicy,
156
161
  ): SimpleTreeSchema<SchemaType.Stored>;
157
162
 
158
163
  /**
@@ -324,7 +329,7 @@ export function getStoredSchema(
324
329
  */
325
330
  export function transformSimpleNodeSchema(
326
331
  schema: SimpleNodeSchema<SchemaType.View>,
327
- options: StoredFromViewSchemaGenerationOptions,
332
+ options: StagedSchemaUpgradePolicy,
328
333
  ): SimpleNodeSchema<SchemaType.Stored>;
329
334
 
330
335
  /**
@@ -483,7 +488,7 @@ function allowedTypeFilter(
483
488
  if (options === ExpectStored) {
484
489
  if (data.isStaged !== undefined) {
485
490
  throw new UsageError(
486
- "Failed to covert view schema to stored schema. The simple schema provided was indicated to be a stored schema by the use of `ExpectStored`, but view schema specific content was encountered which requires a `StoredFromViewSchemaGenerationOptions` to process.",
491
+ "Failed to covert view schema to stored schema. The simple schema provided was indicated to be a stored schema by the use of `ExpectStored`, but view schema specific content was encountered which requires a `StagedSchemaUpgradePolicy` to process.",
487
492
  );
488
493
  }
489
494
  return true;
@@ -505,7 +510,7 @@ function allowedTypeFilter(
505
510
 
506
511
  function isStoredFromView(
507
512
  options: SimpleSchemaTransformationOptions,
508
- ): options is StoredFromViewSchemaGenerationOptions {
513
+ ): options is StagedSchemaUpgradePolicy {
509
514
  return typeof options === "object" && "includeStaged" in options;
510
515
  }
511
516
 
@@ -77,7 +77,7 @@ function treeKernelFactory(
77
77
  };
78
78
 
79
79
  return new SharedTreeKernel(
80
- new Breakable("SharedTree"),
80
+ new Breakable("SharedTree", args.logger),
81
81
  args.sharedObject,
82
82
  args.serializer,
83
83
  args.submitLocalMessage,
@@ -4,7 +4,7 @@
4
4
  */
5
5
 
6
6
  import { assert } from "@fluidframework/core-utils/internal";
7
- import { UsageError } from "@fluidframework/telemetry-utils/internal";
7
+ import { UsageError, type TelemetryLoggerExt } from "@fluidframework/telemetry-utils/internal";
8
8
 
9
9
  /**
10
10
  * An object which can enter a "broken" state where trying to use it is a UsageError.
@@ -22,6 +22,13 @@ export class Breakable {
22
22
  * This is useful for documenting the semantics of a given Breakable and when inspecting things in the debugger, but is currently otherwise unused.
23
23
  */
24
24
  private readonly name: string,
25
+ /**
26
+ * Optional logger for telemetry.
27
+ * @remarks
28
+ * When provided, subsystems that have access to a Breakable can use this logger to emit telemetry
29
+ * without requiring additional plumbing.
30
+ */
31
+ public readonly logger?: TelemetryLoggerExt,
25
32
  ) {}
26
33
 
27
34
  /**