@fluidframework/tree 2.51.0 → 2.52.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 (579) hide show
  1. package/.vscode/settings.json +0 -1
  2. package/CHANGELOG.md +43 -0
  3. package/api-report/tree.alpha.api.md +3 -2
  4. package/dist/codec/codec.d.ts +2 -1
  5. package/dist/codec/codec.d.ts.map +1 -1
  6. package/dist/codec/codec.js +4 -3
  7. package/dist/codec/codec.js.map +1 -1
  8. package/dist/core/index.d.ts +1 -1
  9. package/dist/core/index.d.ts.map +1 -1
  10. package/dist/core/index.js +3 -2
  11. package/dist/core/index.js.map +1 -1
  12. package/dist/core/rebase/index.d.ts +1 -1
  13. package/dist/core/rebase/index.d.ts.map +1 -1
  14. package/dist/core/rebase/index.js +2 -1
  15. package/dist/core/rebase/index.js.map +1 -1
  16. package/dist/core/rebase/types.d.ts +3 -1
  17. package/dist/core/rebase/types.d.ts.map +1 -1
  18. package/dist/core/rebase/types.js +2 -1
  19. package/dist/core/rebase/types.js.map +1 -1
  20. package/dist/core/schema-stored/schema.d.ts +1 -23
  21. package/dist/core/schema-stored/schema.d.ts.map +1 -1
  22. package/dist/core/schema-stored/schema.js +2 -2
  23. package/dist/core/schema-stored/schema.js.map +1 -1
  24. package/dist/core/tree/detachedFieldIndex.d.ts.map +1 -1
  25. package/dist/core/tree/detachedFieldIndex.js +2 -3
  26. package/dist/core/tree/detachedFieldIndex.js.map +1 -1
  27. package/dist/core/tree/detachedFieldIndexCodecCommon.d.ts +17 -0
  28. package/dist/core/tree/detachedFieldIndexCodecCommon.d.ts.map +1 -0
  29. package/dist/core/tree/detachedFieldIndexCodecCommon.js +68 -0
  30. package/dist/core/tree/detachedFieldIndexCodecCommon.js.map +1 -0
  31. package/dist/core/tree/detachedFieldIndexCodecV1.d.ts +11 -0
  32. package/dist/core/tree/detachedFieldIndexCodecV1.d.ts.map +1 -0
  33. package/dist/core/tree/detachedFieldIndexCodecV1.js +55 -0
  34. package/dist/core/tree/detachedFieldIndexCodecV1.js.map +1 -0
  35. package/dist/core/tree/detachedFieldIndexCodecV2.d.ts +11 -0
  36. package/dist/core/tree/detachedFieldIndexCodecV2.d.ts.map +1 -0
  37. package/dist/core/tree/detachedFieldIndexCodecV2.js +49 -0
  38. package/dist/core/tree/detachedFieldIndexCodecV2.js.map +1 -0
  39. package/dist/core/tree/detachedFieldIndexCodecs.d.ts +11 -0
  40. package/dist/core/tree/detachedFieldIndexCodecs.d.ts.map +1 -0
  41. package/dist/core/tree/detachedFieldIndexCodecs.js +26 -0
  42. package/dist/core/tree/detachedFieldIndexCodecs.js.map +1 -0
  43. package/dist/core/tree/detachedFieldIndexFormatCommon.d.ts +37 -0
  44. package/dist/core/tree/detachedFieldIndexFormatCommon.d.ts.map +1 -0
  45. package/dist/core/tree/{detachedFieldIndexFormat.js → detachedFieldIndexFormatCommon.js} +18 -13
  46. package/dist/core/tree/detachedFieldIndexFormatCommon.js.map +1 -0
  47. package/dist/core/tree/detachedFieldIndexFormatV1.d.ts +13 -0
  48. package/dist/core/tree/detachedFieldIndexFormatV1.d.ts.map +1 -0
  49. package/dist/core/tree/detachedFieldIndexFormatV1.js +12 -0
  50. package/dist/core/tree/detachedFieldIndexFormatV1.js.map +1 -0
  51. package/dist/core/tree/detachedFieldIndexFormatV2.d.ts +14 -0
  52. package/dist/core/tree/detachedFieldIndexFormatV2.d.ts.map +1 -0
  53. package/dist/core/tree/detachedFieldIndexFormatV2.js +14 -0
  54. package/dist/core/tree/detachedFieldIndexFormatV2.js.map +1 -0
  55. package/dist/feature-libraries/chunked-forest/codec/chunkDecoding.d.ts +9 -9
  56. package/dist/feature-libraries/chunked-forest/codec/chunkDecoding.d.ts.map +1 -1
  57. package/dist/feature-libraries/chunked-forest/codec/chunkDecoding.js +21 -21
  58. package/dist/feature-libraries/chunked-forest/codec/chunkDecoding.js.map +1 -1
  59. package/dist/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.d.ts +4 -2
  60. package/dist/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.d.ts.map +1 -1
  61. package/dist/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.js +4 -4
  62. package/dist/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.js.map +1 -1
  63. package/dist/feature-libraries/chunked-forest/codec/compressedEncode.d.ts +50 -31
  64. package/dist/feature-libraries/chunked-forest/codec/compressedEncode.d.ts.map +1 -1
  65. package/dist/feature-libraries/chunked-forest/codec/compressedEncode.js +74 -61
  66. package/dist/feature-libraries/chunked-forest/codec/compressedEncode.js.map +1 -1
  67. package/dist/feature-libraries/chunked-forest/codec/format.d.ts +20 -14
  68. package/dist/feature-libraries/chunked-forest/codec/format.d.ts.map +1 -1
  69. package/dist/feature-libraries/chunked-forest/codec/format.js +18 -12
  70. package/dist/feature-libraries/chunked-forest/codec/format.js.map +1 -1
  71. package/{lib/feature-libraries/chunked-forest/codec/nodeShape.d.ts → dist/feature-libraries/chunked-forest/codec/nodeEncoder.d.ts} +20 -14
  72. package/dist/feature-libraries/chunked-forest/codec/nodeEncoder.d.ts.map +1 -0
  73. package/dist/feature-libraries/chunked-forest/codec/{nodeShape.js → nodeEncoder.js} +23 -17
  74. package/dist/feature-libraries/chunked-forest/codec/nodeEncoder.js.map +1 -0
  75. package/dist/feature-libraries/chunked-forest/codec/schemaBasedEncode.d.ts +7 -7
  76. package/dist/feature-libraries/chunked-forest/codec/schemaBasedEncode.d.ts.map +1 -1
  77. package/dist/feature-libraries/chunked-forest/codec/schemaBasedEncode.js +22 -22
  78. package/dist/feature-libraries/chunked-forest/codec/schemaBasedEncode.js.map +1 -1
  79. package/dist/feature-libraries/chunked-forest/codec/uncompressedEncode.js +2 -2
  80. package/dist/feature-libraries/chunked-forest/codec/uncompressedEncode.js.map +1 -1
  81. package/dist/feature-libraries/default-schema/defaultFieldKinds.d.ts +5 -1
  82. package/dist/feature-libraries/default-schema/defaultFieldKinds.d.ts.map +1 -1
  83. package/dist/feature-libraries/default-schema/defaultFieldKinds.js +14 -2
  84. package/dist/feature-libraries/default-schema/defaultFieldKinds.js.map +1 -1
  85. package/dist/feature-libraries/default-schema/defaultSchema.d.ts.map +1 -1
  86. package/dist/feature-libraries/default-schema/defaultSchema.js +0 -2
  87. package/dist/feature-libraries/default-schema/defaultSchema.js.map +1 -1
  88. package/dist/feature-libraries/default-schema/index.d.ts +1 -1
  89. package/dist/feature-libraries/default-schema/index.d.ts.map +1 -1
  90. package/dist/feature-libraries/default-schema/index.js +2 -2
  91. package/dist/feature-libraries/default-schema/index.js.map +1 -1
  92. package/dist/feature-libraries/default-schema/schemaChecker.d.ts +14 -4
  93. package/dist/feature-libraries/default-schema/schemaChecker.d.ts.map +1 -1
  94. package/dist/feature-libraries/default-schema/schemaChecker.js +31 -26
  95. package/dist/feature-libraries/default-schema/schemaChecker.js.map +1 -1
  96. package/dist/feature-libraries/index.d.ts +1 -2
  97. package/dist/feature-libraries/index.d.ts.map +1 -1
  98. package/dist/feature-libraries/index.js +2 -4
  99. package/dist/feature-libraries/index.js.map +1 -1
  100. package/dist/feature-libraries/modular-schema/comparison.d.ts +5 -6
  101. package/dist/feature-libraries/modular-schema/comparison.d.ts.map +1 -1
  102. package/dist/feature-libraries/modular-schema/comparison.js +15 -16
  103. package/dist/feature-libraries/modular-schema/comparison.js.map +1 -1
  104. package/dist/feature-libraries/modular-schema/modularChangeFormat.d.ts +9 -3
  105. package/dist/feature-libraries/modular-schema/modularChangeFormat.d.ts.map +1 -1
  106. package/dist/feature-libraries/object-forest/objectForest.d.ts.map +1 -1
  107. package/dist/feature-libraries/object-forest/objectForest.js +2 -3
  108. package/dist/feature-libraries/object-forest/objectForest.js.map +1 -1
  109. package/dist/index.d.ts +1 -1
  110. package/dist/index.d.ts.map +1 -1
  111. package/dist/index.js +6 -2
  112. package/dist/index.js.map +1 -1
  113. package/dist/packageVersion.d.ts +1 -1
  114. package/dist/packageVersion.js +1 -1
  115. package/dist/packageVersion.js.map +1 -1
  116. package/dist/shared-tree/independentView.d.ts +8 -0
  117. package/dist/shared-tree/independentView.d.ts.map +1 -1
  118. package/dist/shared-tree/independentView.js +23 -11
  119. package/dist/shared-tree/independentView.js.map +1 -1
  120. package/dist/shared-tree/schematizeTree.js +1 -1
  121. package/dist/shared-tree/schematizeTree.js.map +1 -1
  122. package/dist/shared-tree/schematizingTreeView.d.ts +0 -1
  123. package/dist/shared-tree/schematizingTreeView.d.ts.map +1 -1
  124. package/dist/shared-tree/schematizingTreeView.js +7 -10
  125. package/dist/shared-tree/schematizingTreeView.js.map +1 -1
  126. package/dist/shared-tree/sharedTree.d.ts.map +1 -1
  127. package/dist/shared-tree/sharedTree.js +1 -29
  128. package/dist/shared-tree/sharedTree.js.map +1 -1
  129. package/dist/shared-tree/treeAlpha.d.ts +20 -6
  130. package/dist/shared-tree/treeAlpha.d.ts.map +1 -1
  131. package/dist/shared-tree/treeAlpha.js +9 -4
  132. package/dist/shared-tree/treeAlpha.js.map +1 -1
  133. package/dist/shared-tree/treeCheckout.d.ts +2 -1
  134. package/dist/shared-tree/treeCheckout.d.ts.map +1 -1
  135. package/dist/shared-tree/treeCheckout.js +32 -0
  136. package/dist/shared-tree/treeCheckout.js.map +1 -1
  137. package/dist/shared-tree-core/branch.d.ts.map +1 -1
  138. package/dist/shared-tree-core/branch.js +1 -1
  139. package/dist/shared-tree-core/branch.js.map +1 -1
  140. package/dist/simple-tree/api/conciseTree.d.ts +2 -2
  141. package/dist/simple-tree/api/conciseTree.d.ts.map +1 -1
  142. package/dist/simple-tree/api/conciseTree.js +6 -6
  143. package/dist/simple-tree/api/conciseTree.js.map +1 -1
  144. package/dist/simple-tree/api/configuration.d.ts +8 -2
  145. package/dist/simple-tree/api/configuration.d.ts.map +1 -1
  146. package/dist/simple-tree/api/configuration.js.map +1 -1
  147. package/dist/simple-tree/api/create.d.ts +8 -7
  148. package/dist/simple-tree/api/create.d.ts.map +1 -1
  149. package/dist/simple-tree/api/create.js +35 -22
  150. package/dist/simple-tree/api/create.js.map +1 -1
  151. package/dist/simple-tree/api/customTree.d.ts +25 -4
  152. package/dist/simple-tree/api/customTree.d.ts.map +1 -1
  153. package/dist/simple-tree/api/customTree.js +42 -16
  154. package/dist/simple-tree/api/customTree.js.map +1 -1
  155. package/dist/simple-tree/api/discrepancies.d.ts +98 -0
  156. package/dist/simple-tree/api/discrepancies.d.ts.map +1 -0
  157. package/dist/simple-tree/api/discrepancies.js +255 -0
  158. package/dist/simple-tree/api/discrepancies.js.map +1 -0
  159. package/dist/simple-tree/api/schemaCompatibilityTester.d.ts +9 -7
  160. package/dist/simple-tree/api/schemaCompatibilityTester.d.ts.map +1 -1
  161. package/dist/simple-tree/api/schemaCompatibilityTester.js +18 -117
  162. package/dist/simple-tree/api/schemaCompatibilityTester.js.map +1 -1
  163. package/dist/simple-tree/api/schemaFactory.d.ts +7 -4
  164. package/dist/simple-tree/api/schemaFactory.d.ts.map +1 -1
  165. package/dist/simple-tree/api/schemaFactory.js.map +1 -1
  166. package/dist/simple-tree/api/storedSchema.d.ts.map +1 -1
  167. package/dist/simple-tree/api/storedSchema.js +5 -1
  168. package/dist/simple-tree/api/storedSchema.js.map +1 -1
  169. package/dist/simple-tree/api/treeBeta.d.ts +2 -2
  170. package/dist/simple-tree/api/treeBeta.d.ts.map +1 -1
  171. package/dist/simple-tree/api/treeBeta.js +10 -4
  172. package/dist/simple-tree/api/treeBeta.js.map +1 -1
  173. package/dist/simple-tree/api/verboseTree.d.ts +2 -2
  174. package/dist/simple-tree/api/verboseTree.d.ts.map +1 -1
  175. package/dist/simple-tree/api/verboseTree.js +15 -15
  176. package/dist/simple-tree/api/verboseTree.js.map +1 -1
  177. package/dist/simple-tree/core/allowedTypes.d.ts +20 -4
  178. package/dist/simple-tree/core/allowedTypes.d.ts.map +1 -1
  179. package/dist/simple-tree/core/allowedTypes.js +45 -13
  180. package/dist/simple-tree/core/allowedTypes.js.map +1 -1
  181. package/dist/simple-tree/core/context.d.ts +13 -2
  182. package/dist/simple-tree/core/context.d.ts.map +1 -1
  183. package/dist/simple-tree/core/context.js +22 -9
  184. package/dist/simple-tree/core/context.js.map +1 -1
  185. package/dist/simple-tree/core/index.d.ts +2 -2
  186. package/dist/simple-tree/core/index.d.ts.map +1 -1
  187. package/dist/simple-tree/core/index.js +3 -1
  188. package/dist/simple-tree/core/index.js.map +1 -1
  189. package/dist/simple-tree/core/treeNodeKernel.d.ts +1 -1
  190. package/dist/simple-tree/core/treeNodeKernel.js +1 -1
  191. package/dist/simple-tree/core/treeNodeKernel.js.map +1 -1
  192. package/dist/simple-tree/core/treeNodeValid.d.ts +1 -1
  193. package/dist/simple-tree/core/treeNodeValid.d.ts.map +1 -1
  194. package/dist/simple-tree/core/treeNodeValid.js +8 -1
  195. package/dist/simple-tree/core/treeNodeValid.js.map +1 -1
  196. package/dist/simple-tree/core/walkSchema.d.ts +3 -0
  197. package/dist/simple-tree/core/walkSchema.d.ts.map +1 -1
  198. package/dist/simple-tree/core/walkSchema.js +2 -0
  199. package/dist/simple-tree/core/walkSchema.js.map +1 -1
  200. package/dist/simple-tree/createContext.d.ts +2 -0
  201. package/dist/simple-tree/createContext.d.ts.map +1 -1
  202. package/dist/simple-tree/createContext.js +3 -1
  203. package/dist/simple-tree/createContext.js.map +1 -1
  204. package/dist/simple-tree/fieldSchema.d.ts +1 -0
  205. package/dist/simple-tree/fieldSchema.d.ts.map +1 -1
  206. package/dist/simple-tree/fieldSchema.js +1 -0
  207. package/dist/simple-tree/fieldSchema.js.map +1 -1
  208. package/dist/simple-tree/index.d.ts +4 -4
  209. package/dist/simple-tree/index.d.ts.map +1 -1
  210. package/dist/simple-tree/index.js +7 -8
  211. package/dist/simple-tree/index.js.map +1 -1
  212. package/dist/simple-tree/node-kinds/array/arrayNode.d.ts.map +1 -1
  213. package/dist/simple-tree/node-kinds/array/arrayNode.js +1 -1
  214. package/dist/simple-tree/node-kinds/array/arrayNode.js.map +1 -1
  215. package/dist/simple-tree/node-kinds/index.d.ts +1 -1
  216. package/dist/simple-tree/node-kinds/index.d.ts.map +1 -1
  217. package/dist/simple-tree/node-kinds/index.js +1 -2
  218. package/dist/simple-tree/node-kinds/index.js.map +1 -1
  219. package/dist/simple-tree/node-kinds/object/index.d.ts +1 -1
  220. package/dist/simple-tree/node-kinds/object/index.d.ts.map +1 -1
  221. package/dist/simple-tree/node-kinds/object/index.js +1 -2
  222. package/dist/simple-tree/node-kinds/object/index.js.map +1 -1
  223. package/dist/simple-tree/node-kinds/object/objectNode.d.ts +2 -7
  224. package/dist/simple-tree/node-kinds/object/objectNode.d.ts.map +1 -1
  225. package/dist/simple-tree/node-kinds/object/objectNode.js +4 -18
  226. package/dist/simple-tree/node-kinds/object/objectNode.js.map +1 -1
  227. package/dist/simple-tree/prepareForInsertion.d.ts +5 -5
  228. package/dist/simple-tree/prepareForInsertion.d.ts.map +1 -1
  229. package/dist/simple-tree/prepareForInsertion.js +9 -3
  230. package/dist/simple-tree/prepareForInsertion.js.map +1 -1
  231. package/dist/simple-tree/toStoredSchema.d.ts +3 -0
  232. package/dist/simple-tree/toStoredSchema.d.ts.map +1 -1
  233. package/dist/simple-tree/toStoredSchema.js +3 -0
  234. package/dist/simple-tree/toStoredSchema.js.map +1 -1
  235. package/dist/simple-tree/unhydratedFlexTreeFromInsertable.d.ts +2 -2
  236. package/dist/simple-tree/unhydratedFlexTreeFromInsertable.d.ts.map +1 -1
  237. package/dist/simple-tree/unhydratedFlexTreeFromInsertable.js.map +1 -1
  238. package/dist/simple-tree/walkFieldSchema.d.ts +1 -0
  239. package/dist/simple-tree/walkFieldSchema.d.ts.map +1 -1
  240. package/dist/simple-tree/walkFieldSchema.js +1 -0
  241. package/dist/simple-tree/walkFieldSchema.js.map +1 -1
  242. package/lib/codec/codec.d.ts +2 -1
  243. package/lib/codec/codec.d.ts.map +1 -1
  244. package/lib/codec/codec.js +4 -3
  245. package/lib/codec/codec.js.map +1 -1
  246. package/lib/core/index.d.ts +1 -1
  247. package/lib/core/index.d.ts.map +1 -1
  248. package/lib/core/index.js +1 -1
  249. package/lib/core/index.js.map +1 -1
  250. package/lib/core/rebase/index.d.ts +1 -1
  251. package/lib/core/rebase/index.d.ts.map +1 -1
  252. package/lib/core/rebase/index.js +1 -1
  253. package/lib/core/rebase/index.js.map +1 -1
  254. package/lib/core/rebase/types.d.ts +3 -1
  255. package/lib/core/rebase/types.d.ts.map +1 -1
  256. package/lib/core/rebase/types.js +1 -0
  257. package/lib/core/rebase/types.js.map +1 -1
  258. package/lib/core/schema-stored/schema.d.ts +1 -23
  259. package/lib/core/schema-stored/schema.d.ts.map +1 -1
  260. package/lib/core/schema-stored/schema.js +2 -2
  261. package/lib/core/schema-stored/schema.js.map +1 -1
  262. package/lib/core/tree/detachedFieldIndex.d.ts.map +1 -1
  263. package/lib/core/tree/detachedFieldIndex.js +2 -3
  264. package/lib/core/tree/detachedFieldIndex.js.map +1 -1
  265. package/lib/core/tree/detachedFieldIndexCodecCommon.d.ts +17 -0
  266. package/lib/core/tree/detachedFieldIndexCodecCommon.d.ts.map +1 -0
  267. package/lib/core/tree/detachedFieldIndexCodecCommon.js +64 -0
  268. package/lib/core/tree/detachedFieldIndexCodecCommon.js.map +1 -0
  269. package/lib/core/tree/detachedFieldIndexCodecV1.d.ts +11 -0
  270. package/lib/core/tree/detachedFieldIndexCodecV1.d.ts.map +1 -0
  271. package/lib/core/tree/detachedFieldIndexCodecV1.js +51 -0
  272. package/lib/core/tree/detachedFieldIndexCodecV1.js.map +1 -0
  273. package/lib/core/tree/detachedFieldIndexCodecV2.d.ts +11 -0
  274. package/lib/core/tree/detachedFieldIndexCodecV2.d.ts.map +1 -0
  275. package/lib/core/tree/detachedFieldIndexCodecV2.js +45 -0
  276. package/lib/core/tree/detachedFieldIndexCodecV2.js.map +1 -0
  277. package/lib/core/tree/detachedFieldIndexCodecs.d.ts +11 -0
  278. package/lib/core/tree/detachedFieldIndexCodecs.d.ts.map +1 -0
  279. package/lib/core/tree/detachedFieldIndexCodecs.js +21 -0
  280. package/lib/core/tree/detachedFieldIndexCodecs.js.map +1 -0
  281. package/lib/core/tree/detachedFieldIndexFormatCommon.d.ts +37 -0
  282. package/lib/core/tree/detachedFieldIndexFormatCommon.d.ts.map +1 -0
  283. package/lib/core/tree/{detachedFieldIndexFormat.js → detachedFieldIndexFormatCommon.js} +13 -10
  284. package/lib/core/tree/detachedFieldIndexFormatCommon.js.map +1 -0
  285. package/lib/core/tree/detachedFieldIndexFormatV1.d.ts +13 -0
  286. package/lib/core/tree/detachedFieldIndexFormatV1.d.ts.map +1 -0
  287. package/lib/core/tree/detachedFieldIndexFormatV1.js +9 -0
  288. package/lib/core/tree/detachedFieldIndexFormatV1.js.map +1 -0
  289. package/lib/core/tree/detachedFieldIndexFormatV2.d.ts +14 -0
  290. package/lib/core/tree/detachedFieldIndexFormatV2.d.ts.map +1 -0
  291. package/lib/core/tree/detachedFieldIndexFormatV2.js +11 -0
  292. package/lib/core/tree/detachedFieldIndexFormatV2.js.map +1 -0
  293. package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.d.ts +9 -9
  294. package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.d.ts.map +1 -1
  295. package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.js +19 -19
  296. package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.js.map +1 -1
  297. package/lib/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.d.ts +4 -2
  298. package/lib/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.d.ts.map +1 -1
  299. package/lib/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.js +4 -4
  300. package/lib/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.js.map +1 -1
  301. package/lib/feature-libraries/chunked-forest/codec/compressedEncode.d.ts +50 -31
  302. package/lib/feature-libraries/chunked-forest/codec/compressedEncode.d.ts.map +1 -1
  303. package/lib/feature-libraries/chunked-forest/codec/compressedEncode.js +70 -57
  304. package/lib/feature-libraries/chunked-forest/codec/compressedEncode.js.map +1 -1
  305. package/lib/feature-libraries/chunked-forest/codec/format.d.ts +20 -14
  306. package/lib/feature-libraries/chunked-forest/codec/format.d.ts.map +1 -1
  307. package/lib/feature-libraries/chunked-forest/codec/format.js +17 -11
  308. package/lib/feature-libraries/chunked-forest/codec/format.js.map +1 -1
  309. package/{dist/feature-libraries/chunked-forest/codec/nodeShape.d.ts → lib/feature-libraries/chunked-forest/codec/nodeEncoder.d.ts} +20 -14
  310. package/lib/feature-libraries/chunked-forest/codec/nodeEncoder.d.ts.map +1 -0
  311. package/lib/feature-libraries/chunked-forest/codec/{nodeShape.js → nodeEncoder.js} +21 -15
  312. package/lib/feature-libraries/chunked-forest/codec/nodeEncoder.js.map +1 -0
  313. package/lib/feature-libraries/chunked-forest/codec/schemaBasedEncode.d.ts +7 -7
  314. package/lib/feature-libraries/chunked-forest/codec/schemaBasedEncode.d.ts.map +1 -1
  315. package/lib/feature-libraries/chunked-forest/codec/schemaBasedEncode.js +19 -19
  316. package/lib/feature-libraries/chunked-forest/codec/schemaBasedEncode.js.map +1 -1
  317. package/lib/feature-libraries/chunked-forest/codec/uncompressedEncode.js +2 -2
  318. package/lib/feature-libraries/chunked-forest/codec/uncompressedEncode.js.map +1 -1
  319. package/lib/feature-libraries/default-schema/defaultFieldKinds.d.ts +5 -1
  320. package/lib/feature-libraries/default-schema/defaultFieldKinds.d.ts.map +1 -1
  321. package/lib/feature-libraries/default-schema/defaultFieldKinds.js +14 -2
  322. package/lib/feature-libraries/default-schema/defaultFieldKinds.js.map +1 -1
  323. package/lib/feature-libraries/default-schema/defaultSchema.d.ts.map +1 -1
  324. package/lib/feature-libraries/default-schema/defaultSchema.js +0 -2
  325. package/lib/feature-libraries/default-schema/defaultSchema.js.map +1 -1
  326. package/lib/feature-libraries/default-schema/index.d.ts +1 -1
  327. package/lib/feature-libraries/default-schema/index.d.ts.map +1 -1
  328. package/lib/feature-libraries/default-schema/index.js +1 -1
  329. package/lib/feature-libraries/default-schema/index.js.map +1 -1
  330. package/lib/feature-libraries/default-schema/schemaChecker.d.ts +14 -4
  331. package/lib/feature-libraries/default-schema/schemaChecker.d.ts.map +1 -1
  332. package/lib/feature-libraries/default-schema/schemaChecker.js +29 -24
  333. package/lib/feature-libraries/default-schema/schemaChecker.js.map +1 -1
  334. package/lib/feature-libraries/index.d.ts +1 -2
  335. package/lib/feature-libraries/index.d.ts.map +1 -1
  336. package/lib/feature-libraries/index.js +1 -2
  337. package/lib/feature-libraries/index.js.map +1 -1
  338. package/lib/feature-libraries/modular-schema/comparison.d.ts +5 -6
  339. package/lib/feature-libraries/modular-schema/comparison.d.ts.map +1 -1
  340. package/lib/feature-libraries/modular-schema/comparison.js +14 -14
  341. package/lib/feature-libraries/modular-schema/comparison.js.map +1 -1
  342. package/lib/feature-libraries/modular-schema/modularChangeFormat.d.ts +9 -3
  343. package/lib/feature-libraries/modular-schema/modularChangeFormat.d.ts.map +1 -1
  344. package/lib/feature-libraries/object-forest/objectForest.d.ts.map +1 -1
  345. package/lib/feature-libraries/object-forest/objectForest.js +3 -4
  346. package/lib/feature-libraries/object-forest/objectForest.js.map +1 -1
  347. package/lib/index.d.ts +1 -1
  348. package/lib/index.d.ts.map +1 -1
  349. package/lib/index.js +2 -2
  350. package/lib/index.js.map +1 -1
  351. package/lib/packageVersion.d.ts +1 -1
  352. package/lib/packageVersion.js +1 -1
  353. package/lib/packageVersion.js.map +1 -1
  354. package/lib/shared-tree/independentView.d.ts +8 -0
  355. package/lib/shared-tree/independentView.d.ts.map +1 -1
  356. package/lib/shared-tree/independentView.js +21 -10
  357. package/lib/shared-tree/independentView.js.map +1 -1
  358. package/lib/shared-tree/schematizeTree.js +1 -1
  359. package/lib/shared-tree/schematizeTree.js.map +1 -1
  360. package/lib/shared-tree/schematizingTreeView.d.ts +0 -1
  361. package/lib/shared-tree/schematizingTreeView.d.ts.map +1 -1
  362. package/lib/shared-tree/schematizingTreeView.js +8 -11
  363. package/lib/shared-tree/schematizingTreeView.js.map +1 -1
  364. package/lib/shared-tree/sharedTree.d.ts.map +1 -1
  365. package/lib/shared-tree/sharedTree.js +2 -30
  366. package/lib/shared-tree/sharedTree.js.map +1 -1
  367. package/lib/shared-tree/treeAlpha.d.ts +20 -6
  368. package/lib/shared-tree/treeAlpha.d.ts.map +1 -1
  369. package/lib/shared-tree/treeAlpha.js +10 -5
  370. package/lib/shared-tree/treeAlpha.js.map +1 -1
  371. package/lib/shared-tree/treeCheckout.d.ts +2 -1
  372. package/lib/shared-tree/treeCheckout.d.ts.map +1 -1
  373. package/lib/shared-tree/treeCheckout.js +33 -1
  374. package/lib/shared-tree/treeCheckout.js.map +1 -1
  375. package/lib/shared-tree-core/branch.d.ts.map +1 -1
  376. package/lib/shared-tree-core/branch.js +1 -1
  377. package/lib/shared-tree-core/branch.js.map +1 -1
  378. package/lib/simple-tree/api/conciseTree.d.ts +2 -2
  379. package/lib/simple-tree/api/conciseTree.d.ts.map +1 -1
  380. package/lib/simple-tree/api/conciseTree.js +6 -6
  381. package/lib/simple-tree/api/conciseTree.js.map +1 -1
  382. package/lib/simple-tree/api/configuration.d.ts +8 -2
  383. package/lib/simple-tree/api/configuration.d.ts.map +1 -1
  384. package/lib/simple-tree/api/configuration.js.map +1 -1
  385. package/lib/simple-tree/api/create.d.ts +8 -7
  386. package/lib/simple-tree/api/create.d.ts.map +1 -1
  387. package/lib/simple-tree/api/create.js +38 -25
  388. package/lib/simple-tree/api/create.js.map +1 -1
  389. package/lib/simple-tree/api/customTree.d.ts +25 -4
  390. package/lib/simple-tree/api/customTree.d.ts.map +1 -1
  391. package/lib/simple-tree/api/customTree.js +43 -17
  392. package/lib/simple-tree/api/customTree.js.map +1 -1
  393. package/lib/simple-tree/api/discrepancies.d.ts +98 -0
  394. package/lib/simple-tree/api/discrepancies.d.ts.map +1 -0
  395. package/lib/simple-tree/{discrepancies.js → api/discrepancies.js} +80 -206
  396. package/lib/simple-tree/api/discrepancies.js.map +1 -0
  397. package/lib/simple-tree/api/schemaCompatibilityTester.d.ts +9 -7
  398. package/lib/simple-tree/api/schemaCompatibilityTester.d.ts.map +1 -1
  399. package/lib/simple-tree/api/schemaCompatibilityTester.js +19 -118
  400. package/lib/simple-tree/api/schemaCompatibilityTester.js.map +1 -1
  401. package/lib/simple-tree/api/schemaFactory.d.ts +7 -4
  402. package/lib/simple-tree/api/schemaFactory.d.ts.map +1 -1
  403. package/lib/simple-tree/api/schemaFactory.js.map +1 -1
  404. package/lib/simple-tree/api/storedSchema.d.ts.map +1 -1
  405. package/lib/simple-tree/api/storedSchema.js +6 -2
  406. package/lib/simple-tree/api/storedSchema.js.map +1 -1
  407. package/lib/simple-tree/api/treeBeta.d.ts +2 -2
  408. package/lib/simple-tree/api/treeBeta.d.ts.map +1 -1
  409. package/lib/simple-tree/api/treeBeta.js +8 -2
  410. package/lib/simple-tree/api/treeBeta.js.map +1 -1
  411. package/lib/simple-tree/api/verboseTree.d.ts +2 -2
  412. package/lib/simple-tree/api/verboseTree.d.ts.map +1 -1
  413. package/lib/simple-tree/api/verboseTree.js +9 -9
  414. package/lib/simple-tree/api/verboseTree.js.map +1 -1
  415. package/lib/simple-tree/core/allowedTypes.d.ts +20 -4
  416. package/lib/simple-tree/core/allowedTypes.d.ts.map +1 -1
  417. package/lib/simple-tree/core/allowedTypes.js +42 -12
  418. package/lib/simple-tree/core/allowedTypes.js.map +1 -1
  419. package/lib/simple-tree/core/context.d.ts +13 -2
  420. package/lib/simple-tree/core/context.d.ts.map +1 -1
  421. package/lib/simple-tree/core/context.js +22 -9
  422. package/lib/simple-tree/core/context.js.map +1 -1
  423. package/lib/simple-tree/core/index.d.ts +2 -2
  424. package/lib/simple-tree/core/index.d.ts.map +1 -1
  425. package/lib/simple-tree/core/index.js +2 -2
  426. package/lib/simple-tree/core/index.js.map +1 -1
  427. package/lib/simple-tree/core/treeNodeKernel.d.ts +1 -1
  428. package/lib/simple-tree/core/treeNodeKernel.js +1 -1
  429. package/lib/simple-tree/core/treeNodeKernel.js.map +1 -1
  430. package/lib/simple-tree/core/treeNodeValid.d.ts +1 -1
  431. package/lib/simple-tree/core/treeNodeValid.d.ts.map +1 -1
  432. package/lib/simple-tree/core/treeNodeValid.js +8 -1
  433. package/lib/simple-tree/core/treeNodeValid.js.map +1 -1
  434. package/lib/simple-tree/core/walkSchema.d.ts +3 -0
  435. package/lib/simple-tree/core/walkSchema.d.ts.map +1 -1
  436. package/lib/simple-tree/core/walkSchema.js +2 -0
  437. package/lib/simple-tree/core/walkSchema.js.map +1 -1
  438. package/lib/simple-tree/createContext.d.ts +2 -0
  439. package/lib/simple-tree/createContext.d.ts.map +1 -1
  440. package/lib/simple-tree/createContext.js +3 -1
  441. package/lib/simple-tree/createContext.js.map +1 -1
  442. package/lib/simple-tree/fieldSchema.d.ts +1 -0
  443. package/lib/simple-tree/fieldSchema.d.ts.map +1 -1
  444. package/lib/simple-tree/fieldSchema.js +1 -0
  445. package/lib/simple-tree/fieldSchema.js.map +1 -1
  446. package/lib/simple-tree/index.d.ts +4 -4
  447. package/lib/simple-tree/index.d.ts.map +1 -1
  448. package/lib/simple-tree/index.js +4 -4
  449. package/lib/simple-tree/index.js.map +1 -1
  450. package/lib/simple-tree/node-kinds/array/arrayNode.d.ts.map +1 -1
  451. package/lib/simple-tree/node-kinds/array/arrayNode.js +1 -1
  452. package/lib/simple-tree/node-kinds/array/arrayNode.js.map +1 -1
  453. package/lib/simple-tree/node-kinds/index.d.ts +1 -1
  454. package/lib/simple-tree/node-kinds/index.d.ts.map +1 -1
  455. package/lib/simple-tree/node-kinds/index.js +1 -1
  456. package/lib/simple-tree/node-kinds/index.js.map +1 -1
  457. package/lib/simple-tree/node-kinds/object/index.d.ts +1 -1
  458. package/lib/simple-tree/node-kinds/object/index.d.ts.map +1 -1
  459. package/lib/simple-tree/node-kinds/object/index.js +1 -1
  460. package/lib/simple-tree/node-kinds/object/index.js.map +1 -1
  461. package/lib/simple-tree/node-kinds/object/objectNode.d.ts +2 -7
  462. package/lib/simple-tree/node-kinds/object/objectNode.d.ts.map +1 -1
  463. package/lib/simple-tree/node-kinds/object/objectNode.js +3 -16
  464. package/lib/simple-tree/node-kinds/object/objectNode.js.map +1 -1
  465. package/lib/simple-tree/prepareForInsertion.d.ts +5 -5
  466. package/lib/simple-tree/prepareForInsertion.d.ts.map +1 -1
  467. package/lib/simple-tree/prepareForInsertion.js +11 -5
  468. package/lib/simple-tree/prepareForInsertion.js.map +1 -1
  469. package/lib/simple-tree/toStoredSchema.d.ts +3 -0
  470. package/lib/simple-tree/toStoredSchema.d.ts.map +1 -1
  471. package/lib/simple-tree/toStoredSchema.js +3 -0
  472. package/lib/simple-tree/toStoredSchema.js.map +1 -1
  473. package/lib/simple-tree/unhydratedFlexTreeFromInsertable.d.ts +2 -2
  474. package/lib/simple-tree/unhydratedFlexTreeFromInsertable.d.ts.map +1 -1
  475. package/lib/simple-tree/unhydratedFlexTreeFromInsertable.js +1 -1
  476. package/lib/simple-tree/unhydratedFlexTreeFromInsertable.js.map +1 -1
  477. package/lib/simple-tree/walkFieldSchema.d.ts +1 -0
  478. package/lib/simple-tree/walkFieldSchema.d.ts.map +1 -1
  479. package/lib/simple-tree/walkFieldSchema.js +1 -0
  480. package/lib/simple-tree/walkFieldSchema.js.map +1 -1
  481. package/package.json +23 -23
  482. package/src/codec/codec.ts +4 -3
  483. package/src/core/index.ts +2 -0
  484. package/src/core/rebase/index.ts +2 -0
  485. package/src/core/rebase/types.ts +4 -0
  486. package/src/core/schema-stored/schema.ts +2 -26
  487. package/src/core/tree/detachedFieldIndex.ts +4 -6
  488. package/src/core/tree/detachedFieldIndexCodecCommon.ts +87 -0
  489. package/src/core/tree/{detachedFieldIndexCodec.ts → detachedFieldIndexCodecV1.ts} +22 -68
  490. package/src/core/tree/detachedFieldIndexCodecV2.ts +72 -0
  491. package/src/core/tree/detachedFieldIndexCodecs.ts +44 -0
  492. package/src/core/tree/{detachedFieldIndexFormat.ts → detachedFieldIndexFormatCommon.ts} +32 -23
  493. package/src/core/tree/detachedFieldIndexFormatV1.ts +15 -0
  494. package/src/core/tree/detachedFieldIndexFormatV2.ts +17 -0
  495. package/src/feature-libraries/chunked-forest/codec/README.md +1 -1
  496. package/src/feature-libraries/chunked-forest/codec/chunkDecoding.ts +25 -25
  497. package/src/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.ts +10 -6
  498. package/src/feature-libraries/chunked-forest/codec/compressedEncode.ts +96 -73
  499. package/src/feature-libraries/chunked-forest/codec/format.ts +20 -14
  500. package/src/feature-libraries/chunked-forest/codec/{nodeShape.ts → nodeEncoder.ts} +23 -17
  501. package/src/feature-libraries/chunked-forest/codec/schemaBasedEncode.ts +34 -34
  502. package/src/feature-libraries/chunked-forest/codec/uncompressedEncode.ts +5 -5
  503. package/src/feature-libraries/default-schema/defaultFieldKinds.ts +10 -0
  504. package/src/feature-libraries/default-schema/defaultSchema.ts +0 -2
  505. package/src/feature-libraries/default-schema/index.ts +1 -1
  506. package/src/feature-libraries/default-schema/schemaChecker.ts +47 -30
  507. package/src/feature-libraries/index.ts +1 -3
  508. package/src/feature-libraries/modular-schema/comparison.ts +14 -29
  509. package/src/feature-libraries/object-forest/objectForest.ts +10 -6
  510. package/src/index.ts +5 -0
  511. package/src/packageVersion.ts +1 -1
  512. package/src/shared-tree/independentView.ts +45 -19
  513. package/src/shared-tree/schematizeTree.ts +1 -1
  514. package/src/shared-tree/schematizingTreeView.ts +16 -13
  515. package/src/shared-tree/sharedTree.ts +2 -42
  516. package/src/shared-tree/treeAlpha.ts +30 -18
  517. package/src/shared-tree/treeCheckout.ts +54 -10
  518. package/src/shared-tree-core/branch.ts +1 -6
  519. package/src/simple-tree/api/conciseTree.ts +9 -7
  520. package/src/simple-tree/api/configuration.ts +8 -2
  521. package/src/simple-tree/api/create.ts +49 -36
  522. package/src/simple-tree/api/customTree.ts +59 -20
  523. package/src/simple-tree/{discrepancies.ts → api/discrepancies.ts} +128 -303
  524. package/src/simple-tree/api/schemaCompatibilityTester.ts +27 -151
  525. package/src/simple-tree/api/schemaFactory.ts +7 -4
  526. package/src/simple-tree/api/storedSchema.ts +6 -9
  527. package/src/simple-tree/api/treeBeta.ts +17 -4
  528. package/src/simple-tree/api/verboseTree.ts +17 -8
  529. package/src/simple-tree/core/allowedTypes.ts +54 -21
  530. package/src/simple-tree/core/context.ts +24 -22
  531. package/src/simple-tree/core/index.ts +2 -1
  532. package/src/simple-tree/core/treeNodeKernel.ts +1 -1
  533. package/src/simple-tree/core/treeNodeValid.ts +9 -2
  534. package/src/simple-tree/core/walkSchema.ts +3 -0
  535. package/src/simple-tree/createContext.ts +6 -1
  536. package/src/simple-tree/fieldSchema.ts +1 -0
  537. package/src/simple-tree/index.ts +5 -10
  538. package/src/simple-tree/node-kinds/array/arrayNode.ts +32 -19
  539. package/src/simple-tree/node-kinds/index.ts +0 -1
  540. package/src/simple-tree/node-kinds/object/index.ts +0 -1
  541. package/src/simple-tree/node-kinds/object/objectNode.ts +9 -27
  542. package/src/simple-tree/prepareForInsertion.ts +17 -9
  543. package/src/simple-tree/toStoredSchema.ts +3 -0
  544. package/src/simple-tree/unhydratedFlexTreeFromInsertable.ts +6 -2
  545. package/src/simple-tree/walkFieldSchema.ts +1 -0
  546. package/dist/core/tree/detachedFieldIndexCodec.d.ts +0 -11
  547. package/dist/core/tree/detachedFieldIndexCodec.d.ts.map +0 -1
  548. package/dist/core/tree/detachedFieldIndexCodec.js +0 -100
  549. package/dist/core/tree/detachedFieldIndexCodec.js.map +0 -1
  550. package/dist/core/tree/detachedFieldIndexFormat.d.ts +0 -33
  551. package/dist/core/tree/detachedFieldIndexFormat.d.ts.map +0 -1
  552. package/dist/core/tree/detachedFieldIndexFormat.js.map +0 -1
  553. package/dist/feature-libraries/chunked-forest/codec/nodeShape.d.ts.map +0 -1
  554. package/dist/feature-libraries/chunked-forest/codec/nodeShape.js.map +0 -1
  555. package/dist/feature-libraries/initializeForest.d.ts +0 -18
  556. package/dist/feature-libraries/initializeForest.d.ts.map +0 -1
  557. package/dist/feature-libraries/initializeForest.js +0 -35
  558. package/dist/feature-libraries/initializeForest.js.map +0 -1
  559. package/dist/simple-tree/discrepancies.d.ts +0 -167
  560. package/dist/simple-tree/discrepancies.d.ts.map +0 -1
  561. package/dist/simple-tree/discrepancies.js +0 -382
  562. package/dist/simple-tree/discrepancies.js.map +0 -1
  563. package/lib/core/tree/detachedFieldIndexCodec.d.ts +0 -11
  564. package/lib/core/tree/detachedFieldIndexCodec.d.ts.map +0 -1
  565. package/lib/core/tree/detachedFieldIndexCodec.js +0 -96
  566. package/lib/core/tree/detachedFieldIndexCodec.js.map +0 -1
  567. package/lib/core/tree/detachedFieldIndexFormat.d.ts +0 -33
  568. package/lib/core/tree/detachedFieldIndexFormat.d.ts.map +0 -1
  569. package/lib/core/tree/detachedFieldIndexFormat.js.map +0 -1
  570. package/lib/feature-libraries/chunked-forest/codec/nodeShape.d.ts.map +0 -1
  571. package/lib/feature-libraries/chunked-forest/codec/nodeShape.js.map +0 -1
  572. package/lib/feature-libraries/initializeForest.d.ts +0 -18
  573. package/lib/feature-libraries/initializeForest.d.ts.map +0 -1
  574. package/lib/feature-libraries/initializeForest.js +0 -31
  575. package/lib/feature-libraries/initializeForest.js.map +0 -1
  576. package/lib/simple-tree/discrepancies.d.ts +0 -167
  577. package/lib/simple-tree/discrepancies.d.ts.map +0 -1
  578. package/lib/simple-tree/discrepancies.js.map +0 -1
  579. package/src/feature-libraries/initializeForest.ts +0 -55
@@ -3,12 +3,13 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
  import { SchemaVersion } from "../../core/index.js";
6
- import { defaultSchemaPolicy, encodeTreeSchema, makeSchemaCodec, } from "../../feature-libraries/index.js";
6
+ import { encodeTreeSchema, makeSchemaCodec } from "../../feature-libraries/index.js";
7
7
  import { clientVersionToSchemaVersion,
8
8
  // eslint-disable-next-line import/no-internal-modules
9
9
  } from "../../feature-libraries/schema-index/index.js";
10
10
  import { normalizeFieldSchema } from "../fieldSchema.js";
11
11
  import { simpleToStoredSchema } from "../toStoredSchema.js";
12
+ import { TreeViewConfigurationAlpha } from "./configuration.js";
12
13
  import { SchemaCompatibilityTester } from "./schemaCompatibilityTester.js";
13
14
  /**
14
15
  * Dumps the "persisted" schema subset of the provided `schema` into a deterministic JSON-compatible, semi-human-readable format.
@@ -80,7 +81,10 @@ export function comparePersistedSchema(persisted, view, options) {
80
81
  // We only use the decode part, which always dispatches to the correct codec based on the version in the data, not the version passed to `makeSchemaCodec`.
81
82
  const schemaCodec = makeSchemaCodec(options, SchemaVersion.v1);
82
83
  const stored = schemaCodec.decode(persisted);
83
- const viewSchema = new SchemaCompatibilityTester(defaultSchemaPolicy, normalizeFieldSchema(view));
84
+ const config = new TreeViewConfigurationAlpha({
85
+ schema: normalizeFieldSchema(view),
86
+ });
87
+ const viewSchema = new SchemaCompatibilityTester(config);
84
88
  return viewSchema.checkCompatibility(stored);
85
89
  }
86
90
  //# sourceMappingURL=storedSchema.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"storedSchema.js","sourceRoot":"","sources":["../../../src/simple-tree/api/storedSchema.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EACN,mBAAmB,EACnB,gBAAgB,EAChB,eAAe,GACf,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EACN,4BAA4B;AAE5B,sDAAsD;EACtD,MAAM,+CAA+C,CAAC;AAEvD,OAAO,EAAE,oBAAoB,EAA4B,MAAM,mBAAmB,CAAC;AAEnF,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAE5D,OAAO,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;AAG3E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,MAAM,UAAU,sBAAsB,CACrC,MAAwB,EACxB,sBAA0C;IAE1C,MAAM,MAAM,GAAG,oBAAoB,CAAC,MAAM,CAAC,CAAC;IAC5C,MAAM,kBAAkB,GAAG,4BAA4B,CAAC,sBAAsB,CAAC,CAAC;IAChF,OAAO,gBAAgB,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAAC;AACrD,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,MAAM,UAAU,sBAAsB,CACrC,SAAyB,EACzB,IAAyB,EACzB,OAAsB;IAEtB,0DAA0D;IAC1D,2JAA2J;IAC3J,MAAM,WAAW,GAAG,eAAe,CAAC,OAAO,EAAE,aAAa,CAAC,EAAE,CAAC,CAAC;IAC/D,MAAM,MAAM,GAAG,WAAW,CAAC,MAAM,CAAC,SAAqB,CAAC,CAAC;IACzD,MAAM,UAAU,GAAG,IAAI,yBAAyB,CAC/C,mBAAmB,EACnB,oBAAoB,CAAC,IAAI,CAAC,CAC1B,CAAC;IACF,OAAO,UAAU,CAAC,kBAAkB,CAAC,MAAM,CAAC,CAAC;AAC9C,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { FluidClientVersion, ICodecOptions } from \"../../codec/index.js\";\nimport { SchemaVersion } from \"../../core/index.js\";\nimport {\n\tdefaultSchemaPolicy,\n\tencodeTreeSchema,\n\tmakeSchemaCodec,\n} from \"../../feature-libraries/index.js\";\nimport {\n\tclientVersionToSchemaVersion,\n\ttype FormatV1,\n\t// eslint-disable-next-line import/no-internal-modules\n} from \"../../feature-libraries/schema-index/index.js\";\nimport type { JsonCompatible } from \"../../util/index.js\";\nimport { normalizeFieldSchema, type ImplicitFieldSchema } from \"../fieldSchema.js\";\nimport type { SimpleTreeSchema } from \"../simpleSchema.js\";\nimport { simpleToStoredSchema } from \"../toStoredSchema.js\";\n\nimport { SchemaCompatibilityTester } from \"./schemaCompatibilityTester.js\";\nimport type { SchemaCompatibilityStatus } from \"./tree.js\";\n\n/**\n * Dumps the \"persisted\" schema subset of the provided `schema` into a deterministic JSON-compatible, semi-human-readable format.\n *\n * @param schema - The schema to dump.\n *\n * @remarks\n * This can be used to help inspect schema for debugging, and to save a snapshot of schema to help detect and review changes to an applications schema.\n * This format is also compatible with {@link ViewContent.schema}, {@link comparePersistedSchema} and {@link persistedToSimpleSchema}.\n *\n * This only includes the \"persisted\" subset of schema information, which means the portion which gets included in documents.\n * It thus uses \"persisted\" keys, see {@link FieldProps.key}.\n *\n * If two schema have identical \"persisted\" schema, then they are considered {@link SchemaCompatibilityStatus.isEquivalent|equivalent}.\n *\n * See also {@link comparePersistedSchema}.\n *\n * @example\n * An application could use this API to generate a `schema.json` file when it first releases,\n * then test that the schema is sill compatible with documents from that version with a test like :\n * ```typescript\n * assert.deepEqual(extractPersistedSchema(MySchema, FluidClientVersion.v2_0), require(\"./schema.json\"));\n * ```\n *\n * @privateRemarks\n * This currently uses the schema summary format, but that could be changed to something more human readable (particularly if the encoded format becomes less human readable).\n * This intentionally does not leak the format types in the API.\n *\n * Public API surface uses \"persisted\" terminology while internally we use \"stored\".\n * @alpha\n */\nexport function extractPersistedSchema(\n\tschema: SimpleTreeSchema,\n\toldestCompatibleClient: FluidClientVersion,\n): JsonCompatible {\n\tconst stored = simpleToStoredSchema(schema);\n\tconst schemaWriteVersion = clientVersionToSchemaVersion(oldestCompatibleClient);\n\treturn encodeTreeSchema(stored, schemaWriteVersion);\n}\n\n/**\n * Compares two schema extracted using {@link extractPersistedSchema}.\n * Reports the same compatibility that {@link TreeView.compatibility} would report if\n * opening a document that used the `persisted` schema and provided `view` to {@link ViewableTree.viewWith}.\n *\n * @param persisted - Schema persisted for a document. Typically persisted alongside the data and assumed to describe that data.\n * @param view - Schema which would be used to view persisted content.\n * @param options - {@link ICodecOptions} used when parsing the provided schema.\n * @param canInitialize - Passed through to the return value unchanged and otherwise unused.\n * @returns The {@link SchemaCompatibilityStatus} a {@link TreeView} would report for this combination of schema.\n *\n * @remarks\n * This uses the persisted formats for schema, meaning it only includes data which impacts compatibility.\n * It also uses the persisted format so that this API can be used in tests to compare against saved schema from previous versions of the application.\n *\n * @example\n * An application could use {@link extractPersistedSchema} to generate a `schema.json` file for various versions of the app,\n * then test that documents using those schema can be upgraded to work with the current schema using a test like:\n * ```typescript\n * assert(\n * \tcomparePersistedSchema(\n * \t\trequire(\"./schema.json\"),\n * \t\tMySchema,\n * \t\t{ jsonValidator: typeboxValidator },\n * \t\tfalse,\n * \t).canUpgrade,\n * );\n * ```\n * @alpha\n */\nexport function comparePersistedSchema(\n\tpersisted: JsonCompatible,\n\tview: ImplicitFieldSchema,\n\toptions: ICodecOptions,\n): Omit<SchemaCompatibilityStatus, \"canInitialize\"> {\n\t// Any version can be passed down to makeSchemaCodec here.\n\t// We only use the decode part, which always dispatches to the correct codec based on the version in the data, not the version passed to `makeSchemaCodec`.\n\tconst schemaCodec = makeSchemaCodec(options, SchemaVersion.v1);\n\tconst stored = schemaCodec.decode(persisted as FormatV1);\n\tconst viewSchema = new SchemaCompatibilityTester(\n\t\tdefaultSchemaPolicy,\n\t\tnormalizeFieldSchema(view),\n\t);\n\treturn viewSchema.checkCompatibility(stored);\n}\n"]}
1
+ {"version":3,"file":"storedSchema.js","sourceRoot":"","sources":["../../../src/simple-tree/api/storedSchema.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AACrF,OAAO,EACN,4BAA4B;AAE5B,sDAAsD;EACtD,MAAM,+CAA+C,CAAC;AAEvD,OAAO,EAAE,oBAAoB,EAA4B,MAAM,mBAAmB,CAAC;AAEnF,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,EAAE,0BAA0B,EAAE,MAAM,oBAAoB,CAAC;AAEhE,OAAO,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;AAG3E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,MAAM,UAAU,sBAAsB,CACrC,MAAwB,EACxB,sBAA0C;IAE1C,MAAM,MAAM,GAAG,oBAAoB,CAAC,MAAM,CAAC,CAAC;IAC5C,MAAM,kBAAkB,GAAG,4BAA4B,CAAC,sBAAsB,CAAC,CAAC;IAChF,OAAO,gBAAgB,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAAC;AACrD,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,MAAM,UAAU,sBAAsB,CACrC,SAAyB,EACzB,IAAyB,EACzB,OAAsB;IAEtB,0DAA0D;IAC1D,2JAA2J;IAC3J,MAAM,WAAW,GAAG,eAAe,CAAC,OAAO,EAAE,aAAa,CAAC,EAAE,CAAC,CAAC;IAC/D,MAAM,MAAM,GAAG,WAAW,CAAC,MAAM,CAAC,SAAqB,CAAC,CAAC;IACzD,MAAM,MAAM,GAAG,IAAI,0BAA0B,CAAC;QAC7C,MAAM,EAAE,oBAAoB,CAAC,IAAI,CAAC;KAClC,CAAC,CAAC;IACH,MAAM,UAAU,GAAG,IAAI,yBAAyB,CAAC,MAAM,CAAC,CAAC;IACzD,OAAO,UAAU,CAAC,kBAAkB,CAAC,MAAM,CAAC,CAAC;AAC9C,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { FluidClientVersion, ICodecOptions } from \"../../codec/index.js\";\nimport { SchemaVersion } from \"../../core/index.js\";\nimport { encodeTreeSchema, makeSchemaCodec } from \"../../feature-libraries/index.js\";\nimport {\n\tclientVersionToSchemaVersion,\n\ttype FormatV1,\n\t// eslint-disable-next-line import/no-internal-modules\n} from \"../../feature-libraries/schema-index/index.js\";\nimport type { JsonCompatible } from \"../../util/index.js\";\nimport { normalizeFieldSchema, type ImplicitFieldSchema } from \"../fieldSchema.js\";\nimport type { SimpleTreeSchema } from \"../simpleSchema.js\";\nimport { simpleToStoredSchema } from \"../toStoredSchema.js\";\nimport { TreeViewConfigurationAlpha } from \"./configuration.js\";\n\nimport { SchemaCompatibilityTester } from \"./schemaCompatibilityTester.js\";\nimport type { SchemaCompatibilityStatus } from \"./tree.js\";\n\n/**\n * Dumps the \"persisted\" schema subset of the provided `schema` into a deterministic JSON-compatible, semi-human-readable format.\n *\n * @param schema - The schema to dump.\n *\n * @remarks\n * This can be used to help inspect schema for debugging, and to save a snapshot of schema to help detect and review changes to an applications schema.\n * This format is also compatible with {@link ViewContent.schema}, {@link comparePersistedSchema} and {@link persistedToSimpleSchema}.\n *\n * This only includes the \"persisted\" subset of schema information, which means the portion which gets included in documents.\n * It thus uses \"persisted\" keys, see {@link FieldProps.key}.\n *\n * If two schema have identical \"persisted\" schema, then they are considered {@link SchemaCompatibilityStatus.isEquivalent|equivalent}.\n *\n * See also {@link comparePersistedSchema}.\n *\n * @example\n * An application could use this API to generate a `schema.json` file when it first releases,\n * then test that the schema is sill compatible with documents from that version with a test like :\n * ```typescript\n * assert.deepEqual(extractPersistedSchema(MySchema, FluidClientVersion.v2_0), require(\"./schema.json\"));\n * ```\n *\n * @privateRemarks\n * This currently uses the schema summary format, but that could be changed to something more human readable (particularly if the encoded format becomes less human readable).\n * This intentionally does not leak the format types in the API.\n *\n * Public API surface uses \"persisted\" terminology while internally we use \"stored\".\n * @alpha\n */\nexport function extractPersistedSchema(\n\tschema: SimpleTreeSchema,\n\toldestCompatibleClient: FluidClientVersion,\n): JsonCompatible {\n\tconst stored = simpleToStoredSchema(schema);\n\tconst schemaWriteVersion = clientVersionToSchemaVersion(oldestCompatibleClient);\n\treturn encodeTreeSchema(stored, schemaWriteVersion);\n}\n\n/**\n * Compares two schema extracted using {@link extractPersistedSchema}.\n * Reports the same compatibility that {@link TreeView.compatibility} would report if\n * opening a document that used the `persisted` schema and provided `view` to {@link ViewableTree.viewWith}.\n *\n * @param persisted - Schema persisted for a document. Typically persisted alongside the data and assumed to describe that data.\n * @param view - Schema which would be used to view persisted content.\n * @param options - {@link ICodecOptions} used when parsing the provided schema.\n * @param canInitialize - Passed through to the return value unchanged and otherwise unused.\n * @returns The {@link SchemaCompatibilityStatus} a {@link TreeView} would report for this combination of schema.\n *\n * @remarks\n * This uses the persisted formats for schema, meaning it only includes data which impacts compatibility.\n * It also uses the persisted format so that this API can be used in tests to compare against saved schema from previous versions of the application.\n *\n * @example\n * An application could use {@link extractPersistedSchema} to generate a `schema.json` file for various versions of the app,\n * then test that documents using those schema can be upgraded to work with the current schema using a test like:\n * ```typescript\n * assert(\n * \tcomparePersistedSchema(\n * \t\trequire(\"./schema.json\"),\n * \t\tMySchema,\n * \t\t{ jsonValidator: typeboxValidator },\n * \t\tfalse,\n * \t).canUpgrade,\n * );\n * ```\n * @alpha\n */\nexport function comparePersistedSchema(\n\tpersisted: JsonCompatible,\n\tview: ImplicitFieldSchema,\n\toptions: ICodecOptions,\n): Omit<SchemaCompatibilityStatus, \"canInitialize\"> {\n\t// Any version can be passed down to makeSchemaCodec here.\n\t// We only use the decode part, which always dispatches to the correct codec based on the version in the data, not the version passed to `makeSchemaCodec`.\n\tconst schemaCodec = makeSchemaCodec(options, SchemaVersion.v1);\n\tconst stored = schemaCodec.decode(persisted as FormatV1);\n\tconst config = new TreeViewConfigurationAlpha({\n\t\tschema: normalizeFieldSchema(view),\n\t});\n\tconst viewSchema = new SchemaCompatibilityTester(config);\n\treturn viewSchema.checkCompatibility(stored);\n}\n"]}
@@ -94,8 +94,8 @@ export interface TreeBeta {
94
94
  *
95
95
  * - The identifiers in the node's subtree will be preserved, i.e., they are not replaced with new values.
96
96
  *
97
- * @privateRemarks
98
- * TODO: AB#43548: How this handles unknown optional fields needs to be figured out, tested and documented.
97
+ * - If the node (or any node in its subtree) contains {@link SchemaFactoryObjectOptions.allowUnknownOptionalFields|unknown optional fields},
98
+ * those fields will be cloned just like the known fields.
99
99
  */
100
100
  clone<const TSchema extends ImplicitFieldSchema>(node: TreeFieldFromImplicitField<TSchema>): TreeFieldFromImplicitField<TSchema>;
101
101
  }
@@ -1 +1 @@
1
- {"version":3,"file":"treeBeta.d.ts","sourceRoot":"","sources":["../../../src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G,QAAQ,CAAC,MAAM,GAAG,QAAQ,CAAC,MAAM,CAAC,GAC9E,QAAQ,CAAC,IAAI,CAAC,eAAe,CAAC,KAAK,CAAC,EAAE,mBAAmB,CAAC,CAAC,GAC3D,OAAO,CAAC,KACR,IAAI,CAAC;CACV;AAED;;;;;GAKG;AACH,MAAM,WAAW,QAAQ;IACxB;;;;;;;OAOG;IACH,EAAE,CAAC,CAAC,SAAS,MAAM,oBAAoB,CAAC,KAAK,CAAC,EAAE,KAAK,SAAS,QAAQ,EACrE,IAAI,EAAE,KAAK,EACX,SAAS,EAAE,CAAC,EACZ,QAAQ,EAAE,OAAO,CAAC,oBAAoB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,GAC/C,MAAM,IAAI,CAAC;IAEd;;;;;;;;;;;;;;;;;OAiBG;IACH,KAAK,CAAC,KAAK,CAAC,OAAO,SAAS,mBAAmB,EAC9C,IAAI,EAAE,0BAA0B,CAAC,OAAO,CAAC,GACvC,0BAA0B,CAAC,OAAO,CAAC,CAAC;CAoBvC;AAED;;;;GAIG;AACH,eAAO,MAAM,QAAQ,EAAE,QA+BtB,CAAC"}
@@ -2,7 +2,9 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
- import { getKernel, isTreeNode, } from "../core/index.js";
5
+ import { defaultSchemaPolicy } from "../../feature-libraries/index.js";
6
+ import { Context, getKernel, isTreeNode, UnhydratedContext, } from "../core/index.js";
7
+ import { getUnhydratedContext } from "../createContext.js";
6
8
  import { createFromCursor } from "./create.js";
7
9
  import { treeNodeApi } from "./treeNodeApi.js";
8
10
  /**
@@ -21,7 +23,11 @@ export const TreeBeta = {
21
23
  }
22
24
  const kernel = getKernel(node);
23
25
  const cursor = kernel.getOrCreateInnerNode().borrowCursor();
24
- return createFromCursor(kernel.schema, cursor);
26
+ // To handle when the node transitively contains unknown optional fields,
27
+ // derive the context from the source node's stored schema which has stored schema for any such fields and their contents.
28
+ const flexContext = new UnhydratedContext(defaultSchemaPolicy, kernel.context.flexContext.schema);
29
+ const context = new Context(flexContext, getUnhydratedContext(kernel.schema).schema);
30
+ return createFromCursor(kernel.schema, cursor, context);
25
31
  },
26
32
  };
27
33
  //# sourceMappingURL=treeBeta.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"treeBeta.js","sourceRoot":"","sources":["../../../src/simple-tree/api/treeBeta.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,SAAS,EACT,UAAU,GAKV,MAAM,kBAAkB,CAAC;AAG1B,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE/C,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AA4I/C;;;;GAIG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAa;IACjC,EAAE,CACD,IAAW,EACX,SAAY,EACZ,QAAiD;QAEjD,OAAO,WAAW,CAAC,EAAE,CAAC,IAAI,EAAE,SAAS,EAAE,QAAQ,CAAC,CAAC;IAClD,CAAC;IACD,KAAK,CACJ,IAAyC;QAEzC,mIAAmI;QACnI,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;YACvB,OAAO,IAAI,CAAC;QACb,CAAC;QAED,MAAM,MAAM,GAAG,SAAS,CAAC,IAAI,CAAC,CAAC;QAC/B,MAAM,MAAM,GAAG,MAAM,CAAC,oBAAoB,EAAE,CAAC,YAAY,EAAE,CAAC;QAC5D,OAAO,gBAAgB,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAE5C,CAAC;IACH,CAAC;CACD,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\tgetKernel,\n\tisTreeNode,\n\ttype NodeKind,\n\ttype TreeNode,\n\ttype Unhydrated,\n\ttype WithType,\n} from \"../core/index.js\";\nimport type { ImplicitFieldSchema, TreeFieldFromImplicitField } from \"../fieldSchema.js\";\n\nimport { createFromCursor } from \"./create.js\";\nimport type { TreeChangeEvents } from \"./treeChangeEvents.js\";\nimport { treeNodeApi } from \"./treeNodeApi.js\";\n\n// Tests for this file are grouped with those for treeNodeApi.ts as that is where this functionality will eventually land,\n// and where most of the actual implementation is for much of it.\n\n/**\n * Data included for {@link TreeChangeEventsBeta.nodeChanged}.\n * @sealed @beta\n */\nexport interface NodeChangedData<TNode extends TreeNode = TreeNode> {\n\t/**\n\t * When the node changed is an object or Map node, this lists all the properties which changed.\n\t * @remarks\n\t * This only includes changes to the node itself (which would trigger {@link TreeChangeEvents.nodeChanged}).\n\t *\n\t * Set to `undefined` when the {@link NodeKind} does not support this feature (currently just ArrayNodes).\n\t *\n\t * When defined, the set should never be empty, since `nodeChanged` will only be triggered when there is a change, and for the supported node types, the only things that can change are properties.\n\t */\n\treadonly changedProperties?: ReadonlySet<\n\t\t// For Object nodes, make changedProperties required and strongly typed with the property names from the schema:\n\t\tTNode extends WithType<string, NodeKind.Object, infer TInfo>\n\t\t\t? string & keyof TInfo\n\t\t\t: string\n\t>;\n}\n\n/**\n * Extensions to {@link TreeChangeEvents} which are not yet stable.\n *\n * @sealed @beta\n */\nexport interface TreeChangeEventsBeta<TNode extends TreeNode = TreeNode>\n\textends TreeChangeEvents {\n\t/**\n\t * Emitted by a node after a batch of changes has been applied to the tree, if any of the changes affected the node.\n\t *\n\t * - Object nodes define a change as being when the value of one of its properties changes (i.e., the property's value is set, including when set to `undefined`).\n\t *\n\t * - Array nodes define a change as when an element is added, removed, moved or replaced.\n\t *\n\t * - Map nodes define a change as when an entry is added, updated, or removed.\n\t *\n\t * @remarks\n\t * This event is not emitted when:\n\t *\n\t * - Properties of a child node change. Notably, updates to an array node or a map node (like adding or removing\n\t * elements/entries) will emit this event on the array/map node itself, but not on the node that contains the\n\t * array/map node as one of its properties.\n\t *\n\t * - The node is moved to a different location in the tree or removed from the tree.\n\t * In this case the event is emitted on the _parent_ node, not the node itself.\n\t *\n\t * For remote edits, this event is not guaranteed to occur in the same order or quantity that it did in\n\t * the client that made the original edit.\n\t *\n\t * When the event is emitted, the tree is guaranteed to be in-schema.\n\t *\n\t * @privateRemarks\n\t * This event occurs whenever the apparent contents of the node instance change, regardless of what caused the change.\n\t * For example, it will fire when the local client reassigns a child, when part of a remote edit is applied to the\n\t * node, or when the node has to be updated due to resolution of a merge conflict\n\t * (for example a previously applied local change might be undone, then reapplied differently or not at all).\n\t *\n\t * TODO: define and document event ordering (ex: bottom up, with nodeChanged before treeChange on each level).\n\t *\n\t * This defines a property which is a function instead of using the method syntax to avoid function bi-variance issues with the input data to the callback.\n\t */\n\tnodeChanged: (\n\t\tdata: NodeChangedData<TNode> &\n\t\t\t// Make the properties of object, map, and record nodes required:\n\t\t\t(TNode extends WithType<string, NodeKind.Map | NodeKind.Object | NodeKind.Record>\n\t\t\t\t? Required<Pick<NodeChangedData<TNode>, \"changedProperties\">>\n\t\t\t\t: unknown),\n\t) => void;\n}\n\n/**\n * Extensions to {@link (Tree:interface)} which are not yet stable.\n * @remarks\n * Use via the {@link (TreeBeta:variable)} singleton.\n * @system @sealed @beta\n */\nexport interface TreeBeta {\n\t/**\n\t * Register an event listener on the given node.\n\t * @param node - The node whose events should be subscribed to.\n\t * @param eventName - Which event to subscribe to.\n\t * @param listener - The callback to trigger for the event. The tree can be read during the callback, but it is invalid to modify the tree during this callback.\n\t * @returns A callback function which will deregister the event.\n\t * This callback should be called only once.\n\t */\n\ton<K extends keyof TreeChangeEventsBeta<TNode>, TNode extends TreeNode>(\n\t\tnode: TNode,\n\t\teventName: K,\n\t\tlistener: NoInfer<TreeChangeEventsBeta<TNode>[K]>,\n\t): () => void;\n\n\t/**\n\t * Clones the persisted data associated with a node.\n\t *\n\t * @param node - The node to clone.\n\t * @returns A new unhydrated node with the same persisted data as the original node.\n\t * @remarks\n\t * Some key things to note:\n\t *\n\t * - Local state, such as properties added to customized schema classes, will not be cloned. However, they will be\n\t * initialized to their default state just as if the node had been created via its constructor.\n\t *\n\t * - Value node types (i.e., numbers, strings, booleans, nulls and Fluid handles) will be returned as is.\n\t *\n\t * - The identifiers in the node's subtree will be preserved, i.e., they are not replaced with new values.\n\t *\n\t * @privateRemarks\n\t * TODO: AB#43548: How this handles unknown optional fields needs to be figured out, tested and documented.\n\t */\n\tclone<const TSchema extends ImplicitFieldSchema>(\n\t\tnode: TreeFieldFromImplicitField<TSchema>,\n\t): TreeFieldFromImplicitField<TSchema>;\n\n\t// TODO: support more clone options\n\t// /**\n\t// * Like {@link TreeBeta.create}, except deeply clones existing nodes.\n\t// * @remarks\n\t// * This only clones the persisted data associated with a node.\n\t// * Local state, such as properties added to customized schema classes, will not be cloned:\n\t// * they will be initialized however they end up after running the constructor, just like if a remote client had inserted the same nodes.\n\t// */\n\t// clone<const TSchema extends ImplicitFieldSchema>(\n\t// \toriginal: TreeFieldFromImplicitField<TSchema>,\n\t// \toptions?: {\n\t// \t\t/**\n\t// \t\t * If set, all identifier's in the cloned tree (See {@link SchemaFactory.identifier}) will be replaced with new ones allocated using the default identifier allocation schema.\n\t// \t\t * Otherwise any identifiers will be preserved as is.\n\t// \t\t */\n\t// \t\treplaceIdentifiers?: true;\n\t// \t},\n\t// ): TreeFieldFromImplicitField<TSchema>;\n}\n\n/**\n * Extensions to {@link (Tree:variable)} which are not yet stable.\n * @see {@link (TreeBeta:interface)}.\n * @beta\n */\nexport const TreeBeta: TreeBeta = {\n\ton<K extends keyof TreeChangeEventsBeta<TNode>, TNode extends TreeNode>(\n\t\tnode: TNode,\n\t\teventName: K,\n\t\tlistener: NoInfer<TreeChangeEventsBeta<TNode>[K]>,\n\t): () => void {\n\t\treturn treeNodeApi.on(node, eventName, listener);\n\t},\n\tclone<const TSchema extends ImplicitFieldSchema>(\n\t\tnode: TreeFieldFromImplicitField<TSchema>,\n\t): Unhydrated<TreeFieldFromImplicitField<TSchema>> {\n\t\t// The only non-TreeNode cases are {@link TreeLeafValue} and `undefined` (for an empty optional field) which can be returned as is.\n\t\tif (!isTreeNode(node)) {\n\t\t\treturn node;\n\t\t}\n\n\t\tconst kernel = getKernel(node);\n\t\tconst cursor = kernel.getOrCreateInnerNode().borrowCursor();\n\t\treturn createFromCursor(kernel.schema, cursor) as Unhydrated<\n\t\t\tTreeFieldFromImplicitField<TSchema>\n\t\t>;\n\t},\n};\n"]}
1
+ {"version":3,"file":"treeBeta.js","sourceRoot":"","sources":["../../../src/simple-tree/api/treeBeta.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AACvE,OAAO,EACN,OAAO,EACP,SAAS,EACT,UAAU,EACV,iBAAiB,GAKjB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAG3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE/C,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AA4I/C;;;;GAIG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAa;IACjC,EAAE,CACD,IAAW,EACX,SAAY,EACZ,QAAiD;QAEjD,OAAO,WAAW,CAAC,EAAE,CAAC,IAAI,EAAE,SAAS,EAAE,QAAQ,CAAC,CAAC;IAClD,CAAC;IACD,KAAK,CACJ,IAAyC;QAEzC,mIAAmI;QACnI,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;YACvB,OAAO,IAAI,CAAC;QACb,CAAC;QAED,MAAM,MAAM,GAAG,SAAS,CAAC,IAAI,CAAC,CAAC;QAC/B,MAAM,MAAM,GAAG,MAAM,CAAC,oBAAoB,EAAE,CAAC,YAAY,EAAE,CAAC;QAE5D,yEAAyE;QACzE,0HAA0H;QAC1H,MAAM,WAAW,GAAG,IAAI,iBAAiB,CACxC,mBAAmB,EACnB,MAAM,CAAC,OAAO,CAAC,WAAW,CAAC,MAAM,CACjC,CAAC;QACF,MAAM,OAAO,GAAG,IAAI,OAAO,CAAC,WAAW,EAAE,oBAAoB,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC;QAErF,OAAO,gBAAgB,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,CAErD,CAAC;IACH,CAAC;CACD,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { defaultSchemaPolicy } from \"../../feature-libraries/index.js\";\nimport {\n\tContext,\n\tgetKernel,\n\tisTreeNode,\n\tUnhydratedContext,\n\ttype NodeKind,\n\ttype TreeNode,\n\ttype Unhydrated,\n\ttype WithType,\n} from \"../core/index.js\";\nimport { getUnhydratedContext } from \"../createContext.js\";\nimport type { ImplicitFieldSchema, TreeFieldFromImplicitField } from \"../fieldSchema.js\";\n\nimport { createFromCursor } from \"./create.js\";\nimport type { TreeChangeEvents } from \"./treeChangeEvents.js\";\nimport { treeNodeApi } from \"./treeNodeApi.js\";\n\n// Tests for this file are grouped with those for treeNodeApi.ts as that is where this functionality will eventually land,\n// and where most of the actual implementation is for much of it.\n\n/**\n * Data included for {@link TreeChangeEventsBeta.nodeChanged}.\n * @sealed @beta\n */\nexport interface NodeChangedData<TNode extends TreeNode = TreeNode> {\n\t/**\n\t * When the node changed is an object or Map node, this lists all the properties which changed.\n\t * @remarks\n\t * This only includes changes to the node itself (which would trigger {@link TreeChangeEvents.nodeChanged}).\n\t *\n\t * Set to `undefined` when the {@link NodeKind} does not support this feature (currently just ArrayNodes).\n\t *\n\t * When defined, the set should never be empty, since `nodeChanged` will only be triggered when there is a change, and for the supported node types, the only things that can change are properties.\n\t */\n\treadonly changedProperties?: ReadonlySet<\n\t\t// For Object nodes, make changedProperties required and strongly typed with the property names from the schema:\n\t\tTNode extends WithType<string, NodeKind.Object, infer TInfo>\n\t\t\t? string & keyof TInfo\n\t\t\t: string\n\t>;\n}\n\n/**\n * Extensions to {@link TreeChangeEvents} which are not yet stable.\n *\n * @sealed @beta\n */\nexport interface TreeChangeEventsBeta<TNode extends TreeNode = TreeNode>\n\textends TreeChangeEvents {\n\t/**\n\t * Emitted by a node after a batch of changes has been applied to the tree, if any of the changes affected the node.\n\t *\n\t * - Object nodes define a change as being when the value of one of its properties changes (i.e., the property's value is set, including when set to `undefined`).\n\t *\n\t * - Array nodes define a change as when an element is added, removed, moved or replaced.\n\t *\n\t * - Map nodes define a change as when an entry is added, updated, or removed.\n\t *\n\t * @remarks\n\t * This event is not emitted when:\n\t *\n\t * - Properties of a child node change. Notably, updates to an array node or a map node (like adding or removing\n\t * elements/entries) will emit this event on the array/map node itself, but not on the node that contains the\n\t * array/map node as one of its properties.\n\t *\n\t * - The node is moved to a different location in the tree or removed from the tree.\n\t * In this case the event is emitted on the _parent_ node, not the node itself.\n\t *\n\t * For remote edits, this event is not guaranteed to occur in the same order or quantity that it did in\n\t * the client that made the original edit.\n\t *\n\t * When the event is emitted, the tree is guaranteed to be in-schema.\n\t *\n\t * @privateRemarks\n\t * This event occurs whenever the apparent contents of the node instance change, regardless of what caused the change.\n\t * For example, it will fire when the local client reassigns a child, when part of a remote edit is applied to the\n\t * node, or when the node has to be updated due to resolution of a merge conflict\n\t * (for example a previously applied local change might be undone, then reapplied differently or not at all).\n\t *\n\t * TODO: define and document event ordering (ex: bottom up, with nodeChanged before treeChange on each level).\n\t *\n\t * This defines a property which is a function instead of using the method syntax to avoid function bi-variance issues with the input data to the callback.\n\t */\n\tnodeChanged: (\n\t\tdata: NodeChangedData<TNode> &\n\t\t\t// Make the properties of object, map, and record nodes required:\n\t\t\t(TNode extends WithType<string, NodeKind.Map | NodeKind.Object | NodeKind.Record>\n\t\t\t\t? Required<Pick<NodeChangedData<TNode>, \"changedProperties\">>\n\t\t\t\t: unknown),\n\t) => void;\n}\n\n/**\n * Extensions to {@link (Tree:interface)} which are not yet stable.\n * @remarks\n * Use via the {@link (TreeBeta:variable)} singleton.\n * @system @sealed @beta\n */\nexport interface TreeBeta {\n\t/**\n\t * Register an event listener on the given node.\n\t * @param node - The node whose events should be subscribed to.\n\t * @param eventName - Which event to subscribe to.\n\t * @param listener - The callback to trigger for the event. The tree can be read during the callback, but it is invalid to modify the tree during this callback.\n\t * @returns A callback function which will deregister the event.\n\t * This callback should be called only once.\n\t */\n\ton<K extends keyof TreeChangeEventsBeta<TNode>, TNode extends TreeNode>(\n\t\tnode: TNode,\n\t\teventName: K,\n\t\tlistener: NoInfer<TreeChangeEventsBeta<TNode>[K]>,\n\t): () => void;\n\n\t/**\n\t * Clones the persisted data associated with a node.\n\t *\n\t * @param node - The node to clone.\n\t * @returns A new unhydrated node with the same persisted data as the original node.\n\t * @remarks\n\t * Some key things to note:\n\t *\n\t * - Local state, such as properties added to customized schema classes, will not be cloned. However, they will be\n\t * initialized to their default state just as if the node had been created via its constructor.\n\t *\n\t * - Value node types (i.e., numbers, strings, booleans, nulls and Fluid handles) will be returned as is.\n\t *\n\t * - The identifiers in the node's subtree will be preserved, i.e., they are not replaced with new values.\n\t *\n\t * - If the node (or any node in its subtree) contains {@link SchemaFactoryObjectOptions.allowUnknownOptionalFields|unknown optional fields},\n\t * those fields will be cloned just like the known fields.\n\t */\n\tclone<const TSchema extends ImplicitFieldSchema>(\n\t\tnode: TreeFieldFromImplicitField<TSchema>,\n\t): TreeFieldFromImplicitField<TSchema>;\n\n\t// TODO: support more clone options\n\t// /**\n\t// * Like {@link (TreeBeta:interface).create}, except deeply clones existing nodes.\n\t// * @remarks\n\t// * This only clones the persisted data associated with a node.\n\t// * Local state, such as properties added to customized schema classes, will not be cloned:\n\t// * they will be initialized however they end up after running the constructor, just like if a remote client had inserted the same nodes.\n\t// */\n\t// clone<const TSchema extends ImplicitFieldSchema>(\n\t// \toriginal: TreeFieldFromImplicitField<TSchema>,\n\t// \toptions?: {\n\t// \t\t/**\n\t// \t\t * If set, all identifier's in the cloned tree (See {@link SchemaFactory.identifier}) will be replaced with new ones allocated using the default identifier allocation schema.\n\t// \t\t * Otherwise any identifiers will be preserved as is.\n\t// \t\t */\n\t// \t\treplaceIdentifiers?: true;\n\t// \t},\n\t// ): TreeFieldFromImplicitField<TSchema>;\n}\n\n/**\n * Extensions to {@link (Tree:variable)} which are not yet stable.\n * @see {@link (TreeBeta:interface)}.\n * @beta\n */\nexport const TreeBeta: TreeBeta = {\n\ton<K extends keyof TreeChangeEventsBeta<TNode>, TNode extends TreeNode>(\n\t\tnode: TNode,\n\t\teventName: K,\n\t\tlistener: NoInfer<TreeChangeEventsBeta<TNode>[K]>,\n\t): () => void {\n\t\treturn treeNodeApi.on(node, eventName, listener);\n\t},\n\tclone<const TSchema extends ImplicitFieldSchema>(\n\t\tnode: TreeFieldFromImplicitField<TSchema>,\n\t): Unhydrated<TreeFieldFromImplicitField<TSchema>> {\n\t\t// The only non-TreeNode cases are {@link TreeLeafValue} and `undefined` (for an empty optional field) which can be returned as is.\n\t\tif (!isTreeNode(node)) {\n\t\t\treturn node;\n\t\t}\n\n\t\tconst kernel = getKernel(node);\n\t\tconst cursor = kernel.getOrCreateInnerNode().borrowCursor();\n\n\t\t// To handle when the node transitively contains unknown optional fields,\n\t\t// derive the context from the source node's stored schema which has stored schema for any such fields and their contents.\n\t\tconst flexContext = new UnhydratedContext(\n\t\t\tdefaultSchemaPolicy,\n\t\t\tkernel.context.flexContext.schema,\n\t\t);\n\t\tconst context = new Context(flexContext, getUnhydratedContext(kernel.schema).schema);\n\n\t\treturn createFromCursor(kernel.schema, cursor, context) as Unhydrated<\n\t\t\tTreeFieldFromImplicitField<TSchema>\n\t\t>;\n\t},\n};\n"]}
@@ -5,7 +5,7 @@
5
5
  import type { IFluidHandle } from "@fluidframework/core-interfaces";
6
6
  import { type ITreeCursor, type ITreeCursorSynchronous } from "../../core/index.js";
7
7
  import type { ImplicitFieldSchema } from "../fieldSchema.js";
8
- import type { ImplicitAllowedTypes, TreeLeafValue } from "../core/index.js";
8
+ import type { Context, TreeLeafValue } from "../core/index.js";
9
9
  import { type HandleConverter, type SchemalessParseOptions, type TreeEncodingOptions } from "./customTree.js";
10
10
  /**
11
11
  * Verbose encoding of a {@link TreeNode} or {@link TreeLeafValue}.
@@ -82,7 +82,7 @@ export declare function fieldCursorFromVerbose(data: VerboseTree[], options: Sch
82
82
  /**
83
83
  * Used to read a node cursor as a VerboseTree.
84
84
  */
85
- export declare function verboseFromCursor(reader: ITreeCursor, rootSchema: ImplicitAllowedTypes, options: TreeEncodingOptions): VerboseTree;
85
+ export declare function verboseFromCursor(reader: ITreeCursor, context: Context, options: TreeEncodingOptions): VerboseTree;
86
86
  /**
87
87
  * Clones tree, replacing any handles.
88
88
  * @remarks
@@ -1 +1 @@
1
- {"version":3,"file":"verboseTree.d.ts","sourceRoot":"","sources":["../../../src/simple-tree/api/verboseTree.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAKpE,OAAO,EAKN,KAAK,WAAW,EAChB,KAAK,sBAAsB,EAC3B,MAAM,qBAAqB,CAAC;AAE7B,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAE7D,OAAO,KAAK,EAAkB,oBAAoB,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAe5F,OAAO,EAKN,KAAK,eAAe,EACpB,KAAK,sBAAsB,EAC3B,KAAK,mBAAmB,EACxB,MAAM,iBAAiB,CAAC;AAGzB;;;;;;;;;GASG;AACH,MAAM,MAAM,WAAW,CAAC,OAAO,GAAG,YAAY,IAC3C,eAAe,CAAC,OAAO,CAAC,GACxB,OAAO,CAAC,aAAa,EAAE,YAAY,CAAC,GACpC,OAAO,CAAC;AAEX;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,WAAW,eAAe,CAAC,OAAO,GAAG,YAAY;IACtD;;;;;;OAMG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;;;;;OAMG;IACH,MAAM,EACH,WAAW,CAAC,OAAO,CAAC,EAAE,GACtB;QACA,CAAC,GAAG,EAAE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eAAe,CAAC,OAAO,CAAC,GACxB,OAAO,CAAC,aAAa,EAAE,YAAY,CAAC,GACpC,OAAO,CAAC;AAEX;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,WAAW,eAAe,CAAC,OAAO,GAAG,YAAY;IACtD;;;;;;OAMG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;;;;;OAMG;IACH,MAAM,EACH,WAAW,CAAC,OAAO,CAAC,EAAE,GACtB;QACA,CAAC,GAAG,EAAE,MAAM,GAAG,WAAW,CAAC,OAAO,CAAC,CAAC;KACnC,CAAC;CACL;AAED;;GAEG;AACH,wBAAgB,0BAA0B,CACzC,MAAM,EAAE,mBAAmB,EAC3B,OAAO,EAAE,mBAAmB,GAC1B,sBAAsB,CAkDxB;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAChC,IAAI,EAAE,WAAW,EACjB,OAAO,EAAE,sBAAsB,GAC7B,sBAAsB,CAExB;AAED;;;;GAIG;AACH,wBAAgB,sBAAsB,CACrC,IAAI,EAAE,WAAW,EAAE,EACnB,OAAO,EAAE,sBAAsB,GAC7B,sBAAsB,CAMxB;AAiFD;;GAEG;AACH,wBAAgB,iBAAiB,CAChC,MAAM,EAAE,WAAW,EACnB,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,mBAAmB,GAC1B,WAAW,CAUb;AA2BD;;;;;GAKG;AACH,wBAAgB,yBAAyB,CAAC,CAAC,EAC1C,IAAI,EAAE,WAAW,EACjB,QAAQ,EAAE,eAAe,CAAC,CAAC,CAAC,GAC1B,WAAW,CAAC,CAAC,CAAC,CAEhB"}
@@ -5,9 +5,8 @@
5
5
  import { isFluidHandle } from "@fluidframework/runtime-utils/internal";
6
6
  import { assert, fail } from "@fluidframework/core-utils/internal";
7
7
  import { UsageError } from "@fluidframework/telemetry-utils/internal";
8
- import { aboveRootPlaceholder, EmptyKey, keyAsDetachedField, } from "../../core/index.js";
8
+ import { aboveRootPlaceholder, EmptyKey, keyAsDetachedField, LeafNodeStoredSchema, } from "../../core/index.js";
9
9
  import { brand } from "../../util/index.js";
10
- import { NodeKind } from "../core/index.js";
11
10
  import { isTreeValue, stackTreeFieldCursor, stackTreeNodeCursor, } from "../../feature-libraries/index.js";
12
11
  import { booleanSchema, handleSchema, nullSchema, numberSchema, stringSchema, } from "../leafNodeSchema.js";
13
12
  import { isObjectNodeSchema } from "../node-kinds/index.js";
@@ -148,18 +147,19 @@ function verboseTreeAdapter(options) {
148
147
  /**
149
148
  * Used to read a node cursor as a VerboseTree.
150
149
  */
151
- export function verboseFromCursor(reader, rootSchema, options) {
150
+ export function verboseFromCursor(reader, context, options) {
152
151
  const config = {
153
152
  useStoredKeys: false,
154
153
  ...options,
155
154
  };
156
- const schemaMap = getUnhydratedContext(rootSchema).schema;
157
- return verboseFromCursorInner(reader, config, schemaMap);
155
+ const storedSchemaMap = context.flexContext.schema.nodeSchema;
156
+ const schemaMap = context.schema;
157
+ return verboseFromCursorInner(reader, config, storedSchemaMap, schemaMap);
158
158
  }
159
- function verboseFromCursorInner(reader, options, schema) {
160
- const fields = customFromCursor(reader, options, schema, verboseFromCursorInner);
161
- const nodeSchema = schema.get(reader.type) ?? fail(0xb3c /* missing schema for type in cursor */);
162
- if (nodeSchema.kind === NodeKind.Leaf) {
159
+ function verboseFromCursorInner(reader, options, storedSchema, schema) {
160
+ const fields = customFromCursor(reader, options, storedSchema, schema, verboseFromCursorInner);
161
+ const nodeSchema = storedSchema.get(reader.type) ?? fail(0xb3c /* missing schema for type in cursor */);
162
+ if (nodeSchema instanceof LeafNodeStoredSchema) {
163
163
  return fields;
164
164
  }
165
165
  return {
@@ -1 +1 @@
1
- {"version":3,"file":"verboseTree.js","sourceRoot":"","sources":["../../../src/simple-tree/api/verboseTree.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,aAAa,EAAE,MAAM,wCAAwC,CAAC;AACvE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,qCAAqC,CAAC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;IAED,OAAO;QACN,IAAI,EAAE,MAAM,CAAC,IAAI;QACjB,MAAM,EAAE,MAAqC;KAC7C,CAAC;AACH,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,yBAAyB,CACxC,IAAiB,EACjB,QAA4B;IAE5B,OAAO,cAAc,CAAC,IAAI,EAAE,QAAQ,CAAmB,CAAC;AACzD,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { IFluidHandle } from \"@fluidframework/core-interfaces\";\nimport { isFluidHandle } from \"@fluidframework/runtime-utils/internal\";\nimport { assert, fail } from \"@fluidframework/core-utils/internal\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\n\nimport {\n\taboveRootPlaceholder,\n\tEmptyKey,\n\tkeyAsDetachedField,\n\ttype FieldKey,\n\ttype ITreeCursor,\n\ttype ITreeCursorSynchronous,\n} from \"../../core/index.js\";\nimport { brand } from \"../../util/index.js\";\nimport type { ImplicitFieldSchema } from \"../fieldSchema.js\";\nimport { NodeKind } from \"../core/index.js\";\nimport type { TreeNodeSchema, ImplicitAllowedTypes, TreeLeafValue } from \"../core/index.js\";\nimport {\n\tisTreeValue,\n\tstackTreeFieldCursor,\n\tstackTreeNodeCursor,\n\ttype CursorAdapter,\n} from \"../../feature-libraries/index.js\";\nimport {\n\tbooleanSchema,\n\thandleSchema,\n\tnullSchema,\n\tnumberSchema,\n\tstringSchema,\n} from \"../leafNodeSchema.js\";\nimport { isObjectNodeSchema } from \"../node-kinds/index.js\";\nimport {\n\tcustomFromCursor,\n\treplaceHandles,\n\tunknownTypeError,\n\ttype CustomTreeNode,\n\ttype HandleConverter,\n\ttype SchemalessParseOptions,\n\ttype TreeEncodingOptions,\n} from \"./customTree.js\";\nimport { getUnhydratedContext } from \"../createContext.js\";\n\n/**\n * Verbose encoding of a {@link TreeNode} or {@link TreeLeafValue}.\n * @remarks\n * This is verbose meaning that every {@link TreeNode} is a {@link VerboseTreeNode}.\n * Any IFluidHandle values have been replaced by `THandle`.\n * @privateRemarks\n * This can store all possible simple trees,\n * but it can not store all possible trees representable by our internal representations like FlexTree and JsonableTree.\n * @alpha\n */\nexport type VerboseTree<THandle = IFluidHandle> =\n\t| VerboseTreeNode<THandle>\n\t| Exclude<TreeLeafValue, IFluidHandle>\n\t| THandle;\n\n/**\n * Verbose encoding of a {@link TreeNode}.\n * @remarks\n * This is verbose meaning that every {@link TreeNode} has an explicit `type` property, and `fields`.\n * This allowed VerboseTreeNode to be unambiguous regarding which type each node is without relying on symbols or hidden state.\n *\n * Any IFluidHandle values have been replaced by `THandle`. If the `THandle` is JSON compatible, then this type is JSON compatible as well.\n *\n * @privateRemarks\n * This type is only used for data which is copied into and out of the tree.\n * When being copied out, its fine to have the data be mutable since its a copy.\n *\n * When being copied in, we don't need to mutate, so we could use a readonly variant of this type.\n * however the copy in case (createFromVerbose) probably isn't harmed much by just reusing this type as is,\n * since if the caller has immutable data, TypeScript doesn't prevent assigning immutable data to a mutable type anyway.\n * Also relaxing the input methods to take readonly data would be a non-breaking change so it can be done later if desired.\n *\n * This format is simple-tree specialized alternative to {@link JsonableTree}.\n * This format allows for all simple-tree compatible trees to be represented.\n *\n * Unlike `JsonableTree`, leaf nodes are not boxed into node objects, and instead have their schema inferred from the value.\n * Additionally, sequence fields can only occur on a node that has a single sequence field (with the empty key)\n * replicating the behavior of simple-tree ArrayNodes.\n * @alpha\n */\nexport interface VerboseTreeNode<THandle = IFluidHandle> {\n\t/**\n\t * The meaning of this node.\n\t * Provides contexts/semantics for this node and its content.\n\t * @remarks\n\t * Typically used to associate a node with metadata (including a schema) and source code (types, behaviors, etc).\n\t * When used with this package's schema system, it will be the {@link TreeNodeSchemaCore.identifier}.\n\t */\n\ttype: string;\n\n\t/**\n\t * Content of this node.\n\t * For array nodes, an array of children.\n\t * For map and object nodes, an object which children under keys.\n\t * @remarks\n\t * For object nodes, the keys could be either the stored keys, or the property keys depending on usage.\n\t */\n\tfields:\n\t\t| VerboseTree<THandle>[]\n\t\t| {\n\t\t\t\t[key: string]: VerboseTree<THandle>;\n\t\t };\n}\n\n/**\n * Use info from `schema` to convert `options` to {@link SchemalessParseOptions}.\n */\nexport function applySchemaToParserOptions(\n\tschema: ImplicitFieldSchema,\n\toptions: TreeEncodingOptions,\n): SchemalessParseOptions {\n\tconst config: Required<TreeEncodingOptions> = {\n\t\tuseStoredKeys: false,\n\t\t...options,\n\t};\n\n\tconst context = getUnhydratedContext(schema);\n\n\treturn {\n\t\tkeyConverter: config.useStoredKeys\n\t\t\t? undefined\n\t\t\t: {\n\t\t\t\t\tencode: (type, key: FieldKey): string => {\n\t\t\t\t\t\t// translate stored key into property key.\n\t\t\t\t\t\tconst simpleNodeSchema =\n\t\t\t\t\t\t\tcontext.schema.get(brand(type)) ?? fail(0xb39 /* missing schema */);\n\t\t\t\t\t\tif (isObjectNodeSchema(simpleNodeSchema)) {\n\t\t\t\t\t\t\tconst propertyKey = simpleNodeSchema.storedKeyToPropertyKey.get(key);\n\t\t\t\t\t\t\tif (propertyKey !== undefined) {\n\t\t\t\t\t\t\t\treturn propertyKey;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t// Looking up an out of schema key.\n\t\t\t\t\t\t\t// This must point to a non-existent field.\n\t\t\t\t\t\t\t// It's possible that the key, if we returned it unmodified, could point to some data\n\t\t\t\t\t\t\t// (for example if looking up a key which is a stored key already when using property keys).\n\t\t\t\t\t\t\t// Thus return an arbitrary key that was selected randomly, so should not exist on non-adversarial data:\n\t\t\t\t\t\t\tconst arbitrary = \"arbitrary unused key: fe71614a-bf3e-43b3-b7b0-4cef39538e90\";\n\t\t\t\t\t\t\tassert(\n\t\t\t\t\t\t\t\t!simpleNodeSchema.storedKeyToPropertyKey.has(brand(arbitrary)),\n\t\t\t\t\t\t\t\t0xa13 /* arbitrarily selected unused key was actually used */,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\treturn arbitrary;\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn key;\n\t\t\t\t\t},\n\t\t\t\t\tparse: (type, inputKey): FieldKey => {\n\t\t\t\t\t\tconst simpleNodeSchema = context.schema.get(brand(type)) ?? unknownTypeError(type);\n\t\t\t\t\t\tif (isObjectNodeSchema(simpleNodeSchema)) {\n\t\t\t\t\t\t\tconst info = simpleNodeSchema.flexKeyMap.get(inputKey);\n\t\t\t\t\t\t\tif (info === undefined) {\n\t\t\t\t\t\t\t\tthrow new UsageError(\n\t\t\t\t\t\t\t\t\t`Failed to parse VerboseTree due to unexpected key ${JSON.stringify(inputKey)} on type ${JSON.stringify(type)}.`,\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\treturn info.storedKey;\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn brand(inputKey);\n\t\t\t\t\t},\n\t\t\t\t},\n\t};\n}\n\n/**\n * Used to read a VerboseTree as a node cursor.\n *\n * @returns an {@link ITreeCursorSynchronous} for a single node in nodes mode.\n */\nexport function cursorFromVerbose(\n\tdata: VerboseTree,\n\toptions: SchemalessParseOptions,\n): ITreeCursorSynchronous {\n\treturn stackTreeNodeCursor(verboseTreeAdapter(options), data);\n}\n\n/**\n * Used to read a VerboseTree[] as a field cursor.\n *\n * @returns an {@link ITreeCursorSynchronous} for a single field in fields mode.\n */\nexport function fieldCursorFromVerbose(\n\tdata: VerboseTree[],\n\toptions: SchemalessParseOptions,\n): ITreeCursorSynchronous {\n\treturn stackTreeFieldCursor(\n\t\tverboseTreeAdapter(options),\n\t\t{ type: aboveRootPlaceholder, fields: data },\n\t\tkeyAsDetachedField(EmptyKey),\n\t);\n}\n\nfunction verboseTreeAdapter(options: SchemalessParseOptions): CursorAdapter<VerboseTree> {\n\treturn {\n\t\tvalue: (node: VerboseTree) => {\n\t\t\treturn isTreeValue(node) ? node : undefined;\n\t\t},\n\t\ttype: (node: VerboseTree) => {\n\t\t\tswitch (typeof node) {\n\t\t\t\tcase \"number\":\n\t\t\t\t\treturn brand(numberSchema.identifier);\n\t\t\t\tcase \"string\":\n\t\t\t\t\treturn brand(stringSchema.identifier);\n\t\t\t\tcase \"boolean\":\n\t\t\t\t\treturn brand(booleanSchema.identifier);\n\t\t\t\tdefault:\n\t\t\t\t\tif (node === null) {\n\t\t\t\t\t\treturn brand(nullSchema.identifier);\n\t\t\t\t\t}\n\t\t\t\t\tif (isFluidHandle(node)) {\n\t\t\t\t\t\treturn brand(handleSchema.identifier);\n\t\t\t\t\t}\n\t\t\t\t\treturn brand(node.type);\n\t\t\t}\n\t\t},\n\t\tkeysFromNode: (node: VerboseTree): readonly FieldKey[] => {\n\t\t\tswitch (typeof node) {\n\t\t\t\tcase \"object\": {\n\t\t\t\t\tif (node === null) {\n\t\t\t\t\t\treturn [];\n\t\t\t\t\t}\n\t\t\t\t\tif (isFluidHandle(node)) {\n\t\t\t\t\t\treturn [];\n\t\t\t\t\t}\n\t\t\t\t\tif (Array.isArray(node.fields)) {\n\t\t\t\t\t\treturn node.fields.length === 0 ? [] : [EmptyKey];\n\t\t\t\t\t}\n\n\t\t\t\t\tconst inputKeys = Object.keys(node.fields);\n\t\t\t\t\tconst converter = options.keyConverter;\n\t\t\t\t\tif (converter === undefined) {\n\t\t\t\t\t\treturn inputKeys as FieldKey[];\n\t\t\t\t\t}\n\t\t\t\t\treturn inputKeys.map((k) => converter.parse(node.type, k));\n\t\t\t\t}\n\t\t\t\tdefault:\n\t\t\t\t\treturn [];\n\t\t\t}\n\t\t},\n\t\tgetFieldFromNode: (node: VerboseTree, key: FieldKey): readonly VerboseTree[] => {\n\t\t\t// Object.prototype.hasOwnProperty can return true for strings (ex: with key \"0\"), so we have to filter them out.\n\t\t\t// Rather than just special casing strings, we can handle them with an early return for all primitives.\n\t\t\tif (typeof node !== \"object\") {\n\t\t\t\treturn [];\n\t\t\t}\n\n\t\t\tif (node === null) {\n\t\t\t\treturn [];\n\t\t\t}\n\n\t\t\tif (isFluidHandle(node)) {\n\t\t\t\treturn [];\n\t\t\t}\n\n\t\t\tif (Array.isArray(node.fields)) {\n\t\t\t\treturn key === EmptyKey ? node.fields : [];\n\t\t\t}\n\n\t\t\tconst convertedKey =\n\t\t\t\toptions.keyConverter === undefined ? key : options.keyConverter.encode(node.type, key);\n\n\t\t\tif (Object.prototype.hasOwnProperty.call(node.fields, convertedKey)) {\n\t\t\t\tconst field = node.fields[convertedKey];\n\t\t\t\treturn field === undefined ? [] : [field];\n\t\t\t}\n\n\t\t\treturn [];\n\t\t},\n\t};\n}\n\n/**\n * Used to read a node cursor as a VerboseTree.\n */\nexport function verboseFromCursor(\n\treader: ITreeCursor,\n\trootSchema: ImplicitAllowedTypes,\n\toptions: TreeEncodingOptions,\n): VerboseTree {\n\tconst config: Required<TreeEncodingOptions> = {\n\t\tuseStoredKeys: false,\n\t\t...options,\n\t};\n\n\tconst schemaMap = getUnhydratedContext(rootSchema).schema;\n\n\treturn verboseFromCursorInner(reader, config, schemaMap);\n}\n\nfunction verboseFromCursorInner(\n\treader: ITreeCursor,\n\toptions: Required<TreeEncodingOptions>,\n\tschema: ReadonlyMap<string, TreeNodeSchema>,\n): VerboseTree {\n\tconst fields = customFromCursor(reader, options, schema, verboseFromCursorInner);\n\tconst nodeSchema =\n\t\tschema.get(reader.type) ?? fail(0xb3c /* missing schema for type in cursor */);\n\tif (nodeSchema.kind === NodeKind.Leaf) {\n\t\treturn fields as TreeLeafValue;\n\t}\n\n\treturn {\n\t\ttype: reader.type,\n\t\tfields: fields as CustomTreeNode<VerboseTree>,\n\t};\n}\n\n/**\n * Clones tree, replacing any handles.\n * @remarks\n * A strongly types version of {@link replaceHandles}.\n * @alpha\n */\nexport function replaceVerboseTreeHandles<T>(\n\ttree: VerboseTree,\n\treplacer: HandleConverter<T>,\n): VerboseTree<T> {\n\treturn replaceHandles(tree, replacer) as VerboseTree<T>;\n}\n"]}
1
+ {"version":3,"file":"verboseTree.js","sourceRoot":"","sources":["../../../src/simple-tree/api/verboseTree.ts"],"names":[],"mappings":"AAA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AAC,IAAI,CAAC,IAAI,IAAI,CAAC,KAAK,CAAC,uCAAuC,CAAC,CAAC;IACtF,IAAI,UAAU,YAAY,oBAAoB,EAAE,CAAC;QAChD,OAAO,MAAuB,CAAC;IAChC,CAAC;IAED,OAAO;QACN,IAAI,EAAE,MAAM,CAAC,IAAI;QACjB,MAAM,EAAE,MAAqC;KAC7C,CAAC;AACH,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,yBAAyB,CACxC,IAAiB,EACjB,QAA4B;IAE5B,OAAO,cAAc,CAAC,IAAI,EAAE,QAAQ,CAAmB,CAAC;AACzD,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { IFluidHandle } from \"@fluidframework/core-interfaces\";\nimport { isFluidHandle } from \"@fluidframework/runtime-utils/internal\";\nimport { assert, fail } from \"@fluidframework/core-utils/internal\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\n\nimport {\n\taboveRootPlaceholder,\n\tEmptyKey,\n\tkeyAsDetachedField,\n\tLeafNodeStoredSchema,\n\ttype FieldKey,\n\ttype ITreeCursor,\n\ttype ITreeCursorSynchronous,\n\ttype TreeNodeStoredSchema,\n} from \"../../core/index.js\";\nimport { brand } from \"../../util/index.js\";\nimport type { ImplicitFieldSchema } from \"../fieldSchema.js\";\nimport type { Context, TreeLeafValue, TreeNodeSchema } from \"../core/index.js\";\nimport {\n\tisTreeValue,\n\tstackTreeFieldCursor,\n\tstackTreeNodeCursor,\n\ttype CursorAdapter,\n} from \"../../feature-libraries/index.js\";\nimport {\n\tbooleanSchema,\n\thandleSchema,\n\tnullSchema,\n\tnumberSchema,\n\tstringSchema,\n} from \"../leafNodeSchema.js\";\nimport { isObjectNodeSchema } from \"../node-kinds/index.js\";\nimport {\n\tcustomFromCursor,\n\treplaceHandles,\n\tunknownTypeError,\n\ttype CustomTreeNode,\n\ttype HandleConverter,\n\ttype SchemalessParseOptions,\n\ttype TreeEncodingOptions,\n} from \"./customTree.js\";\nimport { getUnhydratedContext } from \"../createContext.js\";\n\n/**\n * Verbose encoding of a {@link TreeNode} or {@link TreeLeafValue}.\n * @remarks\n * This is verbose meaning that every {@link TreeNode} is a {@link VerboseTreeNode}.\n * Any IFluidHandle values have been replaced by `THandle`.\n * @privateRemarks\n * This can store all possible simple trees,\n * but it can not store all possible trees representable by our internal representations like FlexTree and JsonableTree.\n * @alpha\n */\nexport type VerboseTree<THandle = IFluidHandle> =\n\t| VerboseTreeNode<THandle>\n\t| Exclude<TreeLeafValue, IFluidHandle>\n\t| THandle;\n\n/**\n * Verbose encoding of a {@link TreeNode}.\n * @remarks\n * This is verbose meaning that every {@link TreeNode} has an explicit `type` property, and `fields`.\n * This allowed VerboseTreeNode to be unambiguous regarding which type each node is without relying on symbols or hidden state.\n *\n * Any IFluidHandle values have been replaced by `THandle`. If the `THandle` is JSON compatible, then this type is JSON compatible as well.\n *\n * @privateRemarks\n * This type is only used for data which is copied into and out of the tree.\n * When being copied out, its fine to have the data be mutable since its a copy.\n *\n * When being copied in, we don't need to mutate, so we could use a readonly variant of this type.\n * however the copy in case (createFromVerbose) probably isn't harmed much by just reusing this type as is,\n * since if the caller has immutable data, TypeScript doesn't prevent assigning immutable data to a mutable type anyway.\n * Also relaxing the input methods to take readonly data would be a non-breaking change so it can be done later if desired.\n *\n * This format is simple-tree specialized alternative to {@link JsonableTree}.\n * This format allows for all simple-tree compatible trees to be represented.\n *\n * Unlike `JsonableTree`, leaf nodes are not boxed into node objects, and instead have their schema inferred from the value.\n * Additionally, sequence fields can only occur on a node that has a single sequence field (with the empty key)\n * replicating the behavior of simple-tree ArrayNodes.\n * @alpha\n */\nexport interface VerboseTreeNode<THandle = IFluidHandle> {\n\t/**\n\t * The meaning of this node.\n\t * Provides contexts/semantics for this node and its content.\n\t * @remarks\n\t * Typically used to associate a node with metadata (including a schema) and source code (types, behaviors, etc).\n\t * When used with this package's schema system, it will be the {@link TreeNodeSchemaCore.identifier}.\n\t */\n\ttype: string;\n\n\t/**\n\t * Content of this node.\n\t * For array nodes, an array of children.\n\t * For map and object nodes, an object which children under keys.\n\t * @remarks\n\t * For object nodes, the keys could be either the stored keys, or the property keys depending on usage.\n\t */\n\tfields:\n\t\t| VerboseTree<THandle>[]\n\t\t| {\n\t\t\t\t[key: string]: VerboseTree<THandle>;\n\t\t };\n}\n\n/**\n * Use info from `schema` to convert `options` to {@link SchemalessParseOptions}.\n */\nexport function applySchemaToParserOptions(\n\tschema: ImplicitFieldSchema,\n\toptions: TreeEncodingOptions,\n): SchemalessParseOptions {\n\tconst config: Required<TreeEncodingOptions> = {\n\t\tuseStoredKeys: false,\n\t\t...options,\n\t};\n\n\tconst context = getUnhydratedContext(schema);\n\n\treturn {\n\t\tkeyConverter: config.useStoredKeys\n\t\t\t? undefined\n\t\t\t: {\n\t\t\t\t\tencode: (type, key: FieldKey): string => {\n\t\t\t\t\t\t// translate stored key into property key.\n\t\t\t\t\t\tconst simpleNodeSchema =\n\t\t\t\t\t\t\tcontext.schema.get(brand(type)) ?? fail(0xb39 /* missing schema */);\n\t\t\t\t\t\tif (isObjectNodeSchema(simpleNodeSchema)) {\n\t\t\t\t\t\t\tconst propertyKey = simpleNodeSchema.storedKeyToPropertyKey.get(key);\n\t\t\t\t\t\t\tif (propertyKey !== undefined) {\n\t\t\t\t\t\t\t\treturn propertyKey;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t// Looking up an out of schema key.\n\t\t\t\t\t\t\t// This must point to a non-existent field.\n\t\t\t\t\t\t\t// It's possible that the key, if we returned it unmodified, could point to some data\n\t\t\t\t\t\t\t// (for example if looking up a key which is a stored key already when using property keys).\n\t\t\t\t\t\t\t// Thus return an arbitrary key that was selected randomly, so should not exist on non-adversarial data:\n\t\t\t\t\t\t\tconst arbitrary = \"arbitrary unused key: fe71614a-bf3e-43b3-b7b0-4cef39538e90\";\n\t\t\t\t\t\t\tassert(\n\t\t\t\t\t\t\t\t!simpleNodeSchema.storedKeyToPropertyKey.has(brand(arbitrary)),\n\t\t\t\t\t\t\t\t0xa13 /* arbitrarily selected unused key was actually used */,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\treturn arbitrary;\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn key;\n\t\t\t\t\t},\n\t\t\t\t\tparse: (type, inputKey): FieldKey => {\n\t\t\t\t\t\tconst simpleNodeSchema = context.schema.get(brand(type)) ?? unknownTypeError(type);\n\t\t\t\t\t\tif (isObjectNodeSchema(simpleNodeSchema)) {\n\t\t\t\t\t\t\tconst info = simpleNodeSchema.flexKeyMap.get(inputKey);\n\t\t\t\t\t\t\tif (info === undefined) {\n\t\t\t\t\t\t\t\tthrow new UsageError(\n\t\t\t\t\t\t\t\t\t`Failed to parse VerboseTree due to unexpected key ${JSON.stringify(inputKey)} on type ${JSON.stringify(type)}.`,\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\treturn info.storedKey;\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn brand(inputKey);\n\t\t\t\t\t},\n\t\t\t\t},\n\t};\n}\n\n/**\n * Used to read a VerboseTree as a node cursor.\n *\n * @returns an {@link ITreeCursorSynchronous} for a single node in nodes mode.\n */\nexport function cursorFromVerbose(\n\tdata: VerboseTree,\n\toptions: SchemalessParseOptions,\n): ITreeCursorSynchronous {\n\treturn stackTreeNodeCursor(verboseTreeAdapter(options), data);\n}\n\n/**\n * Used to read a VerboseTree[] as a field cursor.\n *\n * @returns an {@link ITreeCursorSynchronous} for a single field in fields mode.\n */\nexport function fieldCursorFromVerbose(\n\tdata: VerboseTree[],\n\toptions: SchemalessParseOptions,\n): ITreeCursorSynchronous {\n\treturn stackTreeFieldCursor(\n\t\tverboseTreeAdapter(options),\n\t\t{ type: aboveRootPlaceholder, fields: data },\n\t\tkeyAsDetachedField(EmptyKey),\n\t);\n}\n\nfunction verboseTreeAdapter(options: SchemalessParseOptions): CursorAdapter<VerboseTree> {\n\treturn {\n\t\tvalue: (node: VerboseTree) => {\n\t\t\treturn isTreeValue(node) ? node : undefined;\n\t\t},\n\t\ttype: (node: VerboseTree) => {\n\t\t\tswitch (typeof node) {\n\t\t\t\tcase \"number\":\n\t\t\t\t\treturn brand(numberSchema.identifier);\n\t\t\t\tcase \"string\":\n\t\t\t\t\treturn brand(stringSchema.identifier);\n\t\t\t\tcase \"boolean\":\n\t\t\t\t\treturn brand(booleanSchema.identifier);\n\t\t\t\tdefault:\n\t\t\t\t\tif (node === null) {\n\t\t\t\t\t\treturn brand(nullSchema.identifier);\n\t\t\t\t\t}\n\t\t\t\t\tif (isFluidHandle(node)) {\n\t\t\t\t\t\treturn brand(handleSchema.identifier);\n\t\t\t\t\t}\n\t\t\t\t\treturn brand(node.type);\n\t\t\t}\n\t\t},\n\t\tkeysFromNode: (node: VerboseTree): readonly FieldKey[] => {\n\t\t\tswitch (typeof node) {\n\t\t\t\tcase \"object\": {\n\t\t\t\t\tif (node === null) {\n\t\t\t\t\t\treturn [];\n\t\t\t\t\t}\n\t\t\t\t\tif (isFluidHandle(node)) {\n\t\t\t\t\t\treturn [];\n\t\t\t\t\t}\n\t\t\t\t\tif (Array.isArray(node.fields)) {\n\t\t\t\t\t\treturn node.fields.length === 0 ? [] : [EmptyKey];\n\t\t\t\t\t}\n\n\t\t\t\t\tconst inputKeys = Object.keys(node.fields);\n\t\t\t\t\tconst converter = options.keyConverter;\n\t\t\t\t\tif (converter === undefined) {\n\t\t\t\t\t\treturn inputKeys as FieldKey[];\n\t\t\t\t\t}\n\t\t\t\t\treturn inputKeys.map((k) => converter.parse(node.type, k));\n\t\t\t\t}\n\t\t\t\tdefault:\n\t\t\t\t\treturn [];\n\t\t\t}\n\t\t},\n\t\tgetFieldFromNode: (node: VerboseTree, key: FieldKey): readonly VerboseTree[] => {\n\t\t\t// Object.prototype.hasOwnProperty can return true for strings (ex: with key \"0\"), so we have to filter them out.\n\t\t\t// Rather than just special casing strings, we can handle them with an early return for all primitives.\n\t\t\tif (typeof node !== \"object\") {\n\t\t\t\treturn [];\n\t\t\t}\n\n\t\t\tif (node === null) {\n\t\t\t\treturn [];\n\t\t\t}\n\n\t\t\tif (isFluidHandle(node)) {\n\t\t\t\treturn [];\n\t\t\t}\n\n\t\t\tif (Array.isArray(node.fields)) {\n\t\t\t\treturn key === EmptyKey ? node.fields : [];\n\t\t\t}\n\n\t\t\tconst convertedKey =\n\t\t\t\toptions.keyConverter === undefined ? key : options.keyConverter.encode(node.type, key);\n\n\t\t\tif (Object.prototype.hasOwnProperty.call(node.fields, convertedKey)) {\n\t\t\t\tconst field = node.fields[convertedKey];\n\t\t\t\treturn field === undefined ? [] : [field];\n\t\t\t}\n\n\t\t\treturn [];\n\t\t},\n\t};\n}\n\n/**\n * Used to read a node cursor as a VerboseTree.\n */\nexport function verboseFromCursor(\n\treader: ITreeCursor,\n\tcontext: Context,\n\toptions: TreeEncodingOptions,\n): VerboseTree {\n\tconst config: Required<TreeEncodingOptions> = {\n\t\tuseStoredKeys: false,\n\t\t...options,\n\t};\n\n\tconst storedSchemaMap = context.flexContext.schema.nodeSchema;\n\tconst schemaMap = context.schema;\n\n\treturn verboseFromCursorInner(reader, config, storedSchemaMap, schemaMap);\n}\n\nfunction verboseFromCursorInner(\n\treader: ITreeCursor,\n\toptions: Required<TreeEncodingOptions>,\n\tstoredSchema: ReadonlyMap<string, TreeNodeStoredSchema>,\n\tschema: ReadonlyMap<string, TreeNodeSchema>,\n): VerboseTree {\n\tconst fields = customFromCursor(\n\t\treader,\n\t\toptions,\n\t\tstoredSchema,\n\t\tschema,\n\t\tverboseFromCursorInner,\n\t);\n\tconst nodeSchema =\n\t\tstoredSchema.get(reader.type) ?? fail(0xb3c /* missing schema for type in cursor */);\n\tif (nodeSchema instanceof LeafNodeStoredSchema) {\n\t\treturn fields as TreeLeafValue;\n\t}\n\n\treturn {\n\t\ttype: reader.type,\n\t\tfields: fields as CustomTreeNode<VerboseTree>,\n\t};\n}\n\n/**\n * Clones tree, replacing any handles.\n * @remarks\n * A strongly types version of {@link replaceHandles}.\n * @alpha\n */\nexport function replaceVerboseTreeHandles<T>(\n\ttree: VerboseTree,\n\treplacer: HandleConverter<T>,\n): VerboseTree<T> {\n\treturn replaceHandles(tree, replacer) as VerboseTree<T>;\n}\n"]}
@@ -169,7 +169,7 @@ export type UnannotateAllowedTypes<T extends AnnotatedAllowedTypes> = Unannotate
169
169
  * Removes annotations from an allowed type.
170
170
  * @system @alpha
171
171
  */
172
- export type UnannotateAllowedType<T extends AnnotatedAllowedType> = T extends AnnotatedAllowedType<infer X> ? [X] : T;
172
+ export type UnannotateAllowedType<T extends AnnotatedAllowedType | LazyItem<TreeNodeSchema>> = T extends AnnotatedAllowedType<infer X> ? [X] : T;
173
173
  /**
174
174
  * Normalizes a {@link ImplicitAllowedTypes} to a set of {@link TreeNodeSchema}s, by eagerly evaluating any
175
175
  * lazy schema declarations.
@@ -179,11 +179,17 @@ export type UnannotateAllowedType<T extends AnnotatedAllowedType> = T extends An
179
179
  *
180
180
  * @internal
181
181
  */
182
- export declare function normalizeAllowedTypes(types: ImplicitAllowedTypes): ReadonlySet<TreeNodeSchema>;
182
+ export declare function normalizeAllowedTypes(types: ImplicitAnnotatedAllowedTypes): ReadonlySet<TreeNodeSchema>;
183
183
  /**
184
- * Normalizes an allowed type to an {@link AnnotatedAllowedType}, by adding empty annotations if they don't already exist.
184
+ * Normalizes an allowed type to an {@link AnnotatedAllowedType}, by adding empty annotations if they don't already exist
185
+ * and eagerly evaluating any lazy schema declarations.
186
+ *
187
+ * @remarks
188
+ * Note: this must only be called after all required schemas have been declared, otherwise evaluation of
189
+ * recursive schemas may fail.
190
+ * type is frozen and should not be modified after being passed in.
185
191
  */
186
- export declare function normalizeToAnnotatedAllowedType<T extends TreeNodeSchema>(type: T | AnnotatedAllowedType<T> | AnnotatedAllowedType<LazyItem<T>>): AnnotatedAllowedType<T> | AnnotatedAllowedType<LazyItem<T>>;
192
+ export declare function normalizeToAnnotatedAllowedType<T extends TreeNodeSchema>(type: T | AnnotatedAllowedType<T> | AnnotatedAllowedType<LazyItem<T>>): AnnotatedAllowedType<T>;
187
193
  /**
188
194
  * Normalizes a {@link ImplicitAnnotatedAllowedTypes} to a set of {@link AnnotatedAllowedSchema}s, by eagerly evaluating any
189
195
  * lazy schema declarations and adding empty metadata if it doesn't already exist.
@@ -199,6 +205,12 @@ export declare function normalizeAnnotatedAllowedTypes(types: ImplicitAnnotatedA
199
205
  * This does not evaluate any lazy schemas.
200
206
  */
201
207
  export declare function unannotateImplicitAllowedTypes<Types extends ImplicitAnnotatedAllowedTypes>(types: Types): UnannotateImplicitAllowedTypes<Types>;
208
+ /**
209
+ * Converts an {@link AnnotatedAllowedType} to an {@link LazyItem} by removing any annotations.
210
+ * @remarks
211
+ * This does not evaluate any lazy schemas.
212
+ */
213
+ export declare function unannotateAllowedType<Type extends AnnotatedAllowedType | LazyItem<TreeNodeSchema>>(allowedType: Type): UnannotateAllowedType<Type>;
202
214
  /**
203
215
  * Returns the schema referenced by the {@link LazyItem}.
204
216
  * @remarks
@@ -206,6 +218,10 @@ export declare function unannotateImplicitAllowedTypes<Types extends ImplicitAnn
206
218
  * @alpha
207
219
  */
208
220
  export declare function evaluateLazySchema<T extends TreeNodeSchema>(value: LazyItem<T>): T;
221
+ /**
222
+ * Throws a UsageError if the provided schema is undefined, most likely due to being used before it was initialized.
223
+ */
224
+ export declare function checkForUninitializedSchema(schema: ImplicitAnnotatedAllowedTypes | LazyItem<TreeNodeSchema>): void;
209
225
  /**
210
226
  * Indicates that the provided schema is the "most derived" version in its class hierarchy.
211
227
  *
@@ -1 +1 @@
1
- {"version":3,"file":"allowedTypes.d.ts","sourceRoot":"","sources":["../../../src/simple-tree/core/allowedTypes.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAgC,KAAK,OAAO,EAAE,MAAM,qBAAqB,CAAC;AACjF,OAAO,EAAU,KAAK,eAAe,EAAE,KAAK,QAAQ,EAAE,MAA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H,MAAM,MAAM,0CAA0C,CAAC,OAAO,SAAS,oBAAoB,IAC1F;IAAC,OAAO;CAAC,SAAS,CAAC,cAAc,CAAC,GAC/B,mBAAmB,CAAC,OAAO,CAAC,GAC5B,CAAC,OAAO,CAAC,SAAS,CAAC,YAAY,CAAC,GAC/B,kCAAkC,CAAC,OAAO,CAAC,GAC3C,KAAK,CAAC;AAEX;;;;;;;;;;GAUG;AACH,MAAM,MAAM,kCAAkC,CAAC,KAAK,SAAS,YAAY,IACxE,OAAO,CAAC,KAAK,CAAC,SAAS,IAAI,GACxB,KAAK,GACL;IACA,QAAQ,EAAE,QAAQ,IAAI,MAAM,KAAK,GAAG,KAAK,CAAC,QAAQ,CAAC,SAAS,QAAQ,CACnE,MAAM,OAAO,SAAS,cAAc,CACpC,GACE,mBAAmB,CAAC,OAAO,CAAC,GAC5B,KAAK;CACR,CAAC,MAAM,CAAC,CAAC"}
@@ -11,6 +11,7 @@ import { schemaAsTreeNodeValid } from "./treeNodeValid.js";
11
11
  * Checks if the input is an {@link AnnotatedAllowedTypes}.
12
12
  */
13
13
  export function isAnnotatedAllowedTypes(allowedTypes) {
14
+ checkForUninitializedSchema(allowedTypes);
14
15
  return (
15
16
  // Class based schema, and lazy schema references report type "function": filtering them out with typeof makes narrowing based on members mostly safe
16
17
  typeof allowedTypes === "object" && "metadata" in allowedTypes && "types" in allowedTypes);
@@ -19,7 +20,9 @@ export function isAnnotatedAllowedTypes(allowedTypes) {
19
20
  * Checks if the given allowed type is annotated with {@link AllowedTypeMetadata}.
20
21
  */
21
22
  export function isAnnotatedAllowedType(allowedType) {
22
- return "metadata" in allowedType && "type" in allowedType;
23
+ checkForUninitializedSchema(allowedType);
24
+ // Class based schema, and lazy schema references report type "function": filtering them out with typeof makes narrowing based on members mostly safe
25
+ return typeof allowedType === "object" && "metadata" in allowedType && "type" in allowedType;
23
26
  }
24
27
  /**
25
28
  * Normalizes a {@link ImplicitAllowedTypes} to a set of {@link TreeNodeSchema}s, by eagerly evaluating any
@@ -31,25 +34,36 @@ export function isAnnotatedAllowedType(allowedType) {
31
34
  * @internal
32
35
  */
33
36
  export function normalizeAllowedTypes(types) {
37
+ // remove annotations before normalizing
38
+ const unannotated = unannotateImplicitAllowedTypes(types);
34
39
  const normalized = new Set();
35
- if (isReadonlyArray(types)) {
40
+ if (isReadonlyArray(unannotated)) {
36
41
  // Types array must not be modified after it is normalized since that would result in the user of the normalized data having wrong (out of date) content.
37
- Object.freeze(types);
38
- for (const lazyType of types) {
42
+ Object.freeze(unannotated);
43
+ for (const lazyType of unannotated) {
39
44
  normalized.add(evaluateLazySchema(lazyType));
40
45
  }
41
46
  }
42
47
  else {
43
- normalized.add(evaluateLazySchema(types));
48
+ normalized.add(evaluateLazySchema(unannotated));
44
49
  }
45
50
  return normalized;
46
51
  }
47
52
  /**
48
- * Normalizes an allowed type to an {@link AnnotatedAllowedType}, by adding empty annotations if they don't already exist.
53
+ * Normalizes an allowed type to an {@link AnnotatedAllowedType}, by adding empty annotations if they don't already exist
54
+ * and eagerly evaluating any lazy schema declarations.
55
+ *
56
+ * @remarks
57
+ * Note: this must only be called after all required schemas have been declared, otherwise evaluation of
58
+ * recursive schemas may fail.
59
+ * type is frozen and should not be modified after being passed in.
49
60
  */
50
61
  export function normalizeToAnnotatedAllowedType(type) {
51
62
  return isAnnotatedAllowedType(type)
52
- ? type
63
+ ? {
64
+ metadata: type.metadata,
65
+ type: evaluateLazySchema(type.type),
66
+ }
53
67
  : {
54
68
  metadata: {},
55
69
  type,
@@ -102,13 +116,23 @@ export function normalizeAnnotatedAllowedTypes(types) {
102
116
  */
103
117
  export function unannotateImplicitAllowedTypes(types) {
104
118
  return (isAnnotatedAllowedTypes(types)
105
- ? types.types.map((allowedType) => isAnnotatedAllowedType(allowedType) ? allowedType.type : allowedType)
119
+ ? types.types.map(unannotateAllowedType)
106
120
  : isReadonlyArray(types)
107
- ? types.map((allowedType) => isAnnotatedAllowedType(allowedType) ? allowedType.type : allowedType)
121
+ ? types.map(unannotateAllowedType)
108
122
  : isAnnotatedAllowedType(types)
109
123
  ? types.type
110
124
  : types);
111
125
  }
126
+ /**
127
+ * Converts an {@link AnnotatedAllowedType} to an {@link LazyItem} by removing any annotations.
128
+ * @remarks
129
+ * This does not evaluate any lazy schemas.
130
+ */
131
+ export function unannotateAllowedType(allowedType) {
132
+ return isAnnotatedAllowedType(allowedType)
133
+ ? allowedType.type
134
+ : allowedType;
135
+ }
112
136
  const cachedLazyItem = new WeakMap();
113
137
  /**
114
138
  * Returns the schema referenced by the {@link LazyItem}.
@@ -120,12 +144,18 @@ export function evaluateLazySchema(value) {
120
144
  const evaluatedSchema = isLazy(value)
121
145
  ? getOrCreate(cachedLazyItem, value, value)
122
146
  : value;
123
- if (evaluatedSchema === undefined) {
124
- throw new UsageError(`Encountered an undefined schema. This could indicate that some referenced schema has not yet been instantiated.`);
125
- }
147
+ checkForUninitializedSchema(evaluatedSchema);
126
148
  markSchemaMostDerived(evaluatedSchema);
127
149
  return evaluatedSchema;
128
150
  }
151
+ /**
152
+ * Throws a UsageError if the provided schema is undefined, most likely due to being used before it was initialized.
153
+ */
154
+ export function checkForUninitializedSchema(schema) {
155
+ if (schema === undefined) {
156
+ throw new UsageError(`Encountered an undefined schema. This could indicate that some referenced schema has not yet been instantiated. Consider using a lazy schema reference (like "() => schema") or delaying the evaluation of the lazy reference if one is already being used.`);
157
+ }
158
+ }
129
159
  /**
130
160
  * Indicates that the provided schema is the "most derived" version in its class hierarchy.
131
161
  *