@fluidframework/tree 2.41.0 → 2.43.0-343119

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 (673) hide show
  1. package/.vscode/settings.json +1 -0
  2. package/CHANGELOG.md +33 -0
  3. package/api-report/tree.alpha.api.md +70 -28
  4. package/api-report/tree.beta.api.md +33 -0
  5. package/dist/alpha.d.ts +12 -6
  6. package/dist/beta.d.ts +6 -1
  7. package/dist/codec/codec.d.ts +23 -3
  8. package/dist/codec/codec.d.ts.map +1 -1
  9. package/dist/codec/codec.js.map +1 -1
  10. package/dist/codec/index.d.ts +1 -1
  11. package/dist/codec/index.d.ts.map +1 -1
  12. package/dist/codec/index.js.map +1 -1
  13. package/dist/codec/versioned/codec.d.ts +35 -2
  14. package/dist/codec/versioned/codec.d.ts.map +1 -1
  15. package/dist/codec/versioned/codec.js +38 -3
  16. package/dist/codec/versioned/codec.js.map +1 -1
  17. package/dist/core/index.d.ts +1 -1
  18. package/dist/core/index.d.ts.map +1 -1
  19. package/dist/core/index.js +5 -2
  20. package/dist/core/index.js.map +1 -1
  21. package/dist/core/schema-stored/formatV2.d.ts +80 -0
  22. package/dist/core/schema-stored/formatV2.d.ts.map +1 -0
  23. package/dist/core/schema-stored/formatV2.js +55 -0
  24. package/dist/core/schema-stored/formatV2.js.map +1 -0
  25. package/dist/core/schema-stored/index.d.ts +3 -1
  26. package/dist/core/schema-stored/index.d.ts.map +1 -1
  27. package/dist/core/schema-stored/index.js +5 -2
  28. package/dist/core/schema-stored/index.js.map +1 -1
  29. package/dist/core/schema-stored/schema.d.ts +49 -17
  30. package/dist/core/schema-stored/schema.d.ts.map +1 -1
  31. package/dist/core/schema-stored/schema.js +65 -22
  32. package/dist/core/schema-stored/schema.js.map +1 -1
  33. package/dist/core/tree/detachedFieldIndex.d.ts +2 -2
  34. package/dist/core/tree/detachedFieldIndex.d.ts.map +1 -1
  35. package/dist/core/tree/detachedFieldIndex.js +5 -1
  36. package/dist/core/tree/detachedFieldIndex.js.map +1 -1
  37. package/dist/core/tree/mapTree.d.ts +2 -1
  38. package/dist/core/tree/mapTree.d.ts.map +1 -1
  39. package/dist/core/tree/mapTree.js +11 -5
  40. package/dist/core/tree/mapTree.js.map +1 -1
  41. package/dist/core/tree/visitorUtils.d.ts +2 -2
  42. package/dist/core/tree/visitorUtils.d.ts.map +1 -1
  43. package/dist/core/tree/visitorUtils.js.map +1 -1
  44. package/dist/feature-libraries/chunked-forest/codec/chunkEncodingGeneric.d.ts +9 -7
  45. package/dist/feature-libraries/chunked-forest/codec/chunkEncodingGeneric.d.ts.map +1 -1
  46. package/dist/feature-libraries/chunked-forest/codec/chunkEncodingGeneric.js +13 -9
  47. package/dist/feature-libraries/chunked-forest/codec/chunkEncodingGeneric.js.map +1 -1
  48. package/dist/feature-libraries/chunked-forest/codec/compressedEncode.d.ts +3 -3
  49. package/dist/feature-libraries/chunked-forest/codec/compressedEncode.d.ts.map +1 -1
  50. package/dist/feature-libraries/chunked-forest/codec/compressedEncode.js +6 -6
  51. package/dist/feature-libraries/chunked-forest/codec/compressedEncode.js.map +1 -1
  52. package/dist/feature-libraries/chunked-forest/codec/nodeShape.d.ts +1 -1
  53. package/dist/feature-libraries/chunked-forest/codec/nodeShape.d.ts.map +1 -1
  54. package/dist/feature-libraries/chunked-forest/codec/nodeShape.js +3 -3
  55. package/dist/feature-libraries/chunked-forest/codec/nodeShape.js.map +1 -1
  56. package/dist/feature-libraries/default-schema/defaultEditBuilder.d.ts +3 -2
  57. package/dist/feature-libraries/default-schema/defaultEditBuilder.d.ts.map +1 -1
  58. package/dist/feature-libraries/default-schema/defaultEditBuilder.js.map +1 -1
  59. package/dist/feature-libraries/default-schema/schemaChecker.d.ts +4 -3
  60. package/dist/feature-libraries/default-schema/schemaChecker.d.ts.map +1 -1
  61. package/dist/feature-libraries/default-schema/schemaChecker.js +4 -3
  62. package/dist/feature-libraries/default-schema/schemaChecker.js.map +1 -1
  63. package/dist/feature-libraries/detachedFieldIndexSummarizer.d.ts +8 -3
  64. package/dist/feature-libraries/detachedFieldIndexSummarizer.d.ts.map +1 -1
  65. package/dist/feature-libraries/detachedFieldIndexSummarizer.js +2 -5
  66. package/dist/feature-libraries/detachedFieldIndexSummarizer.js.map +1 -1
  67. package/dist/feature-libraries/flex-tree/context.d.ts +14 -6
  68. package/dist/feature-libraries/flex-tree/context.d.ts.map +1 -1
  69. package/dist/feature-libraries/flex-tree/context.js.map +1 -1
  70. package/dist/feature-libraries/flex-tree/flexTreeTypes.d.ts +48 -29
  71. package/dist/feature-libraries/flex-tree/flexTreeTypes.d.ts.map +1 -1
  72. package/dist/feature-libraries/flex-tree/flexTreeTypes.js +4 -0
  73. package/dist/feature-libraries/flex-tree/flexTreeTypes.js.map +1 -1
  74. package/dist/feature-libraries/flex-tree/index.d.ts +2 -3
  75. package/dist/feature-libraries/flex-tree/index.d.ts.map +1 -1
  76. package/dist/feature-libraries/flex-tree/index.js +1 -7
  77. package/dist/feature-libraries/flex-tree/index.js.map +1 -1
  78. package/dist/feature-libraries/flex-tree/lazyEntity.d.ts +2 -2
  79. package/dist/feature-libraries/flex-tree/lazyEntity.d.ts.map +1 -1
  80. package/dist/feature-libraries/flex-tree/lazyEntity.js +3 -0
  81. package/dist/feature-libraries/flex-tree/lazyEntity.js.map +1 -1
  82. package/dist/feature-libraries/flex-tree/lazyField.d.ts +6 -7
  83. package/dist/feature-libraries/flex-tree/lazyField.d.ts.map +1 -1
  84. package/dist/feature-libraries/flex-tree/lazyField.js +2 -5
  85. package/dist/feature-libraries/flex-tree/lazyField.js.map +1 -1
  86. package/dist/feature-libraries/flex-tree/lazyNode.d.ts +8 -7
  87. package/dist/feature-libraries/flex-tree/lazyNode.d.ts.map +1 -1
  88. package/dist/feature-libraries/flex-tree/lazyNode.js +17 -6
  89. package/dist/feature-libraries/flex-tree/lazyNode.js.map +1 -1
  90. package/dist/feature-libraries/forest-summary/forestSummarizer.d.ts +10 -5
  91. package/dist/feature-libraries/forest-summary/forestSummarizer.d.ts.map +1 -1
  92. package/dist/feature-libraries/forest-summary/forestSummarizer.js +9 -12
  93. package/dist/feature-libraries/forest-summary/forestSummarizer.js.map +1 -1
  94. package/dist/feature-libraries/index.d.ts +2 -2
  95. package/dist/feature-libraries/index.d.ts.map +1 -1
  96. package/dist/feature-libraries/index.js +4 -3
  97. package/dist/feature-libraries/index.js.map +1 -1
  98. package/dist/feature-libraries/mapTreeCursor.d.ts +53 -3
  99. package/dist/feature-libraries/mapTreeCursor.d.ts.map +1 -1
  100. package/dist/feature-libraries/mapTreeCursor.js +45 -7
  101. package/dist/feature-libraries/mapTreeCursor.js.map +1 -1
  102. package/dist/feature-libraries/modular-schema/fieldKindWithEditor.d.ts.map +1 -1
  103. package/dist/feature-libraries/modular-schema/fieldKindWithEditor.js +2 -0
  104. package/dist/feature-libraries/modular-schema/fieldKindWithEditor.js.map +1 -1
  105. package/dist/feature-libraries/modular-schema/modularChangeCodecs.d.ts +1 -1
  106. package/dist/feature-libraries/modular-schema/modularChangeCodecs.d.ts.map +1 -1
  107. package/dist/feature-libraries/modular-schema/modularChangeCodecs.js +5 -5
  108. package/dist/feature-libraries/modular-schema/modularChangeCodecs.js.map +1 -1
  109. package/dist/feature-libraries/object-forest/objectForest.d.ts.map +1 -1
  110. package/dist/feature-libraries/object-forest/objectForest.js +2 -0
  111. package/dist/feature-libraries/object-forest/objectForest.js.map +1 -1
  112. package/dist/feature-libraries/schema-edits/schemaChangeCodecs.d.ts.map +1 -1
  113. package/dist/feature-libraries/schema-edits/schemaChangeCodecs.js +8 -4
  114. package/dist/feature-libraries/schema-edits/schemaChangeCodecs.js.map +1 -1
  115. package/dist/feature-libraries/schema-edits/schemaChangeFormat.d.ts +2 -36
  116. package/dist/feature-libraries/schema-edits/schemaChangeFormat.d.ts.map +1 -1
  117. package/dist/feature-libraries/schema-edits/schemaChangeFormat.js +3 -3
  118. package/dist/feature-libraries/schema-edits/schemaChangeFormat.js.map +1 -1
  119. package/dist/feature-libraries/schema-index/codec.d.ts.map +1 -1
  120. package/dist/feature-libraries/schema-index/codec.js +59 -9
  121. package/dist/feature-libraries/schema-index/codec.js.map +1 -1
  122. package/dist/feature-libraries/schema-index/formatV1.d.ts +1 -1
  123. package/dist/feature-libraries/schema-index/formatV2.d.ts +42 -0
  124. package/dist/feature-libraries/schema-index/formatV2.d.ts.map +1 -0
  125. package/dist/feature-libraries/schema-index/formatV2.js +26 -0
  126. package/dist/feature-libraries/schema-index/formatV2.js.map +1 -0
  127. package/dist/feature-libraries/schema-index/index.d.ts +2 -1
  128. package/dist/feature-libraries/schema-index/index.d.ts.map +1 -1
  129. package/dist/feature-libraries/schema-index/index.js +4 -2
  130. package/dist/feature-libraries/schema-index/index.js.map +1 -1
  131. package/dist/feature-libraries/schema-index/schemaSummarizer.d.ts +7 -2
  132. package/dist/feature-libraries/schema-index/schemaSummarizer.d.ts.map +1 -1
  133. package/dist/feature-libraries/schema-index/schemaSummarizer.js +6 -6
  134. package/dist/feature-libraries/schema-index/schemaSummarizer.js.map +1 -1
  135. package/dist/feature-libraries/treeCursorUtils.d.ts +5 -1
  136. package/dist/feature-libraries/treeCursorUtils.d.ts.map +1 -1
  137. package/dist/feature-libraries/treeCursorUtils.js +8 -2
  138. package/dist/feature-libraries/treeCursorUtils.js.map +1 -1
  139. package/dist/index.d.ts +3 -3
  140. package/dist/index.d.ts.map +1 -1
  141. package/dist/index.js.map +1 -1
  142. package/dist/packageVersion.d.ts +1 -1
  143. package/dist/packageVersion.d.ts.map +1 -1
  144. package/dist/packageVersion.js +1 -1
  145. package/dist/packageVersion.js.map +1 -1
  146. package/dist/shared-tree/schematizeTree.d.ts.map +1 -1
  147. package/dist/shared-tree/schematizeTree.js +1 -0
  148. package/dist/shared-tree/schematizeTree.js.map +1 -1
  149. package/dist/shared-tree/schematizingTreeView.d.ts +11 -1
  150. package/dist/shared-tree/schematizingTreeView.d.ts.map +1 -1
  151. package/dist/shared-tree/schematizingTreeView.js +36 -22
  152. package/dist/shared-tree/schematizingTreeView.js.map +1 -1
  153. package/dist/shared-tree/sharedTree.d.ts +8 -4
  154. package/dist/shared-tree/sharedTree.d.ts.map +1 -1
  155. package/dist/shared-tree/sharedTree.js +35 -5
  156. package/dist/shared-tree/sharedTree.js.map +1 -1
  157. package/dist/shared-tree/tree.d.ts.map +1 -1
  158. package/dist/shared-tree/tree.js +8 -24
  159. package/dist/shared-tree/tree.js.map +1 -1
  160. package/dist/shared-tree/treeAlpha.d.ts +2 -3
  161. package/dist/shared-tree/treeAlpha.d.ts.map +1 -1
  162. package/dist/shared-tree/treeAlpha.js +4 -5
  163. package/dist/shared-tree/treeAlpha.js.map +1 -1
  164. package/dist/shared-tree/treeCheckout.d.ts.map +1 -1
  165. package/dist/shared-tree/treeCheckout.js +5 -2
  166. package/dist/shared-tree/treeCheckout.js.map +1 -1
  167. package/dist/shared-tree-core/editManagerSummarizer.d.ts +8 -3
  168. package/dist/shared-tree-core/editManagerSummarizer.d.ts.map +1 -1
  169. package/dist/shared-tree-core/editManagerSummarizer.js +2 -5
  170. package/dist/shared-tree-core/editManagerSummarizer.js.map +1 -1
  171. package/dist/shared-tree-core/sharedTreeCore.d.ts +18 -7
  172. package/dist/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
  173. package/dist/shared-tree-core/sharedTreeCore.js +15 -2
  174. package/dist/shared-tree-core/sharedTreeCore.js.map +1 -1
  175. package/dist/simple-tree/api/configuration.d.ts +2 -2
  176. package/dist/simple-tree/api/configuration.js +1 -1
  177. package/dist/simple-tree/api/configuration.js.map +1 -1
  178. package/dist/simple-tree/api/create.d.ts +9 -4
  179. package/dist/simple-tree/api/create.d.ts.map +1 -1
  180. package/dist/simple-tree/api/create.js +29 -16
  181. package/dist/simple-tree/api/create.js.map +1 -1
  182. package/dist/simple-tree/api/customTree.d.ts +4 -0
  183. package/dist/simple-tree/api/customTree.d.ts.map +1 -1
  184. package/dist/simple-tree/api/customTree.js +9 -1
  185. package/dist/simple-tree/api/customTree.js.map +1 -1
  186. package/dist/simple-tree/api/index.d.ts +1 -1
  187. package/dist/simple-tree/api/index.d.ts.map +1 -1
  188. package/dist/simple-tree/api/index.js +1 -2
  189. package/dist/simple-tree/api/index.js.map +1 -1
  190. package/dist/simple-tree/api/schemaCompatibilityTester.js +1 -1
  191. package/dist/simple-tree/api/schemaCompatibilityTester.js.map +1 -1
  192. package/dist/simple-tree/api/schemaCreationUtilities.d.ts +3 -3
  193. package/dist/simple-tree/api/schemaCreationUtilities.js +3 -3
  194. package/dist/simple-tree/api/schemaCreationUtilities.js.map +1 -1
  195. package/dist/simple-tree/api/schemaFactory.d.ts +25 -13
  196. package/dist/simple-tree/api/schemaFactory.d.ts.map +1 -1
  197. package/dist/simple-tree/api/schemaFactory.js +42 -9
  198. package/dist/simple-tree/api/schemaFactory.js.map +1 -1
  199. package/dist/simple-tree/api/schemaFactoryAlpha.d.ts +41 -11
  200. package/dist/simple-tree/api/schemaFactoryAlpha.d.ts.map +1 -1
  201. package/dist/simple-tree/api/schemaFactoryAlpha.js +31 -4
  202. package/dist/simple-tree/api/schemaFactoryAlpha.js.map +1 -1
  203. package/dist/simple-tree/api/storedSchema.js +2 -2
  204. package/dist/simple-tree/api/storedSchema.js.map +1 -1
  205. package/dist/simple-tree/api/treeChangeEvents.d.ts +8 -3
  206. package/dist/simple-tree/api/treeChangeEvents.d.ts.map +1 -1
  207. package/dist/simple-tree/api/treeChangeEvents.js.map +1 -1
  208. package/dist/simple-tree/api/treeNodeApi.d.ts +14 -3
  209. package/dist/simple-tree/api/treeNodeApi.d.ts.map +1 -1
  210. package/dist/simple-tree/api/treeNodeApi.js +32 -17
  211. package/dist/simple-tree/api/treeNodeApi.js.map +1 -1
  212. package/dist/simple-tree/api/verboseTree.d.ts.map +1 -1
  213. package/dist/simple-tree/api/verboseTree.js +12 -9
  214. package/dist/simple-tree/api/verboseTree.js.map +1 -1
  215. package/dist/simple-tree/api/viewSchemaToSimpleSchema.d.ts.map +1 -1
  216. package/dist/simple-tree/api/viewSchemaToSimpleSchema.js +5 -0
  217. package/dist/simple-tree/api/viewSchemaToSimpleSchema.js.map +1 -1
  218. package/dist/simple-tree/core/getOrCreateNode.d.ts.map +1 -1
  219. package/dist/simple-tree/core/getOrCreateNode.js +2 -1
  220. package/dist/simple-tree/core/getOrCreateNode.js.map +1 -1
  221. package/dist/simple-tree/core/index.d.ts +2 -2
  222. package/dist/simple-tree/core/index.d.ts.map +1 -1
  223. package/dist/simple-tree/core/index.js +3 -4
  224. package/dist/simple-tree/core/index.js.map +1 -1
  225. package/dist/simple-tree/core/treeNodeKernel.d.ts +15 -25
  226. package/dist/simple-tree/core/treeNodeKernel.d.ts.map +1 -1
  227. package/dist/simple-tree/core/treeNodeKernel.js +27 -34
  228. package/dist/simple-tree/core/treeNodeKernel.js.map +1 -1
  229. package/dist/simple-tree/core/unhydratedFlexTree.d.ts +129 -64
  230. package/dist/simple-tree/core/unhydratedFlexTree.d.ts.map +1 -1
  231. package/dist/simple-tree/core/unhydratedFlexTree.js +175 -207
  232. package/dist/simple-tree/core/unhydratedFlexTree.js.map +1 -1
  233. package/dist/simple-tree/index.d.ts +5 -5
  234. package/dist/simple-tree/index.d.ts.map +1 -1
  235. package/dist/simple-tree/index.js +5 -5
  236. package/dist/simple-tree/index.js.map +1 -1
  237. package/dist/simple-tree/leafNodeSchema.d.ts +2 -0
  238. package/dist/simple-tree/leafNodeSchema.d.ts.map +1 -1
  239. package/dist/simple-tree/leafNodeSchema.js.map +1 -1
  240. package/dist/simple-tree/node-kinds/array/arrayNode.d.ts +3 -1
  241. package/dist/simple-tree/node-kinds/array/arrayNode.d.ts.map +1 -1
  242. package/dist/simple-tree/node-kinds/array/arrayNode.js +8 -7
  243. package/dist/simple-tree/node-kinds/array/arrayNode.js.map +1 -1
  244. package/dist/simple-tree/node-kinds/index.d.ts +1 -1
  245. package/dist/simple-tree/node-kinds/index.d.ts.map +1 -1
  246. package/dist/simple-tree/node-kinds/index.js +1 -2
  247. package/dist/simple-tree/node-kinds/index.js.map +1 -1
  248. package/dist/simple-tree/node-kinds/map/mapNode.d.ts +3 -2
  249. package/dist/simple-tree/node-kinds/map/mapNode.d.ts.map +1 -1
  250. package/dist/simple-tree/node-kinds/map/mapNode.js +6 -4
  251. package/dist/simple-tree/node-kinds/map/mapNode.js.map +1 -1
  252. package/dist/simple-tree/node-kinds/object/index.d.ts +1 -1
  253. package/dist/simple-tree/node-kinds/object/index.d.ts.map +1 -1
  254. package/dist/simple-tree/node-kinds/object/index.js +1 -2
  255. package/dist/simple-tree/node-kinds/object/index.js.map +1 -1
  256. package/dist/simple-tree/node-kinds/object/objectNode.d.ts +5 -15
  257. package/dist/simple-tree/node-kinds/object/objectNode.d.ts.map +1 -1
  258. package/dist/simple-tree/node-kinds/object/objectNode.js +15 -44
  259. package/dist/simple-tree/node-kinds/object/objectNode.js.map +1 -1
  260. package/dist/simple-tree/prepareForInsertion.d.ts +20 -6
  261. package/dist/simple-tree/prepareForInsertion.d.ts.map +1 -1
  262. package/dist/simple-tree/prepareForInsertion.js +31 -20
  263. package/dist/simple-tree/prepareForInsertion.js.map +1 -1
  264. package/dist/simple-tree/schemaTypes.d.ts +56 -9
  265. package/dist/simple-tree/schemaTypes.d.ts.map +1 -1
  266. package/dist/simple-tree/schemaTypes.js +28 -1
  267. package/dist/simple-tree/schemaTypes.js.map +1 -1
  268. package/dist/simple-tree/simpleSchema.d.ts +22 -4
  269. package/dist/simple-tree/simpleSchema.d.ts.map +1 -1
  270. package/dist/simple-tree/simpleSchema.js.map +1 -1
  271. package/dist/simple-tree/toStoredSchema.d.ts +8 -1
  272. package/dist/simple-tree/toStoredSchema.d.ts.map +1 -1
  273. package/dist/simple-tree/toStoredSchema.js +19 -7
  274. package/dist/simple-tree/toStoredSchema.js.map +1 -1
  275. package/{lib/simple-tree/toMapTree.d.ts → dist/simple-tree/unhydratedFlexTreeFromInsertable.d.ts} +12 -23
  276. package/dist/simple-tree/unhydratedFlexTreeFromInsertable.d.ts.map +1 -0
  277. package/dist/simple-tree/{toMapTree.js → unhydratedFlexTreeFromInsertable.js} +103 -185
  278. package/dist/simple-tree/unhydratedFlexTreeFromInsertable.js.map +1 -0
  279. package/dist/tableSchema.d.ts +1 -1
  280. package/dist/treeFactory.d.ts.map +1 -1
  281. package/dist/treeFactory.js +6 -1
  282. package/dist/treeFactory.js.map +1 -1
  283. package/dist/util/index.d.ts +1 -1
  284. package/dist/util/index.d.ts.map +1 -1
  285. package/dist/util/index.js +2 -1
  286. package/dist/util/index.js.map +1 -1
  287. package/dist/util/typeUtils.d.ts +2 -2
  288. package/dist/util/typeUtils.js.map +1 -1
  289. package/dist/util/utils.d.ts +6 -0
  290. package/dist/util/utils.d.ts.map +1 -1
  291. package/dist/util/utils.js +8 -1
  292. package/dist/util/utils.js.map +1 -1
  293. package/docs/user-facing/schema-evolution.md +1 -1
  294. package/lib/alpha.d.ts +12 -6
  295. package/lib/beta.d.ts +6 -1
  296. package/lib/codec/codec.d.ts +23 -3
  297. package/lib/codec/codec.d.ts.map +1 -1
  298. package/lib/codec/codec.js.map +1 -1
  299. package/lib/codec/index.d.ts +1 -1
  300. package/lib/codec/index.d.ts.map +1 -1
  301. package/lib/codec/index.js.map +1 -1
  302. package/lib/codec/versioned/codec.d.ts +35 -2
  303. package/lib/codec/versioned/codec.d.ts.map +1 -1
  304. package/lib/codec/versioned/codec.js +36 -2
  305. package/lib/codec/versioned/codec.js.map +1 -1
  306. package/lib/core/index.d.ts +1 -1
  307. package/lib/core/index.d.ts.map +1 -1
  308. package/lib/core/index.js +1 -1
  309. package/lib/core/index.js.map +1 -1
  310. package/lib/core/schema-stored/formatV2.d.ts +80 -0
  311. package/lib/core/schema-stored/formatV2.d.ts.map +1 -0
  312. package/lib/core/schema-stored/formatV2.js +52 -0
  313. package/lib/core/schema-stored/formatV2.js.map +1 -0
  314. package/lib/core/schema-stored/index.d.ts +3 -1
  315. package/lib/core/schema-stored/index.d.ts.map +1 -1
  316. package/lib/core/schema-stored/index.js +3 -1
  317. package/lib/core/schema-stored/index.js.map +1 -1
  318. package/lib/core/schema-stored/schema.d.ts +49 -17
  319. package/lib/core/schema-stored/schema.d.ts.map +1 -1
  320. package/lib/core/schema-stored/schema.js +63 -21
  321. package/lib/core/schema-stored/schema.js.map +1 -1
  322. package/lib/core/tree/detachedFieldIndex.d.ts +2 -2
  323. package/lib/core/tree/detachedFieldIndex.d.ts.map +1 -1
  324. package/lib/core/tree/detachedFieldIndex.js +6 -2
  325. package/lib/core/tree/detachedFieldIndex.js.map +1 -1
  326. package/lib/core/tree/mapTree.d.ts +2 -1
  327. package/lib/core/tree/mapTree.d.ts.map +1 -1
  328. package/lib/core/tree/mapTree.js +11 -5
  329. package/lib/core/tree/mapTree.js.map +1 -1
  330. package/lib/core/tree/visitorUtils.d.ts +2 -2
  331. package/lib/core/tree/visitorUtils.d.ts.map +1 -1
  332. package/lib/core/tree/visitorUtils.js.map +1 -1
  333. package/lib/feature-libraries/chunked-forest/codec/chunkEncodingGeneric.d.ts +9 -7
  334. package/lib/feature-libraries/chunked-forest/codec/chunkEncodingGeneric.d.ts.map +1 -1
  335. package/lib/feature-libraries/chunked-forest/codec/chunkEncodingGeneric.js +11 -7
  336. package/lib/feature-libraries/chunked-forest/codec/chunkEncodingGeneric.js.map +1 -1
  337. package/lib/feature-libraries/chunked-forest/codec/compressedEncode.d.ts +3 -3
  338. package/lib/feature-libraries/chunked-forest/codec/compressedEncode.d.ts.map +1 -1
  339. package/lib/feature-libraries/chunked-forest/codec/compressedEncode.js +7 -7
  340. package/lib/feature-libraries/chunked-forest/codec/compressedEncode.js.map +1 -1
  341. package/lib/feature-libraries/chunked-forest/codec/nodeShape.d.ts +1 -1
  342. package/lib/feature-libraries/chunked-forest/codec/nodeShape.d.ts.map +1 -1
  343. package/lib/feature-libraries/chunked-forest/codec/nodeShape.js +3 -3
  344. package/lib/feature-libraries/chunked-forest/codec/nodeShape.js.map +1 -1
  345. package/lib/feature-libraries/default-schema/defaultEditBuilder.d.ts +3 -2
  346. package/lib/feature-libraries/default-schema/defaultEditBuilder.d.ts.map +1 -1
  347. package/lib/feature-libraries/default-schema/defaultEditBuilder.js.map +1 -1
  348. package/lib/feature-libraries/default-schema/schemaChecker.d.ts +4 -3
  349. package/lib/feature-libraries/default-schema/schemaChecker.d.ts.map +1 -1
  350. package/lib/feature-libraries/default-schema/schemaChecker.js +4 -3
  351. package/lib/feature-libraries/default-schema/schemaChecker.js.map +1 -1
  352. package/lib/feature-libraries/detachedFieldIndexSummarizer.d.ts +8 -3
  353. package/lib/feature-libraries/detachedFieldIndexSummarizer.d.ts.map +1 -1
  354. package/lib/feature-libraries/detachedFieldIndexSummarizer.js +2 -5
  355. package/lib/feature-libraries/detachedFieldIndexSummarizer.js.map +1 -1
  356. package/lib/feature-libraries/flex-tree/context.d.ts +14 -6
  357. package/lib/feature-libraries/flex-tree/context.d.ts.map +1 -1
  358. package/lib/feature-libraries/flex-tree/context.js.map +1 -1
  359. package/lib/feature-libraries/flex-tree/flexTreeTypes.d.ts +48 -29
  360. package/lib/feature-libraries/flex-tree/flexTreeTypes.d.ts.map +1 -1
  361. package/lib/feature-libraries/flex-tree/flexTreeTypes.js +4 -0
  362. package/lib/feature-libraries/flex-tree/flexTreeTypes.js.map +1 -1
  363. package/lib/feature-libraries/flex-tree/index.d.ts +2 -3
  364. package/lib/feature-libraries/flex-tree/index.d.ts.map +1 -1
  365. package/lib/feature-libraries/flex-tree/index.js +0 -1
  366. package/lib/feature-libraries/flex-tree/index.js.map +1 -1
  367. package/lib/feature-libraries/flex-tree/lazyEntity.d.ts +2 -2
  368. package/lib/feature-libraries/flex-tree/lazyEntity.d.ts.map +1 -1
  369. package/lib/feature-libraries/flex-tree/lazyEntity.js +3 -0
  370. package/lib/feature-libraries/flex-tree/lazyEntity.js.map +1 -1
  371. package/lib/feature-libraries/flex-tree/lazyField.d.ts +6 -7
  372. package/lib/feature-libraries/flex-tree/lazyField.d.ts.map +1 -1
  373. package/lib/feature-libraries/flex-tree/lazyField.js +3 -6
  374. package/lib/feature-libraries/flex-tree/lazyField.js.map +1 -1
  375. package/lib/feature-libraries/flex-tree/lazyNode.d.ts +8 -7
  376. package/lib/feature-libraries/flex-tree/lazyNode.d.ts.map +1 -1
  377. package/lib/feature-libraries/flex-tree/lazyNode.js +17 -6
  378. package/lib/feature-libraries/flex-tree/lazyNode.js.map +1 -1
  379. package/lib/feature-libraries/forest-summary/forestSummarizer.d.ts +10 -5
  380. package/lib/feature-libraries/forest-summary/forestSummarizer.d.ts.map +1 -1
  381. package/lib/feature-libraries/forest-summary/forestSummarizer.js +4 -7
  382. package/lib/feature-libraries/forest-summary/forestSummarizer.js.map +1 -1
  383. package/lib/feature-libraries/index.d.ts +2 -2
  384. package/lib/feature-libraries/index.d.ts.map +1 -1
  385. package/lib/feature-libraries/index.js +2 -2
  386. package/lib/feature-libraries/index.js.map +1 -1
  387. package/lib/feature-libraries/mapTreeCursor.d.ts +53 -3
  388. package/lib/feature-libraries/mapTreeCursor.d.ts.map +1 -1
  389. package/lib/feature-libraries/mapTreeCursor.js +43 -7
  390. package/lib/feature-libraries/mapTreeCursor.js.map +1 -1
  391. package/lib/feature-libraries/modular-schema/fieldKindWithEditor.d.ts.map +1 -1
  392. package/lib/feature-libraries/modular-schema/fieldKindWithEditor.js +2 -0
  393. package/lib/feature-libraries/modular-schema/fieldKindWithEditor.js.map +1 -1
  394. package/lib/feature-libraries/modular-schema/modularChangeCodecs.d.ts +1 -1
  395. package/lib/feature-libraries/modular-schema/modularChangeCodecs.d.ts.map +1 -1
  396. package/lib/feature-libraries/modular-schema/modularChangeCodecs.js +5 -5
  397. package/lib/feature-libraries/modular-schema/modularChangeCodecs.js.map +1 -1
  398. package/lib/feature-libraries/object-forest/objectForest.d.ts.map +1 -1
  399. package/lib/feature-libraries/object-forest/objectForest.js +2 -0
  400. package/lib/feature-libraries/object-forest/objectForest.js.map +1 -1
  401. package/lib/feature-libraries/schema-edits/schemaChangeCodecs.d.ts.map +1 -1
  402. package/lib/feature-libraries/schema-edits/schemaChangeCodecs.js +8 -4
  403. package/lib/feature-libraries/schema-edits/schemaChangeCodecs.js.map +1 -1
  404. package/lib/feature-libraries/schema-edits/schemaChangeFormat.d.ts +2 -36
  405. package/lib/feature-libraries/schema-edits/schemaChangeFormat.d.ts.map +1 -1
  406. package/lib/feature-libraries/schema-edits/schemaChangeFormat.js +3 -3
  407. package/lib/feature-libraries/schema-edits/schemaChangeFormat.js.map +1 -1
  408. package/lib/feature-libraries/schema-index/codec.d.ts.map +1 -1
  409. package/lib/feature-libraries/schema-index/codec.js +60 -10
  410. package/lib/feature-libraries/schema-index/codec.js.map +1 -1
  411. package/lib/feature-libraries/schema-index/formatV1.d.ts +1 -1
  412. package/lib/feature-libraries/schema-index/formatV2.d.ts +42 -0
  413. package/lib/feature-libraries/schema-index/formatV2.d.ts.map +1 -0
  414. package/lib/feature-libraries/schema-index/formatV2.js +23 -0
  415. package/lib/feature-libraries/schema-index/formatV2.js.map +1 -0
  416. package/lib/feature-libraries/schema-index/index.d.ts +2 -1
  417. package/lib/feature-libraries/schema-index/index.d.ts.map +1 -1
  418. package/lib/feature-libraries/schema-index/index.js +2 -1
  419. package/lib/feature-libraries/schema-index/index.js.map +1 -1
  420. package/lib/feature-libraries/schema-index/schemaSummarizer.d.ts +7 -2
  421. package/lib/feature-libraries/schema-index/schemaSummarizer.d.ts.map +1 -1
  422. package/lib/feature-libraries/schema-index/schemaSummarizer.js +6 -6
  423. package/lib/feature-libraries/schema-index/schemaSummarizer.js.map +1 -1
  424. package/lib/feature-libraries/treeCursorUtils.d.ts +5 -1
  425. package/lib/feature-libraries/treeCursorUtils.d.ts.map +1 -1
  426. package/lib/feature-libraries/treeCursorUtils.js +8 -2
  427. package/lib/feature-libraries/treeCursorUtils.js.map +1 -1
  428. package/lib/index.d.ts +3 -3
  429. package/lib/index.d.ts.map +1 -1
  430. package/lib/index.js.map +1 -1
  431. package/lib/packageVersion.d.ts +1 -1
  432. package/lib/packageVersion.d.ts.map +1 -1
  433. package/lib/packageVersion.js +1 -1
  434. package/lib/packageVersion.js.map +1 -1
  435. package/lib/shared-tree/schematizeTree.d.ts.map +1 -1
  436. package/lib/shared-tree/schematizeTree.js +1 -0
  437. package/lib/shared-tree/schematizeTree.js.map +1 -1
  438. package/lib/shared-tree/schematizingTreeView.d.ts +11 -1
  439. package/lib/shared-tree/schematizingTreeView.d.ts.map +1 -1
  440. package/lib/shared-tree/schematizingTreeView.js +34 -21
  441. package/lib/shared-tree/schematizingTreeView.js.map +1 -1
  442. package/lib/shared-tree/sharedTree.d.ts +8 -4
  443. package/lib/shared-tree/sharedTree.d.ts.map +1 -1
  444. package/lib/shared-tree/sharedTree.js +36 -6
  445. package/lib/shared-tree/sharedTree.js.map +1 -1
  446. package/lib/shared-tree/tree.d.ts.map +1 -1
  447. package/lib/shared-tree/tree.js +2 -18
  448. package/lib/shared-tree/tree.js.map +1 -1
  449. package/lib/shared-tree/treeAlpha.d.ts +2 -3
  450. package/lib/shared-tree/treeAlpha.d.ts.map +1 -1
  451. package/lib/shared-tree/treeAlpha.js +6 -7
  452. package/lib/shared-tree/treeAlpha.js.map +1 -1
  453. package/lib/shared-tree/treeCheckout.d.ts.map +1 -1
  454. package/lib/shared-tree/treeCheckout.js +6 -3
  455. package/lib/shared-tree/treeCheckout.js.map +1 -1
  456. package/lib/shared-tree-core/editManagerSummarizer.d.ts +8 -3
  457. package/lib/shared-tree-core/editManagerSummarizer.d.ts.map +1 -1
  458. package/lib/shared-tree-core/editManagerSummarizer.js +2 -5
  459. package/lib/shared-tree-core/editManagerSummarizer.js.map +1 -1
  460. package/lib/shared-tree-core/sharedTreeCore.d.ts +18 -7
  461. package/lib/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
  462. package/lib/shared-tree-core/sharedTreeCore.js +15 -2
  463. package/lib/shared-tree-core/sharedTreeCore.js.map +1 -1
  464. package/lib/simple-tree/api/configuration.d.ts +2 -2
  465. package/lib/simple-tree/api/configuration.js +1 -1
  466. package/lib/simple-tree/api/configuration.js.map +1 -1
  467. package/lib/simple-tree/api/create.d.ts +9 -4
  468. package/lib/simple-tree/api/create.d.ts.map +1 -1
  469. package/lib/simple-tree/api/create.js +22 -9
  470. package/lib/simple-tree/api/create.js.map +1 -1
  471. package/lib/simple-tree/api/customTree.d.ts +4 -0
  472. package/lib/simple-tree/api/customTree.d.ts.map +1 -1
  473. package/lib/simple-tree/api/customTree.js +7 -0
  474. package/lib/simple-tree/api/customTree.js.map +1 -1
  475. package/lib/simple-tree/api/index.d.ts +1 -1
  476. package/lib/simple-tree/api/index.d.ts.map +1 -1
  477. package/lib/simple-tree/api/index.js +1 -1
  478. package/lib/simple-tree/api/index.js.map +1 -1
  479. package/lib/simple-tree/api/schemaCompatibilityTester.js +1 -1
  480. package/lib/simple-tree/api/schemaCompatibilityTester.js.map +1 -1
  481. package/lib/simple-tree/api/schemaCreationUtilities.d.ts +3 -3
  482. package/lib/simple-tree/api/schemaCreationUtilities.js +3 -3
  483. package/lib/simple-tree/api/schemaCreationUtilities.js.map +1 -1
  484. package/lib/simple-tree/api/schemaFactory.d.ts +25 -13
  485. package/lib/simple-tree/api/schemaFactory.d.ts.map +1 -1
  486. package/lib/simple-tree/api/schemaFactory.js +44 -11
  487. package/lib/simple-tree/api/schemaFactory.js.map +1 -1
  488. package/lib/simple-tree/api/schemaFactoryAlpha.d.ts +41 -11
  489. package/lib/simple-tree/api/schemaFactoryAlpha.d.ts.map +1 -1
  490. package/lib/simple-tree/api/schemaFactoryAlpha.js +31 -4
  491. package/lib/simple-tree/api/schemaFactoryAlpha.js.map +1 -1
  492. package/lib/simple-tree/api/storedSchema.js +2 -2
  493. package/lib/simple-tree/api/storedSchema.js.map +1 -1
  494. package/lib/simple-tree/api/treeChangeEvents.d.ts +8 -3
  495. package/lib/simple-tree/api/treeChangeEvents.d.ts.map +1 -1
  496. package/lib/simple-tree/api/treeChangeEvents.js.map +1 -1
  497. package/lib/simple-tree/api/treeNodeApi.d.ts +14 -3
  498. package/lib/simple-tree/api/treeNodeApi.d.ts.map +1 -1
  499. package/lib/simple-tree/api/treeNodeApi.js +35 -20
  500. package/lib/simple-tree/api/treeNodeApi.js.map +1 -1
  501. package/lib/simple-tree/api/verboseTree.d.ts.map +1 -1
  502. package/lib/simple-tree/api/verboseTree.js +13 -10
  503. package/lib/simple-tree/api/verboseTree.js.map +1 -1
  504. package/lib/simple-tree/api/viewSchemaToSimpleSchema.d.ts.map +1 -1
  505. package/lib/simple-tree/api/viewSchemaToSimpleSchema.js +5 -0
  506. package/lib/simple-tree/api/viewSchemaToSimpleSchema.js.map +1 -1
  507. package/lib/simple-tree/core/getOrCreateNode.d.ts.map +1 -1
  508. package/lib/simple-tree/core/getOrCreateNode.js +3 -2
  509. package/lib/simple-tree/core/getOrCreateNode.js.map +1 -1
  510. package/lib/simple-tree/core/index.d.ts +2 -2
  511. package/lib/simple-tree/core/index.d.ts.map +1 -1
  512. package/lib/simple-tree/core/index.js +2 -2
  513. package/lib/simple-tree/core/index.js.map +1 -1
  514. package/lib/simple-tree/core/treeNodeKernel.d.ts +15 -25
  515. package/lib/simple-tree/core/treeNodeKernel.d.ts.map +1 -1
  516. package/lib/simple-tree/core/treeNodeKernel.js +25 -33
  517. package/lib/simple-tree/core/treeNodeKernel.js.map +1 -1
  518. package/lib/simple-tree/core/unhydratedFlexTree.d.ts +129 -64
  519. package/lib/simple-tree/core/unhydratedFlexTree.d.ts.map +1 -1
  520. package/lib/simple-tree/core/unhydratedFlexTree.js +174 -208
  521. package/lib/simple-tree/core/unhydratedFlexTree.js.map +1 -1
  522. package/lib/simple-tree/index.d.ts +5 -5
  523. package/lib/simple-tree/index.d.ts.map +1 -1
  524. package/lib/simple-tree/index.js +3 -3
  525. package/lib/simple-tree/index.js.map +1 -1
  526. package/lib/simple-tree/leafNodeSchema.d.ts +2 -0
  527. package/lib/simple-tree/leafNodeSchema.d.ts.map +1 -1
  528. package/lib/simple-tree/leafNodeSchema.js.map +1 -1
  529. package/lib/simple-tree/node-kinds/array/arrayNode.d.ts +3 -1
  530. package/lib/simple-tree/node-kinds/array/arrayNode.d.ts.map +1 -1
  531. package/lib/simple-tree/node-kinds/array/arrayNode.js +7 -6
  532. package/lib/simple-tree/node-kinds/array/arrayNode.js.map +1 -1
  533. package/lib/simple-tree/node-kinds/index.d.ts +1 -1
  534. package/lib/simple-tree/node-kinds/index.d.ts.map +1 -1
  535. package/lib/simple-tree/node-kinds/index.js +1 -1
  536. package/lib/simple-tree/node-kinds/index.js.map +1 -1
  537. package/lib/simple-tree/node-kinds/map/mapNode.d.ts +3 -2
  538. package/lib/simple-tree/node-kinds/map/mapNode.d.ts.map +1 -1
  539. package/lib/simple-tree/node-kinds/map/mapNode.js +8 -6
  540. package/lib/simple-tree/node-kinds/map/mapNode.js.map +1 -1
  541. package/lib/simple-tree/node-kinds/object/index.d.ts +1 -1
  542. package/lib/simple-tree/node-kinds/object/index.d.ts.map +1 -1
  543. package/lib/simple-tree/node-kinds/object/index.js +1 -1
  544. package/lib/simple-tree/node-kinds/object/index.js.map +1 -1
  545. package/lib/simple-tree/node-kinds/object/objectNode.d.ts +5 -15
  546. package/lib/simple-tree/node-kinds/object/objectNode.d.ts.map +1 -1
  547. package/lib/simple-tree/node-kinds/object/objectNode.js +6 -34
  548. package/lib/simple-tree/node-kinds/object/objectNode.js.map +1 -1
  549. package/lib/simple-tree/prepareForInsertion.d.ts +20 -6
  550. package/lib/simple-tree/prepareForInsertion.d.ts.map +1 -1
  551. package/lib/simple-tree/prepareForInsertion.js +30 -20
  552. package/lib/simple-tree/prepareForInsertion.js.map +1 -1
  553. package/lib/simple-tree/schemaTypes.d.ts +56 -9
  554. package/lib/simple-tree/schemaTypes.d.ts.map +1 -1
  555. package/lib/simple-tree/schemaTypes.js +28 -1
  556. package/lib/simple-tree/schemaTypes.js.map +1 -1
  557. package/lib/simple-tree/simpleSchema.d.ts +22 -4
  558. package/lib/simple-tree/simpleSchema.d.ts.map +1 -1
  559. package/lib/simple-tree/simpleSchema.js.map +1 -1
  560. package/lib/simple-tree/toStoredSchema.d.ts +8 -1
  561. package/lib/simple-tree/toStoredSchema.d.ts.map +1 -1
  562. package/lib/simple-tree/toStoredSchema.js +17 -5
  563. package/lib/simple-tree/toStoredSchema.js.map +1 -1
  564. package/{dist/simple-tree/toMapTree.d.ts → lib/simple-tree/unhydratedFlexTreeFromInsertable.d.ts} +12 -23
  565. package/lib/simple-tree/unhydratedFlexTreeFromInsertable.d.ts.map +1 -0
  566. package/lib/simple-tree/{toMapTree.js → unhydratedFlexTreeFromInsertable.js} +105 -186
  567. package/lib/simple-tree/unhydratedFlexTreeFromInsertable.js.map +1 -0
  568. package/lib/tableSchema.d.ts +1 -1
  569. package/lib/treeFactory.d.ts.map +1 -1
  570. package/lib/treeFactory.js +6 -1
  571. package/lib/treeFactory.js.map +1 -1
  572. package/lib/util/index.d.ts +1 -1
  573. package/lib/util/index.d.ts.map +1 -1
  574. package/lib/util/index.js +1 -1
  575. package/lib/util/index.js.map +1 -1
  576. package/lib/util/typeUtils.d.ts +2 -2
  577. package/lib/util/typeUtils.js.map +1 -1
  578. package/lib/util/utils.d.ts +6 -0
  579. package/lib/util/utils.d.ts.map +1 -1
  580. package/lib/util/utils.js +6 -0
  581. package/lib/util/utils.js.map +1 -1
  582. package/package.json +21 -21
  583. package/src/codec/codec.ts +24 -3
  584. package/src/codec/index.ts +1 -0
  585. package/src/codec/versioned/codec.ts +42 -5
  586. package/src/core/index.ts +3 -1
  587. package/src/core/schema-stored/formatV2.ts +78 -0
  588. package/src/core/schema-stored/index.ts +4 -1
  589. package/src/core/schema-stored/schema.ts +123 -33
  590. package/src/core/tree/detachedFieldIndex.ts +13 -4
  591. package/src/core/tree/mapTree.ts +22 -7
  592. package/src/core/tree/visitorUtils.ts +2 -2
  593. package/src/feature-libraries/chunked-forest/codec/chunkEncodingGeneric.ts +16 -11
  594. package/src/feature-libraries/chunked-forest/codec/compressedEncode.ts +16 -7
  595. package/src/feature-libraries/chunked-forest/codec/nodeShape.ts +4 -4
  596. package/src/feature-libraries/default-schema/defaultEditBuilder.ts +3 -2
  597. package/src/feature-libraries/default-schema/schemaChecker.ts +7 -6
  598. package/src/feature-libraries/detachedFieldIndexSummarizer.ts +9 -16
  599. package/src/feature-libraries/flex-tree/context.ts +17 -7
  600. package/src/feature-libraries/flex-tree/flexTreeTypes.ts +57 -33
  601. package/src/feature-libraries/flex-tree/index.ts +4 -8
  602. package/src/feature-libraries/flex-tree/lazyEntity.ts +5 -1
  603. package/src/feature-libraries/flex-tree/lazyField.ts +12 -13
  604. package/src/feature-libraries/flex-tree/lazyNode.ts +21 -8
  605. package/src/feature-libraries/forest-summary/forestSummarizer.ts +12 -18
  606. package/src/feature-libraries/index.ts +10 -1
  607. package/src/feature-libraries/mapTreeCursor.ts +112 -16
  608. package/src/feature-libraries/modular-schema/fieldKindWithEditor.ts +2 -0
  609. package/src/feature-libraries/modular-schema/modularChangeCodecs.ts +9 -5
  610. package/src/feature-libraries/object-forest/objectForest.ts +3 -0
  611. package/src/feature-libraries/schema-edits/schemaChangeCodecs.ts +11 -6
  612. package/src/feature-libraries/schema-edits/schemaChangeFormat.ts +3 -3
  613. package/src/feature-libraries/schema-index/codec.ts +73 -14
  614. package/src/feature-libraries/schema-index/formatV2.ts +30 -0
  615. package/src/feature-libraries/schema-index/index.ts +2 -1
  616. package/src/feature-libraries/schema-index/schemaSummarizer.ts +11 -18
  617. package/src/feature-libraries/treeCursorUtils.ts +21 -10
  618. package/src/index.ts +6 -0
  619. package/src/packageVersion.ts +1 -1
  620. package/src/shared-tree/schematizeTree.ts +1 -0
  621. package/src/shared-tree/schematizingTreeView.ts +40 -22
  622. package/src/shared-tree/sharedTree.ts +51 -15
  623. package/src/shared-tree/tree.ts +5 -20
  624. package/src/shared-tree/treeAlpha.ts +23 -12
  625. package/src/shared-tree/treeCheckout.ts +6 -3
  626. package/src/shared-tree-core/editManagerSummarizer.ts +9 -16
  627. package/src/shared-tree-core/sharedTreeCore.ts +33 -24
  628. package/src/simple-tree/api/configuration.ts +3 -3
  629. package/src/simple-tree/api/create.ts +49 -19
  630. package/src/simple-tree/api/customTree.ts +10 -0
  631. package/src/simple-tree/api/index.ts +1 -4
  632. package/src/simple-tree/api/schemaCompatibilityTester.ts +1 -1
  633. package/src/simple-tree/api/schemaCreationUtilities.ts +3 -3
  634. package/src/simple-tree/api/schemaFactory.ts +78 -24
  635. package/src/simple-tree/api/schemaFactoryAlpha.ts +53 -8
  636. package/src/simple-tree/api/storedSchema.ts +4 -4
  637. package/src/simple-tree/api/treeChangeEvents.ts +8 -3
  638. package/src/simple-tree/api/treeNodeApi.ts +48 -27
  639. package/src/simple-tree/api/verboseTree.ts +15 -12
  640. package/src/simple-tree/api/viewSchemaToSimpleSchema.ts +5 -0
  641. package/src/simple-tree/core/getOrCreateNode.ts +4 -2
  642. package/src/simple-tree/core/index.ts +2 -3
  643. package/src/simple-tree/core/treeNodeKernel.ts +38 -55
  644. package/src/simple-tree/core/unhydratedFlexTree.ts +231 -292
  645. package/src/simple-tree/index.ts +6 -3
  646. package/src/simple-tree/leafNodeSchema.ts +2 -0
  647. package/src/simple-tree/node-kinds/array/arrayNode.ts +17 -13
  648. package/src/simple-tree/node-kinds/index.ts +0 -1
  649. package/src/simple-tree/node-kinds/map/mapNode.ts +17 -11
  650. package/src/simple-tree/node-kinds/object/index.ts +0 -1
  651. package/src/simple-tree/node-kinds/object/objectNode.ts +15 -49
  652. package/src/simple-tree/prepareForInsertion.ts +54 -43
  653. package/src/simple-tree/schemaTypes.ts +103 -13
  654. package/src/simple-tree/simpleSchema.ts +27 -5
  655. package/src/simple-tree/toStoredSchema.ts +22 -5
  656. package/src/simple-tree/{toMapTree.ts → unhydratedFlexTreeFromInsertable.ts} +134 -226
  657. package/src/treeFactory.ts +6 -1
  658. package/src/util/index.ts +1 -0
  659. package/src/util/typeUtils.ts +2 -2
  660. package/src/util/utils.ts +9 -0
  661. package/dist/feature-libraries/flex-tree/navigation.d.ts +0 -46
  662. package/dist/feature-libraries/flex-tree/navigation.d.ts.map +0 -1
  663. package/dist/feature-libraries/flex-tree/navigation.js +0 -104
  664. package/dist/feature-libraries/flex-tree/navigation.js.map +0 -1
  665. package/dist/simple-tree/toMapTree.d.ts.map +0 -1
  666. package/dist/simple-tree/toMapTree.js.map +0 -1
  667. package/lib/feature-libraries/flex-tree/navigation.d.ts +0 -46
  668. package/lib/feature-libraries/flex-tree/navigation.d.ts.map +0 -1
  669. package/lib/feature-libraries/flex-tree/navigation.js +0 -97
  670. package/lib/feature-libraries/flex-tree/navigation.js.map +0 -1
  671. package/lib/simple-tree/toMapTree.d.ts.map +0 -1
  672. package/lib/simple-tree/toMapTree.js.map +0 -1
  673. package/src/feature-libraries/flex-tree/navigation.ts +0 -121
@@ -4,11 +4,11 @@
4
4
  */
5
5
  import type { FieldKey, SchemaPolicy } from "../../../core/index.js";
6
6
  import { type FlexTreeField } from "../../../feature-libraries/index.js";
7
- import { type RestrictiveStringRecord, type FlattenKeys } from "../../../util/index.js";
8
- import { NodeKind, type WithType, type TreeNode, UnhydratedFlexTreeNode } from "../../core/index.js";
7
+ import type { RestrictiveStringRecord, FlattenKeys, JsonCompatibleReadOnlyObject } from "../../../util/index.js";
8
+ import { NodeKind, type WithType, type TreeNode } from "../../core/index.js";
9
9
  import { type ObjectNodeSchema, type ObjectNodeSchemaInternalData } from "./objectNodeTypes.js";
10
10
  import { type ImplicitFieldSchema, type TreeFieldFromImplicitField, type InsertableTreeFieldFromImplicitField, type FieldSchema, FieldKind, type NodeSchemaMetadata, type ImplicitAnnotatedFieldSchema, type UnannotateSchemaRecord } from "../../schemaTypes.js";
11
- import { type InsertableContent } from "../../toMapTree.js";
11
+ import { type InsertableContent } from "../../unhydratedFlexTreeFromInsertable.js";
12
12
  /**
13
13
  * Generates the properties for an ObjectNode from its field schema object.
14
14
  * @remarks
@@ -104,25 +104,15 @@ export type SimpleKeyMap = ReadonlyMap<string | symbol, {
104
104
  storedKey: FieldKey;
105
105
  schema: FieldSchema;
106
106
  }>;
107
- /**
108
- * Modify `flexNode` to add a newly generated identifier under the given `storedKey`.
109
- * @remarks
110
- * This is used after checking if the user is trying to read an identifier field of an unhydrated node, but the identifier is not present.
111
- * This means the identifier is an "auto-generated identifier", because otherwise it would have been supplied by the user at construction time and would have been successfully read just above.
112
- * In this case, it is categorically impossible to provide an identifier (auto-generated identifiers can't be created until hydration/insertion time), so we emit an error.
113
- * @privateRemarks
114
- * TODO: this special case logic should move to the inner node (who's schema claims it has an identifier), rather than here, after we already read undefined out of a required field.
115
- * TODO: unify this with a more general defaults mechanism.
116
- */
117
- export declare function lazilyAllocateIdentifier(flexNode: UnhydratedFlexTreeNode, storedKey: FieldKey): string;
118
107
  export declare function setField(field: FlexTreeField, simpleFieldSchema: FieldSchema, value: InsertableContent | undefined): void;
119
108
  /**
120
109
  * Define a {@link TreeNodeSchema} for a {@link TreeObjectNode}.
121
110
  *
122
111
  * @param name - Unique identifier for this schema within this factory's scope.
123
112
  * @param fields - Schema for fields of the object node's schema. Defines what children can be placed under each key.
113
+ * @param persistedMetadata - Optional persisted metadata for the object node schema.
124
114
  */
125
- export declare function objectSchema<TName extends string, const T extends RestrictiveStringRecord<ImplicitAnnotatedFieldSchema>, const ImplicitlyConstructable extends boolean, const TCustomMetadata = unknown>(identifier: TName, info: T, implicitlyConstructable: ImplicitlyConstructable, allowUnknownOptionalFields: boolean, metadata?: NodeSchemaMetadata<TCustomMetadata>): ObjectNodeSchema<TName, T, ImplicitlyConstructable, TCustomMetadata> & ObjectNodeSchemaInternalData;
115
+ export declare function objectSchema<TName extends string, const T extends RestrictiveStringRecord<ImplicitAnnotatedFieldSchema>, const ImplicitlyConstructable extends boolean, const TCustomMetadata = unknown>(identifier: TName, info: T, implicitlyConstructable: ImplicitlyConstructable, allowUnknownOptionalFields: boolean, metadata?: NodeSchemaMetadata<TCustomMetadata>, persistedMetadata?: JsonCompatibleReadOnlyObject | undefined): ObjectNodeSchema<TName, T, ImplicitlyConstructable, TCustomMetadata> & ObjectNodeSchemaInternalData;
126
116
  /**
127
117
  * Creates a policy for allowing unknown optional fields on an object node which delegates to the policy defined
128
118
  * on the object node's internal schema data.
@@ -1 +1 @@
1
- {"version":3,"file":"objectNode.d.ts","sourceRoot":"","sources":["../../../../src/simple-tree/node-kinds/object/objectNode.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAOH,OAAO,KAAK,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACrE,OAAO,EAEN,KAAK,aAAa,EAIlB,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EAAE,KAAK,uBAAuB,EAAE,KAAK,WAAW,EAAS,MAAM,wBAAwB,CAAC;AAE/F,OAAO,EAEN,QAAQ,EACR,KAAK,QAAQ,EAKb,KAAK,QAAQ,EAEb,sBAAsB,EAEtB,MAAM,qBAAqB,CAAC;AAG7B,OAAO,EAEN,KAAK,gBAAgB,EACrB,KAAK,4BAA4B,EACjC,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EACN,KAAK,mBAAmB,EAGxB,KAAK,0BAA0B,EAC/B,KAAK,oCAAoC,EACzC,KAAK,WAAW,EAGhB,SAAS,EACT,KAAK,kBAAkB,EAGvB,KAAK,4BAA4B,EAEjC,KAAK,sBAAsB,EAC3B,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAAuB,KAAK,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAIjF;;;;;;;GAOG;AACH,MAAM,MAAM,sBAAsB,CAAC,CAAC,SAAS,uBAAuB,CAAC,mBAAmB,CAAC,IACxF,uBAAuB,CAAC,mBAAmB,CAAC,SAAS,CAAC,GAEpD,EAAE,GACD;IACA,CAAC,UAAU,QAAQ,IAAI,MAAM,CAAC,GAAG,QAAQ,SAAS,MAAM,GACrD,0BAA0B,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,GACvC,OAAO;CACV,CAAC;AAEL;;;;;;;;;;;;;GAaG;AACH,MAAM,MAAM,cAAc,CACzB,CA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7C,KAAK,CAAC,eAAe,GAAG,OAAO,EAE/B,UAAU,EAAE,KAAK,EACjB,IAAI,EAAE,CAAC,EACP,uBAAuB,EAAE,uBAAuB,EAChD,0BAA0B,EAAE,OAAO,EACnC,QAAQ,CAAC,EAAE,kBAAkB,CAAC,eAAe,CAAC,EAC9C,iBAAiB,CAAC,EAAE,4BAA4B,GAAG,SAAS,GAC1D,gBAAgB,CAAC,KAAK,EAAE,CAAC,EAAE,uBAAuB,EAAE,eAAe,CAAC,GACtE,4BAA4B,CA8J5B;AA0CD;;;GAGG;AACH,wBAAgB,gCAAgC,CAC/C,MAAM,EAAE,mBAAmB,GACzB,YAAY,CAAC,4BAA4B,CAAC,CAU5C"}
@@ -4,21 +4,18 @@
4
4
  * Licensed under the MIT License.
5
5
  */
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.createUnknownOptionalFieldPolicy = exports.objectSchema = exports.setField = exports.lazilyAllocateIdentifier = void 0;
7
+ exports.createUnknownOptionalFieldPolicy = exports.objectSchema = exports.setField = void 0;
8
8
  const internal_1 = require("@fluidframework/core-utils/internal");
9
9
  const internal_2 = require("@fluidframework/telemetry-utils/internal");
10
- const internal_3 = require("@fluidframework/id-compressor/internal");
11
10
  const index_js_1 = require("../../../feature-libraries/index.js");
12
- const index_js_2 = require("../../../util/index.js");
13
- const index_js_3 = require("../../core/index.js");
11
+ const index_js_2 = require("../../core/index.js");
14
12
  const createContext_js_1 = require("../../createContext.js");
15
13
  const getTreeNodeForField_js_1 = require("../../getTreeNodeForField.js");
16
14
  const objectNodeTypes_js_1 = require("./objectNodeTypes.js");
17
15
  const prepareForInsertion_js_1 = require("../../prepareForInsertion.js");
18
16
  const schemaTypes_js_1 = require("../../schemaTypes.js");
19
- const toMapTree_js_1 = require("../../toMapTree.js");
17
+ const unhydratedFlexTreeFromInsertable_js_1 = require("../../unhydratedFlexTreeFromInsertable.js");
20
18
  const treeNodeValid_js_1 = require("../../treeNodeValid.js");
21
- const leafNodeSchema_js_1 = require("../../leafNodeSchema.js");
22
19
  /**
23
20
  * Caches the mappings from property keys to stored keys for the provided object field schemas in {@link simpleKeyToFlexKeyCache}.
24
21
  */
@@ -30,30 +27,6 @@ function createFlexKeyMapping(fields) {
30
27
  }
31
28
  return keyMap;
32
29
  }
33
- const globalIdentifierAllocator = (0, internal_3.createIdCompressor)();
34
- /**
35
- * Modify `flexNode` to add a newly generated identifier under the given `storedKey`.
36
- * @remarks
37
- * This is used after checking if the user is trying to read an identifier field of an unhydrated node, but the identifier is not present.
38
- * This means the identifier is an "auto-generated identifier", because otherwise it would have been supplied by the user at construction time and would have been successfully read just above.
39
- * In this case, it is categorically impossible to provide an identifier (auto-generated identifiers can't be created until hydration/insertion time), so we emit an error.
40
- * @privateRemarks
41
- * TODO: this special case logic should move to the inner node (who's schema claims it has an identifier), rather than here, after we already read undefined out of a required field.
42
- * TODO: unify this with a more general defaults mechanism.
43
- */
44
- function lazilyAllocateIdentifier(flexNode, storedKey) {
45
- (0, internal_1.debugAssert)(() => !flexNode.mapTree.fields.has(storedKey) || "Identifier field already set");
46
- const value = globalIdentifierAllocator.decompress(globalIdentifierAllocator.generateCompressedId());
47
- flexNode.mapTree.fields.set(storedKey, [
48
- {
49
- type: (0, index_js_2.brand)(leafNodeSchema_js_1.stringSchema.identifier),
50
- value,
51
- fields: new Map(),
52
- },
53
- ]);
54
- return value;
55
- }
56
- exports.lazilyAllocateIdentifier = lazilyAllocateIdentifier;
57
30
  /**
58
31
  * Creates a proxy handler for the given schema.
59
32
  *
@@ -76,24 +49,20 @@ function createProxyHandler(schema, allowAdditionalProperties) {
76
49
  get(target, propertyKey, proxy) {
77
50
  const fieldInfo = schema.flexKeyMap.get(propertyKey);
78
51
  if (fieldInfo !== undefined) {
79
- const flexNode = (0, index_js_3.getOrCreateInnerNode)(proxy);
52
+ const flexNode = (0, index_js_2.getOrCreateInnerNode)(proxy);
80
53
  (0, internal_1.debugAssert)(() => !flexNode.context.isDisposed() || "FlexTreeNode is disposed");
81
54
  const field = flexNode.tryGetField(fieldInfo.storedKey);
82
55
  if (field !== undefined) {
83
56
  return (0, getTreeNodeForField_js_1.getTreeNodeForField)(field);
84
57
  }
85
- if (fieldInfo.schema.kind === schemaTypes_js_1.FieldKind.Identifier &&
86
- flexNode instanceof index_js_3.UnhydratedFlexTreeNode) {
87
- return lazilyAllocateIdentifier(flexNode, fieldInfo.storedKey);
88
- }
89
58
  return undefined;
90
59
  }
91
60
  // POJO mode objects don't have TreeNode's build in members on their targets, so special case them:
92
- if (propertyKey === index_js_3.typeSchemaSymbol) {
61
+ if (propertyKey === index_js_2.typeSchemaSymbol) {
93
62
  return schema;
94
63
  }
95
64
  // eslint-disable-next-line import/no-deprecated
96
- if (propertyKey === index_js_3.typeNameSymbol) {
65
+ if (propertyKey === index_js_2.typeNameSymbol) {
97
66
  return schema.identifier;
98
67
  }
99
68
  // Pass the proxy as the receiver here, so that any methods on the prototype receive `proxy` as `this`.
@@ -107,7 +76,7 @@ function createProxyHandler(schema, allowAdditionalProperties) {
107
76
  ? Reflect.set(target, propertyKey, value, proxy)
108
77
  : false;
109
78
  }
110
- setField((0, index_js_3.getOrCreateInnerNode)(proxy).getBoxed(fieldInfo.storedKey), fieldInfo.schema, value);
79
+ setField((0, index_js_2.getOrCreateInnerNode)(proxy).getBoxed(fieldInfo.storedKey), fieldInfo.schema, value);
111
80
  return true;
112
81
  },
113
82
  deleteProperty(target, propertyKey) {
@@ -135,7 +104,7 @@ function createProxyHandler(schema, allowAdditionalProperties) {
135
104
  // If a refactoring is done to associated flex tree data with the target not the proxy, this extra map could be removed,
136
105
  // and the design would be more compatible with proxyless nodes.
137
106
  const proxy = targetToProxy.get(target) ?? (0, internal_1.fail)(0xadd /* missing proxy */);
138
- const field = (0, index_js_3.getOrCreateInnerNode)(proxy).tryGetField(fieldInfo.storedKey);
107
+ const field = (0, index_js_2.getOrCreateInnerNode)(proxy).tryGetField(fieldInfo.storedKey);
139
108
  const p = {
140
109
  value: field === undefined ? undefined : (0, getTreeNodeForField_js_1.getTreeNodeForField)(field),
141
110
  writable: true,
@@ -171,14 +140,15 @@ function setField(field, simpleFieldSchema, value) {
171
140
  exports.setField = setField;
172
141
  class CustomObjectNodeBase extends treeNodeValid_js_1.TreeNodeValid {
173
142
  }
174
- CustomObjectNodeBase.kind = index_js_3.NodeKind.Object;
143
+ CustomObjectNodeBase.kind = index_js_2.NodeKind.Object;
175
144
  /**
176
145
  * Define a {@link TreeNodeSchema} for a {@link TreeObjectNode}.
177
146
  *
178
147
  * @param name - Unique identifier for this schema within this factory's scope.
179
148
  * @param fields - Schema for fields of the object node's schema. Defines what children can be placed under each key.
149
+ * @param persistedMetadata - Optional persisted metadata for the object node schema.
180
150
  */
181
- function objectSchema(identifier, info, implicitlyConstructable, allowUnknownOptionalFields, metadata) {
151
+ function objectSchema(identifier, info, implicitlyConstructable, allowUnknownOptionalFields, metadata, persistedMetadata) {
182
152
  // Field set can't be modified after this since derived data is stored in maps.
183
153
  Object.freeze(info);
184
154
  const unannotatedInfo = (0, schemaTypes_js_1.unannotateSchemaRecord)(info);
@@ -223,7 +193,7 @@ function objectSchema(identifier, info, implicitlyConstructable, allowUnknownOpt
223
193
  return proxy;
224
194
  }
225
195
  static buildRawNode(instance, input) {
226
- return index_js_3.UnhydratedFlexTreeNode.getOrCreate(unhydratedContext, (0, toMapTree_js_1.mapTreeFromNodeData)(input, this));
196
+ return (0, unhydratedFlexTreeFromInsertable_js_1.unhydratedFlexTreeFromInsertable)(input, this);
227
197
  }
228
198
  static oneTimeSetup() {
229
199
  // One time initialization that required knowing the most derived type (from this.constructor) and thus has to be lazy.
@@ -258,10 +228,10 @@ function objectSchema(identifier, info, implicitlyConstructable, allowUnknownOpt
258
228
  return lazyChildTypes.value;
259
229
  }
260
230
  // eslint-disable-next-line import/no-deprecated
261
- get [index_js_3.typeNameSymbol]() {
231
+ get [index_js_2.typeNameSymbol]() {
262
232
  return identifier;
263
233
  }
264
- get [index_js_3.typeSchemaSymbol]() {
234
+ get [index_js_2.typeSchemaSymbol]() {
265
235
  return CustomObjectNode.constructorCached?.constructor;
266
236
  }
267
237
  }
@@ -284,6 +254,7 @@ function objectSchema(identifier, info, implicitlyConstructable, allowUnknownOpt
284
254
  CustomObjectNode.info = info;
285
255
  CustomObjectNode.implicitlyConstructable = implicitlyConstructable;
286
256
  CustomObjectNode.metadata = metadata ?? {};
257
+ CustomObjectNode.persistedMetadata = persistedMetadata;
287
258
  return CustomObjectNode;
288
259
  }
289
260
  exports.objectSchema = objectSchema;
@@ -1 +1 @@
1
- {"version":3,"file":"objectNode.js","sourceRoot":"","sources":["../../../../src/simple-tree/node-kinds/object/objectNode.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAAsF;AACtF,uEAAsE;AAEtE,qEAA4E;AAG5E,kEAM6C;AAC7C,qDAA+F;AAE/F,kDAY6B;AAC7B,6DAA8D;AAC9D,yEAAmE;AACnE,6DAI8B;AAC9B,yEAAmE;AACnE,yDAgB8B;AAE9B,qDAAiF;AACjF,6DAA6E;AAC7E,+DAAuD;AAiIvD;;GAEG;AACH,SAAS,oBAAoB,CAAC,MAA2C;IACxE,MAAM,MAAM,GAAuE,IAAI,GAAG,EAAE,CAAC;IAC7F,KAAK,MAAM,CAAC,WAAW,EAAE,WAAW,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;QACjE,MAAM,SAAS,GAAG,IAAA,6BAAY,EAAC,WAAW,EAAE,WAAW,CAAC,CAAC;QACzD,MAAM,CAAC,GAAG,CAAC,WAAW,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,IAAA,qCAAoB,EAAC,WAAW,CAAC,EAAE,CAAC,CAAC;IACnF,CAAC;IAED,OAAO,MAAM,CAAC;AACf,CAAC;AAED,MAAM,yBAAyB,GAAkB,IAAA,6BAAkB,GAAE,CAAC;AAEtE;;;;;;;;;GASG;AACH,SAAgB,wBAAwB,CACvC,QAAgC,EAChC,SAAmB;IAEnB,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AG,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;QACpD,OAAO,CACN,YAAY,KAAK,SAAS;YAC1B,IAAA,uCAAkB,EAAC,YAAY,CAAC;YAChC,YAAY,CAAC,0BAA0B,CACvC,CAAC;IACH,CAAC,CAAC;AACH,CAAC;AAZD,4EAYC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, Lazy, fail, debugAssert } from \"@fluidframework/core-utils/internal\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\nimport type { IIdCompressor } from \"@fluidframework/id-compressor\";\nimport { createIdCompressor } from \"@fluidframework/id-compressor/internal\";\n\nimport type { FieldKey, SchemaPolicy } from \"../../../core/index.js\";\nimport {\n\tFieldKinds,\n\ttype FlexTreeField,\n\ttype FlexTreeNode,\n\ttype FlexTreeOptionalField,\n\ttype FlexTreeRequiredField,\n} from \"../../../feature-libraries/index.js\";\nimport { type RestrictiveStringRecord, type FlattenKeys, brand } from \"../../../util/index.js\";\n\nimport {\n\ttype TreeNodeSchema,\n\tNodeKind,\n\ttype WithType,\n\t// eslint-disable-next-line import/no-deprecated\n\ttypeNameSymbol,\n\ttypeSchemaSymbol,\n\ttype InternalTreeNode,\n\ttype TreeNode,\n\ttype Context,\n\tUnhydratedFlexTreeNode,\n\tgetOrCreateInnerNode,\n} from \"../../core/index.js\";\nimport { getUnhydratedContext } from \"../../createContext.js\";\nimport { getTreeNodeForField } from \"../../getTreeNodeForField.js\";\nimport {\n\tisObjectNodeSchema,\n\ttype ObjectNodeSchema,\n\ttype ObjectNodeSchemaInternalData,\n} from \"./objectNodeTypes.js\";\nimport { prepareForInsertion } from \"../../prepareForInsertion.js\";\nimport {\n\ttype ImplicitFieldSchema,\n\tgetStoredKey,\n\tgetExplicitStoredKey,\n\ttype TreeFieldFromImplicitField,\n\ttype InsertableTreeFieldFromImplicitField,\n\ttype FieldSchema,\n\tnormalizeFieldSchema,\n\ttype ImplicitAllowedTypes,\n\tFieldKind,\n\ttype NodeSchemaMetadata,\n\ttype FieldSchemaAlpha,\n\tObjectFieldSchema,\n\ttype ImplicitAnnotatedFieldSchema,\n\tunannotateSchemaRecord,\n\ttype UnannotateSchemaRecord,\n} from \"../../schemaTypes.js\";\nimport type { SimpleObjectFieldSchema } from \"../../simpleSchema.js\";\nimport { mapTreeFromNodeData, type InsertableContent } from \"../../toMapTree.js\";\nimport { TreeNodeValid, type MostDerivedData } from \"../../treeNodeValid.js\";\nimport { stringSchema } from \"../../leafNodeSchema.js\";\n\n/**\n * Generates the properties for an ObjectNode from its field schema object.\n * @remarks\n * Due to {@link https://github.com/microsoft/TypeScript/issues/43826}, we can't enable implicit construction of {@link TreeNode|TreeNodes} for setters.\n * Therefore code assigning to these fields must explicitly construct nodes using the schema's constructor or create method,\n * or using some other method like {@link (TreeAlpha:interface).create}.\n * @system @public\n */\nexport type ObjectFromSchemaRecord<T extends RestrictiveStringRecord<ImplicitFieldSchema>> =\n\tRestrictiveStringRecord<ImplicitFieldSchema> extends T\n\t\t? // eslint-disable-next-line @typescript-eslint/ban-types\n\t\t\t{}\n\t\t: {\n\t\t\t\t-readonly [Property in keyof T]: Property extends string\n\t\t\t\t\t? TreeFieldFromImplicitField<T[Property]>\n\t\t\t\t\t: unknown;\n\t\t\t};\n\n/**\n * A {@link TreeNode} which models a JavaScript object.\n * @remarks\n * Object nodes consist of a type which specifies which {@link TreeNodeSchema} they use (see {@link TreeNodeApi.schema} and {@link SchemaFactory.object}),\n * and a collections of fields, each with a distinct `key` and its own {@link FieldSchema} defining what can be placed under that key.\n *\n * All fields on an object node are exposed as own properties with string keys.\n * Non-empty fields are enumerable and empty optional fields are non-enumerable own properties with the value `undefined`.\n * No other own `own` or `enumerable` properties are included on object nodes unless the user of the node manually adds custom session only state.\n * This allows a majority of general purpose JavaScript object processing operations (like `for...in`, `Reflect.ownKeys()` and `Object.entries()`) to enumerate all the children.\n *\n * The API for fields is defined by {@link ObjectFromSchemaRecord}.\n * @public\n */\nexport type TreeObjectNode<\n\tT extends RestrictiveStringRecord<ImplicitFieldSchema>,\n\tTypeName extends string = string,\n> = TreeNode & ObjectFromSchemaRecord<T> & WithType<TypeName, NodeKind.Object, T>;\n\n/**\n * Type utility for determining if an implicit field schema is known to have a default value.\n *\n * @remarks Yields `false` when unknown.\n *\n * @privateRemarks\n * TODO: Account for field schemas with default value providers.\n * For now, this only captures field kinds that we know always have defaults - optional fields and identifier fields.\n *\n * @system @public\n */\nexport type FieldHasDefault<T extends ImplicitFieldSchema> = [T] extends [\n\tFieldSchema<FieldKind.Optional | FieldKind.Identifier>,\n]\n\t? true\n\t: false;\n\n/**\n * Helper used to produce types for:\n *\n * 1. Insertable content which can be used to construct an object node.\n * In this case, only own properties are considered.\n * This reduces the risk of incorrectly interpreting data at the cost of occasionally requiring users to convert data into a compatible format.\n *\n * 2. Insertable content which is an unhydrated object node.\n *\n * 3. Union of 1 and 2.\n *\n * @see {@link Input}\n *\n * @privateRemarks\n * TODO: consider separating these cases into different types.\n *\n * Empty objects don't get \"no excess property\" checks in literals.\n * To prevent extraneous properties in literals for the fields of an empty object from compiling, the empty case is special cased to produce `Record<string, never>`.\n * More details at {@link https://mercury.com/blog/creating-an-emptyobject-type-in-typescript}.\n *\n * Additionally when T is exactly `RestrictiveStringRecord<ImplicitFieldSchema>` produce just `never` so that it is assignable to the insertable for any given object type.\n *\n * Separating `{}` from `RestrictiveStringRecord<ImplicitFieldSchema>` is a bit messy since both extend each-other despite them being very different types.\n * A third dummy type `{ arbitraryKey: \"arbitraryValue\" }` is used to resolve this.\n *\n * @system @public\n */\nexport type InsertableObjectFromSchemaRecord<\n\tT extends RestrictiveStringRecord<ImplicitFieldSchema>,\n> = RestrictiveStringRecord<ImplicitFieldSchema> extends T\n\t? { arbitraryKey: \"arbitraryValue\" } extends T\n\t\t? // {} case\n\t\t\tRecord<string, never>\n\t\t: // RestrictiveStringRecord<ImplicitFieldSchema> case\n\t\t\tnever\n\t: FlattenKeys<\n\t\t\t{\n\t\t\t\treadonly [Property in keyof T]?: InsertableTreeFieldFromImplicitField<\n\t\t\t\t\tT[Property & string]\n\t\t\t\t>;\n\t\t\t} & {\n\t\t\t\t// Field does not have a known default, make it required:\n\t\t\t\treadonly [Property in keyof T as FieldHasDefault<T[Property & string]> extends false\n\t\t\t\t\t? Property\n\t\t\t\t\t: never]: InsertableTreeFieldFromImplicitField<T[Property & string]>;\n\t\t\t}\n\t\t>;\n\n/**\n * Helper used to remove annotations from a schema record and produce insertable objects,\n *\n * @privateremarks\n * This calls {@link InsertableObjectFromSchemaRecord} in order to produce the insertable objects.\n *\n * @system @alpha\n */\nexport type InsertableObjectFromAnnotatedSchemaRecord<\n\tT extends RestrictiveStringRecord<ImplicitAnnotatedFieldSchema>,\n> = InsertableObjectFromSchemaRecord<UnannotateSchemaRecord<T>>;\n\n/**\n * Maps from simple field keys (\"property\" keys) to information about the field.\n *\n * @remarks\n * A missing entry for a given property key indicates that no such field exists.\n * Keys with symbols are currently never used, but allowed to make lookups on non-field things\n * (returning undefined) easier.\n */\nexport type SimpleKeyMap = ReadonlyMap<\n\tstring | symbol,\n\t{ storedKey: FieldKey; schema: FieldSchema }\n>;\n\n/**\n * Caches the mappings from property keys to stored keys for the provided object field schemas in {@link simpleKeyToFlexKeyCache}.\n */\nfunction createFlexKeyMapping(fields: Record<string, ImplicitFieldSchema>): SimpleKeyMap {\n\tconst keyMap: Map<string | symbol, { storedKey: FieldKey; schema: FieldSchema }> = new Map();\n\tfor (const [propertyKey, fieldSchema] of Object.entries(fields)) {\n\t\tconst storedKey = getStoredKey(propertyKey, fieldSchema);\n\t\tkeyMap.set(propertyKey, { storedKey, schema: normalizeFieldSchema(fieldSchema) });\n\t}\n\n\treturn keyMap;\n}\n\nconst globalIdentifierAllocator: IIdCompressor = createIdCompressor();\n\n/**\n * Modify `flexNode` to add a newly generated identifier under the given `storedKey`.\n * @remarks\n * This is used after checking if the user is trying to read an identifier field of an unhydrated node, but the identifier is not present.\n * This means the identifier is an \"auto-generated identifier\", because otherwise it would have been supplied by the user at construction time and would have been successfully read just above.\n * In this case, it is categorically impossible to provide an identifier (auto-generated identifiers can't be created until hydration/insertion time), so we emit an error.\n * @privateRemarks\n * TODO: this special case logic should move to the inner node (who's schema claims it has an identifier), rather than here, after we already read undefined out of a required field.\n * TODO: unify this with a more general defaults mechanism.\n */\nexport function lazilyAllocateIdentifier(\n\tflexNode: UnhydratedFlexTreeNode,\n\tstoredKey: FieldKey,\n): string {\n\tdebugAssert(() => !flexNode.mapTree.fields.has(storedKey) || \"Identifier field already set\");\n\tconst value = globalIdentifierAllocator.decompress(\n\t\tglobalIdentifierAllocator.generateCompressedId(),\n\t);\n\tflexNode.mapTree.fields.set(storedKey, [\n\t\t{\n\t\t\ttype: brand(stringSchema.identifier),\n\t\t\tvalue,\n\t\t\tfields: new Map(),\n\t\t},\n\t]);\n\n\treturn value;\n}\n\n/**\n * Creates a proxy handler for the given schema.\n *\n * @param allowAdditionalProperties - If true, setting of unexpected properties will be forwarded to the target object.\n * Otherwise setting of unexpected properties will error.\n * TODO: consider implementing this using `Object.preventExtension` instead.\n * @param customTargetObject - Target object of the proxy.\n * If not provided `{}` is used for the target.\n */\nfunction createProxyHandler(\n\tschema: ObjectNodeSchema & ObjectNodeSchemaInternalData,\n\tallowAdditionalProperties: boolean,\n): ProxyHandler<TreeNode> {\n\t// To satisfy 'deepEquals' level scrutiny, the target of the proxy must be an object with the same\n\t// prototype as an object literal '{}'. This is because 'deepEquals' uses 'Object.getPrototypeOf'\n\t// as a way to quickly reject objects with different prototype chains.\n\t//\n\t// (Note that the prototype of an object literal appears as '[Object: null prototype] {}', not because\n\t// the prototype is null, but because the prototype object itself has a null prototype.)\n\n\t// TODO: Although the target is an object literal, it's still worthwhile to try experimenting with\n\t// a dispatch object to see if it improves performance.\n\tconst handler: ProxyHandler<TreeNode> = {\n\t\tget(target, propertyKey, proxy): unknown {\n\t\t\tconst fieldInfo = schema.flexKeyMap.get(propertyKey);\n\t\t\tif (fieldInfo !== undefined) {\n\t\t\t\tconst flexNode = getOrCreateInnerNode(proxy);\n\t\t\t\tdebugAssert(() => !flexNode.context.isDisposed() || \"FlexTreeNode is disposed\");\n\t\t\t\tconst field = flexNode.tryGetField(fieldInfo.storedKey);\n\t\t\t\tif (field !== undefined) {\n\t\t\t\t\treturn getTreeNodeForField(field);\n\t\t\t\t}\n\n\t\t\t\tif (\n\t\t\t\t\tfieldInfo.schema.kind === FieldKind.Identifier &&\n\t\t\t\t\tflexNode instanceof UnhydratedFlexTreeNode\n\t\t\t\t) {\n\t\t\t\t\treturn lazilyAllocateIdentifier(flexNode, fieldInfo.storedKey);\n\t\t\t\t}\n\n\t\t\t\treturn undefined;\n\t\t\t}\n\n\t\t\t// POJO mode objects don't have TreeNode's build in members on their targets, so special case them:\n\t\t\tif (propertyKey === typeSchemaSymbol) {\n\t\t\t\treturn schema;\n\t\t\t}\n\t\t\t// eslint-disable-next-line import/no-deprecated\n\t\t\tif (propertyKey === typeNameSymbol) {\n\t\t\t\treturn schema.identifier;\n\t\t\t}\n\n\t\t\t// Pass the proxy as the receiver here, so that any methods on the prototype receive `proxy` as `this`.\n\t\t\treturn Reflect.get(target, propertyKey, proxy);\n\t\t},\n\t\tset(target, propertyKey, value: InsertableContent | undefined, proxy) {\n\t\t\tconst fieldInfo = schema.flexKeyMap.get(propertyKey);\n\t\t\tif (fieldInfo === undefined) {\n\t\t\t\t// Pass the proxy as the receiver here, so that setters on the prototype receive `proxy` as `this`.\n\t\t\t\treturn allowAdditionalProperties\n\t\t\t\t\t? Reflect.set(target, propertyKey, value, proxy)\n\t\t\t\t\t: false;\n\t\t\t}\n\n\t\t\tsetField(\n\t\t\t\tgetOrCreateInnerNode(proxy).getBoxed(fieldInfo.storedKey),\n\t\t\t\tfieldInfo.schema,\n\t\t\t\tvalue,\n\t\t\t);\n\t\t\treturn true;\n\t\t},\n\t\tdeleteProperty(target, propertyKey): boolean {\n\t\t\t// TODO: supporting delete when it makes sense (custom local fields, and optional field) could be added as a feature in the future.\n\t\t\tthrow new UsageError(\n\t\t\t\t`Object nodes do not support the delete operator. Optional fields can be assigned to undefined instead.`,\n\t\t\t);\n\t\t},\n\t\thas: (target, propertyKey) => {\n\t\t\treturn (\n\t\t\t\tschema.flexKeyMap.has(propertyKey) ||\n\t\t\t\t(allowAdditionalProperties ? Reflect.has(target, propertyKey) : false)\n\t\t\t);\n\t\t},\n\t\townKeys: (target) => {\n\t\t\treturn [\n\t\t\t\t...schema.flexKeyMap.keys(),\n\t\t\t\t...(allowAdditionalProperties ? Reflect.ownKeys(target) : []),\n\t\t\t];\n\t\t},\n\t\tgetOwnPropertyDescriptor: (target, propertyKey) => {\n\t\t\tconst fieldInfo = schema.flexKeyMap.get(propertyKey);\n\n\t\t\tif (fieldInfo === undefined) {\n\t\t\t\treturn allowAdditionalProperties\n\t\t\t\t\t? Reflect.getOwnPropertyDescriptor(target, propertyKey)\n\t\t\t\t\t: undefined;\n\t\t\t}\n\n\t\t\t// For some reason, the getOwnPropertyDescriptor is not passed in the receiver, so use a weak map.\n\t\t\t// If a refactoring is done to associated flex tree data with the target not the proxy, this extra map could be removed,\n\t\t\t// and the design would be more compatible with proxyless nodes.\n\t\t\tconst proxy = targetToProxy.get(target) ?? fail(0xadd /* missing proxy */);\n\t\t\tconst field = getOrCreateInnerNode(proxy).tryGetField(fieldInfo.storedKey);\n\n\t\t\tconst p: PropertyDescriptor = {\n\t\t\t\tvalue: field === undefined ? undefined : getTreeNodeForField(field),\n\t\t\t\twritable: true,\n\t\t\t\t// Report empty fields as own properties so they shadow inherited properties (even when empty) to match TypeScript typing.\n\t\t\t\t// Make empty fields not enumerable so they get skipped when iterating over an object to better align with\n\t\t\t\t// JSON and deep equals with JSON compatible object (which can't have undefined fields).\n\t\t\t\tenumerable: field !== undefined,\n\t\t\t\tconfigurable: true, // Must be 'configurable' if property is absent from proxy target.\n\t\t\t};\n\n\t\t\treturn p;\n\t\t},\n\t};\n\treturn handler;\n}\n\nexport function setField(\n\tfield: FlexTreeField,\n\tsimpleFieldSchema: FieldSchema,\n\tvalue: InsertableContent | undefined,\n): void {\n\tconst mapTree = prepareForInsertion(value, simpleFieldSchema, field.context);\n\n\tswitch (field.schema) {\n\t\tcase FieldKinds.required.identifier: {\n\t\t\tassert(mapTree !== undefined, 0xa04 /* Cannot set a required field to undefined */);\n\t\t\tconst typedField = field as FlexTreeRequiredField;\n\t\t\ttypedField.editor.set(mapTree);\n\t\t\tbreak;\n\t\t}\n\t\tcase FieldKinds.optional.identifier: {\n\t\t\tconst typedField = field as FlexTreeOptionalField;\n\t\t\ttypedField.editor.set(mapTree, typedField.length === 0);\n\t\t\tbreak;\n\t\t}\n\n\t\tdefault:\n\t\t\tfail(0xade /* invalid FieldKind */);\n\t}\n}\n\nabstract class CustomObjectNodeBase<\n\tconst T extends RestrictiveStringRecord<ImplicitFieldSchema>,\n> extends TreeNodeValid<InsertableObjectFromSchemaRecord<T>> {\n\tpublic static readonly kind = NodeKind.Object;\n}\n\n/**\n * Define a {@link TreeNodeSchema} for a {@link TreeObjectNode}.\n *\n * @param name - Unique identifier for this schema within this factory's scope.\n * @param fields - Schema for fields of the object node's schema. Defines what children can be placed under each key.\n */\nexport function objectSchema<\n\tTName extends string,\n\tconst T extends RestrictiveStringRecord<ImplicitAnnotatedFieldSchema>,\n\tconst ImplicitlyConstructable extends boolean,\n\tconst TCustomMetadata = unknown,\n>(\n\tidentifier: TName,\n\tinfo: T,\n\timplicitlyConstructable: ImplicitlyConstructable,\n\tallowUnknownOptionalFields: boolean,\n\tmetadata?: NodeSchemaMetadata<TCustomMetadata>,\n): ObjectNodeSchema<TName, T, ImplicitlyConstructable, TCustomMetadata> &\n\tObjectNodeSchemaInternalData {\n\t// Field set can't be modified after this since derived data is stored in maps.\n\tObject.freeze(info);\n\n\tconst unannotatedInfo = unannotateSchemaRecord(info);\n\n\t// Ensure no collisions between final set of property keys, and final set of stored keys (including those\n\t// implicitly derived from property keys)\n\tassertUniqueKeys(identifier, unannotatedInfo);\n\n\t// Performance optimization: cache property key => stored key and schema.\n\tconst flexKeyMap: SimpleKeyMap = createFlexKeyMapping(unannotatedInfo);\n\n\tconst identifierFieldKeys: FieldKey[] = [];\n\tfor (const item of flexKeyMap.values()) {\n\t\tif (item.schema.kind === FieldKind.Identifier) {\n\t\t\tidentifierFieldKeys.push(item.storedKey);\n\t\t}\n\t}\n\n\tconst lazyChildTypes = new Lazy(\n\t\t() => new Set(Array.from(flexKeyMap.values(), (f) => [...f.schema.allowedTypeSet]).flat()),\n\t);\n\n\tlet handler: ProxyHandler<object>;\n\tlet customizable: boolean;\n\tlet unhydratedContext: Context;\n\n\tclass CustomObjectNode extends CustomObjectNodeBase<UnannotateSchemaRecord<T>> {\n\t\tpublic static readonly fields: ReadonlyMap<\n\t\t\tstring,\n\t\t\tFieldSchemaAlpha & SimpleObjectFieldSchema\n\t\t> = new Map(\n\t\t\tArray.from(flexKeyMap, ([key, value]) => [\n\t\t\t\tkey as string,\n\t\t\t\tnew ObjectFieldSchema(\n\t\t\t\t\tvalue.schema.kind,\n\t\t\t\t\tvalue.schema.allowedTypes,\n\t\t\t\t\t(value.schema as FieldSchemaAlpha).annotatedAllowedTypes,\n\t\t\t\t\t{\n\t\t\t\t\t\t...value.schema.props,\n\t\t\t\t\t\tkey: getStoredKey(key as string, value.schema),\n\t\t\t\t\t},\n\t\t\t\t),\n\t\t\t]),\n\t\t);\n\t\tpublic static readonly flexKeyMap: SimpleKeyMap = flexKeyMap;\n\t\tpublic static readonly storedKeyToPropertyKey: ReadonlyMap<FieldKey, string> = new Map<\n\t\t\tFieldKey,\n\t\t\tstring\n\t\t>(\n\t\t\tArray.from(flexKeyMap, ([key, value]): [FieldKey, string] => [\n\t\t\t\tvalue.storedKey,\n\t\t\t\tkey as string,\n\t\t\t]),\n\t\t);\n\t\tpublic static readonly identifierFieldKeys: readonly FieldKey[] = identifierFieldKeys;\n\t\tpublic static readonly allowUnknownOptionalFields: boolean = allowUnknownOptionalFields;\n\n\t\tpublic static override prepareInstance<T2>(\n\t\t\tthis: typeof TreeNodeValid<T2>,\n\t\t\tinstance: TreeNodeValid<T2>,\n\t\t\tflexNode: FlexTreeNode,\n\t\t): TreeNodeValid<T2> {\n\t\t\t// Differentiate between the following cases:\n\t\t\t//\n\t\t\t// Case 1: Direct construction (POJO emulation)\n\t\t\t//\n\t\t\t// const Foo = schemaFactory.object(\"Foo\", {bar: schemaFactory.number});\n\t\t\t//\n\t\t\t// assert.deepEqual(new Foo({ bar: 42 }), { bar: 42 },\n\t\t\t//\t\t \"Prototype chain equivalent to POJO.\");\n\t\t\t//\n\t\t\t// Case 2: Subclass construction (Customizable Object)\n\t\t\t//\n\t\t\t// \t class Foo extends schemaFactory.object(\"Foo\", {bar: schemaFactory.number}) {}\n\t\t\t//\n\t\t\t// \t assert.notDeepEqual(new Foo({ bar: 42 }), { bar: 42 },\n\t\t\t// \t \"Subclass prototype chain differs from POJO.\");\n\t\t\t//\n\t\t\t// In Case 1 (POJO emulation), the prototype chain match '{}' (proxyTarget = undefined)\n\t\t\t// In Case 2 (Customizable Object), the prototype chain include the user's subclass (proxyTarget = this)\n\n\t\t\tconst proxyTarget = customizable ? instance : {};\n\t\t\tconst proxy = new Proxy(proxyTarget, handler) as CustomObjectNode;\n\t\t\ttargetToProxy.set(proxyTarget, proxy);\n\t\t\treturn proxy;\n\t\t}\n\n\t\tpublic static override buildRawNode<T2>(\n\t\t\tthis: typeof TreeNodeValid<T2>,\n\t\t\tinstance: TreeNodeValid<T2>,\n\t\t\tinput: T2,\n\t\t): UnhydratedFlexTreeNode {\n\t\t\treturn UnhydratedFlexTreeNode.getOrCreate(\n\t\t\t\tunhydratedContext,\n\t\t\t\tmapTreeFromNodeData(input as object, this as unknown as ImplicitAllowedTypes),\n\t\t\t);\n\t\t}\n\n\t\tprotected static override constructorCached: MostDerivedData | undefined = undefined;\n\n\t\tprotected static override oneTimeSetup<T2>(this: typeof TreeNodeValid<T2>): Context {\n\t\t\t// One time initialization that required knowing the most derived type (from this.constructor) and thus has to be lazy.\n\t\t\tcustomizable = (this as unknown) !== CustomObjectNode;\n\t\t\tconst schema = this as unknown as ObjectNodeSchema & ObjectNodeSchemaInternalData;\n\t\t\thandler = createProxyHandler(schema, customizable);\n\t\t\tunhydratedContext = getUnhydratedContext(schema);\n\n\t\t\t// First run, do extra validation.\n\t\t\t// TODO: provide a way for TreeConfiguration to trigger this same validation to ensure it gets run early.\n\t\t\t// Scan for shadowing inherited members which won't work, but stop scan early to allow shadowing built in (which seems to work ok).\n\t\t\t{\n\t\t\t\tlet prototype: object = this.prototype;\n\t\t\t\t// There isn't a clear cleaner way to author this loop.\n\t\t\t\twhile (prototype !== CustomObjectNode.prototype) {\n\t\t\t\t\tfor (const [key] of flexKeyMap) {\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t// constructor is a special case, since one is built in on the derived type, and shadowing it works fine since we only use it before fields are applied.\n\t\t\t\t\t\t\tkey !== \"constructor\" &&\n\t\t\t\t\t\t\tReflect.getOwnPropertyDescriptor(prototype, key) !== undefined\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tthrow new UsageError(\n\t\t\t\t\t\t\t\t`Schema ${identifier} defines an inherited property \"${key.toString()}\" which shadows a field. Since fields are exposed as own properties, this shadowing will not work, and is an error.`,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\t// Since this stops at CustomObjectNode, it should never see a null prototype, so this case is safe.\n\t\t\t\t\t// Additionally, if the prototype chain is ever messed up such that CustomObjectNode is not in it,\n\t\t\t\t\t// the null that would show up here does at least ensure this code throws instead of hanging.\n\t\t\t\t\tprototype = Reflect.getPrototypeOf(prototype) as object;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn unhydratedContext;\n\t\t}\n\n\t\tpublic static readonly identifier = identifier;\n\t\tpublic static readonly info = info;\n\t\tpublic static readonly implicitlyConstructable: ImplicitlyConstructable =\n\t\t\timplicitlyConstructable;\n\t\tpublic static get childTypes(): ReadonlySet<TreeNodeSchema> {\n\t\t\treturn lazyChildTypes.value;\n\t\t}\n\t\tpublic static readonly metadata: NodeSchemaMetadata<TCustomMetadata> = metadata ?? {};\n\n\t\t// eslint-disable-next-line import/no-deprecated\n\t\tpublic get [typeNameSymbol](): TName {\n\t\t\treturn identifier;\n\t\t}\n\t\tpublic get [typeSchemaSymbol](): Output {\n\t\t\treturn CustomObjectNode.constructorCached?.constructor as unknown as Output;\n\t\t}\n\t}\n\ttype Output = typeof CustomObjectNode &\n\t\t(new (\n\t\t\tinput: InsertableObjectFromAnnotatedSchemaRecord<T> | InternalTreeNode,\n\t\t) => TreeObjectNode<UnannotateSchemaRecord<T>, TName>);\n\treturn CustomObjectNode as Output;\n}\n\nconst targetToProxy: WeakMap<object, TreeNode> = new WeakMap();\n\n/**\n * Ensures that the set of property keys in the schema is unique.\n * Also ensure that the final set of stored keys (including those implicitly derived from property keys) is unique.\n * @throws Throws a `UsageError` if either of the key uniqueness invariants is violated.\n */\nfunction assertUniqueKeys<\n\tconst Name extends number | string,\n\tconst Fields extends RestrictiveStringRecord<ImplicitFieldSchema>,\n>(schemaName: Name, fields: Fields): void {\n\t// Verify that there are no duplicates among the explicitly specified stored keys.\n\tconst explicitStoredKeys = new Set<string>();\n\tfor (const schema of Object.values(fields)) {\n\t\tconst storedKey = getExplicitStoredKey(schema);\n\t\tif (storedKey === undefined) {\n\t\t\tcontinue;\n\t\t}\n\t\tif (explicitStoredKeys.has(storedKey)) {\n\t\t\tthrow new UsageError(\n\t\t\t\t`Duplicate stored key \"${storedKey}\" in schema \"${schemaName}\". Stored keys must be unique within an object schema.`,\n\t\t\t);\n\t\t}\n\t\texplicitStoredKeys.add(storedKey);\n\t}\n\n\t// Verify that there are no duplicates among the derived\n\t// (including those implicitly derived from property keys) stored keys.\n\tconst derivedStoredKeys = new Set<string>();\n\tfor (const [propertyKey, schema] of Object.entries(fields)) {\n\t\tconst storedKey = getStoredKey(propertyKey, schema);\n\t\tif (derivedStoredKeys.has(storedKey)) {\n\t\t\tthrow new UsageError(\n\t\t\t\t`Stored key \"${storedKey}\" in schema \"${schemaName}\" conflicts with a property key of the same name, which is not overridden by a stored key. The final set of stored keys in an object schema must be unique.`,\n\t\t\t);\n\t\t}\n\t\tderivedStoredKeys.add(storedKey);\n\t}\n}\n\n/**\n * Creates a policy for allowing unknown optional fields on an object node which delegates to the policy defined\n * on the object node's internal schema data.\n */\nexport function createUnknownOptionalFieldPolicy(\n\tschema: ImplicitFieldSchema,\n): SchemaPolicy[\"allowUnknownOptionalFields\"] {\n\tconst context = getUnhydratedContext(schema);\n\treturn (identifier) => {\n\t\tconst storedSchema = context.schema.get(identifier);\n\t\treturn (\n\t\t\tstoredSchema !== undefined &&\n\t\t\tisObjectNodeSchema(storedSchema) &&\n\t\t\tstoredSchema.allowUnknownOptionalFields\n\t\t);\n\t};\n}\n"]}
1
+ {"version":3,"file":"objectNode.js","sourceRoot":"","sources":["../../../../src/simple-tree/node-kinds/object/objectNode.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAAsF;AACtF,uEAAsE;AAGtE,kEAM6C;AAO7C,kDAY6B;AAC7B,6DAA8D;AAC9D,yEAAmE;AACnE,6DAI8B;AAC9B,yEAAmE;AACnE,yDAe8B;AAE9B,mGAGmD;AACnD,6DAA6E;AAiI7E;;GAEG;AACH,SAAS,oBAAoB,CAAC,MAA2C;IACxE,MAAM,MAAM,GAAuE,IAAI,GAAG,EAAE,CAAC;IAC7F,KAAK,MAAM,CAAC,WAAW,EAAE,WAAW,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;QACjE,MAAM,SAAS,GAAG,IAAA,6BAAY,EAAC,WAAW,EAAE,WAAW,CAAC,CAAC;QACzD,MAAM,CAAC,GAAG,CAAC,WAAW,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,IAAA,qCAAoB,EAAC,WAA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wD;IACxD,uEAAuE;IACvE,MAAM,iBAAiB,GAAG,IAAI,GAAG,EAAU,CAAC;IAC5C,KAAK,MAAM,CAAC,WAAW,EAAE,MAAM,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;QAC5D,MAAM,SAAS,GAAG,IAAA,6BAAY,EAAC,WAAW,EAAE,MAAM,CAAC,CAAC;QACpD,IAAI,iBAAiB,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE,CAAC;YACtC,MAAM,IAAI,qBAAU,CACnB,eAAe,SAAS,gBAAgB,UAAU,6JAA6J,CAC/M,CAAC;QACH,CAAC;QACD,iBAAiB,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;IAClC,CAAC;AACF,CAAC;AAED;;;GAGG;AACH,SAAgB,gCAAgC,CAC/C,MAA2B;IAE3B,MAAM,OAAO,GAAG,IAAA,uCAAoB,EAAC,MAAM,CAAC,CAAC;IAC7C,OAAO,CAAC,UAAU,EAAE,EAAE;QACrB,MAAM,YAAY,GAAG,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;QACpD,OAAO,CACN,YAAY,KAAK,SAAS;YAC1B,IAAA,uCAAkB,EAAC,YAAY,CAAC;YAChC,YAAY,CAAC,0BAA0B,CACvC,CAAC;IACH,CAAC,CAAC;AACH,CAAC;AAZD,4EAYC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, Lazy, fail, debugAssert } from \"@fluidframework/core-utils/internal\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\n\nimport type { FieldKey, SchemaPolicy } from \"../../../core/index.js\";\nimport {\n\tFieldKinds,\n\ttype FlexTreeField,\n\ttype FlexTreeNode,\n\ttype FlexTreeOptionalField,\n\ttype FlexTreeRequiredField,\n} from \"../../../feature-libraries/index.js\";\nimport type {\n\tRestrictiveStringRecord,\n\tFlattenKeys,\n\tJsonCompatibleReadOnlyObject,\n} from \"../../../util/index.js\";\n\nimport {\n\ttype TreeNodeSchema,\n\tNodeKind,\n\ttype WithType,\n\t// eslint-disable-next-line import/no-deprecated\n\ttypeNameSymbol,\n\ttypeSchemaSymbol,\n\ttype InternalTreeNode,\n\ttype TreeNode,\n\ttype Context,\n\ttype UnhydratedFlexTreeNode,\n\tgetOrCreateInnerNode,\n} from \"../../core/index.js\";\nimport { getUnhydratedContext } from \"../../createContext.js\";\nimport { getTreeNodeForField } from \"../../getTreeNodeForField.js\";\nimport {\n\tisObjectNodeSchema,\n\ttype ObjectNodeSchema,\n\ttype ObjectNodeSchemaInternalData,\n} from \"./objectNodeTypes.js\";\nimport { prepareForInsertion } from \"../../prepareForInsertion.js\";\nimport {\n\ttype ImplicitFieldSchema,\n\tgetStoredKey,\n\tgetExplicitStoredKey,\n\ttype TreeFieldFromImplicitField,\n\ttype InsertableTreeFieldFromImplicitField,\n\ttype FieldSchema,\n\tnormalizeFieldSchema,\n\tFieldKind,\n\ttype NodeSchemaMetadata,\n\ttype FieldSchemaAlpha,\n\tObjectFieldSchema,\n\ttype ImplicitAnnotatedFieldSchema,\n\tunannotateSchemaRecord,\n\ttype UnannotateSchemaRecord,\n} from \"../../schemaTypes.js\";\nimport type { SimpleObjectFieldSchema } from \"../../simpleSchema.js\";\nimport {\n\tunhydratedFlexTreeFromInsertable,\n\ttype InsertableContent,\n} from \"../../unhydratedFlexTreeFromInsertable.js\";\nimport { TreeNodeValid, type MostDerivedData } from \"../../treeNodeValid.js\";\n\n/**\n * Generates the properties for an ObjectNode from its field schema object.\n * @remarks\n * Due to {@link https://github.com/microsoft/TypeScript/issues/43826}, we can't enable implicit construction of {@link TreeNode|TreeNodes} for setters.\n * Therefore code assigning to these fields must explicitly construct nodes using the schema's constructor or create method,\n * or using some other method like {@link (TreeAlpha:interface).create}.\n * @system @public\n */\nexport type ObjectFromSchemaRecord<T extends RestrictiveStringRecord<ImplicitFieldSchema>> =\n\tRestrictiveStringRecord<ImplicitFieldSchema> extends T\n\t\t? // eslint-disable-next-line @typescript-eslint/ban-types\n\t\t\t{}\n\t\t: {\n\t\t\t\t-readonly [Property in keyof T]: Property extends string\n\t\t\t\t\t? TreeFieldFromImplicitField<T[Property]>\n\t\t\t\t\t: unknown;\n\t\t\t};\n\n/**\n * A {@link TreeNode} which models a JavaScript object.\n * @remarks\n * Object nodes consist of a type which specifies which {@link TreeNodeSchema} they use (see {@link TreeNodeApi.schema} and {@link SchemaFactory.object}),\n * and a collections of fields, each with a distinct `key` and its own {@link FieldSchema} defining what can be placed under that key.\n *\n * All fields on an object node are exposed as own properties with string keys.\n * Non-empty fields are enumerable and empty optional fields are non-enumerable own properties with the value `undefined`.\n * No other own `own` or `enumerable` properties are included on object nodes unless the user of the node manually adds custom session only state.\n * This allows a majority of general purpose JavaScript object processing operations (like `for...in`, `Reflect.ownKeys()` and `Object.entries()`) to enumerate all the children.\n *\n * The API for fields is defined by {@link ObjectFromSchemaRecord}.\n * @public\n */\nexport type TreeObjectNode<\n\tT extends RestrictiveStringRecord<ImplicitFieldSchema>,\n\tTypeName extends string = string,\n> = TreeNode & ObjectFromSchemaRecord<T> & WithType<TypeName, NodeKind.Object, T>;\n\n/**\n * Type utility for determining if an implicit field schema is known to have a default value.\n *\n * @remarks Yields `false` when unknown.\n *\n * @privateRemarks\n * TODO: Account for field schemas with default value providers.\n * For now, this only captures field kinds that we know always have defaults - optional fields and identifier fields.\n *\n * @system @public\n */\nexport type FieldHasDefault<T extends ImplicitFieldSchema> = [T] extends [\n\tFieldSchema<FieldKind.Optional | FieldKind.Identifier>,\n]\n\t? true\n\t: false;\n\n/**\n * Helper used to produce types for:\n *\n * 1. Insertable content which can be used to construct an object node.\n * In this case, only own properties are considered.\n * This reduces the risk of incorrectly interpreting data at the cost of occasionally requiring users to convert data into a compatible format.\n *\n * 2. Insertable content which is an unhydrated object node.\n *\n * 3. Union of 1 and 2.\n *\n * @see {@link Input}\n *\n * @privateRemarks\n * TODO: consider separating these cases into different types.\n *\n * Empty objects don't get \"no excess property\" checks in literals.\n * To prevent extraneous properties in literals for the fields of an empty object from compiling, the empty case is special cased to produce `Record<string, never>`.\n * More details at {@link https://mercury.com/blog/creating-an-emptyobject-type-in-typescript}.\n *\n * Additionally when T is exactly `RestrictiveStringRecord<ImplicitFieldSchema>` produce just `never` so that it is assignable to the insertable for any given object type.\n *\n * Separating `{}` from `RestrictiveStringRecord<ImplicitFieldSchema>` is a bit messy since both extend each-other despite them being very different types.\n * A third dummy type `{ arbitraryKey: \"arbitraryValue\" }` is used to resolve this.\n *\n * @system @public\n */\nexport type InsertableObjectFromSchemaRecord<\n\tT extends RestrictiveStringRecord<ImplicitFieldSchema>,\n> = RestrictiveStringRecord<ImplicitFieldSchema> extends T\n\t? { arbitraryKey: \"arbitraryValue\" } extends T\n\t\t? // {} case\n\t\t\tRecord<string, never>\n\t\t: // RestrictiveStringRecord<ImplicitFieldSchema> case\n\t\t\tnever\n\t: FlattenKeys<\n\t\t\t{\n\t\t\t\treadonly [Property in keyof T]?: InsertableTreeFieldFromImplicitField<\n\t\t\t\t\tT[Property & string]\n\t\t\t\t>;\n\t\t\t} & {\n\t\t\t\t// Field does not have a known default, make it required:\n\t\t\t\treadonly [Property in keyof T as FieldHasDefault<T[Property & string]> extends false\n\t\t\t\t\t? Property\n\t\t\t\t\t: never]: InsertableTreeFieldFromImplicitField<T[Property & string]>;\n\t\t\t}\n\t\t>;\n\n/**\n * Helper used to remove annotations from a schema record and produce insertable objects,\n *\n * @privateremarks\n * This calls {@link InsertableObjectFromSchemaRecord} in order to produce the insertable objects.\n *\n * @system @alpha\n */\nexport type InsertableObjectFromAnnotatedSchemaRecord<\n\tT extends RestrictiveStringRecord<ImplicitAnnotatedFieldSchema>,\n> = InsertableObjectFromSchemaRecord<UnannotateSchemaRecord<T>>;\n\n/**\n * Maps from simple field keys (\"property\" keys) to information about the field.\n *\n * @remarks\n * A missing entry for a given property key indicates that no such field exists.\n * Keys with symbols are currently never used, but allowed to make lookups on non-field things\n * (returning undefined) easier.\n */\nexport type SimpleKeyMap = ReadonlyMap<\n\tstring | symbol,\n\t{ storedKey: FieldKey; schema: FieldSchema }\n>;\n\n/**\n * Caches the mappings from property keys to stored keys for the provided object field schemas in {@link simpleKeyToFlexKeyCache}.\n */\nfunction createFlexKeyMapping(fields: Record<string, ImplicitFieldSchema>): SimpleKeyMap {\n\tconst keyMap: Map<string | symbol, { storedKey: FieldKey; schema: FieldSchema }> = new Map();\n\tfor (const [propertyKey, fieldSchema] of Object.entries(fields)) {\n\t\tconst storedKey = getStoredKey(propertyKey, fieldSchema);\n\t\tkeyMap.set(propertyKey, { storedKey, schema: normalizeFieldSchema(fieldSchema) });\n\t}\n\n\treturn keyMap;\n}\n\n/**\n * Creates a proxy handler for the given schema.\n *\n * @param allowAdditionalProperties - If true, setting of unexpected properties will be forwarded to the target object.\n * Otherwise setting of unexpected properties will error.\n * TODO: consider implementing this using `Object.preventExtension` instead.\n * @param customTargetObject - Target object of the proxy.\n * If not provided `{}` is used for the target.\n */\nfunction createProxyHandler(\n\tschema: ObjectNodeSchema & ObjectNodeSchemaInternalData,\n\tallowAdditionalProperties: boolean,\n): ProxyHandler<TreeNode> {\n\t// To satisfy 'deepEquals' level scrutiny, the target of the proxy must be an object with the same\n\t// prototype as an object literal '{}'. This is because 'deepEquals' uses 'Object.getPrototypeOf'\n\t// as a way to quickly reject objects with different prototype chains.\n\t//\n\t// (Note that the prototype of an object literal appears as '[Object: null prototype] {}', not because\n\t// the prototype is null, but because the prototype object itself has a null prototype.)\n\n\t// TODO: Although the target is an object literal, it's still worthwhile to try experimenting with\n\t// a dispatch object to see if it improves performance.\n\tconst handler: ProxyHandler<TreeNode> = {\n\t\tget(target, propertyKey, proxy): unknown {\n\t\t\tconst fieldInfo = schema.flexKeyMap.get(propertyKey);\n\t\t\tif (fieldInfo !== undefined) {\n\t\t\t\tconst flexNode = getOrCreateInnerNode(proxy);\n\t\t\t\tdebugAssert(() => !flexNode.context.isDisposed() || \"FlexTreeNode is disposed\");\n\t\t\t\tconst field = flexNode.tryGetField(fieldInfo.storedKey);\n\t\t\t\tif (field !== undefined) {\n\t\t\t\t\treturn getTreeNodeForField(field);\n\t\t\t\t}\n\n\t\t\t\treturn undefined;\n\t\t\t}\n\n\t\t\t// POJO mode objects don't have TreeNode's build in members on their targets, so special case them:\n\t\t\tif (propertyKey === typeSchemaSymbol) {\n\t\t\t\treturn schema;\n\t\t\t}\n\t\t\t// eslint-disable-next-line import/no-deprecated\n\t\t\tif (propertyKey === typeNameSymbol) {\n\t\t\t\treturn schema.identifier;\n\t\t\t}\n\n\t\t\t// Pass the proxy as the receiver here, so that any methods on the prototype receive `proxy` as `this`.\n\t\t\treturn Reflect.get(target, propertyKey, proxy);\n\t\t},\n\t\tset(target, propertyKey, value: InsertableContent | undefined, proxy) {\n\t\t\tconst fieldInfo = schema.flexKeyMap.get(propertyKey);\n\t\t\tif (fieldInfo === undefined) {\n\t\t\t\t// Pass the proxy as the receiver here, so that setters on the prototype receive `proxy` as `this`.\n\t\t\t\treturn allowAdditionalProperties\n\t\t\t\t\t? Reflect.set(target, propertyKey, value, proxy)\n\t\t\t\t\t: false;\n\t\t\t}\n\n\t\t\tsetField(\n\t\t\t\tgetOrCreateInnerNode(proxy).getBoxed(fieldInfo.storedKey),\n\t\t\t\tfieldInfo.schema,\n\t\t\t\tvalue,\n\t\t\t);\n\t\t\treturn true;\n\t\t},\n\t\tdeleteProperty(target, propertyKey): boolean {\n\t\t\t// TODO: supporting delete when it makes sense (custom local fields, and optional field) could be added as a feature in the future.\n\t\t\tthrow new UsageError(\n\t\t\t\t`Object nodes do not support the delete operator. Optional fields can be assigned to undefined instead.`,\n\t\t\t);\n\t\t},\n\t\thas: (target, propertyKey) => {\n\t\t\treturn (\n\t\t\t\tschema.flexKeyMap.has(propertyKey) ||\n\t\t\t\t(allowAdditionalProperties ? Reflect.has(target, propertyKey) : false)\n\t\t\t);\n\t\t},\n\t\townKeys: (target) => {\n\t\t\treturn [\n\t\t\t\t...schema.flexKeyMap.keys(),\n\t\t\t\t...(allowAdditionalProperties ? Reflect.ownKeys(target) : []),\n\t\t\t];\n\t\t},\n\t\tgetOwnPropertyDescriptor: (target, propertyKey) => {\n\t\t\tconst fieldInfo = schema.flexKeyMap.get(propertyKey);\n\n\t\t\tif (fieldInfo === undefined) {\n\t\t\t\treturn allowAdditionalProperties\n\t\t\t\t\t? Reflect.getOwnPropertyDescriptor(target, propertyKey)\n\t\t\t\t\t: undefined;\n\t\t\t}\n\n\t\t\t// For some reason, the getOwnPropertyDescriptor is not passed in the receiver, so use a weak map.\n\t\t\t// If a refactoring is done to associated flex tree data with the target not the proxy, this extra map could be removed,\n\t\t\t// and the design would be more compatible with proxyless nodes.\n\t\t\tconst proxy = targetToProxy.get(target) ?? fail(0xadd /* missing proxy */);\n\t\t\tconst field = getOrCreateInnerNode(proxy).tryGetField(fieldInfo.storedKey);\n\n\t\t\tconst p: PropertyDescriptor = {\n\t\t\t\tvalue: field === undefined ? undefined : getTreeNodeForField(field),\n\t\t\t\twritable: true,\n\t\t\t\t// Report empty fields as own properties so they shadow inherited properties (even when empty) to match TypeScript typing.\n\t\t\t\t// Make empty fields not enumerable so they get skipped when iterating over an object to better align with\n\t\t\t\t// JSON and deep equals with JSON compatible object (which can't have undefined fields).\n\t\t\t\tenumerable: field !== undefined,\n\t\t\t\tconfigurable: true, // Must be 'configurable' if property is absent from proxy target.\n\t\t\t};\n\n\t\t\treturn p;\n\t\t},\n\t};\n\treturn handler;\n}\n\nexport function setField(\n\tfield: FlexTreeField,\n\tsimpleFieldSchema: FieldSchema,\n\tvalue: InsertableContent | undefined,\n): void {\n\tconst mapTree = prepareForInsertion(value, simpleFieldSchema, field.context);\n\n\tswitch (field.schema) {\n\t\tcase FieldKinds.required.identifier: {\n\t\t\tassert(mapTree !== undefined, 0xa04 /* Cannot set a required field to undefined */);\n\t\t\tconst typedField = field as FlexTreeRequiredField;\n\t\t\ttypedField.editor.set(mapTree);\n\t\t\tbreak;\n\t\t}\n\t\tcase FieldKinds.optional.identifier: {\n\t\t\tconst typedField = field as FlexTreeOptionalField;\n\t\t\ttypedField.editor.set(mapTree, typedField.length === 0);\n\t\t\tbreak;\n\t\t}\n\n\t\tdefault:\n\t\t\tfail(0xade /* invalid FieldKind */);\n\t}\n}\n\nabstract class CustomObjectNodeBase<\n\tconst T extends RestrictiveStringRecord<ImplicitFieldSchema>,\n> extends TreeNodeValid<InsertableObjectFromSchemaRecord<T>> {\n\tpublic static readonly kind = NodeKind.Object;\n}\n\n/**\n * Define a {@link TreeNodeSchema} for a {@link TreeObjectNode}.\n *\n * @param name - Unique identifier for this schema within this factory's scope.\n * @param fields - Schema for fields of the object node's schema. Defines what children can be placed under each key.\n * @param persistedMetadata - Optional persisted metadata for the object node schema.\n */\nexport function objectSchema<\n\tTName extends string,\n\tconst T extends RestrictiveStringRecord<ImplicitAnnotatedFieldSchema>,\n\tconst ImplicitlyConstructable extends boolean,\n\tconst TCustomMetadata = unknown,\n>(\n\tidentifier: TName,\n\tinfo: T,\n\timplicitlyConstructable: ImplicitlyConstructable,\n\tallowUnknownOptionalFields: boolean,\n\tmetadata?: NodeSchemaMetadata<TCustomMetadata>,\n\tpersistedMetadata?: JsonCompatibleReadOnlyObject | undefined,\n): ObjectNodeSchema<TName, T, ImplicitlyConstructable, TCustomMetadata> &\n\tObjectNodeSchemaInternalData {\n\t// Field set can't be modified after this since derived data is stored in maps.\n\tObject.freeze(info);\n\n\tconst unannotatedInfo = unannotateSchemaRecord(info);\n\n\t// Ensure no collisions between final set of property keys, and final set of stored keys (including those\n\t// implicitly derived from property keys)\n\tassertUniqueKeys(identifier, unannotatedInfo);\n\n\t// Performance optimization: cache property key => stored key and schema.\n\tconst flexKeyMap: SimpleKeyMap = createFlexKeyMapping(unannotatedInfo);\n\n\tconst identifierFieldKeys: FieldKey[] = [];\n\tfor (const item of flexKeyMap.values()) {\n\t\tif (item.schema.kind === FieldKind.Identifier) {\n\t\t\tidentifierFieldKeys.push(item.storedKey);\n\t\t}\n\t}\n\n\tconst lazyChildTypes = new Lazy(\n\t\t() => new Set(Array.from(flexKeyMap.values(), (f) => [...f.schema.allowedTypeSet]).flat()),\n\t);\n\n\tlet handler: ProxyHandler<object>;\n\tlet customizable: boolean;\n\tlet unhydratedContext: Context;\n\n\tclass CustomObjectNode extends CustomObjectNodeBase<UnannotateSchemaRecord<T>> {\n\t\tpublic static readonly fields: ReadonlyMap<\n\t\t\tstring,\n\t\t\tFieldSchemaAlpha & SimpleObjectFieldSchema\n\t\t> = new Map(\n\t\t\tArray.from(flexKeyMap, ([key, value]) => [\n\t\t\t\tkey as string,\n\t\t\t\tnew ObjectFieldSchema(\n\t\t\t\t\tvalue.schema.kind,\n\t\t\t\t\tvalue.schema.allowedTypes,\n\t\t\t\t\t(value.schema as FieldSchemaAlpha).annotatedAllowedTypes,\n\t\t\t\t\t{\n\t\t\t\t\t\t...value.schema.props,\n\t\t\t\t\t\tkey: getStoredKey(key as string, value.schema),\n\t\t\t\t\t},\n\t\t\t\t),\n\t\t\t]),\n\t\t);\n\t\tpublic static readonly flexKeyMap: SimpleKeyMap = flexKeyMap;\n\t\tpublic static readonly storedKeyToPropertyKey: ReadonlyMap<FieldKey, string> = new Map<\n\t\t\tFieldKey,\n\t\t\tstring\n\t\t>(\n\t\t\tArray.from(flexKeyMap, ([key, value]): [FieldKey, string] => [\n\t\t\t\tvalue.storedKey,\n\t\t\t\tkey as string,\n\t\t\t]),\n\t\t);\n\t\tpublic static readonly identifierFieldKeys: readonly FieldKey[] = identifierFieldKeys;\n\t\tpublic static readonly allowUnknownOptionalFields: boolean = allowUnknownOptionalFields;\n\n\t\tpublic static override prepareInstance<T2>(\n\t\t\tthis: typeof TreeNodeValid<T2>,\n\t\t\tinstance: TreeNodeValid<T2>,\n\t\t\tflexNode: FlexTreeNode,\n\t\t): TreeNodeValid<T2> {\n\t\t\t// Differentiate between the following cases:\n\t\t\t//\n\t\t\t// Case 1: Direct construction (POJO emulation)\n\t\t\t//\n\t\t\t// const Foo = schemaFactory.object(\"Foo\", {bar: schemaFactory.number});\n\t\t\t//\n\t\t\t// assert.deepEqual(new Foo({ bar: 42 }), { bar: 42 },\n\t\t\t//\t\t \"Prototype chain equivalent to POJO.\");\n\t\t\t//\n\t\t\t// Case 2: Subclass construction (Customizable Object)\n\t\t\t//\n\t\t\t// \t class Foo extends schemaFactory.object(\"Foo\", {bar: schemaFactory.number}) {}\n\t\t\t//\n\t\t\t// \t assert.notDeepEqual(new Foo({ bar: 42 }), { bar: 42 },\n\t\t\t// \t \"Subclass prototype chain differs from POJO.\");\n\t\t\t//\n\t\t\t// In Case 1 (POJO emulation), the prototype chain match '{}' (proxyTarget = undefined)\n\t\t\t// In Case 2 (Customizable Object), the prototype chain include the user's subclass (proxyTarget = this)\n\n\t\t\tconst proxyTarget = customizable ? instance : {};\n\t\t\tconst proxy = new Proxy(proxyTarget, handler) as CustomObjectNode;\n\t\t\ttargetToProxy.set(proxyTarget, proxy);\n\t\t\treturn proxy;\n\t\t}\n\n\t\tpublic static override buildRawNode<T2>(\n\t\t\tthis: typeof TreeNodeValid<T2>,\n\t\t\tinstance: TreeNodeValid<T2>,\n\t\t\tinput: T2,\n\t\t): UnhydratedFlexTreeNode {\n\t\t\treturn unhydratedFlexTreeFromInsertable(input as object, this as Output);\n\t\t}\n\n\t\tprotected static override constructorCached: MostDerivedData | undefined = undefined;\n\n\t\tprotected static override oneTimeSetup<T2>(this: typeof TreeNodeValid<T2>): Context {\n\t\t\t// One time initialization that required knowing the most derived type (from this.constructor) and thus has to be lazy.\n\t\t\tcustomizable = (this as unknown) !== CustomObjectNode;\n\t\t\tconst schema = this as unknown as ObjectNodeSchema & ObjectNodeSchemaInternalData;\n\t\t\thandler = createProxyHandler(schema, customizable);\n\t\t\tunhydratedContext = getUnhydratedContext(schema);\n\n\t\t\t// First run, do extra validation.\n\t\t\t// TODO: provide a way for TreeConfiguration to trigger this same validation to ensure it gets run early.\n\t\t\t// Scan for shadowing inherited members which won't work, but stop scan early to allow shadowing built in (which seems to work ok).\n\t\t\t{\n\t\t\t\tlet prototype: object = this.prototype;\n\t\t\t\t// There isn't a clear cleaner way to author this loop.\n\t\t\t\twhile (prototype !== CustomObjectNode.prototype) {\n\t\t\t\t\tfor (const [key] of flexKeyMap) {\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t// constructor is a special case, since one is built in on the derived type, and shadowing it works fine since we only use it before fields are applied.\n\t\t\t\t\t\t\tkey !== \"constructor\" &&\n\t\t\t\t\t\t\tReflect.getOwnPropertyDescriptor(prototype, key) !== undefined\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tthrow new UsageError(\n\t\t\t\t\t\t\t\t`Schema ${identifier} defines an inherited property \"${key.toString()}\" which shadows a field. Since fields are exposed as own properties, this shadowing will not work, and is an error.`,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\t// Since this stops at CustomObjectNode, it should never see a null prototype, so this case is safe.\n\t\t\t\t\t// Additionally, if the prototype chain is ever messed up such that CustomObjectNode is not in it,\n\t\t\t\t\t// the null that would show up here does at least ensure this code throws instead of hanging.\n\t\t\t\t\tprototype = Reflect.getPrototypeOf(prototype) as object;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn unhydratedContext;\n\t\t}\n\n\t\tpublic static readonly identifier = identifier;\n\t\tpublic static readonly info = info;\n\t\tpublic static readonly implicitlyConstructable: ImplicitlyConstructable =\n\t\t\timplicitlyConstructable;\n\t\tpublic static get childTypes(): ReadonlySet<TreeNodeSchema> {\n\t\t\treturn lazyChildTypes.value;\n\t\t}\n\t\tpublic static readonly metadata: NodeSchemaMetadata<TCustomMetadata> = metadata ?? {};\n\t\tpublic static readonly persistedMetadata: JsonCompatibleReadOnlyObject | undefined =\n\t\t\tpersistedMetadata;\n\n\t\t// eslint-disable-next-line import/no-deprecated\n\t\tpublic get [typeNameSymbol](): TName {\n\t\t\treturn identifier;\n\t\t}\n\t\tpublic get [typeSchemaSymbol](): Output {\n\t\t\treturn CustomObjectNode.constructorCached?.constructor as unknown as Output;\n\t\t}\n\t}\n\ttype Output = typeof CustomObjectNode &\n\t\t(new (\n\t\t\tinput: InsertableObjectFromAnnotatedSchemaRecord<T> | InternalTreeNode,\n\t\t) => TreeObjectNode<UnannotateSchemaRecord<T>, TName>);\n\treturn CustomObjectNode as Output;\n}\n\nconst targetToProxy: WeakMap<object, TreeNode> = new WeakMap();\n\n/**\n * Ensures that the set of property keys in the schema is unique.\n * Also ensure that the final set of stored keys (including those implicitly derived from property keys) is unique.\n * @throws Throws a `UsageError` if either of the key uniqueness invariants is violated.\n */\nfunction assertUniqueKeys<\n\tconst Name extends number | string,\n\tconst Fields extends RestrictiveStringRecord<ImplicitFieldSchema>,\n>(schemaName: Name, fields: Fields): void {\n\t// Verify that there are no duplicates among the explicitly specified stored keys.\n\tconst explicitStoredKeys = new Set<string>();\n\tfor (const schema of Object.values(fields)) {\n\t\tconst storedKey = getExplicitStoredKey(schema);\n\t\tif (storedKey === undefined) {\n\t\t\tcontinue;\n\t\t}\n\t\tif (explicitStoredKeys.has(storedKey)) {\n\t\t\tthrow new UsageError(\n\t\t\t\t`Duplicate stored key \"${storedKey}\" in schema \"${schemaName}\". Stored keys must be unique within an object schema.`,\n\t\t\t);\n\t\t}\n\t\texplicitStoredKeys.add(storedKey);\n\t}\n\n\t// Verify that there are no duplicates among the derived\n\t// (including those implicitly derived from property keys) stored keys.\n\tconst derivedStoredKeys = new Set<string>();\n\tfor (const [propertyKey, schema] of Object.entries(fields)) {\n\t\tconst storedKey = getStoredKey(propertyKey, schema);\n\t\tif (derivedStoredKeys.has(storedKey)) {\n\t\t\tthrow new UsageError(\n\t\t\t\t`Stored key \"${storedKey}\" in schema \"${schemaName}\" conflicts with a property key of the same name, which is not overridden by a stored key. The final set of stored keys in an object schema must be unique.`,\n\t\t\t);\n\t\t}\n\t\tderivedStoredKeys.add(storedKey);\n\t}\n}\n\n/**\n * Creates a policy for allowing unknown optional fields on an object node which delegates to the policy defined\n * on the object node's internal schema data.\n */\nexport function createUnknownOptionalFieldPolicy(\n\tschema: ImplicitFieldSchema,\n): SchemaPolicy[\"allowUnknownOptionalFields\"] {\n\tconst context = getUnhydratedContext(schema);\n\treturn (identifier) => {\n\t\tconst storedSchema = context.schema.get(identifier);\n\t\treturn (\n\t\t\tstoredSchema !== undefined &&\n\t\t\tisObjectNodeSchema(storedSchema) &&\n\t\t\tstoredSchema.allowUnknownOptionalFields\n\t\t);\n\t};\n}\n"]}
@@ -2,10 +2,11 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
- import type { ExclusiveMapTree, SchemaAndPolicy } from "../core/index.js";
6
- import { type FlexTreeContext, type FlexTreeHydratedContext } from "../feature-libraries/index.js";
5
+ import type { SchemaAndPolicy, IForestSubscription } from "../core/index.js";
6
+ import { type FlexTreeContext, type FlexTreeHydratedContextMinimal, type FlexibleFieldContent, type FlexibleNodeContent } from "../feature-libraries/index.js";
7
7
  import { type ImplicitAllowedTypes, type ImplicitFieldSchema } from "./schemaTypes.js";
8
- import { type InsertableContent } from "./toMapTree.js";
8
+ import { type InsertableContent } from "./unhydratedFlexTreeFromInsertable.js";
9
+ import { type UnhydratedFlexTreeNode } from "./core/index.js";
9
10
  /**
10
11
  * Prepare content from a user for insertion into a tree.
11
12
  * @remarks
@@ -14,7 +15,7 @@ import { type InsertableContent } from "./toMapTree.js";
14
15
  * The next edit made to `destinationContext`'s forest must be the creation of a detached field containing this content,
15
16
  * (Triggering {@link ForestEvents.afterRootFieldCreated}) otherwise hydration will break.
16
17
  */
17
- export declare function prepareForInsertion<TIn extends InsertableContent | undefined>(data: TIn, schema: ImplicitFieldSchema, destinationContext: FlexTreeContext): TIn extends undefined ? undefined : ExclusiveMapTree;
18
+ export declare function prepareForInsertion<TIn extends InsertableContent | undefined>(data: TIn, schema: ImplicitFieldSchema, destinationContext: FlexTreeContext): TIn extends undefined ? undefined : FlexibleNodeContent;
18
19
  /**
19
20
  * {@link prepareForInsertion} but batched for array content.
20
21
  * @remarks
@@ -28,7 +29,7 @@ export declare function prepareForInsertion<TIn extends InsertableContent | unde
28
29
  * (as opposed to mapping {@link prepareForInsertion} over the array)
29
30
  * due to how the eventing in prepareContentForHydration works.
30
31
  */
31
- export declare function prepareArrayContentForInsertion(data: readonly InsertableContent[], schema: ImplicitAllowedTypes, destinationContext: FlexTreeContext): ExclusiveMapTree[];
32
+ export declare function prepareArrayContentForInsertion(data: readonly InsertableContent[], schema: ImplicitAllowedTypes, destinationContext: FlexTreeContext): FlexibleFieldContent;
32
33
  /**
33
34
  * Split out from {@link prepareForInsertion} as to allow use without a context.
34
35
  *
@@ -38,5 +39,18 @@ export declare function prepareArrayContentForInsertion(data: readonly Insertabl
38
39
  * @remarks
39
40
  * Adding this entry point is a workaround for initialize not currently having a context.
40
41
  */
41
- export declare function prepareForInsertionContextless<TIn extends InsertableContent | undefined>(data: TIn, schema: ImplicitFieldSchema, schemaAndPolicy: SchemaAndPolicy, hydratedData: Pick<FlexTreeHydratedContext, "checkout" | "nodeKeyManager"> | undefined): TIn extends undefined ? undefined : ExclusiveMapTree;
42
+ export declare function prepareForInsertionContextless<TIn extends InsertableContent | undefined>(data: TIn, schema: ImplicitFieldSchema, schemaAndPolicy: SchemaAndPolicy, hydratedData: FlexTreeHydratedContextMinimal | undefined): TIn extends undefined ? undefined : FlexibleNodeContent;
43
+ /**
44
+ * Records any {@link TreeNode}s in the given `content` tree and does the necessary bookkeeping to ensure they are synchronized with subsequent reads of the tree.
45
+ * Additionally populates any {@link UnhydratedFlexTreeField.pendingDefault}s using the provided `context`.
46
+ *
47
+ * @remarks If the content tree contains has any associated {@link TreeNode}s, this function must be called just prior to inserting the content into the tree.
48
+ * Specifically, no other content may be inserted into the tree between the invocation of this function and the insertion of `content`.
49
+ * The insertion of `content` must occur or else this function will cause memory leaks.
50
+ *
51
+ * Exported for testing purposes: otherwise should not be used outside this module.
52
+ * @param content - the content subsequence to be inserted, of which might deeply contain {@link TreeNode}s which need to be hydrated.
53
+ * @param forest - the forest the content is being inserted into.
54
+ */
55
+ export declare function prepareContentForHydration(content: readonly UnhydratedFlexTreeNode[], forest: IForestSubscription, context: FlexTreeHydratedContextMinimal): void;
42
56
  //# sourceMappingURL=prepareForInsertion.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"prepareForInsertion.d.ts","sourceRoot":"","sources":["../../src/simple-tree/prepareForInsertion.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EACX,gBAAgB,EAChB,eAAe,EAQf,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACN,KAAK,eAAe,EAEpB,KAAK,uBAAuB,EAE5B,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAEN,KAAK,oBAAoB,EACzB,KAAK,mBAAmB,EACxB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,KAAK,iBAAiB,EAAuB,MAAM,gBAAgB,CAAC;AAa7E;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CAAC,GAAG,SAAS,iBAAiB,GAAG,SAAS,EAC5E,IAAI,EAAE,GAAG,EACT,MAAM,EAAE,mBAAmB,EAC3B,kBAAkB,EAAE,eAAe,GACjC,GAAG,SAAS,SAAS,GAAG,SAAS,GAAG,gBAAgB,CAOtD;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,+BAA+B,CAC9C,IAAI,EAAE,SAAS,iBAAiB,EAAE,EAClC,MAAM,EAAE,oBAAoB,EAC5B,kBAAkB,EAAE,eAAe,GACjC,gBAAgB,EAAE,CAmBpB;AAED;;;;;;;;GAQG;AACH,wBAAgB,8BAA8B,CAAC,GAAG,SAAS,iBAAiB,GAAG,SAAS,EACvF,IAAI,EAAE,GAAG,EACT,MAAM,EAAE,mBAAmB,EAC3B,eAAe,EAAE,eAAe,EAChC,YAAY,EAAE,IAAI,CAAC,uBAAuB,EAAE,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;;;;;;;;;GAWG;AACH,wBAAgB,0BAA0B,CACzC,OAAO,EAAE,SAAS,sBAAsB,EAAE,EAC1C,MAAM,EAAE,mBAAmB,EAC3B,OAAO,EAAE,8BAA8B,GACrC,IAAI,CAuBN"}
@@ -4,10 +4,10 @@
4
4
  * Licensed under the MIT License.
5
5
  */
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.prepareForInsertionContextless = exports.prepareArrayContentForInsertion = exports.prepareForInsertion = void 0;
7
+ exports.prepareContentForHydration = exports.prepareForInsertionContextless = exports.prepareArrayContentForInsertion = exports.prepareForInsertion = void 0;
8
8
  const index_js_1 = require("../feature-libraries/index.js");
9
9
  const schemaTypes_js_1 = require("./schemaTypes.js");
10
- const toMapTree_js_1 = require("./toMapTree.js");
10
+ const unhydratedFlexTreeFromInsertable_js_1 = require("./unhydratedFlexTreeFromInsertable.js");
11
11
  const internal_1 = require("@fluidframework/telemetry-utils/internal");
12
12
  const index_js_2 = require("../util/index.js");
13
13
  const index_js_3 = require("./core/index.js");
@@ -40,9 +40,13 @@ exports.prepareForInsertion = prepareForInsertion;
40
40
  * due to how the eventing in prepareContentForHydration works.
41
41
  */
42
42
  function prepareArrayContentForInsertion(data, schema, destinationContext) {
43
- const mapTrees = data.map((item) => (0, toMapTree_js_1.mapTreeFromNodeData)(item, schema, destinationContext.isHydrated() ? destinationContext.nodeKeyManager : undefined));
43
+ const mapTrees = data.map((item) => (0, unhydratedFlexTreeFromInsertable_js_1.unhydratedFlexTreeFromInsertable)(item, schema));
44
44
  const fieldSchema = (0, toStoredSchema_js_1.convertField)((0, schemaTypes_js_1.normalizeFieldSchema)(schema));
45
- validateAndPrepare((0, index_js_1.getSchemaAndPolicy)(destinationContext), destinationContext.isHydrated() ? destinationContext : undefined, { kind: index_js_1.FieldKinds.sequence.identifier, types: fieldSchema.types }, mapTrees);
45
+ validateAndPrepare((0, index_js_1.getSchemaAndPolicy)(destinationContext), destinationContext.isHydrated() ? destinationContext : undefined, {
46
+ kind: index_js_1.FieldKinds.sequence.identifier,
47
+ types: fieldSchema.types,
48
+ persistedMetadata: undefined,
49
+ }, mapTrees);
46
50
  return mapTrees;
47
51
  }
48
52
  exports.prepareArrayContentForInsertion = prepareArrayContentForInsertion;
@@ -56,7 +60,7 @@ exports.prepareArrayContentForInsertion = prepareArrayContentForInsertion;
56
60
  * Adding this entry point is a workaround for initialize not currently having a context.
57
61
  */
58
62
  function prepareForInsertionContextless(data, schema, schemaAndPolicy, hydratedData) {
59
- const mapTree = (0, toMapTree_js_1.mapTreeFromNodeData)(data, schema, hydratedData?.nodeKeyManager);
63
+ const mapTree = (0, unhydratedFlexTreeFromInsertable_js_1.unhydratedFlexTreeFromInsertable)(data, schema);
60
64
  const contentArray = mapTree === undefined ? [] : [mapTree];
61
65
  const fieldSchema = (0, toStoredSchema_js_1.convertField)((0, schemaTypes_js_1.normalizeFieldSchema)(schema));
62
66
  validateAndPrepare(schemaAndPolicy, hydratedData, fieldSchema, contentArray);
@@ -71,11 +75,14 @@ exports.prepareForInsertionContextless = prepareForInsertionContextless;
71
75
  */
72
76
  function validateAndPrepare(schemaAndPolicy, hydratedData, fieldSchema, mapTrees) {
73
77
  if (hydratedData !== undefined) {
78
+ // Run `prepareContentForHydration` before walking the tree in `isFieldInSchema`.
79
+ // This ensures that when `isFieldInSchema` requests identifiers (or any other contextual defaults),
80
+ // they were already creating used the more specific context we have access to from `hydratedData`.
81
+ prepareContentForHydration(mapTrees, hydratedData.checkout.forest, hydratedData);
74
82
  if (schemaAndPolicy.policy.validateSchema === true) {
75
83
  const maybeError = (0, index_js_4.isFieldInSchema)(mapTrees, fieldSchema, schemaAndPolicy);
76
84
  (0, index_js_4.inSchemaOrThrow)(maybeError);
77
85
  }
78
- prepareContentForHydration(mapTrees, hydratedData.checkout.forest);
79
86
  }
80
87
  }
81
88
  /**
@@ -83,15 +90,18 @@ function validateAndPrepare(schemaAndPolicy, hydratedData, fieldSchema, mapTrees
83
90
  */
84
91
  const placeholderKey = (0, index_js_2.brand)("placeholder");
85
92
  /**
86
- * Records any proxies in the given content tree and does the necessary bookkeeping to ensure they are synchronized with subsequent reads of the tree.
87
- * @remarks If the content tree contains any proxies, this function must be called just prior to inserting the content into the tree.
93
+ * Records any {@link TreeNode}s in the given `content` tree and does the necessary bookkeeping to ensure they are synchronized with subsequent reads of the tree.
94
+ * Additionally populates any {@link UnhydratedFlexTreeField.pendingDefault}s using the provided `context`.
95
+ *
96
+ * @remarks If the content tree contains has any associated {@link TreeNode}s, this function must be called just prior to inserting the content into the tree.
88
97
  * Specifically, no other content may be inserted into the tree between the invocation of this function and the insertion of `content`.
89
98
  * The insertion of `content` must occur or else this function will cause memory leaks.
99
+ *
100
+ * Exported for testing purposes: otherwise should not be used outside this module.
90
101
  * @param content - the content subsequence to be inserted, of which might deeply contain {@link TreeNode}s which need to be hydrated.
91
102
  * @param forest - the forest the content is being inserted into.
92
- * See {@link extractFactoryContent} for more details.
93
103
  */
94
- function prepareContentForHydration(content, forest) {
104
+ function prepareContentForHydration(content, forest, context) {
95
105
  const batches = [];
96
106
  for (const item of content) {
97
107
  const batch = {
@@ -105,26 +115,27 @@ function prepareContentForHydration(content, forest) {
105
115
  batches.push(batch);
106
116
  walkMapTree(item, batch.rootPath, (p, node) => {
107
117
  batch.paths.push({ path: p, node });
108
- });
118
+ }, context);
109
119
  }
110
120
  scheduleHydration(batches, forest);
111
121
  }
112
- function walkMapTree(mapTree, path, onVisitTreeNode) {
113
- if ((0, index_js_3.tryUnhydratedFlexTreeNode)(mapTree)?.parentField.parent.parent !== undefined) {
122
+ exports.prepareContentForHydration = prepareContentForHydration;
123
+ function walkMapTree(root, path, onVisitTreeNode, context) {
124
+ if (root.parentField.parent.parent !== undefined) {
114
125
  throw new internal_1.UsageError("Attempted to insert a node which is already under a parent. If this is desired, remove the node from its parent before inserting it elsewhere.");
115
126
  }
116
127
  const nexts = [];
117
- for (let next = [path, mapTree]; next !== undefined; next = nexts.pop()) {
118
- const [p, m] = next;
119
- const mapTreeNode = (0, index_js_3.tryUnhydratedFlexTreeNode)(m);
120
- if (mapTreeNode !== undefined) {
121
- const treeNode = index_js_3.unhydratedFlexTreeNodeToTreeNode.get(mapTreeNode);
128
+ for (let next = [path, root]; next !== undefined; next = nexts.pop()) {
129
+ const [p, node] = next;
130
+ if (node !== undefined) {
131
+ const treeNode = node.treeNode;
122
132
  if (treeNode !== undefined) {
123
133
  onVisitTreeNode(p, treeNode);
124
134
  }
125
135
  }
126
- for (const [key, field] of m.fields) {
127
- for (const [i, child] of field.entries()) {
136
+ for (const [key, field] of node.allFieldsLazy) {
137
+ field.fillPendingDefaults(context);
138
+ for (const [i, child] of field.children.entries()) {
128
139
  nexts.push([
129
140
  {
130
141
  parent: p,