@fluidframework/tree 2.4.0-294316 → 2.4.0-297027

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 (606) hide show
  1. package/api-report/tree.alpha.api.md +58 -28
  2. package/api-report/tree.beta.api.md +38 -27
  3. package/api-report/tree.legacy.alpha.api.md +38 -27
  4. package/api-report/tree.legacy.public.api.md +38 -27
  5. package/api-report/tree.public.api.md +38 -27
  6. package/dist/alpha.d.ts +6 -0
  7. package/dist/beta.d.ts +3 -0
  8. package/dist/core/schema-stored/schema.d.ts +7 -0
  9. package/dist/core/schema-stored/schema.d.ts.map +1 -1
  10. package/dist/core/schema-stored/schema.js +9 -0
  11. package/dist/core/schema-stored/schema.js.map +1 -1
  12. package/dist/core/tree/anchorSet.d.ts +1 -2
  13. package/dist/core/tree/anchorSet.d.ts.map +1 -1
  14. package/dist/core/tree/anchorSet.js +2 -2
  15. package/dist/core/tree/anchorSet.js.map +1 -1
  16. package/dist/core/tree/detachedFieldIndex.d.ts.map +1 -1
  17. package/dist/core/tree/detachedFieldIndex.js +13 -2
  18. package/dist/core/tree/detachedFieldIndex.js.map +1 -1
  19. package/dist/core/tree/detachedFieldIndexTypes.d.ts +1 -1
  20. package/dist/core/tree/detachedFieldIndexTypes.js.map +1 -1
  21. package/dist/feature-libraries/editableTreeBinder.d.ts +3 -230
  22. package/dist/feature-libraries/editableTreeBinder.d.ts.map +1 -1
  23. package/dist/feature-libraries/editableTreeBinder.js +1 -539
  24. package/dist/feature-libraries/editableTreeBinder.js.map +1 -1
  25. package/dist/feature-libraries/flex-tree/context.d.ts +7 -14
  26. package/dist/feature-libraries/flex-tree/context.d.ts.map +1 -1
  27. package/dist/feature-libraries/flex-tree/context.js +3 -3
  28. package/dist/feature-libraries/flex-tree/context.js.map +1 -1
  29. package/dist/feature-libraries/flex-tree/flexTreeTypes.d.ts +2 -16
  30. package/dist/feature-libraries/flex-tree/flexTreeTypes.d.ts.map +1 -1
  31. package/dist/feature-libraries/flex-tree/flexTreeTypes.js.map +1 -1
  32. package/dist/feature-libraries/flex-tree/lazyEntity.d.ts +2 -3
  33. package/dist/feature-libraries/flex-tree/lazyEntity.d.ts.map +1 -1
  34. package/dist/feature-libraries/flex-tree/lazyEntity.js +1 -2
  35. package/dist/feature-libraries/flex-tree/lazyEntity.js.map +1 -1
  36. package/dist/feature-libraries/flex-tree/lazyField.d.ts +10 -15
  37. package/dist/feature-libraries/flex-tree/lazyField.d.ts.map +1 -1
  38. package/dist/feature-libraries/flex-tree/lazyField.js +18 -20
  39. package/dist/feature-libraries/flex-tree/lazyField.js.map +1 -1
  40. package/dist/feature-libraries/flex-tree/lazyNode.d.ts +4 -5
  41. package/dist/feature-libraries/flex-tree/lazyNode.d.ts.map +1 -1
  42. package/dist/feature-libraries/flex-tree/lazyNode.js +13 -23
  43. package/dist/feature-libraries/flex-tree/lazyNode.js.map +1 -1
  44. package/dist/feature-libraries/flex-tree/utilities.js +1 -1
  45. package/dist/feature-libraries/flex-tree/utilities.js.map +1 -1
  46. package/dist/feature-libraries/index.d.ts +4 -7
  47. package/dist/feature-libraries/index.d.ts.map +1 -1
  48. package/dist/feature-libraries/index.js +5 -31
  49. package/dist/feature-libraries/index.js.map +1 -1
  50. package/dist/feature-libraries/sequence-field/formatV1.d.ts +18 -18
  51. package/dist/feature-libraries/sequence-field/formatV2.d.ts +18 -18
  52. package/dist/feature-libraries/sequence-field/formatV3.d.ts +27 -27
  53. package/dist/feature-libraries/typed-schema/flexList.d.ts +1 -46
  54. package/dist/feature-libraries/typed-schema/flexList.d.ts.map +1 -1
  55. package/dist/feature-libraries/typed-schema/flexList.js +1 -13
  56. package/dist/feature-libraries/typed-schema/flexList.js.map +1 -1
  57. package/dist/feature-libraries/typed-schema/index.d.ts +2 -4
  58. package/dist/feature-libraries/typed-schema/index.d.ts.map +1 -1
  59. package/dist/feature-libraries/typed-schema/index.js +1 -19
  60. package/dist/feature-libraries/typed-schema/index.js.map +1 -1
  61. package/dist/feature-libraries/typed-schema/typedTreeSchema.d.ts +0 -212
  62. package/dist/feature-libraries/typed-schema/typedTreeSchema.d.ts.map +1 -1
  63. package/dist/feature-libraries/typed-schema/typedTreeSchema.js +0 -266
  64. package/dist/feature-libraries/typed-schema/typedTreeSchema.js.map +1 -1
  65. package/dist/index.d.ts +3 -3
  66. package/dist/index.d.ts.map +1 -1
  67. package/dist/index.js +2 -1
  68. package/dist/index.js.map +1 -1
  69. package/dist/internalTypes.d.ts +1 -1
  70. package/dist/internalTypes.d.ts.map +1 -1
  71. package/dist/internalTypes.js.map +1 -1
  72. package/dist/legacy.d.ts +3 -0
  73. package/dist/packageVersion.d.ts +1 -1
  74. package/dist/packageVersion.js +1 -1
  75. package/dist/packageVersion.js.map +1 -1
  76. package/dist/public.d.ts +3 -0
  77. package/dist/shared-tree/checkoutFlexTreeView.d.ts +3 -3
  78. package/dist/shared-tree/checkoutFlexTreeView.d.ts.map +1 -1
  79. package/dist/shared-tree/checkoutFlexTreeView.js +1 -1
  80. package/dist/shared-tree/checkoutFlexTreeView.js.map +1 -1
  81. package/dist/shared-tree/index.d.ts +3 -3
  82. package/dist/shared-tree/index.d.ts.map +1 -1
  83. package/dist/shared-tree/index.js +2 -3
  84. package/dist/shared-tree/index.js.map +1 -1
  85. package/dist/shared-tree/schematizeTree.d.ts +1 -40
  86. package/dist/shared-tree/schematizeTree.d.ts.map +1 -1
  87. package/dist/shared-tree/schematizeTree.js +2 -11
  88. package/dist/shared-tree/schematizeTree.js.map +1 -1
  89. package/dist/shared-tree/schematizingTreeView.d.ts +8 -7
  90. package/dist/shared-tree/schematizingTreeView.d.ts.map +1 -1
  91. package/dist/shared-tree/schematizingTreeView.js +16 -8
  92. package/dist/shared-tree/schematizingTreeView.js.map +1 -1
  93. package/dist/shared-tree/sharedTree.d.ts +19 -2
  94. package/dist/shared-tree/sharedTree.d.ts.map +1 -1
  95. package/dist/shared-tree/sharedTree.js +10 -2
  96. package/dist/shared-tree/sharedTree.js.map +1 -1
  97. package/dist/shared-tree/treeCheckout.d.ts +71 -41
  98. package/dist/shared-tree/treeCheckout.d.ts.map +1 -1
  99. package/dist/shared-tree/treeCheckout.js +116 -84
  100. package/dist/shared-tree/treeCheckout.js.map +1 -1
  101. package/dist/shared-tree-core/branch.d.ts +8 -11
  102. package/dist/shared-tree-core/branch.d.ts.map +1 -1
  103. package/dist/shared-tree-core/branch.js +12 -15
  104. package/dist/shared-tree-core/branch.js.map +1 -1
  105. package/dist/simple-tree/api/create.d.ts +1 -1
  106. package/dist/simple-tree/api/create.d.ts.map +1 -1
  107. package/dist/simple-tree/api/create.js +11 -13
  108. package/dist/simple-tree/api/create.js.map +1 -1
  109. package/dist/simple-tree/api/getJsonSchema.d.ts +3 -3
  110. package/dist/simple-tree/api/getJsonSchema.d.ts.map +1 -1
  111. package/dist/simple-tree/api/getJsonSchema.js +1 -1
  112. package/dist/simple-tree/api/getJsonSchema.js.map +1 -1
  113. package/dist/simple-tree/api/getSimpleSchema.d.ts +2 -2
  114. package/dist/simple-tree/api/getSimpleSchema.d.ts.map +1 -1
  115. package/dist/simple-tree/api/getSimpleSchema.js.map +1 -1
  116. package/dist/simple-tree/api/index.d.ts +2 -1
  117. package/dist/simple-tree/api/index.d.ts.map +1 -1
  118. package/dist/simple-tree/api/index.js +3 -1
  119. package/dist/simple-tree/api/index.js.map +1 -1
  120. package/dist/simple-tree/api/schemaFactory.d.ts +6 -6
  121. package/dist/simple-tree/api/schemaFactory.d.ts.map +1 -1
  122. package/dist/simple-tree/api/schemaFactory.js +15 -2
  123. package/dist/simple-tree/api/schemaFactory.js.map +1 -1
  124. package/dist/simple-tree/api/schemaFactoryRecursive.d.ts +3 -3
  125. package/dist/simple-tree/api/schemaFactoryRecursive.d.ts.map +1 -1
  126. package/dist/simple-tree/api/schemaFactoryRecursive.js.map +1 -1
  127. package/dist/simple-tree/api/simpleSchema.d.ts +14 -10
  128. package/dist/simple-tree/api/simpleSchema.d.ts.map +1 -1
  129. package/dist/simple-tree/api/simpleSchema.js.map +1 -1
  130. package/dist/simple-tree/api/tree.d.ts +12 -6
  131. package/dist/simple-tree/api/tree.d.ts.map +1 -1
  132. package/dist/simple-tree/api/tree.js +4 -4
  133. package/dist/simple-tree/api/tree.js.map +1 -1
  134. package/dist/simple-tree/api/treeNodeApi.d.ts.map +1 -1
  135. package/dist/simple-tree/api/treeNodeApi.js +8 -6
  136. package/dist/simple-tree/api/treeNodeApi.js.map +1 -1
  137. package/dist/simple-tree/api/verboseTree.d.ts.map +1 -1
  138. package/dist/simple-tree/api/verboseTree.js +6 -10
  139. package/dist/simple-tree/api/verboseTree.js.map +1 -1
  140. package/{lib/feature-libraries/typed-schema → dist/simple-tree/api}/view.d.ts +4 -11
  141. package/dist/simple-tree/api/view.d.ts.map +1 -0
  142. package/dist/{feature-libraries/typed-schema → simple-tree/api}/view.js +9 -9
  143. package/dist/simple-tree/api/view.js.map +1 -0
  144. package/dist/simple-tree/api/viewSchemaToSimpleSchema.d.ts +2 -2
  145. package/dist/simple-tree/api/viewSchemaToSimpleSchema.d.ts.map +1 -1
  146. package/dist/simple-tree/api/viewSchemaToSimpleSchema.js +7 -1
  147. package/dist/simple-tree/api/viewSchemaToSimpleSchema.js.map +1 -1
  148. package/dist/simple-tree/arrayNode.d.ts +147 -14
  149. package/dist/simple-tree/arrayNode.d.ts.map +1 -1
  150. package/dist/simple-tree/arrayNode.js +32 -20
  151. package/dist/simple-tree/arrayNode.js.map +1 -1
  152. package/dist/simple-tree/core/context.d.ts +55 -0
  153. package/dist/simple-tree/core/context.d.ts.map +1 -0
  154. package/dist/simple-tree/core/context.js +60 -0
  155. package/dist/simple-tree/core/context.js.map +1 -0
  156. package/dist/simple-tree/core/getOrCreateNode.d.ts +15 -0
  157. package/dist/simple-tree/core/getOrCreateNode.d.ts.map +1 -0
  158. package/dist/simple-tree/core/getOrCreateNode.js +36 -0
  159. package/dist/simple-tree/core/getOrCreateNode.js.map +1 -0
  160. package/dist/simple-tree/core/index.d.ts +7 -3
  161. package/dist/simple-tree/core/index.d.ts.map +1 -1
  162. package/dist/simple-tree/core/index.js +16 -7
  163. package/dist/simple-tree/core/index.js.map +1 -1
  164. package/dist/simple-tree/core/schemaCaching.d.ts +5 -13
  165. package/dist/simple-tree/core/schemaCaching.d.ts.map +1 -1
  166. package/dist/simple-tree/core/schemaCaching.js +16 -45
  167. package/dist/simple-tree/core/schemaCaching.js.map +1 -1
  168. package/dist/simple-tree/core/treeNodeKernel.d.ts +29 -7
  169. package/dist/simple-tree/core/treeNodeKernel.d.ts.map +1 -1
  170. package/dist/simple-tree/core/treeNodeKernel.js +94 -58
  171. package/dist/simple-tree/core/treeNodeKernel.js.map +1 -1
  172. package/dist/simple-tree/core/treeNodeSchema.d.ts +24 -0
  173. package/dist/simple-tree/core/treeNodeSchema.d.ts.map +1 -1
  174. package/dist/simple-tree/core/treeNodeSchema.js.map +1 -1
  175. package/dist/simple-tree/core/types.d.ts +0 -5
  176. package/dist/simple-tree/core/types.d.ts.map +1 -1
  177. package/dist/simple-tree/core/types.js.map +1 -1
  178. package/dist/simple-tree/core/unhydratedFlexTree.d.ts +139 -0
  179. package/dist/simple-tree/core/unhydratedFlexTree.d.ts.map +1 -0
  180. package/dist/{feature-libraries/flex-map-tree/mapTreeNode.js → simple-tree/core/unhydratedFlexTree.js} +112 -132
  181. package/dist/simple-tree/core/unhydratedFlexTree.js.map +1 -0
  182. package/dist/simple-tree/{walkSchema.d.ts → core/walkSchema.d.ts} +8 -4
  183. package/dist/simple-tree/core/walkSchema.d.ts.map +1 -0
  184. package/dist/simple-tree/core/walkSchema.js +34 -0
  185. package/dist/simple-tree/core/walkSchema.js.map +1 -0
  186. package/dist/simple-tree/createContext.d.ts +11 -0
  187. package/dist/simple-tree/createContext.d.ts.map +1 -0
  188. package/dist/simple-tree/createContext.js +25 -0
  189. package/dist/simple-tree/createContext.js.map +1 -0
  190. package/dist/simple-tree/index.d.ts +3 -4
  191. package/dist/simple-tree/index.d.ts.map +1 -1
  192. package/dist/simple-tree/index.js +7 -7
  193. package/dist/simple-tree/index.js.map +1 -1
  194. package/dist/simple-tree/leafNodeSchema.d.ts +1 -0
  195. package/dist/simple-tree/leafNodeSchema.d.ts.map +1 -1
  196. package/dist/simple-tree/leafNodeSchema.js +1 -2
  197. package/dist/simple-tree/leafNodeSchema.js.map +1 -1
  198. package/dist/simple-tree/mapNode.d.ts +4 -4
  199. package/dist/simple-tree/mapNode.d.ts.map +1 -1
  200. package/dist/simple-tree/mapNode.js +9 -5
  201. package/dist/simple-tree/mapNode.js.map +1 -1
  202. package/dist/simple-tree/objectNode.d.ts +8 -8
  203. package/dist/simple-tree/objectNode.d.ts.map +1 -1
  204. package/dist/simple-tree/objectNode.js +33 -14
  205. package/dist/simple-tree/objectNode.js.map +1 -1
  206. package/dist/simple-tree/objectNodeTypes.d.ts +7 -3
  207. package/dist/simple-tree/objectNodeTypes.d.ts.map +1 -1
  208. package/dist/simple-tree/objectNodeTypes.js.map +1 -1
  209. package/dist/simple-tree/proxies.d.ts +1 -2
  210. package/dist/simple-tree/proxies.d.ts.map +1 -1
  211. package/dist/simple-tree/proxies.js +6 -22
  212. package/dist/simple-tree/proxies.js.map +1 -1
  213. package/dist/simple-tree/schemaTypes.d.ts +2 -2
  214. package/dist/simple-tree/schemaTypes.d.ts.map +1 -1
  215. package/dist/simple-tree/schemaTypes.js.map +1 -1
  216. package/dist/simple-tree/toFlexSchema.d.ts +6 -36
  217. package/dist/simple-tree/toFlexSchema.d.ts.map +1 -1
  218. package/dist/simple-tree/toFlexSchema.js +58 -142
  219. package/dist/simple-tree/toFlexSchema.js.map +1 -1
  220. package/dist/simple-tree/toMapTree.d.ts.map +1 -1
  221. package/dist/simple-tree/toMapTree.js +2 -2
  222. package/dist/simple-tree/toMapTree.js.map +1 -1
  223. package/dist/simple-tree/treeNodeValid.d.ts +13 -5
  224. package/dist/simple-tree/treeNodeValid.d.ts.map +1 -1
  225. package/dist/simple-tree/treeNodeValid.js +19 -10
  226. package/dist/simple-tree/treeNodeValid.js.map +1 -1
  227. package/dist/simple-tree/typesUnsafe.d.ts +4 -4
  228. package/dist/simple-tree/typesUnsafe.d.ts.map +1 -1
  229. package/dist/simple-tree/typesUnsafe.js.map +1 -1
  230. package/dist/simple-tree/walkFieldSchema.d.ts +11 -0
  231. package/dist/simple-tree/walkFieldSchema.d.ts.map +1 -0
  232. package/dist/simple-tree/walkFieldSchema.js +17 -0
  233. package/dist/simple-tree/walkFieldSchema.js.map +1 -0
  234. package/dist/util/index.d.ts +1 -1
  235. package/dist/util/index.d.ts.map +1 -1
  236. package/dist/util/index.js.map +1 -1
  237. package/dist/util/typeUtils.d.ts +14 -45
  238. package/dist/util/typeUtils.d.ts.map +1 -1
  239. package/dist/util/typeUtils.js.map +1 -1
  240. package/lib/alpha.d.ts +6 -0
  241. package/lib/beta.d.ts +3 -0
  242. package/lib/core/schema-stored/schema.d.ts +7 -0
  243. package/lib/core/schema-stored/schema.d.ts.map +1 -1
  244. package/lib/core/schema-stored/schema.js +9 -0
  245. package/lib/core/schema-stored/schema.js.map +1 -1
  246. package/lib/core/tree/anchorSet.d.ts +1 -2
  247. package/lib/core/tree/anchorSet.d.ts.map +1 -1
  248. package/lib/core/tree/anchorSet.js +2 -2
  249. package/lib/core/tree/anchorSet.js.map +1 -1
  250. package/lib/core/tree/detachedFieldIndex.d.ts.map +1 -1
  251. package/lib/core/tree/detachedFieldIndex.js +13 -2
  252. package/lib/core/tree/detachedFieldIndex.js.map +1 -1
  253. package/lib/core/tree/detachedFieldIndexTypes.d.ts +1 -1
  254. package/lib/core/tree/detachedFieldIndexTypes.js.map +1 -1
  255. package/lib/feature-libraries/editableTreeBinder.d.ts +3 -230
  256. package/lib/feature-libraries/editableTreeBinder.d.ts.map +1 -1
  257. package/lib/feature-libraries/editableTreeBinder.js +1 -532
  258. package/lib/feature-libraries/editableTreeBinder.js.map +1 -1
  259. package/lib/feature-libraries/flex-tree/context.d.ts +7 -14
  260. package/lib/feature-libraries/flex-tree/context.d.ts.map +1 -1
  261. package/lib/feature-libraries/flex-tree/context.js +3 -3
  262. package/lib/feature-libraries/flex-tree/context.js.map +1 -1
  263. package/lib/feature-libraries/flex-tree/flexTreeTypes.d.ts +2 -16
  264. package/lib/feature-libraries/flex-tree/flexTreeTypes.d.ts.map +1 -1
  265. package/lib/feature-libraries/flex-tree/flexTreeTypes.js.map +1 -1
  266. package/lib/feature-libraries/flex-tree/lazyEntity.d.ts +2 -3
  267. package/lib/feature-libraries/flex-tree/lazyEntity.d.ts.map +1 -1
  268. package/lib/feature-libraries/flex-tree/lazyEntity.js +1 -2
  269. package/lib/feature-libraries/flex-tree/lazyEntity.js.map +1 -1
  270. package/lib/feature-libraries/flex-tree/lazyField.d.ts +10 -15
  271. package/lib/feature-libraries/flex-tree/lazyField.d.ts.map +1 -1
  272. package/lib/feature-libraries/flex-tree/lazyField.js +18 -20
  273. package/lib/feature-libraries/flex-tree/lazyField.js.map +1 -1
  274. package/lib/feature-libraries/flex-tree/lazyNode.d.ts +4 -5
  275. package/lib/feature-libraries/flex-tree/lazyNode.d.ts.map +1 -1
  276. package/lib/feature-libraries/flex-tree/lazyNode.js +13 -23
  277. package/lib/feature-libraries/flex-tree/lazyNode.js.map +1 -1
  278. package/lib/feature-libraries/flex-tree/utilities.js +1 -1
  279. package/lib/feature-libraries/flex-tree/utilities.js.map +1 -1
  280. package/lib/feature-libraries/index.d.ts +4 -7
  281. package/lib/feature-libraries/index.d.ts.map +1 -1
  282. package/lib/feature-libraries/index.js +4 -6
  283. package/lib/feature-libraries/index.js.map +1 -1
  284. package/lib/feature-libraries/sequence-field/formatV1.d.ts +18 -18
  285. package/lib/feature-libraries/sequence-field/formatV2.d.ts +18 -18
  286. package/lib/feature-libraries/sequence-field/formatV3.d.ts +27 -27
  287. package/lib/feature-libraries/typed-schema/flexList.d.ts +1 -46
  288. package/lib/feature-libraries/typed-schema/flexList.d.ts.map +1 -1
  289. package/lib/feature-libraries/typed-schema/flexList.js +0 -11
  290. package/lib/feature-libraries/typed-schema/flexList.js.map +1 -1
  291. package/lib/feature-libraries/typed-schema/index.d.ts +2 -4
  292. package/lib/feature-libraries/typed-schema/index.d.ts.map +1 -1
  293. package/lib/feature-libraries/typed-schema/index.js +0 -3
  294. package/lib/feature-libraries/typed-schema/index.js.map +1 -1
  295. package/lib/feature-libraries/typed-schema/typedTreeSchema.d.ts +0 -212
  296. package/lib/feature-libraries/typed-schema/typedTreeSchema.d.ts.map +1 -1
  297. package/lib/feature-libraries/typed-schema/typedTreeSchema.js +1 -253
  298. package/lib/feature-libraries/typed-schema/typedTreeSchema.js.map +1 -1
  299. package/lib/index.d.ts +3 -3
  300. package/lib/index.d.ts.map +1 -1
  301. package/lib/index.js +1 -1
  302. package/lib/index.js.map +1 -1
  303. package/lib/internalTypes.d.ts +1 -1
  304. package/lib/internalTypes.d.ts.map +1 -1
  305. package/lib/internalTypes.js.map +1 -1
  306. package/lib/legacy.d.ts +3 -0
  307. package/lib/packageVersion.d.ts +1 -1
  308. package/lib/packageVersion.js +1 -1
  309. package/lib/packageVersion.js.map +1 -1
  310. package/lib/public.d.ts +3 -0
  311. package/lib/shared-tree/checkoutFlexTreeView.d.ts +3 -3
  312. package/lib/shared-tree/checkoutFlexTreeView.d.ts.map +1 -1
  313. package/lib/shared-tree/checkoutFlexTreeView.js +1 -1
  314. package/lib/shared-tree/checkoutFlexTreeView.js.map +1 -1
  315. package/lib/shared-tree/index.d.ts +3 -3
  316. package/lib/shared-tree/index.d.ts.map +1 -1
  317. package/lib/shared-tree/index.js +1 -2
  318. package/lib/shared-tree/index.js.map +1 -1
  319. package/lib/shared-tree/schematizeTree.d.ts +1 -40
  320. package/lib/shared-tree/schematizeTree.d.ts.map +1 -1
  321. package/lib/shared-tree/schematizeTree.js +1 -9
  322. package/lib/shared-tree/schematizeTree.js.map +1 -1
  323. package/lib/shared-tree/schematizingTreeView.d.ts +8 -7
  324. package/lib/shared-tree/schematizingTreeView.d.ts.map +1 -1
  325. package/lib/shared-tree/schematizingTreeView.js +19 -11
  326. package/lib/shared-tree/schematizingTreeView.js.map +1 -1
  327. package/lib/shared-tree/sharedTree.d.ts +19 -2
  328. package/lib/shared-tree/sharedTree.d.ts.map +1 -1
  329. package/lib/shared-tree/sharedTree.js +10 -3
  330. package/lib/shared-tree/sharedTree.js.map +1 -1
  331. package/lib/shared-tree/treeCheckout.d.ts +71 -41
  332. package/lib/shared-tree/treeCheckout.d.ts.map +1 -1
  333. package/lib/shared-tree/treeCheckout.js +118 -86
  334. package/lib/shared-tree/treeCheckout.js.map +1 -1
  335. package/lib/shared-tree-core/branch.d.ts +8 -11
  336. package/lib/shared-tree-core/branch.d.ts.map +1 -1
  337. package/lib/shared-tree-core/branch.js +12 -15
  338. package/lib/shared-tree-core/branch.js.map +1 -1
  339. package/lib/simple-tree/api/create.d.ts +1 -1
  340. package/lib/simple-tree/api/create.d.ts.map +1 -1
  341. package/lib/simple-tree/api/create.js +14 -16
  342. package/lib/simple-tree/api/create.js.map +1 -1
  343. package/lib/simple-tree/api/getJsonSchema.d.ts +3 -3
  344. package/lib/simple-tree/api/getJsonSchema.d.ts.map +1 -1
  345. package/lib/simple-tree/api/getJsonSchema.js +1 -1
  346. package/lib/simple-tree/api/getJsonSchema.js.map +1 -1
  347. package/lib/simple-tree/api/getSimpleSchema.d.ts +2 -2
  348. package/lib/simple-tree/api/getSimpleSchema.d.ts.map +1 -1
  349. package/lib/simple-tree/api/getSimpleSchema.js.map +1 -1
  350. package/lib/simple-tree/api/index.d.ts +2 -1
  351. package/lib/simple-tree/api/index.d.ts.map +1 -1
  352. package/lib/simple-tree/api/index.js +1 -0
  353. package/lib/simple-tree/api/index.js.map +1 -1
  354. package/lib/simple-tree/api/schemaFactory.d.ts +6 -6
  355. package/lib/simple-tree/api/schemaFactory.d.ts.map +1 -1
  356. package/lib/simple-tree/api/schemaFactory.js +15 -2
  357. package/lib/simple-tree/api/schemaFactory.js.map +1 -1
  358. package/lib/simple-tree/api/schemaFactoryRecursive.d.ts +3 -3
  359. package/lib/simple-tree/api/schemaFactoryRecursive.d.ts.map +1 -1
  360. package/lib/simple-tree/api/schemaFactoryRecursive.js.map +1 -1
  361. package/lib/simple-tree/api/simpleSchema.d.ts +14 -10
  362. package/lib/simple-tree/api/simpleSchema.d.ts.map +1 -1
  363. package/lib/simple-tree/api/simpleSchema.js.map +1 -1
  364. package/lib/simple-tree/api/tree.d.ts +12 -6
  365. package/lib/simple-tree/api/tree.d.ts.map +1 -1
  366. package/lib/simple-tree/api/tree.js +4 -4
  367. package/lib/simple-tree/api/tree.js.map +1 -1
  368. package/lib/simple-tree/api/treeNodeApi.d.ts.map +1 -1
  369. package/lib/simple-tree/api/treeNodeApi.js +10 -8
  370. package/lib/simple-tree/api/treeNodeApi.js.map +1 -1
  371. package/lib/simple-tree/api/verboseTree.d.ts.map +1 -1
  372. package/lib/simple-tree/api/verboseTree.js +6 -10
  373. package/lib/simple-tree/api/verboseTree.js.map +1 -1
  374. package/{dist/feature-libraries/typed-schema → lib/simple-tree/api}/view.d.ts +4 -11
  375. package/lib/simple-tree/api/view.d.ts.map +1 -0
  376. package/lib/{feature-libraries/typed-schema → simple-tree/api}/view.js +9 -9
  377. package/lib/simple-tree/api/view.js.map +1 -0
  378. package/lib/simple-tree/api/viewSchemaToSimpleSchema.d.ts +2 -2
  379. package/lib/simple-tree/api/viewSchemaToSimpleSchema.d.ts.map +1 -1
  380. package/lib/simple-tree/api/viewSchemaToSimpleSchema.js +7 -1
  381. package/lib/simple-tree/api/viewSchemaToSimpleSchema.js.map +1 -1
  382. package/lib/simple-tree/arrayNode.d.ts +147 -14
  383. package/lib/simple-tree/arrayNode.d.ts.map +1 -1
  384. package/lib/simple-tree/arrayNode.js +37 -25
  385. package/lib/simple-tree/arrayNode.js.map +1 -1
  386. package/lib/simple-tree/core/context.d.ts +55 -0
  387. package/lib/simple-tree/core/context.d.ts.map +1 -0
  388. package/lib/simple-tree/core/context.js +55 -0
  389. package/lib/simple-tree/core/context.js.map +1 -0
  390. package/lib/simple-tree/core/getOrCreateNode.d.ts +15 -0
  391. package/lib/simple-tree/core/getOrCreateNode.d.ts.map +1 -0
  392. package/lib/simple-tree/core/getOrCreateNode.js +32 -0
  393. package/lib/simple-tree/core/getOrCreateNode.js.map +1 -0
  394. package/lib/simple-tree/core/index.d.ts +7 -3
  395. package/lib/simple-tree/core/index.d.ts.map +1 -1
  396. package/lib/simple-tree/core/index.js +6 -2
  397. package/lib/simple-tree/core/index.js.map +1 -1
  398. package/lib/simple-tree/core/schemaCaching.d.ts +5 -13
  399. package/lib/simple-tree/core/schemaCaching.d.ts.map +1 -1
  400. package/lib/simple-tree/core/schemaCaching.js +13 -39
  401. package/lib/simple-tree/core/schemaCaching.js.map +1 -1
  402. package/lib/simple-tree/core/treeNodeKernel.d.ts +29 -7
  403. package/lib/simple-tree/core/treeNodeKernel.d.ts.map +1 -1
  404. package/lib/simple-tree/core/treeNodeKernel.js +89 -54
  405. package/lib/simple-tree/core/treeNodeKernel.js.map +1 -1
  406. package/lib/simple-tree/core/treeNodeSchema.d.ts +24 -0
  407. package/lib/simple-tree/core/treeNodeSchema.d.ts.map +1 -1
  408. package/lib/simple-tree/core/treeNodeSchema.js.map +1 -1
  409. package/lib/simple-tree/core/types.d.ts +0 -5
  410. package/lib/simple-tree/core/types.d.ts.map +1 -1
  411. package/lib/simple-tree/core/types.js.map +1 -1
  412. package/lib/simple-tree/core/unhydratedFlexTree.d.ts +139 -0
  413. package/lib/simple-tree/core/unhydratedFlexTree.d.ts.map +1 -0
  414. package/lib/{feature-libraries/flex-map-tree/mapTreeNode.js → simple-tree/core/unhydratedFlexTree.js} +110 -128
  415. package/lib/simple-tree/core/unhydratedFlexTree.js.map +1 -0
  416. package/lib/simple-tree/{walkSchema.d.ts → core/walkSchema.d.ts} +8 -4
  417. package/lib/simple-tree/core/walkSchema.d.ts.map +1 -0
  418. package/lib/simple-tree/core/walkSchema.js +29 -0
  419. package/lib/simple-tree/core/walkSchema.js.map +1 -0
  420. package/lib/simple-tree/createContext.d.ts +11 -0
  421. package/lib/simple-tree/createContext.d.ts.map +1 -0
  422. package/lib/simple-tree/createContext.js +21 -0
  423. package/lib/simple-tree/createContext.js.map +1 -0
  424. package/lib/simple-tree/index.d.ts +3 -4
  425. package/lib/simple-tree/index.d.ts.map +1 -1
  426. package/lib/simple-tree/index.js +3 -4
  427. package/lib/simple-tree/index.js.map +1 -1
  428. package/lib/simple-tree/leafNodeSchema.d.ts +1 -0
  429. package/lib/simple-tree/leafNodeSchema.d.ts.map +1 -1
  430. package/lib/simple-tree/leafNodeSchema.js +3 -4
  431. package/lib/simple-tree/leafNodeSchema.js.map +1 -1
  432. package/lib/simple-tree/mapNode.d.ts +4 -4
  433. package/lib/simple-tree/mapNode.d.ts.map +1 -1
  434. package/lib/simple-tree/mapNode.js +12 -8
  435. package/lib/simple-tree/mapNode.js.map +1 -1
  436. package/lib/simple-tree/objectNode.d.ts +8 -8
  437. package/lib/simple-tree/objectNode.d.ts.map +1 -1
  438. package/lib/simple-tree/objectNode.js +36 -17
  439. package/lib/simple-tree/objectNode.js.map +1 -1
  440. package/lib/simple-tree/objectNodeTypes.d.ts +7 -3
  441. package/lib/simple-tree/objectNodeTypes.d.ts.map +1 -1
  442. package/lib/simple-tree/objectNodeTypes.js.map +1 -1
  443. package/lib/simple-tree/proxies.d.ts +1 -2
  444. package/lib/simple-tree/proxies.d.ts.map +1 -1
  445. package/lib/simple-tree/proxies.js +7 -22
  446. package/lib/simple-tree/proxies.js.map +1 -1
  447. package/lib/simple-tree/schemaTypes.d.ts +2 -2
  448. package/lib/simple-tree/schemaTypes.d.ts.map +1 -1
  449. package/lib/simple-tree/schemaTypes.js.map +1 -1
  450. package/lib/simple-tree/toFlexSchema.d.ts +6 -36
  451. package/lib/simple-tree/toFlexSchema.d.ts.map +1 -1
  452. package/lib/simple-tree/toFlexSchema.js +61 -142
  453. package/lib/simple-tree/toFlexSchema.js.map +1 -1
  454. package/lib/simple-tree/toMapTree.d.ts.map +1 -1
  455. package/lib/simple-tree/toMapTree.js +4 -4
  456. package/lib/simple-tree/toMapTree.js.map +1 -1
  457. package/lib/simple-tree/treeNodeValid.d.ts +13 -5
  458. package/lib/simple-tree/treeNodeValid.d.ts.map +1 -1
  459. package/lib/simple-tree/treeNodeValid.js +21 -12
  460. package/lib/simple-tree/treeNodeValid.js.map +1 -1
  461. package/lib/simple-tree/typesUnsafe.d.ts +4 -4
  462. package/lib/simple-tree/typesUnsafe.d.ts.map +1 -1
  463. package/lib/simple-tree/typesUnsafe.js.map +1 -1
  464. package/lib/simple-tree/walkFieldSchema.d.ts +11 -0
  465. package/lib/simple-tree/walkFieldSchema.d.ts.map +1 -0
  466. package/lib/simple-tree/walkFieldSchema.js +13 -0
  467. package/lib/simple-tree/walkFieldSchema.js.map +1 -0
  468. package/lib/util/index.d.ts +1 -1
  469. package/lib/util/index.d.ts.map +1 -1
  470. package/lib/util/index.js.map +1 -1
  471. package/lib/util/typeUtils.d.ts +14 -45
  472. package/lib/util/typeUtils.d.ts.map +1 -1
  473. package/lib/util/typeUtils.js.map +1 -1
  474. package/package.json +29 -20
  475. package/src/core/schema-stored/schema.ts +17 -0
  476. package/src/core/tree/anchorSet.ts +3 -4
  477. package/src/core/tree/detachedFieldIndex.ts +14 -3
  478. package/src/core/tree/detachedFieldIndexTypes.ts +1 -1
  479. package/src/feature-libraries/editableTreeBinder.ts +2 -915
  480. package/src/feature-libraries/flex-tree/context.ts +7 -20
  481. package/src/feature-libraries/flex-tree/flexTreeTypes.ts +2 -18
  482. package/src/feature-libraries/flex-tree/lazyEntity.ts +1 -4
  483. package/src/feature-libraries/flex-tree/lazyField.ts +22 -78
  484. package/src/feature-libraries/flex-tree/lazyNode.ts +24 -39
  485. package/src/feature-libraries/flex-tree/utilities.ts +1 -1
  486. package/src/feature-libraries/index.ts +3 -71
  487. package/src/feature-libraries/typed-schema/flexList.ts +3 -84
  488. package/src/feature-libraries/typed-schema/index.ts +1 -33
  489. package/src/feature-libraries/typed-schema/typedTreeSchema.ts +0 -458
  490. package/src/index.ts +6 -0
  491. package/src/internalTypes.ts +0 -1
  492. package/src/packageVersion.ts +1 -1
  493. package/src/shared-tree/checkoutFlexTreeView.ts +3 -3
  494. package/src/shared-tree/index.ts +4 -8
  495. package/src/shared-tree/schematizeTree.ts +2 -56
  496. package/src/shared-tree/schematizingTreeView.ts +34 -15
  497. package/src/shared-tree/sharedTree.ts +36 -8
  498. package/src/shared-tree/treeCheckout.ts +225 -128
  499. package/src/shared-tree-core/branch.ts +15 -26
  500. package/src/simple-tree/api/create.ts +18 -20
  501. package/src/simple-tree/api/getJsonSchema.ts +3 -3
  502. package/src/simple-tree/api/getSimpleSchema.ts +2 -2
  503. package/src/simple-tree/api/index.ts +2 -0
  504. package/src/simple-tree/api/schemaFactory.ts +41 -12
  505. package/src/simple-tree/api/schemaFactoryRecursive.ts +3 -6
  506. package/src/simple-tree/api/simpleSchema.ts +15 -10
  507. package/src/simple-tree/api/tree.ts +15 -9
  508. package/src/simple-tree/api/treeNodeApi.ts +12 -10
  509. package/src/simple-tree/api/verboseTree.ts +6 -12
  510. package/src/{feature-libraries/typed-schema → simple-tree/api}/view.ts +9 -22
  511. package/src/simple-tree/api/viewSchemaToSimpleSchema.ts +11 -2
  512. package/src/simple-tree/arrayNode.ts +202 -53
  513. package/src/simple-tree/core/context.ts +78 -0
  514. package/src/simple-tree/core/getOrCreateNode.ts +38 -0
  515. package/src/simple-tree/core/index.ts +11 -7
  516. package/src/simple-tree/core/schemaCaching.ts +13 -50
  517. package/src/simple-tree/core/treeNodeKernel.ts +117 -78
  518. package/src/simple-tree/core/treeNodeSchema.ts +35 -1
  519. package/src/simple-tree/core/types.ts +0 -5
  520. package/src/{feature-libraries/flex-map-tree/mapTreeNode.ts → simple-tree/core/unhydratedFlexTree.ts} +167 -210
  521. package/src/simple-tree/{walkSchema.ts → core/walkSchema.ts} +12 -34
  522. package/src/simple-tree/createContext.ts +24 -0
  523. package/src/simple-tree/index.ts +5 -2
  524. package/src/simple-tree/leafNodeSchema.ts +3 -9
  525. package/src/simple-tree/mapNode.ts +20 -17
  526. package/src/simple-tree/objectNode.ts +63 -38
  527. package/src/simple-tree/objectNodeTypes.ts +8 -5
  528. package/src/simple-tree/proxies.ts +8 -26
  529. package/src/simple-tree/schemaTypes.ts +2 -2
  530. package/src/simple-tree/toFlexSchema.ts +71 -204
  531. package/src/simple-tree/toMapTree.ts +5 -5
  532. package/src/simple-tree/treeNodeValid.ts +28 -22
  533. package/src/simple-tree/typesUnsafe.ts +4 -4
  534. package/src/simple-tree/walkFieldSchema.ts +19 -0
  535. package/src/util/index.ts +1 -5
  536. package/src/util/typeUtils.ts +14 -56
  537. package/dist/feature-libraries/fieldGenerator.d.ts +0 -43
  538. package/dist/feature-libraries/fieldGenerator.d.ts.map +0 -1
  539. package/dist/feature-libraries/fieldGenerator.js +0 -13
  540. package/dist/feature-libraries/fieldGenerator.js.map +0 -1
  541. package/dist/feature-libraries/flex-map-tree/index.d.ts +0 -6
  542. package/dist/feature-libraries/flex-map-tree/index.d.ts.map +0 -1
  543. package/dist/feature-libraries/flex-map-tree/index.js +0 -14
  544. package/dist/feature-libraries/flex-map-tree/index.js.map +0 -1
  545. package/dist/feature-libraries/flex-map-tree/mapTreeNode.d.ts +0 -157
  546. package/dist/feature-libraries/flex-map-tree/mapTreeNode.d.ts.map +0 -1
  547. package/dist/feature-libraries/flex-map-tree/mapTreeNode.js.map +0 -1
  548. package/dist/feature-libraries/storedToViewSchema.d.ts +0 -17
  549. package/dist/feature-libraries/storedToViewSchema.d.ts.map +0 -1
  550. package/dist/feature-libraries/storedToViewSchema.js +0 -67
  551. package/dist/feature-libraries/storedToViewSchema.js.map +0 -1
  552. package/dist/feature-libraries/typed-schema/schemaCollection.d.ts +0 -58
  553. package/dist/feature-libraries/typed-schema/schemaCollection.d.ts.map +0 -1
  554. package/dist/feature-libraries/typed-schema/schemaCollection.js +0 -160
  555. package/dist/feature-libraries/typed-schema/schemaCollection.js.map +0 -1
  556. package/dist/feature-libraries/typed-schema/typeUtils.d.ts +0 -15
  557. package/dist/feature-libraries/typed-schema/typeUtils.d.ts.map +0 -1
  558. package/dist/feature-libraries/typed-schema/typeUtils.js +0 -14
  559. package/dist/feature-libraries/typed-schema/typeUtils.js.map +0 -1
  560. package/dist/feature-libraries/typed-schema/view.d.ts.map +0 -1
  561. package/dist/feature-libraries/typed-schema/view.js.map +0 -1
  562. package/dist/simple-tree/getSimpleFieldSchema.d.ts +0 -14
  563. package/dist/simple-tree/getSimpleFieldSchema.d.ts.map +0 -1
  564. package/dist/simple-tree/getSimpleFieldSchema.js +0 -29
  565. package/dist/simple-tree/getSimpleFieldSchema.js.map +0 -1
  566. package/dist/simple-tree/walkSchema.d.ts.map +0 -1
  567. package/dist/simple-tree/walkSchema.js +0 -49
  568. package/dist/simple-tree/walkSchema.js.map +0 -1
  569. package/lib/feature-libraries/fieldGenerator.d.ts +0 -43
  570. package/lib/feature-libraries/fieldGenerator.d.ts.map +0 -1
  571. package/lib/feature-libraries/fieldGenerator.js +0 -12
  572. package/lib/feature-libraries/fieldGenerator.js.map +0 -1
  573. package/lib/feature-libraries/flex-map-tree/index.d.ts +0 -6
  574. package/lib/feature-libraries/flex-map-tree/index.d.ts.map +0 -1
  575. package/lib/feature-libraries/flex-map-tree/index.js +0 -6
  576. package/lib/feature-libraries/flex-map-tree/index.js.map +0 -1
  577. package/lib/feature-libraries/flex-map-tree/mapTreeNode.d.ts +0 -157
  578. package/lib/feature-libraries/flex-map-tree/mapTreeNode.d.ts.map +0 -1
  579. package/lib/feature-libraries/flex-map-tree/mapTreeNode.js.map +0 -1
  580. package/lib/feature-libraries/storedToViewSchema.d.ts +0 -17
  581. package/lib/feature-libraries/storedToViewSchema.d.ts.map +0 -1
  582. package/lib/feature-libraries/storedToViewSchema.js +0 -62
  583. package/lib/feature-libraries/storedToViewSchema.js.map +0 -1
  584. package/lib/feature-libraries/typed-schema/schemaCollection.d.ts +0 -58
  585. package/lib/feature-libraries/typed-schema/schemaCollection.d.ts.map +0 -1
  586. package/lib/feature-libraries/typed-schema/schemaCollection.js +0 -153
  587. package/lib/feature-libraries/typed-schema/schemaCollection.js.map +0 -1
  588. package/lib/feature-libraries/typed-schema/typeUtils.d.ts +0 -15
  589. package/lib/feature-libraries/typed-schema/typeUtils.d.ts.map +0 -1
  590. package/lib/feature-libraries/typed-schema/typeUtils.js +0 -10
  591. package/lib/feature-libraries/typed-schema/typeUtils.js.map +0 -1
  592. package/lib/feature-libraries/typed-schema/view.d.ts.map +0 -1
  593. package/lib/feature-libraries/typed-schema/view.js.map +0 -1
  594. package/lib/simple-tree/getSimpleFieldSchema.d.ts +0 -14
  595. package/lib/simple-tree/getSimpleFieldSchema.d.ts.map +0 -1
  596. package/lib/simple-tree/getSimpleFieldSchema.js +0 -25
  597. package/lib/simple-tree/getSimpleFieldSchema.js.map +0 -1
  598. package/lib/simple-tree/walkSchema.d.ts.map +0 -1
  599. package/lib/simple-tree/walkSchema.js +0 -43
  600. package/lib/simple-tree/walkSchema.js.map +0 -1
  601. package/src/feature-libraries/fieldGenerator.ts +0 -47
  602. package/src/feature-libraries/flex-map-tree/index.ts +0 -14
  603. package/src/feature-libraries/storedToViewSchema.ts +0 -100
  604. package/src/feature-libraries/typed-schema/schemaCollection.ts +0 -254
  605. package/src/feature-libraries/typed-schema/typeUtils.ts +0 -29
  606. package/src/simple-tree/getSimpleFieldSchema.ts +0 -36
@@ -0,0 +1 @@
1
+ {"version":3,"file":"view.js","sourceRoot":"","sources":["../../../src/simple-tree/api/view.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,iBAAiB,EAEjB,aAAa,GAKb,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAC3C,OAAO,EAEN,kBAAkB,EAClB,WAAW,GACX,MAAM,kCAAkC,CAAC;AAE1C;;GAEG;AACH,MAAM,OAAO,UAAU;IACtB;;OAEG;IACH,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K,CAAC,GAAG,CAAC,WAAW,CAAC,KAAK,CAAC,EAAE,CAAC;oBAClC,KAAK,CAAC,MAAM,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;oBAChC,KAAK,CAAC,GAAG,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;gBAC/B,CAAC;YACF,CAAC;YAED,OAAO,EAAE,IAAI,EAAE,QAAQ,CAAC,IAAI,EAAE,KAAK,EAAE,CAAC;QACvC,CAAC;QACD,OAAO,QAAQ,CAAC;IACjB,CAAC;IAEO,SAAS,CAAC,QAA8B;QAC/C,sDAAsD;QACtD,OAAO,QAAQ,CAAC;IACjB,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\tAdaptedViewSchema,\n\ttype Adapters,\n\tCompatibility,\n\ttype TreeFieldStoredSchema,\n\ttype TreeNodeSchemaIdentifier,\n\ttype TreeNodeStoredSchema,\n\ttype TreeStoredSchema,\n} from \"../../core/index.js\";\nimport { fail } from \"../../util/index.js\";\nimport {\n\ttype FullSchemaPolicy,\n\tallowsRepoSuperset,\n\tisNeverTree,\n} from \"../../feature-libraries/index.js\";\n\n/**\n * A collection of View information for schema, including policy.\n */\nexport class ViewSchema {\n\t/**\n\t * @param schema - Cached conversion of view schema in the stored schema format.\n\t */\n\tpublic constructor(\n\t\tpublic readonly policy: FullSchemaPolicy,\n\t\tpublic readonly adapters: Adapters,\n\t\tpublic readonly schema: TreeStoredSchema,\n\t) {}\n\n\t/**\n\t * Determines the compatibility of a stored document\n\t * (based on its stored schema) with a viewer (based on its view schema).\n\t *\n\t * Adapters can be provided to handle differences between the two schema.\n\t * Adapters should only use to types in the `view` SchemaRepository.\n\t *\n\t * TODO: this API violates the parse don't validate design philosophy.\n\t * It should be wrapped with (or replaced by) a parse style API.\n\t */\n\tpublic checkCompatibility(stored: TreeStoredSchema): {\n\t\tread: Compatibility;\n\t\twrite: Compatibility;\n\t\twriteAllowingStoredSchemaUpdates: Compatibility;\n\t} {\n\t\t// TODO: support adapters\n\t\t// const adapted = this.adaptRepo(stored);\n\n\t\tconst read = allowsRepoSuperset(this.policy, stored, this.schema)\n\t\t\t? Compatibility.Compatible\n\t\t\t: // TODO: support adapters\n\t\t\t\t// : allowsRepoSuperset(this.policy, adapted.adaptedForViewSchema, this.storedSchema)\n\t\t\t\t// ? Compatibility.RequiresAdapters\n\t\t\t\tCompatibility.Incompatible;\n\t\t// TODO: Extract subset of adapters that are valid to use on stored\n\t\t// TODO: separate adapters from schema updates\n\t\tconst write = allowsRepoSuperset(this.policy, this.schema, stored)\n\t\t\t? Compatibility.Compatible\n\t\t\t: // TODO: support adapters\n\t\t\t\t// : allowsRepoSuperset(this.policy, this.storedSchema, adapted.adaptedForViewSchema)\n\t\t\t\t// TODO: IThis assumes adapters are bidirectional.\n\t\t\t\t// Compatibility.RequiresAdapters\n\t\t\t\tCompatibility.Incompatible;\n\n\t\t// TODO: compute this properly (and maybe include the set of schema changes needed for it?).\n\t\t// Maybe updates would happen lazily when needed to store data?\n\t\t// When willingness to updates can avoid need for some adapters,\n\t\t// how should it be decided if the adapter should be used to avoid the update?\n\t\t// TODO: is this case actually bi-variant, making this correct if we did it for each schema independently?\n\t\tlet writeAllowingStoredSchemaUpdates =\n\t\t\t// TODO: This should consider just the updates needed\n\t\t\t// (ex: when view covers a subset of stored after stored has a update to that subset).\n\t\t\tallowsRepoSuperset(this.policy, stored, this.schema)\n\t\t\t\t? Compatibility.Compatible\n\t\t\t\t: // TODO: this assumes adapters can translate in both directions. In general this will not be true.\n\t\t\t\t\t// TODO: this also assumes that schema updates to the adapted repo would translate to\n\t\t\t\t\t// updates on the stored schema, which is also likely untrue.\n\t\t\t\t\t// // TODO: support adapters\n\t\t\t\t\t// allowsRepoSuperset(this.policy, adapted.adaptedForViewSchema, this.storedSchema)\n\t\t\t\t\t// ? Compatibility.RequiresAdapters // Requires schema updates. TODO: consider adapters that can update writes.\n\t\t\t\t\tCompatibility.Incompatible;\n\n\t\t// Since the above does not consider partial updates,\n\t\t// we can improve the tolerance a bit by considering the op-op update:\n\t\twriteAllowingStoredSchemaUpdates = Math.max(writeAllowingStoredSchemaUpdates, write);\n\n\t\treturn { read, write, writeAllowingStoredSchemaUpdates };\n\t}\n\n\t/**\n\t * Compute a schema that `original` could be viewed as using adapters as needed.\n\t *\n\t * TODO: have a way for callers to get invalidated on schema updates.\n\t */\n\tpublic adaptRepo(stored: TreeStoredSchema): AdaptedViewSchema {\n\t\t// Sanity check on adapters:\n\t\t// it's probably a bug if they use the never types,\n\t\t// since there never is a reason to have a never type as an adapter input,\n\t\t// and its impossible for an adapter to be correctly implemented if its output type is never\n\t\t// (unless its input is also never).\n\t\tfor (const adapter of this.adapters?.tree ?? []) {\n\t\t\tif (isNeverTree(this.policy, this.schema, this.schema.nodeSchema.get(adapter.output))) {\n\t\t\t\tfail(\"tree adapter for stored adapter.output should not be never\");\n\t\t\t}\n\t\t}\n\n\t\tconst adapted = {\n\t\t\trootFieldSchema: this.adaptField(stored.rootFieldSchema),\n\t\t\tnodeSchema: new Map<TreeNodeSchemaIdentifier, TreeNodeStoredSchema>(),\n\t\t};\n\n\t\tfor (const [key, schema] of stored.nodeSchema) {\n\t\t\tconst adapatedTree = this.adaptTree(schema);\n\t\t\tadapted.nodeSchema.set(key, adapatedTree);\n\t\t}\n\n\t\t// TODO: subset these adapters to the ones that were needed/used.\n\t\treturn new AdaptedViewSchema(this.adapters, adapted);\n\t}\n\n\t/**\n\t * Adapt original such that it allows member types which can be adapted to its specified types.\n\t */\n\tprivate adaptField(original: TreeFieldStoredSchema): TreeFieldStoredSchema {\n\t\tif (original.types !== undefined) {\n\t\t\tconst types: Set<TreeNodeSchemaIdentifier> = new Set(original.types);\n\t\t\tfor (const treeAdapter of this.adapters?.tree ?? []) {\n\t\t\t\tif (types.has(treeAdapter.input)) {\n\t\t\t\t\ttypes.delete(treeAdapter.input);\n\t\t\t\t\ttypes.add(treeAdapter.output);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn { kind: original.kind, types };\n\t\t}\n\t\treturn original;\n\t}\n\n\tprivate adaptTree(original: TreeNodeStoredSchema): TreeNodeStoredSchema {\n\t\t// TODO: support adapters like missing field adapters.\n\t\treturn original;\n\t}\n}\n"]}
@@ -2,10 +2,10 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
- import { type ImplicitAllowedTypes } from "../schemaTypes.js";
5
+ import { type ImplicitFieldSchema } from "../schemaTypes.js";
6
6
  import type { SimpleTreeSchema } from "./simpleSchema.js";
7
7
  /**
8
8
  * Converts a "view" schema to a "simple" schema representation.
9
9
  */
10
- export declare function toSimpleTreeSchema(schema: ImplicitAllowedTypes): SimpleTreeSchema;
10
+ export declare function toSimpleTreeSchema(schema: ImplicitFieldSchema): SimpleTreeSchema;
11
11
  //# sourceMappingURL=viewSchemaToSimpleSchema.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"viewSchemaToSimpleSchema.d.ts","sourceRoot":"","sources":["../../../src/simple-tree/api/viewSchemaToSimpleSchema.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAGN,KAAK,oBAAoB,EACzB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAOX,gBAAgB,EAChB,MAAM,mBAAmB,CAAC;AAM3B;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,oBAAoB,GAAG,gBAAgB,CAYjF"}
1
+ {"version":3,"file":"viewSchemaToSimpleSchema.d.ts","sourceRoot":"","sources":["../../../src/simple-tree/api/viewSchemaToSimpleSchema.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAIN,KAAK,mBAAmB,EACxB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAOX,gBAAgB,EAChB,MAAM,mBAAmB,CAAC;AAM3B;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,mBAAmB,GAAG,gBAAgB,CAoBhF"}
@@ -15,10 +15,16 @@ export function toSimpleTreeSchema(schema) {
15
15
  const allowedTypes = allowedTypesFromFieldSchema(normalizedSchema);
16
16
  const definitions = new Map();
17
17
  populateSchemaDefinitionsForField(normalizedSchema, definitions);
18
- return {
18
+ const output = {
19
+ kind: normalizedSchema.kind,
19
20
  allowedTypes,
20
21
  definitions,
21
22
  };
23
+ // Include the "description" property only if it's present on the input.
24
+ if (normalizedSchema.metadata?.description !== undefined) {
25
+ output.description = normalizedSchema.metadata.description;
26
+ }
27
+ return output;
22
28
  }
23
29
  /**
24
30
  * Cache in which the results of {@link toSimpleNodeSchema} are saved.
@@ -1 +1 @@
1
- {"version":3,"file":"viewSchemaToSimpleSchema.js","sourceRoot":"","sources":["../../../src/simple-tree/api/viewSchemaToSimpleSchema.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAC;AAC9E,OAAO,EACN,oBAAoB,GAGpB,MAAM,mBAAmB,CAAC;AAW3B,OAAO,EAAE,WAAW,EAAgB,MAAM,qBAAqB,CAAC;AAChE,OAAO,EAAE,kBAAkB,EAAyB,MAAM,uBAAuB,CAAC;AAClF,OAAO,EAAE,QAAQ,EAAuB,MAAM,kBAAkB,CAAC;AAEjE;;GAEG;AACH,MAAM,UAAU,kBAAkB,CAAC,MAA4B;IAC9D,MAAM,gBAAgB,GAAG,oBAAoB,CAAC,MAAM,CAAC,CAAC;IAEtD,MAAM,YAAY,GAAG,2BAA2B,CAAC,gBAAgB,CAAC,CAAC;IAEnE,MAAM,WAAW,GAAG,IAAI,GAAG,EAA4B,CAAC;IACxD,iCAAiC,CAAC,gBAAgB,EAAE,WAAW,CAAC,CAAC;IAEjE,OAAO;QACN,YAAY;QACZ,WAAW;KACX,CAAC;AACH,CAAC;AAED;;GAEG;AACH,MAAM,qBAAqB,GAAG,IAAI,OAAO,EAAoC,CAA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,WAAW,GAAG,oBAAoB,CAAC,MAAM,CAAC,IAA4B,CAAC,CAAC;YAC9E,iCAAiC,CAAC,WAAW,EAAE,WAAW,CAAC,CAAC;YAC5D,MAAM;QACP,CAAC;QACD,KAAK,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC;YACtB,MAAM,CAAC,kBAAkB,CAAC,MAAM,CAAC,EAAE,KAAK,CAAC,4BAA4B,CAAC,CAAC;YACvE,KAAK,MAAM,CAAC,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC;gBACvC,iCAAiC,CAAC,KAAK,EAAE,WAAW,CAAC,CAAC;YACvD,CAAC;YACD,MAAM;QACP,CAAC;QACD,OAAO,CAAC,CAAC,CAAC;YACT,eAAe,CAAC,IAAI,CAAC,CAAC;QACvB,CAAC;IACF,CAAC;AACF,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, unreachableCase } from \"@fluidframework/core-utils/internal\";\nimport {\n\tnormalizeFieldSchema,\n\ttype FieldSchema,\n\ttype ImplicitAllowedTypes,\n} from \"../schemaTypes.js\";\nimport type {\n\tSimpleArrayNodeSchema,\n\tSimpleFieldSchema,\n\tSimpleLeafNodeSchema,\n\tSimpleMapNodeSchema,\n\tSimpleNodeSchema,\n\tSimpleObjectNodeSchema,\n\tSimpleTreeSchema,\n} from \"./simpleSchema.js\";\nimport type { ValueSchema } from \"../../core/index.js\";\nimport { getOrCreate, type Mutable } from \"../../util/index.js\";\nimport { isObjectNodeSchema, type ObjectNodeSchema } from \"../objectNodeTypes.js\";\nimport { NodeKind, type TreeNodeSchema } from \"../core/index.js\";\n\n/**\n * Converts a \"view\" schema to a \"simple\" schema representation.\n */\nexport function toSimpleTreeSchema(schema: ImplicitAllowedTypes): SimpleTreeSchema {\n\tconst normalizedSchema = normalizeFieldSchema(schema);\n\n\tconst allowedTypes = allowedTypesFromFieldSchema(normalizedSchema);\n\n\tconst definitions = new Map<string, SimpleNodeSchema>();\n\tpopulateSchemaDefinitionsForField(normalizedSchema, definitions);\n\n\treturn {\n\t\tallowedTypes,\n\t\tdefinitions,\n\t};\n}\n\n/**\n * Cache in which the results of {@link toSimpleNodeSchema} are saved.\n */\nconst simpleNodeSchemaCache = new WeakMap<TreeNodeSchema, SimpleNodeSchema>();\n\n/**\n * Creates a {@link SimpleNodeSchema} from a {@link TreeNodeSchema}.\n *\n * @remarks Caches the result on the input schema for future calls.\n */\nfunction toSimpleNodeSchema(schema: TreeNodeSchema): SimpleNodeSchema {\n\treturn getOrCreate(simpleNodeSchemaCache, schema, () => {\n\t\tconst kind = schema.kind;\n\t\tswitch (kind) {\n\t\t\tcase NodeKind.Leaf: {\n\t\t\t\treturn leafSchemaToSimpleSchema(schema);\n\t\t\t}\n\t\t\tcase NodeKind.Map: {\n\t\t\t\treturn mapSchemaToSimpleSchema(schema);\n\t\t\t}\n\t\t\tcase NodeKind.Array: {\n\t\t\t\treturn arraySchemaToSimpleSchema(schema);\n\t\t\t}\n\t\t\tcase NodeKind.Object: {\n\t\t\t\tassert(isObjectNodeSchema(schema), 0xa06 /* Expected object schema */);\n\t\t\t\treturn objectSchemaToSimpleSchema(schema);\n\t\t\t}\n\t\t\tdefault: {\n\t\t\t\tunreachableCase(kind);\n\t\t\t}\n\t\t}\n\t});\n}\n\n// TODO: Use a stronger type for leaf schemas once one is available (see object schema handler for an example).\nfunction leafSchemaToSimpleSchema(schema: TreeNodeSchema): SimpleLeafNodeSchema {\n\treturn {\n\t\tkind: NodeKind.Leaf,\n\t\tleafKind: schema.info as ValueSchema,\n\t};\n}\n\n// TODO: Use a stronger type for array schemas once one is available (see object schema handler for an example).\nfunction arraySchemaToSimpleSchema(schema: TreeNodeSchema): SimpleArrayNodeSchema {\n\tconst fieldSchema = normalizeFieldSchema(schema.info as ImplicitAllowedTypes);\n\tconst allowedTypes = allowedTypesFromFieldSchema(fieldSchema);\n\treturn {\n\t\tkind: NodeKind.Array,\n\t\tallowedTypes,\n\t};\n}\n\n// TODO: Use a stronger type for map schemas once one is available (see object schema handler for an example).\nfunction mapSchemaToSimpleSchema(schema: TreeNodeSchema): SimpleMapNodeSchema {\n\tconst fieldSchema = normalizeFieldSchema(schema.info as ImplicitAllowedTypes);\n\tconst allowedTypes = allowedTypesFromFieldSchema(fieldSchema);\n\treturn {\n\t\tkind: NodeKind.Map,\n\t\tallowedTypes,\n\t};\n}\n\nfunction objectSchemaToSimpleSchema(schema: ObjectNodeSchema): SimpleObjectNodeSchema {\n\tconst fields: Record<string, SimpleFieldSchema> = {};\n\tfor (const [key, field] of schema.fields) {\n\t\tfields[key] = fieldSchemaToSimpleSchema(field);\n\t}\n\treturn {\n\t\tkind: NodeKind.Object,\n\t\tfields,\n\t};\n}\n\n/**\n * Private symbol under which the results of {@link toSimpleNodeSchema} are cached on an input {@link TreeNodeSchema}.\n */\nconst simpleFieldSchemaCacheSymbol = Symbol(\"simpleFieldSchemaCache\");\n\nfunction fieldSchemaToSimpleSchema(schema: FieldSchema): SimpleFieldSchema {\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tif ((schema as any)[simpleFieldSchemaCacheSymbol] !== undefined) {\n\t\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t\treturn (schema as any)[simpleFieldSchemaCacheSymbol] as SimpleFieldSchema;\n\t}\n\n\tconst allowedTypes = allowedTypesFromFieldSchema(schema);\n\tconst result: Mutable<SimpleFieldSchema> = {\n\t\tkind: schema.kind,\n\t\tallowedTypes,\n\t};\n\n\t// Don't include \"description\" property at all if it's not present.\n\tif (schema.metadata?.description !== undefined) {\n\t\tresult.description = schema.metadata.description;\n\t}\n\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t(schema as any)[simpleFieldSchemaCacheSymbol] = result;\n\n\treturn result;\n}\n\nfunction allowedTypesFromFieldSchema(schema: FieldSchema): Set<string> {\n\tconst allowedTypes = new Set<string>();\n\tfor (const type of schema.allowedTypeSet) {\n\t\tallowedTypes.add(type.identifier);\n\t}\n\treturn allowedTypes;\n}\n\n/**\n * Recursively populates `definitions` by walking the input field schema tree.\n */\nfunction populateSchemaDefinitionsForField(\n\tschema: FieldSchema,\n\tdefinitions: Map<string, SimpleNodeSchema>,\n): void {\n\tfor (const child of schema.allowedTypeSet) {\n\t\tpopulateSchemaDefinitionsForNode(child, definitions);\n\t}\n}\n\n/**\n * Recursively populates `definitions` by walking the input node schema tree.\n */\nfunction populateSchemaDefinitionsForNode(\n\tschema: TreeNodeSchema,\n\tdefinitions: Map<string, SimpleNodeSchema>,\n): void {\n\tif (definitions.has(schema.identifier)) {\n\t\t// If the definition has already been populated, no need to recurse.\n\t\treturn;\n\t}\n\n\t// Populate definition for this schema\n\tdefinitions.set(schema.identifier, toSimpleNodeSchema(schema));\n\n\t// Recurse into children to populate definitions for them\n\tconst kind = schema.kind;\n\tswitch (kind) {\n\t\tcase NodeKind.Leaf: {\n\t\t\t// Leaf node, so no need to recurse\n\t\t\tbreak;\n\t\t}\n\t\tcase NodeKind.Map: {\n\t\t\t// TODO: Utilize a map schema type-guard once one exists (see object case for an example).\n\n\t\t\t// Recursively populate definitions for allowed map children\n\t\t\tconst fieldSchema = normalizeFieldSchema(schema.info as ImplicitAllowedTypes);\n\t\t\tpopulateSchemaDefinitionsForField(fieldSchema, definitions);\n\t\t\tbreak;\n\t\t}\n\t\tcase NodeKind.Array: {\n\t\t\t// TODO: Utilize an array schema type-guard once one exists (see object case for an example).\n\n\t\t\t// Recursively populate definitions for allowed map children\n\t\t\tconst fieldSchema = normalizeFieldSchema(schema.info as ImplicitAllowedTypes);\n\t\t\tpopulateSchemaDefinitionsForField(fieldSchema, definitions);\n\t\t\tbreak;\n\t\t}\n\t\tcase NodeKind.Object: {\n\t\t\tassert(isObjectNodeSchema(schema), 0xa07 /* Expected object schema */);\n\t\t\tfor (const [, field] of schema.fields) {\n\t\t\t\tpopulateSchemaDefinitionsForField(field, definitions);\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t\tdefault: {\n\t\t\tunreachableCase(kind);\n\t\t}\n\t}\n}\n"]}
1
+ {"version":3,"file":"viewSchemaToSimpleSchema.js","sourceRoot":"","sources":["../../../src/simple-tree/api/viewSchemaToSimpleSchema.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAC;AAC9E,OAAO,EACN,oBAAoB,GAIpB,MAAM,mBAAmB,CAAC;AAW3B,OAAO,EAAE,WAAW,EAAgB,MAAM,qBAAqB,CAAC;AAChE,OAAO,EAAE,kBAAkB,EAAyB,MAAM,uBAAuB,CAAC;AAClF,OAAO,EAAE,QAAQ,EAAuB,MAAM,kBAAkB,CAAC;AAEjE;;GAEG;AACH,MAAM,UAAU,kBAAkB,CAAC,MAA2B;IAC7D,MAAM,gBAAgB,GAAG,oBAAoB,CAAC,MAAM,CAAC,CAAC;IAEtD,MAAM,YAAY,GAAG,2BAA2B,CAAC,gBAAgB,CAAC,CAAC;IAEnE,MAAM,WAAW,GAAG,IAAI,GAAG,EAA4B,CAAC;IACxD,iCAAiC,CAAC,gBAAgB,EAAE,WAAW,CAAC,CAAC;IAEjE,MAAM,MAAM,GAA8B;QACzC,IAAI,EAAE,gBAAgB,CAAC,IAAI;QAC3B,YAAY;QACZ,WAAW;KACX,CAAC;IAEF,wEAAwE;IACxE,IAAI,gBAAgB,CAAC,QAAQ,EAAE,WAAW,KAAK,SAAS,EAAE,CAAC;QAC1D,MAAM,CAAC,WAAW,GAAG,gBAAgB,CAAC,QAAQ,CAAC,WAAW,CAAC;IAC5D,CAAC;IAED,OAAO,MAAM,CAAC;AACf,CAAC;AAED;;GAEG;AACH,MAAM,qBAAqB,GAAG,IAAI,OAAO,EAAoC,CAAC;AAE9E;;;;GAIG;AACH,SAAS,kBAAkB,CAAC,MAAsB;IACjD,OAAO,WAAW,CAAC,qBAAqB,EAAE,MAAM,EAAE,GAAG,EAAE;QACtD,MAAM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ACP,CAAC;QACD,KAAK,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC;YACtB,MAAM,CAAC,kBAAkB,CAAC,MAAM,CAAC,EAAE,KAAK,CAAC,4BAA4B,CAAC,CAAC;YACvE,KAAK,MAAM,CAAC,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC;gBACvC,iCAAiC,CAAC,KAAK,EAAE,WAAW,CAAC,CAAC;YACvD,CAAC;YACD,MAAM;QACP,CAAC;QACD,OAAO,CAAC,CAAC,CAAC;YACT,eAAe,CAAC,IAAI,CAAC,CAAC;QACvB,CAAC;IACF,CAAC;AACF,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, unreachableCase } from \"@fluidframework/core-utils/internal\";\nimport {\n\tnormalizeFieldSchema,\n\ttype FieldSchema,\n\ttype ImplicitAllowedTypes,\n\ttype ImplicitFieldSchema,\n} from \"../schemaTypes.js\";\nimport type {\n\tSimpleArrayNodeSchema,\n\tSimpleFieldSchema,\n\tSimpleLeafNodeSchema,\n\tSimpleMapNodeSchema,\n\tSimpleNodeSchema,\n\tSimpleObjectNodeSchema,\n\tSimpleTreeSchema,\n} from \"./simpleSchema.js\";\nimport type { ValueSchema } from \"../../core/index.js\";\nimport { getOrCreate, type Mutable } from \"../../util/index.js\";\nimport { isObjectNodeSchema, type ObjectNodeSchema } from \"../objectNodeTypes.js\";\nimport { NodeKind, type TreeNodeSchema } from \"../core/index.js\";\n\n/**\n * Converts a \"view\" schema to a \"simple\" schema representation.\n */\nexport function toSimpleTreeSchema(schema: ImplicitFieldSchema): SimpleTreeSchema {\n\tconst normalizedSchema = normalizeFieldSchema(schema);\n\n\tconst allowedTypes = allowedTypesFromFieldSchema(normalizedSchema);\n\n\tconst definitions = new Map<string, SimpleNodeSchema>();\n\tpopulateSchemaDefinitionsForField(normalizedSchema, definitions);\n\n\tconst output: Mutable<SimpleTreeSchema> = {\n\t\tkind: normalizedSchema.kind,\n\t\tallowedTypes,\n\t\tdefinitions,\n\t};\n\n\t// Include the \"description\" property only if it's present on the input.\n\tif (normalizedSchema.metadata?.description !== undefined) {\n\t\toutput.description = normalizedSchema.metadata.description;\n\t}\n\n\treturn output;\n}\n\n/**\n * Cache in which the results of {@link toSimpleNodeSchema} are saved.\n */\nconst simpleNodeSchemaCache = new WeakMap<TreeNodeSchema, SimpleNodeSchema>();\n\n/**\n * Creates a {@link SimpleNodeSchema} from a {@link TreeNodeSchema}.\n *\n * @remarks Caches the result on the input schema for future calls.\n */\nfunction toSimpleNodeSchema(schema: TreeNodeSchema): SimpleNodeSchema {\n\treturn getOrCreate(simpleNodeSchemaCache, schema, () => {\n\t\tconst kind = schema.kind;\n\t\tswitch (kind) {\n\t\t\tcase NodeKind.Leaf: {\n\t\t\t\treturn leafSchemaToSimpleSchema(schema);\n\t\t\t}\n\t\t\tcase NodeKind.Map: {\n\t\t\t\treturn mapSchemaToSimpleSchema(schema);\n\t\t\t}\n\t\t\tcase NodeKind.Array: {\n\t\t\t\treturn arraySchemaToSimpleSchema(schema);\n\t\t\t}\n\t\t\tcase NodeKind.Object: {\n\t\t\t\tassert(isObjectNodeSchema(schema), 0xa06 /* Expected object schema */);\n\t\t\t\treturn objectSchemaToSimpleSchema(schema);\n\t\t\t}\n\t\t\tdefault: {\n\t\t\t\tunreachableCase(kind);\n\t\t\t}\n\t\t}\n\t});\n}\n\n// TODO: Use a stronger type for leaf schemas once one is available (see object schema handler for an example).\nfunction leafSchemaToSimpleSchema(schema: TreeNodeSchema): SimpleLeafNodeSchema {\n\treturn {\n\t\tkind: NodeKind.Leaf,\n\t\tleafKind: schema.info as ValueSchema,\n\t};\n}\n\n// TODO: Use a stronger type for array schemas once one is available (see object schema handler for an example).\nfunction arraySchemaToSimpleSchema(schema: TreeNodeSchema): SimpleArrayNodeSchema {\n\tconst fieldSchema = normalizeFieldSchema(schema.info as ImplicitAllowedTypes);\n\tconst allowedTypes = allowedTypesFromFieldSchema(fieldSchema);\n\treturn {\n\t\tkind: NodeKind.Array,\n\t\tallowedTypes,\n\t};\n}\n\n// TODO: Use a stronger type for map schemas once one is available (see object schema handler for an example).\nfunction mapSchemaToSimpleSchema(schema: TreeNodeSchema): SimpleMapNodeSchema {\n\tconst fieldSchema = normalizeFieldSchema(schema.info as ImplicitAllowedTypes);\n\tconst allowedTypes = allowedTypesFromFieldSchema(fieldSchema);\n\treturn {\n\t\tkind: NodeKind.Map,\n\t\tallowedTypes,\n\t};\n}\n\nfunction objectSchemaToSimpleSchema(schema: ObjectNodeSchema): SimpleObjectNodeSchema {\n\tconst fields: Record<string, SimpleFieldSchema> = {};\n\tfor (const [key, field] of schema.fields) {\n\t\tfields[key] = fieldSchemaToSimpleSchema(field);\n\t}\n\treturn {\n\t\tkind: NodeKind.Object,\n\t\tfields,\n\t};\n}\n\n/**\n * Private symbol under which the results of {@link toSimpleNodeSchema} are cached on an input {@link TreeNodeSchema}.\n */\nconst simpleFieldSchemaCacheSymbol = Symbol(\"simpleFieldSchemaCache\");\n\nfunction fieldSchemaToSimpleSchema(schema: FieldSchema): SimpleFieldSchema {\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tif ((schema as any)[simpleFieldSchemaCacheSymbol] !== undefined) {\n\t\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t\treturn (schema as any)[simpleFieldSchemaCacheSymbol] as SimpleFieldSchema;\n\t}\n\n\tconst allowedTypes = allowedTypesFromFieldSchema(schema);\n\tconst result: Mutable<SimpleFieldSchema> = {\n\t\tkind: schema.kind,\n\t\tallowedTypes,\n\t};\n\n\t// Don't include \"description\" property at all if it's not present.\n\tif (schema.metadata?.description !== undefined) {\n\t\tresult.description = schema.metadata.description;\n\t}\n\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t(schema as any)[simpleFieldSchemaCacheSymbol] = result;\n\n\treturn result;\n}\n\nfunction allowedTypesFromFieldSchema(schema: FieldSchema): Set<string> {\n\tconst allowedTypes = new Set<string>();\n\tfor (const type of schema.allowedTypeSet) {\n\t\tallowedTypes.add(type.identifier);\n\t}\n\treturn allowedTypes;\n}\n\n/**\n * Recursively populates `definitions` by walking the input field schema tree.\n */\nfunction populateSchemaDefinitionsForField(\n\tschema: FieldSchema,\n\tdefinitions: Map<string, SimpleNodeSchema>,\n): void {\n\tfor (const child of schema.allowedTypeSet) {\n\t\tpopulateSchemaDefinitionsForNode(child, definitions);\n\t}\n}\n\n/**\n * Recursively populates `definitions` by walking the input node schema tree.\n */\nfunction populateSchemaDefinitionsForNode(\n\tschema: TreeNodeSchema,\n\tdefinitions: Map<string, SimpleNodeSchema>,\n): void {\n\tif (definitions.has(schema.identifier)) {\n\t\t// If the definition has already been populated, no need to recurse.\n\t\treturn;\n\t}\n\n\t// Populate definition for this schema\n\tdefinitions.set(schema.identifier, toSimpleNodeSchema(schema));\n\n\t// Recurse into children to populate definitions for them\n\tconst kind = schema.kind;\n\tswitch (kind) {\n\t\tcase NodeKind.Leaf: {\n\t\t\t// Leaf node, so no need to recurse\n\t\t\tbreak;\n\t\t}\n\t\tcase NodeKind.Map: {\n\t\t\t// TODO: Utilize a map schema type-guard once one exists (see object case for an example).\n\n\t\t\t// Recursively populate definitions for allowed map children\n\t\t\tconst fieldSchema = normalizeFieldSchema(schema.info as ImplicitAllowedTypes);\n\t\t\tpopulateSchemaDefinitionsForField(fieldSchema, definitions);\n\t\t\tbreak;\n\t\t}\n\t\tcase NodeKind.Array: {\n\t\t\t// TODO: Utilize an array schema type-guard once one exists (see object case for an example).\n\n\t\t\t// Recursively populate definitions for allowed map children\n\t\t\tconst fieldSchema = normalizeFieldSchema(schema.info as ImplicitAllowedTypes);\n\t\t\tpopulateSchemaDefinitionsForField(fieldSchema, definitions);\n\t\t\tbreak;\n\t\t}\n\t\tcase NodeKind.Object: {\n\t\t\tassert(isObjectNodeSchema(schema), 0xa07 /* Expected object schema */);\n\t\t\tfor (const [, field] of schema.fields) {\n\t\t\t\tpopulateSchemaDefinitionsForField(field, definitions);\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t\tdefault: {\n\t\t\tunreachableCase(kind);\n\t\t}\n\t}\n}\n"]}
@@ -2,8 +2,8 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
- import type { ImplicitAllowedTypes, InsertableTreeNodeFromImplicitAllowedTypes, TreeNodeFromImplicitAllowedTypes } from "./schemaTypes.js";
6
- import { type WithType, NodeKind, type TreeNode, type TreeNodeSchemaClass } from "./core/index.js";
5
+ import { type ImplicitAllowedTypes, type InsertableTreeNodeFromImplicitAllowedTypes, type TreeNodeFromImplicitAllowedTypes } from "./schemaTypes.js";
6
+ import { type WithType, NodeKind, type TreeNode, type TreeNodeSchemaBoth } from "./core/index.js";
7
7
  /**
8
8
  * A generic array type, used to defined types like {@link (TreeArrayNode:interface)}.
9
9
  *
@@ -79,22 +79,88 @@ export interface TreeArrayNodeBase<out T, in TNew, in TMoveFrom> extends Readonl
79
79
  moveToEnd(sourceIndex: number, source: TMoveFrom): void;
80
80
  /**
81
81
  * Moves the specified item to the desired location in the array.
82
- * @param index - The index to move the item to.
83
- * This is based on the state of the array before moving the source item.
82
+ *
83
+ * WARNING - This API is easily misused.
84
+ * Please read the documentation for the `destinationGap` parameter carefully.
85
+ *
86
+ * @param destinationGap - The location *between* existing items that the moved item should be moved to.
87
+ *
88
+ * WARNING - `destinationGap` describes a location between existing items *prior to applying the move operation*.
89
+ *
90
+ * For example, if the array contains items `[A, B, C]` before the move, the `destinationGap` must be one of the following:
91
+ *
92
+ * - `0` (between the start of the array and `A`'s original position)
93
+ * - `1` (between `A`'s original position and `B`'s original position)
94
+ * - `2` (between `B`'s original position and `C`'s original position)
95
+ * - `3` (between `C`'s original position and the end of the array)
96
+ *
97
+ * So moving `A` between `B` and `C` would require `destinationGap` to be `2`.
98
+ *
99
+ * This interpretation of `destinationGap` makes it easy to specify the desired destination relative to a sibling item that is not being moved,
100
+ * or relative to the start or end of the array:
101
+ *
102
+ * - Move to the start of the array: `array.moveToIndex(0, ...)` (see also `moveToStart`)
103
+ * - Move to before some item X: `array.moveToIndex(indexOfX, ...)`
104
+ * - Move to after some item X: `array.moveToIndex(indexOfX + 1`, ...)
105
+ * - Move to the end of the array: `array.moveToIndex(array.length, ...)` (see also `moveToEnd`)
106
+ *
107
+ * This interpretation of `destinationGap` does however make it less obvious how to move an item relative to its current position:
108
+ *
109
+ * - Move item B before its predecessor: `array.moveToIndex(indexOfB - 1, ...)`
110
+ * - Move item B after its successor: `array.moveToIndex(indexOfB + 2, ...)`
111
+ *
112
+ * Notice the asymmetry between `-1` and `+2` in the above examples.
113
+ * In such scenarios, it can often be easier to approach such edits by swapping adjacent items:
114
+ * If items A and B are adjacent, such that A precedes B,
115
+ * then they can be swapped with `array.moveToIndex(indexOfA, indexOfB)`.
116
+ *
84
117
  * @param sourceIndex - The index of the item to move.
85
118
  * @throws Throws if any of the input indices are not in the range [0, `array.length`).
86
119
  */
87
- moveToIndex(index: number, sourceIndex: number): void;
120
+ moveToIndex(destinationGap: number, sourceIndex: number): void;
88
121
  /**
89
122
  * Moves the specified item to the desired location in the array.
90
- * @param index - The index to move the item to in the range [0, `array.length`].
91
- * This is based on the state of the array before moving the source item.
123
+ *
124
+ * WARNING - This API is easily misused.
125
+ * Please read the documentation for the `destinationGap` parameter carefully.
126
+ *
127
+ * @param destinationGap - The location *between* existing items that the moved item should be moved to.
128
+ *
129
+ * WARNING - `destinationGap` describes a location between existing items *prior to applying the move operation*.
130
+ *
131
+ * For example, if the array contains items `[A, B, C]` before the move, the `destinationGap` must be one of the following:
132
+ *
133
+ * - `0` (between the start of the array and `A`'s original position)
134
+ * - `1` (between `A`'s original position and `B`'s original position)
135
+ * - `2` (between `B`'s original position and `C`'s original position)
136
+ * - `3` (between `C`'s original position and the end of the array)
137
+ *
138
+ * So moving `A` between `B` and `C` would require `destinationGap` to be `2`.
139
+ *
140
+ * This interpretation of `destinationGap` makes it easy to specify the desired destination relative to a sibling item that is not being moved,
141
+ * or relative to the start or end of the array:
142
+ *
143
+ * - Move to the start of the array: `array.moveToIndex(0, ...)` (see also `moveToStart`)
144
+ * - Move to before some item X: `array.moveToIndex(indexOfX, ...)`
145
+ * - Move to after some item X: `array.moveToIndex(indexOfX + 1`, ...)
146
+ * - Move to the end of the array: `array.moveToIndex(array.length, ...)` (see also `moveToEnd`)
147
+ *
148
+ * This interpretation of `destinationGap` does however make it less obvious how to move an item relative to its current position:
149
+ *
150
+ * - Move item B before its predecessor: `array.moveToIndex(indexOfB - 1, ...)`
151
+ * - Move item B after its successor: `array.moveToIndex(indexOfB + 2, ...)`
152
+ *
153
+ * Notice the asymmetry between `-1` and `+2` in the above examples.
154
+ * In such scenarios, it can often be easier to approach such edits by swapping adjacent items:
155
+ * If items A and B are adjacent, such that A precedes B,
156
+ * then they can be swapped with `array.moveToIndex(indexOfA, indexOfB)`.
157
+ *
92
158
  * @param sourceIndex - The index of the item to move.
93
159
  * @param source - The source array to move the item out of.
94
160
  * @throws Throws if any of the source index is not in the range [0, `array.length`),
95
161
  * or if the index is not in the range [0, `array.length`].
96
162
  */
97
- moveToIndex(index: number, sourceIndex: number, source: TMoveFrom): void;
163
+ moveToIndex(destinationGap: number, sourceIndex: number, source: TMoveFrom): void;
98
164
  /**
99
165
  * Moves the specified items to the start of the array.
100
166
  * @param sourceStart - The starting index of the range to move (inclusive).
@@ -133,24 +199,91 @@ export interface TreeArrayNodeBase<out T, in TNew, in TMoveFrom> extends Readonl
133
199
  moveRangeToEnd(sourceStart: number, sourceEnd: number, source: TMoveFrom): void;
134
200
  /**
135
201
  * Moves the specified items to the desired location within the array.
136
- * @param index - The index to move the items to.
137
- * This is based on the state of the array before moving the source items.
202
+ *
203
+ * WARNING - This API is easily misused.
204
+ * Please read the documentation for the `destinationGap` parameter carefully.
205
+ *
206
+ * @param destinationGap - The location *between* existing items that the moved item should be moved to.
207
+ *
208
+ * WARNING - `destinationGap` describes a location between existing items *prior to applying the move operation*.
209
+ *
210
+ * For example, if the array contains items `[A, B, C]` before the move, the `destinationGap` must be one of the following:
211
+ *
212
+ * - `0` (between the start of the array and `A`'s original position)
213
+ * - `1` (between `A`'s original position and `B`'s original position)
214
+ * - `2` (between `B`'s original position and `C`'s original position)
215
+ * - `3` (between `C`'s original position and the end of the array)
216
+ *
217
+ * So moving `A` between `B` and `C` would require `destinationGap` to be `2`.
218
+ *
219
+ * This interpretation of `destinationGap` makes it easy to specify the desired destination relative to a sibling item that is not being moved,
220
+ * or relative to the start or end of the array:
221
+ *
222
+ * - Move to the start of the array: `array.moveToIndex(0, ...)` (see also `moveToStart`)
223
+ * - Move to before some item X: `array.moveToIndex(indexOfX, ...)`
224
+ * - Move to after some item X: `array.moveToIndex(indexOfX + 1`, ...)
225
+ * - Move to the end of the array: `array.moveToIndex(array.length, ...)` (see also `moveToEnd`)
226
+ *
227
+ * This interpretation of `destinationGap` does however make it less obvious how to move an item relative to its current position:
228
+ *
229
+ * - Move item B before its predecessor: `array.moveToIndex(indexOfB - 1, ...)`
230
+ * - Move item B after its successor: `array.moveToIndex(indexOfB + 2, ...)`
231
+ *
232
+ * Notice the asymmetry between `-1` and `+2` in the above examples.
233
+ * In such scenarios, it can often be easier to approach such edits by swapping adjacent items:
234
+ * If items A and B are adjacent, such that A precedes B,
235
+ * then they can be swapped with `array.moveToIndex(indexOfA, indexOfB)`.
236
+ *
138
237
  * @param sourceStart - The starting index of the range to move (inclusive).
139
238
  * @param sourceEnd - The ending index of the range to move (exclusive)
140
239
  * @throws Throws if any of the input indices are not in the range [0, `array.length`) or if `sourceStart` is greater than `sourceEnd`.
141
240
  * if any of the input indices are not in the range [0, `array.length`], or if `sourceStart` is greater than `sourceEnd`.
142
241
  */
143
- moveRangeToIndex(index: number, sourceStart: number, sourceEnd: number): void;
242
+ moveRangeToIndex(destinationGap: number, sourceStart: number, sourceEnd: number): void;
144
243
  /**
145
244
  * Moves the specified items to the desired location within the array.
146
- * @param index - The index to move the items to.
245
+ *
246
+ * WARNING - This API is easily misused.
247
+ * Please read the documentation for the `destinationGap` parameter carefully.
248
+ *
249
+ * @param destinationGap - The location *between* existing items that the moved item should be moved to.
250
+ *
251
+ * WARNING - `destinationGap` describes a location between existing items *prior to applying the move operation*.
252
+ *
253
+ * For example, if the array contains items `[A, B, C]` before the move, the `destinationGap` must be one of the following:
254
+ *
255
+ * - `0` (between the start of the array and `A`'s original position)
256
+ * - `1` (between `A`'s original position and `B`'s original position)
257
+ * - `2` (between `B`'s original position and `C`'s original position)
258
+ * - `3` (between `C`'s original position and the end of the array)
259
+ *
260
+ * So moving `A` between `B` and `C` would require `destinationGap` to be `2`.
261
+ *
262
+ * This interpretation of `destinationGap` makes it easy to specify the desired destination relative to a sibling item that is not being moved,
263
+ * or relative to the start or end of the array:
264
+ *
265
+ * - Move to the start of the array: `array.moveToIndex(0, ...)` (see also `moveToStart`)
266
+ * - Move to before some item X: `array.moveToIndex(indexOfX, ...)`
267
+ * - Move to after some item X: `array.moveToIndex(indexOfX + 1`, ...)
268
+ * - Move to the end of the array: `array.moveToIndex(array.length, ...)` (see also `moveToEnd`)
269
+ *
270
+ * This interpretation of `destinationGap` does however make it less obvious how to move an item relative to its current position:
271
+ *
272
+ * - Move item B before its predecessor: `array.moveToIndex(indexOfB - 1, ...)`
273
+ * - Move item B after its successor: `array.moveToIndex(indexOfB + 2, ...)`
274
+ *
275
+ * Notice the asymmetry between `-1` and `+2` in the above examples.
276
+ * In such scenarios, it can often be easier to approach such edits by swapping adjacent items:
277
+ * If items A and B are adjacent, such that A precedes B,
278
+ * then they can be swapped with `array.moveToIndex(indexOfA, indexOfB)`.
279
+ *
147
280
  * @param sourceStart - The starting index of the range to move (inclusive).
148
281
  * @param sourceEnd - The ending index of the range to move (exclusive)
149
282
  * @param source - The source array to move items out of.
150
283
  * @throws Throws if the types of any of the items being moved are not allowed in the destination array,
151
284
  * if any of the input indices are not in the range [0, `array.length`], or if `sourceStart` is greater than `sourceEnd`.
152
285
  */
153
- moveRangeToIndex(index: number, sourceStart: number, sourceEnd: number, source: TMoveFrom): void;
286
+ moveRangeToIndex(destinationGap: number, sourceStart: number, sourceEnd: number, source: TMoveFrom): void;
154
287
  /**
155
288
  * Returns a custom IterableIterator which throws usage errors if concurrent editing and iteration occurs.
156
289
  */
@@ -208,5 +341,5 @@ export declare function asIndex(key: string | symbol, exclusiveMax: number): num
208
341
  *
209
342
  * @param name - Unique identifier for this schema including the factory's scope.
210
343
  */
211
- export declare function arraySchema<TName extends string, const T extends ImplicitAllowedTypes, const ImplicitlyConstructable extends boolean>(identifier: TName, info: T, implicitlyConstructable: ImplicitlyConstructable, customizable: boolean): TreeNodeSchemaClass<TName, NodeKind.Array, TreeArrayNode<T> & WithType<TName, NodeKind.Array, unknown>, Iterable<InsertableTreeNodeFromImplicitAllowedTypes<T>>, ImplicitlyConstructable, T>;
344
+ export declare function arraySchema<TName extends string, const T extends ImplicitAllowedTypes, const ImplicitlyConstructable extends boolean>(identifier: TName, info: T, implicitlyConstructable: ImplicitlyConstructable, customizable: boolean): TreeNodeSchemaBoth<TName, NodeKind.Array, TreeArrayNode<T> & WithType<TName, NodeKind.Array, unknown>, Iterable<InsertableTreeNodeFromImplicitAllowedTypes<T>>, ImplicitlyConstructable, T>;
212
345
  //# sourceMappingURL=arrayNode.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"arrayNode.d.ts","sourceRoot":"","sources":["../../src/simple-tree/arrayNode.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAuBH,OAAO,KAAK,EACX,oBAAoB,EACpB,0CAA0C,EAC1C,gCAAgC,EAChC,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACN,KAAK,QAAQ,EAGb,QAAQ,EACR,KAAK,QAAQ,EAEb,KAAK,mBAAmB,EAGxB,MAAM,iBAAiB,CAAC;AAOzB;;;;;;;GAOG;AACH,MAAM,WAAW,iBAAiB,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE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AAgB,WAAW,CAC1B,KAAK,SAAS,MAAM,EACpB,KAAK,CAAC,CAAC,SAAS,oBAAoB,EACpC,KAAK,CAAC,uBAAuB,SAAS,OAAO,EAE7C,UAAU,EAAE,KAAK,EACjB,IAAI,EAAE,CAAC,EACP,uBAAuB,EAAE,uBAAuB,EAChD,YAAY,EAAE,OAAO,+LA6GrB"}
@@ -8,20 +8,21 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
8
8
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
9
9
  };
10
10
  var _CustomArrayNodeBase_instances, _CustomArrayNodeBase_mapTreesFromFieldData;
11
- import { oob } from "@fluidframework/core-utils/internal";
11
+ import { Lazy, oob } from "@fluidframework/core-utils/internal";
12
12
  import { UsageError } from "@fluidframework/telemetry-utils/internal";
13
13
  import { EmptyKey } from "../core/index.js";
14
- import { getOrCreateMapTreeNode, getSchemaAndPolicy, isFlexTreeNode, isMapTreeSequenceField, UnhydratedContext, } from "../feature-libraries/index.js";
15
- import { getOrCreateNodeFromFlexTreeNode, prepareContentForHydration } from "./proxies.js";
14
+ import { getSchemaAndPolicy, isFlexTreeNode, } from "../feature-libraries/index.js";
15
+ import { prepareContentForHydration } from "./proxies.js";
16
16
  import { getOrCreateInnerNode } from "./proxyBinding.js";
17
+ import { normalizeAllowedTypes, } from "./schemaTypes.js";
17
18
  import {
18
19
  // eslint-disable-next-line import/no-deprecated
19
- typeNameSymbol, NodeKind, typeSchemaSymbol, } from "./core/index.js";
20
+ typeNameSymbol, NodeKind, typeSchemaSymbol, getOrCreateNodeFromInnerNode, getSimpleNodeSchemaFromInnerNode, } from "./core/index.js";
20
21
  import { mapTreeFromNodeData } from "./toMapTree.js";
21
22
  import { fail } from "../util/index.js";
22
- import { getFlexSchema, toFlexSchema } from "./toFlexSchema.js";
23
- import { getKernel } from "./core/index.js";
23
+ import { getKernel, UnhydratedFlexTreeNode, UnhydratedTreeSequenceField, } from "./core/index.js";
24
24
  import { TreeNodeValid } from "./treeNodeValid.js";
25
+ import { getUnhydratedContext } from "./createContext.js";
25
26
  /**
26
27
  * A {@link TreeNode} which implements 'readonly T[]' and the array mutation APIs.
27
28
  * @public
@@ -182,7 +183,7 @@ function createArrayNodeProxy(allowAdditionalProperties, proxyTarget, dispatchTa
182
183
  }
183
184
  const maybeContent = field.at(maybeIndex);
184
185
  return isFlexTreeNode(maybeContent)
185
- ? getOrCreateNodeFromFlexTreeNode(maybeContent)
186
+ ? getOrCreateNodeFromInnerNode(maybeContent)
186
187
  : maybeContent;
187
188
  },
188
189
  set: (target, key, newValue, receiver) => {
@@ -234,7 +235,7 @@ function createArrayNodeProxy(allowAdditionalProperties, proxyTarget, dispatchTa
234
235
  // To satisfy 'deepEquals' level scrutiny, the property descriptor for indexed properties must
235
236
  // be a simple value property (as opposed to using getter) and declared writable/enumerable/configurable.
236
237
  return {
237
- value: isFlexTreeNode(val) ? getOrCreateNodeFromFlexTreeNode(val) : val,
238
+ value: isFlexTreeNode(val) ? getOrCreateNodeFromInnerNode(val) : val,
238
239
  writable: true, // For MVP, setting indexed properties is reported as allowed here (for deep equals compatibility noted above), but not actually supported.
239
240
  enumerable: true,
240
241
  configurable: true,
@@ -305,7 +306,7 @@ class CustomArrayNodeBase extends TreeNodeWithArrayFeatures {
305
306
  if (val === undefined) {
306
307
  return val;
307
308
  }
308
- return getOrCreateNodeFromFlexTreeNode(val);
309
+ return getOrCreateNodeFromInnerNode(val);
309
310
  }
310
311
  insertAt(index, ...value) {
311
312
  const field = getSequenceField(this);
@@ -349,13 +350,13 @@ class CustomArrayNodeBase extends TreeNodeWithArrayFeatures {
349
350
  validateIndex(sourceIndex, sourceField, "moveToEnd");
350
351
  this.moveRangeToIndex(this.length, sourceIndex, sourceIndex + 1, source);
351
352
  }
352
- moveToIndex(destinationIndex, sourceIndex, source) {
353
+ moveToIndex(destinationGap, sourceIndex, source) {
353
354
  const sourceArray = source ?? this;
354
355
  const sourceField = getSequenceField(sourceArray);
355
356
  const destinationField = getSequenceField(this);
356
- validateIndex(destinationIndex, destinationField, "moveToIndex", true);
357
+ validateIndex(destinationGap, destinationField, "moveToIndex", true);
357
358
  validateIndex(sourceIndex, sourceField, "moveToIndex");
358
- this.moveRangeToIndex(destinationIndex, sourceIndex, sourceIndex + 1, source);
359
+ this.moveRangeToIndex(destinationGap, sourceIndex, sourceIndex + 1, source);
359
360
  }
360
361
  moveRangeToStart(sourceStart, sourceEnd, source) {
361
362
  validateIndexRange(sourceStart, sourceEnd, source ?? getSequenceField(this), "moveRangeToStart");
@@ -365,30 +366,35 @@ class CustomArrayNodeBase extends TreeNodeWithArrayFeatures {
365
366
  validateIndexRange(sourceStart, sourceEnd, source ?? getSequenceField(this), "moveRangeToEnd");
366
367
  this.moveRangeToIndex(this.length, sourceStart, sourceEnd, source);
367
368
  }
368
- moveRangeToIndex(destinationIndex, sourceStart, sourceEnd, source) {
369
+ moveRangeToIndex(destinationGap, sourceStart, sourceEnd, source) {
369
370
  const destinationField = getSequenceField(this);
371
+ const destinationSchema = this.allowedTypes;
370
372
  const sourceField = source !== undefined ? getSequenceField(source) : destinationField;
371
- validateIndex(destinationIndex, destinationField, "moveRangeToIndex", true);
373
+ validateIndex(destinationGap, destinationField, "moveRangeToIndex", true);
372
374
  validateIndexRange(sourceStart, sourceEnd, source ?? destinationField, "moveRangeToIndex");
373
375
  // TODO: determine support for move across different sequence types
374
376
  if (sourceField !== destinationField) {
375
377
  for (let i = sourceStart; i < sourceEnd; i++) {
376
378
  const sourceNode = sourceField.boxedAt(i) ?? oob();
377
- if (!destinationField.schema.types.has(sourceNode.schema)) {
379
+ const sourceSchema = getSimpleNodeSchemaFromInnerNode(sourceNode);
380
+ if (!destinationSchema.has(sourceSchema)) {
378
381
  throw new UsageError("Type in source sequence is not allowed in destination.");
379
382
  }
380
383
  }
381
384
  }
382
385
  const movedCount = sourceEnd - sourceStart;
383
386
  if (!destinationField.context.isHydrated()) {
384
- if (!isMapTreeSequenceField(sourceField)) {
387
+ if (!(sourceField instanceof UnhydratedTreeSequenceField)) {
385
388
  throw new UsageError("Cannot move elements from an unhydrated array to a hydrated array.");
386
389
  }
387
- if (sourceField !== destinationField || destinationIndex < sourceStart) {
388
- destinationField.editor.insert(destinationIndex, sourceField.editor.remove(sourceStart, movedCount));
390
+ if (sourceField.context.isHydrated()) {
391
+ throw new UsageError("Cannot move elements from an unhydrated array to a hydrated array.");
392
+ }
393
+ if (sourceField !== destinationField || destinationGap < sourceStart) {
394
+ destinationField.editor.insert(destinationGap, sourceField.editor.remove(sourceStart, movedCount));
389
395
  }
390
- else if (destinationIndex > sourceStart + movedCount) {
391
- destinationField.editor.insert(destinationIndex - movedCount, sourceField.editor.remove(sourceStart, movedCount));
396
+ else if (destinationGap > sourceStart + movedCount) {
397
+ destinationField.editor.insert(destinationGap - movedCount, sourceField.editor.remove(sourceStart, movedCount));
392
398
  }
393
399
  }
394
400
  else {
@@ -398,7 +404,7 @@ class CustomArrayNodeBase extends TreeNodeWithArrayFeatures {
398
404
  if (sourceField.context !== destinationField.context) {
399
405
  throw new UsageError("Cannot move elements between two different TreeViews.");
400
406
  }
401
- destinationField.context.checkout.editor.move(sourceField.getFieldPath(), sourceStart, movedCount, destinationField.getFieldPath(), destinationIndex);
407
+ destinationField.context.checkout.editor.move(sourceField.getFieldPath(), sourceStart, movedCount, destinationField.getFieldPath(), destinationGap);
402
408
  }
403
409
  }
404
410
  values() {
@@ -425,7 +431,7 @@ CustomArrayNodeBase.kind = NodeKind.Array;
425
431
  */
426
432
  // eslint-disable-next-line @typescript-eslint/explicit-function-return-type
427
433
  export function arraySchema(identifier, info, implicitlyConstructable, customizable) {
428
- let flexSchema;
434
+ const lazyChildTypes = new Lazy(() => normalizeAllowedTypes(info));
429
435
  let unhydratedContext;
430
436
  // This class returns a proxy from its constructor to handle numeric indexing.
431
437
  // Alternatively it could extend a normal class which gets tons of numeric properties added.
@@ -445,12 +451,11 @@ export function arraySchema(identifier, info, implicitlyConstructable, customiza
445
451
  return createArrayNodeProxy(customizable, proxyTarget, instance);
446
452
  }
447
453
  static buildRawNode(instance, input) {
448
- return getOrCreateMapTreeNode(unhydratedContext, flexSchema, mapTreeFromNodeData(input, this));
454
+ return UnhydratedFlexTreeNode.getOrCreate(unhydratedContext, mapTreeFromNodeData(input, this));
449
455
  }
450
456
  static oneTimeSetup() {
451
457
  const schema = this;
452
- flexSchema = getFlexSchema(schema);
453
- unhydratedContext = new UnhydratedContext(toFlexSchema(schema));
458
+ unhydratedContext = getUnhydratedContext(schema);
454
459
  // First run, do extra validation.
455
460
  // TODO: provide a way for TreeConfiguration to trigger this same validation to ensure it gets run early.
456
461
  // Scan for shadowing inherited members which won't work, but stop scan early to allow shadowing built in (which seems to work ok).
@@ -472,6 +477,10 @@ export function arraySchema(identifier, info, implicitlyConstructable, customiza
472
477
  prototype = Reflect.getPrototypeOf(prototype);
473
478
  }
474
479
  }
480
+ return unhydratedContext;
481
+ }
482
+ static get childTypes() {
483
+ return lazyChildTypes.value;
475
484
  }
476
485
  // eslint-disable-next-line import/no-deprecated
477
486
  get [typeNameSymbol]() {
@@ -483,6 +492,9 @@ export function arraySchema(identifier, info, implicitlyConstructable, customiza
483
492
  get simpleSchema() {
484
493
  return info;
485
494
  }
495
+ get allowedTypes() {
496
+ return lazyChildTypes.value;
497
+ }
486
498
  }
487
499
  Schema.constructorCached = undefined;
488
500
  Schema.identifier = identifier;