@fluidframework/tree 2.113.1 → 2.115.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (660) hide show
  1. package/CHANGELOG.md +289 -0
  2. package/api-report/tree.alpha.api.md +127 -39
  3. package/dist/core/change-family/changeFamily.d.ts +15 -4
  4. package/dist/core/change-family/changeFamily.d.ts.map +1 -1
  5. package/dist/core/change-family/changeFamily.js.map +1 -1
  6. package/dist/core/change-family/editBuilder.d.ts +2 -3
  7. package/dist/core/change-family/editBuilder.d.ts.map +1 -1
  8. package/dist/core/change-family/editBuilder.js +1 -2
  9. package/dist/core/change-family/editBuilder.js.map +1 -1
  10. package/dist/core/change-family/index.d.ts +1 -1
  11. package/dist/core/change-family/index.d.ts.map +1 -1
  12. package/dist/core/change-family/index.js.map +1 -1
  13. package/dist/core/index.d.ts +4 -3
  14. package/dist/core/index.d.ts.map +1 -1
  15. package/dist/core/index.js +3 -2
  16. package/dist/core/index.js.map +1 -1
  17. package/dist/core/rebase/index.d.ts +1 -1
  18. package/dist/core/rebase/index.d.ts.map +1 -1
  19. package/dist/core/rebase/index.js +2 -1
  20. package/dist/core/rebase/index.js.map +1 -1
  21. package/dist/core/rebase/types.d.ts +110 -0
  22. package/dist/core/rebase/types.d.ts.map +1 -1
  23. package/dist/core/rebase/types.js +47 -1
  24. package/dist/core/rebase/types.js.map +1 -1
  25. package/dist/core/tree/delta.d.ts +62 -16
  26. package/dist/core/tree/delta.d.ts.map +1 -1
  27. package/dist/core/tree/delta.js.map +1 -1
  28. package/dist/core/tree/detachedFieldIndex.d.ts +7 -13
  29. package/dist/core/tree/detachedFieldIndex.d.ts.map +1 -1
  30. package/dist/core/tree/detachedFieldIndex.js +32 -46
  31. package/dist/core/tree/detachedFieldIndex.js.map +1 -1
  32. package/dist/core/tree/index.d.ts +1 -0
  33. package/dist/core/tree/index.d.ts.map +1 -1
  34. package/dist/core/tree/index.js.map +1 -1
  35. package/dist/core/tree/visitorUtils.d.ts +2 -4
  36. package/dist/core/tree/visitorUtils.d.ts.map +1 -1
  37. package/dist/core/tree/visitorUtils.js +2 -2
  38. package/dist/core/tree/visitorUtils.js.map +1 -1
  39. package/dist/entrypoints/alpha.d.ts +1 -1
  40. package/dist/entrypoints/alpha.d.ts.map +1 -1
  41. package/dist/entrypoints/alpha.js +8 -3
  42. package/dist/entrypoints/alpha.js.map +1 -1
  43. package/dist/feature-libraries/chunked-forest/codec/codecs.d.ts +9 -6
  44. package/dist/feature-libraries/chunked-forest/codec/codecs.d.ts.map +1 -1
  45. package/dist/feature-libraries/chunked-forest/codec/codecs.js +16 -13
  46. package/dist/feature-libraries/chunked-forest/codec/codecs.js.map +1 -1
  47. package/dist/feature-libraries/chunked-forest/uniformChunk.d.ts.map +1 -1
  48. package/dist/feature-libraries/chunked-forest/uniformChunk.js +10 -2
  49. package/dist/feature-libraries/chunked-forest/uniformChunk.js.map +1 -1
  50. package/dist/feature-libraries/comparison-forest/comparisonForest.d.ts +51 -0
  51. package/dist/feature-libraries/comparison-forest/comparisonForest.d.ts.map +1 -0
  52. package/dist/feature-libraries/comparison-forest/comparisonForest.js +98 -0
  53. package/dist/feature-libraries/comparison-forest/comparisonForest.js.map +1 -0
  54. package/dist/feature-libraries/comparison-forest/index.d.ts +6 -0
  55. package/dist/feature-libraries/comparison-forest/index.d.ts.map +1 -0
  56. package/dist/feature-libraries/comparison-forest/index.js +10 -0
  57. package/dist/feature-libraries/comparison-forest/index.js.map +1 -0
  58. package/dist/feature-libraries/default-schema/defaultEditBuilder.d.ts +8 -6
  59. package/dist/feature-libraries/default-schema/defaultEditBuilder.d.ts.map +1 -1
  60. package/dist/feature-libraries/default-schema/defaultEditBuilder.js +6 -3
  61. package/dist/feature-libraries/default-schema/defaultEditBuilder.js.map +1 -1
  62. package/dist/feature-libraries/default-schema/index.d.ts +1 -1
  63. package/dist/feature-libraries/default-schema/index.d.ts.map +1 -1
  64. package/dist/feature-libraries/default-schema/index.js.map +1 -1
  65. package/dist/feature-libraries/default-schema/noChangeCodecs.d.ts +2 -2
  66. package/dist/feature-libraries/default-schema/noChangeCodecs.d.ts.map +1 -1
  67. package/dist/feature-libraries/default-schema/noChangeCodecs.js +3 -1
  68. package/dist/feature-libraries/default-schema/noChangeCodecs.js.map +1 -1
  69. package/dist/feature-libraries/detachedFieldIndexSummarizer.d.ts +6 -3
  70. package/dist/feature-libraries/detachedFieldIndexSummarizer.d.ts.map +1 -1
  71. package/dist/feature-libraries/detachedFieldIndexSummarizer.js +18 -6
  72. package/dist/feature-libraries/detachedFieldIndexSummarizer.js.map +1 -1
  73. package/dist/feature-libraries/forest-summary/forestSummarizer.d.ts +2 -3
  74. package/dist/feature-libraries/forest-summary/forestSummarizer.d.ts.map +1 -1
  75. package/dist/feature-libraries/forest-summary/forestSummarizer.js +2 -3
  76. package/dist/feature-libraries/forest-summary/forestSummarizer.js.map +1 -1
  77. package/dist/feature-libraries/index.d.ts +4 -3
  78. package/dist/feature-libraries/index.d.ts.map +1 -1
  79. package/dist/feature-libraries/index.js +77 -72
  80. package/dist/feature-libraries/index.js.map +1 -1
  81. package/dist/feature-libraries/mitigatedChangeFamily.d.ts +1 -1
  82. package/dist/feature-libraries/mitigatedChangeFamily.d.ts.map +1 -1
  83. package/dist/feature-libraries/mitigatedChangeFamily.js +12 -0
  84. package/dist/feature-libraries/mitigatedChangeFamily.js.map +1 -1
  85. package/dist/feature-libraries/modular-schema/fieldChangeHandler.d.ts +9 -1
  86. package/dist/feature-libraries/modular-schema/fieldChangeHandler.d.ts.map +1 -1
  87. package/dist/feature-libraries/modular-schema/fieldChangeHandler.js.map +1 -1
  88. package/dist/feature-libraries/modular-schema/genericFieldKindCodecs.d.ts +2 -2
  89. package/dist/feature-libraries/modular-schema/genericFieldKindCodecs.d.ts.map +1 -1
  90. package/dist/feature-libraries/modular-schema/genericFieldKindCodecs.js.map +1 -1
  91. package/dist/feature-libraries/modular-schema/index.d.ts +1 -1
  92. package/dist/feature-libraries/modular-schema/index.d.ts.map +1 -1
  93. package/dist/feature-libraries/modular-schema/index.js.map +1 -1
  94. package/dist/feature-libraries/modular-schema/invert.d.ts +15 -0
  95. package/dist/feature-libraries/modular-schema/invert.d.ts.map +1 -0
  96. package/dist/feature-libraries/modular-schema/invert.js +159 -0
  97. package/dist/feature-libraries/modular-schema/invert.js.map +1 -0
  98. package/dist/feature-libraries/modular-schema/minimizeModularChange.d.ts +3 -4
  99. package/dist/feature-libraries/modular-schema/minimizeModularChange.d.ts.map +1 -1
  100. package/dist/feature-libraries/modular-schema/minimizeModularChange.js +2 -2
  101. package/dist/feature-libraries/modular-schema/minimizeModularChange.js.map +1 -1
  102. package/dist/feature-libraries/modular-schema/modularChangeCodecV1.d.ts +9 -9
  103. package/dist/feature-libraries/modular-schema/modularChangeCodecV1.d.ts.map +1 -1
  104. package/dist/feature-libraries/modular-schema/modularChangeCodecV1.js +0 -2
  105. package/dist/feature-libraries/modular-schema/modularChangeCodecV1.js.map +1 -1
  106. package/dist/feature-libraries/modular-schema/modularChangeCodecV2.d.ts +2 -2
  107. package/dist/feature-libraries/modular-schema/modularChangeCodecV2.d.ts.map +1 -1
  108. package/dist/feature-libraries/modular-schema/modularChangeCodecV2.js.map +1 -1
  109. package/dist/feature-libraries/modular-schema/modularChangeCodecs.d.ts +2 -2
  110. package/dist/feature-libraries/modular-schema/modularChangeCodecs.d.ts.map +1 -1
  111. package/dist/feature-libraries/modular-schema/modularChangeCodecs.js.map +1 -1
  112. package/dist/feature-libraries/modular-schema/modularChangeFamily.d.ts +8 -22
  113. package/dist/feature-libraries/modular-schema/modularChangeFamily.d.ts.map +1 -1
  114. package/dist/feature-libraries/modular-schema/modularChangeFamily.js +53 -406
  115. package/dist/feature-libraries/modular-schema/modularChangeFamily.js.map +1 -1
  116. package/dist/feature-libraries/modular-schema/modularChangeUtils.d.ts +61 -0
  117. package/dist/feature-libraries/modular-schema/modularChangeUtils.d.ts.map +1 -0
  118. package/dist/feature-libraries/modular-schema/modularChangeUtils.js +205 -0
  119. package/dist/feature-libraries/modular-schema/modularChangeUtils.js.map +1 -0
  120. package/dist/feature-libraries/modular-schema/prune.d.ts +10 -0
  121. package/dist/feature-libraries/modular-schema/prune.d.ts.map +1 -0
  122. package/dist/feature-libraries/modular-schema/prune.js +49 -0
  123. package/dist/feature-libraries/modular-schema/prune.js.map +1 -0
  124. package/dist/feature-libraries/optional-field/optionalFieldCodecV2.d.ts +2 -2
  125. package/dist/feature-libraries/optional-field/optionalFieldCodecV2.d.ts.map +1 -1
  126. package/dist/feature-libraries/optional-field/optionalFieldCodecV2.js.map +1 -1
  127. package/dist/feature-libraries/optional-field/optionalFieldCodecs.d.ts +2 -2
  128. package/dist/feature-libraries/optional-field/optionalFieldCodecs.d.ts.map +1 -1
  129. package/dist/feature-libraries/optional-field/optionalFieldCodecs.js.map +1 -1
  130. package/dist/feature-libraries/sequence-field/sequenceFieldCodecV2.d.ts +2 -2
  131. package/dist/feature-libraries/sequence-field/sequenceFieldCodecV2.d.ts.map +1 -1
  132. package/dist/feature-libraries/sequence-field/sequenceFieldCodecV2.js.map +1 -1
  133. package/dist/feature-libraries/sequence-field/sequenceFieldCodecV3.d.ts +2 -2
  134. package/dist/feature-libraries/sequence-field/sequenceFieldCodecV3.d.ts.map +1 -1
  135. package/dist/feature-libraries/sequence-field/sequenceFieldCodecV3.js.map +1 -1
  136. package/dist/feature-libraries/sequence-field/sequenceFieldCodecs.d.ts +2 -2
  137. package/dist/feature-libraries/sequence-field/sequenceFieldCodecs.d.ts.map +1 -1
  138. package/dist/feature-libraries/sequence-field/sequenceFieldCodecs.js.map +1 -1
  139. package/dist/feature-libraries/treeTextCursor.d.ts +15 -0
  140. package/dist/feature-libraries/treeTextCursor.d.ts.map +1 -1
  141. package/dist/feature-libraries/treeTextCursor.js +64 -1
  142. package/dist/feature-libraries/treeTextCursor.js.map +1 -1
  143. package/dist/index.d.ts +6 -4
  144. package/dist/index.d.ts.map +1 -1
  145. package/dist/index.js +10 -5
  146. package/dist/index.js.map +1 -1
  147. package/dist/packageVersion.d.ts +1 -1
  148. package/dist/packageVersion.js +1 -1
  149. package/dist/packageVersion.js.map +1 -1
  150. package/dist/shared-tree/serializedChange.d.ts +2 -2
  151. package/dist/shared-tree/serializedChange.d.ts.map +1 -1
  152. package/dist/shared-tree/serializedChange.js.map +1 -1
  153. package/dist/shared-tree/sharedTree.d.ts +11 -3
  154. package/dist/shared-tree/sharedTree.d.ts.map +1 -1
  155. package/dist/shared-tree/sharedTree.js +9 -7
  156. package/dist/shared-tree/sharedTree.js.map +1 -1
  157. package/dist/shared-tree/sharedTreeChangeCodecs.d.ts +2 -2
  158. package/dist/shared-tree/sharedTreeChangeCodecs.d.ts.map +1 -1
  159. package/dist/shared-tree/sharedTreeChangeCodecs.js.map +1 -1
  160. package/dist/shared-tree/sharedTreeChangeFamily.d.ts +41 -4
  161. package/dist/shared-tree/sharedTreeChangeFamily.d.ts.map +1 -1
  162. package/dist/shared-tree/sharedTreeChangeFamily.js +57 -1
  163. package/dist/shared-tree/sharedTreeChangeFamily.js.map +1 -1
  164. package/dist/shared-tree/transactionMinimize.d.ts.map +1 -1
  165. package/dist/shared-tree/transactionMinimize.js +2 -2
  166. package/dist/shared-tree/transactionMinimize.js.map +1 -1
  167. package/dist/shared-tree/transactionPostProcessor.d.ts +2 -1
  168. package/dist/shared-tree/transactionPostProcessor.d.ts.map +1 -1
  169. package/dist/shared-tree/transactionPostProcessor.js.map +1 -1
  170. package/dist/shared-tree/treeCheckout.d.ts +13 -7
  171. package/dist/shared-tree/treeCheckout.d.ts.map +1 -1
  172. package/dist/shared-tree/treeCheckout.js +59 -13
  173. package/dist/shared-tree/treeCheckout.js.map +1 -1
  174. package/dist/shared-tree-core/branch.d.ts +24 -9
  175. package/dist/shared-tree-core/branch.d.ts.map +1 -1
  176. package/dist/shared-tree-core/branch.js +7 -0
  177. package/dist/shared-tree-core/branch.js.map +1 -1
  178. package/dist/shared-tree-core/editManager.d.ts +4 -4
  179. package/dist/shared-tree-core/editManager.d.ts.map +1 -1
  180. package/dist/shared-tree-core/editManager.js +2 -0
  181. package/dist/shared-tree-core/editManager.js.map +1 -1
  182. package/dist/shared-tree-core/editManagerCodecs.d.ts +3 -14
  183. package/dist/shared-tree-core/editManagerCodecs.d.ts.map +1 -1
  184. package/dist/shared-tree-core/editManagerCodecs.js.map +1 -1
  185. package/dist/shared-tree-core/editManagerCodecsCommons.d.ts +11 -1
  186. package/dist/shared-tree-core/editManagerCodecsCommons.d.ts.map +1 -1
  187. package/dist/shared-tree-core/editManagerCodecsCommons.js.map +1 -1
  188. package/dist/shared-tree-core/editManagerCodecsV1toV4.d.ts +4 -11
  189. package/dist/shared-tree-core/editManagerCodecsV1toV4.d.ts.map +1 -1
  190. package/dist/shared-tree-core/editManagerCodecsV1toV4.js.map +1 -1
  191. package/dist/shared-tree-core/editManagerCodecsVSharedBranches.d.ts +4 -11
  192. package/dist/shared-tree-core/editManagerCodecsVSharedBranches.d.ts.map +1 -1
  193. package/dist/shared-tree-core/editManagerCodecsVSharedBranches.js.map +1 -1
  194. package/dist/shared-tree-core/editManagerSummarizer.d.ts +4 -4
  195. package/dist/shared-tree-core/editManagerSummarizer.d.ts.map +1 -1
  196. package/dist/shared-tree-core/editManagerSummarizer.js +0 -1
  197. package/dist/shared-tree-core/editManagerSummarizer.js.map +1 -1
  198. package/dist/shared-tree-core/messageCodecV1ToV4.d.ts +2 -2
  199. package/dist/shared-tree-core/messageCodecV1ToV4.d.ts.map +1 -1
  200. package/dist/shared-tree-core/messageCodecV1ToV4.js.map +1 -1
  201. package/dist/shared-tree-core/messageCodecVSharedBranches.d.ts.map +1 -1
  202. package/dist/shared-tree-core/messageCodecVSharedBranches.js.map +1 -1
  203. package/dist/shared-tree-core/messageCodecs.d.ts +8 -1
  204. package/dist/shared-tree-core/messageCodecs.d.ts.map +1 -1
  205. package/dist/shared-tree-core/messageCodecs.js.map +1 -1
  206. package/dist/shared-tree-core/sharedTreeCore.d.ts +5 -5
  207. package/dist/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
  208. package/dist/shared-tree-core/sharedTreeCore.js +1 -1
  209. package/dist/shared-tree-core/sharedTreeCore.js.map +1 -1
  210. package/dist/shared-tree-core/transaction.d.ts +10 -10
  211. package/dist/shared-tree-core/transaction.d.ts.map +1 -1
  212. package/dist/shared-tree-core/transaction.js +6 -3
  213. package/dist/shared-tree-core/transaction.js.map +1 -1
  214. package/dist/simple-tree/api/eraseSchemaDetails.d.ts +15 -0
  215. package/dist/simple-tree/api/eraseSchemaDetails.d.ts.map +1 -1
  216. package/dist/simple-tree/api/eraseSchemaDetails.js +15 -0
  217. package/dist/simple-tree/api/eraseSchemaDetails.js.map +1 -1
  218. package/dist/simple-tree/api/index.d.ts +1 -1
  219. package/dist/simple-tree/api/index.d.ts.map +1 -1
  220. package/dist/simple-tree/api/index.js +2 -3
  221. package/dist/simple-tree/api/index.js.map +1 -1
  222. package/dist/simple-tree/api/schemaFactoryAlpha.d.ts +3 -3
  223. package/dist/simple-tree/api/schemaFactoryAlpha.d.ts.map +1 -1
  224. package/dist/simple-tree/api/schemaStatics.d.ts +6 -7
  225. package/dist/simple-tree/api/schemaStatics.d.ts.map +1 -1
  226. package/dist/simple-tree/api/schemaStatics.js.map +1 -1
  227. package/dist/simple-tree/api/treeNodeApi.d.ts +20 -24
  228. package/dist/simple-tree/api/treeNodeApi.d.ts.map +1 -1
  229. package/dist/simple-tree/api/treeNodeApi.js +48 -49
  230. package/dist/simple-tree/api/treeNodeApi.js.map +1 -1
  231. package/dist/simple-tree/core/treeNode.d.ts +5 -6
  232. package/dist/simple-tree/core/treeNode.d.ts.map +1 -1
  233. package/dist/simple-tree/core/treeNode.js +2 -4
  234. package/dist/simple-tree/core/treeNode.js.map +1 -1
  235. package/dist/simple-tree/core/withType.d.ts +20 -7
  236. package/dist/simple-tree/core/withType.d.ts.map +1 -1
  237. package/dist/simple-tree/core/withType.js +4 -7
  238. package/dist/simple-tree/core/withType.js.map +1 -1
  239. package/dist/simple-tree/index.d.ts +2 -2
  240. package/dist/simple-tree/index.d.ts.map +1 -1
  241. package/dist/simple-tree/index.js +3 -4
  242. package/dist/simple-tree/index.js.map +1 -1
  243. package/dist/simple-tree/leafNodeSchema.d.ts +6 -1
  244. package/dist/simple-tree/leafNodeSchema.d.ts.map +1 -1
  245. package/dist/simple-tree/leafNodeSchema.js +0 -1
  246. package/dist/simple-tree/leafNodeSchema.js.map +1 -1
  247. package/dist/simple-tree/node-kinds/array/arrayNode.d.ts +53 -5
  248. package/dist/simple-tree/node-kinds/array/arrayNode.d.ts.map +1 -1
  249. package/dist/simple-tree/node-kinds/array/arrayNode.js +91 -10
  250. package/dist/simple-tree/node-kinds/array/arrayNode.js.map +1 -1
  251. package/dist/simple-tree/node-kinds/map/mapNode.d.ts +90 -0
  252. package/dist/simple-tree/node-kinds/map/mapNode.d.ts.map +1 -1
  253. package/dist/simple-tree/node-kinds/map/mapNode.js +26 -1
  254. package/dist/simple-tree/node-kinds/map/mapNode.js.map +1 -1
  255. package/dist/simple-tree/node-kinds/object/objectNode.js +2 -2
  256. package/dist/simple-tree/node-kinds/object/objectNode.js.map +1 -1
  257. package/dist/simple-tree/node-kinds/record/recordNode.js +2 -2
  258. package/dist/simple-tree/node-kinds/record/recordNode.js.map +1 -1
  259. package/dist/text/codePointUtils.d.ts +2 -2
  260. package/dist/text/codePointUtils.js +2 -2
  261. package/dist/text/codePointUtils.js.map +1 -1
  262. package/dist/text/index.d.ts +3 -3
  263. package/dist/text/index.d.ts.map +1 -1
  264. package/dist/text/index.js +4 -4
  265. package/dist/text/index.js.map +1 -1
  266. package/dist/text/textDomain.d.ts +30 -18
  267. package/dist/text/textDomain.d.ts.map +1 -1
  268. package/dist/text/textDomain.js +44 -23
  269. package/dist/text/textDomain.js.map +1 -1
  270. package/dist/text/textDomainFormatted.d.ts +180 -82
  271. package/dist/text/textDomainFormatted.d.ts.map +1 -1
  272. package/dist/text/textDomainFormatted.js +164 -84
  273. package/dist/text/textDomainFormatted.js.map +1 -1
  274. package/dist/text/textDomainFormattedDefault.d.ts +48 -25
  275. package/dist/text/textDomainFormattedDefault.d.ts.map +1 -1
  276. package/dist/text/textDomainFormattedDefault.js +24 -19
  277. package/dist/text/textDomainFormattedDefault.js.map +1 -1
  278. package/dist/treeDataStore.d.ts +49 -0
  279. package/dist/treeDataStore.d.ts.map +1 -0
  280. package/dist/treeDataStore.js +57 -0
  281. package/dist/treeDataStore.js.map +1 -0
  282. package/dist/treeFactory.d.ts +8 -3
  283. package/dist/treeFactory.d.ts.map +1 -1
  284. package/dist/treeFactory.js +6 -1
  285. package/dist/treeFactory.js.map +1 -1
  286. package/dist/util/compressedIds.d.ts +22 -2
  287. package/dist/util/compressedIds.d.ts.map +1 -1
  288. package/dist/util/compressedIds.js +22 -1
  289. package/dist/util/compressedIds.js.map +1 -1
  290. package/lib/core/change-family/changeFamily.d.ts +15 -4
  291. package/lib/core/change-family/changeFamily.d.ts.map +1 -1
  292. package/lib/core/change-family/changeFamily.js.map +1 -1
  293. package/lib/core/change-family/editBuilder.d.ts +2 -3
  294. package/lib/core/change-family/editBuilder.d.ts.map +1 -1
  295. package/lib/core/change-family/editBuilder.js +1 -2
  296. package/lib/core/change-family/editBuilder.js.map +1 -1
  297. package/lib/core/change-family/index.d.ts +1 -1
  298. package/lib/core/change-family/index.d.ts.map +1 -1
  299. package/lib/core/change-family/index.js.map +1 -1
  300. package/lib/core/index.d.ts +4 -3
  301. package/lib/core/index.d.ts.map +1 -1
  302. package/lib/core/index.js +2 -2
  303. package/lib/core/index.js.map +1 -1
  304. package/lib/core/rebase/index.d.ts +1 -1
  305. package/lib/core/rebase/index.d.ts.map +1 -1
  306. package/lib/core/rebase/index.js +1 -1
  307. package/lib/core/rebase/index.js.map +1 -1
  308. package/lib/core/rebase/types.d.ts +110 -0
  309. package/lib/core/rebase/types.d.ts.map +1 -1
  310. package/lib/core/rebase/types.js +46 -0
  311. package/lib/core/rebase/types.js.map +1 -1
  312. package/lib/core/tree/delta.d.ts +62 -16
  313. package/lib/core/tree/delta.d.ts.map +1 -1
  314. package/lib/core/tree/delta.js.map +1 -1
  315. package/lib/core/tree/detachedFieldIndex.d.ts +7 -13
  316. package/lib/core/tree/detachedFieldIndex.d.ts.map +1 -1
  317. package/lib/core/tree/detachedFieldIndex.js +7 -21
  318. package/lib/core/tree/detachedFieldIndex.js.map +1 -1
  319. package/lib/core/tree/index.d.ts +1 -0
  320. package/lib/core/tree/index.d.ts.map +1 -1
  321. package/lib/core/tree/index.js.map +1 -1
  322. package/lib/core/tree/visitorUtils.d.ts +2 -4
  323. package/lib/core/tree/visitorUtils.d.ts.map +1 -1
  324. package/lib/core/tree/visitorUtils.js +2 -2
  325. package/lib/core/tree/visitorUtils.js.map +1 -1
  326. package/lib/entrypoints/alpha.d.ts +1 -1
  327. package/lib/entrypoints/alpha.d.ts.map +1 -1
  328. package/lib/entrypoints/alpha.js +1 -1
  329. package/lib/entrypoints/alpha.js.map +1 -1
  330. package/lib/feature-libraries/chunked-forest/codec/codecs.d.ts +9 -6
  331. package/lib/feature-libraries/chunked-forest/codec/codecs.d.ts.map +1 -1
  332. package/lib/feature-libraries/chunked-forest/codec/codecs.js +16 -13
  333. package/lib/feature-libraries/chunked-forest/codec/codecs.js.map +1 -1
  334. package/lib/feature-libraries/chunked-forest/uniformChunk.d.ts.map +1 -1
  335. package/lib/feature-libraries/chunked-forest/uniformChunk.js +10 -2
  336. package/lib/feature-libraries/chunked-forest/uniformChunk.js.map +1 -1
  337. package/lib/feature-libraries/comparison-forest/comparisonForest.d.ts +51 -0
  338. package/lib/feature-libraries/comparison-forest/comparisonForest.d.ts.map +1 -0
  339. package/lib/feature-libraries/comparison-forest/comparisonForest.js +94 -0
  340. package/lib/feature-libraries/comparison-forest/comparisonForest.js.map +1 -0
  341. package/lib/feature-libraries/comparison-forest/index.d.ts +6 -0
  342. package/lib/feature-libraries/comparison-forest/index.d.ts.map +1 -0
  343. package/lib/feature-libraries/comparison-forest/index.js +6 -0
  344. package/lib/feature-libraries/comparison-forest/index.js.map +1 -0
  345. package/lib/feature-libraries/default-schema/defaultEditBuilder.d.ts +8 -6
  346. package/lib/feature-libraries/default-schema/defaultEditBuilder.d.ts.map +1 -1
  347. package/lib/feature-libraries/default-schema/defaultEditBuilder.js +6 -3
  348. package/lib/feature-libraries/default-schema/defaultEditBuilder.js.map +1 -1
  349. package/lib/feature-libraries/default-schema/index.d.ts +1 -1
  350. package/lib/feature-libraries/default-schema/index.d.ts.map +1 -1
  351. package/lib/feature-libraries/default-schema/index.js.map +1 -1
  352. package/lib/feature-libraries/default-schema/noChangeCodecs.d.ts +2 -2
  353. package/lib/feature-libraries/default-schema/noChangeCodecs.d.ts.map +1 -1
  354. package/lib/feature-libraries/default-schema/noChangeCodecs.js +3 -1
  355. package/lib/feature-libraries/default-schema/noChangeCodecs.js.map +1 -1
  356. package/lib/feature-libraries/detachedFieldIndexSummarizer.d.ts +6 -3
  357. package/lib/feature-libraries/detachedFieldIndexSummarizer.d.ts.map +1 -1
  358. package/lib/feature-libraries/detachedFieldIndexSummarizer.js +16 -4
  359. package/lib/feature-libraries/detachedFieldIndexSummarizer.js.map +1 -1
  360. package/lib/feature-libraries/forest-summary/forestSummarizer.d.ts +2 -3
  361. package/lib/feature-libraries/forest-summary/forestSummarizer.d.ts.map +1 -1
  362. package/lib/feature-libraries/forest-summary/forestSummarizer.js +2 -3
  363. package/lib/feature-libraries/forest-summary/forestSummarizer.js.map +1 -1
  364. package/lib/feature-libraries/index.d.ts +4 -3
  365. package/lib/feature-libraries/index.d.ts.map +1 -1
  366. package/lib/feature-libraries/index.js +2 -1
  367. package/lib/feature-libraries/index.js.map +1 -1
  368. package/lib/feature-libraries/mitigatedChangeFamily.d.ts +1 -1
  369. package/lib/feature-libraries/mitigatedChangeFamily.d.ts.map +1 -1
  370. package/lib/feature-libraries/mitigatedChangeFamily.js +12 -0
  371. package/lib/feature-libraries/mitigatedChangeFamily.js.map +1 -1
  372. package/lib/feature-libraries/modular-schema/fieldChangeHandler.d.ts +9 -1
  373. package/lib/feature-libraries/modular-schema/fieldChangeHandler.d.ts.map +1 -1
  374. package/lib/feature-libraries/modular-schema/fieldChangeHandler.js.map +1 -1
  375. package/lib/feature-libraries/modular-schema/genericFieldKindCodecs.d.ts +2 -2
  376. package/lib/feature-libraries/modular-schema/genericFieldKindCodecs.d.ts.map +1 -1
  377. package/lib/feature-libraries/modular-schema/genericFieldKindCodecs.js.map +1 -1
  378. package/lib/feature-libraries/modular-schema/index.d.ts +1 -1
  379. package/lib/feature-libraries/modular-schema/index.d.ts.map +1 -1
  380. package/lib/feature-libraries/modular-schema/index.js.map +1 -1
  381. package/lib/feature-libraries/modular-schema/invert.d.ts +15 -0
  382. package/lib/feature-libraries/modular-schema/invert.d.ts.map +1 -0
  383. package/lib/feature-libraries/modular-schema/invert.js +155 -0
  384. package/lib/feature-libraries/modular-schema/invert.js.map +1 -0
  385. package/lib/feature-libraries/modular-schema/minimizeModularChange.d.ts +3 -4
  386. package/lib/feature-libraries/modular-schema/minimizeModularChange.d.ts.map +1 -1
  387. package/lib/feature-libraries/modular-schema/minimizeModularChange.js +2 -2
  388. package/lib/feature-libraries/modular-schema/minimizeModularChange.js.map +1 -1
  389. package/lib/feature-libraries/modular-schema/modularChangeCodecV1.d.ts +9 -9
  390. package/lib/feature-libraries/modular-schema/modularChangeCodecV1.d.ts.map +1 -1
  391. package/lib/feature-libraries/modular-schema/modularChangeCodecV1.js +0 -2
  392. package/lib/feature-libraries/modular-schema/modularChangeCodecV1.js.map +1 -1
  393. package/lib/feature-libraries/modular-schema/modularChangeCodecV2.d.ts +2 -2
  394. package/lib/feature-libraries/modular-schema/modularChangeCodecV2.d.ts.map +1 -1
  395. package/lib/feature-libraries/modular-schema/modularChangeCodecV2.js.map +1 -1
  396. package/lib/feature-libraries/modular-schema/modularChangeCodecs.d.ts +2 -2
  397. package/lib/feature-libraries/modular-schema/modularChangeCodecs.d.ts.map +1 -1
  398. package/lib/feature-libraries/modular-schema/modularChangeCodecs.js.map +1 -1
  399. package/lib/feature-libraries/modular-schema/modularChangeFamily.d.ts +8 -22
  400. package/lib/feature-libraries/modular-schema/modularChangeFamily.d.ts.map +1 -1
  401. package/lib/feature-libraries/modular-schema/modularChangeFamily.js +16 -367
  402. package/lib/feature-libraries/modular-schema/modularChangeFamily.js.map +1 -1
  403. package/lib/feature-libraries/modular-schema/modularChangeUtils.d.ts +61 -0
  404. package/lib/feature-libraries/modular-schema/modularChangeUtils.d.ts.map +1 -0
  405. package/lib/feature-libraries/modular-schema/modularChangeUtils.js +192 -0
  406. package/lib/feature-libraries/modular-schema/modularChangeUtils.js.map +1 -0
  407. package/lib/feature-libraries/modular-schema/prune.d.ts +10 -0
  408. package/lib/feature-libraries/modular-schema/prune.d.ts.map +1 -0
  409. package/lib/feature-libraries/modular-schema/prune.js +45 -0
  410. package/lib/feature-libraries/modular-schema/prune.js.map +1 -0
  411. package/lib/feature-libraries/optional-field/optionalFieldCodecV2.d.ts +2 -2
  412. package/lib/feature-libraries/optional-field/optionalFieldCodecV2.d.ts.map +1 -1
  413. package/lib/feature-libraries/optional-field/optionalFieldCodecV2.js.map +1 -1
  414. package/lib/feature-libraries/optional-field/optionalFieldCodecs.d.ts +2 -2
  415. package/lib/feature-libraries/optional-field/optionalFieldCodecs.d.ts.map +1 -1
  416. package/lib/feature-libraries/optional-field/optionalFieldCodecs.js.map +1 -1
  417. package/lib/feature-libraries/sequence-field/sequenceFieldCodecV2.d.ts +2 -2
  418. package/lib/feature-libraries/sequence-field/sequenceFieldCodecV2.d.ts.map +1 -1
  419. package/lib/feature-libraries/sequence-field/sequenceFieldCodecV2.js.map +1 -1
  420. package/lib/feature-libraries/sequence-field/sequenceFieldCodecV3.d.ts +2 -2
  421. package/lib/feature-libraries/sequence-field/sequenceFieldCodecV3.d.ts.map +1 -1
  422. package/lib/feature-libraries/sequence-field/sequenceFieldCodecV3.js.map +1 -1
  423. package/lib/feature-libraries/sequence-field/sequenceFieldCodecs.d.ts +2 -2
  424. package/lib/feature-libraries/sequence-field/sequenceFieldCodecs.d.ts.map +1 -1
  425. package/lib/feature-libraries/sequence-field/sequenceFieldCodecs.js.map +1 -1
  426. package/lib/feature-libraries/treeTextCursor.d.ts +15 -0
  427. package/lib/feature-libraries/treeTextCursor.d.ts.map +1 -1
  428. package/lib/feature-libraries/treeTextCursor.js +62 -1
  429. package/lib/feature-libraries/treeTextCursor.js.map +1 -1
  430. package/lib/index.d.ts +6 -4
  431. package/lib/index.d.ts.map +1 -1
  432. package/lib/index.js +4 -3
  433. package/lib/index.js.map +1 -1
  434. package/lib/packageVersion.d.ts +1 -1
  435. package/lib/packageVersion.js +1 -1
  436. package/lib/packageVersion.js.map +1 -1
  437. package/lib/shared-tree/serializedChange.d.ts +2 -2
  438. package/lib/shared-tree/serializedChange.d.ts.map +1 -1
  439. package/lib/shared-tree/serializedChange.js.map +1 -1
  440. package/lib/shared-tree/sharedTree.d.ts +11 -3
  441. package/lib/shared-tree/sharedTree.d.ts.map +1 -1
  442. package/lib/shared-tree/sharedTree.js +10 -8
  443. package/lib/shared-tree/sharedTree.js.map +1 -1
  444. package/lib/shared-tree/sharedTreeChangeCodecs.d.ts +2 -2
  445. package/lib/shared-tree/sharedTreeChangeCodecs.d.ts.map +1 -1
  446. package/lib/shared-tree/sharedTreeChangeCodecs.js.map +1 -1
  447. package/lib/shared-tree/sharedTreeChangeFamily.d.ts +41 -4
  448. package/lib/shared-tree/sharedTreeChangeFamily.d.ts.map +1 -1
  449. package/lib/shared-tree/sharedTreeChangeFamily.js +55 -0
  450. package/lib/shared-tree/sharedTreeChangeFamily.js.map +1 -1
  451. package/lib/shared-tree/transactionMinimize.d.ts.map +1 -1
  452. package/lib/shared-tree/transactionMinimize.js +3 -3
  453. package/lib/shared-tree/transactionMinimize.js.map +1 -1
  454. package/lib/shared-tree/transactionPostProcessor.d.ts +2 -1
  455. package/lib/shared-tree/transactionPostProcessor.d.ts.map +1 -1
  456. package/lib/shared-tree/transactionPostProcessor.js.map +1 -1
  457. package/lib/shared-tree/treeCheckout.d.ts +13 -7
  458. package/lib/shared-tree/treeCheckout.d.ts.map +1 -1
  459. package/lib/shared-tree/treeCheckout.js +61 -15
  460. package/lib/shared-tree/treeCheckout.js.map +1 -1
  461. package/lib/shared-tree-core/branch.d.ts +24 -9
  462. package/lib/shared-tree-core/branch.d.ts.map +1 -1
  463. package/lib/shared-tree-core/branch.js +7 -0
  464. package/lib/shared-tree-core/branch.js.map +1 -1
  465. package/lib/shared-tree-core/editManager.d.ts +4 -4
  466. package/lib/shared-tree-core/editManager.d.ts.map +1 -1
  467. package/lib/shared-tree-core/editManager.js +2 -0
  468. package/lib/shared-tree-core/editManager.js.map +1 -1
  469. package/lib/shared-tree-core/editManagerCodecs.d.ts +3 -14
  470. package/lib/shared-tree-core/editManagerCodecs.d.ts.map +1 -1
  471. package/lib/shared-tree-core/editManagerCodecs.js.map +1 -1
  472. package/lib/shared-tree-core/editManagerCodecsCommons.d.ts +11 -1
  473. package/lib/shared-tree-core/editManagerCodecsCommons.d.ts.map +1 -1
  474. package/lib/shared-tree-core/editManagerCodecsCommons.js.map +1 -1
  475. package/lib/shared-tree-core/editManagerCodecsV1toV4.d.ts +4 -11
  476. package/lib/shared-tree-core/editManagerCodecsV1toV4.d.ts.map +1 -1
  477. package/lib/shared-tree-core/editManagerCodecsV1toV4.js +1 -1
  478. package/lib/shared-tree-core/editManagerCodecsV1toV4.js.map +1 -1
  479. package/lib/shared-tree-core/editManagerCodecsVSharedBranches.d.ts +4 -11
  480. package/lib/shared-tree-core/editManagerCodecsVSharedBranches.d.ts.map +1 -1
  481. package/lib/shared-tree-core/editManagerCodecsVSharedBranches.js +1 -1
  482. package/lib/shared-tree-core/editManagerCodecsVSharedBranches.js.map +1 -1
  483. package/lib/shared-tree-core/editManagerSummarizer.d.ts +4 -4
  484. package/lib/shared-tree-core/editManagerSummarizer.d.ts.map +1 -1
  485. package/lib/shared-tree-core/editManagerSummarizer.js +0 -1
  486. package/lib/shared-tree-core/editManagerSummarizer.js.map +1 -1
  487. package/lib/shared-tree-core/messageCodecV1ToV4.d.ts +2 -2
  488. package/lib/shared-tree-core/messageCodecV1ToV4.d.ts.map +1 -1
  489. package/lib/shared-tree-core/messageCodecV1ToV4.js.map +1 -1
  490. package/lib/shared-tree-core/messageCodecVSharedBranches.d.ts.map +1 -1
  491. package/lib/shared-tree-core/messageCodecVSharedBranches.js.map +1 -1
  492. package/lib/shared-tree-core/messageCodecs.d.ts +8 -1
  493. package/lib/shared-tree-core/messageCodecs.d.ts.map +1 -1
  494. package/lib/shared-tree-core/messageCodecs.js.map +1 -1
  495. package/lib/shared-tree-core/sharedTreeCore.d.ts +5 -5
  496. package/lib/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
  497. package/lib/shared-tree-core/sharedTreeCore.js +1 -1
  498. package/lib/shared-tree-core/sharedTreeCore.js.map +1 -1
  499. package/lib/shared-tree-core/transaction.d.ts +10 -10
  500. package/lib/shared-tree-core/transaction.d.ts.map +1 -1
  501. package/lib/shared-tree-core/transaction.js +6 -3
  502. package/lib/shared-tree-core/transaction.js.map +1 -1
  503. package/lib/simple-tree/api/eraseSchemaDetails.d.ts +15 -0
  504. package/lib/simple-tree/api/eraseSchemaDetails.d.ts.map +1 -1
  505. package/lib/simple-tree/api/eraseSchemaDetails.js +15 -0
  506. package/lib/simple-tree/api/eraseSchemaDetails.js.map +1 -1
  507. package/lib/simple-tree/api/index.d.ts +1 -1
  508. package/lib/simple-tree/api/index.d.ts.map +1 -1
  509. package/lib/simple-tree/api/index.js +1 -1
  510. package/lib/simple-tree/api/index.js.map +1 -1
  511. package/lib/simple-tree/api/schemaFactoryAlpha.d.ts +3 -3
  512. package/lib/simple-tree/api/schemaFactoryAlpha.d.ts.map +1 -1
  513. package/lib/simple-tree/api/schemaStatics.d.ts +6 -7
  514. package/lib/simple-tree/api/schemaStatics.d.ts.map +1 -1
  515. package/lib/simple-tree/api/schemaStatics.js.map +1 -1
  516. package/lib/simple-tree/api/treeNodeApi.d.ts +20 -24
  517. package/lib/simple-tree/api/treeNodeApi.d.ts.map +1 -1
  518. package/lib/simple-tree/api/treeNodeApi.js +46 -46
  519. package/lib/simple-tree/api/treeNodeApi.js.map +1 -1
  520. package/lib/simple-tree/core/treeNode.d.ts +5 -6
  521. package/lib/simple-tree/core/treeNode.d.ts.map +1 -1
  522. package/lib/simple-tree/core/treeNode.js +2 -4
  523. package/lib/simple-tree/core/treeNode.js.map +1 -1
  524. package/lib/simple-tree/core/withType.d.ts +20 -7
  525. package/lib/simple-tree/core/withType.d.ts.map +1 -1
  526. package/lib/simple-tree/core/withType.js +4 -7
  527. package/lib/simple-tree/core/withType.js.map +1 -1
  528. package/lib/simple-tree/index.d.ts +2 -2
  529. package/lib/simple-tree/index.d.ts.map +1 -1
  530. package/lib/simple-tree/index.js +1 -1
  531. package/lib/simple-tree/index.js.map +1 -1
  532. package/lib/simple-tree/leafNodeSchema.d.ts +6 -1
  533. package/lib/simple-tree/leafNodeSchema.d.ts.map +1 -1
  534. package/lib/simple-tree/leafNodeSchema.js +0 -1
  535. package/lib/simple-tree/leafNodeSchema.js.map +1 -1
  536. package/lib/simple-tree/node-kinds/array/arrayNode.d.ts +53 -5
  537. package/lib/simple-tree/node-kinds/array/arrayNode.d.ts.map +1 -1
  538. package/lib/simple-tree/node-kinds/array/arrayNode.js +93 -12
  539. package/lib/simple-tree/node-kinds/array/arrayNode.js.map +1 -1
  540. package/lib/simple-tree/node-kinds/map/mapNode.d.ts +90 -0
  541. package/lib/simple-tree/node-kinds/map/mapNode.d.ts.map +1 -1
  542. package/lib/simple-tree/node-kinds/map/mapNode.js +27 -2
  543. package/lib/simple-tree/node-kinds/map/mapNode.js.map +1 -1
  544. package/lib/simple-tree/node-kinds/object/objectNode.js +3 -3
  545. package/lib/simple-tree/node-kinds/object/objectNode.js.map +1 -1
  546. package/lib/simple-tree/node-kinds/record/recordNode.js +3 -3
  547. package/lib/simple-tree/node-kinds/record/recordNode.js.map +1 -1
  548. package/lib/text/codePointUtils.d.ts +2 -2
  549. package/lib/text/codePointUtils.js +2 -2
  550. package/lib/text/codePointUtils.js.map +1 -1
  551. package/lib/text/index.d.ts +3 -3
  552. package/lib/text/index.d.ts.map +1 -1
  553. package/lib/text/index.js +3 -3
  554. package/lib/text/index.js.map +1 -1
  555. package/lib/text/textDomain.d.ts +30 -18
  556. package/lib/text/textDomain.d.ts.map +1 -1
  557. package/lib/text/textDomain.js +41 -22
  558. package/lib/text/textDomain.js.map +1 -1
  559. package/lib/text/textDomainFormatted.d.ts +180 -82
  560. package/lib/text/textDomainFormatted.d.ts.map +1 -1
  561. package/lib/text/textDomainFormatted.js +165 -86
  562. package/lib/text/textDomainFormatted.js.map +1 -1
  563. package/lib/text/textDomainFormattedDefault.d.ts +48 -25
  564. package/lib/text/textDomainFormattedDefault.d.ts.map +1 -1
  565. package/lib/text/textDomainFormattedDefault.js +25 -20
  566. package/lib/text/textDomainFormattedDefault.js.map +1 -1
  567. package/lib/treeDataStore.d.ts +49 -0
  568. package/lib/treeDataStore.d.ts.map +1 -0
  569. package/lib/treeDataStore.js +52 -0
  570. package/lib/treeDataStore.js.map +1 -0
  571. package/lib/treeFactory.d.ts +8 -3
  572. package/lib/treeFactory.d.ts.map +1 -1
  573. package/lib/treeFactory.js +5 -0
  574. package/lib/treeFactory.js.map +1 -1
  575. package/lib/util/compressedIds.d.ts +22 -2
  576. package/lib/util/compressedIds.d.ts.map +1 -1
  577. package/lib/util/compressedIds.js +22 -1
  578. package/lib/util/compressedIds.js.map +1 -1
  579. package/package.json +32 -24
  580. package/src/core/change-family/changeFamily.ts +32 -4
  581. package/src/core/change-family/editBuilder.ts +1 -2
  582. package/src/core/change-family/index.ts +2 -0
  583. package/src/core/index.ts +11 -6
  584. package/src/core/rebase/index.ts +2 -0
  585. package/src/core/rebase/types.ts +113 -0
  586. package/src/core/tree/delta.ts +62 -16
  587. package/src/core/tree/detachedFieldIndex.ts +7 -38
  588. package/src/core/tree/index.ts +2 -0
  589. package/src/core/tree/visitorUtils.ts +3 -17
  590. package/src/entrypoints/alpha.ts +9 -1
  591. package/src/feature-libraries/chunked-forest/codec/codecs.ts +17 -14
  592. package/src/feature-libraries/chunked-forest/uniformChunk.ts +11 -1
  593. package/src/feature-libraries/comparison-forest/comparisonForest.ts +140 -0
  594. package/src/feature-libraries/comparison-forest/index.ts +6 -0
  595. package/src/feature-libraries/default-schema/defaultEditBuilder.ts +20 -6
  596. package/src/feature-libraries/default-schema/index.ts +1 -0
  597. package/src/feature-libraries/default-schema/noChangeCodecs.ts +11 -3
  598. package/src/feature-libraries/detachedFieldIndexSummarizer.ts +33 -5
  599. package/src/feature-libraries/forest-summary/forestSummarizer.ts +1 -3
  600. package/src/feature-libraries/index.ts +5 -0
  601. package/src/feature-libraries/mitigatedChangeFamily.ts +21 -3
  602. package/src/feature-libraries/modular-schema/fieldChangeHandler.ts +10 -1
  603. package/src/feature-libraries/modular-schema/genericFieldKindCodecs.ts +9 -4
  604. package/src/feature-libraries/modular-schema/index.ts +1 -0
  605. package/src/feature-libraries/modular-schema/invert.ts +338 -0
  606. package/src/feature-libraries/modular-schema/minimizeModularChange.ts +3 -5
  607. package/src/feature-libraries/modular-schema/modularChangeCodecV1.ts +16 -13
  608. package/src/feature-libraries/modular-schema/modularChangeCodecV2.ts +3 -1
  609. package/src/feature-libraries/modular-schema/modularChangeCodecs.ts +2 -1
  610. package/src/feature-libraries/modular-schema/modularChangeFamily.ts +45 -644
  611. package/src/feature-libraries/modular-schema/modularChangeUtils.ts +340 -0
  612. package/src/feature-libraries/modular-schema/prune.ts +69 -0
  613. package/src/feature-libraries/optional-field/optionalFieldCodecV2.ts +4 -2
  614. package/src/feature-libraries/optional-field/optionalFieldCodecs.ts +5 -2
  615. package/src/feature-libraries/sequence-field/sequenceFieldCodecV2.ts +4 -2
  616. package/src/feature-libraries/sequence-field/sequenceFieldCodecV3.ts +4 -2
  617. package/src/feature-libraries/sequence-field/sequenceFieldCodecs.ts +6 -3
  618. package/src/feature-libraries/treeTextCursor.ts +66 -1
  619. package/src/index.ts +11 -4
  620. package/src/packageVersion.ts +1 -1
  621. package/src/shared-tree/serializedChange.ts +2 -2
  622. package/src/shared-tree/sharedTree.ts +40 -15
  623. package/src/shared-tree/sharedTreeChangeCodecs.ts +11 -3
  624. package/src/shared-tree/sharedTreeChangeFamily.ts +77 -2
  625. package/src/shared-tree/transactionMinimize.ts +7 -3
  626. package/src/shared-tree/transactionPostProcessor.ts +5 -1
  627. package/src/shared-tree/treeCheckout.ts +136 -30
  628. package/src/shared-tree-core/branch.ts +41 -12
  629. package/src/shared-tree-core/editManager.ts +46 -25
  630. package/src/shared-tree-core/editManagerCodecs.ts +9 -21
  631. package/src/shared-tree-core/editManagerCodecsCommons.ts +14 -2
  632. package/src/shared-tree-core/editManagerCodecsV1toV4.ts +18 -21
  633. package/src/shared-tree-core/editManagerCodecsVSharedBranches.ts +18 -20
  634. package/src/shared-tree-core/editManagerSummarizer.ts +9 -6
  635. package/src/shared-tree-core/messageCodecV1ToV4.ts +3 -3
  636. package/src/shared-tree-core/messageCodecVSharedBranches.ts +2 -2
  637. package/src/shared-tree-core/messageCodecs.ts +12 -2
  638. package/src/shared-tree-core/sharedTreeCore.ts +16 -7
  639. package/src/shared-tree-core/transaction.ts +47 -25
  640. package/src/simple-tree/api/eraseSchemaDetails.ts +15 -0
  641. package/src/simple-tree/api/index.ts +0 -1
  642. package/src/simple-tree/api/schemaStatics.ts +2 -2
  643. package/src/simple-tree/api/treeNodeApi.ts +64 -48
  644. package/src/simple-tree/core/treeNode.ts +13 -10
  645. package/src/simple-tree/core/withType.ts +20 -7
  646. package/src/simple-tree/index.ts +1 -2
  647. package/src/simple-tree/leafNodeSchema.ts +6 -1
  648. package/src/simple-tree/node-kinds/array/arrayNode.ts +130 -16
  649. package/src/simple-tree/node-kinds/map/mapNode.ts +137 -5
  650. package/src/simple-tree/node-kinds/object/objectNode.ts +3 -3
  651. package/src/simple-tree/node-kinds/record/recordNode.ts +3 -3
  652. package/src/text/README.md +1 -1
  653. package/src/text/codePointUtils.ts +2 -2
  654. package/src/text/index.ts +3 -3
  655. package/src/text/textDomain.ts +50 -27
  656. package/src/text/textDomainFormatted.ts +384 -163
  657. package/src/text/textDomainFormattedDefault.ts +32 -32
  658. package/src/treeDataStore.ts +125 -0
  659. package/src/treeFactory.ts +11 -3
  660. package/src/util/compressedIds.ts +36 -3
@@ -35,6 +35,14 @@ export interface MessageEncodingContext {
35
35
  schema?: SchemaAndPolicy;
36
36
  }
37
37
 
38
+ /**
39
+ * Context required for decoding a message. Unlike {@link MessageEncodingContext}, no schema is
40
+ * needed: message decoding is schema-agnostic.
41
+ */
42
+ export interface MessageDecodingContext {
43
+ idCompressor: IIdCompressor;
44
+ }
45
+
38
46
  /**
39
47
  * Codec name used to identify the message codec, see {@link makeMessageCodecBuilder}.
40
48
  */
@@ -65,14 +73,16 @@ export function makeMessageCodecBuilder<TChangeset>(): VersionDispatchingCodecBu
65
73
  DecodedMessage<TChangeset>,
66
74
  MessageEncodingContext,
67
75
  MessageFormatVersion | undefined,
68
- typeof messageCodecName
76
+ typeof messageCodecName,
77
+ MessageDecodingContext
69
78
  > {
70
79
  // See MessageFormatVersion and its members for documentation on what changed in each version.
71
80
  const versions: CodecVersion<
72
81
  DecodedMessage<TChangeset>,
73
82
  MessageEncodingContext,
74
83
  MessageFormatVersion | undefined,
75
- MessageCodecBuilderOptions<TChangeset>
84
+ MessageCodecBuilderOptions<TChangeset>,
85
+ MessageDecodingContext
76
86
  >[] = [
77
87
  // The "undefined" wire format (no version field) is discontinued.
78
88
  makeDiscontinuedCodecAndSchema(undefined, "2.73.0"),
@@ -95,12 +95,19 @@ export interface EnrichmentConfig<TChange> {
95
95
  * Generic shared tree, which needs to be configured with indexes, field kinds and other configuration.
96
96
  */
97
97
  @breakingClass
98
- export class SharedTreeCore<TEditor extends ChangeFamilyEditor, TChange>
98
+ export class SharedTreeCore<
99
+ TEditor extends ChangeFamilyEditor,
100
+ TChange,
101
+ TChangeProcessingContext,
102
+ >
99
103
  extends VersionedSummarizer<SharedTreeSummaryFormatVersion>
100
104
  implements WithBreakable, Summarizable
101
105
  {
102
- private readonly editManager: EditManager<TEditor, TChange, ChangeFamily<TEditor, TChange>>;
103
- private readonly summarizables: readonly [EditManagerSummarizer<TChange>, ...Summarizable[]];
106
+ private readonly editManager: EditManager<TEditor, TChange, TChangeProcessingContext>;
107
+ private readonly summarizables: readonly [
108
+ EditManagerSummarizer<TChange, TChangeProcessingContext>,
109
+ ...Summarizable[],
110
+ ];
104
111
  /**
105
112
  * The sequence number that this instance is at.
106
113
  * This number is artificial in that it is made up by this instance as opposed to being provided by the runtime.
@@ -147,7 +154,7 @@ export class SharedTreeCore<TEditor extends ChangeFamilyEditor, TChange>
147
154
  public readonly submitLocalMessage: (content: unknown, localOpMetadata?: unknown) => void,
148
155
  logger: ITelemetryBaseLogger | undefined,
149
156
  summarizables: readonly Summarizable[],
150
- protected readonly changeFamily: ChangeFamily<TEditor, TChange>,
157
+ protected readonly changeFamily: ChangeFamily<TEditor, TChange, TChangeProcessingContext>,
151
158
  options: SharedTreeCoreOptionsInternal,
152
159
  changeFormatVersionForEditManager: DependentFormatVersion<EditManagerFormatVersion>,
153
160
  changeFormatVersionForMessage: DependentFormatVersion<MessageFormatVersion>,
@@ -207,7 +214,7 @@ export class SharedTreeCore<TEditor extends ChangeFamilyEditor, TChange>
207
214
  options.minVersionForCollab,
208
215
  this.schemaAndPolicy,
209
216
  options.healUnresolvableIdentifiersOnDecode === true
210
- ? { sharedObjectId: sharedObject.id }
217
+ ? { sharedObjectId: sharedObject.id, logger }
211
218
  : undefined,
212
219
  ),
213
220
  ...summarizables,
@@ -519,7 +526,7 @@ export class SharedTreeCore<TEditor extends ChangeFamilyEditor, TChange>
519
526
  }
520
527
  }
521
528
 
522
- public getLocalBranch(): SharedTreeBranch<TEditor, TChange> {
529
+ public getLocalBranch(): SharedTreeBranch<TEditor, TChange, TChangeProcessingContext> {
523
530
  return this.editManager.getLocalBranch("main");
524
531
  }
525
532
 
@@ -545,7 +552,9 @@ export class SharedTreeCore<TEditor extends ChangeFamilyEditor, TChange>
545
552
  this.editManager.addNewBranch(branchId, branchName);
546
553
  }
547
554
 
548
- public getSharedBranch(branchId: BranchId): SharedTreeBranch<TEditor, TChange> {
555
+ public getSharedBranch(
556
+ branchId: BranchId,
557
+ ): SharedTreeBranch<TEditor, TChange, TChangeProcessingContext> {
549
558
  return this.editManager.getLocalBranch(branchId);
550
559
  }
551
560
 
@@ -17,6 +17,7 @@ import {
17
17
  tagChange,
18
18
  type ChangeFamilyEditor,
19
19
  type GraphCommit,
20
+ type ProcessChangeFn,
20
21
  type RevisionTag,
21
22
  } from "../core/index.js";
22
23
  import { getLast, getOrCreate } from "../util/index.js";
@@ -263,7 +264,7 @@ export enum ChangeProcessorApplicability {
263
264
  * (see the conversion helpers in the `shared-tree` layer) so that its internal
264
265
  * change representation does not leak into the public API.
265
266
  */
266
- export interface ChangeProcessor<TChange> {
267
+ export interface ChangeProcessor<TChange, TChangeProcessingContext> {
267
268
  /**
268
269
  * Informs what context it should be invoked for.
269
270
  */
@@ -271,13 +272,13 @@ export interface ChangeProcessor<TChange> {
271
272
  /**
272
273
  * Processes the given change, returning a change with the same observable effect.
273
274
  */
274
- readonly processChange: (change: TChange) => TChange;
275
+ readonly processChange: ProcessChangeFn<TChange, TChangeProcessingContext>;
275
276
  }
276
277
 
277
278
  /**
278
279
  * Options for {@link Transactor.start | starting} a transaction.
279
280
  */
280
- export interface SquashingTransactionOptions<TChange> {
281
+ export interface SquashingTransactionOptions<TChange, TChangeProcessingContext> {
281
282
  /**
282
283
  * An optional {@link ChangeProcessor} applied to the squashed change produced when a transaction that was started
283
284
  * with this option is committed.
@@ -288,7 +289,7 @@ export interface SquashingTransactionOptions<TChange> {
288
289
  * How often the processor is invoked across nested transactions is governed by its
289
290
  * {@link ChangeProcessor.applicability | applicability}.
290
291
  */
291
- readonly postProcessor?: ChangeProcessor<TChange>;
292
+ readonly postProcessor?: ChangeProcessor<TChange, TChangeProcessingContext>;
292
293
  }
293
294
 
294
295
  /**
@@ -300,8 +301,9 @@ export interface SquashingTransactionOptions<TChange> {
300
301
  export class SquashingTransactionStack<
301
302
  TEditor extends ChangeFamilyEditor,
302
303
  TChange,
303
- > extends TransactionStack<SquashingTransactionOptions<TChange>> {
304
- #transactionBranch?: SharedTreeBranch<TEditor, TChange>;
304
+ TChangeProcessingContext,
305
+ > extends TransactionStack<SquashingTransactionOptions<TChange, TChangeProcessingContext>> {
306
+ #transactionBranch?: SharedTreeBranch<TEditor, TChange, TChangeProcessingContext>;
305
307
 
306
308
  /**
307
309
  * An editor for whichever branch is currently the {@link SquashingTransactionStack.activeBranch | active branch}.
@@ -317,7 +319,7 @@ export class SquashingTransactionStack<
317
319
  /**
318
320
  * Get the "active branch" for this transactor - either the transaction branch if a transaction is in progress, or the original branch otherwise.
319
321
  */
320
- public get activeBranch(): SharedTreeBranch<TEditor, TChange> {
322
+ public get activeBranch(): SharedTreeBranch<TEditor, TChange, TChangeProcessingContext> {
321
323
  return this.#transactionBranch ?? this.branch;
322
324
  }
323
325
 
@@ -326,10 +328,16 @@ export class SquashingTransactionStack<
326
328
  * @remarks When the active branch changes, the listeners for these events will automatically be transferred to the new active branch.
327
329
  * In contrast, binding an event to the {@link SquashingTransactionStack.activeBranch | active branch} directly will not automatically transfer the listener when the active branch changes.
328
330
  */
329
- public get activeBranchEvents(): Listenable<SharedTreeBranchEvents<TEditor, TChange>> {
331
+ public get activeBranchEvents(): Listenable<
332
+ SharedTreeBranchEvents<TEditor, TChange, TChangeProcessingContext>
333
+ > {
330
334
  const off = (
331
- eventName: keyof SharedTreeBranchEvents<TEditor, TChange>,
332
- listener: SharedTreeBranchEvents<TEditor, TChange>[typeof eventName],
335
+ eventName: keyof SharedTreeBranchEvents<TEditor, TChange, TChangeProcessingContext>,
336
+ listener: SharedTreeBranchEvents<
337
+ TEditor,
338
+ TChange,
339
+ TChangeProcessingContext
340
+ >[typeof eventName],
333
341
  ): void => {
334
342
  this.activeBranch.events.off(eventName, listener);
335
343
  const listeners = this.#activeBranchEvents.get(eventName);
@@ -349,9 +357,13 @@ export class SquashingTransactionStack<
349
357
  };
350
358
  }
351
359
  readonly #activeBranchEvents = new Map<
352
- keyof SharedTreeBranchEvents<TEditor, TChange>,
360
+ keyof SharedTreeBranchEvents<TEditor, TChange, TChangeProcessingContext>,
353
361
  Set<
354
- SharedTreeBranchEvents<TEditor, TChange>[keyof SharedTreeBranchEvents<TEditor, TChange>]
362
+ SharedTreeBranchEvents<
363
+ TEditor,
364
+ TChange,
365
+ TChangeProcessingContext
366
+ >[keyof SharedTreeBranchEvents<TEditor, TChange, TChangeProcessingContext>]
355
367
  >
356
368
  >();
357
369
 
@@ -365,20 +377,23 @@ export class SquashingTransactionStack<
365
377
  * options rather than baked into this stack, so different transactions may supply different post-processors (or none).
366
378
  */
367
379
  public constructor(
368
- public readonly branch: SharedTreeBranch<TEditor, TChange>,
380
+ public readonly branch: SharedTreeBranch<TEditor, TChange, TChangeProcessingContext>,
369
381
  mintRevisionTag: () => RevisionTag,
370
382
  onPush?: () => OnPopWithViewUpdate<TChange> | void,
371
383
  ) {
372
384
  // A stack of the post-processors to apply when each in-progress transaction commits, ordered from outermost to
373
385
  // innermost. Each in-progress transaction contributes exactly one entry: either the processor to apply when it
374
386
  // commits, or `undefined` when none should be applied.
375
- const postProcessorStack: (ChangeProcessor<TChange> | undefined)[] = [];
387
+ const postProcessorStack: (
388
+ | ChangeProcessor<TChange, TChangeProcessingContext>
389
+ | undefined
390
+ )[] = [];
376
391
  // Determines the entry to push for a transaction that was started with the given `requested` processor (if any).
377
392
  // A processor with "outermost" applicability that is already active in an enclosing transaction resolves to
378
393
  // `undefined` so that it is only applied once (at the outermost transaction that supplied it).
379
394
  const resolvePostProcessor = (
380
- requested: ChangeProcessor<TChange> | undefined,
381
- ): ChangeProcessor<TChange> | undefined => {
395
+ requested: ChangeProcessor<TChange, TChangeProcessingContext> | undefined,
396
+ ): ChangeProcessor<TChange, TChangeProcessingContext> | undefined => {
382
397
  if (
383
398
  requested?.applicability === ChangeProcessorApplicability.IfOutermost &&
384
399
  postProcessorStack.includes(requested)
@@ -391,12 +406,13 @@ export class SquashingTransactionStack<
391
406
  super(
392
407
  // Invoked when an outer transaction starts
393
408
  (
394
- startOptions?: SquashingTransactionOptions<TChange>,
395
- ): Callbacks<SquashingTransactionOptions<TChange>> => {
409
+ startOptions?: SquashingTransactionOptions<TChange, TChangeProcessingContext>,
410
+ ): Callbacks<SquashingTransactionOptions<TChange, TChangeProcessingContext>> => {
396
411
  postProcessorStack.push(resolvePostProcessor(startOptions?.postProcessor));
397
412
  // Keep track of the commit that each transaction was on when it started
398
413
  const startHead = this.activeBranch.getHead();
399
- const rebaser = this.branch.changeFamily.rebaser;
414
+ const changeFamily = this.branch.changeFamily;
415
+ const rebaser = changeFamily.rebaser;
400
416
  const outerOnPop = onPush?.();
401
417
  let transactionRevision: RevisionTag | undefined;
402
418
  const transactionBranch = this.branch.fork(
@@ -462,7 +478,9 @@ export class SquashingTransactionStack<
462
478
  // Apply this transaction's post-processor (if any) to the squashed change (for example, to
463
479
  // "minimize" it so that it contains no extraneous information).
464
480
  const change =
465
- postProcessor === undefined ? squash : postProcessor.processChange(squash);
481
+ postProcessor === undefined
482
+ ? squash
483
+ : changeFamily.buildProcessor(postProcessor.processChange)(squash);
466
484
 
467
485
  if (change !== squash) {
468
486
  // The post-processor produced a change that differs from the
@@ -524,9 +542,9 @@ export class SquashingTransactionStack<
524
542
  outerOnPop?.(result, viewUpdate);
525
543
  };
526
544
  // Invoked when a nested transaction begins
527
- const onNestedTransactionPush: OnPush<SquashingTransactionOptions<TChange>> = (
528
- nestedStartOptions,
529
- ) => {
545
+ const onNestedTransactionPush: OnPush<
546
+ SquashingTransactionOptions<TChange, TChangeProcessingContext>
547
+ > = (nestedStartOptions) => {
530
548
  postProcessorStack.push(resolvePostProcessor(nestedStartOptions?.postProcessor));
531
549
  const nestedStartHead = this.activeBranch.getHead();
532
550
  const nestedOuterOnPop = onPush?.();
@@ -558,7 +576,9 @@ export class SquashingTransactionStack<
558
576
  0xd07 /* Expected transaction revision in the presence of transaction steps */,
559
577
  );
560
578
  const squash = rebaser.compose(nestedSteps);
561
- const processedSquash = nestedPostProcessor.processChange(squash);
579
+ const processedSquash = changeFamily.buildProcessor(
580
+ nestedPostProcessor.processChange,
581
+ )(squash);
562
582
  // Roll back the transaction branch to the nested start head and apply the
563
583
  // processed change if it differs from the original change.
564
584
  if (processedSquash !== squash) {
@@ -586,7 +606,9 @@ export class SquashingTransactionStack<
586
606
 
587
607
  /** Updates the transaction branch (and therefore the active branch) and rebinds the branch events. */
588
608
  private setTransactionBranch(
589
- transactionBranch: SharedTreeBranch<TEditor, TChange> | undefined,
609
+ transactionBranch:
610
+ | SharedTreeBranch<TEditor, TChange, TChangeProcessingContext>
611
+ | undefined,
590
612
  ): void {
591
613
  const oldActiveBranch = this.activeBranch;
592
614
  this.#transactionBranch = transactionBranch;
@@ -103,6 +103,21 @@ export function eraseSchemaDetails<TNode, ExtraSchemaProperties = unknown>(): <
103
103
  * const square = Square.create(10);
104
104
  * assert.equal(square.area, 100);
105
105
  * ```
106
+ * @remarks
107
+ * Care must be taken to avoid subclass members colliding with internal members of the schema.
108
+ * This is mainly a problem when using the output from {@link eraseSchemaDetailsSubclassable} to type a class returned to third party code which can subclass it.
109
+ * This pattern mainly occurs when writing generic schema factory functions which generate a schema from some parameters and return it to third party code which can subclass it.
110
+ *
111
+ * For example if the schema has a field or method named `size` (from a field, like in the `Square` example, or otherwise),
112
+ * then a subclass should not define a member named `size` as it will collide with the internal field.
113
+ *
114
+ * In practice, this risk can be mitigated by doing one of:
115
+ * 1. Using JavaScript private properties
116
+ * 2. Use non exported symbols for the properties
117
+ * 3. Use a naming convention for internal properties which you document the subclasses must not use.
118
+ * 4. Documenting the specific internal properties keys as not to be used by subclasses.
119
+ * 5. Subclass the returned class and declaring uninitialized readonly private properties to protect them (`private readonly size!: unknown;`).
120
+ * 6. Include the properties in `TNode` or `ExtraSchemaProperties`. This can use readonly erased types (like unknown) if desired.
106
121
  * @privateRemarks
107
122
  * See "example" test for an executable version of this example.
108
123
  * @alpha
@@ -67,7 +67,6 @@ export {
67
67
  createCustomizedFluidFrameworkScopedFactory,
68
68
  } from "./schemaCreationUtilities.js";
69
69
  export {
70
- deltaMarksToArrayOps,
71
70
  getIdentifierFromNode,
72
71
  getPropertyKeyFromStoredKey,
73
72
  getStoredKey,
@@ -16,7 +16,7 @@ import {
16
16
  type FieldSchema,
17
17
  type FieldSchemaAlpha,
18
18
  } from "../fieldSchema.js";
19
- import type { LeafSchema } from "../leafNodeSchema.js";
19
+ import type { LeafSchema, StringSchema } from "../leafNodeSchema.js";
20
20
  import {
21
21
  stringSchema,
22
22
  numberSchema,
@@ -252,7 +252,7 @@ export const schemaStatics = {
252
252
  props?: Omit<FieldProps<TCustomMetadata>, "defaultProvider">,
253
253
  ): FieldSchemaAlpha<
254
254
  FieldKind.Identifier,
255
- typeof stringSchema,
255
+ StringSchema,
256
256
  TCustomMetadata,
257
257
  FieldPropsAlpha<TCustomMetadata>
258
258
  > => {
@@ -25,6 +25,7 @@ import {
25
25
  type ImplicitAllowedTypes,
26
26
  type TreeNodeFromImplicitAllowedTypes,
27
27
  normalizeAllowedTypes,
28
+ type TreeNodeKernel,
28
29
  } from "../core/index.js";
29
30
  import { type ImplicitFieldSchema, FieldSchema } from "../fieldSchema.js";
30
31
  import { tryGetTreeNodeForField } from "../getTreeNodeForField.js";
@@ -115,6 +116,10 @@ export interface ArrayNodeRemoveOp {
115
116
  * `"remove"` and the destination array's delta contains an `"insert"` — they cannot be
116
117
  * correlated without additional bookkeeping on the caller's side.
117
118
  *
119
+ * The operations cover the complete array: trailing elements that were not changed are included
120
+ * in a final `"retain"` op. Applying every operation therefore consumes the entire pre-edit array
121
+ * and produces the entire post-edit array.
122
+ *
118
123
  * @sealed @alpha
119
124
  */
120
125
  export type ArrayNodeDeltaOp = ArrayNodeRetainOp | ArrayNodeInsertOp | ArrayNodeRemoveOp;
@@ -296,7 +301,13 @@ export const treeNodeApi: TreeNodeApi = {
296
301
  // unavailable rather than receiving stale marks from only the first batch.
297
302
  // TODO: Once the eventing stack is rewritten to walk the composed delta at
298
303
  // flush time, `marks` will always be defined. Remove the `undefined` fallback.
299
- const delta = marks === undefined ? undefined : deltaMarksToArrayOps(marks);
304
+ const delta =
305
+ marks === undefined
306
+ ? undefined
307
+ : deltaMarksToArrayOpsWithRetain(marks, getArrayLength(kernel), (count) => ({
308
+ type: "retain",
309
+ count,
310
+ }));
300
311
  listener({ delta });
301
312
  });
302
313
  } else {
@@ -314,7 +325,17 @@ export const treeNodeApi: TreeNodeApi = {
314
325
  return kernel.events.on("childrenChangedAfterBatch", ({ fieldMarks }) => {
315
326
  const marks = fieldMarks.get(EmptyKey);
316
327
  const delta =
317
- marks === undefined ? undefined : deltaMarksToArrayOpsForTreeChanged(marks);
328
+ marks === undefined
329
+ ? undefined
330
+ : deltaMarksToArrayOpsWithRetain(
331
+ marks,
332
+ getArrayLength(kernel),
333
+ (count, subtreeChanged) => ({
334
+ type: "retain",
335
+ count,
336
+ subtreeChanged,
337
+ }),
338
+ );
318
339
  (listener as (data: { readonly delta: typeof delta }) => void)({ delta });
319
340
  });
320
341
  }
@@ -351,73 +372,68 @@ export const treeNodeApi: TreeNodeApi = {
351
372
  };
352
373
 
353
374
  /**
354
- * Converts an array of internal {@link DeltaMark}s for a sequence field into sequential
355
- * array delta ops suitable for inclusion in {@link NodeChangedDataDelta.delta}.
375
+ * Converts internal {@link DeltaMark}s for an array's sequence field into sequential array delta
376
+ * operations.
377
+ *
378
+ * @remarks
379
+ * Each mark describes a contiguous run:
380
+ * - A mark with only `count` becomes a retain.
381
+ * - A mark with only `attach` becomes an insert.
382
+ * - A mark with only `detach` becomes a remove.
383
+ * - A mark with both `attach` and `detach` becomes a remove followed by an insert.
356
384
  *
357
- * Each mark in the delta describes a contiguous run of positions in the original array:
358
- * - A mark with only `count` (no attach/detach) `"retain"` with no subtree information
359
- * - A mark with only `attach` → `"insert"` (new elements added)
360
- * - A mark with only `detach` → `"remove"` (elements removed)
361
- * - A mark with both `attach` and `detach` → `"remove"` + `"insert"`
385
+ * Internal mark arrays may omit an unchanged suffix. The returned operations always cover the
386
+ * complete array, so this function uses the array's post-edit length to append a trailing retain
387
+ * when needed.
362
388
  *
363
389
  * @param marks - The low-level delta marks for the array's sequence field.
390
+ * @param postEditLength - The array's length after the edit.
391
+ * @param buildRetainOp - Builds a retain operation. Its second argument indicates whether the
392
+ * retained element's subtree changed; it is `false` for a synthesized trailing retain.
364
393
  *
365
394
  * @privateRemarks
366
395
  * The case where both `attach` and `detach` are set is unreachable today: the sequence-field
367
- * encoder never emits such marks for array (EmptyKey) fields. It is handled defensively.
396
+ * encoder never emits such marks for array (`EmptyKey`) fields. It is handled defensively.
368
397
  */
369
- export function deltaMarksToArrayOps(marks: readonly DeltaMark[]): ArrayNodeDeltaOp[] {
370
- const ops: ArrayNodeDeltaOp[] = [];
398
+ export function deltaMarksToArrayOpsWithRetain<TRetain extends ArrayNodeRetainOp>(
399
+ marks: readonly DeltaMark[],
400
+ postEditLength: number,
401
+ buildRetainOp: (count: number, subtreeChanged: boolean) => TRetain,
402
+ ): (TRetain | ArrayNodeInsertOp | ArrayNodeRemoveOp)[] {
403
+ const ops: (TRetain | ArrayNodeInsertOp | ArrayNodeRemoveOp)[] = [];
404
+ let processedLength = 0;
371
405
  for (const mark of marks) {
372
406
  if (mark.detach !== undefined) {
373
407
  ops.push({ type: "remove", count: mark.count });
374
408
  }
375
409
  if (mark.attach !== undefined) {
376
410
  ops.push({ type: "insert", count: mark.count });
411
+ processedLength += mark.count;
377
412
  } else if (mark.detach === undefined) {
378
- // Retain: elements were not added or removed.
379
- ops.push({ type: "retain", count: mark.count });
413
+ // When `fields` is set, `count` is guaranteed to be 1 (DeltaMark invariant).
414
+ ops.push(buildRetainOp(mark.count, mark.fields !== undefined));
415
+ processedLength += mark.count;
380
416
  }
381
417
  }
418
+ // DeltaMark arrays are allowed to omit the trailing retain, while our user facing array equivalents are not, so add it if necessary.
419
+ assert(
420
+ processedLength <= postEditLength,
421
+ 0xd19 /* Array delta exceeds post-edit array length */,
422
+ );
423
+ if (processedLength < postEditLength) {
424
+ ops.push(buildRetainOp(postEditLength - processedLength, false));
425
+ }
382
426
  return ops;
383
427
  }
384
428
 
385
429
  /**
386
- * Converts an array of internal {@link DeltaMark}s for a sequence field into sequential
387
- * {@link ArrayNodeTreeChangedDeltaOp}s suitable for inclusion in
388
- * {@link NodeChangedDataTreeDelta.delta} (delivered to {@link TreeChangeEventsAlpha.treeChanged}).
389
- *
390
- * Same conversion rules as {@link deltaMarksToArrayOps}, but retain ops additionally carry a
391
- * {@link ArrayNodeTreeChangedRetainOp.subtreeChanged} flag derived from whether the mark has
392
- * a `fields` property (indicating a descendant changed).
393
- *
394
- * @param marks - The low-level delta marks for the array's sequence field.
395
- *
396
- * @privateRemarks
397
- * The case where both `attach` and `detach` are set is unreachable today: the sequence-field
398
- * encoder never emits such marks for array (EmptyKey) fields. It is handled defensively.
430
+ * Returns the length of the `EmptyKey` field under the provided node kernel.
431
+ * @remarks
432
+ * Use this with the kernel of an array node to get the current length of the array.
433
+ * This is the same as `.length` on the array node, but is usable without having to get (and possible create) the node and narrow to the proper type to access that.
399
434
  */
400
- export function deltaMarksToArrayOpsForTreeChanged(
401
- marks: readonly DeltaMark[],
402
- ): ArrayNodeTreeChangedDeltaOp[] {
403
- const ops: ArrayNodeTreeChangedDeltaOp[] = [];
404
- for (const mark of marks) {
405
- if (mark.detach !== undefined) {
406
- ops.push({ type: "remove", count: mark.count });
407
- }
408
- if (mark.attach !== undefined) {
409
- ops.push({ type: "insert", count: mark.count });
410
- } else if (mark.detach === undefined) {
411
- // Retain: elements were not added or removed (but may have deep changes).
412
- // When `fields` is set, `count` is guaranteed to be 1 (DeltaMark invariant).
413
- ops.push({
414
- type: "retain",
415
- count: mark.count,
416
- subtreeChanged: mark.fields !== undefined,
417
- });
418
- }
419
- }
420
- return ops;
435
+ function getArrayLength(arrayNodeKernel: TreeNodeKernel): number {
436
+ return arrayNodeKernel.getInnerNode().getBoxed(EmptyKey).length;
421
437
  }
422
438
 
423
439
  /**
@@ -9,8 +9,12 @@ import { UsageError } from "@fluidframework/telemetry-utils/internal";
9
9
  import { markEager } from "./flexList.js";
10
10
  import { tryGetTreeNodeSchema } from "./treeNodeKernel.js";
11
11
  import { NodeKind, type TreeNodeSchemaClass } from "./treeNodeSchema.js";
12
- // eslint-disable-next-line import-x/no-deprecated
13
- import { type WithType, typeNameSymbol, type typeSchemaSymbol } from "./withType.js";
12
+ import type {
13
+ WithType,
14
+ // eslint-disable-next-line import-x/no-deprecated -- Required to implement the deprecated typeNameSymbol API.
15
+ typeNameSymbol,
16
+ typeSchemaSymbol,
17
+ } from "./withType.js";
14
18
 
15
19
  /**
16
20
  * A non-{@link NodeKind.Leaf|leaf} SharedTree node. Includes objects, arrays, and maps.
@@ -72,22 +76,21 @@ export abstract class TreeNode implements WithType {
72
76
  * someone could manually (or via Intellisense auto-implement completion, or in response to a type error)
73
77
  * make an object literal with the [type] field and pass it off as a node: this private brand prevents that.
74
78
  */
75
- // eslint-disable-next-line no-unused-private-class-members
79
+ // eslint-disable-next-line no-unused-private-class-members -- Exists for type checking sideeffect. See private remarks above.
76
80
  readonly #brand!: unknown;
77
81
 
78
82
  /**
79
- * Adds a type symbol for stronger typing.
80
- * @privateRemarks
81
- * Subclasses provide more specific strings for this to get strong typing of otherwise type compatible nodes.
83
+ * Adds a schema identifier brand for stronger and more efficient type checking.
84
+ * @privateRemarks Subclasses provide more specific values to distinguish otherwise type-compatible nodes.
82
85
  * @deprecated Use {@link typeSchemaSymbol} instead.
83
86
  */
84
- // eslint-disable-next-line import-x/no-deprecated
87
+ // eslint-disable-next-line import-x/no-deprecated -- Required to implement the deprecated typeNameSymbol API.
85
88
  public abstract get [typeNameSymbol](): string;
86
89
 
87
90
  /**
88
- * Adds a type symbol for stronger typing.
91
+ * {@inheritDoc typeSchemaSymbol}
89
92
  * @privateRemarks
90
- * Subclasses provide more specific strings for this to get strong typing of otherwise type compatible nodes.
93
+ * Subclasses provide more specific values for this to get strong typing of otherwise type compatible nodes.
91
94
  */
92
95
  public abstract get [typeSchemaSymbol](): TreeNodeSchemaClass;
93
96
 
@@ -152,7 +155,7 @@ export const privateToken = {};
152
155
  * @param base - prototype to search for
153
156
  * @returns true iff `base` is in the prototype chain starting at `derived`.
154
157
  */
155
- // eslint-disable-next-line @rushstack/no-new-null
158
+ // eslint-disable-next-line @rushstack/no-new-null -- getPrototypeOf uses null.
156
159
  export function inPrototypeChain(derived: object | null, base: object): boolean {
157
160
  let checking = derived;
158
161
  while (checking !== null) {
@@ -11,17 +11,14 @@ import type { TreeNode } from "./treeNode.js";
11
11
  import type { NodeKind, TreeNodeSchemaClass } from "./treeNodeSchema.js";
12
12
 
13
13
  /**
14
- * The type of a {@link TreeNode}.
14
+ * An internal brand to improve compiler performance.
15
15
  * For more information about the type, use `Tree.schema(theNode)` instead.
16
16
  * @remarks
17
- * This symbol mainly exists on nodes to allow TypeScript to provide more accurate type checking.
18
17
  * `Tree.is` and `Tree.schema` provide a superset of this information in more friendly ways.
19
- *
20
- * This symbol should not manually be added to objects as doing so allows the object to be invalidly used where nodes are expected.
21
- * Instead construct a real node of the desired type using its constructor.
22
18
  * @privateRemarks
23
- * This prevents non-nodes from being accidentally used as nodes, as well as allows the type checker to distinguish different node types.
24
- * @deprecated External code should use `Tree.schema(theNode)` for schema related runtime data access. For type narrowing, use `WithType` instead of the symbols directly.
19
+ * The identifier of a {@link TreeNode}'s schema.
20
+ * This allows the type checker to distinguish different node types more efficiently than via {@link typeSchemaSymbol}.
21
+ * @deprecated External code should use `Tree.schema(theNode)` for schema related runtime data access. For type narrowing, use {@link WithType} instead of the symbols directly.
25
22
  * @system @public
26
23
  */
27
24
  export const typeNameSymbol: unique symbol = Symbol("TreeNode Type");
@@ -97,6 +94,13 @@ export const contentSchemaSymbol: unique symbol = Symbol("SharedTree Schema");
97
94
  * }
98
95
  * }
99
96
  * ```
97
+ * @privateRemarks
98
+ * The properties of this are implemented as getters rather than instance properties as that is the easiest way to make them non-enumerable,
99
+ * and also saves memory and time as they only have to be setup on the prototype.
100
+ * These being non-enumerable inherited properties minimizes impact on users,
101
+ * hiding them from things like `Reflect.ownKeys`, Object spread, `Object.getOwnPropertyDescriptors`, and `for...in` loops.
102
+ * How we declare them here actually doesn't impact that,
103
+ * but is a good way to communicate to users and internal devs that these should be implemented as inherited getters to accomplish the above.
100
104
  * @sealed @public
101
105
  */
102
106
  export interface WithType<
@@ -106,6 +110,15 @@ export interface WithType<
106
110
  > {
107
111
  /**
108
112
  * Type symbol, marking a type in a way to increase type safety via strong type checking.
113
+ *
114
+ * Use `Tree.schema(theNode)` for schema related runtime data access. For type narrowing, use `WithType` instead of the symbols directly.
115
+ * @remarks
116
+ * This should be redundant with {@link typeSchemaSymbol}, but is kept for improved compiler performance.
117
+ * If we just rely on {@link typeSchemaSymbol}, the compiler has to work much harder to distinguish schema in unions,
118
+ * which can cause large schema unions to hit "error TS2859: Excessive complexity comparing types".
119
+ *
120
+ * This property is not intended for any use other than helping the compiler distinguish schema types,
121
+ * and should not be referenced in any code other than internal to the tree package.
109
122
  * @deprecated Use {@link typeSchemaSymbol} instead.
110
123
  */
111
124
  get [typeNameSymbol](): TName;
@@ -100,7 +100,6 @@ export {
100
100
  type ArrayNodeRetainOp,
101
101
  type ArrayNodeTreeChangedDeltaOp,
102
102
  type ArrayNodeTreeChangedRetainOp,
103
- deltaMarksToArrayOps,
104
103
  type NodeChangedData,
105
104
  type NodeChangedDataAlpha,
106
105
  type NodeChangedDataDelta,
@@ -328,6 +327,6 @@ export {
328
327
  handleSchema,
329
328
  nullSchema,
330
329
  } from "./leafNodeSchema.js";
331
- export type { LeafSchema } from "./leafNodeSchema.js";
330
+ export type { LeafSchema, StringSchema } from "./leafNodeSchema.js";
332
331
  export { getUnhydratedContext } from "./createContext.js";
333
332
  export { type TreeSchema, createTreeSchema } from "./treeSchema.js";
@@ -125,7 +125,12 @@ export interface LeafSchema<Name extends string, T extends TreeLeafValue>
125
125
  > {}
126
126
 
127
127
  // Leaf schema shared between all SchemaFactory instances.
128
- export const stringSchema = makeLeaf("string", ValueSchema.String);
128
+ /**
129
+ * A {@link LeafSchema} for a `string`.
130
+ * @system @sealed @alpha
131
+ */
132
+ export type StringSchema = LeafSchema<"string", string> & SimpleLeafNodeSchema;
133
+ export const stringSchema: StringSchema = makeLeaf("string", ValueSchema.String);
129
134
  export const numberSchema = makeLeaf("number", ValueSchema.Number);
130
135
  export const booleanSchema = makeLeaf("boolean", ValueSchema.Boolean);
131
136
  export const nullSchema = makeLeaf("null", ValueSchema.Null);