@fluidframework/tree 2.30.0 → 2.31.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (660) hide show
  1. package/CHANGELOG.md +1632 -1500
  2. package/api-extractor/api-extractor.current.json +0 -3
  3. package/api-report/tree.alpha.api.md +233 -88
  4. package/api-report/tree.beta.api.md +86 -61
  5. package/api-report/tree.legacy.alpha.api.md +86 -61
  6. package/api-report/tree.legacy.public.api.md +86 -61
  7. package/api-report/tree.public.api.md +86 -61
  8. package/dist/alpha.d.ts +26 -1
  9. package/dist/beta.d.ts +5 -1
  10. package/dist/codec/codec.d.ts +1 -1
  11. package/dist/codec/codec.d.ts.map +1 -1
  12. package/dist/codec/codec.js +3 -4
  13. package/dist/codec/codec.js.map +1 -1
  14. package/dist/codec/discriminatedUnions.d.ts.map +1 -1
  15. package/dist/codec/discriminatedUnions.js +1 -1
  16. package/dist/codec/discriminatedUnions.js.map +1 -1
  17. package/dist/core/rebase/utils.js +1 -1
  18. package/dist/core/rebase/utils.js.map +1 -1
  19. package/dist/core/schema-stored/schema.d.ts +4 -1
  20. package/dist/core/schema-stored/schema.d.ts.map +1 -1
  21. package/dist/core/schema-stored/schema.js +8 -4
  22. package/dist/core/schema-stored/schema.js.map +1 -1
  23. package/dist/core/tree/anchorSet.d.ts.map +1 -1
  24. package/dist/core/tree/anchorSet.js +4 -4
  25. package/dist/core/tree/anchorSet.js.map +1 -1
  26. package/dist/core/tree/treeTextFormat.js +2 -2
  27. package/dist/core/tree/treeTextFormat.js.map +1 -1
  28. package/dist/feature-libraries/chunked-forest/basicChunk.d.ts.map +1 -1
  29. package/dist/feature-libraries/chunked-forest/basicChunk.js +8 -8
  30. package/dist/feature-libraries/chunked-forest/basicChunk.js.map +1 -1
  31. package/dist/feature-libraries/chunked-forest/chunkTree.js +2 -2
  32. package/dist/feature-libraries/chunked-forest/chunkTree.js.map +1 -1
  33. package/dist/feature-libraries/chunked-forest/chunkedForest.d.ts.map +1 -1
  34. package/dist/feature-libraries/chunked-forest/chunkedForest.js +3 -3
  35. package/dist/feature-libraries/chunked-forest/chunkedForest.js.map +1 -1
  36. package/dist/feature-libraries/chunked-forest/codec/chunkEncodingGeneric.js +3 -3
  37. package/dist/feature-libraries/chunked-forest/codec/chunkEncodingGeneric.js.map +1 -1
  38. package/dist/feature-libraries/chunked-forest/codec/compressedEncode.js +3 -3
  39. package/dist/feature-libraries/chunked-forest/codec/compressedEncode.js.map +1 -1
  40. package/dist/feature-libraries/chunked-forest/codec/nodeShape.js +2 -2
  41. package/dist/feature-libraries/chunked-forest/codec/nodeShape.js.map +1 -1
  42. package/dist/feature-libraries/chunked-forest/codec/schemaBasedEncode.d.ts.map +1 -1
  43. package/dist/feature-libraries/chunked-forest/codec/schemaBasedEncode.js +3 -4
  44. package/dist/feature-libraries/chunked-forest/codec/schemaBasedEncode.js.map +1 -1
  45. package/dist/feature-libraries/chunked-forest/emptyChunk.d.ts.map +1 -1
  46. package/dist/feature-libraries/chunked-forest/emptyChunk.js +15 -15
  47. package/dist/feature-libraries/chunked-forest/emptyChunk.js.map +1 -1
  48. package/dist/feature-libraries/chunked-forest/uniformChunk.d.ts.map +1 -1
  49. package/dist/feature-libraries/chunked-forest/uniformChunk.js +4 -4
  50. package/dist/feature-libraries/chunked-forest/uniformChunk.js.map +1 -1
  51. package/dist/feature-libraries/default-schema/defaultFieldKinds.d.ts.map +1 -1
  52. package/dist/feature-libraries/default-schema/defaultFieldKinds.js +19 -19
  53. package/dist/feature-libraries/default-schema/defaultFieldKinds.js.map +1 -1
  54. package/dist/feature-libraries/default-schema/schemaChecker.d.ts.map +1 -1
  55. package/dist/feature-libraries/default-schema/schemaChecker.js +1 -2
  56. package/dist/feature-libraries/default-schema/schemaChecker.js.map +1 -1
  57. package/dist/feature-libraries/flex-tree/lazyField.js +3 -3
  58. package/dist/feature-libraries/flex-tree/lazyField.js.map +1 -1
  59. package/dist/feature-libraries/flex-tree/lazyNode.js +4 -4
  60. package/dist/feature-libraries/flex-tree/lazyNode.js.map +1 -1
  61. package/dist/feature-libraries/indexing/anchorTreeIndex.d.ts.map +1 -1
  62. package/dist/feature-libraries/indexing/anchorTreeIndex.js +1 -1
  63. package/dist/feature-libraries/indexing/anchorTreeIndex.js.map +1 -1
  64. package/dist/feature-libraries/modular-schema/comparison.js +4 -4
  65. package/dist/feature-libraries/modular-schema/comparison.js.map +1 -1
  66. package/dist/feature-libraries/modular-schema/isNeverTree.d.ts.map +1 -1
  67. package/dist/feature-libraries/modular-schema/isNeverTree.js +2 -3
  68. package/dist/feature-libraries/modular-schema/isNeverTree.js.map +1 -1
  69. package/dist/feature-libraries/modular-schema/modularChangeCodecs.d.ts.map +1 -1
  70. package/dist/feature-libraries/modular-schema/modularChangeCodecs.js +4 -4
  71. package/dist/feature-libraries/modular-schema/modularChangeCodecs.js.map +1 -1
  72. package/dist/feature-libraries/modular-schema/modularChangeFamily.d.ts.map +1 -1
  73. package/dist/feature-libraries/modular-schema/modularChangeFamily.js +4 -4
  74. package/dist/feature-libraries/modular-schema/modularChangeFamily.js.map +1 -1
  75. package/dist/feature-libraries/node-identifier/mockNodeIdentifierManager.js +1 -1
  76. package/dist/feature-libraries/node-identifier/mockNodeIdentifierManager.js.map +1 -1
  77. package/dist/feature-libraries/object-forest/objectForest.d.ts.map +1 -1
  78. package/dist/feature-libraries/object-forest/objectForest.js +1 -1
  79. package/dist/feature-libraries/object-forest/objectForest.js.map +1 -1
  80. package/dist/feature-libraries/schema-index/codec.d.ts.map +1 -1
  81. package/dist/feature-libraries/schema-index/codec.js +2 -1
  82. package/dist/feature-libraries/schema-index/codec.js.map +1 -1
  83. package/dist/feature-libraries/sequence-field/compose.d.ts +1 -1
  84. package/dist/feature-libraries/sequence-field/compose.d.ts.map +1 -1
  85. package/dist/feature-libraries/sequence-field/compose.js +16 -17
  86. package/dist/feature-libraries/sequence-field/compose.js.map +1 -1
  87. package/dist/feature-libraries/sequence-field/invert.d.ts.map +1 -1
  88. package/dist/feature-libraries/sequence-field/invert.js +1 -1
  89. package/dist/feature-libraries/sequence-field/invert.js.map +1 -1
  90. package/dist/feature-libraries/sequence-field/sequenceFieldCodecV1.d.ts.map +1 -1
  91. package/dist/feature-libraries/sequence-field/sequenceFieldCodecV1.js +1 -1
  92. package/dist/feature-libraries/sequence-field/sequenceFieldCodecV1.js.map +1 -1
  93. package/dist/feature-libraries/sequence-field/sequenceFieldCodecV2.d.ts.map +1 -1
  94. package/dist/feature-libraries/sequence-field/sequenceFieldCodecV2.js +1 -1
  95. package/dist/feature-libraries/sequence-field/sequenceFieldCodecV2.js.map +1 -1
  96. package/dist/feature-libraries/sequence-field/utils.js +1 -1
  97. package/dist/feature-libraries/sequence-field/utils.js.map +1 -1
  98. package/dist/feature-libraries/treeCursorUtils.d.ts.map +1 -1
  99. package/dist/feature-libraries/treeCursorUtils.js +4 -5
  100. package/dist/feature-libraries/treeCursorUtils.js.map +1 -1
  101. package/dist/index.d.ts +4 -3
  102. package/dist/index.d.ts.map +1 -1
  103. package/dist/index.js +8 -4
  104. package/dist/index.js.map +1 -1
  105. package/dist/jsonDomainSchema.d.ts +15 -16
  106. package/dist/jsonDomainSchema.d.ts.map +1 -1
  107. package/dist/jsonDomainSchema.js +10 -5
  108. package/dist/jsonDomainSchema.js.map +1 -1
  109. package/dist/legacy.d.ts +5 -1
  110. package/dist/packageVersion.d.ts +1 -1
  111. package/dist/packageVersion.js +1 -1
  112. package/dist/packageVersion.js.map +1 -1
  113. package/dist/public.d.ts +5 -1
  114. package/dist/serializableDomainSchema.d.ts +8 -14
  115. package/dist/serializableDomainSchema.d.ts.map +1 -1
  116. package/dist/shared-tree/schematizeTree.js +1 -1
  117. package/dist/shared-tree/schematizeTree.js.map +1 -1
  118. package/dist/shared-tree/sharedTree.d.ts.map +1 -1
  119. package/dist/shared-tree/sharedTree.js +16 -12
  120. package/dist/shared-tree/sharedTree.js.map +1 -1
  121. package/dist/shared-tree/sharedTreeChangeFamily.d.ts.map +1 -1
  122. package/dist/shared-tree/sharedTreeChangeFamily.js +1 -1
  123. package/dist/shared-tree/sharedTreeChangeFamily.js.map +1 -1
  124. package/dist/shared-tree/treeApiAlpha.d.ts +6 -2
  125. package/dist/shared-tree/treeApiAlpha.d.ts.map +1 -1
  126. package/dist/shared-tree/treeApiAlpha.js +20 -17
  127. package/dist/shared-tree/treeApiAlpha.js.map +1 -1
  128. package/dist/shared-tree/treeCheckout.d.ts.map +1 -1
  129. package/dist/shared-tree/treeCheckout.js +1 -1
  130. package/dist/shared-tree/treeCheckout.js.map +1 -1
  131. package/dist/shared-tree-core/branch.d.ts +4 -3
  132. package/dist/shared-tree-core/branch.d.ts.map +1 -1
  133. package/dist/shared-tree-core/branch.js +2 -2
  134. package/dist/shared-tree-core/branch.js.map +1 -1
  135. package/dist/shared-tree-core/editManager.d.ts.map +1 -1
  136. package/dist/shared-tree-core/editManager.js +37 -31
  137. package/dist/shared-tree-core/editManager.js.map +1 -1
  138. package/dist/sharedTreeAttributes.d.ts +18 -0
  139. package/dist/sharedTreeAttributes.d.ts.map +1 -0
  140. package/dist/sharedTreeAttributes.js +25 -0
  141. package/dist/sharedTreeAttributes.js.map +1 -0
  142. package/dist/simple-tree/api/customTree.js +3 -3
  143. package/dist/simple-tree/api/customTree.js.map +1 -1
  144. package/dist/simple-tree/api/getJsonSchema.d.ts +10 -0
  145. package/dist/simple-tree/api/getJsonSchema.d.ts.map +1 -1
  146. package/dist/simple-tree/api/getJsonSchema.js +10 -0
  147. package/dist/simple-tree/api/getJsonSchema.js.map +1 -1
  148. package/dist/simple-tree/api/getSimpleSchema.d.ts +13 -43
  149. package/dist/simple-tree/api/getSimpleSchema.d.ts.map +1 -1
  150. package/dist/simple-tree/api/getSimpleSchema.js +13 -43
  151. package/dist/simple-tree/api/getSimpleSchema.js.map +1 -1
  152. package/dist/simple-tree/api/index.d.ts +3 -3
  153. package/dist/simple-tree/api/index.d.ts.map +1 -1
  154. package/dist/simple-tree/api/index.js +3 -1
  155. package/dist/simple-tree/api/index.js.map +1 -1
  156. package/dist/simple-tree/api/schemaCreationUtilities.d.ts.map +1 -1
  157. package/dist/simple-tree/api/schemaCreationUtilities.js +2 -2
  158. package/dist/simple-tree/api/schemaCreationUtilities.js.map +1 -1
  159. package/dist/simple-tree/api/schemaFactory.d.ts +100 -58
  160. package/dist/simple-tree/api/schemaFactory.d.ts.map +1 -1
  161. package/dist/simple-tree/api/schemaFactory.js +65 -133
  162. package/dist/simple-tree/api/schemaFactory.js.map +1 -1
  163. package/dist/simple-tree/api/schemaFactoryAlpha.d.ts +31 -23
  164. package/dist/simple-tree/api/schemaFactoryAlpha.d.ts.map +1 -1
  165. package/dist/simple-tree/api/schemaFactoryAlpha.js +17 -1
  166. package/dist/simple-tree/api/schemaFactoryAlpha.js.map +1 -1
  167. package/dist/simple-tree/api/schemaFactoryRecursive.d.ts +40 -5
  168. package/dist/simple-tree/api/schemaFactoryRecursive.d.ts.map +1 -1
  169. package/dist/simple-tree/api/schemaFactoryRecursive.js.map +1 -1
  170. package/dist/simple-tree/api/schemaFromSimple.d.ts +4 -4
  171. package/dist/simple-tree/api/schemaFromSimple.d.ts.map +1 -1
  172. package/dist/simple-tree/api/schemaFromSimple.js +26 -15
  173. package/dist/simple-tree/api/schemaFromSimple.js.map +1 -1
  174. package/dist/simple-tree/api/simpleSchemaToJsonSchema.d.ts +3 -2
  175. package/dist/simple-tree/api/simpleSchemaToJsonSchema.d.ts.map +1 -1
  176. package/dist/simple-tree/api/simpleSchemaToJsonSchema.js +7 -6
  177. package/dist/simple-tree/api/simpleSchemaToJsonSchema.js.map +1 -1
  178. package/dist/simple-tree/api/simpleTreeIndex.d.ts.map +1 -1
  179. package/dist/simple-tree/api/simpleTreeIndex.js +4 -3
  180. package/dist/simple-tree/api/simpleTreeIndex.js.map +1 -1
  181. package/dist/simple-tree/api/testRecursiveDomain.d.ts +10 -10
  182. package/dist/simple-tree/api/tree.d.ts +1 -1
  183. package/dist/simple-tree/api/tree.d.ts.map +1 -1
  184. package/dist/simple-tree/api/tree.js +6 -6
  185. package/dist/simple-tree/api/tree.js.map +1 -1
  186. package/dist/simple-tree/api/treeNodeApi.js +3 -3
  187. package/dist/simple-tree/api/treeNodeApi.js.map +1 -1
  188. package/dist/simple-tree/api/typesUnsafe.d.ts +87 -21
  189. package/dist/simple-tree/api/typesUnsafe.d.ts.map +1 -1
  190. package/dist/simple-tree/api/typesUnsafe.js +0 -1
  191. package/dist/simple-tree/api/typesUnsafe.js.map +1 -1
  192. package/dist/simple-tree/api/verboseTree.js +4 -4
  193. package/dist/simple-tree/api/verboseTree.js.map +1 -1
  194. package/dist/simple-tree/api/view.d.ts.map +1 -1
  195. package/dist/simple-tree/api/view.js +16 -17
  196. package/dist/simple-tree/api/view.js.map +1 -1
  197. package/dist/simple-tree/api/viewSchemaToSimpleSchema.d.ts +16 -3
  198. package/dist/simple-tree/api/viewSchemaToSimpleSchema.d.ts.map +1 -1
  199. package/dist/simple-tree/api/viewSchemaToSimpleSchema.js +70 -147
  200. package/dist/simple-tree/api/viewSchemaToSimpleSchema.js.map +1 -1
  201. package/dist/simple-tree/arrayNode.d.ts +5 -4
  202. package/dist/simple-tree/arrayNode.d.ts.map +1 -1
  203. package/dist/simple-tree/arrayNode.js +13 -9
  204. package/dist/simple-tree/arrayNode.js.map +1 -1
  205. package/dist/simple-tree/arrayNodeTypes.d.ts +46 -0
  206. package/dist/simple-tree/arrayNodeTypes.d.ts.map +1 -0
  207. package/dist/simple-tree/arrayNodeTypes.js +30 -0
  208. package/dist/simple-tree/arrayNodeTypes.js.map +1 -0
  209. package/dist/simple-tree/core/getOrCreateNode.d.ts.map +1 -1
  210. package/dist/simple-tree/core/getOrCreateNode.js +1 -11
  211. package/dist/simple-tree/core/getOrCreateNode.js.map +1 -1
  212. package/dist/simple-tree/core/index.d.ts +1 -2
  213. package/dist/simple-tree/core/index.d.ts.map +1 -1
  214. package/dist/simple-tree/core/index.js +2 -3
  215. package/dist/simple-tree/core/index.js.map +1 -1
  216. package/dist/simple-tree/core/treeNodeKernel.d.ts +12 -5
  217. package/dist/simple-tree/core/treeNodeKernel.d.ts.map +1 -1
  218. package/dist/simple-tree/core/treeNodeKernel.js +36 -20
  219. package/dist/simple-tree/core/treeNodeKernel.js.map +1 -1
  220. package/dist/simple-tree/core/treeNodeSchema.d.ts +14 -7
  221. package/dist/simple-tree/core/treeNodeSchema.d.ts.map +1 -1
  222. package/dist/simple-tree/core/treeNodeSchema.js.map +1 -1
  223. package/dist/simple-tree/core/unhydratedFlexTree.js +5 -5
  224. package/dist/simple-tree/core/unhydratedFlexTree.js.map +1 -1
  225. package/dist/simple-tree/index.d.ts +9 -2
  226. package/dist/simple-tree/index.d.ts.map +1 -1
  227. package/dist/simple-tree/index.js +9 -1
  228. package/dist/simple-tree/index.js.map +1 -1
  229. package/dist/simple-tree/leafNodeSchema.d.ts +22 -5
  230. package/dist/simple-tree/leafNodeSchema.d.ts.map +1 -1
  231. package/dist/simple-tree/leafNodeSchema.js +2 -0
  232. package/dist/simple-tree/leafNodeSchema.js.map +1 -1
  233. package/dist/simple-tree/mapNode.d.ts +3 -2
  234. package/dist/simple-tree/mapNode.d.ts.map +1 -1
  235. package/dist/simple-tree/mapNode.js +5 -1
  236. package/dist/simple-tree/mapNode.js.map +1 -1
  237. package/dist/simple-tree/mapNodeTypes.d.ts +46 -0
  238. package/dist/simple-tree/mapNodeTypes.d.ts.map +1 -0
  239. package/dist/simple-tree/mapNodeTypes.js +30 -0
  240. package/dist/simple-tree/mapNodeTypes.js.map +1 -0
  241. package/dist/simple-tree/objectNode.d.ts +10 -3
  242. package/dist/simple-tree/objectNode.d.ts.map +1 -1
  243. package/dist/simple-tree/objectNode.js +10 -5
  244. package/dist/simple-tree/objectNode.js.map +1 -1
  245. package/dist/simple-tree/objectNodeTypes.d.ts +9 -5
  246. package/dist/simple-tree/objectNodeTypes.d.ts.map +1 -1
  247. package/dist/simple-tree/objectNodeTypes.js +3 -0
  248. package/dist/simple-tree/objectNodeTypes.js.map +1 -1
  249. package/dist/simple-tree/proxies.js +2 -1
  250. package/dist/simple-tree/proxies.js.map +1 -1
  251. package/dist/simple-tree/schemaTypes.d.ts +47 -6
  252. package/dist/simple-tree/schemaTypes.d.ts.map +1 -1
  253. package/dist/simple-tree/schemaTypes.js +40 -4
  254. package/dist/simple-tree/schemaTypes.js.map +1 -1
  255. package/dist/simple-tree/{api/simpleSchema.d.ts → simpleSchema.d.ts} +54 -30
  256. package/dist/simple-tree/simpleSchema.d.ts.map +1 -0
  257. package/dist/simple-tree/simpleSchema.js.map +1 -0
  258. package/dist/simple-tree/toMapTree.js +3 -3
  259. package/dist/simple-tree/toMapTree.js.map +1 -1
  260. package/dist/simple-tree/toStoredSchema.js +1 -1
  261. package/dist/simple-tree/toStoredSchema.js.map +1 -1
  262. package/dist/simple-tree/treeNodeValid.d.ts.map +1 -1
  263. package/dist/simple-tree/treeNodeValid.js +4 -5
  264. package/dist/simple-tree/treeNodeValid.js.map +1 -1
  265. package/dist/treeFactory.d.ts +0 -12
  266. package/dist/treeFactory.d.ts.map +1 -1
  267. package/dist/treeFactory.js +5 -21
  268. package/dist/treeFactory.js.map +1 -1
  269. package/dist/util/idAllocator.d.ts.map +1 -1
  270. package/dist/util/idAllocator.js +1 -2
  271. package/dist/util/idAllocator.js.map +1 -1
  272. package/dist/util/index.d.ts +1 -1
  273. package/dist/util/index.d.ts.map +1 -1
  274. package/dist/util/index.js +2 -3
  275. package/dist/util/index.js.map +1 -1
  276. package/dist/util/typeCheck.d.ts +7 -0
  277. package/dist/util/typeCheck.d.ts.map +1 -1
  278. package/dist/util/typeCheck.js.map +1 -1
  279. package/dist/util/utils.d.ts +0 -1
  280. package/dist/util/utils.d.ts.map +1 -1
  281. package/dist/util/utils.js +1 -4
  282. package/dist/util/utils.js.map +1 -1
  283. package/lib/alpha.d.ts +26 -1
  284. package/lib/beta.d.ts +5 -1
  285. package/lib/codec/codec.d.ts +1 -1
  286. package/lib/codec/codec.d.ts.map +1 -1
  287. package/lib/codec/codec.js +1 -2
  288. package/lib/codec/codec.js.map +1 -1
  289. package/lib/codec/discriminatedUnions.d.ts.map +1 -1
  290. package/lib/codec/discriminatedUnions.js +2 -2
  291. package/lib/codec/discriminatedUnions.js.map +1 -1
  292. package/lib/core/rebase/utils.js +1 -1
  293. package/lib/core/rebase/utils.js.map +1 -1
  294. package/lib/core/schema-stored/schema.d.ts +4 -1
  295. package/lib/core/schema-stored/schema.d.ts.map +1 -1
  296. package/lib/core/schema-stored/schema.js +6 -2
  297. package/lib/core/schema-stored/schema.js.map +1 -1
  298. package/lib/core/tree/anchorSet.d.ts.map +1 -1
  299. package/lib/core/tree/anchorSet.js +2 -2
  300. package/lib/core/tree/anchorSet.js.map +1 -1
  301. package/lib/core/tree/treeTextFormat.js +1 -1
  302. package/lib/core/tree/treeTextFormat.js.map +1 -1
  303. package/lib/feature-libraries/chunked-forest/basicChunk.d.ts.map +1 -1
  304. package/lib/feature-libraries/chunked-forest/basicChunk.js +2 -2
  305. package/lib/feature-libraries/chunked-forest/basicChunk.js.map +1 -1
  306. package/lib/feature-libraries/chunked-forest/chunkTree.js +2 -2
  307. package/lib/feature-libraries/chunked-forest/chunkTree.js.map +1 -1
  308. package/lib/feature-libraries/chunked-forest/chunkedForest.d.ts.map +1 -1
  309. package/lib/feature-libraries/chunked-forest/chunkedForest.js +2 -2
  310. package/lib/feature-libraries/chunked-forest/chunkedForest.js.map +1 -1
  311. package/lib/feature-libraries/chunked-forest/codec/chunkEncodingGeneric.js +1 -1
  312. package/lib/feature-libraries/chunked-forest/codec/chunkEncodingGeneric.js.map +1 -1
  313. package/lib/feature-libraries/chunked-forest/codec/compressedEncode.js +2 -2
  314. package/lib/feature-libraries/chunked-forest/codec/compressedEncode.js.map +1 -1
  315. package/lib/feature-libraries/chunked-forest/codec/nodeShape.js +2 -2
  316. package/lib/feature-libraries/chunked-forest/codec/nodeShape.js.map +1 -1
  317. package/lib/feature-libraries/chunked-forest/codec/schemaBasedEncode.d.ts.map +1 -1
  318. package/lib/feature-libraries/chunked-forest/codec/schemaBasedEncode.js +1 -2
  319. package/lib/feature-libraries/chunked-forest/codec/schemaBasedEncode.js.map +1 -1
  320. package/lib/feature-libraries/chunked-forest/emptyChunk.d.ts.map +1 -1
  321. package/lib/feature-libraries/chunked-forest/emptyChunk.js +1 -1
  322. package/lib/feature-libraries/chunked-forest/emptyChunk.js.map +1 -1
  323. package/lib/feature-libraries/chunked-forest/uniformChunk.d.ts.map +1 -1
  324. package/lib/feature-libraries/chunked-forest/uniformChunk.js +2 -2
  325. package/lib/feature-libraries/chunked-forest/uniformChunk.js.map +1 -1
  326. package/lib/feature-libraries/default-schema/defaultFieldKinds.d.ts.map +1 -1
  327. package/lib/feature-libraries/default-schema/defaultFieldKinds.js +1 -1
  328. package/lib/feature-libraries/default-schema/defaultFieldKinds.js.map +1 -1
  329. package/lib/feature-libraries/default-schema/schemaChecker.d.ts.map +1 -1
  330. package/lib/feature-libraries/default-schema/schemaChecker.js +1 -2
  331. package/lib/feature-libraries/default-schema/schemaChecker.js.map +1 -1
  332. package/lib/feature-libraries/flex-tree/lazyField.js +2 -2
  333. package/lib/feature-libraries/flex-tree/lazyField.js.map +1 -1
  334. package/lib/feature-libraries/flex-tree/lazyNode.js +2 -2
  335. package/lib/feature-libraries/flex-tree/lazyNode.js.map +1 -1
  336. package/lib/feature-libraries/indexing/anchorTreeIndex.d.ts.map +1 -1
  337. package/lib/feature-libraries/indexing/anchorTreeIndex.js +2 -2
  338. package/lib/feature-libraries/indexing/anchorTreeIndex.js.map +1 -1
  339. package/lib/feature-libraries/modular-schema/comparison.js +2 -2
  340. package/lib/feature-libraries/modular-schema/comparison.js.map +1 -1
  341. package/lib/feature-libraries/modular-schema/isNeverTree.d.ts.map +1 -1
  342. package/lib/feature-libraries/modular-schema/isNeverTree.js +1 -2
  343. package/lib/feature-libraries/modular-schema/isNeverTree.js.map +1 -1
  344. package/lib/feature-libraries/modular-schema/modularChangeCodecs.d.ts.map +1 -1
  345. package/lib/feature-libraries/modular-schema/modularChangeCodecs.js +2 -2
  346. package/lib/feature-libraries/modular-schema/modularChangeCodecs.js.map +1 -1
  347. package/lib/feature-libraries/modular-schema/modularChangeFamily.d.ts.map +1 -1
  348. package/lib/feature-libraries/modular-schema/modularChangeFamily.js +2 -2
  349. package/lib/feature-libraries/modular-schema/modularChangeFamily.js.map +1 -1
  350. package/lib/feature-libraries/node-identifier/mockNodeIdentifierManager.js +2 -2
  351. package/lib/feature-libraries/node-identifier/mockNodeIdentifierManager.js.map +1 -1
  352. package/lib/feature-libraries/object-forest/objectForest.d.ts.map +1 -1
  353. package/lib/feature-libraries/object-forest/objectForest.js +2 -2
  354. package/lib/feature-libraries/object-forest/objectForest.js.map +1 -1
  355. package/lib/feature-libraries/schema-index/codec.d.ts.map +1 -1
  356. package/lib/feature-libraries/schema-index/codec.js +2 -1
  357. package/lib/feature-libraries/schema-index/codec.js.map +1 -1
  358. package/lib/feature-libraries/sequence-field/compose.d.ts +1 -1
  359. package/lib/feature-libraries/sequence-field/compose.d.ts.map +1 -1
  360. package/lib/feature-libraries/sequence-field/compose.js +1 -2
  361. package/lib/feature-libraries/sequence-field/compose.js.map +1 -1
  362. package/lib/feature-libraries/sequence-field/invert.d.ts.map +1 -1
  363. package/lib/feature-libraries/sequence-field/invert.js +2 -2
  364. package/lib/feature-libraries/sequence-field/invert.js.map +1 -1
  365. package/lib/feature-libraries/sequence-field/sequenceFieldCodecV1.d.ts.map +1 -1
  366. package/lib/feature-libraries/sequence-field/sequenceFieldCodecV1.js +2 -2
  367. package/lib/feature-libraries/sequence-field/sequenceFieldCodecV1.js.map +1 -1
  368. package/lib/feature-libraries/sequence-field/sequenceFieldCodecV2.d.ts.map +1 -1
  369. package/lib/feature-libraries/sequence-field/sequenceFieldCodecV2.js +2 -2
  370. package/lib/feature-libraries/sequence-field/sequenceFieldCodecV2.js.map +1 -1
  371. package/lib/feature-libraries/sequence-field/utils.js +2 -2
  372. package/lib/feature-libraries/sequence-field/utils.js.map +1 -1
  373. package/lib/feature-libraries/treeCursorUtils.d.ts.map +1 -1
  374. package/lib/feature-libraries/treeCursorUtils.js +1 -2
  375. package/lib/feature-libraries/treeCursorUtils.js.map +1 -1
  376. package/lib/index.d.ts +4 -3
  377. package/lib/index.d.ts.map +1 -1
  378. package/lib/index.js +4 -3
  379. package/lib/index.js.map +1 -1
  380. package/lib/jsonDomainSchema.d.ts +15 -16
  381. package/lib/jsonDomainSchema.d.ts.map +1 -1
  382. package/lib/jsonDomainSchema.js +11 -6
  383. package/lib/jsonDomainSchema.js.map +1 -1
  384. package/lib/legacy.d.ts +5 -1
  385. package/lib/packageVersion.d.ts +1 -1
  386. package/lib/packageVersion.js +1 -1
  387. package/lib/packageVersion.js.map +1 -1
  388. package/lib/public.d.ts +5 -1
  389. package/lib/serializableDomainSchema.d.ts +8 -14
  390. package/lib/serializableDomainSchema.d.ts.map +1 -1
  391. package/lib/shared-tree/schematizeTree.js +2 -2
  392. package/lib/shared-tree/schematizeTree.js.map +1 -1
  393. package/lib/shared-tree/sharedTree.d.ts.map +1 -1
  394. package/lib/shared-tree/sharedTree.js +14 -10
  395. package/lib/shared-tree/sharedTree.js.map +1 -1
  396. package/lib/shared-tree/sharedTreeChangeFamily.d.ts.map +1 -1
  397. package/lib/shared-tree/sharedTreeChangeFamily.js +2 -2
  398. package/lib/shared-tree/sharedTreeChangeFamily.js.map +1 -1
  399. package/lib/shared-tree/treeApiAlpha.d.ts +6 -2
  400. package/lib/shared-tree/treeApiAlpha.d.ts.map +1 -1
  401. package/lib/shared-tree/treeApiAlpha.js +10 -7
  402. package/lib/shared-tree/treeApiAlpha.js.map +1 -1
  403. package/lib/shared-tree/treeCheckout.d.ts.map +1 -1
  404. package/lib/shared-tree/treeCheckout.js +2 -2
  405. package/lib/shared-tree/treeCheckout.js.map +1 -1
  406. package/lib/shared-tree-core/branch.d.ts +4 -3
  407. package/lib/shared-tree-core/branch.d.ts.map +1 -1
  408. package/lib/shared-tree-core/branch.js +2 -2
  409. package/lib/shared-tree-core/branch.js.map +1 -1
  410. package/lib/shared-tree-core/editManager.d.ts.map +1 -1
  411. package/lib/shared-tree-core/editManager.js +35 -29
  412. package/lib/shared-tree-core/editManager.js.map +1 -1
  413. package/lib/sharedTreeAttributes.d.ts +18 -0
  414. package/lib/sharedTreeAttributes.d.ts.map +1 -0
  415. package/lib/sharedTreeAttributes.js +22 -0
  416. package/lib/sharedTreeAttributes.js.map +1 -0
  417. package/lib/simple-tree/api/customTree.js +2 -2
  418. package/lib/simple-tree/api/customTree.js.map +1 -1
  419. package/lib/simple-tree/api/getJsonSchema.d.ts +10 -0
  420. package/lib/simple-tree/api/getJsonSchema.d.ts.map +1 -1
  421. package/lib/simple-tree/api/getJsonSchema.js +10 -0
  422. package/lib/simple-tree/api/getJsonSchema.js.map +1 -1
  423. package/lib/simple-tree/api/getSimpleSchema.d.ts +13 -43
  424. package/lib/simple-tree/api/getSimpleSchema.d.ts.map +1 -1
  425. package/lib/simple-tree/api/getSimpleSchema.js +13 -43
  426. package/lib/simple-tree/api/getSimpleSchema.js.map +1 -1
  427. package/lib/simple-tree/api/index.d.ts +3 -3
  428. package/lib/simple-tree/api/index.d.ts.map +1 -1
  429. package/lib/simple-tree/api/index.js +1 -0
  430. package/lib/simple-tree/api/index.js.map +1 -1
  431. package/lib/simple-tree/api/schemaCreationUtilities.d.ts.map +1 -1
  432. package/lib/simple-tree/api/schemaCreationUtilities.js +1 -1
  433. package/lib/simple-tree/api/schemaCreationUtilities.js.map +1 -1
  434. package/lib/simple-tree/api/schemaFactory.d.ts +100 -58
  435. package/lib/simple-tree/api/schemaFactory.d.ts.map +1 -1
  436. package/lib/simple-tree/api/schemaFactory.js +64 -132
  437. package/lib/simple-tree/api/schemaFactory.js.map +1 -1
  438. package/lib/simple-tree/api/schemaFactoryAlpha.d.ts +31 -23
  439. package/lib/simple-tree/api/schemaFactoryAlpha.d.ts.map +1 -1
  440. package/lib/simple-tree/api/schemaFactoryAlpha.js +18 -2
  441. package/lib/simple-tree/api/schemaFactoryAlpha.js.map +1 -1
  442. package/lib/simple-tree/api/schemaFactoryRecursive.d.ts +40 -5
  443. package/lib/simple-tree/api/schemaFactoryRecursive.d.ts.map +1 -1
  444. package/lib/simple-tree/api/schemaFactoryRecursive.js.map +1 -1
  445. package/lib/simple-tree/api/schemaFromSimple.d.ts +4 -4
  446. package/lib/simple-tree/api/schemaFromSimple.d.ts.map +1 -1
  447. package/lib/simple-tree/api/schemaFromSimple.js +21 -10
  448. package/lib/simple-tree/api/schemaFromSimple.js.map +1 -1
  449. package/lib/simple-tree/api/simpleSchemaToJsonSchema.d.ts +3 -2
  450. package/lib/simple-tree/api/simpleSchemaToJsonSchema.d.ts.map +1 -1
  451. package/lib/simple-tree/api/simpleSchemaToJsonSchema.js +6 -6
  452. package/lib/simple-tree/api/simpleSchemaToJsonSchema.js.map +1 -1
  453. package/lib/simple-tree/api/simpleTreeIndex.d.ts.map +1 -1
  454. package/lib/simple-tree/api/simpleTreeIndex.js +2 -1
  455. package/lib/simple-tree/api/simpleTreeIndex.js.map +1 -1
  456. package/lib/simple-tree/api/testRecursiveDomain.d.ts +10 -10
  457. package/lib/simple-tree/api/tree.d.ts +1 -1
  458. package/lib/simple-tree/api/tree.d.ts.map +1 -1
  459. package/lib/simple-tree/api/tree.js +2 -2
  460. package/lib/simple-tree/api/tree.js.map +1 -1
  461. package/lib/simple-tree/api/treeNodeApi.js +2 -2
  462. package/lib/simple-tree/api/treeNodeApi.js.map +1 -1
  463. package/lib/simple-tree/api/typesUnsafe.d.ts +87 -21
  464. package/lib/simple-tree/api/typesUnsafe.d.ts.map +1 -1
  465. package/lib/simple-tree/api/typesUnsafe.js +0 -1
  466. package/lib/simple-tree/api/typesUnsafe.js.map +1 -1
  467. package/lib/simple-tree/api/verboseTree.js +2 -2
  468. package/lib/simple-tree/api/verboseTree.js.map +1 -1
  469. package/lib/simple-tree/api/view.d.ts.map +1 -1
  470. package/lib/simple-tree/api/view.js +1 -2
  471. package/lib/simple-tree/api/view.js.map +1 -1
  472. package/lib/simple-tree/api/viewSchemaToSimpleSchema.d.ts +16 -3
  473. package/lib/simple-tree/api/viewSchemaToSimpleSchema.d.ts.map +1 -1
  474. package/lib/simple-tree/api/viewSchemaToSimpleSchema.js +69 -146
  475. package/lib/simple-tree/api/viewSchemaToSimpleSchema.js.map +1 -1
  476. package/lib/simple-tree/arrayNode.d.ts +5 -4
  477. package/lib/simple-tree/arrayNode.d.ts.map +1 -1
  478. package/lib/simple-tree/arrayNode.js +7 -3
  479. package/lib/simple-tree/arrayNode.js.map +1 -1
  480. package/lib/simple-tree/arrayNodeTypes.d.ts +46 -0
  481. package/lib/simple-tree/arrayNodeTypes.d.ts.map +1 -0
  482. package/lib/simple-tree/arrayNodeTypes.js +26 -0
  483. package/lib/simple-tree/arrayNodeTypes.js.map +1 -0
  484. package/lib/simple-tree/core/getOrCreateNode.d.ts.map +1 -1
  485. package/lib/simple-tree/core/getOrCreateNode.js +2 -12
  486. package/lib/simple-tree/core/getOrCreateNode.js.map +1 -1
  487. package/lib/simple-tree/core/index.d.ts +1 -2
  488. package/lib/simple-tree/core/index.d.ts.map +1 -1
  489. package/lib/simple-tree/core/index.js +1 -2
  490. package/lib/simple-tree/core/index.js.map +1 -1
  491. package/lib/simple-tree/core/treeNodeKernel.d.ts +12 -5
  492. package/lib/simple-tree/core/treeNodeKernel.d.ts.map +1 -1
  493. package/lib/simple-tree/core/treeNodeKernel.js +28 -14
  494. package/lib/simple-tree/core/treeNodeKernel.js.map +1 -1
  495. package/lib/simple-tree/core/treeNodeSchema.d.ts +14 -7
  496. package/lib/simple-tree/core/treeNodeSchema.d.ts.map +1 -1
  497. package/lib/simple-tree/core/treeNodeSchema.js.map +1 -1
  498. package/lib/simple-tree/core/unhydratedFlexTree.js +2 -2
  499. package/lib/simple-tree/core/unhydratedFlexTree.js.map +1 -1
  500. package/lib/simple-tree/index.d.ts +9 -2
  501. package/lib/simple-tree/index.d.ts.map +1 -1
  502. package/lib/simple-tree/index.js +3 -0
  503. package/lib/simple-tree/index.js.map +1 -1
  504. package/lib/simple-tree/leafNodeSchema.d.ts +22 -5
  505. package/lib/simple-tree/leafNodeSchema.d.ts.map +1 -1
  506. package/lib/simple-tree/leafNodeSchema.js +2 -0
  507. package/lib/simple-tree/leafNodeSchema.js.map +1 -1
  508. package/lib/simple-tree/mapNode.d.ts +3 -2
  509. package/lib/simple-tree/mapNode.d.ts.map +1 -1
  510. package/lib/simple-tree/mapNode.js +5 -1
  511. package/lib/simple-tree/mapNode.js.map +1 -1
  512. package/lib/simple-tree/mapNodeTypes.d.ts +46 -0
  513. package/lib/simple-tree/mapNodeTypes.d.ts.map +1 -0
  514. package/lib/simple-tree/mapNodeTypes.js +26 -0
  515. package/lib/simple-tree/mapNodeTypes.js.map +1 -0
  516. package/lib/simple-tree/objectNode.d.ts +10 -3
  517. package/lib/simple-tree/objectNode.d.ts.map +1 -1
  518. package/lib/simple-tree/objectNode.js +10 -5
  519. package/lib/simple-tree/objectNode.js.map +1 -1
  520. package/lib/simple-tree/objectNodeTypes.d.ts +9 -5
  521. package/lib/simple-tree/objectNodeTypes.d.ts.map +1 -1
  522. package/lib/simple-tree/objectNodeTypes.js +3 -0
  523. package/lib/simple-tree/objectNodeTypes.js.map +1 -1
  524. package/lib/simple-tree/proxies.js +2 -1
  525. package/lib/simple-tree/proxies.js.map +1 -1
  526. package/lib/simple-tree/schemaTypes.d.ts +47 -6
  527. package/lib/simple-tree/schemaTypes.d.ts.map +1 -1
  528. package/lib/simple-tree/schemaTypes.js +37 -3
  529. package/lib/simple-tree/schemaTypes.js.map +1 -1
  530. package/lib/simple-tree/{api/simpleSchema.d.ts → simpleSchema.d.ts} +54 -30
  531. package/lib/simple-tree/simpleSchema.d.ts.map +1 -0
  532. package/lib/simple-tree/simpleSchema.js.map +1 -0
  533. package/lib/simple-tree/toMapTree.js +2 -2
  534. package/lib/simple-tree/toMapTree.js.map +1 -1
  535. package/lib/simple-tree/toStoredSchema.js +2 -2
  536. package/lib/simple-tree/toStoredSchema.js.map +1 -1
  537. package/lib/simple-tree/treeNodeValid.d.ts.map +1 -1
  538. package/lib/simple-tree/treeNodeValid.js +1 -2
  539. package/lib/simple-tree/treeNodeValid.js.map +1 -1
  540. package/lib/treeFactory.d.ts +0 -12
  541. package/lib/treeFactory.d.ts.map +1 -1
  542. package/lib/treeFactory.js +1 -17
  543. package/lib/treeFactory.js.map +1 -1
  544. package/lib/tsdoc-metadata.json +1 -1
  545. package/lib/util/idAllocator.d.ts.map +1 -1
  546. package/lib/util/idAllocator.js +1 -2
  547. package/lib/util/idAllocator.js.map +1 -1
  548. package/lib/util/index.d.ts +1 -1
  549. package/lib/util/index.d.ts.map +1 -1
  550. package/lib/util/index.js +1 -1
  551. package/lib/util/index.js.map +1 -1
  552. package/lib/util/typeCheck.d.ts +7 -0
  553. package/lib/util/typeCheck.d.ts.map +1 -1
  554. package/lib/util/typeCheck.js.map +1 -1
  555. package/lib/util/utils.d.ts +0 -1
  556. package/lib/util/utils.d.ts.map +1 -1
  557. package/lib/util/utils.js +0 -2
  558. package/lib/util/utils.js.map +1 -1
  559. package/package.json +36 -26
  560. package/src/codec/codec.ts +2 -2
  561. package/src/codec/discriminatedUnions.ts +2 -2
  562. package/src/core/rebase/utils.ts +1 -1
  563. package/src/core/schema-stored/schema.ts +6 -2
  564. package/src/core/tree/anchorSet.ts +1 -2
  565. package/src/core/tree/treeTextFormat.ts +1 -1
  566. package/src/feature-libraries/chunked-forest/basicChunk.ts +2 -2
  567. package/src/feature-libraries/chunked-forest/chunkTree.ts +2 -2
  568. package/src/feature-libraries/chunked-forest/chunkedForest.ts +1 -2
  569. package/src/feature-libraries/chunked-forest/codec/chunkEncodingGeneric.ts +1 -1
  570. package/src/feature-libraries/chunked-forest/codec/compressedEncode.ts +2 -2
  571. package/src/feature-libraries/chunked-forest/codec/nodeShape.ts +2 -2
  572. package/src/feature-libraries/chunked-forest/codec/schemaBasedEncode.ts +1 -2
  573. package/src/feature-libraries/chunked-forest/emptyChunk.ts +1 -1
  574. package/src/feature-libraries/chunked-forest/uniformChunk.ts +2 -2
  575. package/src/feature-libraries/default-schema/defaultFieldKinds.ts +1 -1
  576. package/src/feature-libraries/default-schema/schemaChecker.ts +1 -2
  577. package/src/feature-libraries/flex-tree/lazyField.ts +2 -2
  578. package/src/feature-libraries/flex-tree/lazyNode.ts +2 -2
  579. package/src/feature-libraries/indexing/anchorTreeIndex.ts +2 -2
  580. package/src/feature-libraries/modular-schema/comparison.ts +2 -2
  581. package/src/feature-libraries/modular-schema/isNeverTree.ts +1 -2
  582. package/src/feature-libraries/modular-schema/modularChangeCodecs.ts +1 -2
  583. package/src/feature-libraries/modular-schema/modularChangeFamily.ts +1 -2
  584. package/src/feature-libraries/node-identifier/mockNodeIdentifierManager.ts +2 -2
  585. package/src/feature-libraries/object-forest/objectForest.ts +1 -2
  586. package/src/feature-libraries/schema-index/codec.ts +2 -1
  587. package/src/feature-libraries/sequence-field/compose.ts +2 -2
  588. package/src/feature-libraries/sequence-field/invert.ts +2 -2
  589. package/src/feature-libraries/sequence-field/sequenceFieldCodecV1.ts +2 -2
  590. package/src/feature-libraries/sequence-field/sequenceFieldCodecV2.ts +2 -2
  591. package/src/feature-libraries/sequence-field/utils.ts +2 -2
  592. package/src/feature-libraries/treeCursorUtils.ts +1 -2
  593. package/src/index.ts +26 -3
  594. package/src/jsonDomainSchema.ts +30 -11
  595. package/src/packageVersion.ts +1 -1
  596. package/src/shared-tree/schematizeTree.ts +2 -2
  597. package/src/shared-tree/sharedTree.ts +16 -10
  598. package/src/shared-tree/sharedTreeChangeFamily.ts +1 -2
  599. package/src/shared-tree/treeApiAlpha.ts +36 -13
  600. package/src/shared-tree/treeCheckout.ts +2 -8
  601. package/src/shared-tree-core/branch.ts +5 -3
  602. package/src/shared-tree-core/editManager.ts +37 -45
  603. package/src/sharedTreeAttributes.ts +25 -0
  604. package/src/simple-tree/api/customTree.ts +2 -2
  605. package/src/simple-tree/api/getJsonSchema.ts +10 -0
  606. package/src/simple-tree/api/getSimpleSchema.ts +14 -44
  607. package/src/simple-tree/api/index.ts +7 -11
  608. package/src/simple-tree/api/schemaCreationUtilities.ts +1 -2
  609. package/src/simple-tree/api/schemaFactory.ts +161 -86
  610. package/src/simple-tree/api/schemaFactoryAlpha.ts +62 -67
  611. package/src/simple-tree/api/schemaFactoryRecursive.ts +44 -12
  612. package/src/simple-tree/api/schemaFromSimple.ts +41 -13
  613. package/src/simple-tree/api/simpleSchemaToJsonSchema.ts +7 -7
  614. package/src/simple-tree/api/simpleTreeIndex.ts +2 -1
  615. package/src/simple-tree/api/tree.ts +3 -3
  616. package/src/simple-tree/api/treeNodeApi.ts +2 -2
  617. package/src/simple-tree/api/typesUnsafe.ts +151 -33
  618. package/src/simple-tree/api/verboseTree.ts +2 -2
  619. package/src/simple-tree/api/view.ts +1 -2
  620. package/src/simple-tree/api/viewSchemaToSimpleSchema.ts +80 -185
  621. package/src/simple-tree/arrayNode.ts +20 -14
  622. package/src/simple-tree/arrayNodeTypes.ts +93 -0
  623. package/src/simple-tree/core/getOrCreateNode.ts +3 -13
  624. package/src/simple-tree/core/index.ts +1 -1
  625. package/src/simple-tree/core/treeNodeKernel.ts +32 -18
  626. package/src/simple-tree/core/treeNodeSchema.ts +14 -8
  627. package/src/simple-tree/core/unhydratedFlexTree.ts +2 -2
  628. package/src/simple-tree/index.ts +30 -9
  629. package/src/simple-tree/leafNodeSchema.ts +28 -7
  630. package/src/simple-tree/mapNode.ts +13 -11
  631. package/src/simple-tree/mapNodeTypes.ts +90 -0
  632. package/src/simple-tree/objectNode.ts +37 -13
  633. package/src/simple-tree/objectNodeTypes.ts +21 -16
  634. package/src/simple-tree/proxies.ts +2 -2
  635. package/src/simple-tree/schemaTypes.ts +83 -19
  636. package/src/simple-tree/{api/simpleSchema.ts → simpleSchema.ts} +61 -32
  637. package/src/simple-tree/toMapTree.ts +2 -2
  638. package/src/simple-tree/toStoredSchema.ts +2 -2
  639. package/src/simple-tree/treeNodeValid.ts +1 -2
  640. package/src/treeFactory.ts +1 -19
  641. package/src/util/idAllocator.ts +1 -3
  642. package/src/util/index.ts +0 -1
  643. package/src/util/typeCheck.ts +7 -0
  644. package/src/util/utils.ts +0 -3
  645. package/dist/simple-tree/api/simpleSchema.d.ts.map +0 -1
  646. package/dist/simple-tree/api/simpleSchema.js.map +0 -1
  647. package/dist/simple-tree/core/schemaCaching.d.ts +0 -16
  648. package/dist/simple-tree/core/schemaCaching.d.ts.map +0 -1
  649. package/dist/simple-tree/core/schemaCaching.js +0 -32
  650. package/dist/simple-tree/core/schemaCaching.js.map +0 -1
  651. package/lib/simple-tree/api/simpleSchema.d.ts.map +0 -1
  652. package/lib/simple-tree/api/simpleSchema.js.map +0 -1
  653. package/lib/simple-tree/core/schemaCaching.d.ts +0 -16
  654. package/lib/simple-tree/core/schemaCaching.d.ts.map +0 -1
  655. package/lib/simple-tree/core/schemaCaching.js +0 -27
  656. package/lib/simple-tree/core/schemaCaching.js.map +0 -1
  657. package/prettier.config.cjs +0 -8
  658. package/src/simple-tree/core/schemaCaching.ts +0 -35
  659. /package/dist/simple-tree/{api/simpleSchema.js → simpleSchema.js} +0 -0
  660. /package/lib/simple-tree/{api/simpleSchema.js → simpleSchema.js} +0 -0
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/simple-tree/core/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,yDAU6B;AAT5B,+GAAA,UAAU,OAAA;AACV,mHAAA,cAAc,OAAA;AACd,8GAAA,SAAS,OAAA;AACT,yHAAA,oBAAoB,OAAA;AAEpB,uHAAA,kBAAkB,OAAA;AAClB,qIAAA,gCAAgC,OAAA;AAChC,yHAAA,oBAAoB,OAAA;AACpB,uHAAA,kBAAkB,OAAA;AAEnB,6CAAgF;AAAxD,6GAAA,cAAc,OAAA;AAAE,+GAAA,gBAAgB,OAAA;AACxD,uCAOoB;AALnB,oGAAA,QAAQ,OAAA;AAER,4GAAA,gBAAgB,OAAA;AAEhB,wGAAA,YAAY,OAAA;AAEb,yDAO6B;AAL5B,6GAAA,QAAQ,OAAA;AAMT,uDAAsE;AAA7D,oIAAA,gCAAgC,OAAA;AACzC,iDAAuE;AAA9D,iHAAA,gBAAgB,OAAA;AACzB,2CAA2E;AAAlE,qGAAA,OAAO,OAAA;AAAE,6GAAA,eAAe,OAAA;AAAE,+GAAA,iBAAiB,OAAA;AACpD,2DAAoE;AAA3D,kIAAA,4BAA4B,OAAA;AACrC,iEAKiC;AAJhC,+HAAA,sBAAsB,OAAA;AACtB,oIAAA,2BAA2B,OAAA;AAC3B,kIAAA,yBAAyB,OAAA;AACzB,0HAAA,iBAAiB,OAAA","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport {\n\tisTreeNode,\n\tTreeNodeKernel,\n\tgetKernel,\n\ttryGetTreeNodeSchema,\n\ttype InnerNode,\n\ttryDisposeTreeNode,\n\tunhydratedFlexTreeNodeToTreeNode,\n\tgetOrCreateInnerNode,\n\ttreeNodeFromAnchor,\n} from \"./treeNodeKernel.js\";\nexport { type WithType, typeNameSymbol, typeSchemaSymbol } from \"./withType.js\";\nexport {\n\ttype TreeChangeEvents,\n\tTreeNode,\n\ttype Unhydrated,\n\tinPrototypeChain,\n\ttype InternalTreeNode,\n\tprivateToken,\n} from \"./types.js\";\nexport {\n\ttype TreeNodeSchema,\n\tNodeKind,\n\ttype TreeNodeSchemaClass,\n\ttype TreeNodeSchemaNonClass,\n\ttype TreeNodeSchemaCore,\n\ttype TreeNodeSchemaBoth,\n} from \"./treeNodeSchema.js\";\nexport { getSimpleNodeSchemaFromInnerNode } from \"./schemaCaching.js\";\nexport { walkAllowedTypes, type SchemaVisitor } from \"./walkSchema.js\";\nexport { Context, HydratedContext, SimpleContextSlot } from \"./context.js\";\nexport { getOrCreateNodeFromInnerNode } from \"./getOrCreateNode.js\";\nexport {\n\tUnhydratedFlexTreeNode,\n\tUnhydratedTreeSequenceField,\n\ttryUnhydratedFlexTreeNode,\n\tUnhydratedContext,\n} from \"./unhydratedFlexTree.js\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/simple-tree/core/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,yDAW6B;AAV5B,+GAAA,UAAU,OAAA;AACV,mHAAA,cAAc,OAAA;AACd,8GAAA,SAAS,OAAA;AACT,yHAAA,oBAAoB,OAAA;AAEpB,uHAAA,kBAAkB,OAAA;AAClB,qIAAA,gCAAgC,OAAA;AAChC,yHAAA,oBAAoB,OAAA;AACpB,uHAAA,kBAAkB,OAAA;AAClB,qIAAA,gCAAgC,OAAA;AAEjC,6CAAgF;AAAxD,6GAAA,cAAc,OAAA;AAAE,+GAAA,gBAAgB,OAAA;AACxD,uCAOoB;AALnB,oGAAA,QAAQ,OAAA;AAER,4GAAA,gBAAgB,OAAA;AAEhB,wGAAA,YAAY,OAAA;AAEb,yDAO6B;AAL5B,6GAAA,QAAQ,OAAA;AAMT,iDAAuE;AAA9D,iHAAA,gBAAgB,OAAA;AACzB,2CAA2E;AAAlE,qGAAA,OAAO,OAAA;AAAE,6GAAA,eAAe,OAAA;AAAE,+GAAA,iBAAiB,OAAA;AACpD,2DAAoE;AAA3D,kIAAA,4BAA4B,OAAA;AACrC,iEAKiC;AAJhC,+HAAA,sBAAsB,OAAA;AACtB,oIAAA,2BAA2B,OAAA;AAC3B,kIAAA,yBAAyB,OAAA;AACzB,0HAAA,iBAAiB,OAAA","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport {\n\tisTreeNode,\n\tTreeNodeKernel,\n\tgetKernel,\n\ttryGetTreeNodeSchema,\n\ttype InnerNode,\n\ttryDisposeTreeNode,\n\tunhydratedFlexTreeNodeToTreeNode,\n\tgetOrCreateInnerNode,\n\ttreeNodeFromAnchor,\n\tgetSimpleNodeSchemaFromInnerNode,\n} from \"./treeNodeKernel.js\";\nexport { type WithType, typeNameSymbol, typeSchemaSymbol } from \"./withType.js\";\nexport {\n\ttype TreeChangeEvents,\n\tTreeNode,\n\ttype Unhydrated,\n\tinPrototypeChain,\n\ttype InternalTreeNode,\n\tprivateToken,\n} from \"./types.js\";\nexport {\n\ttype TreeNodeSchema,\n\tNodeKind,\n\ttype TreeNodeSchemaClass,\n\ttype TreeNodeSchemaNonClass,\n\ttype TreeNodeSchemaCore,\n\ttype TreeNodeSchemaBoth,\n} from \"./treeNodeSchema.js\";\nexport { walkAllowedTypes, type SchemaVisitor } from \"./walkSchema.js\";\nexport { Context, HydratedContext, SimpleContextSlot } from \"./context.js\";\nexport { getOrCreateNodeFromInnerNode } from \"./getOrCreateNode.js\";\nexport {\n\tUnhydratedFlexTreeNode,\n\tUnhydratedTreeSequenceField,\n\ttryUnhydratedFlexTreeNode,\n\tUnhydratedContext,\n} from \"./unhydratedFlexTree.js\";\n"]}
@@ -140,12 +140,13 @@ export declare const unhydratedFlexTreeNodeToTreeNode: Pick<WeakMap<UnhydratedFl
140
140
  export declare const proxySlot: import("../../core/index.js").AnchorSlot<TreeNode>;
141
141
  export declare function tryDisposeTreeNode(anchorNode: AnchorNode): void;
142
142
  /**
143
- * Lookup a TreeNodeSchema from a Hydrated FlexTreeNode.
144
- * @privateRemarks
145
- * This provides a way to access simple tree schema from the flex tree without depending on {@link FlexTreeSchema} which is in the process of being removed.
146
- * This is currently limited to hydrated nodes: this limitation will have to be fixed before {@link FlexTreeSchema} can be fully removed.
143
+ * Gets the {@link TreeNodeSchema} for the {@link InnerNode}.
147
144
  */
148
- export declare function getTreeNodeSchemaFromHydratedFlexNode(flexNode: FlexTreeNode): TreeNodeSchema;
145
+ export declare function getSimpleNodeSchemaFromInnerNode(innerNode: InnerNode): TreeNodeSchema;
146
+ /**
147
+ * Gets the {@link Context} for the {@link InnerNode}.
148
+ */
149
+ export declare function getSimpleContextFromInnerNode(innerNode: InnerNode): Context;
149
150
  /**
150
151
  * Retrieves the flex node associated with the given target via {@link setInnerNode}.
151
152
  * @remarks
@@ -159,5 +160,11 @@ export declare function getOrCreateInnerNode(treeNode: TreeNode, allowFreed?: bo
159
160
  * Gets a tree node from an anchor node
160
161
  */
161
162
  export declare function treeNodeFromAnchor(anchorNode: AnchorNode): TreeNode | TreeValue;
163
+ /**
164
+ * Constructs a TreeNode from an InnerNode.
165
+ * @remarks
166
+ * This does not do caching or validation: caller must ensure duplicate nodes for a given inner node are not created, and that the inner node is valid.
167
+ */
168
+ export declare function createTreeNodeFromInner(innerNode: InnerNode): TreeNode | TreeValue;
162
169
  export {};
163
170
  //# sourceMappingURL=treeNodeKernel.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"treeNodeKernel.d.ts","sourceRoot":"","sources":["../../../src/simple-tree/core/treeNodeKernel.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,KAAK,EAAE,UAAU,EAAO,MAAM,iCAAiC,CAAC;AACvE,OAAO,KAAK,EAAoB,QAAQ,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACzE,OAAO,EAEN,KAAK,YAAY,EACjB,KAAK,UAAU,EACf,KAAK,SAAS,EACd,KAAK,SAAS,EACd,KAAK,MAAM,EACX,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAMN,UAAU,EAEV,KAAK,YAAY,EACjB,MAAM,kCAAkC,CAAC;AAC1C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAK1D,OAAO,EAAqB,KAAK,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,cAAc,CAAC;AACrF,OAAO,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AAIjE,wBAAgB,SAAS,CAAC,IAAI,EAAE,QAAQ,GAAG,cAAc,CAIxD;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,UAAU,CAAC,SAAS,EAAE,OAAO,GAAG,SAAS,IAAI,QAAQ,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G;AACH,MAAM,MAAM,SAAS,GAAG,YAAY,GAAG,sBAAsB,CAAC;AAS9D;;GAEG;AACH,eAAO,MAAM,gCAAgC,wDAI3C,CAAC;AAEH;;;;;GAKG;AACH,eAAO,MAAM,SAAS,oDAAyB,CAAC;AAEhD,wBAAgB,kBAAkB,CAAC,UAAU,EAAE,UAAU,GAAG,IAAI,CAM/D;AAED;;GAEG;AACH,wBAAgB,gCAAgC,CAAC,SAAS,EAAE,SAAS,GAAG,cAAc,CAGrF;AAED;;GAEG;AACH,wBAAgB,6BAA6B,CAAC,SAAS,EAAE,SAAS,GAAG,OAAO,CAS3E;AAED;;;;;;;GAOG;AACH,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,QAAQ,EAAE,UAAU,UAAQ,GAAG,SAAS,CAGtF;AAoBD;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,UAAU,EAAE,UAAU,GAAG,QAAQ,GAAG,SAAS,CAQ/E;AAED;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,SAAS,EAAE,SAAS,GAAG,QAAQ,GAAG,SAAS,CAQlF"}
@@ -16,12 +16,11 @@ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (
16
16
  };
17
17
  var _TreeNodeKernel_hydrationState, _TreeNodeKernel_unhydratedEvents;
18
18
  Object.defineProperty(exports, "__esModule", { value: true });
19
- exports.treeNodeFromAnchor = exports.getOrCreateInnerNode = exports.getTreeNodeSchemaFromHydratedFlexNode = exports.tryDisposeTreeNode = exports.proxySlot = exports.unhydratedFlexTreeNodeToTreeNode = exports.TreeNodeKernel = exports.tryGetTreeNodeSchema = exports.isTreeNode = exports.getKernel = void 0;
19
+ exports.createTreeNodeFromInner = exports.treeNodeFromAnchor = exports.getOrCreateInnerNode = exports.getSimpleContextFromInnerNode = exports.getSimpleNodeSchemaFromInnerNode = exports.tryDisposeTreeNode = exports.proxySlot = exports.unhydratedFlexTreeNodeToTreeNode = exports.TreeNodeKernel = exports.tryGetTreeNodeSchema = exports.isTreeNode = exports.getKernel = void 0;
20
20
  const internal_1 = require("@fluidframework/core-utils/internal");
21
21
  const client_utils_1 = require("@fluid-internal/client-utils");
22
22
  const index_js_1 = require("../../core/index.js");
23
23
  const index_js_2 = require("../../feature-libraries/index.js");
24
- const index_js_3 = require("../../util/index.js");
25
24
  // TODO: decide how to deal with dependencies on flex-tree implementation.
26
25
  // eslint-disable-next-line import/no-internal-modules
27
26
  const lazyNode_js_1 = require("../../feature-libraries/flex-tree/lazyNode.js");
@@ -145,7 +144,7 @@ class TreeNodeKernel {
145
144
  if (isHydrated(__classPrivateFieldGet(this, _TreeNodeKernel_hydrationState, "f"))) {
146
145
  // This can't be cached on this.#hydrated during hydration since initial tree is hydrated before the context is cached on the anchorSet.
147
146
  return (__classPrivateFieldGet(this, _TreeNodeKernel_hydrationState, "f")?.anchorNode.anchorSet.slots.get(context_js_1.SimpleContextSlot) ??
148
- (0, index_js_3.fail)(0xb40 /* missing simple-tree context */));
147
+ (0, internal_1.fail)(0xb40 /* missing simple-tree context */));
149
148
  }
150
149
  return this.initialContext;
151
150
  }
@@ -250,7 +249,7 @@ class TreeNodeKernel {
250
249
  }
251
250
  else {
252
251
  // ...otherwise, the flex node must be created
253
- const context = anchorNode.anchorSet.slots.get(index_js_2.ContextSlot) ?? (0, index_js_3.fail)(0xb41 /* missing context */);
252
+ const context = anchorNode.anchorSet.slots.get(index_js_2.ContextSlot) ?? (0, internal_1.fail)(0xb41 /* missing context */);
254
253
  const cursor = context.checkout.forest.allocateCursor("getFlexNode");
255
254
  context.checkout.forest.moveCursorToPath(anchorNode, cursor);
256
255
  __classPrivateFieldGet(this, _TreeNodeKernel_hydrationState, "f").innerNode = (0, lazyNode_js_1.makeTree)(context, cursor);
@@ -277,7 +276,7 @@ class TreeNodeKernel {
277
276
  anchorProxy(anchors, path) {
278
277
  (0, internal_1.assert)(!anchorForgetters.has(this.node), 0x91c /* Proxy anchor should not be set twice */);
279
278
  const anchor = anchors.track(path);
280
- const anchorNode = anchors.locate(anchor) ?? (0, index_js_3.fail)(0xb42 /* Expected anchor node to be present */);
279
+ const anchorNode = anchors.locate(anchor) ?? (0, internal_1.fail)(0xb42 /* Expected anchor node to be present */);
281
280
  this.hydrate(anchorNode);
282
281
  const forget = () => {
283
282
  if (anchors.locate(anchor)) {
@@ -336,18 +335,25 @@ function tryDisposeTreeNode(anchorNode) {
336
335
  }
337
336
  exports.tryDisposeTreeNode = tryDisposeTreeNode;
338
337
  /**
339
- * Lookup a TreeNodeSchema from a Hydrated FlexTreeNode.
340
- * @privateRemarks
341
- * This provides a way to access simple tree schema from the flex tree without depending on {@link FlexTreeSchema} which is in the process of being removed.
342
- * This is currently limited to hydrated nodes: this limitation will have to be fixed before {@link FlexTreeSchema} can be fully removed.
338
+ * Gets the {@link TreeNodeSchema} for the {@link InnerNode}.
343
339
  */
344
- function getTreeNodeSchemaFromHydratedFlexNode(flexNode) {
345
- (0, internal_1.assert)(flexNode.context.isHydrated(), 0xa56 /* getTreeNodeSchemaFromHydratedFlexNode only allows hydrated flex tree nodes */);
346
- const context = flexNode.anchorNode.anchorSet.slots.get(context_js_1.SimpleContextSlot) ??
347
- (0, index_js_3.fail)(0xb43 /* Missing SimpleContextSlot */);
348
- return context.schema.get(flexNode.schema) ?? (0, index_js_3.fail)(0xb44 /* Missing schema */);
340
+ function getSimpleNodeSchemaFromInnerNode(innerNode) {
341
+ const context = getSimpleContextFromInnerNode(innerNode);
342
+ return context.schema.get(innerNode.schema) ?? (0, internal_1.fail)(0xb3f /* missing schema from context */);
349
343
  }
350
- exports.getTreeNodeSchemaFromHydratedFlexNode = getTreeNodeSchemaFromHydratedFlexNode;
344
+ exports.getSimpleNodeSchemaFromInnerNode = getSimpleNodeSchemaFromInnerNode;
345
+ /**
346
+ * Gets the {@link Context} for the {@link InnerNode}.
347
+ */
348
+ function getSimpleContextFromInnerNode(innerNode) {
349
+ if (innerNode instanceof unhydratedFlexTree_js_1.UnhydratedFlexTreeNode) {
350
+ return innerNode.simpleContext;
351
+ }
352
+ const context = innerNode.anchorNode.anchorSet.slots.get(context_js_1.SimpleContextSlot);
353
+ (0, internal_1.assert)(context !== undefined, 0xa55 /* missing simple tree context */);
354
+ return context;
355
+ }
356
+ exports.getSimpleContextFromInnerNode = getSimpleContextFromInnerNode;
351
357
  /**
352
358
  * Retrieves the flex node associated with the given target via {@link setInnerNode}.
353
359
  * @remarks
@@ -370,7 +376,7 @@ function flexNodeFromAnchor(anchorNode) {
370
376
  if (flexNode !== undefined) {
371
377
  return flexNode; // If it does have a flex node, return it...
372
378
  } // ...otherwise, the flex node must be created
373
- const context = anchorNode.anchorSet.slots.get(index_js_2.ContextSlot) ?? (0, index_js_3.fail)(0xb45 /* missing context */);
379
+ const context = anchorNode.anchorSet.slots.get(index_js_2.ContextSlot) ?? (0, internal_1.fail)(0xb45 /* missing context */);
374
380
  const cursor = context.checkout.forest.allocateCursor("getFlexNode");
375
381
  context.checkout.forest.moveCursorToPath(anchorNode, cursor);
376
382
  const newFlexNode = (0, lazyNode_js_1.makeTree)(context, cursor);
@@ -386,10 +392,20 @@ function treeNodeFromAnchor(anchorNode) {
386
392
  return cached;
387
393
  }
388
394
  const flexNode = flexNodeFromAnchor(anchorNode);
389
- const classSchema = getTreeNodeSchemaFromHydratedFlexNode(flexNode);
390
- return typeof classSchema === "function"
391
- ? new classSchema(flexNode)
392
- : classSchema.create(flexNode);
395
+ return createTreeNodeFromInner(flexNode);
393
396
  }
394
397
  exports.treeNodeFromAnchor = treeNodeFromAnchor;
398
+ /**
399
+ * Constructs a TreeNode from an InnerNode.
400
+ * @remarks
401
+ * This does not do caching or validation: caller must ensure duplicate nodes for a given inner node are not created, and that the inner node is valid.
402
+ */
403
+ function createTreeNodeFromInner(innerNode) {
404
+ const classSchema = getSimpleNodeSchemaFromInnerNode(innerNode);
405
+ const internal = innerNode;
406
+ return typeof classSchema === "function"
407
+ ? new classSchema(internal)
408
+ : classSchema.create(internal);
409
+ }
410
+ exports.createTreeNodeFromInner = createTreeNodeFromInner;
395
411
  //# sourceMappingURL=treeNodeKernel.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"treeNodeKernel.js","sourceRoot":"","sources":["../../../src/simple-tree/core/treeNodeKernel.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;;;AAEH,kEAAmE;AACnE,+DAA6D;AAG7D,kDAO6B;AAC7B,+DAS0C;AAE1C,kDAA2C;AAC3C,0EAA0E;AAC1E,sDAAsD;AACtD,+EAAyE;AACzE,6CAAqF;AACrF,mEAAiE;AAEjE,MAAM,gBAAgB,GAAG,IAAI,OAAO,EAA4B,CAAC;AAEjE,SAAgB,SAAS,CAAC,IAAc;IACvC,MAAM,MAAM,GAAG,gBAAgB,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAC1C,IAAA,iBAAM,EAAC,MAAM,KAAK,SAAS,EAAE,KAAK,CAAC,uCAAuC,CAAC,CAAC;IAC5E,OAAO,MAAM,CAAC;AACf,CAAC;AAJD,8BAIC;AAED;;;;;;;;;;;;;GAaG;AACH,SAAgB,UAAU,CAAC,SAAkB;IAC5C,OAAO,gBAAgB,CAAC,GAAG,CAAC,SAAqB,CAAC,CAAC;AACpD,CAAC;AAFD,gCAEC;AAED;;;;;;GAMG;AACH,SAAgB,oBAAoB,CAAC,KAAc;IAClD,MAAM,MAAM,GAAG,gBAAgB,CAAC,GAAG,CAAC,KAAiB,CAAC,CAAC;IACvD,OAAO,MAAM,EAAE,MAAM,CAAC;AACvB,CAAC;AAHD,oDAGC;AAqBD,6EAA6E;AAC7E,SAAS,UAAU,CAAC,KAAqB;IACxC,OAAQ,KAAgC,CAAC,UAAU,KAAK,SAAS,CAAC;AACnE,CAAC;AAED;;;;GAIG;AACH,MAAa,cAAc;IA2B1B;;;;;;;OAOG;IACH,YACiB,IAAc,EACd,MAAsB,EACtC,SAAoB,EACH,cAAuB;QAHxB,SAAI,GAAJ,IAAI,CAAU;QACd,WAAM,GAAN,MAAM,CAAgB;QAErB,mB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ributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, Lazy } from \"@fluidframework/core-utils/internal\";\nimport { createEmitter } from \"@fluid-internal/client-utils\";\nimport type { Listenable, Off } from \"@fluidframework/core-interfaces\";\nimport type { InternalTreeNode, TreeNode, Unhydrated } from \"./types.js\";\nimport {\n\tanchorSlot,\n\ttype AnchorEvents,\n\ttype AnchorNode,\n\ttype AnchorSet,\n\ttype TreeValue,\n\ttype UpPath,\n} from \"../../core/index.js\";\nimport {\n\tassertFlexTreeEntityNotFreed,\n\tContextSlot,\n\tflexTreeSlot,\n\tisFreedSymbol,\n\tLazyEntity,\n\tTreeStatus,\n\ttreeStatusFromAnchorCache,\n\ttype FlexTreeNode,\n} from \"../../feature-libraries/index.js\";\nimport type { TreeNodeSchema } from \"./treeNodeSchema.js\";\nimport { fail } from \"../../util/index.js\";\n// TODO: decide how to deal with dependencies on flex-tree implementation.\n// eslint-disable-next-line import/no-internal-modules\nimport { makeTree } from \"../../feature-libraries/flex-tree/lazyNode.js\";\nimport { SimpleContextSlot, type Context, type HydratedContext } from \"./context.js\";\nimport { UnhydratedFlexTreeNode } from \"./unhydratedFlexTree.js\";\n\nconst treeNodeToKernel = new WeakMap<TreeNode, TreeNodeKernel>();\n\nexport function getKernel(node: TreeNode): TreeNodeKernel {\n\tconst kernel = treeNodeToKernel.get(node);\n\tassert(kernel !== undefined, 0x9b1 /* Expected tree node to have kernel */);\n\treturn kernel;\n}\n\n/**\n * Detects if the given 'candidate' is a TreeNode.\n *\n * @remarks\n * Supports both Hydrated and {@link Unhydrated} TreeNodes, both of which return true.\n *\n * Because the common usage is to check if a value being inserted/set is a TreeNode,\n * this function permits calling with primitives as well as objects.\n *\n * Primitives will always return false (as they are copies of data, not references to nodes).\n *\n * @param candidate - Value which may be a TreeNode\n * @returns true if the given 'candidate' is a hydrated TreeNode.\n */\nexport function isTreeNode(candidate: unknown): candidate is TreeNode | Unhydrated<TreeNode> {\n\treturn treeNodeToKernel.has(candidate as TreeNode);\n}\n\n/**\n * Returns a schema for a value if the value is a {@link TreeNode}.\n *\n * Returns undefined for other values.\n * @remarks\n * Does not give schema for a {@link TreeLeafValue}.\n */\nexport function tryGetTreeNodeSchema(value: unknown): undefined | TreeNodeSchema {\n\tconst kernel = treeNodeToKernel.get(value as TreeNode);\n\treturn kernel?.schema;\n}\n\n/** The {@link HydrationState} of a {@link TreeNodeKernel} before the kernel is hydrated */\ninterface UnhydratedState {\n\toff: Off;\n\tinnerNode: UnhydratedFlexTreeNode;\n}\n\n/** The {@link HydrationState} of a {@link TreeNodeKernel} after the kernel is hydrated */\ninterface HydratedState {\n\t/** The flex node for this kernel (lazy - undefined if it has not yet been demanded) */\n\tinnerNode?: FlexTreeNode;\n\t/** The {@link AnchorNode} that this node is associated with. */\n\tanchorNode: AnchorNode;\n\t/** All {@link Off | event deregistration functions} that should be run when the kernel is disposed. */\n\toffAnchorNode: Set<Off>;\n}\n\n/** State within a {@link TreeNodeKernel} that is related to the hydration process */\ntype HydrationState = UnhydratedState | HydratedState;\n\n/** True if and only if the given {@link HydrationState} is post-hydration */\nfunction isHydrated(state: HydrationState): state is HydratedState {\n\treturn (state as Partial<HydratedState>).anchorNode !== undefined;\n}\n\n/**\n * Contains state and an internal API for managing {@link TreeNode}s.\n * @remarks All {@link TreeNode}s have an associated kernel object.\n * The kernel has the same lifetime as the node and spans both its unhydrated and hydrated states.\n */\nexport class TreeNodeKernel {\n\tprivate disposed = false;\n\n\t/**\n\t * Generation number which is incremented any time we have an edit on the node.\n\t * Used during iteration to make sure there has been no edits that were concurrently made.\n\t * @remarks\n\t * This is updated monotonically by this class when edits are applied.\n\t * TODO: update this when applying edits to unhydrated trees.\n\t *\n\t * If TypeScript supported making this immutable from outside the class without making it readonly from inside, that would be used here,\n\t * but they only way to do that is add a separate public accessor and make it private, which was deemed not worth the boilerplate, runtime overhead and bundle size.\n\t */\n\tpublic generationNumber: number = 0;\n\n\t#hydrationState: HydrationState;\n\n\t/**\n\t * Events registered before hydration.\n\t * @remarks\n\t * Since these are usually not used, they are allocated lazily as an optimization.\n\t * The laziness also avoids extra forwarding overhead for events from this kernel's anchor node and also avoids registering for events that are unneeded.\n\t * This means optimizations like skipping processing data in subtrees where no subtreeChanged events are subscribed to would be able to work,\n\t * since the kernel does not unconditionally subscribe to those events (like a design which simply forwards all events would).\n\t */\n\treadonly #unhydratedEvents = new Lazy(createEmitter<KernelEvents>);\n\n\t/**\n\t * Create a TreeNodeKernel which can be looked up with {@link getKernel}.\n\t *\n\t * @param initialContext - context from when this node was originally crated.\n\t * @param innerNode - When unhydrated/raw or marinated the MapTreeNode. FlexTreeNode when cooked.\n\t * @remarks\n\t * Exactly one kernel per TreeNode should be created.\n\t */\n\tpublic constructor(\n\t\tpublic readonly node: TreeNode,\n\t\tpublic readonly schema: TreeNodeSchema,\n\t\tinnerNode: InnerNode,\n\t\tprivate readonly initialContext: Context,\n\t) {\n\t\tassert(!treeNodeToKernel.has(node), 0xa1a /* only one kernel per node can be made */);\n\t\ttreeNodeToKernel.set(node, this);\n\n\t\tif (innerNode instanceof UnhydratedFlexTreeNode) {\n\t\t\t// Unhydrated case\n\t\t\tunhydratedFlexTreeNodeToTreeNodeInternal.set(innerNode, node);\n\t\t\t// Register for change events from the unhydrated flex node.\n\t\t\t// These will be fired if the unhydrated node is edited, and will also be forwarded later to the hydrated node.\n\t\t\tthis.#hydrationState = {\n\t\t\t\tinnerNode,\n\t\t\t\toff: innerNode.events.on(\"childrenChangedAfterBatch\", ({ changedFields }) => {\n\t\t\t\t\tthis.#unhydratedEvents.value.emit(\"childrenChangedAfterBatch\", {\n\t\t\t\t\t\tchangedFields,\n\t\t\t\t\t});\n\n\t\t\t\t\tlet n: UnhydratedFlexTreeNode | undefined = innerNode;\n\t\t\t\t\twhile (n !== undefined) {\n\t\t\t\t\t\tconst treeNode = unhydratedFlexTreeNodeToTreeNodeInternal.get(n);\n\t\t\t\t\t\tif (treeNode !== undefined) {\n\t\t\t\t\t\t\tconst kernel = getKernel(treeNode);\n\t\t\t\t\t\t\tkernel.#unhydratedEvents.value.emit(\"subtreeChangedAfterBatch\");\n\t\t\t\t\t\t}\n\t\t\t\t\t\t// This cast is safe because the parent (if it exists) of an unhydrated flex node is always another unhydrated flex node.\n\t\t\t\t\t\tn = n.parentField.parent.parent as UnhydratedFlexTreeNode | undefined;\n\t\t\t\t\t}\n\t\t\t\t}),\n\t\t\t};\n\t\t} else {\n\t\t\t// Hydrated case\n\t\t\tconst { anchorNode } = innerNode;\n\t\t\tassert(\n\t\t\t\t!anchorNode.slots.has(proxySlot),\n\t\t\t\t0x7f5 /* Cannot associate an flex node with multiple simple-tree nodes */,\n\t\t\t);\n\t\t\tthis.#hydrationState = this.createHydratedState(anchorNode);\n\t\t}\n\t}\n\n\tpublic get context(): Context {\n\t\tif (isHydrated(this.#hydrationState)) {\n\t\t\t// This can't be cached on this.#hydrated during hydration since initial tree is hydrated before the context is cached on the anchorSet.\n\t\t\treturn (\n\t\t\t\tthis.#hydrationState?.anchorNode.anchorSet.slots.get(SimpleContextSlot) ??\n\t\t\t\tfail(0xb40 /* missing simple-tree context */)\n\t\t\t);\n\t\t}\n\t\treturn this.initialContext;\n\t}\n\n\t/**\n\t * Transition from {@link Unhydrated} to hydrated.\n\t * Bi-directionally associates the given hydrated TreeNode to the given anchor node.\n\t * @remarks\n\t * Happens at most once for any given node.\n\t * Cleans up mappings to {@link UnhydratedFlexTreeNode} - it is assumed that they are no longer needed once the proxy has an anchor node.\n\t */\n\tprivate hydrate(anchorNode: AnchorNode): void {\n\t\tassert(!this.disposed, 0xa2a /* cannot hydrate a disposed node */);\n\t\tassert(!isHydrated(this.#hydrationState), 0xa2b /* hydration should only happen once */);\n\t\tunhydratedFlexTreeNodeToTreeNodeInternal.delete(this.#hydrationState.innerNode);\n\t\tthis.#hydrationState = this.createHydratedState(anchorNode);\n\n\t\t// If needed, register forwarding emitters for events from before hydration\n\t\tif (this.#unhydratedEvents.evaluated) {\n\t\t\tconst events = this.#unhydratedEvents.value;\n\t\t\tfor (const eventName of kernelEvents) {\n\t\t\t\tif (events.hasListeners(eventName)) {\n\t\t\t\t\tthis.#hydrationState.offAnchorNode.add(\n\t\t\t\t\t\t// Argument is forwarded between matching events, so the type should be correct.\n\t\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t\t\t\t\t\tanchorNode.events.on(eventName, (arg: any) => events.emit(eventName, arg)),\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate createHydratedState(anchorNode: AnchorNode): HydratedState {\n\t\tanchorNode.slots.set(proxySlot, this.node);\n\t\treturn {\n\t\t\tanchorNode,\n\t\t\toffAnchorNode: new Set([\n\t\t\t\tanchorNode.events.on(\"afterDestroy\", () => this.dispose()),\n\t\t\t\t// TODO: this should be triggered on change even for unhydrated nodes.\n\t\t\t\tanchorNode.events.on(\"childrenChanging\", () => {\n\t\t\t\t\tthis.generationNumber += 1;\n\t\t\t\t}),\n\t\t\t]),\n\t\t};\n\t}\n\n\tpublic getStatus(): TreeStatus {\n\t\tif (this.disposed) {\n\t\t\treturn TreeStatus.Deleted;\n\t\t}\n\t\tif (!isHydrated(this.#hydrationState)) {\n\t\t\treturn TreeStatus.New;\n\t\t}\n\n\t\t// TODO: Replace this check with the proper check against the cursor state when the cursor becomes part of the kernel\n\t\tconst flex = this.#hydrationState.anchorNode.slots.get(flexTreeSlot);\n\t\tif (flex !== undefined) {\n\t\t\tassert(flex instanceof LazyEntity, 0x9b4 /* Unexpected flex node implementation */);\n\t\t\tif (flex[isFreedSymbol]()) {\n\t\t\t\treturn TreeStatus.Deleted;\n\t\t\t}\n\t\t}\n\n\t\treturn treeStatusFromAnchorCache(this.#hydrationState.anchorNode);\n\t}\n\n\tpublic get events(): Listenable<KernelEvents> {\n\t\t// Retrieve the correct events object based on whether this node is pre or post hydration.\n\t\treturn isHydrated(this.#hydrationState)\n\t\t\t? this.#hydrationState.anchorNode.events\n\t\t\t: this.#unhydratedEvents.value;\n\t}\n\n\tpublic dispose(): void {\n\t\tthis.disposed = true;\n\t\tif (isHydrated(this.#hydrationState)) {\n\t\t\tfor (const off of this.#hydrationState.offAnchorNode) {\n\t\t\t\toff();\n\t\t\t}\n\t\t}\n\t\t// TODO: go to the context and remove myself from withAnchors\n\t}\n\n\tpublic isHydrated(): this is { anchorNode: AnchorNode; context: HydratedContext } {\n\t\treturn isHydrated(this.#hydrationState);\n\t}\n\n\tpublic get anchorNode(): AnchorNode | undefined {\n\t\treturn isHydrated(this.#hydrationState) ? this.#hydrationState.anchorNode : undefined;\n\t}\n\n\t/**\n\t * Retrieves the flex node associated with the given target via {@link setInnerNode}.\n\t * @remarks\n\t * For {@link Unhydrated} nodes, this returns the MapTreeNode.\n\t *\n\t * For hydrated nodes it returns a FlexTreeNode backed by the forest.\n\t * Note that for \"marinated\" nodes, this FlexTreeNode exists and returns it: it does not return the MapTreeNode which is the current InnerNode.\n\t */\n\tpublic getOrCreateInnerNode(allowFreed = false): InnerNode {\n\t\tif (!isHydrated(this.#hydrationState)) {\n\t\t\treturn this.#hydrationState.innerNode; // Unhydrated case\n\t\t}\n\n\t\tif (this.#hydrationState.innerNode !== undefined) {\n\t\t\treturn this.#hydrationState.innerNode; // Cooked case\n\t\t}\n\n\t\t// Marinated case -> cooked\n\t\tconst anchorNode = this.#hydrationState.anchorNode;\n\t\t// The proxy is bound to an anchor node, but it may or may not have an actual flex node yet\n\t\tconst flexNode = anchorNode.slots.get(flexTreeSlot);\n\t\tif (flexNode !== undefined) {\n\t\t\t// If the flex node already exists, use it...\n\t\t\tthis.#hydrationState.innerNode = flexNode;\n\t\t} else {\n\t\t\t// ...otherwise, the flex node must be created\n\t\t\tconst context =\n\t\t\t\tanchorNode.anchorSet.slots.get(ContextSlot) ?? fail(0xb41 /* missing context */);\n\t\t\tconst cursor = context.checkout.forest.allocateCursor(\"getFlexNode\");\n\t\t\tcontext.checkout.forest.moveCursorToPath(anchorNode, cursor);\n\t\t\tthis.#hydrationState.innerNode = makeTree(context, cursor);\n\t\t\tcursor.free();\n\t\t\t// Calling this is a performance improvement, however, do this only after demand to avoid momentarily having no anchors to anchorNode\n\t\t\tanchorForgetters?.get(this.node)?.();\n\t\t\tif (!allowFreed) {\n\t\t\t\tassertFlexTreeEntityNotFreed(this.#hydrationState.innerNode);\n\t\t\t}\n\t\t}\n\n\t\treturn this.#hydrationState.innerNode;\n\t}\n\n\t/**\n\t * Creates an anchor node and associates it with the given proxy.\n\t * @privateRemarks\n\t * Use `forgetters` to cleanup the anchor allocated by this function once the anchor is no longer needed.\n\t * In practice, this happens when either the anchor node is destroyed, or another anchor to the same node is created by a new flex node.\n\t *\n\t * The FlexTreeNode holds a reference to the same anchor, and has a lifetime at least as long as the simple-tree,\n\t * so this would be unnecessary except for the case of \"marinated\" nodes, which have an anchor,\n\t * but might not have a FlexTreeNode.\n\t * Handling this case is an optimization assuming that this extra anchor reference is cheaper than eagerly creating FlexTreeNodes.\n\t */\n\tpublic anchorProxy(anchors: AnchorSet, path: UpPath): AnchorNode {\n\t\tassert(!anchorForgetters.has(this.node), 0x91c /* Proxy anchor should not be set twice */);\n\t\tconst anchor = anchors.track(path);\n\t\tconst anchorNode =\n\t\t\tanchors.locate(anchor) ?? fail(0xb42 /* Expected anchor node to be present */);\n\t\tthis.hydrate(anchorNode);\n\t\tconst forget = (): void => {\n\t\t\tif (anchors.locate(anchor)) {\n\t\t\t\tanchors.forget(anchor);\n\t\t\t}\n\t\t\tanchorForgetters.delete(this.node);\n\t\t\toff();\n\t\t};\n\t\tanchorForgetters.set(this.node, forget);\n\t\tconst off = anchorNode.events.on(\"afterDestroy\", forget);\n\t\treturn anchorNode;\n\t}\n\n\t/**\n\t * Retrieves the InnerNode associated with the given target via {@link setInnerNode}, if any.\n\t * @remarks\n\t * If `target` is an unhydrated node, returns its UnhydratedFlexTreeNode.\n\t * If `target` is a cooked node (or marinated but a FlexTreeNode exists) returns the FlexTreeNode.\n\t * If the target is a marinated node with no FlexTreeNode for its anchor, returns undefined.\n\t */\n\tpublic tryGetInnerNode(): InnerNode | undefined {\n\t\tif (isHydrated(this.#hydrationState)) {\n\t\t\treturn (\n\t\t\t\tthis.#hydrationState.innerNode ??\n\t\t\t\tthis.#hydrationState.anchorNode.slots.get(flexTreeSlot)\n\t\t\t);\n\t\t}\n\n\t\treturn this.#hydrationState.innerNode;\n\t}\n}\n\n/**\n * Used by {@link anchorProxy} as an optimization to ensure that only one anchor is remembered at a time for a given anchor node\n */\nconst anchorForgetters = new WeakMap<TreeNode, () => void>();\n\nconst kernelEvents = [\"childrenChangedAfterBatch\", \"subtreeChangedAfterBatch\"] as const;\n\ntype KernelEvents = Pick<AnchorEvents, (typeof kernelEvents)[number]>;\n\n/**\n * For \"cooked\" nodes this is a FlexTreeNode thats a projection of forest content.\n * For {@link Unhydrated} nodes this is a MapTreeNode.\n * For \"marinated\" nodes, some code (ex: getOrCreateInnerNode) returns the FlexTreeNode thats a projection of forest content, and some code (ex: tryGetInnerNode) returns undefined.\n *\n * @remarks\n * Currently MapTreeNode extends FlexTreeNode, and most code which can work with either just uses FlexTreeNode.\n * TODO: Code should be migrating toward using this type to distinguish to two use-cases.\n *\n * TODO: The inconsistent handling of \"marinated\" cases should be cleaned up.\n * Maybe getOrCreateInnerNode should cook marinated nodes so they have a proper InnerNode?\n */\nexport type InnerNode = FlexTreeNode | UnhydratedFlexTreeNode;\n\n/**\n * Associates a given {@link UnhydratedFlexTreeNode} with a {@link TreeNode}.\n */\nconst unhydratedFlexTreeNodeToTreeNodeInternal = new WeakMap<\n\tUnhydratedFlexTreeNode,\n\tTreeNode\n>();\n/**\n * Retrieves the {@link TreeNode} associated with the given {@link UnhydratedFlexTreeNode} if any.\n */\nexport const unhydratedFlexTreeNodeToTreeNode =\n\tunhydratedFlexTreeNodeToTreeNodeInternal as Pick<\n\t\tWeakMap<UnhydratedFlexTreeNode, TreeNode>,\n\t\t\"get\"\n\t>;\n\n/**\n * An anchor slot which associates an anchor with its corresponding TreeNode, if there is one.\n * @remarks\n * For this to work, we have to require that there is at most a single view using a given AnchorSet.\n * FlexTree already has this assumption, and we also assume there is a single simple-tree per FlexTree, so this is valid.\n */\nexport const proxySlot = anchorSlot<TreeNode>();\n\nexport function tryDisposeTreeNode(anchorNode: AnchorNode): void {\n\tconst treeNode = anchorNode.slots.get(proxySlot);\n\tif (treeNode !== undefined) {\n\t\tconst kernel = getKernel(treeNode);\n\t\tkernel.dispose();\n\t}\n}\n\n/**\n * Lookup a TreeNodeSchema from a Hydrated FlexTreeNode.\n * @privateRemarks\n * This provides a way to access simple tree schema from the flex tree without depending on {@link FlexTreeSchema} which is in the process of being removed.\n * This is currently limited to hydrated nodes: this limitation will have to be fixed before {@link FlexTreeSchema} can be fully removed.\n */\nexport function getTreeNodeSchemaFromHydratedFlexNode(flexNode: FlexTreeNode): TreeNodeSchema {\n\tassert(\n\t\tflexNode.context.isHydrated(),\n\t\t0xa56 /* getTreeNodeSchemaFromHydratedFlexNode only allows hydrated flex tree nodes */,\n\t);\n\n\tconst context =\n\t\tflexNode.anchorNode.anchorSet.slots.get(SimpleContextSlot) ??\n\t\tfail(0xb43 /* Missing SimpleContextSlot */);\n\n\treturn context.schema.get(flexNode.schema) ?? fail(0xb44 /* Missing schema */);\n}\n\n/**\n * Retrieves the flex node associated with the given target via {@link setInnerNode}.\n * @remarks\n * For {@link Unhydrated} nodes, this returns the MapTreeNode.\n *\n * For hydrated nodes it returns a FlexTreeNode backed by the forest.\n * Note that for \"marinated\" nodes, this FlexTreeNode exists and returns it: it does not return the MapTreeNode which is the current InnerNode.\n */\nexport function getOrCreateInnerNode(treeNode: TreeNode, allowFreed = false): InnerNode {\n\tconst kernel = getKernel(treeNode);\n\treturn kernel.getOrCreateInnerNode(allowFreed);\n}\n\n/**\n * Gets a flex node from an anchor node\n */\nfunction flexNodeFromAnchor(anchorNode: AnchorNode): FlexTreeNode {\n\t// the proxy is bound to an anchor node, but it may or may not have an actual flex node yet\n\tconst flexNode = anchorNode.slots.get(flexTreeSlot);\n\tif (flexNode !== undefined) {\n\t\treturn flexNode; // If it does have a flex node, return it...\n\t} // ...otherwise, the flex node must be created\n\tconst context =\n\t\tanchorNode.anchorSet.slots.get(ContextSlot) ?? fail(0xb45 /* missing context */);\n\tconst cursor = context.checkout.forest.allocateCursor(\"getFlexNode\");\n\tcontext.checkout.forest.moveCursorToPath(anchorNode, cursor);\n\tconst newFlexNode = makeTree(context, cursor);\n\tcursor.free();\n\treturn newFlexNode;\n}\n\n/**\n * Gets a tree node from an anchor node\n */\nexport function treeNodeFromAnchor(anchorNode: AnchorNode): TreeNode | TreeValue {\n\tconst cached = anchorNode.slots.get(proxySlot);\n\tif (cached !== undefined) {\n\t\treturn cached;\n\t}\n\n\tconst flexNode = flexNodeFromAnchor(anchorNode);\n\tconst classSchema = getTreeNodeSchemaFromHydratedFlexNode(flexNode);\n\treturn typeof classSchema === \"function\"\n\t\t? new classSchema(flexNode as unknown as InternalTreeNode)\n\t\t: (classSchema as { create(data: FlexTreeNode): TreeValue }).create(flexNode);\n}\n"]}
1
+ {"version":3,"file":"treeNodeKernel.js","sourceRoot":"","sources":["../../../src/simple-tree/core/treeNodeKernel.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;;;AAEH,kEAAyE;AACzE,+DAA6D;AAG7D,kDAO6B;AAC7B,+DAS0C;AAE1C,0EAA0E;AAC1E,sDAAsD;AACtD,+EAAyE;AACzE,6CAAqF;AACrF,mEAAiE;AAEjE,MAAM,gBAAgB,GAAG,IAAI,OAAO,EAA4B,CAAC;AAEjE,SAAgB,SAAS,CAAC,IAAc;IACvC,MAAM,MAAM,GAAG,gBAAgB,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAC1C,IAAA,iBAAM,EAAC,MAAM,KAAK,SAAS,EAAE,KAAK,CAAC,uCAAuC,CAAC,CAAC;IAC5E,OAAO,MAAM,CAAC;AACf,CAAC;AAJD,8BAIC;AAED;;;;;;;;;;;;;GAaG;AACH,S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,CAAC,MAAM,CAAC,gBAAgB,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;IAC7D,MAAM,WAAW,GAAG,IAAA,sBAAQ,EAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IAC9C,MAAM,CAAC,IAAI,EAAE,CAAC;IACd,OAAO,WAAW,CAAC;AACpB,CAAC;AAED;;GAEG;AACH,SAAgB,kBAAkB,CAAC,UAAsB;IACxD,MAAM,MAAM,GAAG,UAAU,CAAC,KAAK,CAAC,GAAG,CAAC,iBAAS,CAAC,CAAC;IAC/C,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;QAC1B,OAAO,MAAM,CAAC;IACf,CAAC;IAED,MAAM,QAAQ,GAAG,kBAAkB,CAAC,UAAU,CAAC,CAAC;IAChD,OAAO,uBAAuB,CAAC,QAAQ,CAAC,CAAC;AAC1C,CAAC;AARD,gDAQC;AAED;;;;GAIG;AACH,SAAgB,uBAAuB,CAAC,SAAoB;IAC3D,MAAM,WAAW,GAAG,gCAAgC,CAAC,SAAS,CAAC,CAAC;IAChE,MAAM,QAAQ,GAAG,SAAwC,CAAC;IAC1D,OAAO,OAAO,WAAW,KAAK,UAAU;QACvC,CAAC,CAAC,IAAI,WAAW,CAAC,QAAQ,CAAC;QAC3B,CAAC,CAAE,WAAwE,CAAC,MAAM,CAChF,QAAQ,CACR,CAAC;AACL,CAAC;AARD,0DAQC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, Lazy, fail } from \"@fluidframework/core-utils/internal\";\nimport { createEmitter } from \"@fluid-internal/client-utils\";\nimport type { Listenable, Off } from \"@fluidframework/core-interfaces\";\nimport type { InternalTreeNode, TreeNode, Unhydrated } from \"./types.js\";\nimport {\n\tanchorSlot,\n\ttype AnchorEvents,\n\ttype AnchorNode,\n\ttype AnchorSet,\n\ttype TreeValue,\n\ttype UpPath,\n} from \"../../core/index.js\";\nimport {\n\tassertFlexTreeEntityNotFreed,\n\tContextSlot,\n\tflexTreeSlot,\n\tisFreedSymbol,\n\tLazyEntity,\n\tTreeStatus,\n\ttreeStatusFromAnchorCache,\n\ttype FlexTreeNode,\n} from \"../../feature-libraries/index.js\";\nimport type { TreeNodeSchema } from \"./treeNodeSchema.js\";\n// TODO: decide how to deal with dependencies on flex-tree implementation.\n// eslint-disable-next-line import/no-internal-modules\nimport { makeTree } from \"../../feature-libraries/flex-tree/lazyNode.js\";\nimport { SimpleContextSlot, type Context, type HydratedContext } from \"./context.js\";\nimport { UnhydratedFlexTreeNode } from \"./unhydratedFlexTree.js\";\n\nconst treeNodeToKernel = new WeakMap<TreeNode, TreeNodeKernel>();\n\nexport function getKernel(node: TreeNode): TreeNodeKernel {\n\tconst kernel = treeNodeToKernel.get(node);\n\tassert(kernel !== undefined, 0x9b1 /* Expected tree node to have kernel */);\n\treturn kernel;\n}\n\n/**\n * Detects if the given 'candidate' is a TreeNode.\n *\n * @remarks\n * Supports both Hydrated and {@link Unhydrated} TreeNodes, both of which return true.\n *\n * Because the common usage is to check if a value being inserted/set is a TreeNode,\n * this function permits calling with primitives as well as objects.\n *\n * Primitives will always return false (as they are copies of data, not references to nodes).\n *\n * @param candidate - Value which may be a TreeNode\n * @returns true if the given 'candidate' is a hydrated TreeNode.\n */\nexport function isTreeNode(candidate: unknown): candidate is TreeNode | Unhydrated<TreeNode> {\n\treturn treeNodeToKernel.has(candidate as TreeNode);\n}\n\n/**\n * Returns a schema for a value if the value is a {@link TreeNode}.\n *\n * Returns undefined for other values.\n * @remarks\n * Does not give schema for a {@link TreeLeafValue}.\n */\nexport function tryGetTreeNodeSchema(value: unknown): undefined | TreeNodeSchema {\n\tconst kernel = treeNodeToKernel.get(value as TreeNode);\n\treturn kernel?.schema;\n}\n\n/** The {@link HydrationState} of a {@link TreeNodeKernel} before the kernel is hydrated */\ninterface UnhydratedState {\n\toff: Off;\n\tinnerNode: UnhydratedFlexTreeNode;\n}\n\n/** The {@link HydrationState} of a {@link TreeNodeKernel} after the kernel is hydrated */\ninterface HydratedState {\n\t/** The flex node for this kernel (lazy - undefined if it has not yet been demanded) */\n\tinnerNode?: FlexTreeNode;\n\t/** The {@link AnchorNode} that this node is associated with. */\n\tanchorNode: AnchorNode;\n\t/** All {@link Off | event deregistration functions} that should be run when the kernel is disposed. */\n\toffAnchorNode: Set<Off>;\n}\n\n/** State within a {@link TreeNodeKernel} that is related to the hydration process */\ntype HydrationState = UnhydratedState | HydratedState;\n\n/** True if and only if the given {@link HydrationState} is post-hydration */\nfunction isHydrated(state: HydrationState): state is HydratedState {\n\treturn (state as Partial<HydratedState>).anchorNode !== undefined;\n}\n\n/**\n * Contains state and an internal API for managing {@link TreeNode}s.\n * @remarks All {@link TreeNode}s have an associated kernel object.\n * The kernel has the same lifetime as the node and spans both its unhydrated and hydrated states.\n */\nexport class TreeNodeKernel {\n\tprivate disposed = false;\n\n\t/**\n\t * Generation number which is incremented any time we have an edit on the node.\n\t * Used during iteration to make sure there has been no edits that were concurrently made.\n\t * @remarks\n\t * This is updated monotonically by this class when edits are applied.\n\t * TODO: update this when applying edits to unhydrated trees.\n\t *\n\t * If TypeScript supported making this immutable from outside the class without making it readonly from inside, that would be used here,\n\t * but they only way to do that is add a separate public accessor and make it private, which was deemed not worth the boilerplate, runtime overhead and bundle size.\n\t */\n\tpublic generationNumber: number = 0;\n\n\t#hydrationState: HydrationState;\n\n\t/**\n\t * Events registered before hydration.\n\t * @remarks\n\t * Since these are usually not used, they are allocated lazily as an optimization.\n\t * The laziness also avoids extra forwarding overhead for events from this kernel's anchor node and also avoids registering for events that are unneeded.\n\t * This means optimizations like skipping processing data in subtrees where no subtreeChanged events are subscribed to would be able to work,\n\t * since the kernel does not unconditionally subscribe to those events (like a design which simply forwards all events would).\n\t */\n\treadonly #unhydratedEvents = new Lazy(createEmitter<KernelEvents>);\n\n\t/**\n\t * Create a TreeNodeKernel which can be looked up with {@link getKernel}.\n\t *\n\t * @param initialContext - context from when this node was originally crated.\n\t * @param innerNode - When unhydrated/raw or marinated the MapTreeNode. FlexTreeNode when cooked.\n\t * @remarks\n\t * Exactly one kernel per TreeNode should be created.\n\t */\n\tpublic constructor(\n\t\tpublic readonly node: TreeNode,\n\t\tpublic readonly schema: TreeNodeSchema,\n\t\tinnerNode: InnerNode,\n\t\tprivate readonly initialContext: Context,\n\t) {\n\t\tassert(!treeNodeToKernel.has(node), 0xa1a /* only one kernel per node can be made */);\n\t\ttreeNodeToKernel.set(node, this);\n\n\t\tif (innerNode instanceof UnhydratedFlexTreeNode) {\n\t\t\t// Unhydrated case\n\t\t\tunhydratedFlexTreeNodeToTreeNodeInternal.set(innerNode, node);\n\t\t\t// Register for change events from the unhydrated flex node.\n\t\t\t// These will be fired if the unhydrated node is edited, and will also be forwarded later to the hydrated node.\n\t\t\tthis.#hydrationState = {\n\t\t\t\tinnerNode,\n\t\t\t\toff: innerNode.events.on(\"childrenChangedAfterBatch\", ({ changedFields }) => {\n\t\t\t\t\tthis.#unhydratedEvents.value.emit(\"childrenChangedAfterBatch\", {\n\t\t\t\t\t\tchangedFields,\n\t\t\t\t\t});\n\n\t\t\t\t\tlet n: UnhydratedFlexTreeNode | undefined = innerNode;\n\t\t\t\t\twhile (n !== undefined) {\n\t\t\t\t\t\tconst treeNode = unhydratedFlexTreeNodeToTreeNodeInternal.get(n);\n\t\t\t\t\t\tif (treeNode !== undefined) {\n\t\t\t\t\t\t\tconst kernel = getKernel(treeNode);\n\t\t\t\t\t\t\tkernel.#unhydratedEvents.value.emit(\"subtreeChangedAfterBatch\");\n\t\t\t\t\t\t}\n\t\t\t\t\t\t// This cast is safe because the parent (if it exists) of an unhydrated flex node is always another unhydrated flex node.\n\t\t\t\t\t\tn = n.parentField.parent.parent as UnhydratedFlexTreeNode | undefined;\n\t\t\t\t\t}\n\t\t\t\t}),\n\t\t\t};\n\t\t} else {\n\t\t\t// Hydrated case\n\t\t\tconst { anchorNode } = innerNode;\n\t\t\tassert(\n\t\t\t\t!anchorNode.slots.has(proxySlot),\n\t\t\t\t0x7f5 /* Cannot associate an flex node with multiple simple-tree nodes */,\n\t\t\t);\n\t\t\tthis.#hydrationState = this.createHydratedState(anchorNode);\n\t\t}\n\t}\n\n\tpublic get context(): Context {\n\t\tif (isHydrated(this.#hydrationState)) {\n\t\t\t// This can't be cached on this.#hydrated during hydration since initial tree is hydrated before the context is cached on the anchorSet.\n\t\t\treturn (\n\t\t\t\tthis.#hydrationState?.anchorNode.anchorSet.slots.get(SimpleContextSlot) ??\n\t\t\t\tfail(0xb40 /* missing simple-tree context */)\n\t\t\t);\n\t\t}\n\t\treturn this.initialContext;\n\t}\n\n\t/**\n\t * Transition from {@link Unhydrated} to hydrated.\n\t * Bi-directionally associates the given hydrated TreeNode to the given anchor node.\n\t * @remarks\n\t * Happens at most once for any given node.\n\t * Cleans up mappings to {@link UnhydratedFlexTreeNode} - it is assumed that they are no longer needed once the proxy has an anchor node.\n\t */\n\tprivate hydrate(anchorNode: AnchorNode): void {\n\t\tassert(!this.disposed, 0xa2a /* cannot hydrate a disposed node */);\n\t\tassert(!isHydrated(this.#hydrationState), 0xa2b /* hydration should only happen once */);\n\t\tunhydratedFlexTreeNodeToTreeNodeInternal.delete(this.#hydrationState.innerNode);\n\t\tthis.#hydrationState = this.createHydratedState(anchorNode);\n\n\t\t// If needed, register forwarding emitters for events from before hydration\n\t\tif (this.#unhydratedEvents.evaluated) {\n\t\t\tconst events = this.#unhydratedEvents.value;\n\t\t\tfor (const eventName of kernelEvents) {\n\t\t\t\tif (events.hasListeners(eventName)) {\n\t\t\t\t\tthis.#hydrationState.offAnchorNode.add(\n\t\t\t\t\t\t// Argument is forwarded between matching events, so the type should be correct.\n\t\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t\t\t\t\t\tanchorNode.events.on(eventName, (arg: any) => events.emit(eventName, arg)),\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate createHydratedState(anchorNode: AnchorNode): HydratedState {\n\t\tanchorNode.slots.set(proxySlot, this.node);\n\t\treturn {\n\t\t\tanchorNode,\n\t\t\toffAnchorNode: new Set([\n\t\t\t\tanchorNode.events.on(\"afterDestroy\", () => this.dispose()),\n\t\t\t\t// TODO: this should be triggered on change even for unhydrated nodes.\n\t\t\t\tanchorNode.events.on(\"childrenChanging\", () => {\n\t\t\t\t\tthis.generationNumber += 1;\n\t\t\t\t}),\n\t\t\t]),\n\t\t};\n\t}\n\n\tpublic getStatus(): TreeStatus {\n\t\tif (this.disposed) {\n\t\t\treturn TreeStatus.Deleted;\n\t\t}\n\t\tif (!isHydrated(this.#hydrationState)) {\n\t\t\treturn TreeStatus.New;\n\t\t}\n\n\t\t// TODO: Replace this check with the proper check against the cursor state when the cursor becomes part of the kernel\n\t\tconst flex = this.#hydrationState.anchorNode.slots.get(flexTreeSlot);\n\t\tif (flex !== undefined) {\n\t\t\tassert(flex instanceof LazyEntity, 0x9b4 /* Unexpected flex node implementation */);\n\t\t\tif (flex[isFreedSymbol]()) {\n\t\t\t\treturn TreeStatus.Deleted;\n\t\t\t}\n\t\t}\n\n\t\treturn treeStatusFromAnchorCache(this.#hydrationState.anchorNode);\n\t}\n\n\tpublic get events(): Listenable<KernelEvents> {\n\t\t// Retrieve the correct events object based on whether this node is pre or post hydration.\n\t\treturn isHydrated(this.#hydrationState)\n\t\t\t? this.#hydrationState.anchorNode.events\n\t\t\t: this.#unhydratedEvents.value;\n\t}\n\n\tpublic dispose(): void {\n\t\tthis.disposed = true;\n\t\tif (isHydrated(this.#hydrationState)) {\n\t\t\tfor (const off of this.#hydrationState.offAnchorNode) {\n\t\t\t\toff();\n\t\t\t}\n\t\t}\n\t\t// TODO: go to the context and remove myself from withAnchors\n\t}\n\n\tpublic isHydrated(): this is { anchorNode: AnchorNode; context: HydratedContext } {\n\t\treturn isHydrated(this.#hydrationState);\n\t}\n\n\tpublic get anchorNode(): AnchorNode | undefined {\n\t\treturn isHydrated(this.#hydrationState) ? this.#hydrationState.anchorNode : undefined;\n\t}\n\n\t/**\n\t * Retrieves the flex node associated with the given target via {@link setInnerNode}.\n\t * @remarks\n\t * For {@link Unhydrated} nodes, this returns the MapTreeNode.\n\t *\n\t * For hydrated nodes it returns a FlexTreeNode backed by the forest.\n\t * Note that for \"marinated\" nodes, this FlexTreeNode exists and returns it: it does not return the MapTreeNode which is the current InnerNode.\n\t */\n\tpublic getOrCreateInnerNode(allowFreed = false): InnerNode {\n\t\tif (!isHydrated(this.#hydrationState)) {\n\t\t\treturn this.#hydrationState.innerNode; // Unhydrated case\n\t\t}\n\n\t\tif (this.#hydrationState.innerNode !== undefined) {\n\t\t\treturn this.#hydrationState.innerNode; // Cooked case\n\t\t}\n\n\t\t// Marinated case -> cooked\n\t\tconst anchorNode = this.#hydrationState.anchorNode;\n\t\t// The proxy is bound to an anchor node, but it may or may not have an actual flex node yet\n\t\tconst flexNode = anchorNode.slots.get(flexTreeSlot);\n\t\tif (flexNode !== undefined) {\n\t\t\t// If the flex node already exists, use it...\n\t\t\tthis.#hydrationState.innerNode = flexNode;\n\t\t} else {\n\t\t\t// ...otherwise, the flex node must be created\n\t\t\tconst context =\n\t\t\t\tanchorNode.anchorSet.slots.get(ContextSlot) ?? fail(0xb41 /* missing context */);\n\t\t\tconst cursor = context.checkout.forest.allocateCursor(\"getFlexNode\");\n\t\t\tcontext.checkout.forest.moveCursorToPath(anchorNode, cursor);\n\t\t\tthis.#hydrationState.innerNode = makeTree(context, cursor);\n\t\t\tcursor.free();\n\t\t\t// Calling this is a performance improvement, however, do this only after demand to avoid momentarily having no anchors to anchorNode\n\t\t\tanchorForgetters?.get(this.node)?.();\n\t\t\tif (!allowFreed) {\n\t\t\t\tassertFlexTreeEntityNotFreed(this.#hydrationState.innerNode);\n\t\t\t}\n\t\t}\n\n\t\treturn this.#hydrationState.innerNode;\n\t}\n\n\t/**\n\t * Creates an anchor node and associates it with the given proxy.\n\t * @privateRemarks\n\t * Use `forgetters` to cleanup the anchor allocated by this function once the anchor is no longer needed.\n\t * In practice, this happens when either the anchor node is destroyed, or another anchor to the same node is created by a new flex node.\n\t *\n\t * The FlexTreeNode holds a reference to the same anchor, and has a lifetime at least as long as the simple-tree,\n\t * so this would be unnecessary except for the case of \"marinated\" nodes, which have an anchor,\n\t * but might not have a FlexTreeNode.\n\t * Handling this case is an optimization assuming that this extra anchor reference is cheaper than eagerly creating FlexTreeNodes.\n\t */\n\tpublic anchorProxy(anchors: AnchorSet, path: UpPath): AnchorNode {\n\t\tassert(!anchorForgetters.has(this.node), 0x91c /* Proxy anchor should not be set twice */);\n\t\tconst anchor = anchors.track(path);\n\t\tconst anchorNode =\n\t\t\tanchors.locate(anchor) ?? fail(0xb42 /* Expected anchor node to be present */);\n\t\tthis.hydrate(anchorNode);\n\t\tconst forget = (): void => {\n\t\t\tif (anchors.locate(anchor)) {\n\t\t\t\tanchors.forget(anchor);\n\t\t\t}\n\t\t\tanchorForgetters.delete(this.node);\n\t\t\toff();\n\t\t};\n\t\tanchorForgetters.set(this.node, forget);\n\t\tconst off = anchorNode.events.on(\"afterDestroy\", forget);\n\t\treturn anchorNode;\n\t}\n\n\t/**\n\t * Retrieves the InnerNode associated with the given target via {@link setInnerNode}, if any.\n\t * @remarks\n\t * If `target` is an unhydrated node, returns its UnhydratedFlexTreeNode.\n\t * If `target` is a cooked node (or marinated but a FlexTreeNode exists) returns the FlexTreeNode.\n\t * If the target is a marinated node with no FlexTreeNode for its anchor, returns undefined.\n\t */\n\tpublic tryGetInnerNode(): InnerNode | undefined {\n\t\tif (isHydrated(this.#hydrationState)) {\n\t\t\treturn (\n\t\t\t\tthis.#hydrationState.innerNode ??\n\t\t\t\tthis.#hydrationState.anchorNode.slots.get(flexTreeSlot)\n\t\t\t);\n\t\t}\n\n\t\treturn this.#hydrationState.innerNode;\n\t}\n}\n\n/**\n * Used by {@link anchorProxy} as an optimization to ensure that only one anchor is remembered at a time for a given anchor node\n */\nconst anchorForgetters = new WeakMap<TreeNode, () => void>();\n\nconst kernelEvents = [\"childrenChangedAfterBatch\", \"subtreeChangedAfterBatch\"] as const;\n\ntype KernelEvents = Pick<AnchorEvents, (typeof kernelEvents)[number]>;\n\n/**\n * For \"cooked\" nodes this is a FlexTreeNode thats a projection of forest content.\n * For {@link Unhydrated} nodes this is a MapTreeNode.\n * For \"marinated\" nodes, some code (ex: getOrCreateInnerNode) returns the FlexTreeNode thats a projection of forest content, and some code (ex: tryGetInnerNode) returns undefined.\n *\n * @remarks\n * Currently MapTreeNode extends FlexTreeNode, and most code which can work with either just uses FlexTreeNode.\n * TODO: Code should be migrating toward using this type to distinguish to two use-cases.\n *\n * TODO: The inconsistent handling of \"marinated\" cases should be cleaned up.\n * Maybe getOrCreateInnerNode should cook marinated nodes so they have a proper InnerNode?\n */\nexport type InnerNode = FlexTreeNode | UnhydratedFlexTreeNode;\n\n/**\n * Associates a given {@link UnhydratedFlexTreeNode} with a {@link TreeNode}.\n */\nconst unhydratedFlexTreeNodeToTreeNodeInternal = new WeakMap<\n\tUnhydratedFlexTreeNode,\n\tTreeNode\n>();\n/**\n * Retrieves the {@link TreeNode} associated with the given {@link UnhydratedFlexTreeNode} if any.\n */\nexport const unhydratedFlexTreeNodeToTreeNode =\n\tunhydratedFlexTreeNodeToTreeNodeInternal as Pick<\n\t\tWeakMap<UnhydratedFlexTreeNode, TreeNode>,\n\t\t\"get\"\n\t>;\n\n/**\n * An anchor slot which associates an anchor with its corresponding TreeNode, if there is one.\n * @remarks\n * For this to work, we have to require that there is at most a single view using a given AnchorSet.\n * FlexTree already has this assumption, and we also assume there is a single simple-tree per FlexTree, so this is valid.\n */\nexport const proxySlot = anchorSlot<TreeNode>();\n\nexport function tryDisposeTreeNode(anchorNode: AnchorNode): void {\n\tconst treeNode = anchorNode.slots.get(proxySlot);\n\tif (treeNode !== undefined) {\n\t\tconst kernel = getKernel(treeNode);\n\t\tkernel.dispose();\n\t}\n}\n\n/**\n * Gets the {@link TreeNodeSchema} for the {@link InnerNode}.\n */\nexport function getSimpleNodeSchemaFromInnerNode(innerNode: InnerNode): TreeNodeSchema {\n\tconst context: Context = getSimpleContextFromInnerNode(innerNode);\n\treturn context.schema.get(innerNode.schema) ?? fail(0xb3f /* missing schema from context */);\n}\n\n/**\n * Gets the {@link Context} for the {@link InnerNode}.\n */\nexport function getSimpleContextFromInnerNode(innerNode: InnerNode): Context {\n\tif (innerNode instanceof UnhydratedFlexTreeNode) {\n\t\treturn innerNode.simpleContext;\n\t}\n\n\tconst context = innerNode.anchorNode.anchorSet.slots.get(SimpleContextSlot);\n\tassert(context !== undefined, 0xa55 /* missing simple tree context */);\n\n\treturn context;\n}\n\n/**\n * Retrieves the flex node associated with the given target via {@link setInnerNode}.\n * @remarks\n * For {@link Unhydrated} nodes, this returns the MapTreeNode.\n *\n * For hydrated nodes it returns a FlexTreeNode backed by the forest.\n * Note that for \"marinated\" nodes, this FlexTreeNode exists and returns it: it does not return the MapTreeNode which is the current InnerNode.\n */\nexport function getOrCreateInnerNode(treeNode: TreeNode, allowFreed = false): InnerNode {\n\tconst kernel = getKernel(treeNode);\n\treturn kernel.getOrCreateInnerNode(allowFreed);\n}\n\n/**\n * Gets a flex node from an anchor node\n */\nfunction flexNodeFromAnchor(anchorNode: AnchorNode): FlexTreeNode {\n\t// the proxy is bound to an anchor node, but it may or may not have an actual flex node yet\n\tconst flexNode = anchorNode.slots.get(flexTreeSlot);\n\tif (flexNode !== undefined) {\n\t\treturn flexNode; // If it does have a flex node, return it...\n\t} // ...otherwise, the flex node must be created\n\tconst context =\n\t\tanchorNode.anchorSet.slots.get(ContextSlot) ?? fail(0xb45 /* missing context */);\n\tconst cursor = context.checkout.forest.allocateCursor(\"getFlexNode\");\n\tcontext.checkout.forest.moveCursorToPath(anchorNode, cursor);\n\tconst newFlexNode = makeTree(context, cursor);\n\tcursor.free();\n\treturn newFlexNode;\n}\n\n/**\n * Gets a tree node from an anchor node\n */\nexport function treeNodeFromAnchor(anchorNode: AnchorNode): TreeNode | TreeValue {\n\tconst cached = anchorNode.slots.get(proxySlot);\n\tif (cached !== undefined) {\n\t\treturn cached;\n\t}\n\n\tconst flexNode = flexNodeFromAnchor(anchorNode);\n\treturn createTreeNodeFromInner(flexNode);\n}\n\n/**\n * Constructs a TreeNode from an InnerNode.\n * @remarks\n * This does not do caching or validation: caller must ensure duplicate nodes for a given inner node are not created, and that the inner node is valid.\n */\nexport function createTreeNodeFromInner(innerNode: InnerNode): TreeNode | TreeValue {\n\tconst classSchema = getSimpleNodeSchemaFromInnerNode(innerNode);\n\tconst internal = innerNode as unknown as InternalTreeNode;\n\treturn typeof classSchema === \"function\"\n\t\t? new classSchema(internal)\n\t\t: (classSchema as { create(data: InternalTreeNode): TreeNode | TreeValue }).create(\n\t\t\t\tinternal,\n\t\t\t);\n}\n"]}
@@ -2,7 +2,8 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
- import type { NodeSchemaMetadata, TreeLeafValue } from "../schemaTypes.js";
5
+ import type { TreeLeafValue } from "../schemaTypes.js";
6
+ import type { SimpleNodeSchemaBase } from "../simpleSchema.js";
6
7
  import type { InternalTreeNode, TreeNode, Unhydrated } from "./types.js";
7
8
  /**
8
9
  * Schema for a {@link TreeNode} or {@link TreeLeafValue}.
@@ -16,6 +17,13 @@ import type { InternalTreeNode, TreeNode, Unhydrated } from "./types.js";
16
17
  * Captures the schema both as runtime data and compile time type information.
17
18
  * Use {@link SchemaFactory} to define schema.
18
19
  * Use `Tree.schema(value)` to lookup the schema for a {@link TreeNode} or {@link TreeLeafValue}.
20
+ * @privateRemarks
21
+ * TODO:
22
+ * The long lists of type parameters here are awkward to deal with.
23
+ * Switching to (or adding an option to use)
24
+ * an interface based pattern with unordered named parameters for types like this would be a good idea.
25
+ * The related `@system` types should be simple to port to the new pattern, but stable public one like this will need to support both:
26
+ * the new one could either be added as a system type, or be recommended to replace this one (deprecating it).
19
27
  * @sealed @public
20
28
  */
21
29
  export type TreeNodeSchema<Name extends string = string, Kind extends NodeKind = NodeKind, TNode extends TreeNode | TreeLeafValue = TreeNode | TreeLeafValue, TBuild = never, ImplicitlyConstructable extends boolean = boolean, Info = unknown, TCustomMetadata = unknown> = (TNode extends TreeNode ? TreeNodeSchemaClass<Name, Kind, TNode, TBuild, ImplicitlyConstructable, Info, never, TCustomMetadata> : never) | TreeNodeSchemaNonClass<Name, Kind, TNode, TBuild, ImplicitlyConstructable, Info, never, TCustomMetadata>;
@@ -30,12 +38,16 @@ export type TreeNodeSchema<Name extends string = string, Kind extends NodeKind =
30
38
  export type TreeNodeSchemaNonClass<Name extends string = string, Kind extends NodeKind = NodeKind, TNode extends TreeNode | TreeLeafValue = TreeNode | TreeLeafValue, TInsertable = never, ImplicitlyConstructable extends boolean = boolean, Info = unknown, TConstructorExtra = never, TCustomMetadata = unknown> = TreeNodeSchemaCore<Name, Kind, ImplicitlyConstructable, Info, TInsertable, TCustomMetadata> & (undefined extends TConstructorExtra ? {
31
39
  /**
32
40
  * Constructs an {@link Unhydrated} node with this schema.
41
+ * @privateRemarks
42
+ * Also allows InternalTreeNode.
33
43
  * @sealed
34
44
  */
35
45
  create(data?: TInsertable | TConstructorExtra): TNode;
36
46
  } : {
37
47
  /**
38
48
  * Constructs an {@link Unhydrated} node with this schema.
49
+ * @privateRemarks
50
+ * Also allows InternalTreeNode.
39
51
  * @sealed
40
52
  */
41
53
  create(data: TInsertable | TConstructorExtra): TNode;
@@ -114,7 +126,7 @@ export type TreeNodeSchemaBoth<Name extends string = string, Kind extends NodeKi
114
126
  * Implementation detail of {@link TreeNodeSchema} which should be accessed instead of referring to this type directly.
115
127
  * @sealed @public
116
128
  */
117
- export interface TreeNodeSchemaCore<out Name extends string, out Kind extends NodeKind, out ImplicitlyConstructable extends boolean, out Info = unknown, out TInsertable = never, out TCustomMetadata = unknown> {
129
+ export interface TreeNodeSchemaCore<out Name extends string, out Kind extends NodeKind, out ImplicitlyConstructable extends boolean, out Info = unknown, out TInsertable = never, out TCustomMetadata = unknown> extends SimpleNodeSchemaBase<Kind, TCustomMetadata> {
118
130
  /**
119
131
  * Unique (within a document's schema) identifier used to associate nodes with their schema.
120
132
  * @remarks
@@ -126,7 +138,6 @@ export interface TreeNodeSchemaCore<out Name extends string, out Kind extends No
126
138
  * it is best practice to pick a new identifier.
127
139
  */
128
140
  readonly identifier: Name;
129
- readonly kind: Kind;
130
141
  /**
131
142
  * Data used to define this schema.
132
143
  *
@@ -166,10 +177,6 @@ export interface TreeNodeSchemaCore<out Name extends string, out Kind extends No
166
177
  * @system
167
178
  */
168
179
  readonly childTypes: ReadonlySet<TreeNodeSchema>;
169
- /**
170
- * User-provided {@link NodeSchemaMetadata} for this schema.
171
- */
172
- readonly metadata?: NodeSchemaMetadata<TCustomMetadata> | undefined;
173
180
  /**
174
181
  * Constructs an instance of this node type.
175
182
  * @remarks
@@ -1 +1 @@
1
- {"version":3,"file":"treeNodeSchema.d.ts","sourceRoot":"","sources":["../../../src/simple-tree/core/treeNodeSchema.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAC3E,OAAO,KAAK,EAAE,gBAAgB,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAEzE;;;;;;;;;;;;;GAaG;AACH,MAAM,MAAM,cAAc,CACzB,IAAI,SAAS,MAAM,GAAG,MAAM,EAC5B,IAAI,SAAS,QAAQ,GAAG,QAAQ,EAChC,KAAK,SAAS,QAAQ,GAAG,aAAa,GAAG,QAAQ,GAAG,aAAa,EACjE,MAAM,GAAG,KAAK,EACd,uBAAuB,SAAS,OAAO,GAAG,OAAO,EACjD,IAAI,GAAG,OAAO,EACd,eAAe,GAAG,OAAO,IAEvB,CAAC,KAAK,SAAS,QAAQ,GACrB,mBAAmB,CACnB,IAAI,EACJ,IAAI,EACJ,KAAK,EACL,MAAM,EACN,uBAAuB,EACvB,IAAI,EACJ,KAAK,EACL,eAAe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;;;;;OASG;IACH,QAAQ,CAAC,UAAU,EAAE,IAAI,CAAC;IAE1B;;;;;;OAMG;IACH,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC;IAEpB;;;;;;;;;OASG;IACH,QAAQ,CAAC,uBAAuB,EAAE,uBAAuB,CAAC;IAE1D;;;;;;;;;;;;;;;;;;OAkBG;IACH,QAAQ,CAAC,UAAU,EAAE,WAAW,CAAC,cAAc,CAAC,CAAC;IAEjD;;;;;;;;;;;;;;;OAeG;IACH,oBAAoB,CAAC,IAAI,EAAE,WAAW,GAAG,UAAU,CAAC,QAAQ,GAAG,aAAa,CAAC,CAAC;CAC9E;AAED;;;;;GAKG;AACH,oBAAY,QAAQ;IACnB;;OAEG;IACH,GAAG,IAAA;IACH;;OAEG;IACH,KAAK,IAAA;IACL;;;;OAIG;IACH,MAAM,IAAA;IACN;;OAEG;IACH,IAAI,IAAA;CACJ"}
@@ -1 +1 @@
1
- {"version":3,"file":"treeNodeSchema.js","sourceRoot":"","sources":["../../../src/simple-tree/core/treeNodeSchema.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAkTH;;;;;GAKG;AACH,IAAY,QAmBX;AAnBD,WAAY,QAAQ;IACnB;;OAEG;IACH,qCAAG,CAAA;IACH;;OAEG;IACH,yCAAK,CAAA;IACL;;;;OAIG;IACH,2CAAM,CAAA;IACN;;OAEG;IACH,uCAAI,CAAA;AACL,CAAC,EAnBW,QAAQ,wBAAR,QAAQ,QAmBnB","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { NodeSchemaMetadata, TreeLeafValue } from \"../schemaTypes.js\";\nimport type { InternalTreeNode, TreeNode, Unhydrated } from \"./types.js\";\n\n/**\n * Schema for a {@link TreeNode} or {@link TreeLeafValue}.\n *\n * @typeParam Name - The full (including scope) name/identifier for the schema.\n * @typeParam Kind - Which kind of node this schema is for.\n * @typeParam TNode - API for nodes that use this schema.\n * @typeParam TBuild - Data which can be used to construct an {@link Unhydrated} node of this type.\n * @typeParam Info - Data used when defining this schema.\n * @remarks\n * Captures the schema both as runtime data and compile time type information.\n * Use {@link SchemaFactory} to define schema.\n * Use `Tree.schema(value)` to lookup the schema for a {@link TreeNode} or {@link TreeLeafValue}.\n * @sealed @public\n */\nexport type TreeNodeSchema<\n\tName extends string = string,\n\tKind extends NodeKind = NodeKind,\n\tTNode extends TreeNode | TreeLeafValue = TreeNode | TreeLeafValue,\n\tTBuild = never,\n\tImplicitlyConstructable extends boolean = boolean,\n\tInfo = unknown,\n\tTCustomMetadata = unknown,\n> =\n\t| (TNode extends TreeNode\n\t\t\t? TreeNodeSchemaClass<\n\t\t\t\t\tName,\n\t\t\t\t\tKind,\n\t\t\t\t\tTNode,\n\t\t\t\t\tTBuild,\n\t\t\t\t\tImplicitlyConstructable,\n\t\t\t\t\tInfo,\n\t\t\t\t\tnever,\n\t\t\t\t\tTCustomMetadata\n\t\t\t\t>\n\t\t\t: never)\n\t| TreeNodeSchemaNonClass<\n\t\t\tName,\n\t\t\tKind,\n\t\t\tTNode,\n\t\t\tTBuild,\n\t\t\tImplicitlyConstructable,\n\t\t\tInfo,\n\t\t\tnever,\n\t\t\tTCustomMetadata\n\t >;\n\n/**\n * Schema which is not a class.\n * @remarks\n * This is used for schema which cannot have their instances constructed using constructors, like leaf schema.\n * @privateRemarks\n * Non-class based schema can have issues with recursive types due to https://github.com/microsoft/TypeScript/issues/55832.\n * @system @sealed @public\n */\nexport type TreeNodeSchemaNonClass<\n\tName extends string = string,\n\tKind extends NodeKind = NodeKind,\n\tTNode extends TreeNode | TreeLeafValue = TreeNode | TreeLeafValue,\n\tTInsertable = never,\n\tImplicitlyConstructable extends boolean = boolean,\n\tInfo = unknown,\n\tTConstructorExtra = never,\n\tTCustomMetadata = unknown,\n> = TreeNodeSchemaCore<\n\tName,\n\tKind,\n\tImplicitlyConstructable,\n\tInfo,\n\tTInsertable,\n\tTCustomMetadata\n> &\n\t(undefined extends TConstructorExtra\n\t\t? {\n\t\t\t\t/**\n\t\t\t\t * Constructs an {@link Unhydrated} node with this schema.\n\t\t\t\t * @sealed\n\t\t\t\t */\n\t\t\t\tcreate(data?: TInsertable | TConstructorExtra): TNode;\n\t\t\t}\n\t\t: {\n\t\t\t\t/**\n\t\t\t\t * Constructs an {@link Unhydrated} node with this schema.\n\t\t\t\t * @sealed\n\t\t\t\t */\n\t\t\t\tcreate(data: TInsertable | TConstructorExtra): TNode;\n\t\t\t});\n\n/**\n * Tree node schema which is implemented using a class.\n * @remarks\n * Instances of this class are nodes in the tree.\n * This is also a constructor so that it can be subclassed.\n *\n * Using classes in this way allows introducing a named type and a named value at the same time, helping keep the runtime and compile time information together and easy to refer to un a uniform way.\n * Additionally, this works around https://github.com/microsoft/TypeScript/issues/55832 which causes similar patterns with less explicit types to infer \"any\" in the d.ts file.\n *\n * When sub-classing a a `TreeNodeSchemaClass`, some extra rules must be followed:\n *\n * - Only ever use a single class from the schema's class hierarchy within a document and its schema.\n * For example, if using {@link SchemaFactory.object} you can do:\n * ```typescript\n * // Recommended \"customizable\" object schema pattern.\n * class Good extends schemaFactory.object(\"A\", {\n * \texampleField: schemaFactory.number,\n * }) {\n * \tpublic exampleCustomMethod(): void {\n * \t\tthis.exampleField++;\n * \t}\n * }\n * ```\n * But should avoid:\n * ```typescript\n * // This by itself is ok, and opts into \"POJO mode\".\n * const base = schemaFactory.object(\"A\", {});\n * // This is a bad pattern since it leaves two classes in scope which derive from the same SchemaFactory defined class.\n * // If both get used, its an error!\n * class Invalid extends base {}\n * ```\n * - Do not modify the constructor input parameter types or values:\n * ```typescript\n * class Invalid extends schemaFactory.object(\"A\", {\n * \texampleField: schemaFactory.number,\n * }) {\n * \t// This Modifies the type of the constructor input.\n * \t// This is unsupported due to programmatic access to the constructor being used internally.\n * \tpublic constructor(a: number) {\n * \t\tsuper({ exampleField: a });\n * \t}\n * }\n * ```\n * @sealed @public\n */\nexport type TreeNodeSchemaClass<\n\tName extends string = string,\n\tKind extends NodeKind = NodeKind,\n\tTNode extends TreeNode = TreeNode,\n\tTInsertable = never,\n\tImplicitlyConstructable extends boolean = boolean,\n\tInfo = unknown,\n\tTConstructorExtra = never,\n\tTCustomMetadata = unknown,\n> = TreeNodeSchemaCore<\n\tName,\n\tKind,\n\tImplicitlyConstructable,\n\tInfo,\n\tTInsertable,\n\tTCustomMetadata\n> &\n\t(undefined extends TConstructorExtra\n\t\t? {\n\t\t\t\t/**\n\t\t\t\t * Constructs an {@link Unhydrated} node with this schema.\n\t\t\t\t * @remarks\n\t\t\t\t * This constructor is also used internally to construct hydrated nodes with a different parameter type.\n\t\t\t\t * Therefore, overriding this constructor with different argument types is not type-safe and is not supported.\n\t\t\t\t * @sealed\n\t\t\t\t */\n\t\t\t\t// The approach suggested by the linter here is more concise, but ir break intellisense for the constructor.\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/prefer-function-type\n\t\t\t\tnew (data?: TInsertable | InternalTreeNode | TConstructorExtra): Unhydrated<TNode>;\n\t\t\t}\n\t\t: {\n\t\t\t\t/**\n\t\t\t\t * Constructs an {@link Unhydrated} node with this schema.\n\t\t\t\t * @remarks\n\t\t\t\t * This constructor is also used internally to construct hydrated nodes with a different parameter type.\n\t\t\t\t * Therefore, overriding this constructor with different argument types is not type-safe and is not supported.\n\t\t\t\t * @sealed\n\t\t\t\t */\n\t\t\t\t// The approach suggested by the linter here is more concise, but ir break intellisense for the constructor.\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/prefer-function-type\n\t\t\t\tnew (data: TInsertable | InternalTreeNode | TConstructorExtra): Unhydrated<TNode>;\n\t\t\t});\n\n/**\n * Internal helper for utilities that return schema which can be used in class and non class formats depending on the API exposing it.\n */\nexport type TreeNodeSchemaBoth<\n\tName extends string = string,\n\tKind extends NodeKind = NodeKind,\n\tTNode extends TreeNode = TreeNode,\n\tTInsertable = never,\n\tImplicitlyConstructable extends boolean = boolean,\n\tInfo = unknown,\n\tTConstructorExtra = never,\n\tTCustomMetadata = unknown,\n> = TreeNodeSchemaClass<\n\tName,\n\tKind,\n\tTNode,\n\tTInsertable,\n\tImplicitlyConstructable,\n\tInfo,\n\tTConstructorExtra,\n\tTCustomMetadata\n> &\n\tTreeNodeSchemaNonClass<\n\t\tName,\n\t\tKind,\n\t\tTNode,\n\t\tTInsertable,\n\t\tImplicitlyConstructable,\n\t\tInfo,\n\t\tTConstructorExtra,\n\t\tTCustomMetadata\n\t>;\n\n/**\n * Data common to all tree node schema.\n * @remarks\n * Implementation detail of {@link TreeNodeSchema} which should be accessed instead of referring to this type directly.\n * @sealed @public\n */\nexport interface TreeNodeSchemaCore<\n\tout Name extends string,\n\tout Kind extends NodeKind,\n\tout ImplicitlyConstructable extends boolean,\n\tout Info = unknown,\n\tout TInsertable = never,\n\tout TCustomMetadata = unknown,\n> {\n\t/**\n\t * Unique (within a document's schema) identifier used to associate nodes with their schema.\n\t * @remarks\n\t * This is used when encoding nodes, and when decoding nodes to re-associate them with the schema.\n\t * Since this decoding may happen in a different version of the application (or even a different application altogether),\n\t * this identifier should generally correspond to some specific semantics for the data (how to interpret the node with this identifier).\n\t * Any time the semantics change such that data would be misinterpreted if the old semantics were applied\n\t * (for example the units of a value are changed),\n\t * it is best practice to pick a new identifier.\n\t */\n\treadonly identifier: Name;\n\treadonly kind: Kind;\n\n\t/**\n\t * Data used to define this schema.\n\t *\n\t * @remarks\n\t * The format depends on the kind of node it is for.\n\t * For example, the \"object\" node kind could store the field schema here.\n\t */\n\treadonly info: Info;\n\n\t/**\n\t * When constructing insertable content,\n\t * data that could be passed to the node's constructor can be used instead of an {@link Unhydrated} node\n\t * iff implicitlyConstructable is true.\n\t * @privateRemarks\n\t * Currently the logic for traversing insertable content,\n\t * both to build trees and to hydrate them does not defer to the schema classes to handle the policy,\n\t * so if their constructors differ from what is supported, some cases will not work.\n\t * Setting this to false adjusts the insertable types to disallow cases which could be impacted by these inconsistencies.\n\t */\n\treadonly implicitlyConstructable: ImplicitlyConstructable;\n\n\t/**\n\t * All possible schema that a direct child of a node with this schema could have.\n\t *\n\t * Equivalently, this is also all schema directly referenced when defining this schema's allowed child types,\n\t * which is also the same as the set of schema referenced directly by the `Info` type parameter and the `info` property.\n\t * This property is simply re-exposing that information in an easier to traverse format consistent across all node kinds.\n\t * @remarks\n\t * Some kinds of nodes may have additional restrictions on children:\n\t * this set simply enumerates all directly referenced schema, and can be use to walk over all referenced schema types.\n\t *\n\t * This set cannot be used before the schema in it have been defined:\n\t * more specifically, when using lazy schema references (for example to make foreword references to schema which have not yet been defined),\n\t * users must wait until after the schema are defined to access this set.\n\t * @privateRemarks\n\t * Currently there isn't much use for this in the public API,\n\t * and it's possible this will want to be tweaked or renamed as part of a larger schema reflection API surface that might be added later.\n\t * To keep options option, this is marked `@system` for now.\n\t * @system\n\t */\n\treadonly childTypes: ReadonlySet<TreeNodeSchema>;\n\n\t/**\n\t * User-provided {@link NodeSchemaMetadata} for this schema.\n\t */\n\treadonly metadata?: NodeSchemaMetadata<TCustomMetadata> | undefined;\n\n\t/**\n\t * Constructs an instance of this node type.\n\t * @remarks\n\t * Due to TypeScript limitations, the return type of this method can not be very specific.\n\t * For {@link TreeNodeSchemaClass} prefer using the constructor directly for better typing.\n\t * For {@link TreeNodeSchemaNonClass} use `create`.\n\t *\n\t * @privateRemarks\n\t * This method signature provides a way to infer `TInsertable` without relying on the constructor, and to construct nodes from schema of unknown kind.\n\t * This makes customizations of the constructor not impact the typing of insertable content, allowing customization of the constructor,\n\t * as long as doing so only adds additional supported cases.\n\t *\n\t * This cannot be required to return `TNode`:\n\t * doing so breaks sub-classing of schema since they don't overload this method with a more specific return type.\n\t * @sealed @system\n\t */\n\tcreateFromInsertable(data: TInsertable): Unhydrated<TreeNode | TreeLeafValue>;\n}\n\n/**\n * Kind of tree node.\n * @remarks\n * More kinds may be added over time, so do not assume this is an exhaustive set.\n * @public\n */\nexport enum NodeKind {\n\t/**\n\t * A node which serves as a map, storing children under string keys.\n\t */\n\tMap,\n\t/**\n\t * A node which serves as an array, storing children in an ordered sequence.\n\t */\n\tArray,\n\t/**\n\t * A node which stores a heterogenous collection of children in named fields.\n\t * @remarks\n\t * Each field gets its own schema.\n\t */\n\tObject,\n\t/**\n\t * A node which stores a single leaf value.\n\t */\n\tLeaf,\n}\n"]}
1
+ {"version":3,"file":"treeNodeSchema.js","sourceRoot":"","sources":["../../../src/simple-tree/core/treeNodeSchema.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAwTH;;;;;GAKG;AACH,IAAY,QAmBX;AAnBD,WAAY,QAAQ;IACnB;;OAEG;IACH,qCAAG,CAAA;IACH;;OAEG;IACH,yCAAK,CAAA;IACL;;;;OAIG;IACH,2CAAM,CAAA;IACN;;OAEG;IACH,uCAAI,CAAA;AACL,CAAC,EAnBW,QAAQ,wBAAR,QAAQ,QAmBnB","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { TreeLeafValue } from \"../schemaTypes.js\";\nimport type { SimpleNodeSchemaBase } from \"../simpleSchema.js\";\nimport type { InternalTreeNode, TreeNode, Unhydrated } from \"./types.js\";\n\n/**\n * Schema for a {@link TreeNode} or {@link TreeLeafValue}.\n *\n * @typeParam Name - The full (including scope) name/identifier for the schema.\n * @typeParam Kind - Which kind of node this schema is for.\n * @typeParam TNode - API for nodes that use this schema.\n * @typeParam TBuild - Data which can be used to construct an {@link Unhydrated} node of this type.\n * @typeParam Info - Data used when defining this schema.\n * @remarks\n * Captures the schema both as runtime data and compile time type information.\n * Use {@link SchemaFactory} to define schema.\n * Use `Tree.schema(value)` to lookup the schema for a {@link TreeNode} or {@link TreeLeafValue}.\n * @privateRemarks\n * TODO:\n * The long lists of type parameters here are awkward to deal with.\n * Switching to (or adding an option to use)\n * an interface based pattern with unordered named parameters for types like this would be a good idea.\n * The related `@system` types should be simple to port to the new pattern, but stable public one like this will need to support both:\n * the new one could either be added as a system type, or be recommended to replace this one (deprecating it).\n * @sealed @public\n */\nexport type TreeNodeSchema<\n\tName extends string = string,\n\tKind extends NodeKind = NodeKind,\n\tTNode extends TreeNode | TreeLeafValue = TreeNode | TreeLeafValue,\n\tTBuild = never,\n\tImplicitlyConstructable extends boolean = boolean,\n\tInfo = unknown,\n\tTCustomMetadata = unknown,\n> =\n\t| (TNode extends TreeNode\n\t\t\t? TreeNodeSchemaClass<\n\t\t\t\t\tName,\n\t\t\t\t\tKind,\n\t\t\t\t\tTNode,\n\t\t\t\t\tTBuild,\n\t\t\t\t\tImplicitlyConstructable,\n\t\t\t\t\tInfo,\n\t\t\t\t\tnever,\n\t\t\t\t\tTCustomMetadata\n\t\t\t\t>\n\t\t\t: never)\n\t| TreeNodeSchemaNonClass<\n\t\t\tName,\n\t\t\tKind,\n\t\t\tTNode,\n\t\t\tTBuild,\n\t\t\tImplicitlyConstructable,\n\t\t\tInfo,\n\t\t\tnever,\n\t\t\tTCustomMetadata\n\t >;\n\n/**\n * Schema which is not a class.\n * @remarks\n * This is used for schema which cannot have their instances constructed using constructors, like leaf schema.\n * @privateRemarks\n * Non-class based schema can have issues with recursive types due to https://github.com/microsoft/TypeScript/issues/55832.\n * @system @sealed @public\n */\nexport type TreeNodeSchemaNonClass<\n\tName extends string = string,\n\tKind extends NodeKind = NodeKind,\n\tTNode extends TreeNode | TreeLeafValue = TreeNode | TreeLeafValue,\n\tTInsertable = never,\n\tImplicitlyConstructable extends boolean = boolean,\n\tInfo = unknown,\n\tTConstructorExtra = never,\n\tTCustomMetadata = unknown,\n> = TreeNodeSchemaCore<\n\tName,\n\tKind,\n\tImplicitlyConstructable,\n\tInfo,\n\tTInsertable,\n\tTCustomMetadata\n> &\n\t(undefined extends TConstructorExtra\n\t\t? {\n\t\t\t\t/**\n\t\t\t\t * Constructs an {@link Unhydrated} node with this schema.\n\t\t\t\t * @privateRemarks\n\t\t\t\t * Also allows InternalTreeNode.\n\t\t\t\t * @sealed\n\t\t\t\t */\n\t\t\t\tcreate(data?: TInsertable | TConstructorExtra): TNode;\n\t\t\t}\n\t\t: {\n\t\t\t\t/**\n\t\t\t\t * Constructs an {@link Unhydrated} node with this schema.\n\t\t\t\t * @privateRemarks\n\t\t\t\t * Also allows InternalTreeNode.\n\t\t\t\t * @sealed\n\t\t\t\t */\n\t\t\t\tcreate(data: TInsertable | TConstructorExtra): TNode;\n\t\t\t});\n\n/**\n * Tree node schema which is implemented using a class.\n * @remarks\n * Instances of this class are nodes in the tree.\n * This is also a constructor so that it can be subclassed.\n *\n * Using classes in this way allows introducing a named type and a named value at the same time, helping keep the runtime and compile time information together and easy to refer to un a uniform way.\n * Additionally, this works around https://github.com/microsoft/TypeScript/issues/55832 which causes similar patterns with less explicit types to infer \"any\" in the d.ts file.\n *\n * When sub-classing a a `TreeNodeSchemaClass`, some extra rules must be followed:\n *\n * - Only ever use a single class from the schema's class hierarchy within a document and its schema.\n * For example, if using {@link SchemaFactory.object} you can do:\n * ```typescript\n * // Recommended \"customizable\" object schema pattern.\n * class Good extends schemaFactory.object(\"A\", {\n * \texampleField: schemaFactory.number,\n * }) {\n * \tpublic exampleCustomMethod(): void {\n * \t\tthis.exampleField++;\n * \t}\n * }\n * ```\n * But should avoid:\n * ```typescript\n * // This by itself is ok, and opts into \"POJO mode\".\n * const base = schemaFactory.object(\"A\", {});\n * // This is a bad pattern since it leaves two classes in scope which derive from the same SchemaFactory defined class.\n * // If both get used, its an error!\n * class Invalid extends base {}\n * ```\n * - Do not modify the constructor input parameter types or values:\n * ```typescript\n * class Invalid extends schemaFactory.object(\"A\", {\n * \texampleField: schemaFactory.number,\n * }) {\n * \t// This Modifies the type of the constructor input.\n * \t// This is unsupported due to programmatic access to the constructor being used internally.\n * \tpublic constructor(a: number) {\n * \t\tsuper({ exampleField: a });\n * \t}\n * }\n * ```\n * @sealed @public\n */\nexport type TreeNodeSchemaClass<\n\tName extends string = string,\n\tKind extends NodeKind = NodeKind,\n\tTNode extends TreeNode = TreeNode,\n\tTInsertable = never,\n\tImplicitlyConstructable extends boolean = boolean,\n\tInfo = unknown,\n\tTConstructorExtra = never,\n\tTCustomMetadata = unknown,\n> = TreeNodeSchemaCore<\n\tName,\n\tKind,\n\tImplicitlyConstructable,\n\tInfo,\n\tTInsertable,\n\tTCustomMetadata\n> &\n\t(undefined extends TConstructorExtra\n\t\t? {\n\t\t\t\t/**\n\t\t\t\t * Constructs an {@link Unhydrated} node with this schema.\n\t\t\t\t * @remarks\n\t\t\t\t * This constructor is also used internally to construct hydrated nodes with a different parameter type.\n\t\t\t\t * Therefore, overriding this constructor with different argument types is not type-safe and is not supported.\n\t\t\t\t * @sealed\n\t\t\t\t */\n\t\t\t\t// The approach suggested by the linter here is more concise, but ir break intellisense for the constructor.\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/prefer-function-type\n\t\t\t\tnew (data?: TInsertable | InternalTreeNode | TConstructorExtra): Unhydrated<TNode>;\n\t\t\t}\n\t\t: {\n\t\t\t\t/**\n\t\t\t\t * Constructs an {@link Unhydrated} node with this schema.\n\t\t\t\t * @remarks\n\t\t\t\t * This constructor is also used internally to construct hydrated nodes with a different parameter type.\n\t\t\t\t * Therefore, overriding this constructor with different argument types is not type-safe and is not supported.\n\t\t\t\t * @sealed\n\t\t\t\t */\n\t\t\t\t// The approach suggested by the linter here is more concise, but ir break intellisense for the constructor.\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/prefer-function-type\n\t\t\t\tnew (data: TInsertable | InternalTreeNode | TConstructorExtra): Unhydrated<TNode>;\n\t\t\t});\n\n/**\n * Internal helper for utilities that return schema which can be used in class and non class formats depending on the API exposing it.\n */\nexport type TreeNodeSchemaBoth<\n\tName extends string = string,\n\tKind extends NodeKind = NodeKind,\n\tTNode extends TreeNode = TreeNode,\n\tTInsertable = never,\n\tImplicitlyConstructable extends boolean = boolean,\n\tInfo = unknown,\n\tTConstructorExtra = never,\n\tTCustomMetadata = unknown,\n> = TreeNodeSchemaClass<\n\tName,\n\tKind,\n\tTNode,\n\tTInsertable,\n\tImplicitlyConstructable,\n\tInfo,\n\tTConstructorExtra,\n\tTCustomMetadata\n> &\n\tTreeNodeSchemaNonClass<\n\t\tName,\n\t\tKind,\n\t\tTNode,\n\t\tTInsertable,\n\t\tImplicitlyConstructable,\n\t\tInfo,\n\t\tTConstructorExtra,\n\t\tTCustomMetadata\n\t>;\n\n/**\n * Data common to all tree node schema.\n * @remarks\n * Implementation detail of {@link TreeNodeSchema} which should be accessed instead of referring to this type directly.\n * @sealed @public\n */\nexport interface TreeNodeSchemaCore<\n\tout Name extends string,\n\tout Kind extends NodeKind,\n\tout ImplicitlyConstructable extends boolean,\n\tout Info = unknown,\n\tout TInsertable = never,\n\tout TCustomMetadata = unknown,\n> extends SimpleNodeSchemaBase<Kind, TCustomMetadata> {\n\t/**\n\t * Unique (within a document's schema) identifier used to associate nodes with their schema.\n\t * @remarks\n\t * This is used when encoding nodes, and when decoding nodes to re-associate them with the schema.\n\t * Since this decoding may happen in a different version of the application (or even a different application altogether),\n\t * this identifier should generally correspond to some specific semantics for the data (how to interpret the node with this identifier).\n\t * Any time the semantics change such that data would be misinterpreted if the old semantics were applied\n\t * (for example the units of a value are changed),\n\t * it is best practice to pick a new identifier.\n\t */\n\treadonly identifier: Name;\n\n\t/**\n\t * Data used to define this schema.\n\t *\n\t * @remarks\n\t * The format depends on the kind of node it is for.\n\t * For example, the \"object\" node kind could store the field schema here.\n\t */\n\treadonly info: Info;\n\n\t/**\n\t * When constructing insertable content,\n\t * data that could be passed to the node's constructor can be used instead of an {@link Unhydrated} node\n\t * iff implicitlyConstructable is true.\n\t * @privateRemarks\n\t * Currently the logic for traversing insertable content,\n\t * both to build trees and to hydrate them does not defer to the schema classes to handle the policy,\n\t * so if their constructors differ from what is supported, some cases will not work.\n\t * Setting this to false adjusts the insertable types to disallow cases which could be impacted by these inconsistencies.\n\t */\n\treadonly implicitlyConstructable: ImplicitlyConstructable;\n\n\t/**\n\t * All possible schema that a direct child of a node with this schema could have.\n\t *\n\t * Equivalently, this is also all schema directly referenced when defining this schema's allowed child types,\n\t * which is also the same as the set of schema referenced directly by the `Info` type parameter and the `info` property.\n\t * This property is simply re-exposing that information in an easier to traverse format consistent across all node kinds.\n\t * @remarks\n\t * Some kinds of nodes may have additional restrictions on children:\n\t * this set simply enumerates all directly referenced schema, and can be use to walk over all referenced schema types.\n\t *\n\t * This set cannot be used before the schema in it have been defined:\n\t * more specifically, when using lazy schema references (for example to make foreword references to schema which have not yet been defined),\n\t * users must wait until after the schema are defined to access this set.\n\t * @privateRemarks\n\t * Currently there isn't much use for this in the public API,\n\t * and it's possible this will want to be tweaked or renamed as part of a larger schema reflection API surface that might be added later.\n\t * To keep options option, this is marked `@system` for now.\n\t * @system\n\t */\n\treadonly childTypes: ReadonlySet<TreeNodeSchema>;\n\n\t/**\n\t * Constructs an instance of this node type.\n\t * @remarks\n\t * Due to TypeScript limitations, the return type of this method can not be very specific.\n\t * For {@link TreeNodeSchemaClass} prefer using the constructor directly for better typing.\n\t * For {@link TreeNodeSchemaNonClass} use `create`.\n\t *\n\t * @privateRemarks\n\t * This method signature provides a way to infer `TInsertable` without relying on the constructor, and to construct nodes from schema of unknown kind.\n\t * This makes customizations of the constructor not impact the typing of insertable content, allowing customization of the constructor,\n\t * as long as doing so only adds additional supported cases.\n\t *\n\t * This cannot be required to return `TNode`:\n\t * doing so breaks sub-classing of schema since they don't overload this method with a more specific return type.\n\t * @sealed @system\n\t */\n\tcreateFromInsertable(data: TInsertable): Unhydrated<TreeNode | TreeLeafValue>;\n}\n\n/**\n * Kind of tree node.\n * @remarks\n * More kinds may be added over time, so do not assume this is an exhaustive set.\n * @public\n */\nexport enum NodeKind {\n\t/**\n\t * A node which serves as a map, storing children under string keys.\n\t */\n\tMap,\n\t/**\n\t * A node which serves as an array, storing children in an ordered sequence.\n\t */\n\tArray,\n\t/**\n\t * A node which stores a heterogenous collection of children in named fields.\n\t * @remarks\n\t * Each field gets its own schema.\n\t */\n\tObject,\n\t/**\n\t * A node which stores a single leaf value.\n\t */\n\tLeaf,\n}\n"]}
@@ -25,7 +25,7 @@ class UnhydratedFlexTreeNode {
25
25
  return this.mapTree.type;
26
26
  }
27
27
  get storedSchema() {
28
- return (this.context.schema.nodeSchema.get(this.mapTree.type) ?? (0, index_js_2.fail)(0xb46 /* missing schema */));
28
+ return (this.context.schema.nodeSchema.get(this.mapTree.type) ?? (0, internal_1.fail)(0xb46 /* missing schema */));
29
29
  }
30
30
  get events() {
31
31
  return this._events;
@@ -117,7 +117,7 @@ class UnhydratedFlexTreeNode {
117
117
  get anchorNode() {
118
118
  // This API is relevant to `LazyTreeNode`s, but not `UnhydratedFlexTreeNode`s.
119
119
  // TODO: Refactor the FlexTreeNode interface so that stubbing this out isn't necessary.
120
- return (0, index_js_2.fail)(0xb47 /* UnhydratedFlexTreeNode does not implement anchorNode */);
120
+ return (0, internal_1.fail)(0xb47 /* UnhydratedFlexTreeNode does not implement anchorNode */);
121
121
  }
122
122
  walkTree() {
123
123
  for (const [key, mapTrees] of this.mapTree.fields) {
@@ -185,10 +185,10 @@ const unparentedLocation = {
185
185
  },
186
186
  schema: (0, index_js_2.brand)(index_js_1.forbiddenFieldKindIdentifier),
187
187
  get context() {
188
- return (0, index_js_2.fail)(0xb48 /* unsupported */);
188
+ return (0, internal_1.fail)(0xb48 /* unsupported */);
189
189
  },
190
190
  getFieldPath() {
191
- (0, index_js_2.fail)(0xb49 /* unsupported */);
191
+ (0, internal_1.fail)(0xb49 /* unsupported */);
192
192
  },
193
193
  },
194
194
  index: -1,
@@ -353,7 +353,7 @@ class UnhydratedTreeSequenceField extends UnhydratedFlexTreeField {
353
353
  this.edit((mapTrees) => {
354
354
  removed = mapTrees.splice(index, count);
355
355
  });
356
- return removed ?? (0, index_js_2.fail)(0xb4a /* Expected removed to be set by edit */);
356
+ return removed ?? (0, internal_1.fail)(0xb4a /* Expected removed to be set by edit */);
357
357
  },
358
358
  };
359
359
  }