@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
@@ -5,7 +5,6 @@
5
5
 
6
6
  import { assert, unreachableCase, oob } from "@fluidframework/core-utils/internal";
7
7
  import type {
8
- IIdCompressor,
9
8
  OpSpaceCompressedId,
10
9
  SessionSpaceCompressedId,
11
10
  } from "@fluidframework/id-compressor";
@@ -17,7 +16,12 @@ import type {
17
16
  Value,
18
17
  TreeChunk,
19
18
  } from "../../../core/index.js";
20
- import { assertValidIndex, brand, decompressIdentifierIfNeeded } from "../../../util/index.js";
19
+ import {
20
+ assertValidIndex,
21
+ brand,
22
+ decompressIdentifierIfNeeded,
23
+ type IdDecodingContext,
24
+ } from "../../../util/index.js";
21
25
  import { BasicChunk } from "../basicChunk.js";
22
26
  import { emptyChunk } from "../emptyChunk.js";
23
27
  import { SequenceChunk } from "../sequenceChunk.js";
@@ -55,31 +59,6 @@ import {
55
59
  supportsIncrementalEncoding,
56
60
  } from "./format/index.js";
57
61
 
58
- /**
59
- * Context for decoding identifiers.
60
- * @remarks
61
- * See {@link FieldBatchDecodingContext} for the production implementation of this.
62
- *
63
- * This intentionally avoids exposing anything which depends on the underlying id-compressor's session ID to avoid confusion with the session ID of the compressor which encoded the data.
64
- * If the session ID of the encoder which encoded the data is known, that information is baked into `resolveEncodedId`.
65
- */
66
- export interface IdDecodingContext {
67
- /**
68
- * Compressor which can decompress session-space identifiers from {@link resolveEncodedId} as needed.
69
- */
70
- readonly idCompressor: Pick<IIdCompressor, "decompress">;
71
- /**
72
- * Resolves an encoded op-space identifier to either a session-space ID
73
- * (which {@link idCompressor} can decompress if needed)
74
- * or a string (which passes through unchanged).
75
- * @remarks
76
- * In contexts where non-final identifiers can't be supported (where no originator session is available),
77
- * if a non-final identifier is encountered, this may throw or perform a data healing workaround.
78
- * See {@link FieldBatchDecodingContext.forOp} and {@link FieldBatchDecodingContext.forSummary} for details.
79
- */
80
- readonly resolveEncodedId: (id: OpSpaceCompressedId) => SessionSpaceCompressedId | string;
81
- }
82
-
83
62
  /**
84
63
  * Decode `chunk` into a TreeChunk.
85
64
  */
@@ -7,7 +7,7 @@ import { assert } from "@fluidframework/core-utils/internal";
7
7
 
8
8
  import type { DiscriminatedUnionDispatcher } from "../../../codec/index.js";
9
9
  import type { TreeChunk } from "../../../core/index.js";
10
- import type { BrandedType } from "../../../util/index.js";
10
+ import type { BrandedType, IdDecodingContext } from "../../../util/index.js";
11
11
 
12
12
  import {
13
13
  type ChunkDecoder,
@@ -15,7 +15,6 @@ import {
15
15
  getChecked,
16
16
  readStream,
17
17
  } from "./chunkCodecUtilities.js";
18
- import type { IdDecodingContext } from "./chunkDecoding.js";
19
18
  import type { IncrementalDecoder } from "./codecs.js";
20
19
  import type { EncodedFieldBatchGeneric, IdentifierOrIndex } from "./format/index.js";
21
20
 
@@ -4,12 +4,7 @@
4
4
  */
5
5
 
6
6
  import { assert, unreachableCase } from "@fluidframework/core-utils/internal";
7
- import type {
8
- IIdCompressor,
9
- OpSpaceCompressedId,
10
- SessionId,
11
- SessionSpaceCompressedId,
12
- } from "@fluidframework/id-compressor";
7
+ import type { IIdCompressor } from "@fluidframework/id-compressor";
13
8
  import { lowestMinVersionForCollab } from "@fluidframework/runtime-utils/internal";
14
9
  import type { TSchema } from "@sinclair/typebox";
15
10
 
@@ -29,13 +24,14 @@ import {
29
24
  } from "../../../core/index.js";
30
25
  import {
31
26
  brandedNumberType,
32
- forceDecodeEncodedIdWithoutSession,
27
+ IdDecodingContext,
33
28
  type Brand,
34
- type IdentifierHealingConfig,
29
+ type IdDecoderOptionsOriginatorless,
30
+ type IdDecoderOptionsWithOriginator,
35
31
  } from "../../../util/index.js";
36
32
  import { TreeCompressionStrategy } from "../../treeCompressionUtils.js";
37
33
 
38
- import { decode, type IdDecodingContext } from "./chunkDecoding.js";
34
+ import { decode } from "./chunkDecoding.js";
39
35
  import type { FieldBatch } from "./fieldBatch.js";
40
36
  import {
41
37
  EncodedFieldBatchV1,
@@ -148,26 +144,18 @@ export interface FieldBatchEncodingContext {
148
144
  * op-style and summary-style decoding is load-bearing (different invariants
149
145
  * apply, and bugs in this area are typically the result of conflating them).
150
146
  */
151
- export class FieldBatchDecodingContext implements IdDecodingContext {
147
+ export class FieldBatchDecodingContext extends IdDecodingContext {
152
148
  private constructor(
153
- /**
154
- * Used internally to prevent the use of this decoder in incremental chunks if it has a session id (which would be wrong in those chunks).
155
- */
156
- private readonly hasOriginatorSessionId: boolean,
157
-
158
- public readonly idCompressor: Pick<IIdCompressor, "decompress">,
159
-
160
- public readonly resolveEncodedId: (
161
- id: OpSpaceCompressedId,
162
- ) => SessionSpaceCompressedId | string,
163
-
149
+ private readonly options: IdDecoderOptionsOriginatorless | IdDecoderOptionsWithOriginator,
164
150
  /**
165
151
  * Decoder for incremental fields. Defined when the encoded batch contains
166
152
  * incremental chunks. Only populated on summary-style contexts; op-style
167
153
  * contexts always have this undefined.
168
154
  */
169
155
  public readonly incrementalDecoder?: IncrementalDecoder,
170
- ) {}
156
+ ) {
157
+ super(options);
158
+ }
171
159
 
172
160
  /**
173
161
  * Construct a decode context for an op.
@@ -178,14 +166,8 @@ export class FieldBatchDecodingContext implements IdDecodingContext {
178
166
  * not a recoverable state, so the resolver throws rather than synthesizing
179
167
  * a UUID. Incremental decoding is not used for ops.
180
168
  */
181
- public static forOp(opts: {
182
- readonly idCompressor: IIdCompressor;
183
- readonly originatorId: SessionId;
184
- }): FieldBatchDecodingContext {
185
- const { idCompressor, originatorId } = opts;
186
- return new FieldBatchDecodingContext(true, idCompressor, (id) =>
187
- idCompressor.normalizeToSessionSpace(id, originatorId),
188
- );
169
+ public static forOp(options: IdDecoderOptionsWithOriginator): FieldBatchDecodingContext {
170
+ return new FieldBatchDecodingContext(options);
189
171
  }
190
172
 
191
173
  /**
@@ -204,14 +186,10 @@ export class FieldBatchDecodingContext implements IdDecodingContext {
204
186
  * `withIncrementalDecoder` has logic to guard against cases which expect session-relative identifiers in incremental chunks,
205
187
  * as does the encoding-side assert in the {@link EncoderContext}.
206
188
  */
207
- public static forSummary(opts: {
208
- readonly idCompressor: IIdCompressor;
209
- readonly healing?: IdentifierHealingConfig;
210
- }): FieldBatchDecodingContext {
211
- const { idCompressor, healing } = opts;
212
- return new FieldBatchDecodingContext(false, idCompressor, (id) =>
213
- forceDecodeEncodedIdWithoutSession(id, idCompressor, healing),
214
- );
189
+ public static forSummary(
190
+ options: IdDecoderOptionsOriginatorless | IdDecoderOptionsWithOriginator,
191
+ ): FieldBatchDecodingContext {
192
+ return new FieldBatchDecodingContext(options);
215
193
  }
216
194
 
217
195
  /**
@@ -231,12 +209,7 @@ export class FieldBatchDecodingContext implements IdDecodingContext {
231
209
  !this.hasOriginatorSessionId,
232
210
  0xd0c /* withIncrementalDecoder can only be called on contexts without an originator session ID */,
233
211
  );
234
- return new FieldBatchDecodingContext(
235
- false,
236
- this.idCompressor,
237
- this.resolveEncodedId,
238
- incrementalDecoder,
239
- );
212
+ return new FieldBatchDecodingContext(this.options, incrementalDecoder);
240
213
  }
241
214
  }
242
215
 
@@ -38,7 +38,7 @@ export const noChangeHandler: FieldChangeHandler<0> = {
38
38
  compose: (change1: 0, change2: 0) => 0,
39
39
  invert: (changes: 0) => 0,
40
40
  rebase: (change: 0, over: 0) => 0,
41
- mute: (changes: 0) => 0,
41
+ filterEdits: (changes: 0) => 0,
42
42
  }),
43
43
  codecsFactory: () => noChangeCodecFamily,
44
44
  editor: { buildChildChanges: () => fail(0xb0d /* Child changes not supported */) },
@@ -93,6 +93,7 @@ export {
93
93
  isNeverTree,
94
94
  DefaultRevisionReplacer,
95
95
  ModularChangeFormatVersion,
96
+ minimizeModularChangeset,
96
97
  } from "./modular-schema/index.js";
97
98
 
98
99
  export { mapRootChanges } from "./deltaUtils.js";
@@ -149,6 +150,7 @@ export {
149
150
 
150
151
  export {
151
152
  SchemaValidationError,
153
+ type SchemaValidationErrorContext,
152
154
  isNodeInSchema,
153
155
  isFieldInSchema,
154
156
  throwOutOfSchema,
@@ -5,6 +5,7 @@
5
5
 
6
6
  import type { ICodecFamily, JsonCodecPart } from "../../codec/index.js";
7
7
  import type {
8
+ ChangeAtomId,
8
9
  ChangeEncodingContext,
9
10
  DeltaDetachedNodeChanges,
10
11
  DeltaDetachedNodeId,
@@ -16,7 +17,7 @@ import type {
16
17
  RevisionTag,
17
18
  RevisionTagSchema,
18
19
  } from "../../core/index.js";
19
- import type { IdAllocator, Invariant } from "../../util/index.js";
20
+ import type { IdAllocator, Invariant, RangeQueryResult } from "../../util/index.js";
20
21
 
21
22
  import type { CrossFieldManager } from "./crossFieldQueries.js";
22
23
  import type { EncodedNodeChangeset } from "./modularChangeFormatV1.js";
@@ -167,10 +168,53 @@ export interface FieldChangeRebaser<TChangeset> {
167
168
  replaceRevisions(change: TChangeset, replacer: RevisionReplacer): TChangeset;
168
169
 
169
170
  /**
170
- * Returns a copy of the given changeset with the same declarations (e.g., new cells) but no actual changes.
171
- * This is a kludge. TODO: remove once AB#46104 is completed.
171
+ * Returns a copy of the given changeset with edits removed as specified.
172
+ * @param change - The change to filter edits from
173
+ * @param filterDetach - This should be called for each range of detaches in the changeset,
174
+ * and the detach should be preserved, removed, or converted to a non-move detach as specified.
175
+ * If the returned result does not cover the entire detach range, the remainder should be queried again.
176
+ * @param filterDetach - This should be called for each range of attaches in the changeset,
177
+ * and the attach should be preserved, removed, or converted to a non-move attach as specified.
178
+ * If the returned result does not cover the entire detach range, the remainder should be queried again.
179
+ * @param preserveOtherEdits - Whether edits other than attaches and detaches (e.g. root renames),
180
+ * should be preserved or removed.
172
181
  */
173
- mute(change: TChangeset): TChangeset;
182
+ filterEdits(
183
+ change: TChangeset,
184
+ options: {
185
+ filterDetach: EditFilterFunc;
186
+ filterAttach: EditFilterFunc;
187
+ preserveOtherEdits: boolean;
188
+ },
189
+ ): TChangeset;
190
+ }
191
+
192
+ export type EditFilterFunc = (
193
+ id: ChangeAtomId,
194
+ count: number,
195
+ endpoint?: ChangeAtomId,
196
+ ) => RangeQueryResult<EditFilterStatus>;
197
+
198
+ /**
199
+ * Used to describe what should be done with a particular attach or detach during `filterEdits`.
200
+ */
201
+ export enum EditFilterStatus {
202
+ /**
203
+ * The edit should be removed from the filtered changeset.
204
+ */
205
+ Remove,
206
+
207
+ /**
208
+ * The edit should be preserved in the filtered changeset.
209
+ */
210
+ Preserve,
211
+
212
+ /**
213
+ * This should only be used for an attach or detach which is part of a move.
214
+ * The edit should be preserved, but should be adjusted, if necessary,
215
+ * to reflect that the other endpoint of the move has been filtered out.
216
+ */
217
+ PreserveWithoutMove,
174
218
  }
175
219
 
176
220
  /**
@@ -181,13 +225,13 @@ export function referenceFreeFieldChangeRebaser<TChangeset>(data: {
181
225
  compose: (change1: TChangeset, change2: TChangeset) => TChangeset;
182
226
  invert: (change: TChangeset) => TChangeset;
183
227
  rebase: (change: TChangeset, over: TChangeset) => TChangeset;
184
- mute: (change: TChangeset) => TChangeset;
228
+ filterEdits: FieldChangeRebaser<TChangeset>["filterEdits"];
185
229
  }): FieldChangeRebaser<TChangeset> {
186
230
  return isolatedFieldChangeRebaser({
187
231
  compose: (change1, change2, _composeChild, _genId) => data.compose(change1, change2),
188
232
  invert: (change, _invertChild, _genId) => data.invert(change),
189
233
  rebase: (change, over, _rebaseChild, _genId) => data.rebase(change, over),
190
- mute: (change) => data.mute(change),
234
+ filterEdits: (change, options) => data.filterEdits(change, options),
191
235
  });
192
236
  }
193
237
 
@@ -195,7 +239,7 @@ export function isolatedFieldChangeRebaser<TChangeset>(data: {
195
239
  compose: FieldChangeRebaser<TChangeset>["compose"];
196
240
  invert: FieldChangeRebaser<TChangeset>["invert"];
197
241
  rebase: FieldChangeRebaser<TChangeset>["rebase"];
198
- mute: FieldChangeRebaser<TChangeset>["mute"];
242
+ filterEdits: FieldChangeRebaser<TChangeset>["filterEdits"];
199
243
  }): FieldChangeRebaser<TChangeset> {
200
244
  return {
201
245
  ...data,
@@ -40,7 +40,7 @@ export const genericChangeHandler: FieldChangeHandler<GenericChangeset> = {
40
40
  rebase: rebaseGenericChange,
41
41
  prune: pruneGenericChange,
42
42
  replaceRevisions,
43
- mute: (change: GenericChangeset): GenericChangeset => change,
43
+ filterEdits: (change: GenericChangeset): GenericChangeset => change,
44
44
  },
45
45
  codecsFactory: makeGenericChangeCodec,
46
46
  editor: {
@@ -29,10 +29,14 @@ export {
29
29
  export { EncodedModularChangesetV2 } from "./modularChangeFormatV2.js";
30
30
  export { FlexFieldKind, type FullSchemaPolicy } from "./fieldKind.js";
31
31
  export {
32
+ type EditFilterFunc,
33
+ EditFilterStatus,
32
34
  type FieldChangeHandler,
33
35
  type FieldChangeDelta,
36
+ type FieldChangeEncodingContext,
34
37
  type FieldChangeRebaser,
35
38
  type FieldEditor,
39
+ type NestedChangesIndices,
36
40
  type NodeChangeComposer,
37
41
  type NodeChangeInverter,
38
42
  type NodeChangeRebaser,
@@ -42,8 +46,6 @@ export {
42
46
  type RelevantRemovedRootsFromChild,
43
47
  type ToDelta,
44
48
  NodeAttachState,
45
- type FieldChangeEncodingContext,
46
- type NestedChangesIndices,
47
49
  } from "./fieldChangeHandler.js";
48
50
  export type {
49
51
  CrossFieldKey,
@@ -83,3 +85,4 @@ export type {
83
85
  FieldKindConfigurationEntry,
84
86
  } from "./fieldKindConfiguration.js";
85
87
  export { DefaultRevisionReplacer } from "./defaultRevisionReplacer.js";
88
+ export { minimizeModularChangeset } from "./minimizeModularChange.js";
@@ -0,0 +1,33 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+
6
+ import type { FieldKindIdentifier } from "../../core/index.js";
7
+
8
+ import type { FlexFieldKind } from "./fieldKind.js";
9
+ import type { ModularChangeset } from "./modularChangeTypes.js";
10
+
11
+ /**
12
+ * "Minimizes" a {@link ModularChangeset} so that it contains no extraneous
13
+ * information, i.e. no new content that isn't observable from document tree
14
+ * and no edits without net observed effect on the document tree.
15
+ * @remarks
16
+ * "Extraneous information" includes, for example, data for nodes that were both created and removed within the same
17
+ * transaction, or changes whose effects cancel out to nothing. Minimizing reduces the size of an edit without altering
18
+ * its observable effect.
19
+ *
20
+ * This is the eventual home of the minimization algorithm, colocated with {@link ModularChangeFamily} so it can use its
21
+ * internals. It is currently a no-op that returns the change unchanged; a real implementation will be provided in a
22
+ * future change.
23
+ *
24
+ * @param change - The change to minimize.
25
+ * @param fieldKinds - The field kinds to delegate to when computing the change's delta.
26
+ */
27
+ export function minimizeModularChangeset(
28
+ change: ModularChangeset,
29
+ fieldKinds: ReadonlyMap<FieldKindIdentifier, FlexFieldKind>,
30
+ ): ModularChangeset {
31
+ // TODO: Actually minimize the change. For now this is a no-op that returns the change unchanged.
32
+ return change;
33
+ }
@@ -82,6 +82,7 @@ import {
82
82
  setInCrossFieldMap,
83
83
  } from "./crossFieldQueries.js";
84
84
  import {
85
+ EditFilterStatus,
85
86
  type FieldChangeHandler,
86
87
  NodeAttachState,
87
88
  type RebaseRevisionMetadata,
@@ -1739,11 +1740,25 @@ export class ModularChangeFamily
1739
1740
  const handler = getChangeHandler(this.fieldKinds, change.fieldKind);
1740
1741
  return {
1741
1742
  fieldKind: change.fieldKind,
1742
- change: brand(handler.rebaser.mute(change.change)),
1743
+ change: brand(
1744
+ handler.rebaser.filterEdits(change.change, {
1745
+ filterDetach: removeAllEditsFilter,
1746
+ filterAttach: removeAllEditsFilter,
1747
+ preserveOtherEdits: false,
1748
+ }),
1749
+ ),
1743
1750
  };
1744
1751
  }
1745
1752
  }
1746
1753
 
1754
+ function removeAllEditsFilter(
1755
+ _id: ChangeAtomId,
1756
+ count: number,
1757
+ _endpointId?: ChangeAtomId,
1758
+ ): RangeQueryResult<EditFilterStatus> {
1759
+ return { value: EditFilterStatus.Remove, length: count };
1760
+ }
1761
+
1747
1762
  function replaceCrossFieldKeyTableRevisions(
1748
1763
  table: CrossFieldKeyTable,
1749
1764
  replacer: RevisionReplacer,
@@ -35,6 +35,7 @@ import {
35
35
  requiredIdentifier,
36
36
  } from "../fieldKindIdentifiers.js";
37
37
  import {
38
+ EditFilterStatus,
38
39
  type FieldChangeHandler,
39
40
  type FieldChangeRebaser,
40
41
  type FieldEditor,
@@ -48,6 +49,7 @@ import {
48
49
  type NestedChangesIndices,
49
50
  type FieldChangeDelta,
50
51
  FlexFieldKind,
52
+ type EditFilterFunc,
51
53
  } from "../modular-schema/index.js";
52
54
 
53
55
  import type {
@@ -466,9 +468,7 @@ export const optionalChangeRebaser: FieldChangeRebaser<OptionalChangeset> = {
466
468
  return updated;
467
469
  },
468
470
 
469
- mute: (change: OptionalChangeset): OptionalChangeset => {
470
- return { childChanges: change.childChanges, moves: [] };
471
- },
471
+ filterEdits,
472
472
  };
473
473
 
474
474
  function replaceReplaceRevisions(
@@ -814,3 +814,43 @@ export const optional: Optional = new FlexFieldKind(
814
814
  ]),
815
815
  },
816
816
  );
817
+
818
+ function filterEdits(
819
+ change: OptionalChangeset,
820
+ options: {
821
+ filterDetach: EditFilterFunc;
822
+ filterAttach: EditFilterFunc;
823
+ preserveOtherEdits: boolean;
824
+ },
825
+ ): OptionalChangeset {
826
+ const filtered: Mutable<OptionalChangeset> = { ...change };
827
+ if (filtered.valueReplace !== undefined) {
828
+ if (isReplaceEffectful(filtered.valueReplace)) {
829
+ const detachId = getEffectfulDst(filtered.valueReplace);
830
+ const detachResult =
831
+ detachId === undefined ? undefined : options.filterDetach(detachId, 1).value;
832
+
833
+ const attachId = filtered.valueReplace.src;
834
+ const attachResult =
835
+ attachId === undefined ? undefined : options.filterAttach(attachId, 1).value;
836
+
837
+ if (detachResult === EditFilterStatus.Remove) {
838
+ assert(
839
+ attachId === undefined || attachResult === EditFilterStatus.Remove,
840
+ "Cannot remove detach without also removing attach",
841
+ );
842
+
843
+ delete filtered.valueReplace;
844
+ } else if (attachResult === EditFilterStatus.Remove) {
845
+ delete filtered.valueReplace.src;
846
+ }
847
+ } else if (!options.preserveOtherEdits) {
848
+ delete filtered.valueReplace;
849
+ }
850
+ }
851
+
852
+ if (!options.preserveOtherEdits) {
853
+ filtered.moves = [];
854
+ }
855
+ return filtered;
856
+ }
@@ -32,13 +32,82 @@ export enum SchemaValidationError {
32
32
  Node_MissingSchema,
33
33
  }
34
34
 
35
+ /**
36
+ * Additional context about a schema validation error.
37
+ * @remarks
38
+ * Not all fields are populated for every error type — only those relevant to the specific error.
39
+ */
40
+ export interface SchemaValidationErrorContext {
41
+ /**
42
+ * The type identifier of the node that failed validation.
43
+ */
44
+ readonly nodeType?: string;
45
+ /**
46
+ * The set of type identifiers allowed in the field, if applicable.
47
+ */
48
+ readonly allowedTypes?: ReadonlySet<string>;
49
+ /**
50
+ * Field keys on the node that were not recognized by its schema.
51
+ */
52
+ readonly unexpectedFields?: ReadonlySet<string>;
53
+ }
54
+
35
55
  /**
36
56
  * Throws a UsageError indicating a tree is out of schema.
37
57
  */
38
- export function throwOutOfSchema(maybeError: SchemaValidationError): never {
39
- throw new UsageError(
40
- `Tree does not conform to schema: ${SchemaValidationError[maybeError]}`,
41
- );
58
+ export function throwOutOfSchema(
59
+ maybeError: SchemaValidationError,
60
+ context?: SchemaValidationErrorContext,
61
+ ): never {
62
+ throw new UsageError(formatSchemaValidationError(maybeError, context));
63
+ }
64
+
65
+ // Not exported: internal helper used by throwOutOfSchema.
66
+ function formatSchemaValidationError(
67
+ error: SchemaValidationError,
68
+ context: SchemaValidationErrorContext | undefined,
69
+ ): string {
70
+ switch (error) {
71
+ case SchemaValidationError.Field_NodeTypeNotAllowed: {
72
+ const nodeDesc = context?.nodeType === undefined ? "unknown" : `"${context.nodeType}"`;
73
+ const allowedDesc =
74
+ context?.allowedTypes === undefined
75
+ ? "unknown"
76
+ : `[${[...context.allowedTypes].map((t) => `"${t}"`).join(", ")}]`;
77
+ return (
78
+ `Tree does not conform to schema. ` +
79
+ `A node of type ${nodeDesc} is not allowed in this field. Allowed types: ${allowedDesc}. ` +
80
+ `If using a staged allowed type, the stored schema has not been upgraded to include this type yet. ` +
81
+ `Either upgrade the schema to enable the staged type or avoid inserting content of this type until the schema is upgraded.`
82
+ );
83
+ }
84
+ case SchemaValidationError.Node_MissingSchema: {
85
+ const nodeDesc = context?.nodeType === undefined ? "unknown" : `"${context.nodeType}"`;
86
+ return (
87
+ `Tree does not conform to schema. ` +
88
+ `No schema definition was found for node type ${nodeDesc}. ` +
89
+ `Ensure the node's type is included in the schema and that the stored schema has been upgraded if needed.`
90
+ );
91
+ }
92
+ case SchemaValidationError.ObjectNode_FieldNotInSchema: {
93
+ const nodeDesc = context?.nodeType === undefined ? "unknown" : `"${context.nodeType}"`;
94
+ const fieldsDesc =
95
+ context?.unexpectedFields === undefined || context.unexpectedFields.size === 0
96
+ ? undefined
97
+ : `[${[...context.unexpectedFields].map((f) => `"${f}"`).join(", ")}]`;
98
+ const fieldsPart =
99
+ fieldsDesc === undefined
100
+ ? "The node has fields that are not defined in its schema."
101
+ : `Unexpected fields: ${fieldsDesc}.`;
102
+ return (
103
+ `Tree does not conform to schema. ` +
104
+ `A node of type ${nodeDesc} has fields not defined in its schema. ${fieldsPart}`
105
+ );
106
+ }
107
+ default: {
108
+ return `Tree does not conform to schema: ${SchemaValidationError[error]}.`;
109
+ }
110
+ }
42
111
  }
43
112
 
44
113
  type NotUndefined = number | string | boolean | bigint | symbol | object;
@@ -53,12 +122,14 @@ type NotUndefined = number | string | boolean | bigint | symbol | object;
53
122
  export function isNodeInSchema<T extends NotUndefined>(
54
123
  node: MinimalMapTreeNodeView,
55
124
  schemaAndPolicy: SchemaAndPolicy,
56
- onError: (error: SchemaValidationError) => T,
125
+ onError: (error: SchemaValidationError, context?: SchemaValidationErrorContext) => T,
57
126
  ): T | undefined {
58
127
  // Validate the schema declared by the node exists
59
128
  const schema = schemaAndPolicy.schema.nodeSchema.get(node.type);
60
129
  if (schema === undefined) {
61
- return onError(SchemaValidationError.Node_MissingSchema);
130
+ return onError(SchemaValidationError.Node_MissingSchema, {
131
+ nodeType: node.type,
132
+ });
62
133
  }
63
134
 
64
135
  // Validate the node is well formed according to its schema
@@ -95,7 +166,10 @@ export function isNodeInSchema<T extends NotUndefined>(
95
166
  // Code using this with a stored schema derived from a view schema rather than the document can be problematic because it may be missing unknown fields that the actual document has.
96
167
  // Other schema evolution features like "staged" allowed types will likely cause similar issues elsewhere in this checker.
97
168
  if (uncheckedFieldsFromNode.size > 0) {
98
- return onError(SchemaValidationError.ObjectNode_FieldNotInSchema);
169
+ return onError(SchemaValidationError.ObjectNode_FieldNotInSchema, {
170
+ nodeType: node.type,
171
+ unexpectedFields: uncheckedFieldsFromNode,
172
+ });
99
173
  }
100
174
  } else if (schema instanceof MapNodeStoredSchema) {
101
175
  for (const [_key, field] of node.fields) {
@@ -128,7 +202,7 @@ export function isFieldInSchema<T extends NotUndefined>(
128
202
  childNodes: MapTreeFieldViewGeneric<MinimalMapTreeNodeView>,
129
203
  schema: TreeFieldStoredSchema,
130
204
  schemaAndPolicy: SchemaAndPolicy,
131
- onError: (error: SchemaValidationError) => T,
205
+ onError: (error: SchemaValidationError, context?: SchemaValidationErrorContext) => T,
132
206
  ): T | undefined {
133
207
  // Validate that the field kind is handled by the schema policy
134
208
  const kind = schemaAndPolicy.policy.fieldKinds.get(schema.kind);
@@ -147,7 +221,10 @@ export function isFieldInSchema<T extends NotUndefined>(
147
221
  for (const node of childNodes) {
148
222
  // Validate the type declared by the node is allowed in this field
149
223
  if (schema.types !== undefined && !schema.types.has(node.type)) {
150
- return onError(SchemaValidationError.Field_NodeTypeNotAllowed);
224
+ return onError(SchemaValidationError.Field_NodeTypeNotAllowed, {
225
+ nodeType: node.type,
226
+ allowedTypes: schema.types,
227
+ });
151
228
  }
152
229
 
153
230
  // Validate the node complies with the type it declares to be.