@fluidframework/tree 2.91.0 → 2.93.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 (1023) hide show
  1. package/CHANGELOG.md +158 -0
  2. package/README.md +1 -1
  3. package/api-report/tree.alpha.api.md +117 -51
  4. package/api-report/tree.beta.api.md +41 -12
  5. package/api-report/tree.legacy.beta.api.md +41 -12
  6. package/dist/api.d.ts +11 -1
  7. package/dist/api.d.ts.map +1 -1
  8. package/dist/api.js.map +1 -1
  9. package/dist/codec/codec.d.ts +28 -2
  10. package/dist/codec/codec.d.ts.map +1 -1
  11. package/dist/codec/codec.js +1 -0
  12. package/dist/codec/codec.js.map +1 -1
  13. package/dist/codec/index.d.ts +2 -2
  14. package/dist/codec/index.d.ts.map +1 -1
  15. package/dist/codec/index.js +2 -4
  16. package/dist/codec/index.js.map +1 -1
  17. package/dist/codec/versioned/codec.d.ts +18 -36
  18. package/dist/codec/versioned/codec.d.ts.map +1 -1
  19. package/dist/codec/versioned/codec.js +46 -59
  20. package/dist/codec/versioned/codec.js.map +1 -1
  21. package/dist/codec/versioned/index.d.ts +1 -1
  22. package/dist/codec/versioned/index.d.ts.map +1 -1
  23. package/dist/codec/versioned/index.js +2 -4
  24. package/dist/codec/versioned/index.js.map +1 -1
  25. package/dist/core/forest/forest.d.ts +5 -2
  26. package/dist/core/forest/forest.d.ts.map +1 -1
  27. package/dist/core/forest/forest.js.map +1 -1
  28. package/dist/core/index.d.ts +1 -1
  29. package/dist/core/index.d.ts.map +1 -1
  30. package/dist/core/index.js +6 -2
  31. package/dist/core/index.js.map +1 -1
  32. package/dist/core/rebase/changeRebaser.d.ts +8 -1
  33. package/dist/core/rebase/changeRebaser.d.ts.map +1 -1
  34. package/dist/core/rebase/changeRebaser.js.map +1 -1
  35. package/dist/core/rebase/revisionTagCodec.d.ts +4 -3
  36. package/dist/core/rebase/revisionTagCodec.d.ts.map +1 -1
  37. package/dist/core/rebase/revisionTagCodec.js +2 -0
  38. package/dist/core/rebase/revisionTagCodec.js.map +1 -1
  39. package/dist/core/rebase/utils.d.ts +2 -2
  40. package/dist/core/rebase/utils.d.ts.map +1 -1
  41. package/dist/core/rebase/utils.js +4 -4
  42. package/dist/core/rebase/utils.js.map +1 -1
  43. package/dist/core/schema-stored/formatV2.d.ts +1 -1
  44. package/dist/core/schema-stored/formatV2.js +1 -1
  45. package/dist/core/schema-stored/formatV2.js.map +1 -1
  46. package/dist/core/tree/anchorSet.d.ts +8 -0
  47. package/dist/core/tree/anchorSet.d.ts.map +1 -1
  48. package/dist/core/tree/anchorSet.js +63 -7
  49. package/dist/core/tree/anchorSet.js.map +1 -1
  50. package/dist/core/tree/cursor.d.ts +25 -1
  51. package/dist/core/tree/cursor.d.ts.map +1 -1
  52. package/dist/core/tree/cursor.js +45 -1
  53. package/dist/core/tree/cursor.js.map +1 -1
  54. package/dist/core/tree/deltaUtil.d.ts +13 -1
  55. package/dist/core/tree/deltaUtil.d.ts.map +1 -1
  56. package/dist/core/tree/deltaUtil.js +34 -1
  57. package/dist/core/tree/deltaUtil.js.map +1 -1
  58. package/dist/core/tree/detachedFieldIndexCodecs.d.ts +5 -5
  59. package/dist/core/tree/detachedFieldIndexCodecs.d.ts.map +1 -1
  60. package/dist/core/tree/detachedFieldIndexCodecs.js.map +1 -1
  61. package/dist/core/tree/index.d.ts +2 -2
  62. package/dist/core/tree/index.d.ts.map +1 -1
  63. package/dist/core/tree/index.js +6 -2
  64. package/dist/core/tree/index.js.map +1 -1
  65. package/dist/core/tree/visitDelta.d.ts +11 -0
  66. package/dist/core/tree/visitDelta.d.ts.map +1 -1
  67. package/dist/core/tree/visitDelta.js +1 -1
  68. package/dist/core/tree/visitDelta.js.map +1 -1
  69. package/dist/core/tree/visitorUtils.d.ts.map +1 -1
  70. package/dist/core/tree/visitorUtils.js +5 -0
  71. package/dist/core/tree/visitorUtils.js.map +1 -1
  72. package/dist/entrypoints/alpha.d.ts +1 -1
  73. package/dist/entrypoints/alpha.d.ts.map +1 -1
  74. package/dist/entrypoints/alpha.js +5 -6
  75. package/dist/entrypoints/alpha.js.map +1 -1
  76. package/dist/entrypoints/beta.d.ts +1 -1
  77. package/dist/entrypoints/beta.d.ts.map +1 -1
  78. package/dist/entrypoints/beta.js +4 -2
  79. package/dist/entrypoints/beta.js.map +1 -1
  80. package/dist/entrypoints/legacy.d.ts +1 -1
  81. package/dist/entrypoints/legacy.d.ts.map +1 -1
  82. package/dist/entrypoints/legacy.js +4 -2
  83. package/dist/entrypoints/legacy.js.map +1 -1
  84. package/dist/entrypoints/public.js +1 -1
  85. package/dist/entrypoints/public.js.map +1 -1
  86. package/dist/feature-libraries/changeAtomIdCodec.d.ts +4 -3
  87. package/dist/feature-libraries/changeAtomIdCodec.d.ts.map +1 -1
  88. package/dist/feature-libraries/changeAtomIdCodec.js +2 -0
  89. package/dist/feature-libraries/changeAtomIdCodec.js.map +1 -1
  90. package/dist/feature-libraries/chunked-forest/chunkTree.d.ts +2 -2
  91. package/dist/feature-libraries/chunked-forest/chunkTree.d.ts.map +1 -1
  92. package/dist/feature-libraries/chunked-forest/chunkTree.js +2 -1
  93. package/dist/feature-libraries/chunked-forest/chunkTree.js.map +1 -1
  94. package/dist/feature-libraries/chunked-forest/chunkedForest.d.ts +2 -1
  95. package/dist/feature-libraries/chunked-forest/chunkedForest.d.ts.map +1 -1
  96. package/dist/feature-libraries/chunked-forest/chunkedForest.js +2 -2
  97. package/dist/feature-libraries/chunked-forest/chunkedForest.js.map +1 -1
  98. package/dist/feature-libraries/chunked-forest/codec/chunkDecoding.d.ts +4 -4
  99. package/dist/feature-libraries/chunked-forest/codec/chunkDecoding.d.ts.map +1 -1
  100. package/dist/feature-libraries/chunked-forest/codec/chunkDecoding.js +6 -6
  101. package/dist/feature-libraries/chunked-forest/codec/chunkDecoding.js.map +1 -1
  102. package/dist/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.d.ts +1 -1
  103. package/dist/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.d.ts.map +1 -1
  104. package/dist/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.js.map +1 -1
  105. package/dist/feature-libraries/chunked-forest/codec/chunkEncodingGeneric.d.ts +1 -2
  106. package/dist/feature-libraries/chunked-forest/codec/chunkEncodingGeneric.d.ts.map +1 -1
  107. package/dist/feature-libraries/chunked-forest/codec/chunkEncodingGeneric.js.map +1 -1
  108. package/dist/feature-libraries/chunked-forest/codec/codecs.d.ts +4 -4
  109. package/dist/feature-libraries/chunked-forest/codec/codecs.d.ts.map +1 -1
  110. package/dist/feature-libraries/chunked-forest/codec/codecs.js +6 -6
  111. package/dist/feature-libraries/chunked-forest/codec/codecs.js.map +1 -1
  112. package/dist/feature-libraries/chunked-forest/codec/compressedEncode.d.ts +12 -12
  113. package/dist/feature-libraries/chunked-forest/codec/compressedEncode.d.ts.map +1 -1
  114. package/dist/feature-libraries/chunked-forest/codec/compressedEncode.js +3 -3
  115. package/dist/feature-libraries/chunked-forest/codec/compressedEncode.js.map +1 -1
  116. package/dist/feature-libraries/chunked-forest/codec/{formatGeneric.d.ts → format/formatGeneric.d.ts} +1 -1
  117. package/dist/feature-libraries/chunked-forest/codec/format/formatGeneric.d.ts.map +1 -0
  118. package/dist/feature-libraries/chunked-forest/codec/format/formatGeneric.js.map +1 -0
  119. package/dist/feature-libraries/chunked-forest/codec/format/formatV1.d.ts +187 -0
  120. package/dist/feature-libraries/chunked-forest/codec/format/formatV1.d.ts.map +1 -0
  121. package/dist/feature-libraries/chunked-forest/codec/format/formatV1.js +115 -0
  122. package/dist/feature-libraries/chunked-forest/codec/format/formatV1.js.map +1 -0
  123. package/dist/feature-libraries/chunked-forest/codec/format/formatV2.d.ts +33 -0
  124. package/dist/feature-libraries/chunked-forest/codec/format/formatV2.d.ts.map +1 -0
  125. package/dist/feature-libraries/chunked-forest/codec/format/formatV2.js +16 -0
  126. package/dist/feature-libraries/chunked-forest/codec/format/formatV2.js.map +1 -0
  127. package/dist/feature-libraries/chunked-forest/codec/format/index.d.ts +10 -0
  128. package/dist/feature-libraries/chunked-forest/codec/format/index.d.ts.map +1 -0
  129. package/dist/feature-libraries/chunked-forest/codec/format/index.js +18 -0
  130. package/dist/feature-libraries/chunked-forest/codec/format/index.js.map +1 -0
  131. package/dist/feature-libraries/chunked-forest/codec/format/versions.d.ts +93 -0
  132. package/dist/feature-libraries/chunked-forest/codec/format/versions.d.ts.map +1 -0
  133. package/dist/feature-libraries/chunked-forest/codec/format/versions.js +29 -0
  134. package/dist/feature-libraries/chunked-forest/codec/format/versions.js.map +1 -0
  135. package/dist/feature-libraries/chunked-forest/codec/index.d.ts +2 -2
  136. package/dist/feature-libraries/chunked-forest/codec/index.d.ts.map +1 -1
  137. package/dist/feature-libraries/chunked-forest/codec/index.js +2 -2
  138. package/dist/feature-libraries/chunked-forest/codec/index.js.map +1 -1
  139. package/dist/feature-libraries/chunked-forest/codec/nodeEncoder.d.ts +7 -7
  140. package/dist/feature-libraries/chunked-forest/codec/nodeEncoder.d.ts.map +1 -1
  141. package/dist/feature-libraries/chunked-forest/codec/nodeEncoder.js.map +1 -1
  142. package/dist/feature-libraries/chunked-forest/codec/schemaBasedEncode.d.ts +1 -1
  143. package/dist/feature-libraries/chunked-forest/codec/schemaBasedEncode.d.ts.map +1 -1
  144. package/dist/feature-libraries/chunked-forest/codec/schemaBasedEncode.js +6 -4
  145. package/dist/feature-libraries/chunked-forest/codec/schemaBasedEncode.js.map +1 -1
  146. package/dist/feature-libraries/chunked-forest/codec/uncompressedEncode.d.ts +1 -1
  147. package/dist/feature-libraries/chunked-forest/codec/uncompressedEncode.d.ts.map +1 -1
  148. package/dist/feature-libraries/chunked-forest/codec/uncompressedEncode.js +3 -3
  149. package/dist/feature-libraries/chunked-forest/codec/uncompressedEncode.js.map +1 -1
  150. package/dist/feature-libraries/chunked-forest/index.d.ts +1 -1
  151. package/dist/feature-libraries/chunked-forest/index.d.ts.map +1 -1
  152. package/dist/feature-libraries/chunked-forest/index.js.map +1 -1
  153. package/dist/feature-libraries/chunked-forest/uniformChunk.d.ts +13 -5
  154. package/dist/feature-libraries/chunked-forest/uniformChunk.d.ts.map +1 -1
  155. package/dist/feature-libraries/chunked-forest/uniformChunk.js +22 -18
  156. package/dist/feature-libraries/chunked-forest/uniformChunk.js.map +1 -1
  157. package/dist/feature-libraries/cursorComparator.d.ts +23 -0
  158. package/dist/feature-libraries/cursorComparator.d.ts.map +1 -0
  159. package/dist/feature-libraries/cursorComparator.js +65 -0
  160. package/dist/feature-libraries/cursorComparator.js.map +1 -0
  161. package/dist/feature-libraries/forest-summary/codec.d.ts +1 -1
  162. package/dist/feature-libraries/forest-summary/incrementalSummaryBuilder.d.ts +3 -3
  163. package/dist/feature-libraries/forest-summary/incrementalSummaryBuilder.d.ts.map +1 -1
  164. package/dist/feature-libraries/forest-summary/incrementalSummaryBuilder.js.map +1 -1
  165. package/dist/feature-libraries/index.d.ts +3 -2
  166. package/dist/feature-libraries/index.d.ts.map +1 -1
  167. package/dist/feature-libraries/index.js +5 -5
  168. package/dist/feature-libraries/index.js.map +1 -1
  169. package/dist/feature-libraries/indexing/anchorTreeIndex.d.ts +3 -0
  170. package/dist/feature-libraries/indexing/anchorTreeIndex.d.ts.map +1 -1
  171. package/dist/feature-libraries/indexing/anchorTreeIndex.js +15 -8
  172. package/dist/feature-libraries/indexing/anchorTreeIndex.js.map +1 -1
  173. package/dist/feature-libraries/indexing/types.d.ts +4 -3
  174. package/dist/feature-libraries/indexing/types.d.ts.map +1 -1
  175. package/dist/feature-libraries/indexing/types.js.map +1 -1
  176. package/dist/feature-libraries/mitigatedChangeFamily.d.ts.map +1 -1
  177. package/dist/feature-libraries/mitigatedChangeFamily.js +2 -2
  178. package/dist/feature-libraries/mitigatedChangeFamily.js.map +1 -1
  179. package/dist/feature-libraries/modular-schema/fieldChangeHandler.d.ts +3 -3
  180. package/dist/feature-libraries/modular-schema/fieldChangeHandler.d.ts.map +1 -1
  181. package/dist/feature-libraries/modular-schema/fieldChangeHandler.js.map +1 -1
  182. package/dist/feature-libraries/modular-schema/genericFieldKind.d.ts.map +1 -1
  183. package/dist/feature-libraries/modular-schema/genericFieldKind.js +0 -1
  184. package/dist/feature-libraries/modular-schema/genericFieldKind.js.map +1 -1
  185. package/dist/feature-libraries/modular-schema/modularChangeCodecV1.d.ts +10 -10
  186. package/dist/feature-libraries/modular-schema/modularChangeCodecV1.d.ts.map +1 -1
  187. package/dist/feature-libraries/modular-schema/modularChangeCodecV1.js +2 -4
  188. package/dist/feature-libraries/modular-schema/modularChangeCodecV1.js.map +1 -1
  189. package/dist/feature-libraries/modular-schema/modularChangeCodecV2.d.ts +3 -3
  190. package/dist/feature-libraries/modular-schema/modularChangeCodecV2.d.ts.map +1 -1
  191. package/dist/feature-libraries/modular-schema/modularChangeCodecV2.js.map +1 -1
  192. package/dist/feature-libraries/modular-schema/modularChangeCodecs.d.ts +3 -3
  193. package/dist/feature-libraries/modular-schema/modularChangeCodecs.d.ts.map +1 -1
  194. package/dist/feature-libraries/modular-schema/modularChangeCodecs.js.map +1 -1
  195. package/dist/feature-libraries/modular-schema/modularChangeFamily.d.ts +1 -1
  196. package/dist/feature-libraries/modular-schema/modularChangeFamily.d.ts.map +1 -1
  197. package/dist/feature-libraries/modular-schema/modularChangeFamily.js +4 -3
  198. package/dist/feature-libraries/modular-schema/modularChangeFamily.js.map +1 -1
  199. package/dist/feature-libraries/object-forest/objectForest.d.ts +1 -1
  200. package/dist/feature-libraries/object-forest/objectForest.d.ts.map +1 -1
  201. package/dist/feature-libraries/object-forest/objectForest.js +2 -2
  202. package/dist/feature-libraries/object-forest/objectForest.js.map +1 -1
  203. package/dist/feature-libraries/optional-field/optionalFieldCodecV2.d.ts +4 -4
  204. package/dist/feature-libraries/optional-field/optionalFieldCodecV2.d.ts.map +1 -1
  205. package/dist/feature-libraries/optional-field/optionalFieldCodecV2.js.map +1 -1
  206. package/dist/feature-libraries/optional-field/optionalFieldCodecs.d.ts +3 -3
  207. package/dist/feature-libraries/optional-field/optionalFieldCodecs.d.ts.map +1 -1
  208. package/dist/feature-libraries/optional-field/optionalFieldCodecs.js.map +1 -1
  209. package/dist/feature-libraries/schema-edits/index.d.ts +1 -1
  210. package/dist/feature-libraries/schema-edits/index.d.ts.map +1 -1
  211. package/dist/feature-libraries/schema-edits/index.js +2 -3
  212. package/dist/feature-libraries/schema-edits/index.js.map +1 -1
  213. package/dist/feature-libraries/schema-edits/schemaChangeCodecs.d.ts +6 -15
  214. package/dist/feature-libraries/schema-edits/schemaChangeCodecs.d.ts.map +1 -1
  215. package/dist/feature-libraries/schema-edits/schemaChangeCodecs.js +8 -54
  216. package/dist/feature-libraries/schema-edits/schemaChangeCodecs.js.map +1 -1
  217. package/dist/feature-libraries/schema-index/codec.d.ts +3 -16
  218. package/dist/feature-libraries/schema-index/codec.d.ts.map +1 -1
  219. package/dist/feature-libraries/schema-index/codec.js +1 -21
  220. package/dist/feature-libraries/schema-index/codec.js.map +1 -1
  221. package/dist/feature-libraries/schema-index/formatV2.d.ts +1 -1
  222. package/dist/feature-libraries/schema-index/formatV2.js +1 -1
  223. package/dist/feature-libraries/schema-index/formatV2.js.map +1 -1
  224. package/dist/feature-libraries/schema-index/index.d.ts +1 -1
  225. package/dist/feature-libraries/schema-index/index.d.ts.map +1 -1
  226. package/dist/feature-libraries/schema-index/index.js +1 -2
  227. package/dist/feature-libraries/schema-index/index.js.map +1 -1
  228. package/dist/feature-libraries/sequence-field/sequenceFieldCodecV2.d.ts +4 -4
  229. package/dist/feature-libraries/sequence-field/sequenceFieldCodecV2.d.ts.map +1 -1
  230. package/dist/feature-libraries/sequence-field/sequenceFieldCodecV2.js.map +1 -1
  231. package/dist/feature-libraries/sequence-field/sequenceFieldCodecV3.d.ts +3 -3
  232. package/dist/feature-libraries/sequence-field/sequenceFieldCodecV3.d.ts.map +1 -1
  233. package/dist/feature-libraries/sequence-field/sequenceFieldCodecV3.js.map +1 -1
  234. package/dist/feature-libraries/sequence-field/sequenceFieldCodecs.d.ts +3 -3
  235. package/dist/feature-libraries/sequence-field/sequenceFieldCodecs.d.ts.map +1 -1
  236. package/dist/feature-libraries/sequence-field/sequenceFieldCodecs.js.map +1 -1
  237. package/dist/index.d.ts +2 -2
  238. package/dist/index.d.ts.map +1 -1
  239. package/dist/index.js +2 -3
  240. package/dist/index.js.map +1 -1
  241. package/dist/packageVersion.d.ts +1 -1
  242. package/dist/packageVersion.js +1 -1
  243. package/dist/packageVersion.js.map +1 -1
  244. package/dist/serializableDomainSchema.d.ts +5 -5
  245. package/dist/serializableDomainSchema.d.ts.map +1 -1
  246. package/dist/serializableDomainSchema.js.map +1 -1
  247. package/dist/shared-tree/independentView.d.ts +1 -1
  248. package/dist/shared-tree/independentView.d.ts.map +1 -1
  249. package/dist/shared-tree/independentView.js +14 -21
  250. package/dist/shared-tree/independentView.js.map +1 -1
  251. package/dist/shared-tree/index.d.ts +2 -2
  252. package/dist/shared-tree/index.d.ts.map +1 -1
  253. package/dist/shared-tree/index.js +1 -2
  254. package/dist/shared-tree/index.js.map +1 -1
  255. package/dist/shared-tree/schematizingTreeView.d.ts +2 -36
  256. package/dist/shared-tree/schematizingTreeView.d.ts.map +1 -1
  257. package/dist/shared-tree/schematizingTreeView.js +15 -117
  258. package/dist/shared-tree/schematizingTreeView.js.map +1 -1
  259. package/dist/shared-tree/sharedTree.d.ts +3 -22
  260. package/dist/shared-tree/sharedTree.d.ts.map +1 -1
  261. package/dist/shared-tree/sharedTree.js +10 -27
  262. package/dist/shared-tree/sharedTree.js.map +1 -1
  263. package/dist/shared-tree/sharedTreeChangeCodecs.d.ts +3 -2
  264. package/dist/shared-tree/sharedTreeChangeCodecs.d.ts.map +1 -1
  265. package/dist/shared-tree/sharedTreeChangeCodecs.js +23 -16
  266. package/dist/shared-tree/sharedTreeChangeCodecs.js.map +1 -1
  267. package/dist/shared-tree/sharedTreeChangeEnricher.d.ts.map +1 -1
  268. package/dist/shared-tree/sharedTreeChangeEnricher.js +1 -1
  269. package/dist/shared-tree/sharedTreeChangeEnricher.js.map +1 -1
  270. package/dist/shared-tree/sharedTreeChangeFamily.d.ts +1 -1
  271. package/dist/shared-tree/sharedTreeChangeFamily.d.ts.map +1 -1
  272. package/dist/shared-tree/sharedTreeChangeFamily.js +2 -2
  273. package/dist/shared-tree/sharedTreeChangeFamily.js.map +1 -1
  274. package/dist/shared-tree/sharedTreeChangeFormat.d.ts +8 -7
  275. package/dist/shared-tree/sharedTreeChangeFormat.d.ts.map +1 -1
  276. package/dist/shared-tree/sharedTreeChangeFormat.js +13 -5
  277. package/dist/shared-tree/sharedTreeChangeFormat.js.map +1 -1
  278. package/dist/shared-tree/tree.d.ts.map +1 -1
  279. package/dist/shared-tree/tree.js +2 -1
  280. package/dist/shared-tree/tree.js.map +1 -1
  281. package/dist/shared-tree/treeAlpha.d.ts +17 -1
  282. package/dist/shared-tree/treeAlpha.d.ts.map +1 -1
  283. package/dist/shared-tree/treeAlpha.js +3 -0
  284. package/dist/shared-tree/treeAlpha.js.map +1 -1
  285. package/dist/shared-tree/treeCheckout.d.ts +34 -69
  286. package/dist/shared-tree/treeCheckout.d.ts.map +1 -1
  287. package/dist/shared-tree/treeCheckout.js +885 -678
  288. package/dist/shared-tree/treeCheckout.js.map +1 -1
  289. package/dist/shared-tree/unhydratedTreeContext.js +3 -3
  290. package/dist/shared-tree/unhydratedTreeContext.js.map +1 -1
  291. package/dist/shared-tree-core/editManagerCodecs.d.ts +23 -12
  292. package/dist/shared-tree-core/editManagerCodecs.d.ts.map +1 -1
  293. package/dist/shared-tree-core/editManagerCodecs.js +40 -67
  294. package/dist/shared-tree-core/editManagerCodecs.js.map +1 -1
  295. package/dist/shared-tree-core/editManagerCodecsCommons.d.ts.map +1 -1
  296. package/dist/shared-tree-core/editManagerCodecsCommons.js +0 -1
  297. package/dist/shared-tree-core/editManagerCodecsCommons.js.map +1 -1
  298. package/dist/shared-tree-core/editManagerCodecsV1toV4.d.ts +10 -2
  299. package/dist/shared-tree-core/editManagerCodecsV1toV4.d.ts.map +1 -1
  300. package/dist/shared-tree-core/editManagerCodecsV1toV4.js +18 -13
  301. package/dist/shared-tree-core/editManagerCodecsV1toV4.js.map +1 -1
  302. package/dist/shared-tree-core/editManagerCodecsVSharedBranches.d.ts +2 -2
  303. package/dist/shared-tree-core/editManagerCodecsVSharedBranches.d.ts.map +1 -1
  304. package/dist/shared-tree-core/editManagerCodecsVSharedBranches.js +6 -9
  305. package/dist/shared-tree-core/editManagerCodecsVSharedBranches.js.map +1 -1
  306. package/dist/shared-tree-core/index.d.ts +3 -3
  307. package/dist/shared-tree-core/index.d.ts.map +1 -1
  308. package/dist/shared-tree-core/index.js +5 -8
  309. package/dist/shared-tree-core/index.js.map +1 -1
  310. package/dist/shared-tree-core/messageCodecV1ToV4.d.ts +2 -3
  311. package/dist/shared-tree-core/messageCodecV1ToV4.d.ts.map +1 -1
  312. package/dist/shared-tree-core/messageCodecV1ToV4.js +8 -8
  313. package/dist/shared-tree-core/messageCodecV1ToV4.js.map +1 -1
  314. package/dist/shared-tree-core/messageCodecVSharedBranches.d.ts +2 -3
  315. package/dist/shared-tree-core/messageCodecVSharedBranches.d.ts.map +1 -1
  316. package/dist/shared-tree-core/messageCodecVSharedBranches.js +5 -4
  317. package/dist/shared-tree-core/messageCodecVSharedBranches.js.map +1 -1
  318. package/dist/shared-tree-core/messageCodecs.d.ts +15 -14
  319. package/dist/shared-tree-core/messageCodecs.d.ts.map +1 -1
  320. package/dist/shared-tree-core/messageCodecs.js +38 -74
  321. package/dist/shared-tree-core/messageCodecs.js.map +1 -1
  322. package/dist/shared-tree-core/messageFormat.d.ts +0 -1
  323. package/dist/shared-tree-core/messageFormat.d.ts.map +1 -1
  324. package/dist/shared-tree-core/messageFormat.js +1 -2
  325. package/dist/shared-tree-core/messageFormat.js.map +1 -1
  326. package/dist/shared-tree-core/sharedTreeCore.d.ts +1 -3
  327. package/dist/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
  328. package/dist/shared-tree-core/sharedTreeCore.js +12 -2
  329. package/dist/shared-tree-core/sharedTreeCore.js.map +1 -1
  330. package/dist/sharedTreeAttributes.d.ts.map +1 -1
  331. package/dist/sharedTreeAttributes.js +3 -0
  332. package/dist/sharedTreeAttributes.js.map +1 -1
  333. package/dist/simple-tree/api/discrepancies.js +4 -1
  334. package/dist/simple-tree/api/discrepancies.js.map +1 -1
  335. package/dist/simple-tree/api/identifierIndex.d.ts +2 -2
  336. package/dist/simple-tree/api/identifierIndex.js +1 -1
  337. package/dist/simple-tree/api/identifierIndex.js.map +1 -1
  338. package/dist/simple-tree/api/index.d.ts +2 -1
  339. package/dist/simple-tree/api/index.d.ts.map +1 -1
  340. package/dist/simple-tree/api/index.js +3 -2
  341. package/dist/simple-tree/api/index.js.map +1 -1
  342. package/dist/simple-tree/api/schemaFactory.d.ts.map +1 -1
  343. package/dist/simple-tree/api/schemaFactory.js.map +1 -1
  344. package/dist/simple-tree/api/schemaFactoryAlpha.d.ts +33 -4
  345. package/dist/simple-tree/api/schemaFactoryAlpha.d.ts.map +1 -1
  346. package/dist/simple-tree/api/schemaFactoryAlpha.js +17 -1
  347. package/dist/simple-tree/api/schemaFactoryAlpha.js.map +1 -1
  348. package/dist/simple-tree/api/simpleTreeIndex.d.ts +5 -5
  349. package/dist/simple-tree/api/simpleTreeIndex.js +1 -1
  350. package/dist/simple-tree/api/simpleTreeIndex.js.map +1 -1
  351. package/dist/simple-tree/api/storedSchema.d.ts.map +1 -1
  352. package/dist/simple-tree/api/storedSchema.js +10 -7
  353. package/dist/simple-tree/api/storedSchema.js.map +1 -1
  354. package/dist/simple-tree/api/tree.d.ts +7 -19
  355. package/dist/simple-tree/api/tree.d.ts.map +1 -1
  356. package/dist/simple-tree/api/tree.js.map +1 -1
  357. package/dist/simple-tree/api/treeAlpha.d.ts +126 -0
  358. package/dist/simple-tree/api/treeAlpha.d.ts.map +1 -0
  359. package/dist/simple-tree/api/treeAlpha.js +7 -0
  360. package/dist/simple-tree/api/treeAlpha.js.map +1 -0
  361. package/dist/simple-tree/api/treeBeta.d.ts +1 -1
  362. package/dist/simple-tree/api/treeBeta.js.map +1 -1
  363. package/dist/simple-tree/api/treeChangeEvents.d.ts +4 -1
  364. package/dist/simple-tree/api/treeChangeEvents.d.ts.map +1 -1
  365. package/dist/simple-tree/api/treeChangeEvents.js.map +1 -1
  366. package/dist/simple-tree/api/treeNodeApi.d.ts +108 -0
  367. package/dist/simple-tree/api/treeNodeApi.d.ts.map +1 -1
  368. package/dist/simple-tree/api/treeNodeApi.js +104 -3
  369. package/dist/simple-tree/api/treeNodeApi.js.map +1 -1
  370. package/dist/simple-tree/core/toStored.d.ts +7 -0
  371. package/dist/simple-tree/core/toStored.d.ts.map +1 -1
  372. package/dist/simple-tree/core/toStored.js.map +1 -1
  373. package/dist/simple-tree/core/treeNodeKernel.d.ts.map +1 -1
  374. package/dist/simple-tree/core/treeNodeKernel.js +45 -8
  375. package/dist/simple-tree/core/treeNodeKernel.js.map +1 -1
  376. package/dist/simple-tree/core/unhydratedFlexTree.d.ts +17 -3
  377. package/dist/simple-tree/core/unhydratedFlexTree.d.ts.map +1 -1
  378. package/dist/simple-tree/core/unhydratedFlexTree.js +117 -11
  379. package/dist/simple-tree/core/unhydratedFlexTree.js.map +1 -1
  380. package/dist/simple-tree/fieldSchema.d.ts +6 -1
  381. package/dist/simple-tree/fieldSchema.d.ts.map +1 -1
  382. package/dist/simple-tree/fieldSchema.js +3 -0
  383. package/dist/simple-tree/fieldSchema.js.map +1 -1
  384. package/dist/simple-tree/index.d.ts +2 -2
  385. package/dist/simple-tree/index.d.ts.map +1 -1
  386. package/dist/simple-tree/index.js +4 -3
  387. package/dist/simple-tree/index.js.map +1 -1
  388. package/dist/simple-tree/node-kinds/array/arrayNode.d.ts +16 -0
  389. package/dist/simple-tree/node-kinds/array/arrayNode.d.ts.map +1 -1
  390. package/dist/simple-tree/node-kinds/array/arrayNode.js +23 -0
  391. package/dist/simple-tree/node-kinds/array/arrayNode.js.map +1 -1
  392. package/dist/simple-tree/node-kinds/array/arrayNodeTypes.d.ts +10 -1
  393. package/dist/simple-tree/node-kinds/array/arrayNodeTypes.d.ts.map +1 -1
  394. package/dist/simple-tree/node-kinds/array/arrayNodeTypes.js.map +1 -1
  395. package/dist/simple-tree/node-kinds/array/index.d.ts +2 -2
  396. package/dist/simple-tree/node-kinds/array/index.d.ts.map +1 -1
  397. package/dist/simple-tree/node-kinds/array/index.js.map +1 -1
  398. package/dist/simple-tree/node-kinds/index.d.ts +2 -2
  399. package/dist/simple-tree/node-kinds/index.d.ts.map +1 -1
  400. package/dist/simple-tree/node-kinds/index.js.map +1 -1
  401. package/dist/simple-tree/node-kinds/map/index.d.ts +1 -1
  402. package/dist/simple-tree/node-kinds/map/index.d.ts.map +1 -1
  403. package/dist/simple-tree/node-kinds/map/index.js.map +1 -1
  404. package/dist/simple-tree/node-kinds/map/mapNode.d.ts +13 -0
  405. package/dist/simple-tree/node-kinds/map/mapNode.d.ts.map +1 -1
  406. package/dist/simple-tree/node-kinds/map/mapNode.js +6 -1
  407. package/dist/simple-tree/node-kinds/map/mapNode.js.map +1 -1
  408. package/dist/simple-tree/node-kinds/map/mapNodeTypes.d.ts +6 -6
  409. package/dist/simple-tree/node-kinds/map/mapNodeTypes.d.ts.map +1 -1
  410. package/dist/simple-tree/node-kinds/map/mapNodeTypes.js.map +1 -1
  411. package/dist/simple-tree/simpleSchema.d.ts +17 -0
  412. package/dist/simple-tree/simpleSchema.d.ts.map +1 -1
  413. package/dist/simple-tree/simpleSchema.js.map +1 -1
  414. package/dist/simple-tree/toStoredSchema.d.ts.map +1 -1
  415. package/dist/simple-tree/toStoredSchema.js +23 -1
  416. package/dist/simple-tree/toStoredSchema.js.map +1 -1
  417. package/dist/tableSchema.d.ts +4 -5
  418. package/dist/tableSchema.d.ts.map +1 -1
  419. package/dist/tableSchema.js +12 -23
  420. package/dist/tableSchema.js.map +1 -1
  421. package/dist/text/textDomain.d.ts.map +1 -1
  422. package/dist/text/textDomain.js +27 -0
  423. package/dist/text/textDomain.js.map +1 -1
  424. package/dist/text/textDomainFormatted.d.ts +321 -11
  425. package/dist/text/textDomainFormatted.d.ts.map +1 -1
  426. package/dist/text/textDomainFormatted.js +100 -25
  427. package/dist/text/textDomainFormatted.js.map +1 -1
  428. package/dist/treeFactory.d.ts.map +1 -1
  429. package/dist/treeFactory.js +5 -2
  430. package/dist/treeFactory.js.map +1 -1
  431. package/dist/util/index.d.ts +1 -1
  432. package/dist/util/index.d.ts.map +1 -1
  433. package/dist/util/index.js +2 -3
  434. package/dist/util/index.js.map +1 -1
  435. package/dist/util/referenceCounting.d.ts.map +1 -1
  436. package/dist/util/referenceCounting.js +0 -1
  437. package/dist/util/referenceCounting.js.map +1 -1
  438. package/dist/util/utils.d.ts +0 -1
  439. package/dist/util/utils.d.ts.map +1 -1
  440. package/dist/util/utils.js +1 -6
  441. package/dist/util/utils.js.map +1 -1
  442. package/eslint.config.mts +1 -1
  443. package/legacy.d.ts +2 -3
  444. package/lib/api.d.ts +11 -1
  445. package/lib/api.d.ts.map +1 -1
  446. package/lib/api.js.map +1 -1
  447. package/lib/codec/codec.d.ts +28 -2
  448. package/lib/codec/codec.d.ts.map +1 -1
  449. package/lib/codec/codec.js +1 -0
  450. package/lib/codec/codec.js.map +1 -1
  451. package/lib/codec/index.d.ts +2 -2
  452. package/lib/codec/index.d.ts.map +1 -1
  453. package/lib/codec/index.js +1 -1
  454. package/lib/codec/index.js.map +1 -1
  455. package/lib/codec/versioned/codec.d.ts +18 -36
  456. package/lib/codec/versioned/codec.d.ts.map +1 -1
  457. package/lib/codec/versioned/codec.js +45 -56
  458. package/lib/codec/versioned/codec.js.map +1 -1
  459. package/lib/codec/versioned/index.d.ts +1 -1
  460. package/lib/codec/versioned/index.d.ts.map +1 -1
  461. package/lib/codec/versioned/index.js +1 -1
  462. package/lib/codec/versioned/index.js.map +1 -1
  463. package/lib/core/forest/forest.d.ts +5 -2
  464. package/lib/core/forest/forest.d.ts.map +1 -1
  465. package/lib/core/forest/forest.js.map +1 -1
  466. package/lib/core/index.d.ts +1 -1
  467. package/lib/core/index.d.ts.map +1 -1
  468. package/lib/core/index.js +1 -1
  469. package/lib/core/index.js.map +1 -1
  470. package/lib/core/rebase/changeRebaser.d.ts +8 -1
  471. package/lib/core/rebase/changeRebaser.d.ts.map +1 -1
  472. package/lib/core/rebase/changeRebaser.js.map +1 -1
  473. package/lib/core/rebase/revisionTagCodec.d.ts +4 -3
  474. package/lib/core/rebase/revisionTagCodec.d.ts.map +1 -1
  475. package/lib/core/rebase/revisionTagCodec.js +2 -0
  476. package/lib/core/rebase/revisionTagCodec.js.map +1 -1
  477. package/lib/core/rebase/utils.d.ts +2 -2
  478. package/lib/core/rebase/utils.d.ts.map +1 -1
  479. package/lib/core/rebase/utils.js +4 -4
  480. package/lib/core/rebase/utils.js.map +1 -1
  481. package/lib/core/schema-stored/formatV2.d.ts +1 -1
  482. package/lib/core/schema-stored/formatV2.js +1 -1
  483. package/lib/core/schema-stored/formatV2.js.map +1 -1
  484. package/lib/core/tree/anchorSet.d.ts +8 -0
  485. package/lib/core/tree/anchorSet.d.ts.map +1 -1
  486. package/lib/core/tree/anchorSet.js +63 -7
  487. package/lib/core/tree/anchorSet.js.map +1 -1
  488. package/lib/core/tree/cursor.d.ts +25 -1
  489. package/lib/core/tree/cursor.d.ts.map +1 -1
  490. package/lib/core/tree/cursor.js +43 -0
  491. package/lib/core/tree/cursor.js.map +1 -1
  492. package/lib/core/tree/deltaUtil.d.ts +13 -1
  493. package/lib/core/tree/deltaUtil.d.ts.map +1 -1
  494. package/lib/core/tree/deltaUtil.js +31 -0
  495. package/lib/core/tree/deltaUtil.js.map +1 -1
  496. package/lib/core/tree/detachedFieldIndexCodecs.d.ts +5 -5
  497. package/lib/core/tree/detachedFieldIndexCodecs.d.ts.map +1 -1
  498. package/lib/core/tree/detachedFieldIndexCodecs.js.map +1 -1
  499. package/lib/core/tree/index.d.ts +2 -2
  500. package/lib/core/tree/index.d.ts.map +1 -1
  501. package/lib/core/tree/index.js +2 -2
  502. package/lib/core/tree/index.js.map +1 -1
  503. package/lib/core/tree/visitDelta.d.ts +11 -0
  504. package/lib/core/tree/visitDelta.d.ts.map +1 -1
  505. package/lib/core/tree/visitDelta.js +1 -1
  506. package/lib/core/tree/visitDelta.js.map +1 -1
  507. package/lib/core/tree/visitorUtils.d.ts.map +1 -1
  508. package/lib/core/tree/visitorUtils.js +5 -0
  509. package/lib/core/tree/visitorUtils.js.map +1 -1
  510. package/lib/entrypoints/alpha.d.ts +1 -1
  511. package/lib/entrypoints/alpha.d.ts.map +1 -1
  512. package/lib/entrypoints/alpha.js +2 -2
  513. package/lib/entrypoints/alpha.js.map +1 -1
  514. package/lib/entrypoints/beta.d.ts +1 -1
  515. package/lib/entrypoints/beta.d.ts.map +1 -1
  516. package/lib/entrypoints/beta.js +2 -2
  517. package/lib/entrypoints/beta.js.map +1 -1
  518. package/lib/entrypoints/legacy.d.ts +1 -1
  519. package/lib/entrypoints/legacy.d.ts.map +1 -1
  520. package/lib/entrypoints/legacy.js +2 -2
  521. package/lib/entrypoints/legacy.js.map +1 -1
  522. package/lib/entrypoints/public.js +1 -1
  523. package/lib/entrypoints/public.js.map +1 -1
  524. package/lib/feature-libraries/changeAtomIdCodec.d.ts +4 -3
  525. package/lib/feature-libraries/changeAtomIdCodec.d.ts.map +1 -1
  526. package/lib/feature-libraries/changeAtomIdCodec.js +2 -0
  527. package/lib/feature-libraries/changeAtomIdCodec.js.map +1 -1
  528. package/lib/feature-libraries/chunked-forest/chunkTree.d.ts +2 -2
  529. package/lib/feature-libraries/chunked-forest/chunkTree.d.ts.map +1 -1
  530. package/lib/feature-libraries/chunked-forest/chunkTree.js +2 -1
  531. package/lib/feature-libraries/chunked-forest/chunkTree.js.map +1 -1
  532. package/lib/feature-libraries/chunked-forest/chunkedForest.d.ts +2 -1
  533. package/lib/feature-libraries/chunked-forest/chunkedForest.d.ts.map +1 -1
  534. package/lib/feature-libraries/chunked-forest/chunkedForest.js +2 -2
  535. package/lib/feature-libraries/chunked-forest/chunkedForest.js.map +1 -1
  536. package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.d.ts +4 -4
  537. package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.d.ts.map +1 -1
  538. package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.js +4 -4
  539. package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.js.map +1 -1
  540. package/lib/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.d.ts +1 -1
  541. package/lib/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.d.ts.map +1 -1
  542. package/lib/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.js.map +1 -1
  543. package/lib/feature-libraries/chunked-forest/codec/chunkEncodingGeneric.d.ts +1 -2
  544. package/lib/feature-libraries/chunked-forest/codec/chunkEncodingGeneric.d.ts.map +1 -1
  545. package/lib/feature-libraries/chunked-forest/codec/chunkEncodingGeneric.js.map +1 -1
  546. package/lib/feature-libraries/chunked-forest/codec/codecs.d.ts +4 -4
  547. package/lib/feature-libraries/chunked-forest/codec/codecs.d.ts.map +1 -1
  548. package/lib/feature-libraries/chunked-forest/codec/codecs.js +1 -1
  549. package/lib/feature-libraries/chunked-forest/codec/codecs.js.map +1 -1
  550. package/lib/feature-libraries/chunked-forest/codec/compressedEncode.d.ts +12 -12
  551. package/lib/feature-libraries/chunked-forest/codec/compressedEncode.d.ts.map +1 -1
  552. package/lib/feature-libraries/chunked-forest/codec/compressedEncode.js +1 -1
  553. package/lib/feature-libraries/chunked-forest/codec/compressedEncode.js.map +1 -1
  554. package/lib/feature-libraries/chunked-forest/codec/{formatGeneric.d.ts → format/formatGeneric.d.ts} +1 -1
  555. package/lib/feature-libraries/chunked-forest/codec/format/formatGeneric.d.ts.map +1 -0
  556. package/lib/feature-libraries/chunked-forest/codec/format/formatGeneric.js.map +1 -0
  557. package/lib/feature-libraries/chunked-forest/codec/format/formatV1.d.ts +187 -0
  558. package/lib/feature-libraries/chunked-forest/codec/format/formatV1.d.ts.map +1 -0
  559. package/lib/feature-libraries/chunked-forest/codec/format/formatV1.js +112 -0
  560. package/lib/feature-libraries/chunked-forest/codec/format/formatV1.js.map +1 -0
  561. package/lib/feature-libraries/chunked-forest/codec/format/formatV2.d.ts +33 -0
  562. package/lib/feature-libraries/chunked-forest/codec/format/formatV2.d.ts.map +1 -0
  563. package/lib/feature-libraries/chunked-forest/codec/format/formatV2.js +13 -0
  564. package/lib/feature-libraries/chunked-forest/codec/format/formatV2.js.map +1 -0
  565. package/lib/feature-libraries/chunked-forest/codec/format/index.d.ts +10 -0
  566. package/lib/feature-libraries/chunked-forest/codec/format/index.d.ts.map +1 -0
  567. package/lib/feature-libraries/chunked-forest/codec/format/index.js +8 -0
  568. package/lib/feature-libraries/chunked-forest/codec/format/index.js.map +1 -0
  569. package/lib/feature-libraries/chunked-forest/codec/format/versions.d.ts +93 -0
  570. package/lib/feature-libraries/chunked-forest/codec/format/versions.d.ts.map +1 -0
  571. package/lib/feature-libraries/chunked-forest/codec/format/versions.js +26 -0
  572. package/lib/feature-libraries/chunked-forest/codec/format/versions.js.map +1 -0
  573. package/lib/feature-libraries/chunked-forest/codec/index.d.ts +2 -2
  574. package/lib/feature-libraries/chunked-forest/codec/index.d.ts.map +1 -1
  575. package/lib/feature-libraries/chunked-forest/codec/index.js +1 -1
  576. package/lib/feature-libraries/chunked-forest/codec/index.js.map +1 -1
  577. package/lib/feature-libraries/chunked-forest/codec/nodeEncoder.d.ts +7 -7
  578. package/lib/feature-libraries/chunked-forest/codec/nodeEncoder.d.ts.map +1 -1
  579. package/lib/feature-libraries/chunked-forest/codec/nodeEncoder.js.map +1 -1
  580. package/lib/feature-libraries/chunked-forest/codec/schemaBasedEncode.d.ts +1 -1
  581. package/lib/feature-libraries/chunked-forest/codec/schemaBasedEncode.d.ts.map +1 -1
  582. package/lib/feature-libraries/chunked-forest/codec/schemaBasedEncode.js +4 -2
  583. package/lib/feature-libraries/chunked-forest/codec/schemaBasedEncode.js.map +1 -1
  584. package/lib/feature-libraries/chunked-forest/codec/uncompressedEncode.d.ts +1 -1
  585. package/lib/feature-libraries/chunked-forest/codec/uncompressedEncode.d.ts.map +1 -1
  586. package/lib/feature-libraries/chunked-forest/codec/uncompressedEncode.js +1 -1
  587. package/lib/feature-libraries/chunked-forest/codec/uncompressedEncode.js.map +1 -1
  588. package/lib/feature-libraries/chunked-forest/index.d.ts +1 -1
  589. package/lib/feature-libraries/chunked-forest/index.d.ts.map +1 -1
  590. package/lib/feature-libraries/chunked-forest/index.js.map +1 -1
  591. package/lib/feature-libraries/chunked-forest/uniformChunk.d.ts +13 -5
  592. package/lib/feature-libraries/chunked-forest/uniformChunk.d.ts.map +1 -1
  593. package/lib/feature-libraries/chunked-forest/uniformChunk.js +22 -18
  594. package/lib/feature-libraries/chunked-forest/uniformChunk.js.map +1 -1
  595. package/lib/feature-libraries/cursorComparator.d.ts +23 -0
  596. package/lib/feature-libraries/cursorComparator.d.ts.map +1 -0
  597. package/lib/feature-libraries/cursorComparator.js +61 -0
  598. package/lib/feature-libraries/cursorComparator.js.map +1 -0
  599. package/lib/feature-libraries/forest-summary/codec.d.ts +1 -1
  600. package/lib/feature-libraries/forest-summary/incrementalSummaryBuilder.d.ts +3 -3
  601. package/lib/feature-libraries/forest-summary/incrementalSummaryBuilder.d.ts.map +1 -1
  602. package/lib/feature-libraries/forest-summary/incrementalSummaryBuilder.js.map +1 -1
  603. package/lib/feature-libraries/index.d.ts +3 -2
  604. package/lib/feature-libraries/index.d.ts.map +1 -1
  605. package/lib/feature-libraries/index.js +3 -2
  606. package/lib/feature-libraries/index.js.map +1 -1
  607. package/lib/feature-libraries/indexing/anchorTreeIndex.d.ts +3 -0
  608. package/lib/feature-libraries/indexing/anchorTreeIndex.d.ts.map +1 -1
  609. package/lib/feature-libraries/indexing/anchorTreeIndex.js +15 -8
  610. package/lib/feature-libraries/indexing/anchorTreeIndex.js.map +1 -1
  611. package/lib/feature-libraries/indexing/types.d.ts +4 -3
  612. package/lib/feature-libraries/indexing/types.d.ts.map +1 -1
  613. package/lib/feature-libraries/indexing/types.js.map +1 -1
  614. package/lib/feature-libraries/mitigatedChangeFamily.d.ts.map +1 -1
  615. package/lib/feature-libraries/mitigatedChangeFamily.js +2 -2
  616. package/lib/feature-libraries/mitigatedChangeFamily.js.map +1 -1
  617. package/lib/feature-libraries/modular-schema/fieldChangeHandler.d.ts +3 -3
  618. package/lib/feature-libraries/modular-schema/fieldChangeHandler.d.ts.map +1 -1
  619. package/lib/feature-libraries/modular-schema/fieldChangeHandler.js.map +1 -1
  620. package/lib/feature-libraries/modular-schema/genericFieldKind.d.ts.map +1 -1
  621. package/lib/feature-libraries/modular-schema/genericFieldKind.js +0 -1
  622. package/lib/feature-libraries/modular-schema/genericFieldKind.js.map +1 -1
  623. package/lib/feature-libraries/modular-schema/modularChangeCodecV1.d.ts +10 -10
  624. package/lib/feature-libraries/modular-schema/modularChangeCodecV1.d.ts.map +1 -1
  625. package/lib/feature-libraries/modular-schema/modularChangeCodecV1.js +2 -4
  626. package/lib/feature-libraries/modular-schema/modularChangeCodecV1.js.map +1 -1
  627. package/lib/feature-libraries/modular-schema/modularChangeCodecV2.d.ts +3 -3
  628. package/lib/feature-libraries/modular-schema/modularChangeCodecV2.d.ts.map +1 -1
  629. package/lib/feature-libraries/modular-schema/modularChangeCodecV2.js.map +1 -1
  630. package/lib/feature-libraries/modular-schema/modularChangeCodecs.d.ts +3 -3
  631. package/lib/feature-libraries/modular-schema/modularChangeCodecs.d.ts.map +1 -1
  632. package/lib/feature-libraries/modular-schema/modularChangeCodecs.js.map +1 -1
  633. package/lib/feature-libraries/modular-schema/modularChangeFamily.d.ts +1 -1
  634. package/lib/feature-libraries/modular-schema/modularChangeFamily.d.ts.map +1 -1
  635. package/lib/feature-libraries/modular-schema/modularChangeFamily.js +4 -3
  636. package/lib/feature-libraries/modular-schema/modularChangeFamily.js.map +1 -1
  637. package/lib/feature-libraries/object-forest/objectForest.d.ts +1 -1
  638. package/lib/feature-libraries/object-forest/objectForest.d.ts.map +1 -1
  639. package/lib/feature-libraries/object-forest/objectForest.js +2 -2
  640. package/lib/feature-libraries/object-forest/objectForest.js.map +1 -1
  641. package/lib/feature-libraries/optional-field/optionalFieldCodecV2.d.ts +4 -4
  642. package/lib/feature-libraries/optional-field/optionalFieldCodecV2.d.ts.map +1 -1
  643. package/lib/feature-libraries/optional-field/optionalFieldCodecV2.js +1 -1
  644. package/lib/feature-libraries/optional-field/optionalFieldCodecV2.js.map +1 -1
  645. package/lib/feature-libraries/optional-field/optionalFieldCodecs.d.ts +3 -3
  646. package/lib/feature-libraries/optional-field/optionalFieldCodecs.d.ts.map +1 -1
  647. package/lib/feature-libraries/optional-field/optionalFieldCodecs.js.map +1 -1
  648. package/lib/feature-libraries/schema-edits/index.d.ts +1 -1
  649. package/lib/feature-libraries/schema-edits/index.d.ts.map +1 -1
  650. package/lib/feature-libraries/schema-edits/index.js +1 -1
  651. package/lib/feature-libraries/schema-edits/index.js.map +1 -1
  652. package/lib/feature-libraries/schema-edits/schemaChangeCodecs.d.ts +6 -15
  653. package/lib/feature-libraries/schema-edits/schemaChangeCodecs.d.ts.map +1 -1
  654. package/lib/feature-libraries/schema-edits/schemaChangeCodecs.js +6 -50
  655. package/lib/feature-libraries/schema-edits/schemaChangeCodecs.js.map +1 -1
  656. package/lib/feature-libraries/schema-index/codec.d.ts +3 -16
  657. package/lib/feature-libraries/schema-index/codec.d.ts.map +1 -1
  658. package/lib/feature-libraries/schema-index/codec.js +0 -19
  659. package/lib/feature-libraries/schema-index/codec.js.map +1 -1
  660. package/lib/feature-libraries/schema-index/formatV2.d.ts +1 -1
  661. package/lib/feature-libraries/schema-index/formatV2.js +1 -1
  662. package/lib/feature-libraries/schema-index/formatV2.js.map +1 -1
  663. package/lib/feature-libraries/schema-index/index.d.ts +1 -1
  664. package/lib/feature-libraries/schema-index/index.d.ts.map +1 -1
  665. package/lib/feature-libraries/schema-index/index.js +1 -1
  666. package/lib/feature-libraries/schema-index/index.js.map +1 -1
  667. package/lib/feature-libraries/sequence-field/sequenceFieldCodecV2.d.ts +4 -4
  668. package/lib/feature-libraries/sequence-field/sequenceFieldCodecV2.d.ts.map +1 -1
  669. package/lib/feature-libraries/sequence-field/sequenceFieldCodecV2.js.map +1 -1
  670. package/lib/feature-libraries/sequence-field/sequenceFieldCodecV3.d.ts +3 -3
  671. package/lib/feature-libraries/sequence-field/sequenceFieldCodecV3.d.ts.map +1 -1
  672. package/lib/feature-libraries/sequence-field/sequenceFieldCodecV3.js +1 -1
  673. package/lib/feature-libraries/sequence-field/sequenceFieldCodecV3.js.map +1 -1
  674. package/lib/feature-libraries/sequence-field/sequenceFieldCodecs.d.ts +3 -3
  675. package/lib/feature-libraries/sequence-field/sequenceFieldCodecs.d.ts.map +1 -1
  676. package/lib/feature-libraries/sequence-field/sequenceFieldCodecs.js.map +1 -1
  677. package/lib/index.d.ts +2 -2
  678. package/lib/index.d.ts.map +1 -1
  679. package/lib/index.js +1 -1
  680. package/lib/index.js.map +1 -1
  681. package/lib/packageVersion.d.ts +1 -1
  682. package/lib/packageVersion.js +1 -1
  683. package/lib/packageVersion.js.map +1 -1
  684. package/lib/serializableDomainSchema.d.ts +5 -5
  685. package/lib/serializableDomainSchema.d.ts.map +1 -1
  686. package/lib/serializableDomainSchema.js +4 -1
  687. package/lib/serializableDomainSchema.js.map +1 -1
  688. package/lib/shared-tree/independentView.d.ts +1 -1
  689. package/lib/shared-tree/independentView.d.ts.map +1 -1
  690. package/lib/shared-tree/independentView.js +4 -11
  691. package/lib/shared-tree/independentView.js.map +1 -1
  692. package/lib/shared-tree/index.d.ts +2 -2
  693. package/lib/shared-tree/index.d.ts.map +1 -1
  694. package/lib/shared-tree/index.js +1 -1
  695. package/lib/shared-tree/index.js.map +1 -1
  696. package/lib/shared-tree/schematizingTreeView.d.ts +2 -36
  697. package/lib/shared-tree/schematizingTreeView.d.ts.map +1 -1
  698. package/lib/shared-tree/schematizingTreeView.js +17 -116
  699. package/lib/shared-tree/schematizingTreeView.js.map +1 -1
  700. package/lib/shared-tree/sharedTree.d.ts +3 -22
  701. package/lib/shared-tree/sharedTree.d.ts.map +1 -1
  702. package/lib/shared-tree/sharedTree.js +11 -27
  703. package/lib/shared-tree/sharedTree.js.map +1 -1
  704. package/lib/shared-tree/sharedTreeChangeCodecs.d.ts +3 -2
  705. package/lib/shared-tree/sharedTreeChangeCodecs.d.ts.map +1 -1
  706. package/lib/shared-tree/sharedTreeChangeCodecs.js +19 -12
  707. package/lib/shared-tree/sharedTreeChangeCodecs.js.map +1 -1
  708. package/lib/shared-tree/sharedTreeChangeEnricher.d.ts.map +1 -1
  709. package/lib/shared-tree/sharedTreeChangeEnricher.js +2 -2
  710. package/lib/shared-tree/sharedTreeChangeEnricher.js.map +1 -1
  711. package/lib/shared-tree/sharedTreeChangeFamily.d.ts +1 -1
  712. package/lib/shared-tree/sharedTreeChangeFamily.d.ts.map +1 -1
  713. package/lib/shared-tree/sharedTreeChangeFamily.js +2 -2
  714. package/lib/shared-tree/sharedTreeChangeFamily.js.map +1 -1
  715. package/lib/shared-tree/sharedTreeChangeFormat.d.ts +8 -7
  716. package/lib/shared-tree/sharedTreeChangeFormat.d.ts.map +1 -1
  717. package/lib/shared-tree/sharedTreeChangeFormat.js +11 -5
  718. package/lib/shared-tree/sharedTreeChangeFormat.js.map +1 -1
  719. package/lib/shared-tree/tree.d.ts.map +1 -1
  720. package/lib/shared-tree/tree.js +2 -1
  721. package/lib/shared-tree/tree.js.map +1 -1
  722. package/lib/shared-tree/treeAlpha.d.ts +17 -1
  723. package/lib/shared-tree/treeAlpha.d.ts.map +1 -1
  724. package/lib/shared-tree/treeAlpha.js +3 -0
  725. package/lib/shared-tree/treeAlpha.js.map +1 -1
  726. package/lib/shared-tree/treeCheckout.d.ts +34 -69
  727. package/lib/shared-tree/treeCheckout.d.ts.map +1 -1
  728. package/lib/shared-tree/treeCheckout.js +889 -683
  729. package/lib/shared-tree/treeCheckout.js.map +1 -1
  730. package/lib/shared-tree/unhydratedTreeContext.js +1 -1
  731. package/lib/shared-tree/unhydratedTreeContext.js.map +1 -1
  732. package/lib/shared-tree-core/editManagerCodecs.d.ts +23 -12
  733. package/lib/shared-tree-core/editManagerCodecs.d.ts.map +1 -1
  734. package/lib/shared-tree-core/editManagerCodecs.js +41 -65
  735. package/lib/shared-tree-core/editManagerCodecs.js.map +1 -1
  736. package/lib/shared-tree-core/editManagerCodecsCommons.d.ts.map +1 -1
  737. package/lib/shared-tree-core/editManagerCodecsCommons.js +0 -1
  738. package/lib/shared-tree-core/editManagerCodecsCommons.js.map +1 -1
  739. package/lib/shared-tree-core/editManagerCodecsV1toV4.d.ts +10 -2
  740. package/lib/shared-tree-core/editManagerCodecsV1toV4.d.ts.map +1 -1
  741. package/lib/shared-tree-core/editManagerCodecsV1toV4.js +16 -11
  742. package/lib/shared-tree-core/editManagerCodecsV1toV4.js.map +1 -1
  743. package/lib/shared-tree-core/editManagerCodecsVSharedBranches.d.ts +2 -2
  744. package/lib/shared-tree-core/editManagerCodecsVSharedBranches.d.ts.map +1 -1
  745. package/lib/shared-tree-core/editManagerCodecsVSharedBranches.js +5 -8
  746. package/lib/shared-tree-core/editManagerCodecsVSharedBranches.js.map +1 -1
  747. package/lib/shared-tree-core/index.d.ts +3 -3
  748. package/lib/shared-tree-core/index.d.ts.map +1 -1
  749. package/lib/shared-tree-core/index.js +3 -3
  750. package/lib/shared-tree-core/index.js.map +1 -1
  751. package/lib/shared-tree-core/messageCodecV1ToV4.d.ts +2 -3
  752. package/lib/shared-tree-core/messageCodecV1ToV4.d.ts.map +1 -1
  753. package/lib/shared-tree-core/messageCodecV1ToV4.js +8 -8
  754. package/lib/shared-tree-core/messageCodecV1ToV4.js.map +1 -1
  755. package/lib/shared-tree-core/messageCodecVSharedBranches.d.ts +2 -3
  756. package/lib/shared-tree-core/messageCodecVSharedBranches.d.ts.map +1 -1
  757. package/lib/shared-tree-core/messageCodecVSharedBranches.js +5 -4
  758. package/lib/shared-tree-core/messageCodecVSharedBranches.js.map +1 -1
  759. package/lib/shared-tree-core/messageCodecs.d.ts +15 -14
  760. package/lib/shared-tree-core/messageCodecs.d.ts.map +1 -1
  761. package/lib/shared-tree-core/messageCodecs.js +38 -71
  762. package/lib/shared-tree-core/messageCodecs.js.map +1 -1
  763. package/lib/shared-tree-core/messageFormat.d.ts +0 -1
  764. package/lib/shared-tree-core/messageFormat.d.ts.map +1 -1
  765. package/lib/shared-tree-core/messageFormat.js +0 -1
  766. package/lib/shared-tree-core/messageFormat.js.map +1 -1
  767. package/lib/shared-tree-core/sharedTreeCore.d.ts +1 -3
  768. package/lib/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
  769. package/lib/shared-tree-core/sharedTreeCore.js +14 -4
  770. package/lib/shared-tree-core/sharedTreeCore.js.map +1 -1
  771. package/lib/sharedTreeAttributes.d.ts.map +1 -1
  772. package/lib/sharedTreeAttributes.js +3 -0
  773. package/lib/sharedTreeAttributes.js.map +1 -1
  774. package/lib/simple-tree/api/discrepancies.js +4 -1
  775. package/lib/simple-tree/api/discrepancies.js.map +1 -1
  776. package/lib/simple-tree/api/identifierIndex.d.ts +2 -2
  777. package/lib/simple-tree/api/identifierIndex.js +1 -1
  778. package/lib/simple-tree/api/identifierIndex.js.map +1 -1
  779. package/lib/simple-tree/api/index.d.ts +2 -1
  780. package/lib/simple-tree/api/index.d.ts.map +1 -1
  781. package/lib/simple-tree/api/index.js +1 -1
  782. package/lib/simple-tree/api/index.js.map +1 -1
  783. package/lib/simple-tree/api/schemaFactory.d.ts.map +1 -1
  784. package/lib/simple-tree/api/schemaFactory.js.map +1 -1
  785. package/lib/simple-tree/api/schemaFactoryAlpha.d.ts +33 -4
  786. package/lib/simple-tree/api/schemaFactoryAlpha.d.ts.map +1 -1
  787. package/lib/simple-tree/api/schemaFactoryAlpha.js +19 -3
  788. package/lib/simple-tree/api/schemaFactoryAlpha.js.map +1 -1
  789. package/lib/simple-tree/api/simpleTreeIndex.d.ts +5 -5
  790. package/lib/simple-tree/api/simpleTreeIndex.js +1 -1
  791. package/lib/simple-tree/api/simpleTreeIndex.js.map +1 -1
  792. package/lib/simple-tree/api/storedSchema.d.ts.map +1 -1
  793. package/lib/simple-tree/api/storedSchema.js +11 -8
  794. package/lib/simple-tree/api/storedSchema.js.map +1 -1
  795. package/lib/simple-tree/api/tree.d.ts +7 -19
  796. package/lib/simple-tree/api/tree.d.ts.map +1 -1
  797. package/lib/simple-tree/api/tree.js.map +1 -1
  798. package/lib/simple-tree/api/treeAlpha.d.ts +126 -0
  799. package/lib/simple-tree/api/treeAlpha.d.ts.map +1 -0
  800. package/lib/simple-tree/api/treeAlpha.js +6 -0
  801. package/lib/simple-tree/api/treeAlpha.js.map +1 -0
  802. package/lib/simple-tree/api/treeBeta.d.ts +1 -1
  803. package/lib/simple-tree/api/treeBeta.js.map +1 -1
  804. package/lib/simple-tree/api/treeChangeEvents.d.ts +4 -1
  805. package/lib/simple-tree/api/treeChangeEvents.d.ts.map +1 -1
  806. package/lib/simple-tree/api/treeChangeEvents.js.map +1 -1
  807. package/lib/simple-tree/api/treeNodeApi.d.ts +108 -0
  808. package/lib/simple-tree/api/treeNodeApi.d.ts.map +1 -1
  809. package/lib/simple-tree/api/treeNodeApi.js +101 -2
  810. package/lib/simple-tree/api/treeNodeApi.js.map +1 -1
  811. package/lib/simple-tree/core/toStored.d.ts +7 -0
  812. package/lib/simple-tree/core/toStored.d.ts.map +1 -1
  813. package/lib/simple-tree/core/toStored.js.map +1 -1
  814. package/lib/simple-tree/core/treeNodeKernel.d.ts.map +1 -1
  815. package/lib/simple-tree/core/treeNodeKernel.js +45 -8
  816. package/lib/simple-tree/core/treeNodeKernel.js.map +1 -1
  817. package/lib/simple-tree/core/unhydratedFlexTree.d.ts +17 -3
  818. package/lib/simple-tree/core/unhydratedFlexTree.d.ts.map +1 -1
  819. package/lib/simple-tree/core/unhydratedFlexTree.js +118 -12
  820. package/lib/simple-tree/core/unhydratedFlexTree.js.map +1 -1
  821. package/lib/simple-tree/fieldSchema.d.ts +6 -1
  822. package/lib/simple-tree/fieldSchema.d.ts.map +1 -1
  823. package/lib/simple-tree/fieldSchema.js +3 -0
  824. package/lib/simple-tree/fieldSchema.js.map +1 -1
  825. package/lib/simple-tree/index.d.ts +2 -2
  826. package/lib/simple-tree/index.d.ts.map +1 -1
  827. package/lib/simple-tree/index.js +1 -1
  828. package/lib/simple-tree/index.js.map +1 -1
  829. package/lib/simple-tree/node-kinds/array/arrayNode.d.ts +16 -0
  830. package/lib/simple-tree/node-kinds/array/arrayNode.d.ts.map +1 -1
  831. package/lib/simple-tree/node-kinds/array/arrayNode.js +23 -0
  832. package/lib/simple-tree/node-kinds/array/arrayNode.js.map +1 -1
  833. package/lib/simple-tree/node-kinds/array/arrayNodeTypes.d.ts +10 -1
  834. package/lib/simple-tree/node-kinds/array/arrayNodeTypes.d.ts.map +1 -1
  835. package/lib/simple-tree/node-kinds/array/arrayNodeTypes.js.map +1 -1
  836. package/lib/simple-tree/node-kinds/array/index.d.ts +2 -2
  837. package/lib/simple-tree/node-kinds/array/index.d.ts.map +1 -1
  838. package/lib/simple-tree/node-kinds/array/index.js.map +1 -1
  839. package/lib/simple-tree/node-kinds/index.d.ts +2 -2
  840. package/lib/simple-tree/node-kinds/index.d.ts.map +1 -1
  841. package/lib/simple-tree/node-kinds/index.js.map +1 -1
  842. package/lib/simple-tree/node-kinds/map/index.d.ts +1 -1
  843. package/lib/simple-tree/node-kinds/map/index.d.ts.map +1 -1
  844. package/lib/simple-tree/node-kinds/map/index.js.map +1 -1
  845. package/lib/simple-tree/node-kinds/map/mapNode.d.ts +13 -0
  846. package/lib/simple-tree/node-kinds/map/mapNode.d.ts.map +1 -1
  847. package/lib/simple-tree/node-kinds/map/mapNode.js +6 -1
  848. package/lib/simple-tree/node-kinds/map/mapNode.js.map +1 -1
  849. package/lib/simple-tree/node-kinds/map/mapNodeTypes.d.ts +6 -6
  850. package/lib/simple-tree/node-kinds/map/mapNodeTypes.d.ts.map +1 -1
  851. package/lib/simple-tree/node-kinds/map/mapNodeTypes.js.map +1 -1
  852. package/lib/simple-tree/simpleSchema.d.ts +17 -0
  853. package/lib/simple-tree/simpleSchema.d.ts.map +1 -1
  854. package/lib/simple-tree/simpleSchema.js.map +1 -1
  855. package/lib/simple-tree/toStoredSchema.d.ts.map +1 -1
  856. package/lib/simple-tree/toStoredSchema.js +24 -2
  857. package/lib/simple-tree/toStoredSchema.js.map +1 -1
  858. package/lib/tableSchema.d.ts +4 -5
  859. package/lib/tableSchema.d.ts.map +1 -1
  860. package/lib/tableSchema.js +12 -23
  861. package/lib/tableSchema.js.map +1 -1
  862. package/lib/text/textDomain.d.ts.map +1 -1
  863. package/lib/text/textDomain.js +29 -0
  864. package/lib/text/textDomain.js.map +1 -1
  865. package/lib/text/textDomainFormatted.d.ts +321 -11
  866. package/lib/text/textDomainFormatted.d.ts.map +1 -1
  867. package/lib/text/textDomainFormatted.js +103 -28
  868. package/lib/text/textDomainFormatted.js.map +1 -1
  869. package/lib/treeFactory.d.ts.map +1 -1
  870. package/lib/treeFactory.js +6 -3
  871. package/lib/treeFactory.js.map +1 -1
  872. package/lib/tsdoc-metadata.json +1 -1
  873. package/lib/util/index.d.ts +1 -1
  874. package/lib/util/index.d.ts.map +1 -1
  875. package/lib/util/index.js +1 -1
  876. package/lib/util/index.js.map +1 -1
  877. package/lib/util/referenceCounting.d.ts.map +1 -1
  878. package/lib/util/referenceCounting.js +0 -1
  879. package/lib/util/referenceCounting.js.map +1 -1
  880. package/lib/util/utils.d.ts +0 -1
  881. package/lib/util/utils.d.ts.map +1 -1
  882. package/lib/util/utils.js +0 -1
  883. package/lib/util/utils.js.map +1 -1
  884. package/package.json +35 -40
  885. package/scripts/generate-entrypoint-sources.sh +4 -2
  886. package/src/api.ts +21 -0
  887. package/src/codec/codec.ts +32 -2
  888. package/src/codec/index.ts +2 -3
  889. package/src/codec/versioned/codec.ts +99 -109
  890. package/src/codec/versioned/index.ts +1 -3
  891. package/src/core/forest/forest.ts +5 -2
  892. package/src/core/index.ts +4 -0
  893. package/src/core/rebase/changeRebaser.ts +8 -0
  894. package/src/core/rebase/revisionTagCodec.ts +4 -4
  895. package/src/core/rebase/utils.ts +9 -2
  896. package/src/core/schema-stored/formatV2.ts +1 -1
  897. package/src/core/tree/anchorSet.ts +92 -10
  898. package/src/core/tree/cursor.ts +52 -1
  899. package/src/core/tree/deltaUtil.ts +37 -1
  900. package/src/core/tree/detachedFieldIndexCodecs.ts +4 -4
  901. package/src/core/tree/index.ts +4 -0
  902. package/src/core/tree/visitDelta.ts +13 -1
  903. package/src/core/tree/visitorUtils.ts +5 -0
  904. package/src/entrypoints/alpha.ts +21 -10
  905. package/src/entrypoints/beta.ts +7 -1
  906. package/src/entrypoints/legacy.ts +7 -1
  907. package/src/entrypoints/public.ts +1 -1
  908. package/src/feature-libraries/changeAtomIdCodec.ts +8 -7
  909. package/src/feature-libraries/chunked-forest/chunkTree.ts +3 -2
  910. package/src/feature-libraries/chunked-forest/chunkedForest.ts +3 -2
  911. package/src/feature-libraries/chunked-forest/codec/chunkDecoding.ts +18 -13
  912. package/src/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.ts +1 -1
  913. package/src/feature-libraries/chunked-forest/codec/chunkEncodingGeneric.ts +1 -2
  914. package/src/feature-libraries/chunked-forest/codec/codecs.ts +16 -10
  915. package/src/feature-libraries/chunked-forest/codec/compressedEncode.ts +16 -14
  916. package/src/feature-libraries/chunked-forest/codec/{formatGeneric.ts → format/formatGeneric.ts} +1 -1
  917. package/src/feature-libraries/chunked-forest/codec/{format.ts → format/formatV1.ts} +41 -111
  918. package/src/feature-libraries/chunked-forest/codec/format/formatV2.ts +31 -0
  919. package/src/feature-libraries/chunked-forest/codec/format/index.ts +31 -0
  920. package/src/feature-libraries/chunked-forest/codec/format/versions.ts +81 -0
  921. package/src/feature-libraries/chunked-forest/codec/index.ts +6 -2
  922. package/src/feature-libraries/chunked-forest/codec/nodeEncoder.ts +19 -12
  923. package/src/feature-libraries/chunked-forest/codec/schemaBasedEncode.ts +6 -4
  924. package/src/feature-libraries/chunked-forest/codec/uncompressedEncode.ts +10 -10
  925. package/src/feature-libraries/chunked-forest/index.ts +2 -1
  926. package/src/feature-libraries/chunked-forest/uniformChunk.ts +42 -20
  927. package/src/feature-libraries/cursorComparator.ts +77 -0
  928. package/src/feature-libraries/forest-summary/incrementalSummaryBuilder.ts +5 -5
  929. package/src/feature-libraries/index.ts +5 -3
  930. package/src/feature-libraries/indexing/anchorTreeIndex.ts +21 -10
  931. package/src/feature-libraries/indexing/types.ts +5 -3
  932. package/src/feature-libraries/mitigatedChangeFamily.ts +4 -1
  933. package/src/feature-libraries/modular-schema/fieldChangeHandler.ts +4 -5
  934. package/src/feature-libraries/modular-schema/genericFieldKind.ts +0 -1
  935. package/src/feature-libraries/modular-schema/modularChangeCodecV1.ts +19 -26
  936. package/src/feature-libraries/modular-schema/modularChangeCodecV2.ts +4 -4
  937. package/src/feature-libraries/modular-schema/modularChangeCodecs.ts +4 -5
  938. package/src/feature-libraries/modular-schema/modularChangeFamily.ts +6 -2
  939. package/src/feature-libraries/object-forest/objectForest.ts +8 -2
  940. package/src/feature-libraries/optional-field/optionalFieldCodecV2.ts +11 -13
  941. package/src/feature-libraries/optional-field/optionalFieldCodecs.ts +4 -5
  942. package/src/feature-libraries/schema-edits/index.ts +1 -4
  943. package/src/feature-libraries/schema-edits/schemaChangeCodecs.ts +10 -78
  944. package/src/feature-libraries/schema-index/codec.ts +0 -25
  945. package/src/feature-libraries/schema-index/formatV2.ts +1 -1
  946. package/src/feature-libraries/schema-index/index.ts +1 -4
  947. package/src/feature-libraries/sequence-field/sequenceFieldCodecV2.ts +6 -6
  948. package/src/feature-libraries/sequence-field/sequenceFieldCodecV3.ts +8 -5
  949. package/src/feature-libraries/sequence-field/sequenceFieldCodecs.ts +4 -5
  950. package/src/index.ts +14 -3
  951. package/src/packageVersion.ts +1 -1
  952. package/src/serializableDomainSchema.ts +6 -0
  953. package/src/shared-tree/independentView.ts +5 -18
  954. package/src/shared-tree/index.ts +0 -4
  955. package/src/shared-tree/schematizingTreeView.ts +19 -165
  956. package/src/shared-tree/sharedTree.ts +16 -59
  957. package/src/shared-tree/sharedTreeChangeCodecs.ts +23 -29
  958. package/src/shared-tree/sharedTreeChangeEnricher.ts +1 -2
  959. package/src/shared-tree/sharedTreeChangeFamily.ts +2 -0
  960. package/src/shared-tree/sharedTreeChangeFormat.ts +23 -8
  961. package/src/shared-tree/tree.ts +2 -5
  962. package/src/shared-tree/treeAlpha.ts +30 -0
  963. package/src/shared-tree/treeCheckout.ts +275 -99
  964. package/src/shared-tree/unhydratedTreeContext.ts +1 -1
  965. package/src/shared-tree-core/editManagerCodecs.ts +99 -124
  966. package/src/shared-tree-core/editManagerCodecsCommons.ts +0 -1
  967. package/src/shared-tree-core/editManagerCodecsV1toV4.ts +54 -59
  968. package/src/shared-tree-core/editManagerCodecsVSharedBranches.ts +72 -95
  969. package/src/shared-tree-core/index.ts +4 -8
  970. package/src/shared-tree-core/messageCodecV1ToV4.ts +56 -71
  971. package/src/shared-tree-core/messageCodecVSharedBranches.ts +76 -92
  972. package/src/shared-tree-core/messageCodecs.ts +88 -126
  973. package/src/shared-tree-core/messageFormat.ts +0 -3
  974. package/src/shared-tree-core/sharedTreeCore.ts +14 -21
  975. package/src/sharedTreeAttributes.ts +3 -0
  976. package/src/simple-tree/api/discrepancies.ts +6 -1
  977. package/src/simple-tree/api/identifierIndex.ts +2 -2
  978. package/src/simple-tree/api/index.ts +14 -0
  979. package/src/simple-tree/api/schemaFactory.ts +0 -2
  980. package/src/simple-tree/api/schemaFactoryAlpha.ts +80 -4
  981. package/src/simple-tree/api/simpleTreeIndex.ts +6 -6
  982. package/src/simple-tree/api/storedSchema.ts +12 -20
  983. package/src/simple-tree/api/tree.ts +7 -20
  984. package/src/simple-tree/api/treeAlpha.ts +153 -0
  985. package/src/simple-tree/api/treeBeta.ts +1 -1
  986. package/src/simple-tree/api/treeChangeEvents.ts +4 -1
  987. package/src/simple-tree/api/treeNodeApi.ts +189 -3
  988. package/src/simple-tree/core/toStored.ts +8 -0
  989. package/src/simple-tree/core/treeNodeKernel.ts +53 -7
  990. package/src/simple-tree/core/unhydratedFlexTree.ts +137 -9
  991. package/src/simple-tree/fieldSchema.ts +10 -0
  992. package/src/simple-tree/index.ts +15 -0
  993. package/src/simple-tree/node-kinds/array/arrayNode.ts +64 -0
  994. package/src/simple-tree/node-kinds/array/arrayNodeTypes.ts +25 -1
  995. package/src/simple-tree/node-kinds/array/index.ts +2 -0
  996. package/src/simple-tree/node-kinds/index.ts +3 -0
  997. package/src/simple-tree/node-kinds/map/index.ts +1 -0
  998. package/src/simple-tree/node-kinds/map/mapNode.ts +20 -3
  999. package/src/simple-tree/node-kinds/map/mapNodeTypes.ts +6 -6
  1000. package/src/simple-tree/simpleSchema.ts +20 -0
  1001. package/src/simple-tree/toStoredSchema.ts +28 -1
  1002. package/src/tableSchema.ts +16 -28
  1003. package/src/text/textDomain.ts +68 -1
  1004. package/src/text/textDomainFormatted.ts +113 -11
  1005. package/src/treeFactory.ts +10 -5
  1006. package/src/util/index.ts +0 -1
  1007. package/src/util/referenceCounting.ts +0 -1
  1008. package/src/util/utils.ts +0 -2
  1009. package/.mocharc.customBenchmarks.cjs +0 -25
  1010. package/dist/feature-libraries/chunked-forest/codec/format.d.ts +0 -383
  1011. package/dist/feature-libraries/chunked-forest/codec/format.d.ts.map +0 -1
  1012. package/dist/feature-libraries/chunked-forest/codec/format.js +0 -191
  1013. package/dist/feature-libraries/chunked-forest/codec/format.js.map +0 -1
  1014. package/dist/feature-libraries/chunked-forest/codec/formatGeneric.d.ts.map +0 -1
  1015. package/dist/feature-libraries/chunked-forest/codec/formatGeneric.js.map +0 -1
  1016. package/lib/feature-libraries/chunked-forest/codec/format.d.ts +0 -383
  1017. package/lib/feature-libraries/chunked-forest/codec/format.d.ts.map +0 -1
  1018. package/lib/feature-libraries/chunked-forest/codec/format.js +0 -188
  1019. package/lib/feature-libraries/chunked-forest/codec/format.js.map +0 -1
  1020. package/lib/feature-libraries/chunked-forest/codec/formatGeneric.d.ts.map +0 -1
  1021. package/lib/feature-libraries/chunked-forest/codec/formatGeneric.js.map +0 -1
  1022. /package/dist/feature-libraries/chunked-forest/codec/{formatGeneric.js → format/formatGeneric.js} +0 -0
  1023. /package/lib/feature-libraries/chunked-forest/codec/{formatGeneric.js → format/formatGeneric.js} +0 -0
@@ -1 +1 @@
1
- {"version":3,"file":"treeBeta.js","sourceRoot":"","sources":["../../../src/simple-tree/api/treeBeta.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,+DAI0C;AAC1C,kDAA4C;AAC5C,+CAW0B;AAC1B,0DAA2D;AAM3D,gGAGgD;AAGhD,qDAAuE;AACvE,2CAA+C;AAG/C,qDAA+C;AAC/C,qDAAqD;AA2LrD;;;;GAIG;AACH,SAAgB,+BAA+B,CAC9C,IAA8B;IAE9B,IAAI,IAAA,sBAAW,EAAC,IAAI,CAAC,EAAE,CAAC;QACvB,OAAO,IAAA,kCAAiB,EAAC,IAAI,EAAE,EAAE,CAAC,CAAC;IACpC,CAAC;IACD,MAAM,MAAM,GAAG,IAAA,oBAAS,EAAC,IAAI,CAAC,CAAC;IAC/B,MAAM,MAAM,GAAG,MAAM,CAAC,YAAY,EAAE,CAAC,YAAY,EAAE,CAAC;IACpD,OAAO,MAAM,CAAC;AACf,CAAC;AATD,0EASC;AAsBD,SAAgB,aAAa,CAC5B,MAEgC,EAChC,IAA6B;IAM7B,+CAA+C;IAC/C,MAAM,OAAO,GAAG,IAAA,sEAAgC,EAC/C,IAA4C,EAC5C,MAAM,CACN,CAAC;IACF,MAAM,MAAM,GAAG,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAA,uCAA4B,EAAC,OAAO,CAAC,CAAC;IACzF,OAAO,MAIN,CAAC;AACH,CAAC;AArBD,sCAqBC;AAgBD,SAAgB,aA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;YACpC,KAAK,EAAE,IAAI,GAAG,CAAC,CAAC,IAAA,gBAAK,EAAC,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC;YACjD,iBAAiB,EAAE,SAAS;SAC5B,CAAC;QACF,OAAO,IAAA,4BAAgB,EAAC,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,OAAO,CAElE,CAAC;IACH,CAAC;IAED,MAAM,CACL,MAAe,EACf,IAAmD;QAEnD,MAAM,OAAO,GAAG,IAAA,sEAAgC,EAC/C,IAAqC,EACrC,MAAM,CACN,CAAC;QACF,MAAM,MAAM,GAAG,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAA,uCAA4B,EAAC,OAAO,CAAC,CAAC;QACzF,OAAO,MAAyD,CAAC;IAClE,CAAC;CACD,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { ITreeCursorSynchronous, TreeFieldStoredSchema } from \"../../core/index.js\";\nimport {\n\tdefaultSchemaPolicy,\n\tFieldKinds,\n\tisTreeValue,\n} from \"../../feature-libraries/index.js\";\nimport { brand } from \"../../util/index.js\";\nimport {\n\tContext,\n\tgetKernel,\n\tgetOrCreateNodeFromInnerNode,\n\tisTreeNode,\n\tUnhydratedContext,\n\ttype NodeKind,\n\ttype TreeLeafValue,\n\ttype TreeNode,\n\ttype Unhydrated,\n\ttype WithType,\n} from \"../core/index.js\";\nimport { getUnhydratedContext } from \"../createContext.js\";\nimport type {\n\tImplicitFieldSchema,\n\tInsertableTreeFieldFromImplicitField,\n\tTreeFieldFromImplicitField,\n} from \"../fieldSchema.js\";\nimport {\n\tunhydratedFlexTreeFromInsertable,\n\ttype InsertableContent,\n} from \"../unhydratedFlexTreeFromInsertable.js\";\nimport type { InsertableField, UnsafeUnknownSchema } from \"../unsafeUnknownSchema.js\";\n\nimport { conciseFromCursor, type ConciseTree } from \"./conciseTree.js\";\nimport { createFromCursor } from \"./create.js\";\nimport type { TreeEncodingOptions } from \"./customTree.js\";\nimport type { TreeChangeEvents } from \"./treeChangeEvents.js\";\nimport { treeNodeApi } from \"./treeNodeApi.js\";\nimport { cursorFromVerbose } from \"./verboseTree.js\";\n\n// Tests for this file are grouped with those for treeNodeApi.ts as that is where this functionality will eventually land,\n// and where most of the actual implementation is for much of it.\n\n/**\n * Data included for {@link TreeChangeEventsBeta.nodeChanged}.\n * @sealed @beta\n */\nexport interface NodeChangedData<TNode extends TreeNode = TreeNode> {\n\t/**\n\t * When the node changed is an object or Map node, this lists all the properties which changed.\n\t * @remarks\n\t * This only includes changes to the node itself (which would trigger {@link TreeChangeEvents.nodeChanged}).\n\t *\n\t * Set to `undefined` when the {@link NodeKind} does not support this feature (currently just ArrayNodes).\n\t *\n\t * When defined, the set should never be empty, since `nodeChanged` will only be triggered when there is a change, and for the supported node types, the only things that can change are properties.\n\t */\n\treadonly changedProperties?: ReadonlySet<\n\t\t// For Object nodes, make changedProperties required and strongly typed with the property names from the schema:\n\t\tTNode extends WithType<string, NodeKind.Object, infer TInfo>\n\t\t\t? string & keyof TInfo\n\t\t\t: string\n\t>;\n}\n\n/**\n * Extensions to {@link TreeChangeEvents} which are not yet stable.\n *\n * @sealed @beta\n */\nexport interface TreeChangeEventsBeta<TNode extends TreeNode = TreeNode>\n\textends TreeChangeEvents {\n\t/**\n\t * Emitted by a node after a batch of changes has been applied to the tree, if any of the changes affected the node.\n\t *\n\t * - Object nodes define a change as being when the value of one of its properties changes (i.e., the property's value is set, including when set to `undefined`).\n\t *\n\t * - Array nodes define a change as when an element is added, removed, moved or replaced.\n\t *\n\t * - Map nodes define a change as when an entry is added, updated, or removed.\n\t *\n\t * @remarks\n\t * This event is not emitted when:\n\t *\n\t * - Properties of a child node change. Notably, updates to an array node or a map node (like adding or removing\n\t * elements/entries) will emit this event on the array/map node itself, but not on the node that contains the\n\t * array/map node as one of its properties.\n\t *\n\t * - The node is moved to a different location in the tree or removed from the tree.\n\t * In this case the event is emitted on the _parent_ node, not the node itself.\n\t *\n\t * For remote edits, this event is not guaranteed to occur in the same order or quantity that it did in\n\t * the client that made the original edit.\n\t *\n\t * When the event is emitted, the tree is guaranteed to be in-schema.\n\t *\n\t * @privateRemarks\n\t * This event occurs whenever the apparent contents of the node instance change, regardless of what caused the change.\n\t * For example, it will fire when the local client reassigns a child, when part of a remote edit is applied to the\n\t * node, or when the node has to be updated due to resolution of a merge conflict\n\t * (for example a previously applied local change might be undone, then reapplied differently or not at all).\n\t *\n\t * TODO: define and document event ordering (ex: bottom up, with nodeChanged before treeChange on each level).\n\t *\n\t * This defines a property which is a function instead of using the method syntax to avoid function bi-variance issues with the input data to the callback.\n\t */\n\tnodeChanged: (\n\t\tdata: NodeChangedData<TNode> &\n\t\t\t// Make the properties of object, map, and record nodes required:\n\t\t\t(TNode extends WithType<string, NodeKind.Map | NodeKind.Object | NodeKind.Record>\n\t\t\t\t? Required<Pick<NodeChangedData<TNode>, \"changedProperties\">>\n\t\t\t\t: unknown),\n\t) => void;\n}\n\n/**\n * Extensions to {@link (Tree:interface)} which are not yet stable.\n * @remarks\n * Use via the {@link (TreeBeta:variable)} singleton.\n * @sealed @beta\n */\nexport interface TreeBeta {\n\t/**\n\t * Register an event listener on the given node.\n\t * @param node - The node whose events should be subscribed to.\n\t * @param eventName - Which event to subscribe to.\n\t * @param listener - The callback to trigger for the event. The tree can be read during the callback, but it is invalid to modify the tree during this callback.\n\t * @returns A callback function which will deregister the event.\n\t * This callback should be called only once.\n\t */\n\ton<K extends keyof TreeChangeEventsBeta<TNode>, TNode extends TreeNode>(\n\t\tnode: TNode,\n\t\teventName: K,\n\t\tlistener: NoInfer<TreeChangeEventsBeta<TNode>[K]>,\n\t): () => void;\n\n\t/**\n\t * A less type-safe version of {@link (TreeAlpha:interface).create}, suitable for importing data.\n\t * @remarks\n\t * Due to {@link ConciseTree} relying on type inference from the data, its use is somewhat limited.\n\t * This does not support {@link ConciseTree|ConciseTrees} with customized handle encodings or using persisted keys.\n\t * Use \"compressed\" or \"verbose\" formats for more flexibility.\n\t *\n\t * When using this function,\n\t * it is recommend to ensure your schema is unambiguous with {@link ITreeConfigurationOptions.preventAmbiguity}.\n\t * If the schema is ambiguous, consider using {@link (TreeAlpha:interface).create} and {@link Unhydrated} nodes where needed,\n\t * or using {@link (TreeAlpha:interface).(importVerbose:1)} and specify all types.\n\t *\n\t * Documented (and thus recoverable) error handling/reporting for this is not yet implemented,\n\t * but for now most invalid inputs will throw a recoverable error.\n\t */\n\timportConcise<const TSchema extends ImplicitFieldSchema>(\n\t\tschema: TSchema,\n\t\tdata: ConciseTree | undefined,\n\t): Unhydrated<TreeFieldFromImplicitField<TSchema>>;\n\n\t/**\n\t * Copy a snapshot of the current version of a TreeNode into a {@link ConciseTree}.\n\t */\n\texportConcise(node: TreeNode | TreeLeafValue, options?: TreeEncodingOptions): ConciseTree;\n\n\t/**\n\t * Copy a snapshot of the current version of a TreeNode into a {@link ConciseTree}, allowing undefined.\n\t */\n\texportConcise(\n\t\tnode: TreeNode | TreeLeafValue | undefined,\n\t\toptions?: TreeEncodingOptions,\n\t): ConciseTree | undefined;\n\n\t/**\n\t * Clones the persisted data associated with a node.\n\t *\n\t * @param node - The node to clone.\n\t * @returns A new unhydrated node with the same persisted data as the original node.\n\t * @remarks\n\t * Some key things to note:\n\t *\n\t * - Local state, such as properties added to customized schema classes, will not be cloned. However, they will be\n\t * initialized to their default state just as if the node had been created via its constructor.\n\t *\n\t * - Value node types (i.e., numbers, strings, booleans, nulls and Fluid handles) will be returned as is.\n\t *\n\t * - The identifiers in the node's subtree will be preserved, i.e., they are not replaced with new values.\n\t *\n\t * - If the node (or any node in its subtree) contains {@link ObjectSchemaOptions.allowUnknownOptionalFields|unknown optional fields},\n\t * those fields will be cloned just like the known fields.\n\t */\n\tclone<const TSchema extends ImplicitFieldSchema>(\n\t\tnode: TreeFieldFromImplicitField<TSchema>,\n\t): TreeFieldFromImplicitField<TSchema>;\n\n\t// TODO: support more clone options\n\t// /**\n\t// * Like {@link (TreeBeta:interface).create}, except deeply clones existing nodes.\n\t// * @remarks\n\t// * This only clones the persisted data associated with a node.\n\t// * Local state, such as properties added to customized schema classes, will not be cloned:\n\t// * they will be initialized however they end up after running the constructor, just like if a remote client had inserted the same nodes.\n\t// */\n\t// clone<const TSchema extends ImplicitFieldSchema>(\n\t// \toriginal: TreeFieldFromImplicitField<TSchema>,\n\t// \toptions?: {\n\t// \t\t/**\n\t// \t\t * If set, all identifier's in the cloned tree (See {@link SchemaFactory.identifier}) will be replaced with new ones allocated using the default identifier allocation schema.\n\t// \t\t * Otherwise any identifiers will be preserved as is.\n\t// \t\t */\n\t// \t\treplaceIdentifiers?: true;\n\t// \t},\n\t// ): TreeFieldFromImplicitField<TSchema>;\n\n\t/**\n\t * Construct tree content that is compatible with the field defined by the provided `schema`.\n\t * @param schema - The schema for what to construct. As this is an {@link ImplicitFieldSchema}, a {@link FieldSchema}, {@link TreeNodeSchema} or {@link AllowedTypes} array can be provided.\n\t * @param data - The data used to construct the field content.\n\t * @remarks\n\t * When providing a {@link TreeNodeSchemaClass}, this is the same as invoking its constructor except that an unhydrated node can also be provided.\n\t * This function exists as a generalization that can be used in other cases as well,\n\t * such as when `undefined` might be allowed (for an optional field), or when the type should be inferred from the data when more than one type is possible.\n\t */\n\tcreate<const TSchema extends ImplicitFieldSchema>(\n\t\tschema: TSchema,\n\t\tdata: InsertableTreeFieldFromImplicitField<TSchema>,\n\t): Unhydrated<TreeFieldFromImplicitField<TSchema>>;\n}\n\n/**\n * Borrow a cursor from a node.\n * @remarks\n * The cursor must be put back to its original location before the node is used again.\n */\nexport function borrowCursorFromTreeNodeOrValue(\n\tnode: TreeNode | TreeLeafValue,\n): ITreeCursorSynchronous {\n\tif (isTreeValue(node)) {\n\t\treturn cursorFromVerbose(node, {});\n\t}\n\tconst kernel = getKernel(node);\n\tconst cursor = kernel.getInnerNode().borrowCursor();\n\treturn cursor;\n}\n\n/**\n * {@inheritDoc (TreeBeta:interface).importConcise}\n */\nexport function importConcise<TSchema extends ImplicitFieldSchema>(\n\tschema: TSchema & ImplicitFieldSchema,\n\tdata: ConciseTree | undefined,\n): Unhydrated<TreeFieldFromImplicitField<TSchema>>;\n/**\n * {@inheritDoc (TreeAlpha:interface).importConcise}\n */\nexport function importConcise<TSchema extends ImplicitFieldSchema | UnsafeUnknownSchema>(\n\tschema: UnsafeUnknownSchema extends TSchema\n\t\t? ImplicitFieldSchema\n\t\t: TSchema & ImplicitFieldSchema,\n\tdata: ConciseTree | undefined,\n): Unhydrated<\n\tTSchema extends ImplicitFieldSchema\n\t\t? TreeFieldFromImplicitField<TSchema>\n\t\t: TreeNode | TreeLeafValue | undefined\n>;\nexport function importConcise<TSchema extends ImplicitFieldSchema | UnsafeUnknownSchema>(\n\tschema: UnsafeUnknownSchema extends TSchema\n\t\t? ImplicitFieldSchema\n\t\t: TSchema & ImplicitFieldSchema,\n\tdata: ConciseTree | undefined,\n): Unhydrated<\n\tTSchema extends ImplicitFieldSchema\n\t\t? TreeFieldFromImplicitField<TSchema>\n\t\t: TreeNode | TreeLeafValue | undefined\n> {\n\t// Create the tree content from insertable data\n\tconst mapTree = unhydratedFlexTreeFromInsertable(\n\t\tdata as InsertableField<UnsafeUnknownSchema>,\n\t\tschema,\n\t);\n\tconst result = mapTree === undefined ? undefined : getOrCreateNodeFromInnerNode(mapTree);\n\treturn result as Unhydrated<\n\t\tTSchema extends ImplicitFieldSchema\n\t\t\t? TreeFieldFromImplicitField<TSchema>\n\t\t\t: TreeNode | TreeLeafValue | undefined\n\t>;\n}\n\n/**\n * {@inheritDoc (TreeBeta:interface).(exportConcise:1)}\n */\nexport function exportConcise(\n\tnode: TreeNode | TreeLeafValue,\n\toptions?: TreeEncodingOptions,\n): ConciseTree;\n/**\n * {@inheritDoc (TreeBeta:interface).(exportConcise:2)}\n */\nexport function exportConcise(\n\tnode: TreeNode | TreeLeafValue | undefined,\n\toptions?: TreeEncodingOptions,\n): ConciseTree | undefined;\nexport function exportConcise(\n\tnode: TreeNode | TreeLeafValue | undefined,\n\toptions?: TreeEncodingOptions,\n): ConciseTree | undefined {\n\tif (!isTreeNode(node)) {\n\t\treturn node;\n\t}\n\tconst config: TreeEncodingOptions = { ...options };\n\n\tconst kernel = getKernel(node);\n\tconst cursor = borrowCursorFromTreeNodeOrValue(node);\n\treturn conciseFromCursor(cursor, kernel.context, config);\n}\n\n/**\n * Extensions to {@link (Tree:variable)} which are not yet stable.\n * @see {@link (TreeBeta:interface)}.\n * @beta\n */\nexport const TreeBeta: TreeBeta = {\n\ton<K extends keyof TreeChangeEventsBeta<TNode>, TNode extends TreeNode>(\n\t\tnode: TNode,\n\t\teventName: K,\n\t\tlistener: NoInfer<TreeChangeEventsBeta<TNode>[K]>,\n\t): () => void {\n\t\treturn treeNodeApi.on(node, eventName, listener);\n\t},\n\n\timportConcise,\n\texportConcise,\n\n\tclone<const TSchema extends ImplicitFieldSchema>(\n\t\tnode: TreeFieldFromImplicitField<TSchema>,\n\t): Unhydrated<TreeFieldFromImplicitField<TSchema>> {\n\t\t// The only non-TreeNode cases are {@link TreeLeafValue} and `undefined` (for an empty optional field) which can be returned as is.\n\t\tif (!isTreeNode(node)) {\n\t\t\treturn node;\n\t\t}\n\n\t\tconst kernel = getKernel(node);\n\t\tconst cursor = kernel.getInnerNode().borrowCursor();\n\n\t\t// To handle when the node transitively contains unknown optional fields,\n\t\t// derive the context from the source node's stored schema which has stored schema for any such fields and their contents.\n\t\tconst flexContext = new UnhydratedContext(\n\t\t\tdefaultSchemaPolicy,\n\t\t\tkernel.context.flexContext.schema,\n\t\t);\n\t\tconst context = new Context(flexContext, getUnhydratedContext(kernel.schema).schema);\n\n\t\tconst fieldSchema: TreeFieldStoredSchema = {\n\t\t\tkind: FieldKinds.required.identifier,\n\t\t\ttypes: new Set([brand(kernel.schema.identifier)]),\n\t\t\tpersistedMetadata: undefined,\n\t\t};\n\t\treturn createFromCursor(kernel.schema, cursor, fieldSchema, context) as Unhydrated<\n\t\t\tTreeFieldFromImplicitField<TSchema>\n\t\t>;\n\t},\n\n\tcreate<const TSchema extends ImplicitFieldSchema>(\n\t\tschema: TSchema,\n\t\tdata: InsertableTreeFieldFromImplicitField<TSchema>,\n\t): Unhydrated<TreeFieldFromImplicitField<TSchema>> {\n\t\tconst mapTree = unhydratedFlexTreeFromInsertable(\n\t\t\tdata as InsertableContent | undefined,\n\t\t\tschema,\n\t\t);\n\t\tconst result = mapTree === undefined ? undefined : getOrCreateNodeFromInnerNode(mapTree);\n\t\treturn result as Unhydrated<TreeFieldFromImplicitField<TSchema>>;\n\t},\n};\n"]}
1
+ {"version":3,"file":"treeBeta.js","sourceRoot":"","sources":["../../../src/simple-tree/api/treeBeta.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,+DAI0C;AAC1C,kDAA4C;AAC5C,+CAW0B;AAC1B,0DAA2D;AAM3D,gGAGgD;AAGhD,qDAAuE;AACvE,2CAA+C;AAG/C,qDAA+C;AAC/C,qDAAqD;AA2LrD;;;;GAIG;AACH,SAAgB,+BAA+B,CAC9C,IAA8B;IAE9B,IAAI,IAAA,sBAAW,EAAC,IAAI,CAAC,EAAE,CAAC;QACvB,OAAO,IAAA,kCAAiB,EAAC,IAAI,EAAE,EAAE,CAAC,CAAC;IACpC,CAAC;IACD,MAAM,MAAM,GAAG,IAAA,oBAAS,EAAC,IAAI,CAAC,CAAC;IAC/B,MAAM,MAAM,GAAG,MAAM,CAAC,YAAY,EAAE,CAAC,YAAY,EAAE,CAAC;IACpD,OAAO,MAAM,CAAC;AACf,CAAC;AATD,0EASC;AAsBD,SAAgB,aAAa,CAC5B,MAEgC,EAChC,IAA6B;IAM7B,+CAA+C;IAC/C,MAAM,OAAO,GAAG,IAAA,sEAAgC,EAC/C,IAA4C,EAC5C,MAAM,CACN,CAAC;IACF,MAAM,MAAM,GAAG,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CA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M,CAAC,CAAC,MAAM,CAAC,CAAC;QAErF,MAAM,WAAW,GAA0B;YAC1C,IAAI,EAAE,qBAAU,CAAC,QAAQ,CAAC,UAAU;YACpC,KAAK,EAAE,IAAI,GAAG,CAAC,CAAC,IAAA,gBAAK,EAAC,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC;YACjD,iBAAiB,EAAE,SAAS;SAC5B,CAAC;QACF,OAAO,IAAA,4BAAgB,EAAC,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,OAAO,CAElE,CAAC;IACH,CAAC;IAED,MAAM,CACL,MAAe,EACf,IAAmD;QAEnD,MAAM,OAAO,GAAG,IAAA,sEAAgC,EAC/C,IAAqC,EACrC,MAAM,CACN,CAAC;QACF,MAAM,MAAM,GAAG,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAA,uCAA4B,EAAC,OAAO,CAAC,CAAC;QACzF,OAAO,MAAyD,CAAC;IAClE,CAAC;CACD,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { ITreeCursorSynchronous, TreeFieldStoredSchema } from \"../../core/index.js\";\nimport {\n\tdefaultSchemaPolicy,\n\tFieldKinds,\n\tisTreeValue,\n} from \"../../feature-libraries/index.js\";\nimport { brand } from \"../../util/index.js\";\nimport {\n\tContext,\n\tgetKernel,\n\tgetOrCreateNodeFromInnerNode,\n\tisTreeNode,\n\tUnhydratedContext,\n\ttype NodeKind,\n\ttype TreeLeafValue,\n\ttype TreeNode,\n\ttype Unhydrated,\n\ttype WithType,\n} from \"../core/index.js\";\nimport { getUnhydratedContext } from \"../createContext.js\";\nimport type {\n\tImplicitFieldSchema,\n\tInsertableTreeFieldFromImplicitField,\n\tTreeFieldFromImplicitField,\n} from \"../fieldSchema.js\";\nimport {\n\tunhydratedFlexTreeFromInsertable,\n\ttype InsertableContent,\n} from \"../unhydratedFlexTreeFromInsertable.js\";\nimport type { InsertableField, UnsafeUnknownSchema } from \"../unsafeUnknownSchema.js\";\n\nimport { conciseFromCursor, type ConciseTree } from \"./conciseTree.js\";\nimport { createFromCursor } from \"./create.js\";\nimport type { TreeEncodingOptions } from \"./customTree.js\";\nimport type { TreeChangeEvents } from \"./treeChangeEvents.js\";\nimport { treeNodeApi } from \"./treeNodeApi.js\";\nimport { cursorFromVerbose } from \"./verboseTree.js\";\n\n// Tests for this file are grouped with those for treeNodeApi.ts as that is where this functionality will eventually land,\n// and where most of the actual implementation is for much of it.\n\n/**\n * Data included for {@link TreeChangeEventsBeta.nodeChanged}.\n * @sealed @beta\n */\nexport interface NodeChangedData<TNode extends TreeNode = TreeNode> {\n\t/**\n\t * When the node changed is an object or Map node, this lists all the properties which changed.\n\t * @remarks\n\t * This only includes changes to the node itself (which would trigger {@link TreeChangeEvents.nodeChanged}).\n\t *\n\t * Not present when the {@link NodeKind} does not support this feature (currently just ArrayNodes).\n\t *\n\t * When defined, the set should never be empty, since `nodeChanged` will only be triggered when there is a change, and for the supported node types, the only things that can change are properties.\n\t */\n\treadonly changedProperties?: ReadonlySet<\n\t\t// For Object nodes, make changedProperties required and strongly typed with the property names from the schema:\n\t\tTNode extends WithType<string, NodeKind.Object, infer TInfo>\n\t\t\t? string & keyof TInfo\n\t\t\t: string\n\t>;\n}\n\n/**\n * Extensions to {@link TreeChangeEvents} which are not yet stable.\n *\n * @sealed @beta\n */\nexport interface TreeChangeEventsBeta<TNode extends TreeNode = TreeNode>\n\textends TreeChangeEvents {\n\t/**\n\t * Emitted by a node after a batch of changes has been applied to the tree, if any of the changes affected the node.\n\t *\n\t * - Object nodes define a change as being when the value of one of its properties changes (i.e., the property's value is set, including when set to `undefined`).\n\t *\n\t * - Array nodes define a change as when an element is added, removed, moved or replaced.\n\t *\n\t * - Map nodes define a change as when an entry is added, updated, or removed.\n\t *\n\t * @remarks\n\t * This event is not emitted when:\n\t *\n\t * - Properties of a child node change. Notably, updates to an array node or a map node (like adding or removing\n\t * elements/entries) will emit this event on the array/map node itself, but not on the node that contains the\n\t * array/map node as one of its properties.\n\t *\n\t * - The node is moved to a different location in the tree or removed from the tree.\n\t * In this case the event is emitted on the _parent_ node, not the node itself.\n\t *\n\t * For remote edits, this event is not guaranteed to occur in the same order or quantity that it did in\n\t * the client that made the original edit.\n\t *\n\t * When the event is emitted, the tree is guaranteed to be in-schema.\n\t *\n\t * @privateRemarks\n\t * This event occurs whenever the apparent contents of the node instance change, regardless of what caused the change.\n\t * For example, it will fire when the local client reassigns a child, when part of a remote edit is applied to the\n\t * node, or when the node has to be updated due to resolution of a merge conflict\n\t * (for example a previously applied local change might be undone, then reapplied differently or not at all).\n\t *\n\t * TODO: define and document event ordering (ex: bottom up, with nodeChanged before treeChange on each level).\n\t *\n\t * This defines a property which is a function instead of using the method syntax to avoid function bi-variance issues with the input data to the callback.\n\t */\n\tnodeChanged: (\n\t\tdata: NodeChangedData<TNode> &\n\t\t\t// Make the properties of object, map, and record nodes required:\n\t\t\t(TNode extends WithType<string, NodeKind.Map | NodeKind.Object | NodeKind.Record>\n\t\t\t\t? Required<Pick<NodeChangedData<TNode>, \"changedProperties\">>\n\t\t\t\t: unknown),\n\t) => void;\n}\n\n/**\n * Extensions to {@link (Tree:interface)} which are not yet stable.\n * @remarks\n * Use via the {@link (TreeBeta:variable)} singleton.\n * @sealed @beta\n */\nexport interface TreeBeta {\n\t/**\n\t * Register an event listener on the given node.\n\t * @param node - The node whose events should be subscribed to.\n\t * @param eventName - Which event to subscribe to.\n\t * @param listener - The callback to trigger for the event. The tree can be read during the callback, but it is invalid to modify the tree during this callback.\n\t * @returns A callback function which will deregister the event.\n\t * This callback should be called only once.\n\t */\n\ton<K extends keyof TreeChangeEventsBeta<TNode>, TNode extends TreeNode>(\n\t\tnode: TNode,\n\t\teventName: K,\n\t\tlistener: NoInfer<TreeChangeEventsBeta<TNode>[K]>,\n\t): () => void;\n\n\t/**\n\t * A less type-safe version of {@link (TreeAlpha:interface).create}, suitable for importing data.\n\t * @remarks\n\t * Due to {@link ConciseTree} relying on type inference from the data, its use is somewhat limited.\n\t * This does not support {@link ConciseTree|ConciseTrees} with customized handle encodings or using persisted keys.\n\t * Use \"compressed\" or \"verbose\" formats for more flexibility.\n\t *\n\t * When using this function,\n\t * it is recommend to ensure your schema is unambiguous with {@link ITreeConfigurationOptions.preventAmbiguity}.\n\t * If the schema is ambiguous, consider using {@link (TreeAlpha:interface).create} and {@link Unhydrated} nodes where needed,\n\t * or using {@link (TreeAlpha:interface).(importVerbose:1)} and specify all types.\n\t *\n\t * Documented (and thus recoverable) error handling/reporting for this is not yet implemented,\n\t * but for now most invalid inputs will throw a recoverable error.\n\t */\n\timportConcise<const TSchema extends ImplicitFieldSchema>(\n\t\tschema: TSchema,\n\t\tdata: ConciseTree | undefined,\n\t): Unhydrated<TreeFieldFromImplicitField<TSchema>>;\n\n\t/**\n\t * Copy a snapshot of the current version of a TreeNode into a {@link ConciseTree}.\n\t */\n\texportConcise(node: TreeNode | TreeLeafValue, options?: TreeEncodingOptions): ConciseTree;\n\n\t/**\n\t * Copy a snapshot of the current version of a TreeNode into a {@link ConciseTree}, allowing undefined.\n\t */\n\texportConcise(\n\t\tnode: TreeNode | TreeLeafValue | undefined,\n\t\toptions?: TreeEncodingOptions,\n\t): ConciseTree | undefined;\n\n\t/**\n\t * Clones the persisted data associated with a node.\n\t *\n\t * @param node - The node to clone.\n\t * @returns A new unhydrated node with the same persisted data as the original node.\n\t * @remarks\n\t * Some key things to note:\n\t *\n\t * - Local state, such as properties added to customized schema classes, will not be cloned. However, they will be\n\t * initialized to their default state just as if the node had been created via its constructor.\n\t *\n\t * - Value node types (i.e., numbers, strings, booleans, nulls and Fluid handles) will be returned as is.\n\t *\n\t * - The identifiers in the node's subtree will be preserved, i.e., they are not replaced with new values.\n\t *\n\t * - If the node (or any node in its subtree) contains {@link ObjectSchemaOptions.allowUnknownOptionalFields|unknown optional fields},\n\t * those fields will be cloned just like the known fields.\n\t */\n\tclone<const TSchema extends ImplicitFieldSchema>(\n\t\tnode: TreeFieldFromImplicitField<TSchema>,\n\t): TreeFieldFromImplicitField<TSchema>;\n\n\t// TODO: support more clone options\n\t// /**\n\t// * Like {@link (TreeBeta:interface).create}, except deeply clones existing nodes.\n\t// * @remarks\n\t// * This only clones the persisted data associated with a node.\n\t// * Local state, such as properties added to customized schema classes, will not be cloned:\n\t// * they will be initialized however they end up after running the constructor, just like if a remote client had inserted the same nodes.\n\t// */\n\t// clone<const TSchema extends ImplicitFieldSchema>(\n\t// \toriginal: TreeFieldFromImplicitField<TSchema>,\n\t// \toptions?: {\n\t// \t\t/**\n\t// \t\t * If set, all identifier's in the cloned tree (See {@link SchemaFactory.identifier}) will be replaced with new ones allocated using the default identifier allocation schema.\n\t// \t\t * Otherwise any identifiers will be preserved as is.\n\t// \t\t */\n\t// \t\treplaceIdentifiers?: true;\n\t// \t},\n\t// ): TreeFieldFromImplicitField<TSchema>;\n\n\t/**\n\t * Construct tree content that is compatible with the field defined by the provided `schema`.\n\t * @param schema - The schema for what to construct. As this is an {@link ImplicitFieldSchema}, a {@link FieldSchema}, {@link TreeNodeSchema} or {@link AllowedTypes} array can be provided.\n\t * @param data - The data used to construct the field content.\n\t * @remarks\n\t * When providing a {@link TreeNodeSchemaClass}, this is the same as invoking its constructor except that an unhydrated node can also be provided.\n\t * This function exists as a generalization that can be used in other cases as well,\n\t * such as when `undefined` might be allowed (for an optional field), or when the type should be inferred from the data when more than one type is possible.\n\t */\n\tcreate<const TSchema extends ImplicitFieldSchema>(\n\t\tschema: TSchema,\n\t\tdata: InsertableTreeFieldFromImplicitField<TSchema>,\n\t): Unhydrated<TreeFieldFromImplicitField<TSchema>>;\n}\n\n/**\n * Borrow a cursor from a node.\n * @remarks\n * The cursor must be put back to its original location before the node is used again.\n */\nexport function borrowCursorFromTreeNodeOrValue(\n\tnode: TreeNode | TreeLeafValue,\n): ITreeCursorSynchronous {\n\tif (isTreeValue(node)) {\n\t\treturn cursorFromVerbose(node, {});\n\t}\n\tconst kernel = getKernel(node);\n\tconst cursor = kernel.getInnerNode().borrowCursor();\n\treturn cursor;\n}\n\n/**\n * {@inheritDoc (TreeBeta:interface).importConcise}\n */\nexport function importConcise<TSchema extends ImplicitFieldSchema>(\n\tschema: TSchema & ImplicitFieldSchema,\n\tdata: ConciseTree | undefined,\n): Unhydrated<TreeFieldFromImplicitField<TSchema>>;\n/**\n * {@inheritDoc (TreeAlpha:interface).importConcise}\n */\nexport function importConcise<TSchema extends ImplicitFieldSchema | UnsafeUnknownSchema>(\n\tschema: UnsafeUnknownSchema extends TSchema\n\t\t? ImplicitFieldSchema\n\t\t: TSchema & ImplicitFieldSchema,\n\tdata: ConciseTree | undefined,\n): Unhydrated<\n\tTSchema extends ImplicitFieldSchema\n\t\t? TreeFieldFromImplicitField<TSchema>\n\t\t: TreeNode | TreeLeafValue | undefined\n>;\nexport function importConcise<TSchema extends ImplicitFieldSchema | UnsafeUnknownSchema>(\n\tschema: UnsafeUnknownSchema extends TSchema\n\t\t? ImplicitFieldSchema\n\t\t: TSchema & ImplicitFieldSchema,\n\tdata: ConciseTree | undefined,\n): Unhydrated<\n\tTSchema extends ImplicitFieldSchema\n\t\t? TreeFieldFromImplicitField<TSchema>\n\t\t: TreeNode | TreeLeafValue | undefined\n> {\n\t// Create the tree content from insertable data\n\tconst mapTree = unhydratedFlexTreeFromInsertable(\n\t\tdata as InsertableField<UnsafeUnknownSchema>,\n\t\tschema,\n\t);\n\tconst result = mapTree === undefined ? undefined : getOrCreateNodeFromInnerNode(mapTree);\n\treturn result as Unhydrated<\n\t\tTSchema extends ImplicitFieldSchema\n\t\t\t? TreeFieldFromImplicitField<TSchema>\n\t\t\t: TreeNode | TreeLeafValue | undefined\n\t>;\n}\n\n/**\n * {@inheritDoc (TreeBeta:interface).(exportConcise:1)}\n */\nexport function exportConcise(\n\tnode: TreeNode | TreeLeafValue,\n\toptions?: TreeEncodingOptions,\n): ConciseTree;\n/**\n * {@inheritDoc (TreeBeta:interface).(exportConcise:2)}\n */\nexport function exportConcise(\n\tnode: TreeNode | TreeLeafValue | undefined,\n\toptions?: TreeEncodingOptions,\n): ConciseTree | undefined;\nexport function exportConcise(\n\tnode: TreeNode | TreeLeafValue | undefined,\n\toptions?: TreeEncodingOptions,\n): ConciseTree | undefined {\n\tif (!isTreeNode(node)) {\n\t\treturn node;\n\t}\n\tconst config: TreeEncodingOptions = { ...options };\n\n\tconst kernel = getKernel(node);\n\tconst cursor = borrowCursorFromTreeNodeOrValue(node);\n\treturn conciseFromCursor(cursor, kernel.context, config);\n}\n\n/**\n * Extensions to {@link (Tree:variable)} which are not yet stable.\n * @see {@link (TreeBeta:interface)}.\n * @beta\n */\nexport const TreeBeta: TreeBeta = {\n\ton<K extends keyof TreeChangeEventsBeta<TNode>, TNode extends TreeNode>(\n\t\tnode: TNode,\n\t\teventName: K,\n\t\tlistener: NoInfer<TreeChangeEventsBeta<TNode>[K]>,\n\t): () => void {\n\t\treturn treeNodeApi.on(node, eventName, listener);\n\t},\n\n\timportConcise,\n\texportConcise,\n\n\tclone<const TSchema extends ImplicitFieldSchema>(\n\t\tnode: TreeFieldFromImplicitField<TSchema>,\n\t): Unhydrated<TreeFieldFromImplicitField<TSchema>> {\n\t\t// The only non-TreeNode cases are {@link TreeLeafValue} and `undefined` (for an empty optional field) which can be returned as is.\n\t\tif (!isTreeNode(node)) {\n\t\t\treturn node;\n\t\t}\n\n\t\tconst kernel = getKernel(node);\n\t\tconst cursor = kernel.getInnerNode().borrowCursor();\n\n\t\t// To handle when the node transitively contains unknown optional fields,\n\t\t// derive the context from the source node's stored schema which has stored schema for any such fields and their contents.\n\t\tconst flexContext = new UnhydratedContext(\n\t\t\tdefaultSchemaPolicy,\n\t\t\tkernel.context.flexContext.schema,\n\t\t);\n\t\tconst context = new Context(flexContext, getUnhydratedContext(kernel.schema).schema);\n\n\t\tconst fieldSchema: TreeFieldStoredSchema = {\n\t\t\tkind: FieldKinds.required.identifier,\n\t\t\ttypes: new Set([brand(kernel.schema.identifier)]),\n\t\t\tpersistedMetadata: undefined,\n\t\t};\n\t\treturn createFromCursor(kernel.schema, cursor, fieldSchema, context) as Unhydrated<\n\t\t\tTreeFieldFromImplicitField<TSchema>\n\t\t>;\n\t},\n\n\tcreate<const TSchema extends ImplicitFieldSchema>(\n\t\tschema: TSchema,\n\t\tdata: InsertableTreeFieldFromImplicitField<TSchema>,\n\t): Unhydrated<TreeFieldFromImplicitField<TSchema>> {\n\t\tconst mapTree = unhydratedFlexTreeFromInsertable(\n\t\t\tdata as InsertableContent | undefined,\n\t\t\tschema,\n\t\t);\n\t\tconst result = mapTree === undefined ? undefined : getOrCreateNodeFromInnerNode(mapTree);\n\t\treturn result as Unhydrated<TreeFieldFromImplicitField<TSchema>>;\n\t},\n};\n"]}
@@ -5,6 +5,9 @@
5
5
  /**
6
6
  * A collection of events that can be emitted by a {@link TreeNode}.
7
7
  *
8
+ * @remarks
9
+ * Access these events via the {@link (Tree:variable)}'s {@link TreeNodeApi.on} method.
10
+ *
8
11
  * @privateRemarks
9
12
  * TODO: add a way to subscribe to a specific field (for nodeChanged and treeChanged).
10
13
  * Probably have object node and map node specific APIs for this.
@@ -32,7 +35,7 @@ export interface TreeChangeEvents {
32
35
  *
33
36
  * - Object nodes define a change as being when the value of one of its properties changes (i.e., the property's value is set, including when set to `undefined`).
34
37
  *
35
- * - Array nodes define a change as when an element is added, removed, moved or replaced.
38
+ * - Array nodes define a change as when an element is added, removed, moved, or replaced.
36
39
  *
37
40
  * - Map nodes define a change as when an entry is added, updated, or removed.
38
41
  *
@@ -1 +1 @@
1
- {"version":3,"file":"treeChangeEvents.d.ts","sourceRoot":"","sources":["../../../src/simple-tree/api/treeChangeEvents.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,WAAW,gBAAgB;IAChC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAuCG;IACH,WAAW,CAAC,QAAQ,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IAEtC;;;;;;;;;;;;;;;;;OAiBG;IACH,WAAW,IAAI,IAAI,CAAC;CACpB"}
1
+ {"version":3,"file":"treeChangeEvents.d.ts","sourceRoot":"","sources":["../../../src/simple-tree/api/treeChangeEvents.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,WAAW,gBAAgB;IAChC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAuCG;IACH,WAAW,CAAC,QAAQ,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IAEtC;;;;;;;;;;;;;;;;;OAiBG;IACH,WAAW,IAAI,IAAI,CAAC;CACpB"}
@@ -1 +1 @@
1
- {"version":3,"file":"treeChangeEvents.js","sourceRoot":"","sources":["../../../src/simple-tree/api/treeChangeEvents.ts"],"names":[],"mappings":";AAAA;;;GAGG","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/**\n * A collection of events that can be emitted by a {@link TreeNode}.\n *\n * @privateRemarks\n * TODO: add a way to subscribe to a specific field (for nodeChanged and treeChanged).\n * Probably have object node and map node specific APIs for this.\n *\n * TODO: ensure that subscription API for fields aligns with API for subscribing to the root.\n *\n * TODO: add more wider area (avoid needing tons of nodeChanged registration) events for use-cases other than treeChanged.\n * Some ideas:\n *\n * - treeChanged, but with some subtrees/fields/paths excluded\n * - helper to batch several nodeChanged calls to a treeChanged scope\n * - parent change (ex: registration on the parent field for a specific index: maybe allow it for a range. Ex: node event takes optional field and optional index range?)\n * - new content inserted into subtree. Either provide event for this and/or enough info to treeChanged to find and search the new sub-trees.\n * Add separate (non event related) API to efficiently scan tree for given set of types (using low level cursor and schema based filtering)\n * to allow efficiently searching for new content (and initial content) of a given type.\n *\n * @sealed @public\n */\nexport interface TreeChangeEvents {\n\t/**\n\t * Emitted by a node if any changes affected the node.\n\t *\n\t * This event is emitted after all the changes in a batch have been applied to the whole tree.\n\t * This means that a handler for this event will be able to read the updated state of the tree.\n\t *\n\t * - Object nodes define a change as being when the value of one of its properties changes (i.e., the property's value is set, including when set to `undefined`).\n\t *\n\t * - Array nodes define a change as when an element is added, removed, moved or replaced.\n\t *\n\t * - Map nodes define a change as when an entry is added, updated, or removed.\n\t *\n\t * @param unstable - Future versions of this API (such as the one in beta on TreeBeta) may use this argument to provide additional data to the event.\n\t * users of this event should ensure that they do not provide a listener callback which has an optional parameter in this position, since unexpected data might get provided to it.\n\t * This parameter exists to capture this fact in the type system.\n\t * Using an inline lambda expression as the listener callback is a good pattern to avoid cases like this were arguments are added from breaking due to optional arguments.\n\t *\n\t * @remarks\n\t * This event is not emitted when:\n\t *\n\t * - Properties of a child node change. Notably, updates to an array node or a map node (like adding or removing\n\t * elements/entries) will emit this event on the array/map node itself, but not on the node that contains the\n\t * array/map node as one of its properties.\n\t *\n\t * - The node is moved to a different location in the tree or removed from the tree.\n\t * In this case the event is emitted on the _parent_ node, not the node itself.\n\t *\n\t * For remote edits, this event is not guaranteed to occur in the same order or quantity that it did in\n\t * the client that made the original edit.\n\t *\n\t * When the event is emitted, the tree is guaranteed to be in-schema.\n\t *\n\t * @privateRemarks\n\t * This event occurs whenever the apparent contents of the node instance change, regardless of what caused the change.\n\t * For example, it will fire when the local client reassigns a child, when part of a remote edit is applied to the\n\t * node, or when the node has to be updated due to resolution of a merge conflict\n\t * (for example a previously applied local change might be undone, then reapplied differently or not at all).\n\t *\n\t * TODO: define and document event ordering (ex: bottom up, with nodeChanged before treeChange on each level).\n\t */\n\tnodeChanged(unstable?: unknown): void;\n\n\t/**\n\t * Emitted by a node if something changed anywhere in the subtree rooted at it.\n\t *\n\t * This event is emitted after all the changes in a batch have been applied to the whole tree.\n\t * This means that a handler for this event will be able to read the updated state of the tree.\n\t *\n\t * @remarks\n\t * This event is not emitted when the node itself is moved to a different location in the tree or removed from the tree.\n\t * In that case it is emitted on the _parent_ node, not the node itself.\n\t *\n\t * The node itself is part of the subtree, so this event will be emitted even if the only changes are to the properties\n\t * of the node itself.\n\t *\n\t * For remote edits, this event is not guaranteed to occur in the same order or quantity that it did in\n\t * the client that made the original edit.\n\t *\n\t * When it is emitted, the tree is guaranteed to be in-schema.\n\t */\n\ttreeChanged(): void;\n}\n"]}
1
+ {"version":3,"file":"treeChangeEvents.js","sourceRoot":"","sources":["../../../src/simple-tree/api/treeChangeEvents.ts"],"names":[],"mappings":";AAAA;;;GAGG","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/**\n * A collection of events that can be emitted by a {@link TreeNode}.\n *\n * @remarks\n * Access these events via the {@link (Tree:variable)}'s {@link TreeNodeApi.on} method.\n *\n * @privateRemarks\n * TODO: add a way to subscribe to a specific field (for nodeChanged and treeChanged).\n * Probably have object node and map node specific APIs for this.\n *\n * TODO: ensure that subscription API for fields aligns with API for subscribing to the root.\n *\n * TODO: add more wider area (avoid needing tons of nodeChanged registration) events for use-cases other than treeChanged.\n * Some ideas:\n *\n * - treeChanged, but with some subtrees/fields/paths excluded\n * - helper to batch several nodeChanged calls to a treeChanged scope\n * - parent change (ex: registration on the parent field for a specific index: maybe allow it for a range. Ex: node event takes optional field and optional index range?)\n * - new content inserted into subtree. Either provide event for this and/or enough info to treeChanged to find and search the new sub-trees.\n * Add separate (non event related) API to efficiently scan tree for given set of types (using low level cursor and schema based filtering)\n * to allow efficiently searching for new content (and initial content) of a given type.\n *\n * @sealed @public\n */\nexport interface TreeChangeEvents {\n\t/**\n\t * Emitted by a node if any changes affected the node.\n\t *\n\t * This event is emitted after all the changes in a batch have been applied to the whole tree.\n\t * This means that a handler for this event will be able to read the updated state of the tree.\n\t *\n\t * - Object nodes define a change as being when the value of one of its properties changes (i.e., the property's value is set, including when set to `undefined`).\n\t *\n\t * - Array nodes define a change as when an element is added, removed, moved, or replaced.\n\t *\n\t * - Map nodes define a change as when an entry is added, updated, or removed.\n\t *\n\t * @param unstable - Future versions of this API (such as the one in beta on TreeBeta) may use this argument to provide additional data to the event.\n\t * users of this event should ensure that they do not provide a listener callback which has an optional parameter in this position, since unexpected data might get provided to it.\n\t * This parameter exists to capture this fact in the type system.\n\t * Using an inline lambda expression as the listener callback is a good pattern to avoid cases like this were arguments are added from breaking due to optional arguments.\n\t *\n\t * @remarks\n\t * This event is not emitted when:\n\t *\n\t * - Properties of a child node change. Notably, updates to an array node or a map node (like adding or removing\n\t * elements/entries) will emit this event on the array/map node itself, but not on the node that contains the\n\t * array/map node as one of its properties.\n\t *\n\t * - The node is moved to a different location in the tree or removed from the tree.\n\t * In this case the event is emitted on the _parent_ node, not the node itself.\n\t *\n\t * For remote edits, this event is not guaranteed to occur in the same order or quantity that it did in\n\t * the client that made the original edit.\n\t *\n\t * When the event is emitted, the tree is guaranteed to be in-schema.\n\t *\n\t * @privateRemarks\n\t * This event occurs whenever the apparent contents of the node instance change, regardless of what caused the change.\n\t * For example, it will fire when the local client reassigns a child, when part of a remote edit is applied to the\n\t * node, or when the node has to be updated due to resolution of a merge conflict\n\t * (for example a previously applied local change might be undone, then reapplied differently or not at all).\n\t *\n\t * TODO: define and document event ordering (ex: bottom up, with nodeChanged before treeChange on each level).\n\t */\n\tnodeChanged(unstable?: unknown): void;\n\n\t/**\n\t * Emitted by a node if something changed anywhere in the subtree rooted at it.\n\t *\n\t * This event is emitted after all the changes in a batch have been applied to the whole tree.\n\t * This means that a handler for this event will be able to read the updated state of the tree.\n\t *\n\t * @remarks\n\t * This event is not emitted when the node itself is moved to a different location in the tree or removed from the tree.\n\t * In that case it is emitted on the _parent_ node, not the node itself.\n\t *\n\t * The node itself is part of the subtree, so this event will be emitted even if the only changes are to the properties\n\t * of the node itself.\n\t *\n\t * For remote edits, this event is not guaranteed to occur in the same order or quantity that it did in\n\t * the client that made the original edit.\n\t *\n\t * When it is emitted, the tree is guaranteed to be in-schema.\n\t */\n\ttreeChanged(): void;\n}\n"]}
@@ -2,9 +2,81 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
+ import { type DeltaMark } from "../../core/index.js";
5
6
  import { type TreeStatus } from "../../feature-libraries/index.js";
6
7
  import { type TreeNodeSchema, type TreeNode, type TreeLeafValue, type ImplicitAllowedTypes, type TreeNodeFromImplicitAllowedTypes } from "../core/index.js";
7
8
  import type { TreeChangeEvents } from "./treeChangeEvents.js";
9
+ /**
10
+ * A `"retain"` op in an {@link ArrayNodeDeltaOp} sequence.
11
+ * Represents elements that were neither inserted into nor removed from the array.
12
+ * @sealed @alpha
13
+ */
14
+ export interface ArrayNodeRetainOp {
15
+ readonly type: "retain";
16
+ readonly count: number;
17
+ }
18
+ /**
19
+ * A `"retain"` op in an {@link ArrayNodeTreeChangedDeltaOp} sequence, used in
20
+ * {@link NodeChangedDataTreeDelta} payloads delivered to
21
+ * {@link TreeChangeEventsAlpha.treeChanged} on array nodes.
22
+ *
23
+ * Extends {@link ArrayNodeRetainOp} with a {@link ArrayNodeTreeChangedRetainOp.subtreeChanged}
24
+ * flag that indicates whether any descendant of the retained element changed.
25
+ * @sealed @alpha
26
+ */
27
+ export interface ArrayNodeTreeChangedRetainOp extends ArrayNodeRetainOp {
28
+ /**
29
+ * Whether any descendant of this retained element changed.
30
+ * `true` if the element's subtree changed; `false` if nothing changed within it.
31
+ * @remarks
32
+ * Subscribe to `nodeChanged` or `treeChanged` on the element node itself for details.
33
+ */
34
+ readonly subtreeChanged: boolean;
35
+ }
36
+ /**
37
+ * A single operation in an array-node delta delivered by {@link TreeChangeEventsAlpha.treeChanged}.
38
+ * Extends {@link ArrayNodeDeltaOp}: retain ops carry a {@link ArrayNodeTreeChangedRetainOp.subtreeChanged}
39
+ * flag indicating whether any descendant of the retained element changed.
40
+ * @alpha
41
+ */
42
+ export type ArrayNodeTreeChangedDeltaOp = ArrayNodeTreeChangedRetainOp | ArrayNodeInsertOp | ArrayNodeRemoveOp;
43
+ /**
44
+ * An `"insert"` op in an {@link ArrayNodeDeltaOp} sequence.
45
+ * Represents elements added to the array.
46
+ * Read the new element values from the current tree at the positions described by this op.
47
+ * @sealed @alpha
48
+ */
49
+ export interface ArrayNodeInsertOp {
50
+ readonly type: "insert";
51
+ readonly count: number;
52
+ }
53
+ /**
54
+ * A `"remove"` op in an {@link ArrayNodeDeltaOp} sequence.
55
+ * Represents elements removed from the array.
56
+ * @sealed @alpha
57
+ */
58
+ export interface ArrayNodeRemoveOp {
59
+ readonly type: "remove";
60
+ readonly count: number;
61
+ }
62
+ /**
63
+ * A single operation in an array node change delta. Used to efficiently sync an external
64
+ * representation of an array (e.g. a text editor or virtual list) with tree changes without
65
+ * needing to snapshot the old state or diff the entire array. Each op describes a contiguous run
66
+ * of positions in the array before the change. For inserts, read the new element values from the
67
+ * current tree at those positions.
68
+ *
69
+ * @remarks
70
+ * There is no dedicated `"move"` op. Moves are represented as `"remove"` + `"insert"`.
71
+ * When an element is moved within the same array it appears
72
+ * as a `"remove"` at the source position followed by an `"insert"` at the destination position.
73
+ * When an element is moved across two different arrays, the source array's delta contains a
74
+ * `"remove"` and the destination array's delta contains an `"insert"` — they cannot be
75
+ * correlated without additional bookkeeping on the caller's side.
76
+ *
77
+ * @sealed @alpha
78
+ */
79
+ export type ArrayNodeDeltaOp = ArrayNodeRetainOp | ArrayNodeInsertOp | ArrayNodeRemoveOp;
8
80
  /**
9
81
  * Provides various functions for analyzing {@link TreeNode}s.
10
82
  *
@@ -64,6 +136,9 @@ export interface TreeNodeApi {
64
136
  * @param listener - The callback to trigger for the event. The tree can be read during the callback, but it is invalid to modify the tree during this callback.
65
137
  * @returns A callback function which will deregister the event.
66
138
  * This callback should be called only once.
139
+ * @remarks
140
+ * The returned unsubscribe function should be called any time the need for the `listener` callback ends before the node is {@link TreeStatus.Deleted | deleted} (Not just {@link TreeStatus.Removed | removed}).
141
+ * Doing so removes the overhead of tracking and triggering the event, and also avoids leaking any memory retained by the callback.
67
142
  */
68
143
  on<K extends keyof TreeChangeEvents>(node: TreeNode, eventName: K, listener: TreeChangeEvents[K]): () => void;
69
144
  /**
@@ -93,6 +168,39 @@ export interface TreeNodeApi {
93
168
  * {@inheritDoc TreeNodeApi}
94
169
  */
95
170
  export declare const treeNodeApi: TreeNodeApi;
171
+ /**
172
+ * Converts an array of internal {@link DeltaMark}s for a sequence field into sequential
173
+ * array delta ops suitable for inclusion in {@link NodeChangedDataDelta.delta}.
174
+ *
175
+ * Each mark in the delta describes a contiguous run of positions in the original array:
176
+ * - A mark with only `count` (no attach/detach) → `"retain"` with no subtree information
177
+ * - A mark with only `attach` → `"insert"` (new elements added)
178
+ * - A mark with only `detach` → `"remove"` (elements removed)
179
+ * - A mark with both `attach` and `detach` → `"remove"` + `"insert"`
180
+ *
181
+ * @param marks - The low-level delta marks for the array's sequence field.
182
+ *
183
+ * @privateRemarks
184
+ * The case where both `attach` and `detach` are set is unreachable today: the sequence-field
185
+ * encoder never emits such marks for array (EmptyKey) fields. It is handled defensively.
186
+ */
187
+ export declare function deltaMarksToArrayOps(marks: readonly DeltaMark[]): ArrayNodeDeltaOp[];
188
+ /**
189
+ * Converts an array of internal {@link DeltaMark}s for a sequence field into sequential
190
+ * {@link ArrayNodeTreeChangedDeltaOp}s suitable for inclusion in
191
+ * {@link NodeChangedDataTreeDelta.delta} (delivered to {@link TreeChangeEventsAlpha.treeChanged}).
192
+ *
193
+ * Same conversion rules as {@link deltaMarksToArrayOps}, but retain ops additionally carry a
194
+ * {@link ArrayNodeTreeChangedRetainOp.subtreeChanged} flag derived from whether the mark has
195
+ * a `fields` property (indicating a descendant changed).
196
+ *
197
+ * @param marks - The low-level delta marks for the array's sequence field.
198
+ *
199
+ * @privateRemarks
200
+ * The case where both `attach` and `detach` are set is unreachable today: the sequence-field
201
+ * encoder never emits such marks for array (EmptyKey) fields. It is handled defensively.
202
+ */
203
+ export declare function deltaMarksToArrayOpsForTreeChanged(marks: readonly DeltaMark[]): ArrayNodeTreeChangedDeltaOp[];
96
204
  /**
97
205
  * Returns a schema for a value if the value is a {@link TreeNode} or a {@link TreeLeafValue}.
98
206
  * Returns undefined for other values.
@@ -1 +1 @@
1
- {"version":3,"file":"treeNodeApi.d.ts","sourceRoot":"","sources":["../../../src/simple-tree/api/treeNodeApi.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAQH,OAAO,EAAE,KAAK,UAAU,EAA2B,MAAM,kCAAkC,CAAC;AAE5F,OAAO,EAGN,KAAK,cAAc,EAEnB,KAAK,QAAQ,EAKb,KAAK,aAAa,EAClB,KAAK,oBAAoB,EACzB,KAAK,gCAAgC,EAErC,MAAM,kBAAkB,CAAC;AAY1B,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAE9D;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,WAAW,WAAW;IAC3B;;OAEG;IACH,MAAM,CAAC,IAAI,EAAE,QAAQ,GAAG,aAAa,GAAG,cAAc,CAAC;IAEvD;;;;;;;;OAQG;IACH,EAAE,CAAC,OAAO,SAAS,oBAAoB,EACtC,KAAK,EAAE,OAAO,EACd,MAAM,EAAE,OAAO,GACb,KAAK,IAAI,gCAAgC,CAAC,OAAO,CAAC,CAAC;IAEtD;;;;;;;OAOG;IACH,MAAM,CAAC,IAAI,EAAE,QAAQ,GAAG,QAAQ,GAAG,SAAS,CAAC;IAE7C;;;;;;;;OAQG;IACH,GAAG,CAAC,IAAI,EAAE,QAAQ,GAAG,MAAM,GAAG,MAAM,CAAC;IAErC;;;;;;;OAOG;IACH,EAAE,CAAC,CAAC,SAAS,MAAM,gBAAgB,EAClC,IAAI,EAAE,QAAQ,EACd,SAAS,EAAE,CAAC,EACZ,QAAQ,EAAE,gBAAgB,CAAC,CAAC,CAAC,GAC3B,MAAM,IAAI,CAAC;IAEd;;OAEG;IACH,MAAM,CAAC,IAAI,EAAE,QAAQ,GAAG,UAAU,CAAC;IAEnC;;;;;;;;;;;;;;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EAAE,MAAM,GAAG,MAAM,GACxB,MAAM,GAAG,MAAM,CAyBjB"}
@@ -4,7 +4,7 @@
4
4
  * Licensed under the MIT License.
5
5
  */
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.getPropertyKeyFromStoredKey = exports.getStoredKey = exports.getIdentifierFromNode = exports.tryGetSchema = exports.treeNodeApi = void 0;
7
+ exports.getPropertyKeyFromStoredKey = exports.getStoredKey = exports.getIdentifierFromNode = exports.tryGetSchema = exports.deltaMarksToArrayOpsForTreeChanged = exports.deltaMarksToArrayOps = exports.treeNodeApi = void 0;
8
8
  const internal_1 = require("@fluidframework/core-utils/internal");
9
9
  const internal_2 = require("@fluidframework/runtime-utils/internal");
10
10
  const internal_3 = require("@fluidframework/telemetry-utils/internal");
@@ -57,8 +57,28 @@ exports.treeNodeApi = {
57
57
  });
58
58
  }
59
59
  else if ((0, index_js_5.isArrayNodeSchema)(nodeSchema)) {
60
- return kernel.events.on("childrenChangedAfterBatch", () => {
61
- listener({ changedProperties: undefined });
60
+ return kernel.events.on("childrenChangedAfterBatch", ({ fieldMarks }) => {
61
+ const marks = fieldMarks.get(index_js_1.EmptyKey);
62
+ // nodeChanged fires only for shallow changes (insert, remove, move).
63
+ // Deep changes (e.g. a property of an element changed) are
64
+ // surfaced via TreeChangeEventsAlpha.treeChanged with a delta payload instead.
65
+ // When marks are undefined (marks could not be composed across multiple
66
+ // internal passes), we conservatively fire nodeChanged rather than silently
67
+ // dropping the event, even though the underlying change may have been
68
+ // purely deep. This is a known limitation of the current eventing stack.
69
+ const hasShallowChange = marks === undefined ||
70
+ marks.some((m) => m.attach !== undefined || m.detach !== undefined);
71
+ if (!hasShallowChange) {
72
+ return;
73
+ }
74
+ // `marks` is undefined when the field was modified across multiple batches
75
+ // within a single flush (e.g. due to an interleaved schema change) and the
76
+ // marks could not be composed. Emit `undefined` so callers know the delta is
77
+ // unavailable rather than receiving stale marks from only the first batch.
78
+ // TODO: Once the eventing stack is rewritten to walk the composed delta at
79
+ // flush time, `marks` will always be defined. Remove the `undefined` fallback.
80
+ const delta = marks === undefined ? undefined : deltaMarksToArrayOps(marks);
81
+ listener({ delta });
62
82
  });
63
83
  }
64
84
  else {
@@ -68,6 +88,17 @@ exports.treeNodeApi = {
68
88
  }
69
89
  }
70
90
  case "treeChanged": {
91
+ if ((0, index_js_5.isArrayNodeSchema)(kernel.schema)) {
92
+ // For array nodes, treeChanged fires via childrenChangedAfterBatch so that a
93
+ // delta payload can be provided. This covers both shallow changes
94
+ // (insert/remove/move) and deep element changes. Stable (non-alpha) listeners
95
+ // typed as () => void will silently ignore the extra argument at runtime.
96
+ return kernel.events.on("childrenChangedAfterBatch", ({ fieldMarks }) => {
97
+ const marks = fieldMarks.get(index_js_1.EmptyKey);
98
+ const delta = marks === undefined ? undefined : deltaMarksToArrayOpsForTreeChanged(marks);
99
+ listener({ delta });
100
+ });
101
+ }
71
102
  return kernel.events.on("subtreeChangedAfterBatch", () => listener({}));
72
103
  }
73
104
  default: {
@@ -95,6 +126,76 @@ exports.treeNodeApi = {
95
126
  return getIdentifierFromNode(node, "preferCompressed");
96
127
  },
97
128
  };
129
+ /**
130
+ * Converts an array of internal {@link DeltaMark}s for a sequence field into sequential
131
+ * array delta ops suitable for inclusion in {@link NodeChangedDataDelta.delta}.
132
+ *
133
+ * Each mark in the delta describes a contiguous run of positions in the original array:
134
+ * - A mark with only `count` (no attach/detach) → `"retain"` with no subtree information
135
+ * - A mark with only `attach` → `"insert"` (new elements added)
136
+ * - A mark with only `detach` → `"remove"` (elements removed)
137
+ * - A mark with both `attach` and `detach` → `"remove"` + `"insert"`
138
+ *
139
+ * @param marks - The low-level delta marks for the array's sequence field.
140
+ *
141
+ * @privateRemarks
142
+ * The case where both `attach` and `detach` are set is unreachable today: the sequence-field
143
+ * encoder never emits such marks for array (EmptyKey) fields. It is handled defensively.
144
+ */
145
+ function deltaMarksToArrayOps(marks) {
146
+ const ops = [];
147
+ for (const mark of marks) {
148
+ if (mark.detach !== undefined) {
149
+ ops.push({ type: "remove", count: mark.count });
150
+ }
151
+ if (mark.attach !== undefined) {
152
+ ops.push({ type: "insert", count: mark.count });
153
+ }
154
+ else if (mark.detach === undefined) {
155
+ // Retain: elements were not added or removed.
156
+ ops.push({ type: "retain", count: mark.count });
157
+ }
158
+ }
159
+ return ops;
160
+ }
161
+ exports.deltaMarksToArrayOps = deltaMarksToArrayOps;
162
+ /**
163
+ * Converts an array of internal {@link DeltaMark}s for a sequence field into sequential
164
+ * {@link ArrayNodeTreeChangedDeltaOp}s suitable for inclusion in
165
+ * {@link NodeChangedDataTreeDelta.delta} (delivered to {@link TreeChangeEventsAlpha.treeChanged}).
166
+ *
167
+ * Same conversion rules as {@link deltaMarksToArrayOps}, but retain ops additionally carry a
168
+ * {@link ArrayNodeTreeChangedRetainOp.subtreeChanged} flag derived from whether the mark has
169
+ * a `fields` property (indicating a descendant changed).
170
+ *
171
+ * @param marks - The low-level delta marks for the array's sequence field.
172
+ *
173
+ * @privateRemarks
174
+ * The case where both `attach` and `detach` are set is unreachable today: the sequence-field
175
+ * encoder never emits such marks for array (EmptyKey) fields. It is handled defensively.
176
+ */
177
+ function deltaMarksToArrayOpsForTreeChanged(marks) {
178
+ const ops = [];
179
+ for (const mark of marks) {
180
+ if (mark.detach !== undefined) {
181
+ ops.push({ type: "remove", count: mark.count });
182
+ }
183
+ if (mark.attach !== undefined) {
184
+ ops.push({ type: "insert", count: mark.count });
185
+ }
186
+ else if (mark.detach === undefined) {
187
+ // Retain: elements were not added or removed (but may have deep changes).
188
+ // When `fields` is set, `count` is guaranteed to be 1 (DeltaMark invariant).
189
+ ops.push({
190
+ type: "retain",
191
+ count: mark.count,
192
+ subtreeChanged: mark.fields !== undefined,
193
+ });
194
+ }
195
+ }
196
+ return ops;
197
+ }
198
+ exports.deltaMarksToArrayOpsForTreeChanged = deltaMarksToArrayOpsForTreeChanged;
98
199
  /**
99
200
  * Returns a schema for a value if the value is a {@link TreeNode} or a {@link TreeLeafValue}.
100
201
  * Returns undefined for other values.
@@ -1 +1 @@
1
- {"version":3,"file":"treeNodeApi.js","sourceRoot":"","sources":["../../../src/simple-tree/api/treeNodeApi.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,kEAAyF;AACzF,qEAAuE;AACvE,uEAAsE;AAEtE,kDAA6D;AAC7D,+DAA4F;AAC5F,kDAAwD;AACxD,+CAc0B;AAC1B,sDAA0E;AAC1E,sEAAmE;AACnE,4DAM8B;AAC9B,qDAA+E;AAsG/E;;GAEG;AACU,QAAA,WAAW,GAAgB;IACvC,MAAM,CAAC,IAAc;QACpB,MAAM,QAAQ,GAAG,IAAA,uBAAY,EAAC,IAAI,CAAC,CAAC,WAAW,CAAC,MAAM,CAAC,MAAM,CAAC;QAC9D,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;YAC5B,OAAO,SAAS,CAAC;QAClB,CAAC;QAED,MAAM,MAAM,GAAG,IAAA,uCAA4B,EAAC,QAAQ,CAAC,CAAC;QACtD,IAAA,iBAAM,EACL,CAAC,IAAA,sBAAW,EAAC,MAAM,CAAC,EACpB,KAAK,CAAC,gEAAgE,CACtE,CAAC;QACF,OAAO,MAAM,CAAC;IACf,CAAC;IACD,GAAG,CAAC,IAAc;QACjB,sEAAsE;QACtE,8CAA8C;QAC9C,MAAM,MAAM,GAAG,mBAAW,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QACxC,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;YAC1B,OAAO,uBAAY,CAAC;QACrB,CAAC;QAED,+DAA+D;QAC/D,uGAAuG;QACvG,4GAA4G;QAC5G,MAAM,SAAS,GAAG,YAAY,CAAC,IAAI,CAAC,CAAC;QACrC,MAAM,YAAY,GAAG,mBAAW,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QAChD,MAAM,WAAW,GAAG,2BAA2B,CAAC,YAAY,EAAE,SAAS,CAAC,CAAC;QACzE,OAAO,WAAW,CAAC;IACpB,CAAC;IACD,EAAE,CACD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AAC;AA5BD,kEA4BC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { Off } from \"@fluidframework/core-interfaces\";\nimport { assert, oob, fail, unreachableCase } from \"@fluidframework/core-utils/internal\";\nimport { isFluidHandle } from \"@fluidframework/runtime-utils/internal\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\n\nimport { EmptyKey, rootFieldKey } from \"../../core/index.js\";\nimport { type TreeStatus, isTreeValue, FieldKinds } from \"../../feature-libraries/index.js\";\nimport { extractFromOpaque } from \"../../util/index.js\";\nimport {\n\tgetKernel,\n\tisTreeNode,\n\ttype TreeNodeSchema,\n\tNodeKind,\n\ttype TreeNode,\n\ttryGetTreeNodeSchema,\n\tgetOrCreateNodeFromInnerNode,\n\ttypeSchemaSymbol,\n\tgetInnerNode,\n\ttype TreeLeafValue,\n\ttype ImplicitAllowedTypes,\n\ttype TreeNodeFromImplicitAllowedTypes,\n\tnormalizeAllowedTypes,\n} from \"../core/index.js\";\nimport { type ImplicitFieldSchema, FieldSchema } from \"../fieldSchema.js\";\nimport { tryGetTreeNodeForField } from \"../getTreeNodeForField.js\";\nimport {\n\tbooleanSchema,\n\thandleSchema,\n\tnullSchema,\n\tnumberSchema,\n\tstringSchema,\n} from \"../leafNodeSchema.js\";\nimport { isArrayNodeSchema, isObjectNodeSchema } from \"../node-kinds/index.js\";\n\nimport type { TreeChangeEvents } from \"./treeChangeEvents.js\";\n\n/**\n * Provides various functions for analyzing {@link TreeNode}s.\n *\n * @remarks\n * With the exception of {@link TreeNodeApi.status}, these functions should not be called with nodes that have\n * been {@link TreeStatus.Deleted | deleted}.\n * To verify whether or not a node already has been deleted, use the {@link TreeNodeApi.status} function.\n *\n * This type should only be used via the public {@link (Tree:variable)} export.\n *\n * @privateRemarks\n * Due to limitations of API-Extractor link resolution, this type can't be moved into internalTypes but should be considered just an implementation detail of the `Tree` export.\n *\n * Inlining the typing of this interface onto the `Tree` object provides slightly different .d.ts generation,\n * which avoids typescript expanding the type of TreeNodeSchema and thus encountering\n * https://github.com/microsoft/rushstack/issues/1958.\n * @sealed @public\n */\nexport interface TreeNodeApi {\n\t/**\n\t * The schema information for this node.\n\t */\n\tschema(node: TreeNode | TreeLeafValue): TreeNodeSchema;\n\n\t/**\n\t * Narrow the type of the given value if it satisfies the given schema.\n\t * @example\n\t * ```ts\n\t * if (node.is(myNode, Point)) {\n\t * const y = myNode.y; // `myNode` is now known to satisfy the `Point` schema and therefore has a `y` coordinate.\n\t * }\n\t * ```\n\t */\n\tis<TSchema extends ImplicitAllowedTypes>(\n\t\tvalue: unknown,\n\t\tschema: TSchema,\n\t): value is TreeNodeFromImplicitAllowedTypes<TSchema>;\n\n\t/**\n\t * Return the node under which this node resides in the tree (or undefined if this is a root node of the tree).\n\t *\n\t * @throws A {@link @fluidframework/telemetry-utils#UsageError} if the node has been {@link TreeStatus.Deleted | deleted}.\n\t *\n\t * @see {@link (TreeAlpha:interface).child}\n\t * @see {@link (TreeAlpha:interface).children}\n\t */\n\tparent(node: TreeNode): TreeNode | undefined;\n\n\t/**\n\t * The key of the given node under its parent.\n\t *\n\t * @remarks\n\t * If `node` is an element in a {@link (TreeArrayNode:interface)}, this returns the index of `node` in the array node (a `number`).\n\t * Otherwise, this returns the key of the field that it is under (a `string`).\n\t *\n\t * @throws A {@link @fluidframework/telemetry-utils#UsageError} if the node has been {@link TreeStatus.Deleted | deleted}.\n\t */\n\tkey(node: TreeNode): string | number;\n\n\t/**\n\t * Register an event listener on the given node.\n\t * @param node - The node whose events should be subscribed to.\n\t * @param eventName - Which event to subscribe to.\n\t * @param listener - The callback to trigger for the event. The tree can be read during the callback, but it is invalid to modify the tree during this callback.\n\t * @returns A callback function which will deregister the event.\n\t * This callback should be called only once.\n\t */\n\ton<K extends keyof TreeChangeEvents>(\n\t\tnode: TreeNode,\n\t\teventName: K,\n\t\tlistener: TreeChangeEvents[K],\n\t): () => void;\n\n\t/**\n\t * Returns the {@link TreeStatus} of the given node.\n\t */\n\tstatus(node: TreeNode): TreeStatus;\n\n\t/**\n\t * Returns the {@link SchemaFactory.identifier | identifier} of the given node in the most compressed form possible.\n\t * @remarks\n\t * If the node is {@link Unhydrated | hydrated} and its identifier is a valid UUID that was automatically generated by the SharedTree it is part of (or something else using the same {@link @fluidframework/id-compressor#IIdCompressor}), then this will return a process-unique integer corresponding to that identifier.\n\t * This is useful for performance-sensitive scenarios involving many nodes with identifiers that need to be compactly retained in memory or used for efficient lookup.\n\t * Note that automatically generated identifiers that were accessed before the node was hydrated will return the generated UUID, not the process-unique integer.\n\t *\n\t * If the node's identifier is any other user-provided string, then this will return that string.\n\t *\n\t * If the node has no identifier (that is, it has no {@link SchemaFactory.identifier | identifier} field), then this returns `undefined`.\n\t *\n\t * If the node has more than one identifier, then this will throw an error.\n\t *\n\t * The returned integer should not be serialized or preserved outside of the current process.\n\t * Its lifetime is that of the current in-memory instance of the FF container for this client, and it is not guaranteed to be unique or stable outside of that context.\n\t * The same node's identifier may, for example, be different across multiple sessions for the same client and document, or different across two clients in the same session.\n\t */\n\tshortId(node: TreeNode): number | string | undefined;\n}\n\n/**\n * {@inheritDoc TreeNodeApi}\n */\nexport const treeNodeApi: TreeNodeApi = {\n\tparent(node: TreeNode): TreeNode | undefined {\n\t\tconst editNode = getInnerNode(node).parentField.parent.parent;\n\t\tif (editNode === undefined) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst output = getOrCreateNodeFromInnerNode(editNode);\n\t\tassert(\n\t\t\t!isTreeValue(output),\n\t\t\t0x87f /* Parent can't be a leaf, so it should be a node not a value */,\n\t\t);\n\t\treturn output;\n\t},\n\tkey(node: TreeNode): string | number {\n\t\t// If the parent is undefined, then this node is under the root field,\n\t\t// so we know its key is the special root one.\n\t\tconst parent = treeNodeApi.parent(node);\n\t\tif (parent === undefined) {\n\t\t\treturn rootFieldKey;\n\t\t}\n\n\t\t// The flex-domain strictly operates in terms of \"stored keys\".\n\t\t// To find the associated developer-facing \"property key\", we need to look up the field associated with\n\t\t// the stored key from the flex-domain, and get property key its simple-domain counterpart was created with.\n\t\tconst storedKey = getStoredKey(node);\n\t\tconst parentSchema = treeNodeApi.schema(parent);\n\t\tconst propertyKey = getPropertyKeyFromStoredKey(parentSchema, storedKey);\n\t\treturn propertyKey;\n\t},\n\ton<K extends keyof TreeChangeEvents>(\n\t\tnode: TreeNode,\n\t\teventName: K,\n\t\tlistener: TreeChangeEvents[K],\n\t): Off {\n\t\tconst kernel = getKernel(node);\n\t\tswitch (eventName) {\n\t\t\tcase \"nodeChanged\": {\n\t\t\t\tconst nodeSchema = kernel.schema;\n\t\t\t\tif (isObjectNodeSchema(nodeSchema)) {\n\t\t\t\t\treturn kernel.events.on(\"childrenChangedAfterBatch\", ({ changedFields }) => {\n\t\t\t\t\t\tconst changedProperties = new Set(\n\t\t\t\t\t\t\tArray.from(\n\t\t\t\t\t\t\t\tchangedFields,\n\t\t\t\t\t\t\t\t(field) =>\n\t\t\t\t\t\t\t\t\tnodeSchema.storedKeyToPropertyKey.get(field) ??\n\t\t\t\t\t\t\t\t\tfail(0xb36 /* Could not find stored key in schema. */),\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t);\n\t\t\t\t\t\tlistener({ changedProperties });\n\t\t\t\t\t});\n\t\t\t\t} else if (isArrayNodeSchema(nodeSchema)) {\n\t\t\t\t\treturn kernel.events.on(\"childrenChangedAfterBatch\", () => {\n\t\t\t\t\t\tlistener({ changedProperties: undefined });\n\t\t\t\t\t});\n\t\t\t\t} else {\n\t\t\t\t\treturn kernel.events.on(\"childrenChangedAfterBatch\", ({ changedFields }) => {\n\t\t\t\t\t\tlistener({ changedProperties: changedFields });\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t\tcase \"treeChanged\": {\n\t\t\t\treturn kernel.events.on(\"subtreeChangedAfterBatch\", () => listener({}));\n\t\t\t}\n\t\t\tdefault: {\n\t\t\t\tthrow new UsageError(`No event named ${JSON.stringify(eventName)}.`);\n\t\t\t}\n\t\t}\n\t},\n\tstatus(node: TreeNode): TreeStatus {\n\t\treturn getKernel(node).getStatus();\n\t},\n\tis<TSchema extends ImplicitAllowedTypes>(\n\t\tvalue: unknown,\n\t\tschema: TSchema,\n\t): value is TreeNodeFromImplicitAllowedTypes<TSchema> {\n\t\t// This \"is\" utility would return false if the provided schema is a base type of the actual schema.\n\t\t// This could be confusing, and that case can only be hit when violating the rule that there is a single most derived schema that gets used (See documentation on TreeNodeSchemaClass).\n\t\t// Therefore this uses markSchemaMostDerived to ensure an informative usage error is thrown in the case where a base type is used.\n\n\t\tconst actualSchema = tryGetSchema(value);\n\t\tif (actualSchema === undefined) {\n\t\t\treturn false;\n\t\t}\n\t\treturn normalizeAllowedTypes(schema).evaluateSet().has(actualSchema);\n\t},\n\tschema(node: TreeNode | TreeLeafValue): TreeNodeSchema {\n\t\treturn tryGetSchema(node) ?? fail(0xb37 /* Not a tree node */);\n\t},\n\tshortId(node: TreeNode): number | string | undefined {\n\t\treturn getIdentifierFromNode(node, \"preferCompressed\");\n\t},\n};\n\n/**\n * Returns a schema for a value if the value is a {@link TreeNode} or a {@link TreeLeafValue}.\n * Returns undefined for other values.\n */\nexport function tryGetSchema(value: unknown): undefined | TreeNodeSchema {\n\tswitch (typeof value) {\n\t\tcase \"string\": {\n\t\t\treturn stringSchema;\n\t\t}\n\t\tcase \"number\": {\n\t\t\treturn numberSchema;\n\t\t}\n\t\tcase \"boolean\": {\n\t\t\treturn booleanSchema;\n\t\t}\n\t\tcase \"object\": {\n\t\t\tif (isTreeNode(value)) {\n\t\t\t\t// TODO: This case could be optimized, for example by placing the simple schema in a symbol on tree nodes.\n\t\t\t\treturn tryGetTreeNodeSchema(value);\n\t\t\t}\n\t\t\tif (value === null) {\n\t\t\t\treturn nullSchema;\n\t\t\t}\n\t\t\tif (isFluidHandle(value)) {\n\t\t\t\treturn handleSchema;\n\t\t\t}\n\t\t}\n\t\tdefault: {\n\t\t\treturn undefined;\n\t\t}\n\t}\n}\n\n/**\n * Gets the identifier from a node.\n *\n * @param node - {@link TreeNode} where you want to extract the identifier from.\n * @param compression - string value to determine what type of identifier you want to retrieve.\n *\n * @remarks\n * If the node does not contain an identifier field, it returns undefined.\n *\n * If `compression` is set to `compressed`:\n *\n * - If the node contains a compressible identifier known by the id compressor, the compressed identifier is returned.\n *\n * - If the node contains an identifier, but is not compressible or unknown by the id compressor, `undefined` is returned.\n *\n * If `compression` is set to `preferCompressed`:\n *\n * - If the node contains a compressible identifier known by the id compressor, the compressed identifier is returned.\n *\n * - If the node contains an identifier, but is not compressible or unknown by the id compressor, the uncompressed identifier is returned.\n *\n * If `compression` is set to `uncompressed`:\n * - If the node contains an identifier field, the uncompressed identifier is returned.\n */\nexport function getIdentifierFromNode(\n\tnode: TreeNode,\n\tcompression: \"preferCompressed\",\n): number | string | undefined;\nexport function getIdentifierFromNode(\n\tnode: TreeNode,\n\tcompression: \"compressed\",\n): number | undefined;\nexport function getIdentifierFromNode(\n\tnode: TreeNode,\n\tcompression: \"uncompressed\",\n): string | undefined;\nexport function getIdentifierFromNode(\n\tnode: TreeNode,\n\tcompression: \"preferCompressed\" | \"compressed\" | \"uncompressed\",\n): number | string | undefined {\n\tconst schema = node[typeSchemaSymbol];\n\tif (!isObjectNodeSchema(schema)) {\n\t\treturn undefined;\n\t}\n\n\tconst flexNode = getInnerNode(node);\n\tconst identifierFieldKeys = schema.identifierFieldKeys;\n\n\tswitch (identifierFieldKeys.length) {\n\t\tcase 0: {\n\t\t\treturn undefined;\n\t\t}\n\t\tcase 1: {\n\t\t\tconst key = identifierFieldKeys[0] ?? oob();\n\t\t\tconst identifierField = flexNode.tryGetField(key);\n\t\t\tassert(identifierField !== undefined, 0xbb5 /* missing identifier field */);\n\t\t\tconst identifierValue = tryGetTreeNodeForField(identifierField);\n\t\t\tassert(typeof identifierValue === \"string\", 0xbb6 /* identifier not a string */);\n\n\t\t\tconst context = flexNode.context;\n\t\t\tswitch (compression) {\n\t\t\t\tcase \"preferCompressed\": {\n\t\t\t\t\tif (context.isHydrated()) {\n\t\t\t\t\t\tconst localNodeKey =\n\t\t\t\t\t\t\tcontext.nodeKeyManager.tryLocalizeNodeIdentifier(identifierValue);\n\t\t\t\t\t\treturn localNodeKey === undefined\n\t\t\t\t\t\t\t? identifierValue\n\t\t\t\t\t\t\t: extractFromOpaque(localNodeKey);\n\t\t\t\t\t} else {\n\t\t\t\t\t\treturn identifierValue;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tcase \"compressed\": {\n\t\t\t\t\tif (context.isHydrated()) {\n\t\t\t\t\t\tconst localNodeKey =\n\t\t\t\t\t\t\tcontext.nodeKeyManager.tryLocalizeNodeIdentifier(identifierValue);\n\t\t\t\t\t\treturn localNodeKey === undefined ? undefined : extractFromOpaque(localNodeKey);\n\t\t\t\t\t} else {\n\t\t\t\t\t\treturn undefined;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tcase \"uncompressed\": {\n\t\t\t\t\treturn identifierValue;\n\t\t\t\t}\n\t\t\t\tdefault: {\n\t\t\t\t\tunreachableCase(compression);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tdefault: {\n\t\t\tthrow new UsageError(\n\t\t\t\t\"The node has more than one identifier. Retrieve identifiers individually via their fields instead.\",\n\t\t\t);\n\t\t}\n\t}\n}\n\n/**\n * Gets the stored key with which the provided node is associated in the parent.\n */\nexport function getStoredKey(node: TreeNode): string | number {\n\t// Note: the flex domain strictly works with \"stored keys\", and knows nothing about the developer-facing\n\t// \"property keys\".\n\tconst parentField = getInnerNode(node).parentField;\n\tif (parentField.parent.schema === FieldKinds.sequence.identifier) {\n\t\t// The parent of `node` is an array node\n\t\tassert(\n\t\t\tparentField.parent.key === EmptyKey,\n\t\t\t0xa28 /* When using index as key, field should use EmptyKey */,\n\t\t);\n\t\treturn parentField.index;\n\t}\n\n\t// The parent of `node` is an object, a map, or undefined. If undefined, then `node` is a root/detached node.\n\tassert(parentField.index === 0, 0xa29 /* When using field key as key, index should be 0 */);\n\treturn parentField.parent.key;\n}\n\n/**\n * Given a node schema, gets the property key corresponding with the provided {@link FieldProps.key | stored key}.\n */\nexport function getPropertyKeyFromStoredKey(\n\tschema: TreeNodeSchema,\n\tstoredKey: string | number,\n): string | number {\n\t// Only object nodes have the concept of a \"stored key\", differentiated from the developer-facing \"property key\".\n\t// For any other kind of node, the stored key and the property key are the same.\n\tif (schema.kind !== NodeKind.Object) {\n\t\treturn storedKey;\n\t}\n\n\tconst fields = schema.info as Record<string, ImplicitFieldSchema>;\n\n\t// Invariants:\n\t// - The set of all property keys under an object must be unique.\n\t// - The set of all stored keys (including those implicitly created from property keys) must be unique.\n\t// To find the property key associated with the provided stored key, first check for any stored key matches (which are optionally populated).\n\t// If we don't find any, then search for a matching property key.\n\tfor (const [propertyKey, fieldSchema] of Object.entries(fields)) {\n\t\tif (fieldSchema instanceof FieldSchema && fieldSchema.props?.key === storedKey) {\n\t\t\treturn propertyKey;\n\t\t}\n\t}\n\n\tif (fields[storedKey] === undefined) {\n\t\tfail(0xb38 /* Existing stored key should always map to a property key */);\n\t}\n\n\treturn storedKey;\n}\n"]}
1
+ {"version":3,"file":"treeNodeApi.js","sourceRoot":"","sources":["../../../src/simple-tree/api/treeNodeApi.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,kEAAyF;AACzF,qEAAuE;AACvE,uEAAsE;AAEtE,kDAA6E;AAC7E,+DAA4F;AAC5F,kDAAwD;AACxD,+CAc0B;AAC1B,sDAA0E;AAC1E,sEAAmE;AACnE,4DAM8B;AAC9B,qDAA+E;AAyL/E;;GAEG;AACU,QAAA,WAAW,GAAgB;IACvC,MAAM,CAAC,IAAc;QACpB,MAAM,QAAQ,GAAG,IAAA,uBAAY,EAAC,IAAI,CAAC,CAAC,WAAW,CAAC,MAAM,CAAC,MAAM,CAAC;QAC9D,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;YAC5B,OAAO,SAAS,CAAC;QAClB,CAAC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D,CAC9D,CAAC;QACF,OAAO,WAAW,CAAC,KAAK,CAAC;IAC1B,CAAC;IAED,6GAA6G;IAC7G,IAAA,iBAAM,EAAC,WAAW,CAAC,KAAK,KAAK,CAAC,EAAE,KAAK,CAAC,oDAAoD,CAAC,CAAC;IAC5F,OAAO,WAAW,CAAC,MAAM,CAAC,GAAG,CAAC;AAC/B,CAAC;AAhBD,oCAgBC;AAED;;GAEG;AACH,SAAgB,2BAA2B,CAC1C,MAAsB,EACtB,SAA0B;IAE1B,iHAAiH;IACjH,gFAAgF;IAChF,IAAI,MAAM,CAAC,IAAI,KAAK,mBAAQ,CAAC,MAAM,EAAE,CAAC;QACrC,OAAO,SAAS,CAAC;IAClB,CAAC;IAED,MAAM,MAAM,GAAG,MAAM,CAAC,IAA2C,CAAC;IAElE,cAAc;IACd,iEAAiE;IACjE,uGAAuG;IACvG,6IAA6I;IAC7I,iEAAiE;IACjE,KAAK,MAAM,CAAC,WAAW,EAAE,WAAW,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;QACjE,IAAI,WAAW,YAAY,4BAAW,IAAI,WAAW,CAAC,KAAK,EAAE,GAAG,KAAK,SAAS,EAAE,CAAC;YAChF,OAAO,WAAW,CAAC;QACpB,CAAC;IACF,CAAC;IAED,IAAI,MAAM,CAAC,SAAS,CAAC,KAAK,SAAS,EAAE,CAAC;QACrC,IAAA,eAAI,EAAC,KAAK,CAAC,6DAA6D,CAAC,CAAC;IAC3E,CAAC;IAED,OAAO,SAAS,CAAC;AAClB,CAAC;AA5BD,kEA4BC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { Off } from \"@fluidframework/core-interfaces\";\nimport { assert, oob, fail, unreachableCase } from \"@fluidframework/core-utils/internal\";\nimport { isFluidHandle } from \"@fluidframework/runtime-utils/internal\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\n\nimport { EmptyKey, rootFieldKey, type DeltaMark } from \"../../core/index.js\";\nimport { type TreeStatus, isTreeValue, FieldKinds } from \"../../feature-libraries/index.js\";\nimport { extractFromOpaque } from \"../../util/index.js\";\nimport {\n\tgetKernel,\n\tisTreeNode,\n\ttype TreeNodeSchema,\n\tNodeKind,\n\ttype TreeNode,\n\ttryGetTreeNodeSchema,\n\tgetOrCreateNodeFromInnerNode,\n\ttypeSchemaSymbol,\n\tgetInnerNode,\n\ttype TreeLeafValue,\n\ttype ImplicitAllowedTypes,\n\ttype TreeNodeFromImplicitAllowedTypes,\n\tnormalizeAllowedTypes,\n} from \"../core/index.js\";\nimport { type ImplicitFieldSchema, FieldSchema } from \"../fieldSchema.js\";\nimport { tryGetTreeNodeForField } from \"../getTreeNodeForField.js\";\nimport {\n\tbooleanSchema,\n\thandleSchema,\n\tnullSchema,\n\tnumberSchema,\n\tstringSchema,\n} from \"../leafNodeSchema.js\";\nimport { isArrayNodeSchema, isObjectNodeSchema } from \"../node-kinds/index.js\";\n\nimport type { TreeChangeEvents } from \"./treeChangeEvents.js\";\n\n/**\n * A `\"retain\"` op in an {@link ArrayNodeDeltaOp} sequence.\n * Represents elements that were neither inserted into nor removed from the array.\n * @sealed @alpha\n */\nexport interface ArrayNodeRetainOp {\n\treadonly type: \"retain\";\n\treadonly count: number;\n}\n\n/**\n * A `\"retain\"` op in an {@link ArrayNodeTreeChangedDeltaOp} sequence, used in\n * {@link NodeChangedDataTreeDelta} payloads delivered to\n * {@link TreeChangeEventsAlpha.treeChanged} on array nodes.\n *\n * Extends {@link ArrayNodeRetainOp} with a {@link ArrayNodeTreeChangedRetainOp.subtreeChanged}\n * flag that indicates whether any descendant of the retained element changed.\n * @sealed @alpha\n */\nexport interface ArrayNodeTreeChangedRetainOp extends ArrayNodeRetainOp {\n\t/**\n\t * Whether any descendant of this retained element changed.\n\t * `true` if the element's subtree changed; `false` if nothing changed within it.\n\t * @remarks\n\t * Subscribe to `nodeChanged` or `treeChanged` on the element node itself for details.\n\t */\n\treadonly subtreeChanged: boolean;\n}\n\n/**\n * A single operation in an array-node delta delivered by {@link TreeChangeEventsAlpha.treeChanged}.\n * Extends {@link ArrayNodeDeltaOp}: retain ops carry a {@link ArrayNodeTreeChangedRetainOp.subtreeChanged}\n * flag indicating whether any descendant of the retained element changed.\n * @alpha\n */\nexport type ArrayNodeTreeChangedDeltaOp =\n\t| ArrayNodeTreeChangedRetainOp\n\t| ArrayNodeInsertOp\n\t| ArrayNodeRemoveOp;\n\n/**\n * An `\"insert\"` op in an {@link ArrayNodeDeltaOp} sequence.\n * Represents elements added to the array.\n * Read the new element values from the current tree at the positions described by this op.\n * @sealed @alpha\n */\nexport interface ArrayNodeInsertOp {\n\treadonly type: \"insert\";\n\treadonly count: number;\n}\n\n/**\n * A `\"remove\"` op in an {@link ArrayNodeDeltaOp} sequence.\n * Represents elements removed from the array.\n * @sealed @alpha\n */\nexport interface ArrayNodeRemoveOp {\n\treadonly type: \"remove\";\n\treadonly count: number;\n}\n\n/**\n * A single operation in an array node change delta. Used to efficiently sync an external\n * representation of an array (e.g. a text editor or virtual list) with tree changes without\n * needing to snapshot the old state or diff the entire array. Each op describes a contiguous run\n * of positions in the array before the change. For inserts, read the new element values from the\n * current tree at those positions.\n *\n * @remarks\n * There is no dedicated `\"move\"` op. Moves are represented as `\"remove\"` + `\"insert\"`.\n * When an element is moved within the same array it appears\n * as a `\"remove\"` at the source position followed by an `\"insert\"` at the destination position.\n * When an element is moved across two different arrays, the source array's delta contains a\n * `\"remove\"` and the destination array's delta contains an `\"insert\"` — they cannot be\n * correlated without additional bookkeeping on the caller's side.\n *\n * @sealed @alpha\n */\nexport type ArrayNodeDeltaOp = ArrayNodeRetainOp | ArrayNodeInsertOp | ArrayNodeRemoveOp;\n\n/**\n * Provides various functions for analyzing {@link TreeNode}s.\n *\n * @remarks\n * With the exception of {@link TreeNodeApi.status}, these functions should not be called with nodes that have\n * been {@link TreeStatus.Deleted | deleted}.\n * To verify whether or not a node already has been deleted, use the {@link TreeNodeApi.status} function.\n *\n * This type should only be used via the public {@link (Tree:variable)} export.\n *\n * @privateRemarks\n * Due to limitations of API-Extractor link resolution, this type can't be moved into internalTypes but should be considered just an implementation detail of the `Tree` export.\n *\n * Inlining the typing of this interface onto the `Tree` object provides slightly different .d.ts generation,\n * which avoids typescript expanding the type of TreeNodeSchema and thus encountering\n * https://github.com/microsoft/rushstack/issues/1958.\n * @sealed @public\n */\nexport interface TreeNodeApi {\n\t/**\n\t * The schema information for this node.\n\t */\n\tschema(node: TreeNode | TreeLeafValue): TreeNodeSchema;\n\n\t/**\n\t * Narrow the type of the given value if it satisfies the given schema.\n\t * @example\n\t * ```ts\n\t * if (node.is(myNode, Point)) {\n\t * const y = myNode.y; // `myNode` is now known to satisfy the `Point` schema and therefore has a `y` coordinate.\n\t * }\n\t * ```\n\t */\n\tis<TSchema extends ImplicitAllowedTypes>(\n\t\tvalue: unknown,\n\t\tschema: TSchema,\n\t): value is TreeNodeFromImplicitAllowedTypes<TSchema>;\n\n\t/**\n\t * Return the node under which this node resides in the tree (or undefined if this is a root node of the tree).\n\t *\n\t * @throws A {@link @fluidframework/telemetry-utils#UsageError} if the node has been {@link TreeStatus.Deleted | deleted}.\n\t *\n\t * @see {@link (TreeAlpha:interface).child}\n\t * @see {@link (TreeAlpha:interface).children}\n\t */\n\tparent(node: TreeNode): TreeNode | undefined;\n\n\t/**\n\t * The key of the given node under its parent.\n\t *\n\t * @remarks\n\t * If `node` is an element in a {@link (TreeArrayNode:interface)}, this returns the index of `node` in the array node (a `number`).\n\t * Otherwise, this returns the key of the field that it is under (a `string`).\n\t *\n\t * @throws A {@link @fluidframework/telemetry-utils#UsageError} if the node has been {@link TreeStatus.Deleted | deleted}.\n\t */\n\tkey(node: TreeNode): string | number;\n\n\t/**\n\t * Register an event listener on the given node.\n\t * @param node - The node whose events should be subscribed to.\n\t * @param eventName - Which event to subscribe to.\n\t * @param listener - The callback to trigger for the event. The tree can be read during the callback, but it is invalid to modify the tree during this callback.\n\t * @returns A callback function which will deregister the event.\n\t * This callback should be called only once.\n\t * @remarks\n\t * The returned unsubscribe function should be called any time the need for the `listener` callback ends before the node is {@link TreeStatus.Deleted | deleted} (Not just {@link TreeStatus.Removed | removed}).\n\t * Doing so removes the overhead of tracking and triggering the event, and also avoids leaking any memory retained by the callback.\n\t */\n\ton<K extends keyof TreeChangeEvents>(\n\t\tnode: TreeNode,\n\t\teventName: K,\n\t\tlistener: TreeChangeEvents[K],\n\t): () => void;\n\n\t/**\n\t * Returns the {@link TreeStatus} of the given node.\n\t */\n\tstatus(node: TreeNode): TreeStatus;\n\n\t/**\n\t * Returns the {@link SchemaFactory.identifier | identifier} of the given node in the most compressed form possible.\n\t * @remarks\n\t * If the node is {@link Unhydrated | hydrated} and its identifier is a valid UUID that was automatically generated by the SharedTree it is part of (or something else using the same {@link @fluidframework/id-compressor#IIdCompressor}), then this will return a process-unique integer corresponding to that identifier.\n\t * This is useful for performance-sensitive scenarios involving many nodes with identifiers that need to be compactly retained in memory or used for efficient lookup.\n\t * Note that automatically generated identifiers that were accessed before the node was hydrated will return the generated UUID, not the process-unique integer.\n\t *\n\t * If the node's identifier is any other user-provided string, then this will return that string.\n\t *\n\t * If the node has no identifier (that is, it has no {@link SchemaFactory.identifier | identifier} field), then this returns `undefined`.\n\t *\n\t * If the node has more than one identifier, then this will throw an error.\n\t *\n\t * The returned integer should not be serialized or preserved outside of the current process.\n\t * Its lifetime is that of the current in-memory instance of the FF container for this client, and it is not guaranteed to be unique or stable outside of that context.\n\t * The same node's identifier may, for example, be different across multiple sessions for the same client and document, or different across two clients in the same session.\n\t */\n\tshortId(node: TreeNode): number | string | undefined;\n}\n\n/**\n * {@inheritDoc TreeNodeApi}\n */\nexport const treeNodeApi: TreeNodeApi = {\n\tparent(node: TreeNode): TreeNode | undefined {\n\t\tconst editNode = getInnerNode(node).parentField.parent.parent;\n\t\tif (editNode === undefined) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst output = getOrCreateNodeFromInnerNode(editNode);\n\t\tassert(\n\t\t\t!isTreeValue(output),\n\t\t\t0x87f /* Parent can't be a leaf, so it should be a node not a value */,\n\t\t);\n\t\treturn output;\n\t},\n\tkey(node: TreeNode): string | number {\n\t\t// If the parent is undefined, then this node is under the root field,\n\t\t// so we know its key is the special root one.\n\t\tconst parent = treeNodeApi.parent(node);\n\t\tif (parent === undefined) {\n\t\t\treturn rootFieldKey;\n\t\t}\n\n\t\t// The flex-domain strictly operates in terms of \"stored keys\".\n\t\t// To find the associated developer-facing \"property key\", we need to look up the field associated with\n\t\t// the stored key from the flex-domain, and get property key its simple-domain counterpart was created with.\n\t\tconst storedKey = getStoredKey(node);\n\t\tconst parentSchema = treeNodeApi.schema(parent);\n\t\tconst propertyKey = getPropertyKeyFromStoredKey(parentSchema, storedKey);\n\t\treturn propertyKey;\n\t},\n\ton<K extends keyof TreeChangeEvents>(\n\t\tnode: TreeNode,\n\t\teventName: K,\n\t\tlistener: TreeChangeEvents[K],\n\t): Off {\n\t\tconst kernel = getKernel(node);\n\t\tswitch (eventName) {\n\t\t\tcase \"nodeChanged\": {\n\t\t\t\tconst nodeSchema = kernel.schema;\n\t\t\t\tif (isObjectNodeSchema(nodeSchema)) {\n\t\t\t\t\treturn kernel.events.on(\"childrenChangedAfterBatch\", ({ changedFields }) => {\n\t\t\t\t\t\tconst changedProperties = new Set(\n\t\t\t\t\t\t\tArray.from(\n\t\t\t\t\t\t\t\tchangedFields,\n\t\t\t\t\t\t\t\t(field) =>\n\t\t\t\t\t\t\t\t\tnodeSchema.storedKeyToPropertyKey.get(field) ??\n\t\t\t\t\t\t\t\t\tfail(0xb36 /* Could not find stored key in schema. */),\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t);\n\t\t\t\t\t\tlistener({ changedProperties });\n\t\t\t\t\t});\n\t\t\t\t} else if (isArrayNodeSchema(nodeSchema)) {\n\t\t\t\t\treturn kernel.events.on(\"childrenChangedAfterBatch\", ({ fieldMarks }) => {\n\t\t\t\t\t\tconst marks = fieldMarks.get(EmptyKey);\n\t\t\t\t\t\t// nodeChanged fires only for shallow changes (insert, remove, move).\n\t\t\t\t\t\t// Deep changes (e.g. a property of an element changed) are\n\t\t\t\t\t\t// surfaced via TreeChangeEventsAlpha.treeChanged with a delta payload instead.\n\t\t\t\t\t\t// When marks are undefined (marks could not be composed across multiple\n\t\t\t\t\t\t// internal passes), we conservatively fire nodeChanged rather than silently\n\t\t\t\t\t\t// dropping the event, even though the underlying change may have been\n\t\t\t\t\t\t// purely deep. This is a known limitation of the current eventing stack.\n\t\t\t\t\t\tconst hasShallowChange =\n\t\t\t\t\t\t\tmarks === undefined ||\n\t\t\t\t\t\t\tmarks.some((m) => m.attach !== undefined || m.detach !== undefined);\n\t\t\t\t\t\tif (!hasShallowChange) {\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\t// `marks` is undefined when the field was modified across multiple batches\n\t\t\t\t\t\t// within a single flush (e.g. due to an interleaved schema change) and the\n\t\t\t\t\t\t// marks could not be composed. Emit `undefined` so callers know the delta is\n\t\t\t\t\t\t// unavailable rather than receiving stale marks from only the first batch.\n\t\t\t\t\t\t// TODO: Once the eventing stack is rewritten to walk the composed delta at\n\t\t\t\t\t\t// flush time, `marks` will always be defined. Remove the `undefined` fallback.\n\t\t\t\t\t\tconst delta = marks === undefined ? undefined : deltaMarksToArrayOps(marks);\n\t\t\t\t\t\tlistener({ delta });\n\t\t\t\t\t});\n\t\t\t\t} else {\n\t\t\t\t\treturn kernel.events.on(\"childrenChangedAfterBatch\", ({ changedFields }) => {\n\t\t\t\t\t\tlistener({ changedProperties: changedFields });\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t\tcase \"treeChanged\": {\n\t\t\t\tif (isArrayNodeSchema(kernel.schema)) {\n\t\t\t\t\t// For array nodes, treeChanged fires via childrenChangedAfterBatch so that a\n\t\t\t\t\t// delta payload can be provided. This covers both shallow changes\n\t\t\t\t\t// (insert/remove/move) and deep element changes. Stable (non-alpha) listeners\n\t\t\t\t\t// typed as () => void will silently ignore the extra argument at runtime.\n\t\t\t\t\treturn kernel.events.on(\"childrenChangedAfterBatch\", ({ fieldMarks }) => {\n\t\t\t\t\t\tconst marks = fieldMarks.get(EmptyKey);\n\t\t\t\t\t\tconst delta =\n\t\t\t\t\t\t\tmarks === undefined ? undefined : deltaMarksToArrayOpsForTreeChanged(marks);\n\t\t\t\t\t\t(listener as (data: { readonly delta: typeof delta }) => void)({ delta });\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\treturn kernel.events.on(\"subtreeChangedAfterBatch\", () => listener({}));\n\t\t\t}\n\t\t\tdefault: {\n\t\t\t\tthrow new UsageError(`No event named ${JSON.stringify(eventName)}.`);\n\t\t\t}\n\t\t}\n\t},\n\tstatus(node: TreeNode): TreeStatus {\n\t\treturn getKernel(node).getStatus();\n\t},\n\tis<TSchema extends ImplicitAllowedTypes>(\n\t\tvalue: unknown,\n\t\tschema: TSchema,\n\t): value is TreeNodeFromImplicitAllowedTypes<TSchema> {\n\t\t// This \"is\" utility would return false if the provided schema is a base type of the actual schema.\n\t\t// This could be confusing, and that case can only be hit when violating the rule that there is a single most derived schema that gets used (See documentation on TreeNodeSchemaClass).\n\t\t// Therefore this uses markSchemaMostDerived to ensure an informative usage error is thrown in the case where a base type is used.\n\n\t\tconst actualSchema = tryGetSchema(value);\n\t\tif (actualSchema === undefined) {\n\t\t\treturn false;\n\t\t}\n\t\treturn normalizeAllowedTypes(schema).evaluateSet().has(actualSchema);\n\t},\n\tschema(node: TreeNode | TreeLeafValue): TreeNodeSchema {\n\t\treturn tryGetSchema(node) ?? fail(0xb37 /* Not a tree node */);\n\t},\n\tshortId(node: TreeNode): number | string | undefined {\n\t\treturn getIdentifierFromNode(node, \"preferCompressed\");\n\t},\n};\n\n/**\n * Converts an array of internal {@link DeltaMark}s for a sequence field into sequential\n * array delta ops suitable for inclusion in {@link NodeChangedDataDelta.delta}.\n *\n * Each mark in the delta describes a contiguous run of positions in the original array:\n * - A mark with only `count` (no attach/detach) → `\"retain\"` with no subtree information\n * - A mark with only `attach` → `\"insert\"` (new elements added)\n * - A mark with only `detach` → `\"remove\"` (elements removed)\n * - A mark with both `attach` and `detach` → `\"remove\"` + `\"insert\"`\n *\n * @param marks - The low-level delta marks for the array's sequence field.\n *\n * @privateRemarks\n * The case where both `attach` and `detach` are set is unreachable today: the sequence-field\n * encoder never emits such marks for array (EmptyKey) fields. It is handled defensively.\n */\nexport function deltaMarksToArrayOps(marks: readonly DeltaMark[]): ArrayNodeDeltaOp[] {\n\tconst ops: ArrayNodeDeltaOp[] = [];\n\tfor (const mark of marks) {\n\t\tif (mark.detach !== undefined) {\n\t\t\tops.push({ type: \"remove\", count: mark.count });\n\t\t}\n\t\tif (mark.attach !== undefined) {\n\t\t\tops.push({ type: \"insert\", count: mark.count });\n\t\t} else if (mark.detach === undefined) {\n\t\t\t// Retain: elements were not added or removed.\n\t\t\tops.push({ type: \"retain\", count: mark.count });\n\t\t}\n\t}\n\treturn ops;\n}\n\n/**\n * Converts an array of internal {@link DeltaMark}s for a sequence field into sequential\n * {@link ArrayNodeTreeChangedDeltaOp}s suitable for inclusion in\n * {@link NodeChangedDataTreeDelta.delta} (delivered to {@link TreeChangeEventsAlpha.treeChanged}).\n *\n * Same conversion rules as {@link deltaMarksToArrayOps}, but retain ops additionally carry a\n * {@link ArrayNodeTreeChangedRetainOp.subtreeChanged} flag derived from whether the mark has\n * a `fields` property (indicating a descendant changed).\n *\n * @param marks - The low-level delta marks for the array's sequence field.\n *\n * @privateRemarks\n * The case where both `attach` and `detach` are set is unreachable today: the sequence-field\n * encoder never emits such marks for array (EmptyKey) fields. It is handled defensively.\n */\nexport function deltaMarksToArrayOpsForTreeChanged(\n\tmarks: readonly DeltaMark[],\n): ArrayNodeTreeChangedDeltaOp[] {\n\tconst ops: ArrayNodeTreeChangedDeltaOp[] = [];\n\tfor (const mark of marks) {\n\t\tif (mark.detach !== undefined) {\n\t\t\tops.push({ type: \"remove\", count: mark.count });\n\t\t}\n\t\tif (mark.attach !== undefined) {\n\t\t\tops.push({ type: \"insert\", count: mark.count });\n\t\t} else if (mark.detach === undefined) {\n\t\t\t// Retain: elements were not added or removed (but may have deep changes).\n\t\t\t// When `fields` is set, `count` is guaranteed to be 1 (DeltaMark invariant).\n\t\t\tops.push({\n\t\t\t\ttype: \"retain\",\n\t\t\t\tcount: mark.count,\n\t\t\t\tsubtreeChanged: mark.fields !== undefined,\n\t\t\t});\n\t\t}\n\t}\n\treturn ops;\n}\n\n/**\n * Returns a schema for a value if the value is a {@link TreeNode} or a {@link TreeLeafValue}.\n * Returns undefined for other values.\n */\nexport function tryGetSchema(value: unknown): undefined | TreeNodeSchema {\n\tswitch (typeof value) {\n\t\tcase \"string\": {\n\t\t\treturn stringSchema;\n\t\t}\n\t\tcase \"number\": {\n\t\t\treturn numberSchema;\n\t\t}\n\t\tcase \"boolean\": {\n\t\t\treturn booleanSchema;\n\t\t}\n\t\tcase \"object\": {\n\t\t\tif (isTreeNode(value)) {\n\t\t\t\t// TODO: This case could be optimized, for example by placing the simple schema in a symbol on tree nodes.\n\t\t\t\treturn tryGetTreeNodeSchema(value);\n\t\t\t}\n\t\t\tif (value === null) {\n\t\t\t\treturn nullSchema;\n\t\t\t}\n\t\t\tif (isFluidHandle(value)) {\n\t\t\t\treturn handleSchema;\n\t\t\t}\n\t\t}\n\t\tdefault: {\n\t\t\treturn undefined;\n\t\t}\n\t}\n}\n\n/**\n * Gets the identifier from a node.\n *\n * @param node - {@link TreeNode} where you want to extract the identifier from.\n * @param compression - string value to determine what type of identifier you want to retrieve.\n *\n * @remarks\n * If the node does not contain an identifier field, it returns undefined.\n *\n * If `compression` is set to `compressed`:\n *\n * - If the node contains a compressible identifier known by the id compressor, the compressed identifier is returned.\n *\n * - If the node contains an identifier, but is not compressible or unknown by the id compressor, `undefined` is returned.\n *\n * If `compression` is set to `preferCompressed`:\n *\n * - If the node contains a compressible identifier known by the id compressor, the compressed identifier is returned.\n *\n * - If the node contains an identifier, but is not compressible or unknown by the id compressor, the uncompressed identifier is returned.\n *\n * If `compression` is set to `uncompressed`:\n * - If the node contains an identifier field, the uncompressed identifier is returned.\n */\nexport function getIdentifierFromNode(\n\tnode: TreeNode,\n\tcompression: \"preferCompressed\",\n): number | string | undefined;\nexport function getIdentifierFromNode(\n\tnode: TreeNode,\n\tcompression: \"compressed\",\n): number | undefined;\nexport function getIdentifierFromNode(\n\tnode: TreeNode,\n\tcompression: \"uncompressed\",\n): string | undefined;\nexport function getIdentifierFromNode(\n\tnode: TreeNode,\n\tcompression: \"preferCompressed\" | \"compressed\" | \"uncompressed\",\n): number | string | undefined {\n\tconst schema = node[typeSchemaSymbol];\n\tif (!isObjectNodeSchema(schema)) {\n\t\treturn undefined;\n\t}\n\n\tconst flexNode = getInnerNode(node);\n\tconst identifierFieldKeys = schema.identifierFieldKeys;\n\n\tswitch (identifierFieldKeys.length) {\n\t\tcase 0: {\n\t\t\treturn undefined;\n\t\t}\n\t\tcase 1: {\n\t\t\tconst key = identifierFieldKeys[0] ?? oob();\n\t\t\tconst identifierField = flexNode.tryGetField(key);\n\t\t\tassert(identifierField !== undefined, 0xbb5 /* missing identifier field */);\n\t\t\tconst identifierValue = tryGetTreeNodeForField(identifierField);\n\t\t\tassert(typeof identifierValue === \"string\", 0xbb6 /* identifier not a string */);\n\n\t\t\tconst context = flexNode.context;\n\t\t\tswitch (compression) {\n\t\t\t\tcase \"preferCompressed\": {\n\t\t\t\t\tif (context.isHydrated()) {\n\t\t\t\t\t\tconst localNodeKey =\n\t\t\t\t\t\t\tcontext.nodeKeyManager.tryLocalizeNodeIdentifier(identifierValue);\n\t\t\t\t\t\treturn localNodeKey === undefined\n\t\t\t\t\t\t\t? identifierValue\n\t\t\t\t\t\t\t: extractFromOpaque(localNodeKey);\n\t\t\t\t\t} else {\n\t\t\t\t\t\treturn identifierValue;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tcase \"compressed\": {\n\t\t\t\t\tif (context.isHydrated()) {\n\t\t\t\t\t\tconst localNodeKey =\n\t\t\t\t\t\t\tcontext.nodeKeyManager.tryLocalizeNodeIdentifier(identifierValue);\n\t\t\t\t\t\treturn localNodeKey === undefined ? undefined : extractFromOpaque(localNodeKey);\n\t\t\t\t\t} else {\n\t\t\t\t\t\treturn undefined;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tcase \"uncompressed\": {\n\t\t\t\t\treturn identifierValue;\n\t\t\t\t}\n\t\t\t\tdefault: {\n\t\t\t\t\tunreachableCase(compression);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tdefault: {\n\t\t\tthrow new UsageError(\n\t\t\t\t\"The node has more than one identifier. Retrieve identifiers individually via their fields instead.\",\n\t\t\t);\n\t\t}\n\t}\n}\n\n/**\n * Gets the stored key with which the provided node is associated in the parent.\n */\nexport function getStoredKey(node: TreeNode): string | number {\n\t// Note: the flex domain strictly works with \"stored keys\", and knows nothing about the developer-facing\n\t// \"property keys\".\n\tconst parentField = getInnerNode(node).parentField;\n\tif (parentField.parent.schema === FieldKinds.sequence.identifier) {\n\t\t// The parent of `node` is an array node\n\t\tassert(\n\t\t\tparentField.parent.key === EmptyKey,\n\t\t\t0xa28 /* When using index as key, field should use EmptyKey */,\n\t\t);\n\t\treturn parentField.index;\n\t}\n\n\t// The parent of `node` is an object, a map, or undefined. If undefined, then `node` is a root/detached node.\n\tassert(parentField.index === 0, 0xa29 /* When using field key as key, index should be 0 */);\n\treturn parentField.parent.key;\n}\n\n/**\n * Given a node schema, gets the property key corresponding with the provided {@link FieldProps.key | stored key}.\n */\nexport function getPropertyKeyFromStoredKey(\n\tschema: TreeNodeSchema,\n\tstoredKey: string | number,\n): string | number {\n\t// Only object nodes have the concept of a \"stored key\", differentiated from the developer-facing \"property key\".\n\t// For any other kind of node, the stored key and the property key are the same.\n\tif (schema.kind !== NodeKind.Object) {\n\t\treturn storedKey;\n\t}\n\n\tconst fields = schema.info as Record<string, ImplicitFieldSchema>;\n\n\t// Invariants:\n\t// - The set of all property keys under an object must be unique.\n\t// - The set of all stored keys (including those implicitly created from property keys) must be unique.\n\t// To find the property key associated with the provided stored key, first check for any stored key matches (which are optionally populated).\n\t// If we don't find any, then search for a matching property key.\n\tfor (const [propertyKey, fieldSchema] of Object.entries(fields)) {\n\t\tif (fieldSchema instanceof FieldSchema && fieldSchema.props?.key === storedKey) {\n\t\t\treturn propertyKey;\n\t\t}\n\t}\n\n\tif (fields[storedKey] === undefined) {\n\t\tfail(0xb38 /* Existing stored key should always map to a property key */);\n\t}\n\n\treturn storedKey;\n}\n"]}
@@ -13,6 +13,13 @@ export interface StoredFromViewSchemaGenerationOptions {
13
13
  * Due to caching, the behavior of this function must be pure.
14
14
  */
15
15
  includeStaged(upgrade: SchemaUpgrade): boolean;
16
+ /**
17
+ * Determines whether to treat a {@link SchemaFactoryAlpha.stagedOptional | staged optional} field as optional
18
+ * (rather than required) in the resulting stored schema.
19
+ * @remarks
20
+ * Due to caching, the behavior of this function must be pure.
21
+ */
22
+ includeStagedOptional(upgrade: SchemaUpgrade): boolean;
16
23
  }
17
24
  /**
18
25
  * Marker type indicating that the input schema is already a stored schema.
@@ -1 +1 @@
1
- {"version":3,"file":"toStored.d.ts","sourceRoot":"","sources":["../../../src/simple-tree/core/toStored.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAEvD;;GAEG;AACH,MAAM,WAAW,qCAAqC;IACrD;;;;OAIG;IACH,aAAa,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC;CAC/C;AAED;;GAEG;AACH,eAAO,MAAM,YAAY,eAAyB,CAAC;AACnD,MAAM,MAAM,YAAY,GAAG,OAAO,YAAY,CAAC;AAE/C;;;;GAIG;AACH,eAAO,MAAM,SAAS,eAAsB,CAAC;AAC7C,MAAM,MAAM,SAAS,GAAG,OAAO,SAAS,CAAC;AAEzC;;GAEG;AACH,MAAM,MAAM,6BAA6B,GACtC,qCAAqC,GACrC,YAAY,CAAC;AAEhB;;;;;;GAMG;AACH,MAAM,MAAM,iCAAiC,GAC1C,qCAAqC,GACrC,YAAY,GACZ,SAAS,CAAC"}
1
+ {"version":3,"file":"toStored.d.ts","sourceRoot":"","sources":["../../../src/simple-tree/core/toStored.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAEvD;;GAEG;AACH,MAAM,WAAW,qCAAqC;IACrD;;;;OAIG;IACH,aAAa,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC;IAE/C;;;;;OAKG;IACH,qBAAqB,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC;CACvD;AAED;;GAEG;AACH,eAAO,MAAM,YAAY,eAAyB,CAAC;AACnD,MAAM,MAAM,YAAY,GAAG,OAAO,YAAY,CAAC;AAE/C;;;;GAIG;AACH,eAAO,MAAM,SAAS,eAAsB,CAAC;AAC7C,MAAM,MAAM,SAAS,GAAG,OAAO,SAAS,CAAC;AAEzC;;GAEG;AACH,MAAM,MAAM,6BAA6B,GACtC,qCAAqC,GACrC,YAAY,CAAC;AAEhB;;;;;;GAMG;AACH,MAAM,MAAM,iCAAiC,GAC1C,qCAAqC,GACrC,YAAY,GACZ,SAAS,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"toStored.js","sourceRoot":"","sources":["../../../src/simple-tree/core/toStored.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAgBH;;GAEG;AACU,QAAA,YAAY,GAAG,MAAM,CAAC,cAAc,CAAC,CAAC;AAGnD;;;;GAIG;AACU,QAAA,SAAS,GAAG,MAAM,CAAC,WAAW,CAAC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { SchemaUpgrade } from \"./allowedTypes.js\";\n\n/**\n * Options for transforming a view simple-schema to a stored simple-schema (See {@link TreeStoredSchema}).\n */\nexport interface StoredFromViewSchemaGenerationOptions {\n\t/**\n\t * Determines whether to include {@link SchemaStaticsBeta.staged | staged} allowed types in the resulting stored schema.\n\t * @remarks\n\t * Due to caching, the behavior of this function must be pure.\n\t */\n\tincludeStaged(upgrade: SchemaUpgrade): boolean;\n}\n\n/**\n * Marker type indicating that the input schema is already a stored schema.\n */\nexport const ExpectStored = Symbol(\"ExpectStored\");\nexport type ExpectStored = typeof ExpectStored;\n\n/**\n * Marker type indicating that the input schema should not be transformed: data accessible from the simple schema API surface should be copied as is.\n * @remarks\n * The only real use-cases for this are deep-copying simple schema, and copying objects that implement more than just simple schema (such as {@link TreeSchema}) into simple object without extra prototypes and properties.\n */\nexport const Unchanged = Symbol(\"Unchanged\");\nexport type Unchanged = typeof Unchanged;\n\n/**\n * Subset of {@link SimpleSchemaTransformationOptions} for when the output is a known to be a stored schema.\n */\nexport type StoredSchemaGenerationOptions =\n\t| StoredFromViewSchemaGenerationOptions\n\t| ExpectStored;\n\n/**\n * Options for transforming a schema.\n * @remarks\n * See also {@link generateSchemaFromSimpleSchema} for a different schema transformation.\n * Note that if we want to make `generateSchemaFromSimpleSchema` consume view simple-schema, and use these transformation APIs to generate that view simple-schema from a stored simple-schema,\n * we will need to add a \"ToView\" option here.\n */\nexport type SimpleSchemaTransformationOptions =\n\t| StoredFromViewSchemaGenerationOptions\n\t| ExpectStored\n\t| Unchanged;\n"]}
1
+ {"version":3,"file":"toStored.js","sourceRoot":"","sources":["../../../src/simple-tree/core/toStored.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAwBH;;GAEG;AACU,QAAA,YAAY,GAAG,MAAM,CAAC,cAAc,CAAC,CAAC;AAGnD;;;;GAIG;AACU,QAAA,SAAS,GAAG,MAAM,CAAC,WAAW,CAAC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { SchemaUpgrade } from \"./allowedTypes.js\";\n\n/**\n * Options for transforming a view simple-schema to a stored simple-schema (See {@link TreeStoredSchema}).\n */\nexport interface StoredFromViewSchemaGenerationOptions {\n\t/**\n\t * Determines whether to include {@link SchemaStaticsBeta.staged | staged} allowed types in the resulting stored schema.\n\t * @remarks\n\t * Due to caching, the behavior of this function must be pure.\n\t */\n\tincludeStaged(upgrade: SchemaUpgrade): boolean;\n\n\t/**\n\t * Determines whether to treat a {@link SchemaFactoryAlpha.stagedOptional | staged optional} field as optional\n\t * (rather than required) in the resulting stored schema.\n\t * @remarks\n\t * Due to caching, the behavior of this function must be pure.\n\t */\n\tincludeStagedOptional(upgrade: SchemaUpgrade): boolean;\n}\n\n/**\n * Marker type indicating that the input schema is already a stored schema.\n */\nexport const ExpectStored = Symbol(\"ExpectStored\");\nexport type ExpectStored = typeof ExpectStored;\n\n/**\n * Marker type indicating that the input schema should not be transformed: data accessible from the simple schema API surface should be copied as is.\n * @remarks\n * The only real use-cases for this are deep-copying simple schema, and copying objects that implement more than just simple schema (such as {@link TreeSchema}) into simple object without extra prototypes and properties.\n */\nexport const Unchanged = Symbol(\"Unchanged\");\nexport type Unchanged = typeof Unchanged;\n\n/**\n * Subset of {@link SimpleSchemaTransformationOptions} for when the output is a known to be a stored schema.\n */\nexport type StoredSchemaGenerationOptions =\n\t| StoredFromViewSchemaGenerationOptions\n\t| ExpectStored;\n\n/**\n * Options for transforming a schema.\n * @remarks\n * See also {@link generateSchemaFromSimpleSchema} for a different schema transformation.\n * Note that if we want to make `generateSchemaFromSimpleSchema` consume view simple-schema, and use these transformation APIs to generate that view simple-schema from a stored simple-schema,\n * we will need to add a \"ToView\" option here.\n */\nexport type SimpleSchemaTransformationOptions =\n\t| StoredFromViewSchemaGenerationOptions\n\t| ExpectStored\n\t| Unchanged;\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"treeNodeKernel.d.ts","sourceRoot":"","sources":["../../../src/simple-tree/core/treeNodeKernel.ts"],"names":[],"mappings":"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