@fluidframework/tree 2.51.0 → 2.53.0-350190

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 (730) hide show
  1. package/.vscode/settings.json +0 -1
  2. package/CHANGELOG.md +43 -0
  3. package/api-report/tree.alpha.api.md +40 -30
  4. package/dist/alpha.d.ts +2 -1
  5. package/dist/codec/codec.d.ts +2 -1
  6. package/dist/codec/codec.d.ts.map +1 -1
  7. package/dist/codec/codec.js +4 -3
  8. package/dist/codec/codec.js.map +1 -1
  9. package/dist/core/index.d.ts +1 -1
  10. package/dist/core/index.d.ts.map +1 -1
  11. package/dist/core/index.js +3 -2
  12. package/dist/core/index.js.map +1 -1
  13. package/dist/core/rebase/index.d.ts +1 -1
  14. package/dist/core/rebase/index.d.ts.map +1 -1
  15. package/dist/core/rebase/index.js +2 -1
  16. package/dist/core/rebase/index.js.map +1 -1
  17. package/dist/core/rebase/types.d.ts +3 -1
  18. package/dist/core/rebase/types.d.ts.map +1 -1
  19. package/dist/core/rebase/types.js +2 -1
  20. package/dist/core/rebase/types.js.map +1 -1
  21. package/dist/core/schema-stored/schema.d.ts +1 -23
  22. package/dist/core/schema-stored/schema.d.ts.map +1 -1
  23. package/dist/core/schema-stored/schema.js +2 -2
  24. package/dist/core/schema-stored/schema.js.map +1 -1
  25. package/dist/core/tree/detachedFieldIndex.d.ts.map +1 -1
  26. package/dist/core/tree/detachedFieldIndex.js +2 -3
  27. package/dist/core/tree/detachedFieldIndex.js.map +1 -1
  28. package/dist/core/tree/detachedFieldIndexCodecCommon.d.ts +17 -0
  29. package/dist/core/tree/detachedFieldIndexCodecCommon.d.ts.map +1 -0
  30. package/dist/core/tree/detachedFieldIndexCodecCommon.js +68 -0
  31. package/dist/core/tree/detachedFieldIndexCodecCommon.js.map +1 -0
  32. package/dist/core/tree/detachedFieldIndexCodecV1.d.ts +11 -0
  33. package/dist/core/tree/detachedFieldIndexCodecV1.d.ts.map +1 -0
  34. package/dist/core/tree/detachedFieldIndexCodecV1.js +55 -0
  35. package/dist/core/tree/detachedFieldIndexCodecV1.js.map +1 -0
  36. package/dist/core/tree/detachedFieldIndexCodecV2.d.ts +11 -0
  37. package/dist/core/tree/detachedFieldIndexCodecV2.d.ts.map +1 -0
  38. package/dist/core/tree/detachedFieldIndexCodecV2.js +49 -0
  39. package/dist/core/tree/detachedFieldIndexCodecV2.js.map +1 -0
  40. package/dist/core/tree/detachedFieldIndexCodecs.d.ts +11 -0
  41. package/dist/core/tree/detachedFieldIndexCodecs.d.ts.map +1 -0
  42. package/dist/core/tree/detachedFieldIndexCodecs.js +26 -0
  43. package/dist/core/tree/detachedFieldIndexCodecs.js.map +1 -0
  44. package/dist/core/tree/detachedFieldIndexFormatCommon.d.ts +37 -0
  45. package/dist/core/tree/detachedFieldIndexFormatCommon.d.ts.map +1 -0
  46. package/dist/core/tree/{detachedFieldIndexFormat.js → detachedFieldIndexFormatCommon.js} +18 -13
  47. package/dist/core/tree/detachedFieldIndexFormatCommon.js.map +1 -0
  48. package/dist/core/tree/detachedFieldIndexFormatV1.d.ts +13 -0
  49. package/dist/core/tree/detachedFieldIndexFormatV1.d.ts.map +1 -0
  50. package/dist/core/tree/detachedFieldIndexFormatV1.js +12 -0
  51. package/dist/core/tree/detachedFieldIndexFormatV1.js.map +1 -0
  52. package/dist/core/tree/detachedFieldIndexFormatV2.d.ts +14 -0
  53. package/dist/core/tree/detachedFieldIndexFormatV2.d.ts.map +1 -0
  54. package/dist/core/tree/detachedFieldIndexFormatV2.js +14 -0
  55. package/dist/core/tree/detachedFieldIndexFormatV2.js.map +1 -0
  56. package/dist/feature-libraries/chunked-forest/codec/chunkDecoding.d.ts +9 -9
  57. package/dist/feature-libraries/chunked-forest/codec/chunkDecoding.d.ts.map +1 -1
  58. package/dist/feature-libraries/chunked-forest/codec/chunkDecoding.js +21 -21
  59. package/dist/feature-libraries/chunked-forest/codec/chunkDecoding.js.map +1 -1
  60. package/dist/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.d.ts +4 -2
  61. package/dist/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.d.ts.map +1 -1
  62. package/dist/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.js +4 -4
  63. package/dist/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.js.map +1 -1
  64. package/dist/feature-libraries/chunked-forest/codec/compressedEncode.d.ts +50 -31
  65. package/dist/feature-libraries/chunked-forest/codec/compressedEncode.d.ts.map +1 -1
  66. package/dist/feature-libraries/chunked-forest/codec/compressedEncode.js +74 -61
  67. package/dist/feature-libraries/chunked-forest/codec/compressedEncode.js.map +1 -1
  68. package/dist/feature-libraries/chunked-forest/codec/format.d.ts +20 -14
  69. package/dist/feature-libraries/chunked-forest/codec/format.d.ts.map +1 -1
  70. package/dist/feature-libraries/chunked-forest/codec/format.js +18 -12
  71. package/dist/feature-libraries/chunked-forest/codec/format.js.map +1 -1
  72. package/{lib/feature-libraries/chunked-forest/codec/nodeShape.d.ts → dist/feature-libraries/chunked-forest/codec/nodeEncoder.d.ts} +20 -14
  73. package/dist/feature-libraries/chunked-forest/codec/nodeEncoder.d.ts.map +1 -0
  74. package/dist/feature-libraries/chunked-forest/codec/{nodeShape.js → nodeEncoder.js} +23 -17
  75. package/dist/feature-libraries/chunked-forest/codec/nodeEncoder.js.map +1 -0
  76. package/dist/feature-libraries/chunked-forest/codec/schemaBasedEncode.d.ts +7 -7
  77. package/dist/feature-libraries/chunked-forest/codec/schemaBasedEncode.d.ts.map +1 -1
  78. package/dist/feature-libraries/chunked-forest/codec/schemaBasedEncode.js +22 -22
  79. package/dist/feature-libraries/chunked-forest/codec/schemaBasedEncode.js.map +1 -1
  80. package/dist/feature-libraries/chunked-forest/codec/uncompressedEncode.js +2 -2
  81. package/dist/feature-libraries/chunked-forest/codec/uncompressedEncode.js.map +1 -1
  82. package/dist/feature-libraries/default-schema/defaultFieldKinds.d.ts +5 -1
  83. package/dist/feature-libraries/default-schema/defaultFieldKinds.d.ts.map +1 -1
  84. package/dist/feature-libraries/default-schema/defaultFieldKinds.js +15 -2
  85. package/dist/feature-libraries/default-schema/defaultFieldKinds.js.map +1 -1
  86. package/dist/feature-libraries/default-schema/defaultSchema.d.ts.map +1 -1
  87. package/dist/feature-libraries/default-schema/defaultSchema.js +0 -2
  88. package/dist/feature-libraries/default-schema/defaultSchema.js.map +1 -1
  89. package/dist/feature-libraries/default-schema/index.d.ts +1 -1
  90. package/dist/feature-libraries/default-schema/index.d.ts.map +1 -1
  91. package/dist/feature-libraries/default-schema/index.js +2 -2
  92. package/dist/feature-libraries/default-schema/index.js.map +1 -1
  93. package/dist/feature-libraries/default-schema/schemaChecker.d.ts +14 -4
  94. package/dist/feature-libraries/default-schema/schemaChecker.d.ts.map +1 -1
  95. package/dist/feature-libraries/default-schema/schemaChecker.js +31 -26
  96. package/dist/feature-libraries/default-schema/schemaChecker.js.map +1 -1
  97. package/dist/feature-libraries/index.d.ts +1 -2
  98. package/dist/feature-libraries/index.d.ts.map +1 -1
  99. package/dist/feature-libraries/index.js +2 -4
  100. package/dist/feature-libraries/index.js.map +1 -1
  101. package/dist/feature-libraries/modular-schema/comparison.d.ts +5 -6
  102. package/dist/feature-libraries/modular-schema/comparison.d.ts.map +1 -1
  103. package/dist/feature-libraries/modular-schema/comparison.js +15 -16
  104. package/dist/feature-libraries/modular-schema/comparison.js.map +1 -1
  105. package/dist/feature-libraries/modular-schema/fieldChangeHandler.d.ts +7 -0
  106. package/dist/feature-libraries/modular-schema/fieldChangeHandler.d.ts.map +1 -1
  107. package/dist/feature-libraries/modular-schema/fieldChangeHandler.js +1 -0
  108. package/dist/feature-libraries/modular-schema/fieldChangeHandler.js.map +1 -1
  109. package/dist/feature-libraries/modular-schema/genericFieldKind.d.ts.map +1 -1
  110. package/dist/feature-libraries/modular-schema/genericFieldKind.js +1 -0
  111. package/dist/feature-libraries/modular-schema/genericFieldKind.js.map +1 -1
  112. package/dist/feature-libraries/modular-schema/modularChangeFamily.d.ts +9 -1
  113. package/dist/feature-libraries/modular-schema/modularChangeFamily.d.ts.map +1 -1
  114. package/dist/feature-libraries/modular-schema/modularChangeFamily.js +49 -20
  115. package/dist/feature-libraries/modular-schema/modularChangeFamily.js.map +1 -1
  116. package/dist/feature-libraries/modular-schema/modularChangeFormat.d.ts +9 -3
  117. package/dist/feature-libraries/modular-schema/modularChangeFormat.d.ts.map +1 -1
  118. package/dist/feature-libraries/object-forest/objectForest.d.ts.map +1 -1
  119. package/dist/feature-libraries/object-forest/objectForest.js +2 -3
  120. package/dist/feature-libraries/object-forest/objectForest.js.map +1 -1
  121. package/dist/feature-libraries/optional-field/optionalField.d.ts.map +1 -1
  122. package/dist/feature-libraries/optional-field/optionalField.js +3 -0
  123. package/dist/feature-libraries/optional-field/optionalField.js.map +1 -1
  124. package/dist/feature-libraries/sequence-field/sequenceFieldChangeRebaser.d.ts +1 -0
  125. package/dist/feature-libraries/sequence-field/sequenceFieldChangeRebaser.d.ts.map +1 -1
  126. package/dist/feature-libraries/sequence-field/sequenceFieldChangeRebaser.js +4 -0
  127. package/dist/feature-libraries/sequence-field/sequenceFieldChangeRebaser.js.map +1 -1
  128. package/dist/index.d.ts +1 -1
  129. package/dist/index.d.ts.map +1 -1
  130. package/dist/index.js +6 -2
  131. package/dist/index.js.map +1 -1
  132. package/dist/jsonDomainSchema.d.ts +5 -3
  133. package/dist/jsonDomainSchema.d.ts.map +1 -1
  134. package/dist/jsonDomainSchema.js.map +1 -1
  135. package/dist/packageVersion.d.ts +1 -1
  136. package/dist/packageVersion.d.ts.map +1 -1
  137. package/dist/packageVersion.js +1 -1
  138. package/dist/packageVersion.js.map +1 -1
  139. package/dist/shared-tree/independentView.d.ts +8 -0
  140. package/dist/shared-tree/independentView.d.ts.map +1 -1
  141. package/dist/shared-tree/independentView.js +23 -11
  142. package/dist/shared-tree/independentView.js.map +1 -1
  143. package/dist/shared-tree/schematizeTree.d.ts.map +1 -1
  144. package/dist/shared-tree/schematizeTree.js +1 -1
  145. package/dist/shared-tree/schematizeTree.js.map +1 -1
  146. package/dist/shared-tree/schematizingTreeView.d.ts +0 -1
  147. package/dist/shared-tree/schematizingTreeView.d.ts.map +1 -1
  148. package/dist/shared-tree/schematizingTreeView.js +9 -12
  149. package/dist/shared-tree/schematizingTreeView.js.map +1 -1
  150. package/dist/shared-tree/sharedTree.d.ts.map +1 -1
  151. package/dist/shared-tree/sharedTree.js +1 -29
  152. package/dist/shared-tree/sharedTree.js.map +1 -1
  153. package/dist/shared-tree/treeAlpha.d.ts +20 -6
  154. package/dist/shared-tree/treeAlpha.d.ts.map +1 -1
  155. package/dist/shared-tree/treeAlpha.js +18 -7
  156. package/dist/shared-tree/treeAlpha.js.map +1 -1
  157. package/dist/shared-tree/treeCheckout.d.ts +2 -1
  158. package/dist/shared-tree/treeCheckout.d.ts.map +1 -1
  159. package/dist/shared-tree/treeCheckout.js +32 -0
  160. package/dist/shared-tree/treeCheckout.js.map +1 -1
  161. package/dist/shared-tree-core/branch.d.ts.map +1 -1
  162. package/dist/shared-tree-core/branch.js +1 -1
  163. package/dist/shared-tree-core/branch.js.map +1 -1
  164. package/dist/simple-tree/api/conciseTree.d.ts +2 -2
  165. package/dist/simple-tree/api/conciseTree.d.ts.map +1 -1
  166. package/dist/simple-tree/api/conciseTree.js +6 -6
  167. package/dist/simple-tree/api/conciseTree.js.map +1 -1
  168. package/dist/simple-tree/api/configuration.d.ts +11 -2
  169. package/dist/simple-tree/api/configuration.d.ts.map +1 -1
  170. package/dist/simple-tree/api/configuration.js +5 -1
  171. package/dist/simple-tree/api/configuration.js.map +1 -1
  172. package/dist/simple-tree/api/create.d.ts +8 -7
  173. package/dist/simple-tree/api/create.d.ts.map +1 -1
  174. package/dist/simple-tree/api/create.js +33 -23
  175. package/dist/simple-tree/api/create.js.map +1 -1
  176. package/dist/simple-tree/api/customTree.d.ts +25 -4
  177. package/dist/simple-tree/api/customTree.d.ts.map +1 -1
  178. package/dist/simple-tree/api/customTree.js +42 -16
  179. package/dist/simple-tree/api/customTree.js.map +1 -1
  180. package/dist/simple-tree/api/discrepancies.d.ts +94 -0
  181. package/dist/simple-tree/api/discrepancies.d.ts.map +1 -0
  182. package/dist/simple-tree/api/discrepancies.js +256 -0
  183. package/dist/simple-tree/api/discrepancies.js.map +1 -0
  184. package/dist/simple-tree/api/index.d.ts +3 -2
  185. package/dist/simple-tree/api/index.d.ts.map +1 -1
  186. package/dist/simple-tree/api/index.js +3 -2
  187. package/dist/simple-tree/api/index.js.map +1 -1
  188. package/dist/simple-tree/api/schemaCompatibilityTester.d.ts +9 -7
  189. package/dist/simple-tree/api/schemaCompatibilityTester.d.ts.map +1 -1
  190. package/dist/simple-tree/api/schemaCompatibilityTester.js +17 -117
  191. package/dist/simple-tree/api/schemaCompatibilityTester.js.map +1 -1
  192. package/dist/simple-tree/api/schemaFactory.d.ts +16 -159
  193. package/dist/simple-tree/api/schemaFactory.d.ts.map +1 -1
  194. package/dist/simple-tree/api/schemaFactory.js +4 -47
  195. package/dist/simple-tree/api/schemaFactory.js.map +1 -1
  196. package/dist/simple-tree/api/schemaFactoryAlpha.d.ts +157 -16
  197. package/dist/simple-tree/api/schemaFactoryAlpha.d.ts.map +1 -1
  198. package/dist/simple-tree/api/schemaFactoryAlpha.js +33 -11
  199. package/dist/simple-tree/api/schemaFactoryAlpha.js.map +1 -1
  200. package/dist/simple-tree/api/schemaFactoryRecursive.d.ts +1 -3
  201. package/dist/simple-tree/api/schemaFactoryRecursive.d.ts.map +1 -1
  202. package/dist/simple-tree/api/schemaFactoryRecursive.js +1 -7
  203. package/dist/simple-tree/api/schemaFactoryRecursive.js.map +1 -1
  204. package/dist/simple-tree/api/schemaStatics.d.ts +158 -0
  205. package/dist/simple-tree/api/schemaStatics.d.ts.map +1 -0
  206. package/dist/simple-tree/api/schemaStatics.js +59 -0
  207. package/dist/simple-tree/api/schemaStatics.js.map +1 -0
  208. package/dist/simple-tree/api/storedSchema.d.ts +5 -3
  209. package/dist/simple-tree/api/storedSchema.d.ts.map +1 -1
  210. package/dist/simple-tree/api/storedSchema.js +9 -3
  211. package/dist/simple-tree/api/storedSchema.js.map +1 -1
  212. package/dist/simple-tree/api/treeBeta.d.ts +2 -2
  213. package/dist/simple-tree/api/treeBeta.d.ts.map +1 -1
  214. package/dist/simple-tree/api/treeBeta.js +16 -4
  215. package/dist/simple-tree/api/treeBeta.js.map +1 -1
  216. package/dist/simple-tree/api/verboseTree.d.ts +2 -2
  217. package/dist/simple-tree/api/verboseTree.d.ts.map +1 -1
  218. package/dist/simple-tree/api/verboseTree.js +15 -15
  219. package/dist/simple-tree/api/verboseTree.js.map +1 -1
  220. package/dist/simple-tree/core/allowedTypes.d.ts +43 -11
  221. package/dist/simple-tree/core/allowedTypes.d.ts.map +1 -1
  222. package/dist/simple-tree/core/allowedTypes.js +51 -11
  223. package/dist/simple-tree/core/allowedTypes.js.map +1 -1
  224. package/dist/simple-tree/core/context.d.ts +13 -2
  225. package/dist/simple-tree/core/context.d.ts.map +1 -1
  226. package/dist/simple-tree/core/context.js +22 -9
  227. package/dist/simple-tree/core/context.js.map +1 -1
  228. package/dist/simple-tree/core/index.d.ts +6 -4
  229. package/dist/simple-tree/core/index.d.ts.map +1 -1
  230. package/dist/simple-tree/core/index.js +8 -1
  231. package/dist/simple-tree/core/index.js.map +1 -1
  232. package/dist/simple-tree/core/simpleNodeSchemaBase.d.ts +25 -0
  233. package/dist/simple-tree/core/simpleNodeSchemaBase.d.ts.map +1 -0
  234. package/dist/simple-tree/core/simpleNodeSchemaBase.js +7 -0
  235. package/dist/simple-tree/core/simpleNodeSchemaBase.js.map +1 -0
  236. package/dist/simple-tree/core/toStored.d.ts +32 -0
  237. package/dist/simple-tree/core/toStored.d.ts.map +1 -0
  238. package/dist/simple-tree/core/toStored.js +37 -0
  239. package/dist/simple-tree/core/toStored.js.map +1 -0
  240. package/dist/simple-tree/core/treeNodeKernel.d.ts +1 -1
  241. package/dist/simple-tree/core/treeNodeKernel.js +1 -1
  242. package/dist/simple-tree/core/treeNodeKernel.js.map +1 -1
  243. package/dist/simple-tree/core/treeNodeSchema.d.ts +7 -2
  244. package/dist/simple-tree/core/treeNodeSchema.d.ts.map +1 -1
  245. package/dist/simple-tree/core/treeNodeSchema.js.map +1 -1
  246. package/dist/simple-tree/core/treeNodeValid.d.ts +7 -2
  247. package/dist/simple-tree/core/treeNodeValid.d.ts.map +1 -1
  248. package/dist/simple-tree/core/treeNodeValid.js +19 -4
  249. package/dist/simple-tree/core/treeNodeValid.js.map +1 -1
  250. package/dist/simple-tree/core/walkSchema.d.ts +22 -5
  251. package/dist/simple-tree/core/walkSchema.d.ts.map +1 -1
  252. package/dist/simple-tree/core/walkSchema.js +6 -2
  253. package/dist/simple-tree/core/walkSchema.js.map +1 -1
  254. package/dist/simple-tree/createContext.d.ts +2 -0
  255. package/dist/simple-tree/createContext.d.ts.map +1 -1
  256. package/dist/simple-tree/createContext.js +4 -2
  257. package/dist/simple-tree/createContext.js.map +1 -1
  258. package/dist/simple-tree/fieldSchema.d.ts +1 -0
  259. package/dist/simple-tree/fieldSchema.d.ts.map +1 -1
  260. package/dist/simple-tree/fieldSchema.js +2 -1
  261. package/dist/simple-tree/fieldSchema.js.map +1 -1
  262. package/dist/simple-tree/index.d.ts +7 -7
  263. package/dist/simple-tree/index.d.ts.map +1 -1
  264. package/dist/simple-tree/index.js +13 -8
  265. package/dist/simple-tree/index.js.map +1 -1
  266. package/dist/simple-tree/leafNodeSchema.d.ts.map +1 -1
  267. package/dist/simple-tree/leafNodeSchema.js +1 -0
  268. package/dist/simple-tree/leafNodeSchema.js.map +1 -1
  269. package/dist/simple-tree/node-kinds/array/arrayNode.d.ts.map +1 -1
  270. package/dist/simple-tree/node-kinds/array/arrayNode.js +18 -4
  271. package/dist/simple-tree/node-kinds/array/arrayNode.js.map +1 -1
  272. package/dist/simple-tree/node-kinds/index.d.ts +1 -1
  273. package/dist/simple-tree/node-kinds/index.d.ts.map +1 -1
  274. package/dist/simple-tree/node-kinds/index.js +1 -2
  275. package/dist/simple-tree/node-kinds/index.js.map +1 -1
  276. package/dist/simple-tree/node-kinds/map/mapNode.d.ts.map +1 -1
  277. package/dist/simple-tree/node-kinds/map/mapNode.js +9 -2
  278. package/dist/simple-tree/node-kinds/map/mapNode.js.map +1 -1
  279. package/dist/simple-tree/node-kinds/object/index.d.ts +1 -1
  280. package/dist/simple-tree/node-kinds/object/index.d.ts.map +1 -1
  281. package/dist/simple-tree/node-kinds/object/index.js +1 -2
  282. package/dist/simple-tree/node-kinds/object/index.js.map +1 -1
  283. package/dist/simple-tree/node-kinds/object/objectNode.d.ts +3 -8
  284. package/dist/simple-tree/node-kinds/object/objectNode.d.ts.map +1 -1
  285. package/dist/simple-tree/node-kinds/object/objectNode.js +41 -44
  286. package/dist/simple-tree/node-kinds/object/objectNode.js.map +1 -1
  287. package/dist/simple-tree/node-kinds/record/recordNode.d.ts.map +1 -1
  288. package/dist/simple-tree/node-kinds/record/recordNode.js +9 -2
  289. package/dist/simple-tree/node-kinds/record/recordNode.js.map +1 -1
  290. package/dist/simple-tree/prepareForInsertion.d.ts +6 -6
  291. package/dist/simple-tree/prepareForInsertion.d.ts.map +1 -1
  292. package/dist/simple-tree/prepareForInsertion.js +19 -13
  293. package/dist/simple-tree/prepareForInsertion.js.map +1 -1
  294. package/dist/simple-tree/simpleSchema.d.ts +6 -21
  295. package/dist/simple-tree/simpleSchema.d.ts.map +1 -1
  296. package/dist/simple-tree/simpleSchema.js.map +1 -1
  297. package/dist/simple-tree/toStoredSchema.d.ts +38 -11
  298. package/dist/simple-tree/toStoredSchema.d.ts.map +1 -1
  299. package/dist/simple-tree/toStoredSchema.js +71 -33
  300. package/dist/simple-tree/toStoredSchema.js.map +1 -1
  301. package/dist/simple-tree/unhydratedFlexTreeFromInsertable.d.ts +2 -2
  302. package/dist/simple-tree/unhydratedFlexTreeFromInsertable.d.ts.map +1 -1
  303. package/dist/simple-tree/unhydratedFlexTreeFromInsertable.js.map +1 -1
  304. package/dist/simple-tree/walkFieldSchema.d.ts +1 -0
  305. package/dist/simple-tree/walkFieldSchema.d.ts.map +1 -1
  306. package/dist/simple-tree/walkFieldSchema.js +1 -0
  307. package/dist/simple-tree/walkFieldSchema.js.map +1 -1
  308. package/lib/alpha.d.ts +2 -1
  309. package/lib/codec/codec.d.ts +2 -1
  310. package/lib/codec/codec.d.ts.map +1 -1
  311. package/lib/codec/codec.js +4 -3
  312. package/lib/codec/codec.js.map +1 -1
  313. package/lib/core/index.d.ts +1 -1
  314. package/lib/core/index.d.ts.map +1 -1
  315. package/lib/core/index.js +1 -1
  316. package/lib/core/index.js.map +1 -1
  317. package/lib/core/rebase/index.d.ts +1 -1
  318. package/lib/core/rebase/index.d.ts.map +1 -1
  319. package/lib/core/rebase/index.js +1 -1
  320. package/lib/core/rebase/index.js.map +1 -1
  321. package/lib/core/rebase/types.d.ts +3 -1
  322. package/lib/core/rebase/types.d.ts.map +1 -1
  323. package/lib/core/rebase/types.js +1 -0
  324. package/lib/core/rebase/types.js.map +1 -1
  325. package/lib/core/schema-stored/schema.d.ts +1 -23
  326. package/lib/core/schema-stored/schema.d.ts.map +1 -1
  327. package/lib/core/schema-stored/schema.js +2 -2
  328. package/lib/core/schema-stored/schema.js.map +1 -1
  329. package/lib/core/tree/detachedFieldIndex.d.ts.map +1 -1
  330. package/lib/core/tree/detachedFieldIndex.js +2 -3
  331. package/lib/core/tree/detachedFieldIndex.js.map +1 -1
  332. package/lib/core/tree/detachedFieldIndexCodecCommon.d.ts +17 -0
  333. package/lib/core/tree/detachedFieldIndexCodecCommon.d.ts.map +1 -0
  334. package/lib/core/tree/detachedFieldIndexCodecCommon.js +64 -0
  335. package/lib/core/tree/detachedFieldIndexCodecCommon.js.map +1 -0
  336. package/lib/core/tree/detachedFieldIndexCodecV1.d.ts +11 -0
  337. package/lib/core/tree/detachedFieldIndexCodecV1.d.ts.map +1 -0
  338. package/lib/core/tree/detachedFieldIndexCodecV1.js +51 -0
  339. package/lib/core/tree/detachedFieldIndexCodecV1.js.map +1 -0
  340. package/lib/core/tree/detachedFieldIndexCodecV2.d.ts +11 -0
  341. package/lib/core/tree/detachedFieldIndexCodecV2.d.ts.map +1 -0
  342. package/lib/core/tree/detachedFieldIndexCodecV2.js +45 -0
  343. package/lib/core/tree/detachedFieldIndexCodecV2.js.map +1 -0
  344. package/lib/core/tree/detachedFieldIndexCodecs.d.ts +11 -0
  345. package/lib/core/tree/detachedFieldIndexCodecs.d.ts.map +1 -0
  346. package/lib/core/tree/detachedFieldIndexCodecs.js +21 -0
  347. package/lib/core/tree/detachedFieldIndexCodecs.js.map +1 -0
  348. package/lib/core/tree/detachedFieldIndexFormatCommon.d.ts +37 -0
  349. package/lib/core/tree/detachedFieldIndexFormatCommon.d.ts.map +1 -0
  350. package/lib/core/tree/{detachedFieldIndexFormat.js → detachedFieldIndexFormatCommon.js} +13 -10
  351. package/lib/core/tree/detachedFieldIndexFormatCommon.js.map +1 -0
  352. package/lib/core/tree/detachedFieldIndexFormatV1.d.ts +13 -0
  353. package/lib/core/tree/detachedFieldIndexFormatV1.d.ts.map +1 -0
  354. package/lib/core/tree/detachedFieldIndexFormatV1.js +9 -0
  355. package/lib/core/tree/detachedFieldIndexFormatV1.js.map +1 -0
  356. package/lib/core/tree/detachedFieldIndexFormatV2.d.ts +14 -0
  357. package/lib/core/tree/detachedFieldIndexFormatV2.d.ts.map +1 -0
  358. package/lib/core/tree/detachedFieldIndexFormatV2.js +11 -0
  359. package/lib/core/tree/detachedFieldIndexFormatV2.js.map +1 -0
  360. package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.d.ts +9 -9
  361. package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.d.ts.map +1 -1
  362. package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.js +19 -19
  363. package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.js.map +1 -1
  364. package/lib/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.d.ts +4 -2
  365. package/lib/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.d.ts.map +1 -1
  366. package/lib/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.js +4 -4
  367. package/lib/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.js.map +1 -1
  368. package/lib/feature-libraries/chunked-forest/codec/compressedEncode.d.ts +50 -31
  369. package/lib/feature-libraries/chunked-forest/codec/compressedEncode.d.ts.map +1 -1
  370. package/lib/feature-libraries/chunked-forest/codec/compressedEncode.js +70 -57
  371. package/lib/feature-libraries/chunked-forest/codec/compressedEncode.js.map +1 -1
  372. package/lib/feature-libraries/chunked-forest/codec/format.d.ts +20 -14
  373. package/lib/feature-libraries/chunked-forest/codec/format.d.ts.map +1 -1
  374. package/lib/feature-libraries/chunked-forest/codec/format.js +17 -11
  375. package/lib/feature-libraries/chunked-forest/codec/format.js.map +1 -1
  376. package/{dist/feature-libraries/chunked-forest/codec/nodeShape.d.ts → lib/feature-libraries/chunked-forest/codec/nodeEncoder.d.ts} +20 -14
  377. package/lib/feature-libraries/chunked-forest/codec/nodeEncoder.d.ts.map +1 -0
  378. package/lib/feature-libraries/chunked-forest/codec/{nodeShape.js → nodeEncoder.js} +21 -15
  379. package/lib/feature-libraries/chunked-forest/codec/nodeEncoder.js.map +1 -0
  380. package/lib/feature-libraries/chunked-forest/codec/schemaBasedEncode.d.ts +7 -7
  381. package/lib/feature-libraries/chunked-forest/codec/schemaBasedEncode.d.ts.map +1 -1
  382. package/lib/feature-libraries/chunked-forest/codec/schemaBasedEncode.js +19 -19
  383. package/lib/feature-libraries/chunked-forest/codec/schemaBasedEncode.js.map +1 -1
  384. package/lib/feature-libraries/chunked-forest/codec/uncompressedEncode.js +2 -2
  385. package/lib/feature-libraries/chunked-forest/codec/uncompressedEncode.js.map +1 -1
  386. package/lib/feature-libraries/default-schema/defaultFieldKinds.d.ts +5 -1
  387. package/lib/feature-libraries/default-schema/defaultFieldKinds.d.ts.map +1 -1
  388. package/lib/feature-libraries/default-schema/defaultFieldKinds.js +15 -2
  389. package/lib/feature-libraries/default-schema/defaultFieldKinds.js.map +1 -1
  390. package/lib/feature-libraries/default-schema/defaultSchema.d.ts.map +1 -1
  391. package/lib/feature-libraries/default-schema/defaultSchema.js +0 -2
  392. package/lib/feature-libraries/default-schema/defaultSchema.js.map +1 -1
  393. package/lib/feature-libraries/default-schema/index.d.ts +1 -1
  394. package/lib/feature-libraries/default-schema/index.d.ts.map +1 -1
  395. package/lib/feature-libraries/default-schema/index.js +1 -1
  396. package/lib/feature-libraries/default-schema/index.js.map +1 -1
  397. package/lib/feature-libraries/default-schema/schemaChecker.d.ts +14 -4
  398. package/lib/feature-libraries/default-schema/schemaChecker.d.ts.map +1 -1
  399. package/lib/feature-libraries/default-schema/schemaChecker.js +29 -24
  400. package/lib/feature-libraries/default-schema/schemaChecker.js.map +1 -1
  401. package/lib/feature-libraries/index.d.ts +1 -2
  402. package/lib/feature-libraries/index.d.ts.map +1 -1
  403. package/lib/feature-libraries/index.js +1 -2
  404. package/lib/feature-libraries/index.js.map +1 -1
  405. package/lib/feature-libraries/modular-schema/comparison.d.ts +5 -6
  406. package/lib/feature-libraries/modular-schema/comparison.d.ts.map +1 -1
  407. package/lib/feature-libraries/modular-schema/comparison.js +14 -14
  408. package/lib/feature-libraries/modular-schema/comparison.js.map +1 -1
  409. package/lib/feature-libraries/modular-schema/fieldChangeHandler.d.ts +7 -0
  410. package/lib/feature-libraries/modular-schema/fieldChangeHandler.d.ts.map +1 -1
  411. package/lib/feature-libraries/modular-schema/fieldChangeHandler.js +1 -0
  412. package/lib/feature-libraries/modular-schema/fieldChangeHandler.js.map +1 -1
  413. package/lib/feature-libraries/modular-schema/genericFieldKind.d.ts.map +1 -1
  414. package/lib/feature-libraries/modular-schema/genericFieldKind.js +1 -0
  415. package/lib/feature-libraries/modular-schema/genericFieldKind.js.map +1 -1
  416. package/lib/feature-libraries/modular-schema/modularChangeFamily.d.ts +9 -1
  417. package/lib/feature-libraries/modular-schema/modularChangeFamily.d.ts.map +1 -1
  418. package/lib/feature-libraries/modular-schema/modularChangeFamily.js +50 -21
  419. package/lib/feature-libraries/modular-schema/modularChangeFamily.js.map +1 -1
  420. package/lib/feature-libraries/modular-schema/modularChangeFormat.d.ts +9 -3
  421. package/lib/feature-libraries/modular-schema/modularChangeFormat.d.ts.map +1 -1
  422. package/lib/feature-libraries/object-forest/objectForest.d.ts.map +1 -1
  423. package/lib/feature-libraries/object-forest/objectForest.js +3 -4
  424. package/lib/feature-libraries/object-forest/objectForest.js.map +1 -1
  425. package/lib/feature-libraries/optional-field/optionalField.d.ts.map +1 -1
  426. package/lib/feature-libraries/optional-field/optionalField.js +3 -0
  427. package/lib/feature-libraries/optional-field/optionalField.js.map +1 -1
  428. package/lib/feature-libraries/sequence-field/sequenceFieldChangeRebaser.d.ts +1 -0
  429. package/lib/feature-libraries/sequence-field/sequenceFieldChangeRebaser.d.ts.map +1 -1
  430. package/lib/feature-libraries/sequence-field/sequenceFieldChangeRebaser.js +4 -0
  431. package/lib/feature-libraries/sequence-field/sequenceFieldChangeRebaser.js.map +1 -1
  432. package/lib/index.d.ts +1 -1
  433. package/lib/index.d.ts.map +1 -1
  434. package/lib/index.js +2 -2
  435. package/lib/index.js.map +1 -1
  436. package/lib/jsonDomainSchema.d.ts +5 -3
  437. package/lib/jsonDomainSchema.d.ts.map +1 -1
  438. package/lib/jsonDomainSchema.js.map +1 -1
  439. package/lib/packageVersion.d.ts +1 -1
  440. package/lib/packageVersion.d.ts.map +1 -1
  441. package/lib/packageVersion.js +1 -1
  442. package/lib/packageVersion.js.map +1 -1
  443. package/lib/shared-tree/independentView.d.ts +8 -0
  444. package/lib/shared-tree/independentView.d.ts.map +1 -1
  445. package/lib/shared-tree/independentView.js +21 -10
  446. package/lib/shared-tree/independentView.js.map +1 -1
  447. package/lib/shared-tree/schematizeTree.d.ts.map +1 -1
  448. package/lib/shared-tree/schematizeTree.js +2 -2
  449. package/lib/shared-tree/schematizeTree.js.map +1 -1
  450. package/lib/shared-tree/schematizingTreeView.d.ts +0 -1
  451. package/lib/shared-tree/schematizingTreeView.d.ts.map +1 -1
  452. package/lib/shared-tree/schematizingTreeView.js +10 -13
  453. package/lib/shared-tree/schematizingTreeView.js.map +1 -1
  454. package/lib/shared-tree/sharedTree.d.ts.map +1 -1
  455. package/lib/shared-tree/sharedTree.js +2 -30
  456. package/lib/shared-tree/sharedTree.js.map +1 -1
  457. package/lib/shared-tree/treeAlpha.d.ts +20 -6
  458. package/lib/shared-tree/treeAlpha.d.ts.map +1 -1
  459. package/lib/shared-tree/treeAlpha.js +19 -8
  460. package/lib/shared-tree/treeAlpha.js.map +1 -1
  461. package/lib/shared-tree/treeCheckout.d.ts +2 -1
  462. package/lib/shared-tree/treeCheckout.d.ts.map +1 -1
  463. package/lib/shared-tree/treeCheckout.js +33 -1
  464. package/lib/shared-tree/treeCheckout.js.map +1 -1
  465. package/lib/shared-tree-core/branch.d.ts.map +1 -1
  466. package/lib/shared-tree-core/branch.js +1 -1
  467. package/lib/shared-tree-core/branch.js.map +1 -1
  468. package/lib/simple-tree/api/conciseTree.d.ts +2 -2
  469. package/lib/simple-tree/api/conciseTree.d.ts.map +1 -1
  470. package/lib/simple-tree/api/conciseTree.js +6 -6
  471. package/lib/simple-tree/api/conciseTree.js.map +1 -1
  472. package/lib/simple-tree/api/configuration.d.ts +11 -2
  473. package/lib/simple-tree/api/configuration.d.ts.map +1 -1
  474. package/lib/simple-tree/api/configuration.js +6 -2
  475. package/lib/simple-tree/api/configuration.js.map +1 -1
  476. package/lib/simple-tree/api/create.d.ts +8 -7
  477. package/lib/simple-tree/api/create.d.ts.map +1 -1
  478. package/lib/simple-tree/api/create.js +35 -25
  479. package/lib/simple-tree/api/create.js.map +1 -1
  480. package/lib/simple-tree/api/customTree.d.ts +25 -4
  481. package/lib/simple-tree/api/customTree.d.ts.map +1 -1
  482. package/lib/simple-tree/api/customTree.js +43 -17
  483. package/lib/simple-tree/api/customTree.js.map +1 -1
  484. package/lib/simple-tree/api/discrepancies.d.ts +94 -0
  485. package/lib/simple-tree/api/discrepancies.d.ts.map +1 -0
  486. package/lib/simple-tree/api/discrepancies.js +251 -0
  487. package/lib/simple-tree/api/discrepancies.js.map +1 -0
  488. package/lib/simple-tree/api/index.d.ts +3 -2
  489. package/lib/simple-tree/api/index.d.ts.map +1 -1
  490. package/lib/simple-tree/api/index.js +2 -1
  491. package/lib/simple-tree/api/index.js.map +1 -1
  492. package/lib/simple-tree/api/schemaCompatibilityTester.d.ts +9 -7
  493. package/lib/simple-tree/api/schemaCompatibilityTester.d.ts.map +1 -1
  494. package/lib/simple-tree/api/schemaCompatibilityTester.js +19 -119
  495. package/lib/simple-tree/api/schemaCompatibilityTester.js.map +1 -1
  496. package/lib/simple-tree/api/schemaFactory.d.ts +16 -159
  497. package/lib/simple-tree/api/schemaFactory.d.ts.map +1 -1
  498. package/lib/simple-tree/api/schemaFactory.js +2 -45
  499. package/lib/simple-tree/api/schemaFactory.js.map +1 -1
  500. package/lib/simple-tree/api/schemaFactoryAlpha.d.ts +157 -16
  501. package/lib/simple-tree/api/schemaFactoryAlpha.d.ts.map +1 -1
  502. package/lib/simple-tree/api/schemaFactoryAlpha.js +23 -1
  503. package/lib/simple-tree/api/schemaFactoryAlpha.js.map +1 -1
  504. package/lib/simple-tree/api/schemaFactoryRecursive.d.ts +1 -3
  505. package/lib/simple-tree/api/schemaFactoryRecursive.d.ts.map +1 -1
  506. package/lib/simple-tree/api/schemaFactoryRecursive.js +0 -5
  507. package/lib/simple-tree/api/schemaFactoryRecursive.js.map +1 -1
  508. package/lib/simple-tree/api/schemaStatics.d.ts +158 -0
  509. package/lib/simple-tree/api/schemaStatics.d.ts.map +1 -0
  510. package/lib/simple-tree/api/schemaStatics.js +56 -0
  511. package/lib/simple-tree/api/schemaStatics.js.map +1 -0
  512. package/lib/simple-tree/api/storedSchema.d.ts +5 -3
  513. package/lib/simple-tree/api/storedSchema.d.ts.map +1 -1
  514. package/lib/simple-tree/api/storedSchema.js +12 -6
  515. package/lib/simple-tree/api/storedSchema.js.map +1 -1
  516. package/lib/simple-tree/api/treeBeta.d.ts +2 -2
  517. package/lib/simple-tree/api/treeBeta.d.ts.map +1 -1
  518. package/lib/simple-tree/api/treeBeta.js +14 -2
  519. package/lib/simple-tree/api/treeBeta.js.map +1 -1
  520. package/lib/simple-tree/api/verboseTree.d.ts +2 -2
  521. package/lib/simple-tree/api/verboseTree.d.ts.map +1 -1
  522. package/lib/simple-tree/api/verboseTree.js +9 -9
  523. package/lib/simple-tree/api/verboseTree.js.map +1 -1
  524. package/lib/simple-tree/core/allowedTypes.d.ts +43 -11
  525. package/lib/simple-tree/core/allowedTypes.d.ts.map +1 -1
  526. package/lib/simple-tree/core/allowedTypes.js +52 -11
  527. package/lib/simple-tree/core/allowedTypes.js.map +1 -1
  528. package/lib/simple-tree/core/context.d.ts +13 -2
  529. package/lib/simple-tree/core/context.d.ts.map +1 -1
  530. package/lib/simple-tree/core/context.js +22 -9
  531. package/lib/simple-tree/core/context.js.map +1 -1
  532. package/lib/simple-tree/core/index.d.ts +6 -4
  533. package/lib/simple-tree/core/index.d.ts.map +1 -1
  534. package/lib/simple-tree/core/index.js +4 -3
  535. package/lib/simple-tree/core/index.js.map +1 -1
  536. package/lib/simple-tree/core/simpleNodeSchemaBase.d.ts +25 -0
  537. package/lib/simple-tree/core/simpleNodeSchemaBase.d.ts.map +1 -0
  538. package/lib/simple-tree/core/simpleNodeSchemaBase.js +6 -0
  539. package/lib/simple-tree/core/simpleNodeSchemaBase.js.map +1 -0
  540. package/lib/simple-tree/core/toStored.d.ts +32 -0
  541. package/lib/simple-tree/core/toStored.d.ts.map +1 -0
  542. package/lib/simple-tree/core/toStored.js +32 -0
  543. package/lib/simple-tree/core/toStored.js.map +1 -0
  544. package/lib/simple-tree/core/treeNodeKernel.d.ts +1 -1
  545. package/lib/simple-tree/core/treeNodeKernel.js +1 -1
  546. package/lib/simple-tree/core/treeNodeKernel.js.map +1 -1
  547. package/lib/simple-tree/core/treeNodeSchema.d.ts +7 -2
  548. package/lib/simple-tree/core/treeNodeSchema.d.ts.map +1 -1
  549. package/lib/simple-tree/core/treeNodeSchema.js.map +1 -1
  550. package/lib/simple-tree/core/treeNodeValid.d.ts +7 -2
  551. package/lib/simple-tree/core/treeNodeValid.d.ts.map +1 -1
  552. package/lib/simple-tree/core/treeNodeValid.js +17 -3
  553. package/lib/simple-tree/core/treeNodeValid.js.map +1 -1
  554. package/lib/simple-tree/core/walkSchema.d.ts +22 -5
  555. package/lib/simple-tree/core/walkSchema.d.ts.map +1 -1
  556. package/lib/simple-tree/core/walkSchema.js +6 -2
  557. package/lib/simple-tree/core/walkSchema.js.map +1 -1
  558. package/lib/simple-tree/createContext.d.ts +2 -0
  559. package/lib/simple-tree/createContext.d.ts.map +1 -1
  560. package/lib/simple-tree/createContext.js +5 -3
  561. package/lib/simple-tree/createContext.js.map +1 -1
  562. package/lib/simple-tree/fieldSchema.d.ts +1 -0
  563. package/lib/simple-tree/fieldSchema.d.ts.map +1 -1
  564. package/lib/simple-tree/fieldSchema.js +2 -1
  565. package/lib/simple-tree/fieldSchema.js.map +1 -1
  566. package/lib/simple-tree/index.d.ts +7 -7
  567. package/lib/simple-tree/index.d.ts.map +1 -1
  568. package/lib/simple-tree/index.js +5 -5
  569. package/lib/simple-tree/index.js.map +1 -1
  570. package/lib/simple-tree/leafNodeSchema.d.ts.map +1 -1
  571. package/lib/simple-tree/leafNodeSchema.js +2 -1
  572. package/lib/simple-tree/leafNodeSchema.js.map +1 -1
  573. package/lib/simple-tree/node-kinds/array/arrayNode.d.ts.map +1 -1
  574. package/lib/simple-tree/node-kinds/array/arrayNode.js +21 -7
  575. package/lib/simple-tree/node-kinds/array/arrayNode.js.map +1 -1
  576. package/lib/simple-tree/node-kinds/index.d.ts +1 -1
  577. package/lib/simple-tree/node-kinds/index.d.ts.map +1 -1
  578. package/lib/simple-tree/node-kinds/index.js +1 -1
  579. package/lib/simple-tree/node-kinds/index.js.map +1 -1
  580. package/lib/simple-tree/node-kinds/map/mapNode.d.ts.map +1 -1
  581. package/lib/simple-tree/node-kinds/map/mapNode.js +12 -5
  582. package/lib/simple-tree/node-kinds/map/mapNode.js.map +1 -1
  583. package/lib/simple-tree/node-kinds/object/index.d.ts +1 -1
  584. package/lib/simple-tree/node-kinds/object/index.d.ts.map +1 -1
  585. package/lib/simple-tree/node-kinds/object/index.js +1 -1
  586. package/lib/simple-tree/node-kinds/object/index.js.map +1 -1
  587. package/lib/simple-tree/node-kinds/object/objectNode.d.ts +3 -8
  588. package/lib/simple-tree/node-kinds/object/objectNode.d.ts.map +1 -1
  589. package/lib/simple-tree/node-kinds/object/objectNode.js +19 -21
  590. package/lib/simple-tree/node-kinds/object/objectNode.js.map +1 -1
  591. package/lib/simple-tree/node-kinds/record/recordNode.d.ts.map +1 -1
  592. package/lib/simple-tree/node-kinds/record/recordNode.js +12 -5
  593. package/lib/simple-tree/node-kinds/record/recordNode.js.map +1 -1
  594. package/lib/simple-tree/prepareForInsertion.d.ts +6 -6
  595. package/lib/simple-tree/prepareForInsertion.d.ts.map +1 -1
  596. package/lib/simple-tree/prepareForInsertion.js +21 -15
  597. package/lib/simple-tree/prepareForInsertion.js.map +1 -1
  598. package/lib/simple-tree/simpleSchema.d.ts +6 -21
  599. package/lib/simple-tree/simpleSchema.d.ts.map +1 -1
  600. package/lib/simple-tree/simpleSchema.js.map +1 -1
  601. package/lib/simple-tree/toStoredSchema.d.ts +38 -11
  602. package/lib/simple-tree/toStoredSchema.d.ts.map +1 -1
  603. package/lib/simple-tree/toStoredSchema.js +70 -34
  604. package/lib/simple-tree/toStoredSchema.js.map +1 -1
  605. package/lib/simple-tree/unhydratedFlexTreeFromInsertable.d.ts +2 -2
  606. package/lib/simple-tree/unhydratedFlexTreeFromInsertable.d.ts.map +1 -1
  607. package/lib/simple-tree/unhydratedFlexTreeFromInsertable.js +1 -1
  608. package/lib/simple-tree/unhydratedFlexTreeFromInsertable.js.map +1 -1
  609. package/lib/simple-tree/walkFieldSchema.d.ts +1 -0
  610. package/lib/simple-tree/walkFieldSchema.d.ts.map +1 -1
  611. package/lib/simple-tree/walkFieldSchema.js +1 -0
  612. package/lib/simple-tree/walkFieldSchema.js.map +1 -1
  613. package/package.json +23 -23
  614. package/src/codec/codec.ts +4 -3
  615. package/src/core/index.ts +2 -0
  616. package/src/core/rebase/index.ts +2 -0
  617. package/src/core/rebase/types.ts +4 -0
  618. package/src/core/schema-stored/schema.ts +2 -26
  619. package/src/core/tree/detachedFieldIndex.ts +4 -6
  620. package/src/core/tree/detachedFieldIndexCodecCommon.ts +87 -0
  621. package/src/core/tree/{detachedFieldIndexCodec.ts → detachedFieldIndexCodecV1.ts} +22 -68
  622. package/src/core/tree/detachedFieldIndexCodecV2.ts +72 -0
  623. package/src/core/tree/detachedFieldIndexCodecs.ts +44 -0
  624. package/src/core/tree/{detachedFieldIndexFormat.ts → detachedFieldIndexFormatCommon.ts} +32 -23
  625. package/src/core/tree/detachedFieldIndexFormatV1.ts +15 -0
  626. package/src/core/tree/detachedFieldIndexFormatV2.ts +17 -0
  627. package/src/feature-libraries/chunked-forest/codec/README.md +1 -1
  628. package/src/feature-libraries/chunked-forest/codec/chunkDecoding.ts +25 -25
  629. package/src/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.ts +10 -6
  630. package/src/feature-libraries/chunked-forest/codec/compressedEncode.ts +96 -73
  631. package/src/feature-libraries/chunked-forest/codec/format.ts +20 -14
  632. package/src/feature-libraries/chunked-forest/codec/{nodeShape.ts → nodeEncoder.ts} +23 -17
  633. package/src/feature-libraries/chunked-forest/codec/schemaBasedEncode.ts +34 -34
  634. package/src/feature-libraries/chunked-forest/codec/uncompressedEncode.ts +5 -5
  635. package/src/feature-libraries/default-schema/defaultFieldKinds.ts +11 -0
  636. package/src/feature-libraries/default-schema/defaultSchema.ts +0 -2
  637. package/src/feature-libraries/default-schema/index.ts +1 -1
  638. package/src/feature-libraries/default-schema/schemaChecker.ts +47 -30
  639. package/src/feature-libraries/index.ts +1 -3
  640. package/src/feature-libraries/modular-schema/comparison.ts +14 -29
  641. package/src/feature-libraries/modular-schema/fieldChangeHandler.ts +9 -0
  642. package/src/feature-libraries/modular-schema/genericFieldKind.ts +1 -0
  643. package/src/feature-libraries/modular-schema/modularChangeFamily.ts +61 -19
  644. package/src/feature-libraries/object-forest/objectForest.ts +10 -6
  645. package/src/feature-libraries/optional-field/optionalField.ts +4 -0
  646. package/src/feature-libraries/sequence-field/sequenceFieldChangeRebaser.ts +4 -0
  647. package/src/index.ts +7 -1
  648. package/src/jsonDomainSchema.ts +4 -0
  649. package/src/packageVersion.ts +1 -1
  650. package/src/shared-tree/independentView.ts +45 -19
  651. package/src/shared-tree/schematizeTree.ts +2 -2
  652. package/src/shared-tree/schematizingTreeView.ts +24 -15
  653. package/src/shared-tree/sharedTree.ts +2 -42
  654. package/src/shared-tree/treeAlpha.ts +48 -22
  655. package/src/shared-tree/treeCheckout.ts +54 -10
  656. package/src/shared-tree-core/branch.ts +1 -6
  657. package/src/simple-tree/api/conciseTree.ts +9 -7
  658. package/src/simple-tree/api/configuration.ts +18 -4
  659. package/src/simple-tree/api/create.ts +44 -36
  660. package/src/simple-tree/api/customTree.ts +59 -20
  661. package/src/simple-tree/api/discrepancies.ts +474 -0
  662. package/src/simple-tree/api/index.ts +2 -3
  663. package/src/simple-tree/api/schemaCompatibilityTester.ts +23 -151
  664. package/src/simple-tree/api/schemaFactory.ts +13 -254
  665. package/src/simple-tree/api/schemaFactoryAlpha.ts +174 -1
  666. package/src/simple-tree/api/schemaFactoryRecursive.ts +1 -25
  667. package/src/simple-tree/api/schemaStatics.ts +291 -0
  668. package/src/simple-tree/api/storedSchema.ts +18 -14
  669. package/src/simple-tree/api/treeBeta.ts +24 -4
  670. package/src/simple-tree/api/verboseTree.ts +17 -8
  671. package/src/simple-tree/core/allowedTypes.ts +87 -34
  672. package/src/simple-tree/core/context.ts +24 -22
  673. package/src/simple-tree/core/index.ts +11 -2
  674. package/src/simple-tree/core/simpleNodeSchemaBase.ts +30 -0
  675. package/src/simple-tree/core/toStored.ts +58 -0
  676. package/src/simple-tree/core/treeNodeKernel.ts +1 -1
  677. package/src/simple-tree/core/treeNodeSchema.ts +8 -2
  678. package/src/simple-tree/core/treeNodeValid.ts +23 -4
  679. package/src/simple-tree/core/walkSchema.ts +26 -6
  680. package/src/simple-tree/createContext.ts +11 -3
  681. package/src/simple-tree/fieldSchema.ts +3 -1
  682. package/src/simple-tree/index.ts +19 -13
  683. package/src/simple-tree/leafNodeSchema.ts +2 -1
  684. package/src/simple-tree/node-kinds/array/arrayNode.ts +64 -23
  685. package/src/simple-tree/node-kinds/index.ts +0 -1
  686. package/src/simple-tree/node-kinds/map/mapNode.ts +23 -2
  687. package/src/simple-tree/node-kinds/object/index.ts +0 -1
  688. package/src/simple-tree/node-kinds/object/objectNode.ts +42 -30
  689. package/src/simple-tree/node-kinds/record/recordNode.ts +20 -2
  690. package/src/simple-tree/prepareForInsertion.ts +28 -15
  691. package/src/simple-tree/simpleSchema.ts +6 -26
  692. package/src/simple-tree/toStoredSchema.ts +110 -44
  693. package/src/simple-tree/unhydratedFlexTreeFromInsertable.ts +6 -2
  694. package/src/simple-tree/walkFieldSchema.ts +1 -0
  695. package/dist/core/tree/detachedFieldIndexCodec.d.ts +0 -11
  696. package/dist/core/tree/detachedFieldIndexCodec.d.ts.map +0 -1
  697. package/dist/core/tree/detachedFieldIndexCodec.js +0 -100
  698. package/dist/core/tree/detachedFieldIndexCodec.js.map +0 -1
  699. package/dist/core/tree/detachedFieldIndexFormat.d.ts +0 -33
  700. package/dist/core/tree/detachedFieldIndexFormat.d.ts.map +0 -1
  701. package/dist/core/tree/detachedFieldIndexFormat.js.map +0 -1
  702. package/dist/feature-libraries/chunked-forest/codec/nodeShape.d.ts.map +0 -1
  703. package/dist/feature-libraries/chunked-forest/codec/nodeShape.js.map +0 -1
  704. package/dist/feature-libraries/initializeForest.d.ts +0 -18
  705. package/dist/feature-libraries/initializeForest.d.ts.map +0 -1
  706. package/dist/feature-libraries/initializeForest.js +0 -35
  707. package/dist/feature-libraries/initializeForest.js.map +0 -1
  708. package/dist/simple-tree/discrepancies.d.ts +0 -167
  709. package/dist/simple-tree/discrepancies.d.ts.map +0 -1
  710. package/dist/simple-tree/discrepancies.js +0 -382
  711. package/dist/simple-tree/discrepancies.js.map +0 -1
  712. package/lib/core/tree/detachedFieldIndexCodec.d.ts +0 -11
  713. package/lib/core/tree/detachedFieldIndexCodec.d.ts.map +0 -1
  714. package/lib/core/tree/detachedFieldIndexCodec.js +0 -96
  715. package/lib/core/tree/detachedFieldIndexCodec.js.map +0 -1
  716. package/lib/core/tree/detachedFieldIndexFormat.d.ts +0 -33
  717. package/lib/core/tree/detachedFieldIndexFormat.d.ts.map +0 -1
  718. package/lib/core/tree/detachedFieldIndexFormat.js.map +0 -1
  719. package/lib/feature-libraries/chunked-forest/codec/nodeShape.d.ts.map +0 -1
  720. package/lib/feature-libraries/chunked-forest/codec/nodeShape.js.map +0 -1
  721. package/lib/feature-libraries/initializeForest.d.ts +0 -18
  722. package/lib/feature-libraries/initializeForest.d.ts.map +0 -1
  723. package/lib/feature-libraries/initializeForest.js +0 -31
  724. package/lib/feature-libraries/initializeForest.js.map +0 -1
  725. package/lib/simple-tree/discrepancies.d.ts +0 -167
  726. package/lib/simple-tree/discrepancies.d.ts.map +0 -1
  727. package/lib/simple-tree/discrepancies.js +0 -376
  728. package/lib/simple-tree/discrepancies.js.map +0 -1
  729. package/src/feature-libraries/initializeForest.ts +0 -55
  730. package/src/simple-tree/discrepancies.ts +0 -648
@@ -1 +1 @@
1
- {"version":3,"file":"allowedTypes.js","sourceRoot":"","sources":["../../../src/simple-tree/core/allowedTypes.ts"],"names":[],"mappings":"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","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\n\nimport { getOrCreate, isReadonlyArray, type IsUnion } from \"../../util/index.js\";\nimport { isLazy, type FlexListToUnion, type LazyItem } from \"./flexList.js\";\nimport {\n\tNodeKind,\n\ttype InsertableTypedNode,\n\ttype NodeFromSchema,\n\ttype TreeNodeSchema,\n} from \"./treeNodeSchema.js\";\nimport { schemaAsTreeNodeValid } from \"./treeNodeValid.js\";\n\n/**\n * Schema for types allowed in some location in a tree (like a field, map entry or array).\n * @remarks\n * Type constraint used in schema declaration APIs.\n *\n * The order of types in the array is not significant.\n * Additionally, it is legal for users of this type to have the runtime and compile time order of items within this array not match.\n * Therefor to ensure type safety, these arrays should not be indexed, and instead just be iterated.\n *\n * Ideally this restriction would be modeled in the type itself, but it is not ergonomic to do so as there is no easy (when compared to arrays)\n * way to declare and manipulate unordered sets of types in TypeScript.\n *\n * Duplicate entries in this array are not allowed and will produce runtime errors.\n * Duplicate types are allowed,\n * but this must only be reflected in the type and not the runtime values.\n * This duplication can be used to encode the typing when the number of items in the array is not known at compile time\n * but some of the items are known to be present unconditionally.\n * For example, typing `[typeof A] | [typeof A, typeof B]` as `[typeof A, typeof B | typeof A]` is allowed,\n * and can produce more useful {@link Input} types.\n * @privateRemarks\n * Code reading data from this should use `normalizeAllowedTypes` to ensure consistent handling, caching, nice errors etc.\n * @system @public\n */\nexport type AllowedTypes = readonly LazyItem<TreeNodeSchema>[];\n\n/**\n * Stores annotations for an individual allowed type.\n * @alpha\n */\nexport interface AnnotatedAllowedType<T = LazyItem<TreeNodeSchema>> {\n\t/**\n\t * Annotations for the allowed type.\n\t */\n\treadonly metadata: AllowedTypeMetadata;\n\t/**\n\t * The allowed type the annotations apply to in a particular schema.\n\t */\n\treadonly type: T;\n}\n\n/**\n * Stores annotations for a set of evaluated annotated allowed types.\n * @alpha\n */\nexport interface NormalizedAnnotatedAllowedTypes {\n\t/**\n\t * Annotations that apply to a set of allowed types.\n\t */\n\treadonly metadata: AllowedTypesMetadata;\n\t/**\n\t * All the evaluated allowed types that the annotations apply to. The types themselves are also individually annotated.\n\t */\n\treadonly types: readonly AnnotatedAllowedType<TreeNodeSchema>[];\n}\n\n/**\n * Checks if the input is an {@link AnnotatedAllowedTypes}.\n */\nexport function isAnnotatedAllowedTypes(\n\tallowedTypes: ImplicitAnnotatedAllowedTypes,\n): allowedTypes is AnnotatedAllowedTypes {\n\treturn (\n\t\t// Class based schema, and lazy schema references report type \"function\": filtering them out with typeof makes narrowing based on members mostly safe\n\t\ttypeof allowedTypes === \"object\" && \"metadata\" in allowedTypes && \"types\" in allowedTypes\n\t);\n}\n\n/**\n * Stores annotations for a set of allowed types.\n * @alpha\n */\nexport interface AnnotatedAllowedTypes {\n\t/**\n\t * Annotations that apply to a set of allowed types.\n\t */\n\treadonly metadata: AllowedTypesMetadata;\n\t/**\n\t * All the allowed types that the annotations apply to. The types themselves may also have individual annotations.\n\t */\n\treadonly types: readonly (AnnotatedAllowedType | LazyItem<TreeNodeSchema>)[];\n}\n\n/**\n * Annotations that apply to a set of allowed types.\n * @remarks\n * Additional optionals may be added to this as non-breaking changes, so implementations of it should be simple object literals with no unlisted members.\n * @alpha\n */\nexport interface AllowedTypesMetadata {\n\t/**\n\t * User defined metadata\n\t */\n\treadonly custom?: unknown;\n}\n\n/**\n * Checks if the given allowed type is annotated with {@link AllowedTypeMetadata}.\n */\nexport function isAnnotatedAllowedType(\n\tallowedType: AnnotatedAllowedType | LazyItem<TreeNodeSchema>,\n): allowedType is AnnotatedAllowedType {\n\treturn \"metadata\" in allowedType && \"type\" in allowedType;\n}\n\n/**\n * Annotations that apply to an individual allowed type.\n * @remarks\n * Additional optionals may be added to this as non-breaking changes, so implementations of it should be simple object literals with no unlisted members.\n * @alpha\n */\nexport interface AllowedTypeMetadata {\n\t/**\n\t * User defined metadata\n\t */\n\treadonly custom?: unknown;\n\n\t// TODO metadata for enablable types will be added here\n}\n\n/**\n * Types of {@link TreeNode|TreeNodes} or {@link TreeLeafValue|TreeLeafValues} allowed at a location in a tree.\n * @remarks\n * Used by {@link TreeViewConfiguration} for the root and various kinds of {@link TreeNodeSchema} to specify their allowed child types.\n *\n * Use {@link SchemaFactory} to access leaf schema or declare new composite schema.\n *\n * Implicitly treats a single type as an array of one type.\n *\n * Arrays of schema can be used to specify multiple types are allowed, which result in unions of those types in the Tree APIs.\n *\n * When saved into variables, avoid type-erasing the details, as doing so loses the compile time schema awareness of APIs derived from the types.\n *\n * When referring to types that are declared after the definition of the `ImplicitAllowedTypes`, the schema can be wrapped in a lambda to allow the forward reference.\n * See {@link ValidateRecursiveSchema} for details on how to structure the `ImplicitAllowedTypes` instances when constructing recursive schema.\n *\n * @example Explicit use with strong typing\n * ```typescript\n * const sf = new SchemaFactory(\"myScope\");\n * const childTypes = [sf.number, sf.string] as const satisfies ImplicitAllowedTypes;\n * const config = new TreeViewConfiguration({ schema: childTypes });\n * ```\n *\n * @example Forward reference\n * ```typescript\n * const sf = new SchemaFactory(\"myScope\");\n * class A extends sf.array(\"example\", [() => B]) {}\n * class B extends sf.array(\"Inner\", sf.number) {}\n * ```\n * @privateRemarks\n * Code reading data from this should use `normalizeAllowedTypes` to ensure consistent handling, caching, nice errors etc.\n * @public\n */\nexport type ImplicitAllowedTypes = AllowedTypes | TreeNodeSchema;\n\n/**\n * Types of {@link TreeNode|TreeNodes} or {@link TreeLeafValue|TreeLeafValues} allowed at a location in a tree with\n * additional metadata associated with the location they're allowed at.\n * @alpha\n */\nexport type ImplicitAnnotatedAllowedTypes =\n\t| TreeNodeSchema\n\t| AnnotatedAllowedType\n\t| AnnotatedAllowedTypes\n\t| readonly (AnnotatedAllowedType | LazyItem<TreeNodeSchema>)[];\n\n/**\n * Returns an {@link ImplicitAllowedTypes} that is equivalent to the input without annotations.\n * @system @alpha\n */\nexport type UnannotateImplicitAllowedTypes<T extends ImplicitAnnotatedAllowedTypes> =\n\tT extends AnnotatedAllowedTypes\n\t\t? UnannotateAllowedTypes<T>\n\t\t: T extends AnnotatedAllowedType\n\t\t\t? UnannotateAllowedType<T>\n\t\t\t: T extends readonly (AnnotatedAllowedType | LazyItem<TreeNodeSchema>)[]\n\t\t\t\t? UnannotateAllowedTypesList<T>\n\t\t\t\t: T extends TreeNodeSchema\n\t\t\t\t\t? T\n\t\t\t\t\t: never;\n\n/**\n * Removes annotations from a list of allowed types that may contain annotations.\n * @system @alpha\n */\nexport type UnannotateAllowedTypesList<\n\tT extends readonly (AnnotatedAllowedType | LazyItem<TreeNodeSchema>)[],\n> = {\n\t[I in keyof T]: UnannotateAllowedTypeOrLazyItem<T[I]>;\n};\n\n/**\n * Removes annotations from an allowed type that may contain annotations.\n * @system @alpha\n */\nexport type UnannotateAllowedTypeOrLazyItem<\n\tT extends AnnotatedAllowedType | LazyItem<TreeNodeSchema>,\n> = T extends AnnotatedAllowedType<infer X> ? X : T;\n\n/**\n * Removes all annotations from a set of allowed types.\n * @system @alpha\n */\nexport type UnannotateAllowedTypes<T extends AnnotatedAllowedTypes> =\n\tUnannotateAllowedTypesList<T[\"types\"]>;\n\n/**\n * Removes annotations from an allowed type.\n * @system @alpha\n */\nexport type UnannotateAllowedType<T extends AnnotatedAllowedType> =\n\tT extends AnnotatedAllowedType<infer X> ? [X] : T;\n\n/**\n * Normalizes a {@link ImplicitAllowedTypes} to a set of {@link TreeNodeSchema}s, by eagerly evaluating any\n * lazy schema declarations.\n *\n * @remarks Note: this must only be called after all required schemas have been declared, otherwise evaluation of\n * recursive schemas may fail.\n *\n * @internal\n */\nexport function normalizeAllowedTypes(\n\ttypes: ImplicitAllowedTypes,\n): ReadonlySet<TreeNodeSchema> {\n\tconst normalized = new Set<TreeNodeSchema>();\n\tif (isReadonlyArray(types)) {\n\t\t// 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.\n\t\tObject.freeze(types);\n\t\tfor (const lazyType of types) {\n\t\t\tnormalized.add(evaluateLazySchema(lazyType));\n\t\t}\n\t} else {\n\t\tnormalized.add(evaluateLazySchema(types));\n\t}\n\treturn normalized;\n}\n\n/**\n * Normalizes an allowed type to an {@link AnnotatedAllowedType}, by adding empty annotations if they don't already exist.\n */\nexport function normalizeToAnnotatedAllowedType<T extends TreeNodeSchema>(\n\ttype: T | AnnotatedAllowedType<T> | AnnotatedAllowedType<LazyItem<T>>,\n): AnnotatedAllowedType<T> | AnnotatedAllowedType<LazyItem<T>> {\n\treturn isAnnotatedAllowedType(type)\n\t\t? type\n\t\t: {\n\t\t\t\tmetadata: {},\n\t\t\t\ttype,\n\t\t\t};\n}\n\n/**\n * Normalizes a {@link ImplicitAnnotatedAllowedTypes} to a set of {@link AnnotatedAllowedSchema}s, by eagerly evaluating any\n * lazy schema declarations and adding empty metadata if it doesn't already exist.\n *\n * @remarks Note: this must only be called after all required schemas have been declared, otherwise evaluation of\n * recursive schemas may fail.\n */\nexport function normalizeAnnotatedAllowedTypes(\n\ttypes: ImplicitAnnotatedAllowedTypes,\n): NormalizedAnnotatedAllowedTypes {\n\tconst typesWithoutAnnotation = isAnnotatedAllowedTypes(types) ? types.types : types;\n\tconst annotatedTypes: AnnotatedAllowedType<TreeNodeSchema>[] = [];\n\tif (isReadonlyArray(typesWithoutAnnotation)) {\n\t\tfor (const annotatedType of typesWithoutAnnotation) {\n\t\t\tif (isAnnotatedAllowedType(annotatedType)) {\n\t\t\t\tannotatedTypes.push({\n\t\t\t\t\ttype: evaluateLazySchema(annotatedType.type),\n\t\t\t\t\tmetadata: annotatedType.metadata,\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\tannotatedTypes.push({ type: evaluateLazySchema(annotatedType), metadata: {} });\n\t\t\t}\n\t\t}\n\t} else {\n\t\tif (isAnnotatedAllowedType(typesWithoutAnnotation)) {\n\t\t\tannotatedTypes.push({\n\t\t\t\ttype: evaluateLazySchema(typesWithoutAnnotation.type),\n\t\t\t\tmetadata: typesWithoutAnnotation.metadata,\n\t\t\t});\n\t\t} else {\n\t\t\tannotatedTypes.push({ type: evaluateLazySchema(typesWithoutAnnotation), metadata: {} });\n\t\t}\n\t}\n\n\treturn {\n\t\tmetadata: isAnnotatedAllowedTypes(types) ? types.metadata : {},\n\t\ttypes: annotatedTypes,\n\t};\n}\n\n/**\n * Converts an {@link ImplicitAnnotatedAllowedTypes} to an {@link ImplicitAllowedTypes}s, by removing\n * any annotations.\n * @remarks\n * This does not evaluate any lazy schemas.\n */\nexport function unannotateImplicitAllowedTypes<Types extends ImplicitAnnotatedAllowedTypes>(\n\ttypes: Types,\n): UnannotateImplicitAllowedTypes<Types> {\n\treturn (\n\t\tisAnnotatedAllowedTypes(types)\n\t\t\t? types.types.map((allowedType) =>\n\t\t\t\t\tisAnnotatedAllowedType(allowedType) ? allowedType.type : allowedType,\n\t\t\t\t)\n\t\t\t: isReadonlyArray(types)\n\t\t\t\t? types.map((allowedType) =>\n\t\t\t\t\t\tisAnnotatedAllowedType(allowedType) ? allowedType.type : allowedType,\n\t\t\t\t\t)\n\t\t\t\t: isAnnotatedAllowedType(types)\n\t\t\t\t\t? (types.type as UnannotateImplicitAllowedTypes<Types>)\n\t\t\t\t\t: types\n\t) as UnannotateImplicitAllowedTypes<Types>;\n}\n\nconst cachedLazyItem = new WeakMap<() => unknown, unknown>();\n\n/**\n * Returns the schema referenced by the {@link LazyItem}.\n * @remarks\n * Caches results to handle {@link LazyItem}s which compute their resulting schema.\n * @alpha\n */\nexport function evaluateLazySchema<T extends TreeNodeSchema>(value: LazyItem<T>): T {\n\tconst evaluatedSchema = isLazy(value)\n\t\t? (getOrCreate(cachedLazyItem, value, value) as T)\n\t\t: value;\n\tif (evaluatedSchema === undefined) {\n\t\tthrow new UsageError(\n\t\t\t`Encountered an undefined schema. This could indicate that some referenced schema has not yet been instantiated.`,\n\t\t);\n\t}\n\tmarkSchemaMostDerived(evaluatedSchema);\n\treturn evaluatedSchema;\n}\n\n/**\n * Indicates that the provided schema is the \"most derived\" version in its class hierarchy.\n *\n * @param oneTimeInitialize - If true this runs {@link TreeNodeValid.oneTimeInitialize} which does even more initialization and validation.\n * `oneTimeInitialize` can't safely be run until all transitively referenced schema are defined, so which cases can safely use it are more limited.\n * When legal for the caller to set this to true, it is preferred, but it is often not safe due to possible forward references.\n * @remarks\n * See {@link MostDerivedData} and {@link SchemaFactory} for details on what a \"most derived\" schema is and why it matters.\n *\n * This is a helper for invoking {@link TreeNodeValid.markMostDerived} for {@link TreeNodeSchema}.\n *\n * Calling this helps with error messages about invalid schema usage (See {@link SchemaFactory} for the rules, some of which this helps validate).\n * Typically this should be called for each schema as early as practical to improve error reporting for invalid usages of schema\n * (using two different schema derived from the same {@link SchemaFactory} produced base class).\n *\n * Note that construction of actual {@link TreeNode} instances or use of a schema transitively in a {@link TreeViewConfiguration} already do this,\n * so any calls to this that is unconditionally after that point for the given schema is not needed.\n * Instead most usages of this should be from those cases, and from miscellaneous cases where a schema is passed into an public API where theoretically someone could accidentally\n * pass in a base class of a schema instead of the most derived one.\n */\nexport function markSchemaMostDerived(\n\tschema: TreeNodeSchema,\n\toneTimeInitialize = false,\n): void {\n\t// Leaf schema are not classes, and thus do not need to be marked as most derived.\n\tif (schema.kind === NodeKind.Leaf) {\n\t\treturn;\n\t}\n\n\tconst schemaValid = schemaAsTreeNodeValid(schema);\n\n\tif (oneTimeInitialize) {\n\t\tschemaValid.oneTimeInitialize();\n\t} else {\n\t\tschemaValid.markMostDerived();\n\t}\n}\n\n/**\n * Type of tree node for a field of the given schema.\n * @public\n */\nexport type TreeNodeFromImplicitAllowedTypes<\n\tTSchema extends ImplicitAllowedTypes = TreeNodeSchema,\n> = TSchema extends TreeNodeSchema\n\t? NodeFromSchema<TSchema>\n\t: TSchema extends AllowedTypes\n\t\t? NodeFromSchema<FlexListToUnion<TSchema>>\n\t\t: unknown;\n\n/**\n * This type exists only to be linked from documentation to provide a single linkable place to document some details of\n * \"Input\" types and how they handle schema.\n *\n * When a schema is used to describe data which is an input into an API, the API is [contravariant](https://en.wikipedia.org/wiki/Covariance_and_contravariance_(computer_science)) over the schema.\n * (See also, [TypeScript Variance Annotations](https://www.typescriptlang.org/docs/handbook/2/generics.html#variance-annotations)).\n *\n * Since these schema are expressed using TypeScript types, it is possible for the user of the API to provide non-exact values of these types which has implications that depended on the variance.\n *\n * Consider a field with schema type of `A | B` (where A and B are types of schema).\n *\n * - Reading the field behaves covariantly so {@link NodeFromSchema} of `<A | B>` is the same as `NodeFromSchema<A> | NodeFromSchema<B>`, indicating that either type of node can be read from the field.\n *\n * - Writing to the field behaves contravariantly. Since it is unknown if the node actually has a schema `A` or a schema `B`, the only legal values (known to be in schema regardless of which schema the underlying node has) are values which are legal for both `A & B`.\n *\n * Note that this is distinct from the case where the schema is `[A, B]`.\n * In this case it is known that the field allows both A and B (the field can be set to an A or a B value).\n * When `A | B` is used, the field might allow\n * A but not B (so assigning a B value would be out of schema),\n * B but not A (so assigning an A value would be out of schema)\n * or both A and B.\n *\n * This gets more extreme when given completely unspecified schema.\n * For example if a field is just provided {@link ImplicitFieldSchema}, nothing is known about the content of the field.\n * This means that reading the field (via {@link TreeFieldFromImplicitField}) can give any valid tree field content,\n * but there are no safe values which could be written to the field (since it is unknown what values would be out of schema) so {@link InsertableTreeFieldFromImplicitField} gives `never`.\n *\n * To implement this variance correctly, the computation of types for input and output have to use separate utilities\n * which take very different approaches when encountering non-exact schema like unions or `ImplicitFieldSchema`.\n * The utilities which behave contravariantly (as required to handle input correctly) link this documentation to indicate that this is how they behave.\n *\n * In addition to behaving contravariantly, these input type computation utilities often have further limitations.\n * This is due to TypeScript making it difficult to implement this contravariance exactly.\n * When faced with these implementation limitations these contravariant type computation utilities error on the side of producing overly strict requirements.\n * For example in the above case of `A | B`, the utilities might compute an allowed insertable type as `never` even if there happens to be a common value accepted by both `A` and `B`.\n * Future versions of the API can relax these requirements as the type computations are made more accurate.\n *\n * For a more concrete example: if {@link InsertableTreeFieldFromImplicitField} produced `never` for a schema `A | OptionalField<A>`,\n * a future version could instead return a more flexible but still safe type, like `A`.\n *\n * More generally: try to avoid providing non-exact schema, especially for the fields of other schema.\n * While these APIs attempt to handle such cases correctly, there are limitations and known bugs in this handling.\n * Code using non-exact schema is much more likely to have its compilation break due to updates of this package or even TypeScript,\n * and thus compilation breaks due to edge cases of non-exact schema handling, especially with recursive schema, are not considered breaking changes.\n * This may change as the API become more stable.\n *\n * @privateRemarks\n * There likely is a better way to share this documentation, but none was found at the time of writing.\n *\n * TODO: Once {@link InsertableField} is public, consider using it in the examples above.\n * @system @public\n */\nexport type Input<T extends never> = T;\n\n/**\n * Type of content that can be inserted into the tree for a node of the given schema.\n *\n * @see {@link Input}\n *\n * @typeparam TSchema - Schema to process.\n *\n * @privateRemarks\n * This is a bit overly conservative, since cases like `A | [A]` give never and could give `A`.\n * @public\n */\nexport type InsertableTreeNodeFromImplicitAllowedTypes<TSchema extends ImplicitAllowedTypes> =\n\t[TSchema] extends [TreeNodeSchema]\n\t\t? InsertableTypedNode<TSchema>\n\t\t: [TSchema] extends [AllowedTypes]\n\t\t\t? InsertableTreeNodeFromAllowedTypes<TSchema>\n\t\t\t: never;\n\n/**\n * Type of content that can be inserted into the tree for a node of the given schema.\n *\n * @see {@link Input}\n *\n * @typeparam TList - AllowedTypes to process\n *\n * @privateRemarks\n * This loop is manually unrolled to allow larger unions before hitting the recursion limit in TypeScript.\n * @system @public\n */\nexport type InsertableTreeNodeFromAllowedTypes<TList extends AllowedTypes> =\n\tIsUnion<TList> extends true\n\t\t? never\n\t\t: {\n\t\t\t\treadonly [Property in keyof TList]: TList[Property] extends LazyItem<\n\t\t\t\t\tinfer TSchema extends TreeNodeSchema\n\t\t\t\t>\n\t\t\t\t\t? InsertableTypedNode<TSchema>\n\t\t\t\t\t: never;\n\t\t\t}[number];\n"]}
1
+ {"version":3,"file":"allowedTypes.js","sourceRoot":"","sources":["../../../src/simple-tree/core/allowedTypes.ts"],"names":[],"mappings":"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","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\n\nimport {\n\tgetOrCreate,\n\tisReadonlyArray,\n\ttype IsUnion,\n\ttype MakeNominal,\n} from \"../../util/index.js\";\nimport { isLazy, type FlexListToUnion, type LazyItem } from \"./flexList.js\";\nimport {\n\tNodeKind,\n\ttype InsertableTypedNode,\n\ttype NodeFromSchema,\n\ttype TreeNodeSchema,\n} from \"./treeNodeSchema.js\";\nimport { schemaAsTreeNodeValid } from \"./treeNodeValid.js\";\n\n/**\n * Schema for types allowed in some location in a tree (like a field, map entry or array).\n * @remarks\n * Type constraint used in schema declaration APIs.\n *\n * The order of types in the array is not significant.\n * Additionally, it is legal for users of this type to have the runtime and compile time order of items within this array not match.\n * Therefor to ensure type safety, these arrays should not be indexed, and instead just be iterated.\n *\n * Ideally this restriction would be modeled in the type itself, but it is not ergonomic to do so as there is no easy (when compared to arrays)\n * way to declare and manipulate unordered sets of types in TypeScript.\n *\n * Duplicate entries in this array are not allowed and will produce runtime errors.\n * Duplicate types are allowed,\n * but this must only be reflected in the type and not the runtime values.\n * This duplication can be used to encode the typing when the number of items in the array is not known at compile time\n * but some of the items are known to be present unconditionally.\n * For example, typing `[typeof A] | [typeof A, typeof B]` as `[typeof A, typeof B | typeof A]` is allowed,\n * and can produce more useful {@link Input} types.\n * @privateRemarks\n * Code reading data from this should use `normalizeAllowedTypes` to ensure consistent handling, caching, nice errors etc.\n * @system @public\n */\nexport type AllowedTypes = readonly LazyItem<TreeNodeSchema>[];\n\n/**\n * Stores annotations for an individual allowed type.\n * @alpha\n */\nexport interface AnnotatedAllowedType<T = LazyItem<TreeNodeSchema>> {\n\t/**\n\t * Annotations for the allowed type.\n\t */\n\treadonly metadata: AllowedTypeMetadata;\n\t/**\n\t * The allowed type the annotations apply to in a particular schema.\n\t */\n\treadonly type: T;\n}\n\n/**\n * Stores annotations for a set of evaluated annotated allowed types.\n * @alpha\n */\nexport interface NormalizedAnnotatedAllowedTypes {\n\t/**\n\t * Annotations that apply to a set of allowed types.\n\t */\n\treadonly metadata: AllowedTypesMetadata;\n\t/**\n\t * All the evaluated allowed types that the annotations apply to. The types themselves are also individually annotated.\n\t */\n\treadonly types: readonly AnnotatedAllowedType<TreeNodeSchema>[];\n}\n\n/**\n * Checks if the input is an {@link AnnotatedAllowedTypes}.\n */\nexport function isAnnotatedAllowedTypes(\n\tallowedTypes: ImplicitAnnotatedAllowedTypes,\n): allowedTypes is AnnotatedAllowedTypes {\n\tcheckForUninitializedSchema(allowedTypes);\n\treturn (\n\t\t// Class based schema, and lazy schema references report type \"function\": filtering them out with typeof makes narrowing based on members mostly safe\n\t\ttypeof allowedTypes === \"object\" && \"metadata\" in allowedTypes && \"types\" in allowedTypes\n\t);\n}\n\n/**\n * Stores annotations for a set of allowed types.\n * @alpha\n */\nexport interface AnnotatedAllowedTypes {\n\t/**\n\t * Annotations that apply to a set of allowed types.\n\t */\n\treadonly metadata: AllowedTypesMetadata;\n\t/**\n\t * All the allowed types that the annotations apply to. The types themselves may also have individual annotations.\n\t */\n\treadonly types: readonly (AnnotatedAllowedType | LazyItem<TreeNodeSchema>)[];\n}\n\n/**\n * Annotations that apply to a set of allowed types.\n * @remarks\n * Additional optionals may be added to this as non-breaking changes, so implementations of it should be simple object literals with no unlisted members.\n * @alpha\n */\nexport interface AllowedTypesMetadata {\n\t/**\n\t * User defined metadata\n\t */\n\treadonly custom?: unknown;\n}\n\n/**\n * Checks if the given allowed type is annotated with {@link AllowedTypeMetadata}.\n */\nexport function isAnnotatedAllowedType(\n\tallowedType: AnnotatedAllowedType | LazyItem<TreeNodeSchema>,\n): allowedType is AnnotatedAllowedType {\n\tcheckForUninitializedSchema(allowedType);\n\t// Class based schema, and lazy schema references report type \"function\": filtering them out with typeof makes narrowing based on members mostly safe\n\treturn typeof allowedType === \"object\" && \"metadata\" in allowedType && \"type\" in allowedType;\n}\n\n/**\n * Annotations that apply to an individual allowed type.\n * @remarks\n * Additional optionals may be added to this as non-breaking changes, so implementations of it should be simple object literals with no unlisted members.\n * @alpha\n */\nexport interface AllowedTypeMetadata {\n\t/**\n\t * User defined metadata\n\t */\n\treadonly custom?: unknown;\n\n\t/**\n\t * If defined, indicates that an allowed type is {@link SchemaStaticsAlpha.staged | staged}.\n\t */\n\treadonly stagedSchemaUpgrade?: SchemaUpgrade;\n}\n\n/**\n * Package internal {@link SchemaUpgrade} construction API.\n */\nexport let createSchemaUpgrade: () => SchemaUpgrade;\n\n/**\n * Unique token used to upgrade schemas and determine if a particular upgrade has been completed.\n * @remarks\n * Create using {@link SchemaStaticsAlpha.staged}.\n * @privateRemarks\n * TODO:#38722 implement runtime schema upgrades.\n * Until then, the class purely behaves mostly as a placeholder.\n * TODO: Consider allowing users to store a name for the upgrade to use in error messages.\n * @sealed @alpha\n */\nexport class SchemaUpgrade {\n\tprotected _typeCheck!: MakeNominal;\n\tstatic {\n\t\tcreateSchemaUpgrade = () => new SchemaUpgrade();\n\t}\n\n\tprivate constructor() {}\n}\n\n/**\n * Types of {@link TreeNode|TreeNodes} or {@link TreeLeafValue|TreeLeafValues} allowed at a location in a tree.\n * @remarks\n * Used by {@link TreeViewConfiguration} for the root and various kinds of {@link TreeNodeSchema} to specify their allowed child types.\n *\n * Use {@link SchemaFactory} to access leaf schema or declare new composite schema.\n *\n * Implicitly treats a single type as an array of one type.\n *\n * Arrays of schema can be used to specify multiple types are allowed, which result in unions of those types in the Tree APIs.\n *\n * When saved into variables, avoid type-erasing the details, as doing so loses the compile time schema awareness of APIs derived from the types.\n *\n * When referring to types that are declared after the definition of the `ImplicitAllowedTypes`, the schema can be wrapped in a lambda to allow the forward reference.\n * See {@link ValidateRecursiveSchema} for details on how to structure the `ImplicitAllowedTypes` instances when constructing recursive schema.\n *\n * @example Explicit use with strong typing\n * ```typescript\n * const sf = new SchemaFactory(\"myScope\");\n * const childTypes = [sf.number, sf.string] as const satisfies ImplicitAllowedTypes;\n * const config = new TreeViewConfiguration({ schema: childTypes });\n * ```\n *\n * @example Forward reference\n * ```typescript\n * const sf = new SchemaFactory(\"myScope\");\n * class A extends sf.array(\"example\", [() => B]) {}\n * class B extends sf.array(\"Inner\", sf.number) {}\n * ```\n * @privateRemarks\n * Code reading data from this should use `normalizeAllowedTypes` to ensure consistent handling, caching, nice errors etc.\n * @public\n */\nexport type ImplicitAllowedTypes = AllowedTypes | TreeNodeSchema;\n\n/**\n * Types of {@link TreeNode|TreeNodes} or {@link TreeLeafValue|TreeLeafValues} allowed at a location in a tree with\n * additional metadata associated with the location they're allowed at.\n * @alpha\n */\nexport type ImplicitAnnotatedAllowedTypes =\n\t| TreeNodeSchema\n\t| AnnotatedAllowedType\n\t| AnnotatedAllowedTypes\n\t| readonly (AnnotatedAllowedType | LazyItem<TreeNodeSchema>)[];\n\n/**\n * Returns an {@link ImplicitAllowedTypes} that is equivalent to the input without annotations.\n * @system @alpha\n */\nexport type UnannotateImplicitAllowedTypes<T extends ImplicitAnnotatedAllowedTypes> =\n\tT extends AnnotatedAllowedTypes\n\t\t? UnannotateAllowedTypes<T>\n\t\t: T extends AnnotatedAllowedType\n\t\t\t? UnannotateAllowedTypesList<[T]>\n\t\t\t: T extends readonly (AnnotatedAllowedType | LazyItem<TreeNodeSchema>)[]\n\t\t\t\t? UnannotateAllowedTypesList<T>\n\t\t\t\t: T extends TreeNodeSchema\n\t\t\t\t\t? T\n\t\t\t\t\t: never;\n\n/**\n * Removes annotations from a list of allowed types that may contain annotations.\n * @system @alpha\n */\nexport type UnannotateAllowedTypesList<\n\tT extends readonly (AnnotatedAllowedType | LazyItem<TreeNodeSchema>)[],\n> = {\n\t[I in keyof T]: UnannotateAllowedType<T[I]>;\n};\n\n/**\n * Removes all annotations from a set of allowed types.\n * @system @alpha\n */\nexport type UnannotateAllowedTypes<T extends AnnotatedAllowedTypes> =\n\tUnannotateAllowedTypesList<T[\"types\"]>;\n\n/**\n * Removes annotations from an allowed type.\n * @remarks\n * If the input could be lazy\n * (is a LazyItem or AnnotatedAllowedType<LazyItem> instead of just a TreeNodeSchema | AnnotatedAllowedType<TreeNodeSchema>)\n * then the output of this will be a LazyItem and thus is not valid as an ImplicitAllowedTypes without wrapping it in an array.\n * This can however be used on items within an AllowedTypes array.\n * @system @alpha\n */\nexport type UnannotateAllowedType<T extends AnnotatedAllowedType | LazyItem<TreeNodeSchema>> =\n\tT extends AnnotatedAllowedType<infer X> ? X : T;\n\n/**\n * Normalizes a {@link ImplicitAllowedTypes} to a set of {@link TreeNodeSchema}s, by eagerly evaluating any\n * lazy schema declarations.\n *\n * @remarks Note: this must only be called after all required schemas have been declared, otherwise evaluation of\n * recursive schemas may fail.\n *\n * @internal\n */\nexport function normalizeAllowedTypes(\n\ttypes: ImplicitAnnotatedAllowedTypes,\n): ReadonlySet<TreeNodeSchema> {\n\t// remove annotations before normalizing\n\tconst unannotated = unannotateImplicitAllowedTypes(types);\n\tconst normalized = new Set<TreeNodeSchema>();\n\tif (isReadonlyArray(unannotated)) {\n\t\t// 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.\n\t\tObject.freeze(unannotated);\n\t\tfor (const lazyType of unannotated) {\n\t\t\tnormalized.add(evaluateLazySchema(lazyType));\n\t\t}\n\t} else {\n\t\tnormalized.add(evaluateLazySchema(unannotated));\n\t}\n\treturn normalized;\n}\n\n/**\n * Normalizes an allowed type to an {@link AnnotatedAllowedType}, by adding empty annotations if they don't already exist.\n */\nexport function normalizeToAnnotatedAllowedType<T extends LazyItem<TreeNodeSchema>>(\n\ttype: T | AnnotatedAllowedType<T>,\n): AnnotatedAllowedType<T> {\n\treturn isAnnotatedAllowedType(type)\n\t\t? type\n\t\t: {\n\t\t\t\tmetadata: {},\n\t\t\t\ttype,\n\t\t\t};\n}\n\n/**\n * Normalizes a {@link ImplicitAnnotatedAllowedTypes} to a set of {@link AnnotatedAllowedSchema}s, by eagerly evaluating any\n * lazy schema declarations and adding empty metadata if it doesn't already exist.\n *\n * @remarks Note: this must only be called after all required schemas have been declared, otherwise evaluation of\n * recursive schemas may fail.\n */\nexport function normalizeAnnotatedAllowedTypes(\n\ttypes: ImplicitAnnotatedAllowedTypes,\n): NormalizedAnnotatedAllowedTypes {\n\tconst typesWithoutAnnotation = isAnnotatedAllowedTypes(types) ? types.types : types;\n\tconst annotatedTypes: AnnotatedAllowedType<TreeNodeSchema>[] = [];\n\tif (isReadonlyArray(typesWithoutAnnotation)) {\n\t\tfor (const annotatedType of typesWithoutAnnotation) {\n\t\t\tif (isAnnotatedAllowedType(annotatedType)) {\n\t\t\t\tannotatedTypes.push({\n\t\t\t\t\ttype: evaluateLazySchema(annotatedType.type),\n\t\t\t\t\tmetadata: annotatedType.metadata,\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\tannotatedTypes.push({ type: evaluateLazySchema(annotatedType), metadata: {} });\n\t\t\t}\n\t\t}\n\t} else {\n\t\tif (isAnnotatedAllowedType(typesWithoutAnnotation)) {\n\t\t\tannotatedTypes.push({\n\t\t\t\ttype: evaluateLazySchema(typesWithoutAnnotation.type),\n\t\t\t\tmetadata: typesWithoutAnnotation.metadata,\n\t\t\t});\n\t\t} else {\n\t\t\tannotatedTypes.push({ type: evaluateLazySchema(typesWithoutAnnotation), metadata: {} });\n\t\t}\n\t}\n\n\treturn {\n\t\tmetadata: isAnnotatedAllowedTypes(types) ? types.metadata : {},\n\t\ttypes: annotatedTypes,\n\t};\n}\n\n/**\n * Converts an {@link ImplicitAnnotatedAllowedTypes} to an {@link ImplicitAllowedTypes}s, by removing\n * any annotations.\n * @remarks\n * This does not evaluate any lazy schemas.\n */\nexport function unannotateImplicitAllowedTypes<Types extends ImplicitAnnotatedAllowedTypes>(\n\ttypes: Types,\n): UnannotateImplicitAllowedTypes<Types> {\n\treturn (\n\t\tisAnnotatedAllowedTypes(types)\n\t\t\t? types.types.map(unannotateAllowedType)\n\t\t\t: isReadonlyArray(types)\n\t\t\t\t? types.map(unannotateAllowedType)\n\t\t\t\t: isAnnotatedAllowedType(types)\n\t\t\t\t\t? types.type\n\t\t\t\t\t: types\n\t) as UnannotateImplicitAllowedTypes<Types>;\n}\n\n/**\n * Converts an {@link AnnotatedAllowedType} to an {@link LazyItem} by removing any annotations.\n * @remarks\n * This does not evaluate any lazy schemas.\n */\nexport function unannotateAllowedType<\n\tType extends AnnotatedAllowedType | LazyItem<TreeNodeSchema>,\n>(allowedType: Type): UnannotateAllowedType<Type> {\n\treturn isAnnotatedAllowedType(allowedType)\n\t\t? (allowedType.type as UnannotateAllowedType<Type>)\n\t\t: (allowedType as UnannotateAllowedType<Type>);\n}\n\nconst cachedLazyItem = new WeakMap<() => unknown, unknown>();\n\n/**\n * Returns the schema referenced by the {@link LazyItem}.\n * @remarks\n * Caches results to handle {@link LazyItem}s which compute their resulting schema.\n * @alpha\n */\nexport function evaluateLazySchema<T extends TreeNodeSchema>(value: LazyItem<T>): T {\n\tconst evaluatedSchema = isLazy(value)\n\t\t? (getOrCreate(cachedLazyItem, value, value) as T)\n\t\t: value;\n\n\tcheckForUninitializedSchema(evaluatedSchema);\n\tmarkSchemaMostDerived(evaluatedSchema);\n\treturn evaluatedSchema;\n}\n\n/**\n * Throws a UsageError if the provided schema is undefined, most likely due to being used before it was initialized.\n */\nexport function checkForUninitializedSchema(\n\tschema: ImplicitAnnotatedAllowedTypes | LazyItem<TreeNodeSchema>,\n): void {\n\tif (schema === undefined) {\n\t\tthrow new UsageError(\n\t\t\t`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.`,\n\t\t);\n\t}\n}\n\n/**\n * Indicates that the provided schema is the \"most derived\" version in its class hierarchy.\n *\n * @param oneTimeInitialize - If true this runs {@link TreeNodeValid.oneTimeInitialize} which does even more initialization and validation.\n * `oneTimeInitialize` can't safely be run until all transitively referenced schema are defined, so which cases can safely use it are more limited.\n * When legal for the caller to set this to true, it is preferred, but it is often not safe due to possible forward references.\n * @remarks\n * See {@link MostDerivedData} and {@link SchemaFactory} for details on what a \"most derived\" schema is and why it matters.\n *\n * This is a helper for invoking {@link TreeNodeValid.markMostDerived} for {@link TreeNodeSchema}.\n *\n * Calling this helps with error messages about invalid schema usage (See {@link SchemaFactory} for the rules, some of which this helps validate).\n * Typically this should be called for each schema as early as practical to improve error reporting for invalid usages of schema\n * (using two different schema derived from the same {@link SchemaFactory} produced base class).\n *\n * Note that construction of actual {@link TreeNode} instances or use of a schema transitively in a {@link TreeViewConfiguration} already do this,\n * so any calls to this that is unconditionally after that point for the given schema is not needed.\n * Instead most usages of this should be from those cases, and from miscellaneous cases where a schema is passed into an public API where theoretically someone could accidentally\n * pass in a base class of a schema instead of the most derived one.\n */\nexport function markSchemaMostDerived(\n\tschema: TreeNodeSchema,\n\toneTimeInitialize = false,\n): void {\n\t// Leaf schema are not classes, and thus do not need to be marked as most derived.\n\tif (schema.kind === NodeKind.Leaf) {\n\t\treturn;\n\t}\n\n\tconst schemaValid = schemaAsTreeNodeValid(schema);\n\n\tif (oneTimeInitialize) {\n\t\tschemaValid.oneTimeInitialize();\n\t} else {\n\t\tschemaValid.markMostDerived();\n\t}\n}\n\n/**\n * Type of tree node for a field of the given schema.\n * @public\n */\nexport type TreeNodeFromImplicitAllowedTypes<\n\tTSchema extends ImplicitAllowedTypes = TreeNodeSchema,\n> = TSchema extends TreeNodeSchema\n\t? NodeFromSchema<TSchema>\n\t: TSchema extends AllowedTypes\n\t\t? NodeFromSchema<FlexListToUnion<TSchema>>\n\t\t: unknown;\n\n/**\n * This type exists only to be linked from documentation to provide a single linkable place to document some details of\n * \"Input\" types and how they handle schema.\n *\n * When a schema is used to describe data which is an input into an API, the API is [contravariant](https://en.wikipedia.org/wiki/Covariance_and_contravariance_(computer_science)) over the schema.\n * (See also, [TypeScript Variance Annotations](https://www.typescriptlang.org/docs/handbook/2/generics.html#variance-annotations)).\n *\n * Since these schema are expressed using TypeScript types, it is possible for the user of the API to provide non-exact values of these types which has implications that depended on the variance.\n *\n * Consider a field with schema type of `A | B` (where A and B are types of schema).\n *\n * - Reading the field behaves covariantly so {@link NodeFromSchema} of `<A | B>` is the same as `NodeFromSchema<A> | NodeFromSchema<B>`, indicating that either type of node can be read from the field.\n *\n * - Writing to the field behaves contravariantly. Since it is unknown if the node actually has a schema `A` or a schema `B`, the only legal values (known to be in schema regardless of which schema the underlying node has) are values which are legal for both `A & B`.\n *\n * Note that this is distinct from the case where the schema is `[A, B]`.\n * In this case it is known that the field allows both A and B (the field can be set to an A or a B value).\n * When `A | B` is used, the field might allow\n * A but not B (so assigning a B value would be out of schema),\n * B but not A (so assigning an A value would be out of schema)\n * or both A and B.\n *\n * This gets more extreme when given completely unspecified schema.\n * For example if a field is just provided {@link ImplicitFieldSchema}, nothing is known about the content of the field.\n * This means that reading the field (via {@link TreeFieldFromImplicitField}) can give any valid tree field content,\n * but there are no safe values which could be written to the field (since it is unknown what values would be out of schema) so {@link InsertableTreeFieldFromImplicitField} gives `never`.\n *\n * To implement this variance correctly, the computation of types for input and output have to use separate utilities\n * which take very different approaches when encountering non-exact schema like unions or `ImplicitFieldSchema`.\n * The utilities which behave contravariantly (as required to handle input correctly) link this documentation to indicate that this is how they behave.\n *\n * In addition to behaving contravariantly, these input type computation utilities often have further limitations.\n * This is due to TypeScript making it difficult to implement this contravariance exactly.\n * When faced with these implementation limitations these contravariant type computation utilities error on the side of producing overly strict requirements.\n * For example in the above case of `A | B`, the utilities might compute an allowed insertable type as `never` even if there happens to be a common value accepted by both `A` and `B`.\n * Future versions of the API can relax these requirements as the type computations are made more accurate.\n *\n * For a more concrete example: if {@link InsertableTreeFieldFromImplicitField} produced `never` for a schema `A | OptionalField<A>`,\n * a future version could instead return a more flexible but still safe type, like `A`.\n *\n * More generally: try to avoid providing non-exact schema, especially for the fields of other schema.\n * While these APIs attempt to handle such cases correctly, there are limitations and known bugs in this handling.\n * Code using non-exact schema is much more likely to have its compilation break due to updates of this package or even TypeScript,\n * and thus compilation breaks due to edge cases of non-exact schema handling, especially with recursive schema, are not considered breaking changes.\n * This may change as the API become more stable.\n *\n * @privateRemarks\n * There likely is a better way to share this documentation, but none was found at the time of writing.\n *\n * TODO: Once {@link InsertableField} is public, consider using it in the examples above.\n * @system @public\n */\nexport type Input<T extends never> = T;\n\n/**\n * Type of content that can be inserted into the tree for a node of the given schema.\n *\n * @see {@link Input}\n *\n * @typeparam TSchema - Schema to process.\n *\n * @privateRemarks\n * This is a bit overly conservative, since cases like `A | [A]` give never and could give `A`.\n * @public\n */\nexport type InsertableTreeNodeFromImplicitAllowedTypes<TSchema extends ImplicitAllowedTypes> =\n\t[TSchema] extends [TreeNodeSchema]\n\t\t? InsertableTypedNode<TSchema>\n\t\t: [TSchema] extends [AllowedTypes]\n\t\t\t? InsertableTreeNodeFromAllowedTypes<TSchema>\n\t\t\t: never;\n\n/**\n * Type of content that can be inserted into the tree for a node of the given schema.\n *\n * @see {@link Input}\n *\n * @typeparam TList - AllowedTypes to process\n *\n * @privateRemarks\n * This loop is manually unrolled to allow larger unions before hitting the recursion limit in TypeScript.\n * @system @public\n */\nexport type InsertableTreeNodeFromAllowedTypes<TList extends AllowedTypes> =\n\tIsUnion<TList> extends true\n\t\t? never\n\t\t: {\n\t\t\t\treadonly [Property in keyof TList]: TList[Property] extends LazyItem<\n\t\t\t\t\tinfer TSchema extends TreeNodeSchema\n\t\t\t\t>\n\t\t\t\t\t? InsertableTypedNode<TSchema>\n\t\t\t\t\t: never;\n\t\t\t}[number];\n"]}
@@ -31,12 +31,23 @@ export declare class Context {
31
31
  * This design mirrors how {@link FlexTreeSchema} are accessed off the {@link FlexTreeContext}, making the migration away from them simpler.
32
32
  */
33
33
  readonly schema: ReadonlyMap<TreeNodeSchemaIdentifier, TreeNodeSchema>;
34
+ static schemaMapFromRootSchema(rootSchema: NormalizedAnnotatedAllowedTypes): ReadonlyMap<TreeNodeSchemaIdentifier, TreeNodeSchema>;
34
35
  /**
35
36
  * Builds the context.
36
37
  * @remarks
37
38
  * Since this walks the schema, it must not be invoked during schema declaration or schema forward references could fail to be resolved.
38
39
  */
39
- constructor(rootSchema: NormalizedAnnotatedAllowedTypes, flexContext: FlexTreeContext);
40
+ constructor(flexContext: FlexTreeContext,
41
+ /**
42
+ * All schema which could transitively be used under the associated node.
43
+ * @remarks
44
+ * While generally {@link TreeNodeSchema} are referenced as objects and thus do not need to be looked up by identifier,
45
+ * there are a few cases (mainly constructing new TreeNodes from existing tree data) where such a lookup is useful.
46
+ * Having this map in the context addresses this use-case.
47
+ * @privateRemarks
48
+ * This design mirrors how {@link FlexTreeSchema} are accessed off the {@link FlexTreeContext}, making the migration away from them simpler.
49
+ */
50
+ schema: ReadonlyMap<TreeNodeSchemaIdentifier, TreeNodeSchema>);
40
51
  }
41
52
  /**
42
53
  * Extends {@link Context} with additional information from the view and/or tree which becomes known when a {@link TreeNode} is hydrated,
@@ -44,6 +55,6 @@ export declare class Context {
44
55
  */
45
56
  export declare class HydratedContext extends Context {
46
57
  readonly flexContext: FlexTreeHydratedContext;
47
- constructor(rootSchema: NormalizedAnnotatedAllowedTypes, flexContext: FlexTreeHydratedContext);
58
+ constructor(flexContext: FlexTreeHydratedContext, schema: ReadonlyMap<TreeNodeSchemaIdentifier, TreeNodeSchema>);
48
59
  }
49
60
  //# sourceMappingURL=context.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../../src/simple-tree/core/context.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAC;AACpE,OAAO,KAAK,EACX,eAAe,EACf,uBAAuB,EACvB,MAAM,kCAAkC,CAAC;AAE1C,OAAO,KAAK,EAAE,+BAA+B,EAAE,MAAM,mBAAmB,CAAC;AAEzE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAG1D;;;;;;;;;;;;GAYG;AACH,qBAAa,OAAO;aAmBF,WAAW,EAAE,eAAe;IAlB7C;;;;;;;;OAQG;IACH,SAAgB,MAAM,EAAE,WAAW,CAAC,wBAAwB,EAAE,cAAc,CAAC,CAAC;IAE9E;;;;OAIG;gBAEF,UAAU,EAAE,+BAA+B,EAC3B,WAAW,EAAE,eAAe;CAU7C;AAED;;;GAGG;AACH,qBAAa,eAAgB,SAAQ,OAAO;aAGjB,WAAW,EAAE,uBAAuB;gBAD7D,UAAU,EAAE,+BAA+B,EAClB,WAAW,EAAE,uBAAuB;CAI9D"}
1
+ {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../../src/simple-tree/core/context.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAC;AACpE,OAAO,KAAK,EACX,eAAe,EACf,uBAAuB,EACvB,MAAM,kCAAkC,CAAC;AAE1C,OAAO,KAAK,EAAE,+BAA+B,EAAE,MAAM,mBAAmB,CAAC;AAEzE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAG1D;;;;;;;;;;;;GAYG;AACH,qBAAa,OAAO;aAmBF,WAAW,EAAE,eAAe;IAC5C;;;;;;;;OAQG;aACa,MAAM,EAAE,WAAW,CAAC,wBAAwB,EAAE,cAAc,CAAC;WA5BhE,uBAAuB,CACpC,UAAU,EAAE,+BAA+B,GACzC,WAAW,CAAC,wBAAwB,EAAE,cAAc,CAAC;IAUxD;;;;OAIG;gBAEc,WAAW,EAAE,eAAe;IAC5C;;;;;;;;OAQG;IACa,MAAM,EAAE,WAAW,CAAC,wBAAwB,EAAE,cAAc,CAAC;CAE9E;AAED;;;GAGG;AACH,qBAAa,eAAgB,SAAQ,OAAO;aAEjB,WAAW,EAAE,uBAAuB;gBAApC,WAAW,EAAE,uBAAuB,EAC7D,MAAM,EAAE,WAAW,CAAC,wBAAwB,EAAE,cAAc,CAAC;CAI9D"}
@@ -18,19 +18,32 @@ import { walkAllowedTypes } from "./walkSchema.js";
18
18
  * This design is the same as {@link FlexTreeContext} with its base type and {@link FlexTreeHydratedContext} extending it.
19
19
  */
20
20
  export class Context {
21
- /**
22
- * Builds the context.
23
- * @remarks
24
- * Since this walks the schema, it must not be invoked during schema declaration or schema forward references could fail to be resolved.
25
- */
26
- constructor(rootSchema, flexContext) {
27
- this.flexContext = flexContext;
21
+ static schemaMapFromRootSchema(rootSchema) {
28
22
  const schema = new Map();
29
23
  walkAllowedTypes(rootSchema, {
30
24
  node(nodeSchema) {
31
25
  schema.set(brand(nodeSchema.identifier), nodeSchema);
32
26
  },
33
27
  });
28
+ return schema;
29
+ }
30
+ /**
31
+ * Builds the context.
32
+ * @remarks
33
+ * Since this walks the schema, it must not be invoked during schema declaration or schema forward references could fail to be resolved.
34
+ */
35
+ constructor(flexContext,
36
+ /**
37
+ * All schema which could transitively be used under the associated node.
38
+ * @remarks
39
+ * While generally {@link TreeNodeSchema} are referenced as objects and thus do not need to be looked up by identifier,
40
+ * there are a few cases (mainly constructing new TreeNodes from existing tree data) where such a lookup is useful.
41
+ * Having this map in the context addresses this use-case.
42
+ * @privateRemarks
43
+ * This design mirrors how {@link FlexTreeSchema} are accessed off the {@link FlexTreeContext}, making the migration away from them simpler.
44
+ */
45
+ schema) {
46
+ this.flexContext = flexContext;
34
47
  this.schema = schema;
35
48
  }
36
49
  }
@@ -39,8 +52,8 @@ export class Context {
39
52
  * associating it with the containing {@link TreeView}.
40
53
  */
41
54
  export class HydratedContext extends Context {
42
- constructor(rootSchema, flexContext) {
43
- super(rootSchema, flexContext);
55
+ constructor(flexContext, schema) {
56
+ super(flexContext, schema);
44
57
  this.flexContext = flexContext;
45
58
  }
46
59
  }
@@ -1 +1 @@
1
- {"version":3,"file":"context.js","sourceRoot":"","sources":["../../../src/simple-tree/core/context.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAOH,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAI5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAEnD;;;;;;;;;;;;GAYG;AACH,MAAM,OAAO,OAAO;IAYnB;;;;OAIG;IACH,YACC,UAA2C,EAC3B,WAA4B;QAA5B,gBAAW,GAAX,WAAW,CAAiB;QAE5C,MAAM,MAAM,GAAkD,IAAI,GAAG,EAAE,CAAC;QACxE,gBAAgB,CAAC,UAAU,EAAE;YAC5B,IAAI,CAAC,UAAU;gBACd,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,UAAU,CAAC,CAAC;YACtD,CAAC;SACD,CAAC,CAAC;QACH,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACtB,CAAC;CACD;AAED;;;GAGG;AACH,MAAM,OAAO,eAAgB,SAAQ,OAAO;IAC3C,YACC,UAA2C,EAClB,WAAoC;QAE7D,KAAK,CAAC,UAAU,EAAE,WAAW,CAAC,CAAC;QAFN,gBAAW,GAAX,WAAW,CAAyB;IAG9D,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { TreeNodeSchemaIdentifier } from \"../../core/index.js\";\nimport type {\n\tFlexTreeContext,\n\tFlexTreeHydratedContext,\n} from \"../../feature-libraries/index.js\";\nimport { brand } from \"../../util/index.js\";\nimport type { NormalizedAnnotatedAllowedTypes } from \"./allowedTypes.js\";\n\nimport type { TreeNodeSchema } from \"./treeNodeSchema.js\";\nimport { walkAllowedTypes } from \"./walkSchema.js\";\n\n/**\n * Additional information about a collection of {@link TreeNode}s.\n * @remarks\n * Each TreeNode provides a way to navigate to a context for it with additional information.\n *\n * For unhydrated nodes, this information is rather limited since the node doesn't know what tree it might get inserted into (if any),\n * and thus is limited to information derived about that particular unhydrated tree and its schema.\n *\n * Hydrated nodes have more contextual information, and thus can provide a single {@link HydratedContext} for all nodes in the document which can have additional information.\n *\n * @privateRemarks\n * This design is the same as {@link FlexTreeContext} with its base type and {@link FlexTreeHydratedContext} extending it.\n */\nexport class Context {\n\t/**\n\t * All schema which could transitively be used under the associated node.\n\t * @remarks\n\t * While generally {@link TreeNodeSchema} are referenced as objects and thus do not need to be looked up by identifier,\n\t * there are a few cases (mainly constructing new TreeNodes from existing tree data) where such a lookup is useful.\n\t * Having this map in the context addresses this use-case.\n\t * @privateRemarks\n\t * This design mirrors how {@link FlexTreeSchema} are accessed off the {@link FlexTreeContext}, making the migration away from them simpler.\n\t */\n\tpublic readonly schema: ReadonlyMap<TreeNodeSchemaIdentifier, TreeNodeSchema>;\n\n\t/**\n\t * Builds the context.\n\t * @remarks\n\t * Since this walks the schema, it must not be invoked during schema declaration or schema forward references could fail to be resolved.\n\t */\n\tpublic constructor(\n\t\trootSchema: NormalizedAnnotatedAllowedTypes,\n\t\tpublic readonly flexContext: FlexTreeContext,\n\t) {\n\t\tconst schema: Map<TreeNodeSchemaIdentifier, TreeNodeSchema> = new Map();\n\t\twalkAllowedTypes(rootSchema, {\n\t\t\tnode(nodeSchema) {\n\t\t\t\tschema.set(brand(nodeSchema.identifier), nodeSchema);\n\t\t\t},\n\t\t});\n\t\tthis.schema = schema;\n\t}\n}\n\n/**\n * Extends {@link Context} with additional information from the view and/or tree which becomes known when a {@link TreeNode} is hydrated,\n * associating it with the containing {@link TreeView}.\n */\nexport class HydratedContext extends Context {\n\tpublic constructor(\n\t\trootSchema: NormalizedAnnotatedAllowedTypes,\n\t\tpublic override readonly flexContext: FlexTreeHydratedContext,\n\t) {\n\t\tsuper(rootSchema, flexContext);\n\t}\n}\n"]}
1
+ {"version":3,"file":"context.js","sourceRoot":"","sources":["../../../src/simple-tree/core/context.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAOH,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAI5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAEnD;;;;;;;;;;;;GAYG;AACH,MAAM,OAAO,OAAO;IACZ,MAAM,CAAC,uBAAuB,CACpC,UAA2C;QAE3C,MAAM,MAAM,GAAkD,IAAI,GAAG,EAAE,CAAC;QACxE,gBAAgB,CAAC,UAAU,EAAE;YAC5B,IAAI,CAAC,UAAU;gBACd,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,UAAU,CAAC,CAAC;YACtD,CAAC;SACD,CAAC,CAAC;QACH,OAAO,MAAM,CAAC;IACf,CAAC;IAED;;;;OAIG;IACH,YACiB,WAA4B;IAC5C;;;;;;;;OAQG;IACa,MAA6D;QAV7D,gBAAW,GAAX,WAAW,CAAiB;QAU5B,WAAM,GAAN,MAAM,CAAuD;IAC3E,CAAC;CACJ;AAED;;;GAGG;AACH,MAAM,OAAO,eAAgB,SAAQ,OAAO;IAC3C,YAC0B,WAAoC,EAC7D,MAA6D;QAE7D,KAAK,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC;QAHF,gBAAW,GAAX,WAAW,CAAyB;IAI9D,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { TreeNodeSchemaIdentifier } from \"../../core/index.js\";\nimport type {\n\tFlexTreeContext,\n\tFlexTreeHydratedContext,\n} from \"../../feature-libraries/index.js\";\nimport { brand } from \"../../util/index.js\";\nimport type { NormalizedAnnotatedAllowedTypes } from \"./allowedTypes.js\";\n\nimport type { TreeNodeSchema } from \"./treeNodeSchema.js\";\nimport { walkAllowedTypes } from \"./walkSchema.js\";\n\n/**\n * Additional information about a collection of {@link TreeNode}s.\n * @remarks\n * Each TreeNode provides a way to navigate to a context for it with additional information.\n *\n * For unhydrated nodes, this information is rather limited since the node doesn't know what tree it might get inserted into (if any),\n * and thus is limited to information derived about that particular unhydrated tree and its schema.\n *\n * Hydrated nodes have more contextual information, and thus can provide a single {@link HydratedContext} for all nodes in the document which can have additional information.\n *\n * @privateRemarks\n * This design is the same as {@link FlexTreeContext} with its base type and {@link FlexTreeHydratedContext} extending it.\n */\nexport class Context {\n\tpublic static schemaMapFromRootSchema(\n\t\trootSchema: NormalizedAnnotatedAllowedTypes,\n\t): ReadonlyMap<TreeNodeSchemaIdentifier, TreeNodeSchema> {\n\t\tconst schema: Map<TreeNodeSchemaIdentifier, TreeNodeSchema> = new Map();\n\t\twalkAllowedTypes(rootSchema, {\n\t\t\tnode(nodeSchema) {\n\t\t\t\tschema.set(brand(nodeSchema.identifier), nodeSchema);\n\t\t\t},\n\t\t});\n\t\treturn schema;\n\t}\n\n\t/**\n\t * Builds the context.\n\t * @remarks\n\t * Since this walks the schema, it must not be invoked during schema declaration or schema forward references could fail to be resolved.\n\t */\n\tpublic constructor(\n\t\tpublic readonly flexContext: FlexTreeContext,\n\t\t/**\n\t\t * All schema which could transitively be used under the associated node.\n\t\t * @remarks\n\t\t * While generally {@link TreeNodeSchema} are referenced as objects and thus do not need to be looked up by identifier,\n\t\t * there are a few cases (mainly constructing new TreeNodes from existing tree data) where such a lookup is useful.\n\t\t * Having this map in the context addresses this use-case.\n\t\t * @privateRemarks\n\t\t * This design mirrors how {@link FlexTreeSchema} are accessed off the {@link FlexTreeContext}, making the migration away from them simpler.\n\t\t */\n\t\tpublic readonly schema: ReadonlyMap<TreeNodeSchemaIdentifier, TreeNodeSchema>,\n\t) {}\n}\n\n/**\n * Extends {@link Context} with additional information from the view and/or tree which becomes known when a {@link TreeNode} is hydrated,\n * associating it with the containing {@link TreeView}.\n */\nexport class HydratedContext extends Context {\n\tpublic constructor(\n\t\tpublic override readonly flexContext: FlexTreeHydratedContext,\n\t\tschema: ReadonlyMap<TreeNodeSchemaIdentifier, TreeNodeSchema>,\n\t) {\n\t\tsuper(flexContext, schema);\n\t}\n}\n"]}
@@ -8,13 +8,15 @@ export { type Unhydrated, type InternalTreeNode, } from "./types.js";
8
8
  export { TreeNode, privateToken, inPrototypeChain, } from "./treeNode.js";
9
9
  export { NodeKind, isTreeNodeSchemaClass, privateDataSymbol, getTreeNodeSchemaPrivateData, CompatibilityLevel, } from "./treeNodeSchema.js";
10
10
  export type { TreeNodeSchema, TreeNodeSchemaClass, TreeNodeSchemaNonClass, TreeNodeSchemaCore, TreeNodeSchemaBoth, NodeSchemaMetadata, TreeLeafValue, InsertableTypedNode, NodeBuilderData, NodeFromSchema, TreeNodeSchemaCorePrivate, TreeNodeSchemaPrivateData, TreeNodeSchemaInitializedData, FlexContent, } from "./treeNodeSchema.js";
11
- export { isAnnotatedAllowedTypes, isAnnotatedAllowedType, normalizeAllowedTypes, normalizeAnnotatedAllowedTypes, unannotateImplicitAllowedTypes, markSchemaMostDerived, evaluateLazySchema, } from "./allowedTypes.js";
12
- export type { AnnotatedAllowedType, NormalizedAnnotatedAllowedTypes, ImplicitAllowedTypes, ImplicitAnnotatedAllowedTypes, UnannotateImplicitAllowedTypes, AllowedTypesMetadata, AllowedTypes, TreeNodeFromImplicitAllowedTypes, InsertableTreeNodeFromImplicitAllowedTypes, InsertableTreeNodeFromAllowedTypes, Input, UnannotateAllowedTypes, UnannotateAllowedType, UnannotateAllowedTypesList, UnannotateAllowedTypeOrLazyItem, AllowedTypeMetadata, AnnotatedAllowedTypes, } from "./allowedTypes.js";
13
- export { walkAllowedTypes, type SchemaVisitor } from "./walkSchema.js";
11
+ export { isAnnotatedAllowedTypes, isAnnotatedAllowedType, normalizeAllowedTypes, normalizeAnnotatedAllowedTypes, normalizeToAnnotatedAllowedType, unannotateImplicitAllowedTypes, markSchemaMostDerived, evaluateLazySchema, createSchemaUpgrade, type SchemaUpgrade, } from "./allowedTypes.js";
12
+ export type { AnnotatedAllowedType, NormalizedAnnotatedAllowedTypes, ImplicitAllowedTypes, ImplicitAnnotatedAllowedTypes, UnannotateImplicitAllowedTypes, AllowedTypesMetadata, AllowedTypes, TreeNodeFromImplicitAllowedTypes, InsertableTreeNodeFromImplicitAllowedTypes, InsertableTreeNodeFromAllowedTypes, Input, UnannotateAllowedTypes, UnannotateAllowedType, UnannotateAllowedTypesList, AllowedTypeMetadata, AnnotatedAllowedTypes, } from "./allowedTypes.js";
13
+ export { walkAllowedTypes, walkNodeSchema, type SchemaVisitor } from "./walkSchema.js";
14
14
  export { Context, HydratedContext } from "./context.js";
15
15
  export { getOrCreateNodeFromInnerNode, getOrCreateNodeFromInnerUnboxedNode, } from "./getOrCreateNode.js";
16
16
  export { UnhydratedFlexTreeField, UnhydratedFlexTreeNode, UnhydratedSequenceField, UnhydratedContext, createField, } from "./unhydratedFlexTree.js";
17
17
  export type { LazyItem, FlexList, FlexListToUnion, ExtractItemType, } from "./flexList.js";
18
18
  export { isLazy } from "./flexList.js";
19
- export { TreeNodeValid, type MostDerivedData, createTreeNodeSchemaPrivateData, } from "./treeNodeValid.js";
19
+ export { TreeNodeValid, type MostDerivedData, createTreeNodeSchemaPrivateData, isClassBasedSchema, } from "./treeNodeValid.js";
20
+ export type { SimpleNodeSchemaBase } from "./simpleNodeSchemaBase.js";
21
+ export { type StoredSchemaGenerationOptions, convertAllowedTypes, allowedTypeFilter, } from "./toStored.js";
20
22
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/simple-tree/core/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,UAAU,EACV,cAAc,EACd,SAAS,EACT,oBAAoB,EACpB,KAAK,SAAS,EACd,kBAAkB,EAClB,oBAAoB,EACpB,kBAAkB,EAClB,gCAAgC,EAChC,iBAAiB,GACjB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,KAAK,QAAQ,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAChF,OAAO,EACN,KAAK,UAAU,EACf,KAAK,gBAAgB,GACrB,MAAM,YAAY,CAAC;AACpB,OAAO,EACN,QAAQ,EACR,YAAY,EACZ,gBAAgB,GAChB,MAAM,eAAe,CAAC;AACvB,OAAO,EACN,QAAQ,EACR,qBAAqB,EACrB,iBAAiB,EACjB,4BAA4B,EAC5B,kBAAkB,GAClB,MAAM,qBAAqB,CAAC;AAC7B,YAAY,EACX,cAAc,EACd,mBAAmB,EACnB,sBAAsB,EACtB,kBAAkB,EAClB,kBAAkB,EAClB,kBAAkB,EAClB,aAAa,EACb,mBAAmB,EACnB,eAAe,EACf,cAAc,EACd,yBAAyB,EACzB,yBAAyB,EACzB,6BAA6B,EAC7B,WAAW,GACX,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACN,uBAAuB,EACvB,sBAAsB,EACtB,qBAAqB,EACrB,8BAA8B,EAC9B,8BAA8B,EAC9B,qBAAqB,EACrB,kBAAkB,GAClB,MAAM,mBAAmB,CAAC;AAC3B,YAAY,EACX,oBAAoB,EACpB,+BAA+B,EAC/B,oBAAoB,EACpB,6BAA6B,EAC7B,8BAA8B,EAC9B,oBAAoB,EACpB,YAAY,EACZ,gCAAgC,EAChC,0CAA0C,EAC1C,kCAAkC,EAClC,KAAK,EACL,sBAAsB,EACtB,qBAAqB,EACrB,0BAA0B,EAC1B,+BAA+B,EAC/B,mBAAmB,EACnB,qBAAqB,GACrB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,gBAAgB,EAAE,KAAK,aAAa,EAAE,MAAM,iBAAiB,CAAC;AACvE,OAAO,EAAE,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AACxD,OAAO,EACN,4BAA4B,EAC5B,mCAAmC,GACnC,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACN,uBAAuB,EACvB,sBAAsB,EACtB,uBAAuB,EACvB,iBAAiB,EACjB,WAAW,GACX,MAAM,yBAAyB,CAAC;AACjC,YAAY,EACX,QAAQ,EACR,QAAQ,EACR,eAAe,EACf,eAAe,GACf,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AACvC,OAAO,EACN,aAAa,EACb,KAAK,eAAe,EACpB,+BAA+B,GAC/B,MAAM,oBAAoB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/simple-tree/core/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,UAAU,EACV,cAAc,EACd,SAAS,EACT,oBAAoB,EACpB,KAAK,SAAS,EACd,kBAAkB,EAClB,oBAAoB,EACpB,kBAAkB,EAClB,gCAAgC,EAChC,iBAAiB,GACjB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,KAAK,QAAQ,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAChF,OAAO,EACN,KAAK,UAAU,EACf,KAAK,gBAAgB,GACrB,MAAM,YAAY,CAAC;AACpB,OAAO,EACN,QAAQ,EACR,YAAY,EACZ,gBAAgB,GAChB,MAAM,eAAe,CAAC;AACvB,OAAO,EACN,QAAQ,EACR,qBAAqB,EACrB,iBAAiB,EACjB,4BAA4B,EAC5B,kBAAkB,GAClB,MAAM,qBAAqB,CAAC;AAC7B,YAAY,EACX,cAAc,EACd,mBAAmB,EACnB,sBAAsB,EACtB,kBAAkB,EAClB,kBAAkB,EAClB,kBAAkB,EAClB,aAAa,EACb,mBAAmB,EACnB,eAAe,EACf,cAAc,EACd,yBAAyB,EACzB,yBAAyB,EACzB,6BAA6B,EAC7B,WAAW,GACX,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACN,uBAAuB,EACvB,sBAAsB,EACtB,qBAAqB,EACrB,8BAA8B,EAC9B,+BAA+B,EAC/B,8BAA8B,EAC9B,qBAAqB,EACrB,kBAAkB,EAClB,mBAAmB,EACnB,KAAK,aAAa,GAClB,MAAM,mBAAmB,CAAC;AAC3B,YAAY,EACX,oBAAoB,EACpB,+BAA+B,EAC/B,oBAAoB,EACpB,6BAA6B,EAC7B,8BAA8B,EAC9B,oBAAoB,EACpB,YAAY,EACZ,gCAAgC,EAChC,0CAA0C,EAC1C,kCAAkC,EAClC,KAAK,EACL,sBAAsB,EACtB,qBAAqB,EACrB,0BAA0B,EAC1B,mBAAmB,EACnB,qBAAqB,GACrB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE,KAAK,aAAa,EAAE,MAAM,iBAAiB,CAAC;AACvF,OAAO,EAAE,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AACxD,OAAO,EACN,4BAA4B,EAC5B,mCAAmC,GACnC,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACN,uBAAuB,EACvB,sBAAsB,EACtB,uBAAuB,EACvB,iBAAiB,EACjB,WAAW,GACX,MAAM,yBAAyB,CAAC;AACjC,YAAY,EACX,QAAQ,EACR,QAAQ,EACR,eAAe,EACf,eAAe,GACf,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AACvC,OAAO,EACN,aAAa,EACb,KAAK,eAAe,EACpB,+BAA+B,EAC/B,kBAAkB,GAClB,MAAM,oBAAoB,CAAC;AAC5B,YAAY,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACtE,OAAO,EACN,KAAK,6BAA6B,EAClC,mBAAmB,EACnB,iBAAiB,GACjB,MAAM,eAAe,CAAC"}
@@ -6,11 +6,12 @@ export { isTreeNode, TreeNodeKernel, getKernel, tryGetTreeNodeSchema, tryDispose
6
6
  export { typeNameSymbol, typeSchemaSymbol } from "./withType.js";
7
7
  export { TreeNode, privateToken, inPrototypeChain, } from "./treeNode.js";
8
8
  export { NodeKind, isTreeNodeSchemaClass, privateDataSymbol, getTreeNodeSchemaPrivateData, CompatibilityLevel, } from "./treeNodeSchema.js";
9
- export { isAnnotatedAllowedTypes, isAnnotatedAllowedType, normalizeAllowedTypes, normalizeAnnotatedAllowedTypes, unannotateImplicitAllowedTypes, markSchemaMostDerived, evaluateLazySchema, } from "./allowedTypes.js";
10
- export { walkAllowedTypes } from "./walkSchema.js";
9
+ export { isAnnotatedAllowedTypes, isAnnotatedAllowedType, normalizeAllowedTypes, normalizeAnnotatedAllowedTypes, normalizeToAnnotatedAllowedType, unannotateImplicitAllowedTypes, markSchemaMostDerived, evaluateLazySchema, createSchemaUpgrade, } from "./allowedTypes.js";
10
+ export { walkAllowedTypes, walkNodeSchema } from "./walkSchema.js";
11
11
  export { Context, HydratedContext } from "./context.js";
12
12
  export { getOrCreateNodeFromInnerNode, getOrCreateNodeFromInnerUnboxedNode, } from "./getOrCreateNode.js";
13
13
  export { UnhydratedFlexTreeField, UnhydratedFlexTreeNode, UnhydratedSequenceField, UnhydratedContext, createField, } from "./unhydratedFlexTree.js";
14
14
  export { isLazy } from "./flexList.js";
15
- export { TreeNodeValid, createTreeNodeSchemaPrivateData, } from "./treeNodeValid.js";
15
+ export { TreeNodeValid, createTreeNodeSchemaPrivateData, isClassBasedSchema, } from "./treeNodeValid.js";
16
+ export { convertAllowedTypes, allowedTypeFilter, } from "./toStored.js";
16
17
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/simple-tree/core/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,UAAU,EACV,cAAc,EACd,SAAS,EACT,oBAAoB,EAEpB,kBAAkB,EAClB,oBAAoB,EACpB,kBAAkB,EAClB,gCAAgC,EAChC,iBAAiB,GACjB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAiB,cAAc,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAKhF,OAAO,EACN,QAAQ,EACR,YAAY,EACZ,gBAAgB,GAChB,MAAM,eAAe,CAAC;AACvB,OAAO,EACN,QAAQ,EACR,qBAAqB,EACrB,iBAAiB,EACjB,4BAA4B,EAC5B,kBAAkB,GAClB,MAAM,qBAAqB,CAAC;AAiB7B,OAAO,EACN,uBAAuB,EACvB,sBAAsB,EACtB,qBAAqB,EACrB,8BAA8B,EAC9B,8BAA8B,EAC9B,qBAAqB,EACrB,kBAAkB,GAClB,MAAM,mBAAmB,CAAC;AAoB3B,OAAO,EAAE,gBAAgB,EAAsB,MAAM,iBAAiB,CAAC;AACvE,OAAO,EAAE,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AACxD,OAAO,EACN,4BAA4B,EAC5B,mCAAmC,GACnC,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACN,uBAAuB,EACvB,sBAAsB,EACtB,uBAAuB,EACvB,iBAAiB,EACjB,WAAW,GACX,MAAM,yBAAyB,CAAC;AAOjC,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AACvC,OAAO,EACN,aAAa,EAEb,+BAA+B,GAC/B,MAAM,oBAAoB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport {\n\tisTreeNode,\n\tTreeNodeKernel,\n\tgetKernel,\n\ttryGetTreeNodeSchema,\n\ttype InnerNode,\n\ttryDisposeTreeNode,\n\tgetOrCreateInnerNode,\n\ttreeNodeFromAnchor,\n\tgetSimpleNodeSchemaFromInnerNode,\n\tSimpleContextSlot,\n} from \"./treeNodeKernel.js\";\nexport { type WithType, typeNameSymbol, typeSchemaSymbol } from \"./withType.js\";\nexport {\n\ttype Unhydrated,\n\ttype InternalTreeNode,\n} from \"./types.js\";\nexport {\n\tTreeNode,\n\tprivateToken,\n\tinPrototypeChain,\n} from \"./treeNode.js\";\nexport {\n\tNodeKind,\n\tisTreeNodeSchemaClass,\n\tprivateDataSymbol,\n\tgetTreeNodeSchemaPrivateData,\n\tCompatibilityLevel,\n} from \"./treeNodeSchema.js\";\nexport type {\n\tTreeNodeSchema,\n\tTreeNodeSchemaClass,\n\tTreeNodeSchemaNonClass,\n\tTreeNodeSchemaCore,\n\tTreeNodeSchemaBoth,\n\tNodeSchemaMetadata,\n\tTreeLeafValue,\n\tInsertableTypedNode,\n\tNodeBuilderData,\n\tNodeFromSchema,\n\tTreeNodeSchemaCorePrivate,\n\tTreeNodeSchemaPrivateData,\n\tTreeNodeSchemaInitializedData,\n\tFlexContent,\n} from \"./treeNodeSchema.js\";\nexport {\n\tisAnnotatedAllowedTypes,\n\tisAnnotatedAllowedType,\n\tnormalizeAllowedTypes,\n\tnormalizeAnnotatedAllowedTypes,\n\tunannotateImplicitAllowedTypes,\n\tmarkSchemaMostDerived,\n\tevaluateLazySchema,\n} from \"./allowedTypes.js\";\nexport type {\n\tAnnotatedAllowedType,\n\tNormalizedAnnotatedAllowedTypes,\n\tImplicitAllowedTypes,\n\tImplicitAnnotatedAllowedTypes,\n\tUnannotateImplicitAllowedTypes,\n\tAllowedTypesMetadata,\n\tAllowedTypes,\n\tTreeNodeFromImplicitAllowedTypes,\n\tInsertableTreeNodeFromImplicitAllowedTypes,\n\tInsertableTreeNodeFromAllowedTypes,\n\tInput,\n\tUnannotateAllowedTypes,\n\tUnannotateAllowedType,\n\tUnannotateAllowedTypesList,\n\tUnannotateAllowedTypeOrLazyItem,\n\tAllowedTypeMetadata,\n\tAnnotatedAllowedTypes,\n} from \"./allowedTypes.js\";\nexport { walkAllowedTypes, type SchemaVisitor } from \"./walkSchema.js\";\nexport { Context, HydratedContext } from \"./context.js\";\nexport {\n\tgetOrCreateNodeFromInnerNode,\n\tgetOrCreateNodeFromInnerUnboxedNode,\n} from \"./getOrCreateNode.js\";\nexport {\n\tUnhydratedFlexTreeField,\n\tUnhydratedFlexTreeNode,\n\tUnhydratedSequenceField,\n\tUnhydratedContext,\n\tcreateField,\n} from \"./unhydratedFlexTree.js\";\nexport type {\n\tLazyItem,\n\tFlexList,\n\tFlexListToUnion,\n\tExtractItemType,\n} from \"./flexList.js\";\nexport { isLazy } from \"./flexList.js\";\nexport {\n\tTreeNodeValid,\n\ttype MostDerivedData,\n\tcreateTreeNodeSchemaPrivateData,\n} from \"./treeNodeValid.js\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/simple-tree/core/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,UAAU,EACV,cAAc,EACd,SAAS,EACT,oBAAoB,EAEpB,kBAAkB,EAClB,oBAAoB,EACpB,kBAAkB,EAClB,gCAAgC,EAChC,iBAAiB,GACjB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAiB,cAAc,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAKhF,OAAO,EACN,QAAQ,EACR,YAAY,EACZ,gBAAgB,GAChB,MAAM,eAAe,CAAC;AACvB,OAAO,EACN,QAAQ,EACR,qBAAqB,EACrB,iBAAiB,EACjB,4BAA4B,EAC5B,kBAAkB,GAClB,MAAM,qBAAqB,CAAC;AAiB7B,OAAO,EACN,uBAAuB,EACvB,sBAAsB,EACtB,qBAAqB,EACrB,8BAA8B,EAC9B,+BAA+B,EAC/B,8BAA8B,EAC9B,qBAAqB,EACrB,kBAAkB,EAClB,mBAAmB,GAEnB,MAAM,mBAAmB,CAAC;AAmB3B,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAsB,MAAM,iBAAiB,CAAC;AACvF,OAAO,EAAE,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AACxD,OAAO,EACN,4BAA4B,EAC5B,mCAAmC,GACnC,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACN,uBAAuB,EACvB,sBAAsB,EACtB,uBAAuB,EACvB,iBAAiB,EACjB,WAAW,GACX,MAAM,yBAAyB,CAAC;AAOjC,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AACvC,OAAO,EACN,aAAa,EAEb,+BAA+B,EAC/B,kBAAkB,GAClB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EAEN,mBAAmB,EACnB,iBAAiB,GACjB,MAAM,eAAe,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport {\n\tisTreeNode,\n\tTreeNodeKernel,\n\tgetKernel,\n\ttryGetTreeNodeSchema,\n\ttype InnerNode,\n\ttryDisposeTreeNode,\n\tgetOrCreateInnerNode,\n\ttreeNodeFromAnchor,\n\tgetSimpleNodeSchemaFromInnerNode,\n\tSimpleContextSlot,\n} from \"./treeNodeKernel.js\";\nexport { type WithType, typeNameSymbol, typeSchemaSymbol } from \"./withType.js\";\nexport {\n\ttype Unhydrated,\n\ttype InternalTreeNode,\n} from \"./types.js\";\nexport {\n\tTreeNode,\n\tprivateToken,\n\tinPrototypeChain,\n} from \"./treeNode.js\";\nexport {\n\tNodeKind,\n\tisTreeNodeSchemaClass,\n\tprivateDataSymbol,\n\tgetTreeNodeSchemaPrivateData,\n\tCompatibilityLevel,\n} from \"./treeNodeSchema.js\";\nexport type {\n\tTreeNodeSchema,\n\tTreeNodeSchemaClass,\n\tTreeNodeSchemaNonClass,\n\tTreeNodeSchemaCore,\n\tTreeNodeSchemaBoth,\n\tNodeSchemaMetadata,\n\tTreeLeafValue,\n\tInsertableTypedNode,\n\tNodeBuilderData,\n\tNodeFromSchema,\n\tTreeNodeSchemaCorePrivate,\n\tTreeNodeSchemaPrivateData,\n\tTreeNodeSchemaInitializedData,\n\tFlexContent,\n} from \"./treeNodeSchema.js\";\nexport {\n\tisAnnotatedAllowedTypes,\n\tisAnnotatedAllowedType,\n\tnormalizeAllowedTypes,\n\tnormalizeAnnotatedAllowedTypes,\n\tnormalizeToAnnotatedAllowedType,\n\tunannotateImplicitAllowedTypes,\n\tmarkSchemaMostDerived,\n\tevaluateLazySchema,\n\tcreateSchemaUpgrade,\n\ttype SchemaUpgrade,\n} from \"./allowedTypes.js\";\nexport type {\n\tAnnotatedAllowedType,\n\tNormalizedAnnotatedAllowedTypes,\n\tImplicitAllowedTypes,\n\tImplicitAnnotatedAllowedTypes,\n\tUnannotateImplicitAllowedTypes,\n\tAllowedTypesMetadata,\n\tAllowedTypes,\n\tTreeNodeFromImplicitAllowedTypes,\n\tInsertableTreeNodeFromImplicitAllowedTypes,\n\tInsertableTreeNodeFromAllowedTypes,\n\tInput,\n\tUnannotateAllowedTypes,\n\tUnannotateAllowedType,\n\tUnannotateAllowedTypesList,\n\tAllowedTypeMetadata,\n\tAnnotatedAllowedTypes,\n} from \"./allowedTypes.js\";\nexport { walkAllowedTypes, walkNodeSchema, type SchemaVisitor } from \"./walkSchema.js\";\nexport { Context, HydratedContext } from \"./context.js\";\nexport {\n\tgetOrCreateNodeFromInnerNode,\n\tgetOrCreateNodeFromInnerUnboxedNode,\n} from \"./getOrCreateNode.js\";\nexport {\n\tUnhydratedFlexTreeField,\n\tUnhydratedFlexTreeNode,\n\tUnhydratedSequenceField,\n\tUnhydratedContext,\n\tcreateField,\n} from \"./unhydratedFlexTree.js\";\nexport type {\n\tLazyItem,\n\tFlexList,\n\tFlexListToUnion,\n\tExtractItemType,\n} from \"./flexList.js\";\nexport { isLazy } from \"./flexList.js\";\nexport {\n\tTreeNodeValid,\n\ttype MostDerivedData,\n\tcreateTreeNodeSchemaPrivateData,\n\tisClassBasedSchema,\n} from \"./treeNodeValid.js\";\nexport type { SimpleNodeSchemaBase } from \"./simpleNodeSchemaBase.js\";\nexport {\n\ttype StoredSchemaGenerationOptions,\n\tconvertAllowedTypes,\n\tallowedTypeFilter,\n} from \"./toStored.js\";\n"]}
@@ -0,0 +1,25 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ import type { NodeKind, NodeSchemaMetadata } from "./treeNodeSchema.js";
6
+ /**
7
+ * Base interface for {@link TreeNodeSchema} and {@link SimpleNodeSchema} types.
8
+ * Once simple schema is stable this doesn't have a reason to be kept `@system`, but it could be.
9
+ * @system
10
+ * @public
11
+ * @sealed
12
+ */
13
+ export interface SimpleNodeSchemaBase<out TNodeKind extends NodeKind, out TCustomMetadata = unknown> {
14
+ /**
15
+ * The {@link NodeKind}.
16
+ *
17
+ * @remarks can be used to type-switch between implementations.
18
+ */
19
+ readonly kind: TNodeKind;
20
+ /**
21
+ * User-provided {@link NodeSchemaMetadata} for this schema.
22
+ */
23
+ readonly metadata: NodeSchemaMetadata<TCustomMetadata>;
24
+ }
25
+ //# sourceMappingURL=simpleNodeSchemaBase.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"simpleNodeSchemaBase.d.ts","sourceRoot":"","sources":["../../../src/simple-tree/core/simpleNodeSchemaBase.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAExE;;;;;;GAMG;AACH,MAAM,WAAW,oBAAoB,CACpC,GAAG,CAAC,SAAS,SAAS,QAAQ,EAC9B,GAAG,CAAC,eAAe,GAAG,OAAO;IAE7B;;;;OAIG;IACH,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;IAEzB;;OAEG;IACH,QAAQ,CAAC,QAAQ,EAAE,kBAAkB,CAAC,eAAe,CAAC,CAAC;CACvD"}
@@ -0,0 +1,6 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ export {};
6
+ //# sourceMappingURL=simpleNodeSchemaBase.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"simpleNodeSchemaBase.js","sourceRoot":"","sources":["../../../src/simple-tree/core/simpleNodeSchemaBase.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { NodeKind, NodeSchemaMetadata } from \"./treeNodeSchema.js\";\n\n/**\n * Base interface for {@link TreeNodeSchema} and {@link SimpleNodeSchema} types.\n * Once simple schema is stable this doesn't have a reason to be kept `@system`, but it could be.\n * @system\n * @public\n * @sealed\n */\nexport interface SimpleNodeSchemaBase<\n\tout TNodeKind extends NodeKind,\n\tout TCustomMetadata = unknown,\n> {\n\t/**\n\t * The {@link NodeKind}.\n\t *\n\t * @remarks can be used to type-switch between implementations.\n\t */\n\treadonly kind: TNodeKind;\n\n\t/**\n\t * User-provided {@link NodeSchemaMetadata} for this schema.\n\t */\n\treadonly metadata: NodeSchemaMetadata<TCustomMetadata>;\n}\n"]}
@@ -0,0 +1,32 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ import { type AnnotatedAllowedType, type ImplicitAnnotatedAllowedTypes, type SchemaUpgrade } from "./allowedTypes.js";
6
+ import type { TreeTypeSet } from "../../core/index.js";
7
+ /**
8
+ * Options for generating a {@link TreeStoredSchema} from view schema.
9
+ */
10
+ export interface StoredSchemaGenerationOptions {
11
+ /**
12
+ * Determines whether to include staged schema in the resulting stored schema.
13
+ * @remarks
14
+ * Due to caching, the behavior of this function must be pure.
15
+ */
16
+ includeStaged(upgrade: SchemaUpgrade): boolean;
17
+ }
18
+ /**
19
+ * Filters an allowed type based on the provided options.
20
+ * @param allowedType - The allowed type to filter.
21
+ * @param options - The options to use for filtering.
22
+ * @returns Whether the allowed type passes the filter.
23
+ */
24
+ export declare function allowedTypeFilter(allowedType: AnnotatedAllowedType, options: StoredSchemaGenerationOptions): boolean;
25
+ /**
26
+ * Converts an ImplicitAnnotatedAllowedTypes to a stored schema.
27
+ * @param schema - The schema to convert.
28
+ * @param options - The options to use for filtering.
29
+ * @returns The converted stored schema.
30
+ */
31
+ export declare function convertAllowedTypes(schema: ImplicitAnnotatedAllowedTypes, options: StoredSchemaGenerationOptions): TreeTypeSet;
32
+ //# sourceMappingURL=toStored.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"toStored.d.ts","sourceRoot":"","sources":["../../../src/simple-tree/core/toStored.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAEN,KAAK,oBAAoB,EACzB,KAAK,6BAA6B,EAClC,KAAK,aAAa,EAClB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAA4B,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAEjF;;GAEG;AACH,MAAM,WAAW,6BAA6B;IAC7C;;;;OAIG;IACH,aAAa,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC;CAC/C;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAChC,WAAW,EAAE,oBAAoB,EACjC,OAAO,EAAE,6BAA6B,GACpC,OAAO,CAMT;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAClC,MAAM,EAAE,6BAA6B,EACrC,OAAO,EAAE,6BAA6B,GACpC,WAAW,CAKb"}
@@ -0,0 +1,32 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ import { brand } from "../../util/index.js";
6
+ import { normalizeAnnotatedAllowedTypes, } from "./allowedTypes.js";
7
+ /**
8
+ * Filters an allowed type based on the provided options.
9
+ * @param allowedType - The allowed type to filter.
10
+ * @param options - The options to use for filtering.
11
+ * @returns Whether the allowed type passes the filter.
12
+ */
13
+ export function allowedTypeFilter(allowedType, options) {
14
+ // If the allowed type is staged, only include it if the options allow it.
15
+ if (allowedType.metadata.stagedSchemaUpgrade !== undefined) {
16
+ return options.includeStaged(allowedType.metadata.stagedSchemaUpgrade);
17
+ }
18
+ return true;
19
+ }
20
+ /**
21
+ * Converts an ImplicitAnnotatedAllowedTypes to a stored schema.
22
+ * @param schema - The schema to convert.
23
+ * @param options - The options to use for filtering.
24
+ * @returns The converted stored schema.
25
+ */
26
+ export function convertAllowedTypes(schema, options) {
27
+ const filtered = normalizeAnnotatedAllowedTypes(schema)
28
+ .types.filter((allowedType) => allowedTypeFilter(allowedType, options))
29
+ .map((a) => brand(a.type.identifier));
30
+ return new Set(filtered);
31
+ }
32
+ //# sourceMappingURL=toStored.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"toStored.js","sourceRoot":"","sources":["../../../src/simple-tree/core/toStored.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAC5C,OAAO,EACN,8BAA8B,GAI9B,MAAM,mBAAmB,CAAC;AAe3B;;;;;GAKG;AACH,MAAM,UAAU,iBAAiB,CAChC,WAAiC,EACjC,OAAsC;IAEtC,0EAA0E;IAC1E,IAAI,WAAW,CAAC,QAAQ,CAAC,mBAAmB,KAAK,SAAS,EAAE,CAAC;QAC5D,OAAO,OAAO,CAAC,aAAa,CAAC,WAAW,CAAC,QAAQ,CAAC,mBAAmB,CAAC,CAAC;IACxE,CAAC;IACD,OAAO,IAAI,CAAC;AACb,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,mBAAmB,CAClC,MAAqC,EACrC,OAAsC;IAEtC,MAAM,QAAQ,GAA+B,8BAA8B,CAAC,MAAM,CAAC;SACjF,KAAK,CAAC,MAAM,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC,iBAAiB,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;SACtE,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC;IACvC,OAAO,IAAI,GAAG,CAAC,QAAQ,CAAC,CAAC;AAC1B,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { brand } from \"../../util/index.js\";\nimport {\n\tnormalizeAnnotatedAllowedTypes,\n\ttype AnnotatedAllowedType,\n\ttype ImplicitAnnotatedAllowedTypes,\n\ttype SchemaUpgrade,\n} from \"./allowedTypes.js\";\nimport type { TreeNodeSchemaIdentifier, TreeTypeSet } from \"../../core/index.js\";\n\n/**\n * Options for generating a {@link TreeStoredSchema} from view schema.\n */\nexport interface StoredSchemaGenerationOptions {\n\t/**\n\t * Determines whether to include staged schema in the resulting stored schema.\n\t * @remarks\n\t * Due to caching, the behavior of this function must be pure.\n\t */\n\tincludeStaged(upgrade: SchemaUpgrade): boolean;\n}\n\n/**\n * Filters an allowed type based on the provided options.\n * @param allowedType - The allowed type to filter.\n * @param options - The options to use for filtering.\n * @returns Whether the allowed type passes the filter.\n */\nexport function allowedTypeFilter(\n\tallowedType: AnnotatedAllowedType,\n\toptions: StoredSchemaGenerationOptions,\n): boolean {\n\t// If the allowed type is staged, only include it if the options allow it.\n\tif (allowedType.metadata.stagedSchemaUpgrade !== undefined) {\n\t\treturn options.includeStaged(allowedType.metadata.stagedSchemaUpgrade);\n\t}\n\treturn true;\n}\n\n/**\n * Converts an ImplicitAnnotatedAllowedTypes to a stored schema.\n * @param schema - The schema to convert.\n * @param options - The options to use for filtering.\n * @returns The converted stored schema.\n */\nexport function convertAllowedTypes(\n\tschema: ImplicitAnnotatedAllowedTypes,\n\toptions: StoredSchemaGenerationOptions,\n): TreeTypeSet {\n\tconst filtered: TreeNodeSchemaIdentifier[] = normalizeAnnotatedAllowedTypes(schema)\n\t\t.types.filter((allowedType) => allowedTypeFilter(allowedType, options))\n\t\t.map((a) => brand(a.type.identifier));\n\treturn new Set(filtered);\n}\n"]}
@@ -59,7 +59,7 @@ export declare class TreeNodeKernel {
59
59
  /**
60
60
  * Create a TreeNodeKernel which can be looked up with {@link getKernel}.
61
61
  *
62
- * @param initialContext - context from when this node was originally crated.
62
+ * @param initialContext - context from when this node was originally created. Only used when unhydrated.
63
63
  * @param innerNode - When unhydrated/raw or marinated the MapTreeNode. FlexTreeNode when cooked.
64
64
  * @remarks
65
65
  * Exactly one kernel per TreeNode should be created.
@@ -68,7 +68,7 @@ export class TreeNodeKernel {
68
68
  /**
69
69
  * Create a TreeNodeKernel which can be looked up with {@link getKernel}.
70
70
  *
71
- * @param initialContext - context from when this node was originally crated.
71
+ * @param initialContext - context from when this node was originally created. Only used when unhydrated.
72
72
  * @param innerNode - When unhydrated/raw or marinated the MapTreeNode. FlexTreeNode when cooked.
73
73
  * @remarks
74
74
  * Exactly one kernel per TreeNode should be created.