@fluidframework/tree 2.82.0 → 2.90.0-378676

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 (986) hide show
  1. package/CHANGELOG.md +43 -0
  2. package/README.md +33 -5
  3. package/api-report/tree.alpha.api.md +26 -21
  4. package/api-report/tree.beta.api.md +14 -2
  5. package/api-report/tree.legacy.beta.api.md +14 -2
  6. package/api-report/tree.legacy.public.api.md +1 -1
  7. package/api-report/tree.public.api.md +1 -1
  8. package/dist/alpha.d.ts +3 -3
  9. package/dist/beta.d.ts +1 -0
  10. package/dist/codec/codec.d.ts +3 -39
  11. package/dist/codec/codec.d.ts.map +1 -1
  12. package/dist/codec/codec.js +5 -50
  13. package/dist/codec/codec.js.map +1 -1
  14. package/dist/codec/index.d.ts +1 -1
  15. package/dist/codec/index.d.ts.map +1 -1
  16. package/dist/codec/index.js +1 -2
  17. package/dist/codec/index.js.map +1 -1
  18. package/dist/codec/versioned/codec.d.ts +20 -7
  19. package/dist/codec/versioned/codec.d.ts.map +1 -1
  20. package/dist/codec/versioned/codec.js +56 -30
  21. package/dist/codec/versioned/codec.js.map +1 -1
  22. package/dist/core/change-family/changeFamily.d.ts +4 -1
  23. package/dist/core/change-family/changeFamily.d.ts.map +1 -1
  24. package/dist/core/change-family/changeFamily.js.map +1 -1
  25. package/dist/core/change-family/index.d.ts +1 -1
  26. package/dist/core/change-family/index.d.ts.map +1 -1
  27. package/dist/core/change-family/index.js.map +1 -1
  28. package/dist/core/index.d.ts +3 -3
  29. package/dist/core/index.d.ts.map +1 -1
  30. package/dist/core/index.js +6 -4
  31. package/dist/core/index.js.map +1 -1
  32. package/dist/core/rebase/changeRebaser.d.ts +6 -1
  33. package/dist/core/rebase/changeRebaser.d.ts.map +1 -1
  34. package/dist/core/rebase/changeRebaser.js.map +1 -1
  35. package/dist/core/rebase/index.d.ts +1 -1
  36. package/dist/core/rebase/index.d.ts.map +1 -1
  37. package/dist/core/rebase/index.js +2 -1
  38. package/dist/core/rebase/index.js.map +1 -1
  39. package/dist/core/rebase/types.d.ts +1 -0
  40. package/dist/core/rebase/types.d.ts.map +1 -1
  41. package/dist/core/rebase/types.js +5 -1
  42. package/dist/core/rebase/types.js.map +1 -1
  43. package/dist/core/rebase/utils.d.ts.map +1 -1
  44. package/dist/core/rebase/utils.js +25 -7
  45. package/dist/core/rebase/utils.js.map +1 -1
  46. package/dist/core/tree/delta.d.ts +5 -0
  47. package/dist/core/tree/delta.d.ts.map +1 -1
  48. package/dist/core/tree/delta.js.map +1 -1
  49. package/dist/core/tree/detachedFieldIndex.d.ts +13 -1
  50. package/dist/core/tree/detachedFieldIndex.d.ts.map +1 -1
  51. package/dist/core/tree/detachedFieldIndex.js +14 -1
  52. package/dist/core/tree/detachedFieldIndex.js.map +1 -1
  53. package/dist/core/tree/detachedFieldIndexCodecs.d.ts.map +1 -1
  54. package/dist/core/tree/detachedFieldIndexCodecs.js +6 -4
  55. package/dist/core/tree/detachedFieldIndexCodecs.js.map +1 -1
  56. package/dist/core/tree/detachedFieldIndexTypes.d.ts +4 -0
  57. package/dist/core/tree/detachedFieldIndexTypes.d.ts.map +1 -1
  58. package/dist/core/tree/detachedFieldIndexTypes.js.map +1 -1
  59. package/dist/core/tree/index.d.ts +2 -2
  60. package/dist/core/tree/index.d.ts.map +1 -1
  61. package/dist/core/tree/index.js +4 -3
  62. package/dist/core/tree/index.js.map +1 -1
  63. package/dist/core/tree/pathTree.d.ts +11 -3
  64. package/dist/core/tree/pathTree.d.ts.map +1 -1
  65. package/dist/core/tree/pathTree.js +14 -2
  66. package/dist/core/tree/pathTree.js.map +1 -1
  67. package/dist/core/tree/visitDelta.d.ts.map +1 -1
  68. package/dist/core/tree/visitDelta.js +17 -13
  69. package/dist/core/tree/visitDelta.js.map +1 -1
  70. package/dist/extensibleUnionNode.d.ts +97 -0
  71. package/dist/extensibleUnionNode.d.ts.map +1 -0
  72. package/dist/{extensibleSchemaUnion.js → extensibleUnionNode.js} +28 -18
  73. package/dist/extensibleUnionNode.js.map +1 -0
  74. package/dist/feature-libraries/changeAtomIdBTree.d.ts +3 -2
  75. package/dist/feature-libraries/changeAtomIdBTree.d.ts.map +1 -1
  76. package/dist/feature-libraries/changeAtomIdBTree.js +15 -2
  77. package/dist/feature-libraries/changeAtomIdBTree.js.map +1 -1
  78. package/dist/feature-libraries/chunked-forest/codec/codecs.d.ts +1 -1
  79. package/dist/feature-libraries/chunked-forest/codec/codecs.d.ts.map +1 -1
  80. package/dist/feature-libraries/chunked-forest/codec/codecs.js +4 -4
  81. package/dist/feature-libraries/chunked-forest/codec/codecs.js.map +1 -1
  82. package/dist/feature-libraries/default-schema/defaultEditBuilder.d.ts +92 -44
  83. package/dist/feature-libraries/default-schema/defaultEditBuilder.d.ts.map +1 -1
  84. package/dist/feature-libraries/default-schema/defaultEditBuilder.js +220 -70
  85. package/dist/feature-libraries/default-schema/defaultEditBuilder.js.map +1 -1
  86. package/dist/feature-libraries/default-schema/defaultFieldKinds.d.ts.map +1 -1
  87. package/dist/feature-libraries/default-schema/defaultFieldKinds.js +12 -2
  88. package/dist/feature-libraries/default-schema/defaultFieldKinds.js.map +1 -1
  89. package/dist/feature-libraries/default-schema/index.d.ts +2 -1
  90. package/dist/feature-libraries/default-schema/index.d.ts.map +1 -1
  91. package/dist/feature-libraries/default-schema/index.js +4 -2
  92. package/dist/feature-libraries/default-schema/index.js.map +1 -1
  93. package/dist/feature-libraries/default-schema/locationBasedEditBuilder.d.ts +40 -0
  94. package/dist/feature-libraries/default-schema/locationBasedEditBuilder.d.ts.map +1 -0
  95. package/dist/feature-libraries/default-schema/locationBasedEditBuilder.js +153 -0
  96. package/dist/feature-libraries/default-schema/locationBasedEditBuilder.js.map +1 -0
  97. package/dist/feature-libraries/default-schema/mappedEditBuilder.d.ts +7 -6
  98. package/dist/feature-libraries/default-schema/mappedEditBuilder.d.ts.map +1 -1
  99. package/dist/feature-libraries/default-schema/mappedEditBuilder.js +15 -0
  100. package/dist/feature-libraries/default-schema/mappedEditBuilder.js.map +1 -1
  101. package/dist/feature-libraries/deltaUtils.d.ts +1 -0
  102. package/dist/feature-libraries/deltaUtils.d.ts.map +1 -1
  103. package/dist/feature-libraries/deltaUtils.js +6 -1
  104. package/dist/feature-libraries/deltaUtils.js.map +1 -1
  105. package/dist/feature-libraries/flex-tree/context.d.ts +9 -0
  106. package/dist/feature-libraries/flex-tree/context.d.ts.map +1 -1
  107. package/dist/feature-libraries/flex-tree/context.js +6 -0
  108. package/dist/feature-libraries/flex-tree/context.js.map +1 -1
  109. package/dist/feature-libraries/flex-tree/flexTreeTypes.d.ts +6 -6
  110. package/dist/feature-libraries/flex-tree/flexTreeTypes.d.ts.map +1 -1
  111. package/dist/feature-libraries/flex-tree/flexTreeTypes.js.map +1 -1
  112. package/dist/feature-libraries/flex-tree/lazyField.d.ts +8 -7
  113. package/dist/feature-libraries/flex-tree/lazyField.d.ts.map +1 -1
  114. package/dist/feature-libraries/flex-tree/lazyField.js +39 -8
  115. package/dist/feature-libraries/flex-tree/lazyField.js.map +1 -1
  116. package/dist/feature-libraries/forest-summary/codec.d.ts.map +1 -1
  117. package/dist/feature-libraries/forest-summary/codec.js +7 -1
  118. package/dist/feature-libraries/forest-summary/codec.js.map +1 -1
  119. package/dist/feature-libraries/forest-summary/formatCommon.d.ts +3 -3
  120. package/dist/feature-libraries/forest-summary/formatCommon.d.ts.map +1 -1
  121. package/dist/feature-libraries/forest-summary/formatCommon.js.map +1 -1
  122. package/dist/feature-libraries/forest-summary/formatV1.d.ts +2 -3
  123. package/dist/feature-libraries/forest-summary/formatV1.d.ts.map +1 -1
  124. package/dist/feature-libraries/forest-summary/formatV1.js +1 -2
  125. package/dist/feature-libraries/forest-summary/formatV1.js.map +1 -1
  126. package/dist/feature-libraries/forest-summary/formatV2.d.ts +2 -3
  127. package/dist/feature-libraries/forest-summary/formatV2.d.ts.map +1 -1
  128. package/dist/feature-libraries/forest-summary/formatV2.js +1 -2
  129. package/dist/feature-libraries/forest-summary/formatV2.js.map +1 -1
  130. package/dist/feature-libraries/index.d.ts +3 -3
  131. package/dist/feature-libraries/index.d.ts.map +1 -1
  132. package/dist/feature-libraries/index.js +8 -4
  133. package/dist/feature-libraries/index.js.map +1 -1
  134. package/dist/feature-libraries/mitigatedChangeFamily.d.ts.map +1 -1
  135. package/dist/feature-libraries/mitigatedChangeFamily.js +2 -2
  136. package/dist/feature-libraries/mitigatedChangeFamily.js.map +1 -1
  137. package/dist/feature-libraries/modular-schema/crossFieldQueries.d.ts +100 -24
  138. package/dist/feature-libraries/modular-schema/crossFieldQueries.d.ts.map +1 -1
  139. package/dist/feature-libraries/modular-schema/crossFieldQueries.js +8 -12
  140. package/dist/feature-libraries/modular-schema/crossFieldQueries.js.map +1 -1
  141. package/dist/feature-libraries/modular-schema/fieldChangeHandler.d.ts +85 -51
  142. package/dist/feature-libraries/modular-schema/fieldChangeHandler.d.ts.map +1 -1
  143. package/dist/feature-libraries/modular-schema/fieldChangeHandler.js.map +1 -1
  144. package/dist/feature-libraries/modular-schema/genericFieldKind.d.ts.map +1 -1
  145. package/dist/feature-libraries/modular-schema/genericFieldKind.js +4 -9
  146. package/dist/feature-libraries/modular-schema/genericFieldKind.js.map +1 -1
  147. package/dist/feature-libraries/modular-schema/index.d.ts +3 -3
  148. package/dist/feature-libraries/modular-schema/index.d.ts.map +1 -1
  149. package/dist/feature-libraries/modular-schema/index.js +2 -3
  150. package/dist/feature-libraries/modular-schema/index.js.map +1 -1
  151. package/dist/feature-libraries/modular-schema/modularChangeCodecV1.d.ts +20 -24
  152. package/dist/feature-libraries/modular-schema/modularChangeCodecV1.d.ts.map +1 -1
  153. package/dist/feature-libraries/modular-schema/modularChangeCodecV1.js +277 -159
  154. package/dist/feature-libraries/modular-schema/modularChangeCodecV1.js.map +1 -1
  155. package/dist/feature-libraries/modular-schema/modularChangeCodecV2.d.ts.map +1 -1
  156. package/dist/feature-libraries/modular-schema/modularChangeCodecV2.js +1 -1
  157. package/dist/feature-libraries/modular-schema/modularChangeCodecV2.js.map +1 -1
  158. package/dist/feature-libraries/modular-schema/modularChangeCodecV3.d.ts +15 -0
  159. package/dist/feature-libraries/modular-schema/modularChangeCodecV3.d.ts.map +1 -0
  160. package/dist/feature-libraries/modular-schema/modularChangeCodecV3.js +296 -0
  161. package/dist/feature-libraries/modular-schema/modularChangeCodecV3.js.map +1 -0
  162. package/dist/feature-libraries/modular-schema/modularChangeCodecs.d.ts +1 -0
  163. package/dist/feature-libraries/modular-schema/modularChangeCodecs.d.ts.map +1 -1
  164. package/dist/feature-libraries/modular-schema/modularChangeCodecs.js +8 -0
  165. package/dist/feature-libraries/modular-schema/modularChangeCodecs.js.map +1 -1
  166. package/dist/feature-libraries/modular-schema/modularChangeFamily.d.ts +56 -22
  167. package/dist/feature-libraries/modular-schema/modularChangeFamily.d.ts.map +1 -1
  168. package/dist/feature-libraries/modular-schema/modularChangeFamily.js +1390 -462
  169. package/dist/feature-libraries/modular-schema/modularChangeFamily.js.map +1 -1
  170. package/dist/feature-libraries/modular-schema/modularChangeFormatV1.d.ts.map +1 -1
  171. package/dist/feature-libraries/modular-schema/modularChangeFormatV1.js.map +1 -1
  172. package/dist/feature-libraries/modular-schema/modularChangeFormatV2.d.ts +1 -2
  173. package/dist/feature-libraries/modular-schema/modularChangeFormatV2.d.ts.map +1 -1
  174. package/dist/feature-libraries/modular-schema/modularChangeFormatV2.js +3 -3
  175. package/dist/feature-libraries/modular-schema/modularChangeFormatV2.js.map +1 -1
  176. package/dist/feature-libraries/modular-schema/modularChangeFormatV3.d.ts +74 -0
  177. package/dist/feature-libraries/modular-schema/modularChangeFormatV3.d.ts.map +1 -0
  178. package/dist/feature-libraries/modular-schema/modularChangeFormatV3.js +35 -0
  179. package/dist/feature-libraries/modular-schema/modularChangeFormatV3.js.map +1 -0
  180. package/dist/feature-libraries/modular-schema/modularChangeTypes.d.ts +49 -10
  181. package/dist/feature-libraries/modular-schema/modularChangeTypes.d.ts.map +1 -1
  182. package/dist/feature-libraries/modular-schema/modularChangeTypes.js +3 -3
  183. package/dist/feature-libraries/modular-schema/modularChangeTypes.js.map +1 -1
  184. package/dist/feature-libraries/optional-field/optionalField.d.ts +13 -32
  185. package/dist/feature-libraries/optional-field/optionalField.d.ts.map +1 -1
  186. package/dist/feature-libraries/optional-field/optionalField.js +257 -446
  187. package/dist/feature-libraries/optional-field/optionalField.js.map +1 -1
  188. package/dist/feature-libraries/optional-field/optionalFieldChangeFormatV3.d.ts +23 -0
  189. package/dist/feature-libraries/optional-field/optionalFieldChangeFormatV3.d.ts.map +1 -0
  190. package/dist/feature-libraries/optional-field/optionalFieldChangeFormatV3.js +31 -0
  191. package/dist/feature-libraries/optional-field/optionalFieldChangeFormatV3.js.map +1 -0
  192. package/dist/feature-libraries/optional-field/optionalFieldChangeTypes.d.ts +31 -31
  193. package/dist/feature-libraries/optional-field/optionalFieldChangeTypes.d.ts.map +1 -1
  194. package/dist/feature-libraries/optional-field/optionalFieldChangeTypes.js.map +1 -1
  195. package/dist/feature-libraries/optional-field/optionalFieldCodecV2.d.ts +1 -1
  196. package/dist/feature-libraries/optional-field/optionalFieldCodecV2.d.ts.map +1 -1
  197. package/dist/feature-libraries/optional-field/optionalFieldCodecV2.js +57 -28
  198. package/dist/feature-libraries/optional-field/optionalFieldCodecV2.js.map +1 -1
  199. package/dist/feature-libraries/optional-field/optionalFieldCodecV3.d.ts +12 -0
  200. package/dist/feature-libraries/optional-field/optionalFieldCodecV3.d.ts.map +1 -0
  201. package/dist/feature-libraries/optional-field/optionalFieldCodecV3.js +57 -0
  202. package/dist/feature-libraries/optional-field/optionalFieldCodecV3.js.map +1 -0
  203. package/dist/feature-libraries/optional-field/optionalFieldCodecs.d.ts.map +1 -1
  204. package/dist/feature-libraries/optional-field/optionalFieldCodecs.js +5 -1
  205. package/dist/feature-libraries/optional-field/optionalFieldCodecs.js.map +1 -1
  206. package/dist/feature-libraries/optional-field/requiredField.d.ts +3 -2
  207. package/dist/feature-libraries/optional-field/requiredField.d.ts.map +1 -1
  208. package/dist/feature-libraries/optional-field/requiredField.js +6 -1
  209. package/dist/feature-libraries/optional-field/requiredField.js.map +1 -1
  210. package/dist/feature-libraries/schema-index/codec.d.ts.map +1 -1
  211. package/dist/feature-libraries/schema-index/codec.js +6 -4
  212. package/dist/feature-libraries/schema-index/codec.js.map +1 -1
  213. package/dist/feature-libraries/sequence-field/compose.d.ts +6 -7
  214. package/dist/feature-libraries/sequence-field/compose.d.ts.map +1 -1
  215. package/dist/feature-libraries/sequence-field/compose.js +81 -259
  216. package/dist/feature-libraries/sequence-field/compose.js.map +1 -1
  217. package/dist/feature-libraries/sequence-field/helperTypes.d.ts +14 -10
  218. package/dist/feature-libraries/sequence-field/helperTypes.d.ts.map +1 -1
  219. package/dist/feature-libraries/sequence-field/helperTypes.js.map +1 -1
  220. package/dist/feature-libraries/sequence-field/invert.d.ts +3 -3
  221. package/dist/feature-libraries/sequence-field/invert.d.ts.map +1 -1
  222. package/dist/feature-libraries/sequence-field/invert.js +65 -167
  223. package/dist/feature-libraries/sequence-field/invert.js.map +1 -1
  224. package/dist/feature-libraries/sequence-field/markQueue.d.ts +2 -2
  225. package/dist/feature-libraries/sequence-field/markQueue.d.ts.map +1 -1
  226. package/dist/feature-libraries/sequence-field/markQueue.js.map +1 -1
  227. package/dist/feature-libraries/sequence-field/moveEffectTable.d.ts +4 -56
  228. package/dist/feature-libraries/sequence-field/moveEffectTable.d.ts.map +1 -1
  229. package/dist/feature-libraries/sequence-field/moveEffectTable.js +7 -90
  230. package/dist/feature-libraries/sequence-field/moveEffectTable.js.map +1 -1
  231. package/dist/feature-libraries/sequence-field/rebase.d.ts +3 -3
  232. package/dist/feature-libraries/sequence-field/rebase.d.ts.map +1 -1
  233. package/dist/feature-libraries/sequence-field/rebase.js +109 -116
  234. package/dist/feature-libraries/sequence-field/rebase.js.map +1 -1
  235. package/dist/feature-libraries/sequence-field/replaceRevisions.d.ts.map +1 -1
  236. package/dist/feature-libraries/sequence-field/replaceRevisions.js +19 -32
  237. package/dist/feature-libraries/sequence-field/replaceRevisions.js.map +1 -1
  238. package/dist/feature-libraries/sequence-field/sequenceFieldChangeHandler.d.ts.map +1 -1
  239. package/dist/feature-libraries/sequence-field/sequenceFieldChangeHandler.js +1 -2
  240. package/dist/feature-libraries/sequence-field/sequenceFieldChangeHandler.js.map +1 -1
  241. package/dist/feature-libraries/sequence-field/sequenceFieldCodecV2.d.ts +22 -4
  242. package/dist/feature-libraries/sequence-field/sequenceFieldCodecV2.d.ts.map +1 -1
  243. package/dist/feature-libraries/sequence-field/sequenceFieldCodecV2.js +388 -187
  244. package/dist/feature-libraries/sequence-field/sequenceFieldCodecV2.js.map +1 -1
  245. package/dist/feature-libraries/sequence-field/sequenceFieldCodecV3.d.ts.map +1 -1
  246. package/dist/feature-libraries/sequence-field/sequenceFieldCodecV3.js +20 -62
  247. package/dist/feature-libraries/sequence-field/sequenceFieldCodecV3.js.map +1 -1
  248. package/dist/feature-libraries/sequence-field/sequenceFieldEditor.d.ts +2 -2
  249. package/dist/feature-libraries/sequence-field/sequenceFieldEditor.d.ts.map +1 -1
  250. package/dist/feature-libraries/sequence-field/sequenceFieldEditor.js +13 -13
  251. package/dist/feature-libraries/sequence-field/sequenceFieldEditor.js.map +1 -1
  252. package/dist/feature-libraries/sequence-field/sequenceFieldToDelta.d.ts +3 -2
  253. package/dist/feature-libraries/sequence-field/sequenceFieldToDelta.d.ts.map +1 -1
  254. package/dist/feature-libraries/sequence-field/sequenceFieldToDelta.js +16 -111
  255. package/dist/feature-libraries/sequence-field/sequenceFieldToDelta.js.map +1 -1
  256. package/dist/feature-libraries/sequence-field/types.d.ts +37 -74
  257. package/dist/feature-libraries/sequence-field/types.d.ts.map +1 -1
  258. package/dist/feature-libraries/sequence-field/types.js.map +1 -1
  259. package/dist/feature-libraries/sequence-field/utils.d.ts +20 -25
  260. package/dist/feature-libraries/sequence-field/utils.d.ts.map +1 -1
  261. package/dist/feature-libraries/sequence-field/utils.js +159 -320
  262. package/dist/feature-libraries/sequence-field/utils.js.map +1 -1
  263. package/dist/index.d.ts +2 -2
  264. package/dist/index.d.ts.map +1 -1
  265. package/dist/index.js +4 -4
  266. package/dist/index.js.map +1 -1
  267. package/dist/legacy.d.ts +1 -0
  268. package/dist/packageVersion.d.ts +1 -1
  269. package/dist/packageVersion.d.ts.map +1 -1
  270. package/dist/packageVersion.js +1 -1
  271. package/dist/packageVersion.js.map +1 -1
  272. package/dist/shared-tree/independentView.d.ts.map +1 -1
  273. package/dist/shared-tree/independentView.js +1 -1
  274. package/dist/shared-tree/independentView.js.map +1 -1
  275. package/dist/shared-tree/index.d.ts +1 -1
  276. package/dist/shared-tree/index.d.ts.map +1 -1
  277. package/dist/shared-tree/index.js.map +1 -1
  278. package/dist/shared-tree/schematizeTree.d.ts +4 -4
  279. package/dist/shared-tree/schematizeTree.d.ts.map +1 -1
  280. package/dist/shared-tree/schematizeTree.js +2 -1
  281. package/dist/shared-tree/schematizeTree.js.map +1 -1
  282. package/dist/shared-tree/schematizingTreeView.d.ts +1 -5
  283. package/dist/shared-tree/schematizingTreeView.d.ts.map +1 -1
  284. package/dist/shared-tree/schematizingTreeView.js +21 -35
  285. package/dist/shared-tree/schematizingTreeView.js.map +1 -1
  286. package/dist/shared-tree/sharedTree.d.ts +9 -3
  287. package/dist/shared-tree/sharedTree.d.ts.map +1 -1
  288. package/dist/shared-tree/sharedTree.js +4 -1
  289. package/dist/shared-tree/sharedTree.js.map +1 -1
  290. package/dist/shared-tree/sharedTreeChangeCodecs.d.ts +1 -0
  291. package/dist/shared-tree/sharedTreeChangeCodecs.d.ts.map +1 -1
  292. package/dist/shared-tree/sharedTreeChangeCodecs.js +9 -1
  293. package/dist/shared-tree/sharedTreeChangeCodecs.js.map +1 -1
  294. package/dist/shared-tree/sharedTreeChangeFamily.d.ts +4 -4
  295. package/dist/shared-tree/sharedTreeChangeFamily.d.ts.map +1 -1
  296. package/dist/shared-tree/sharedTreeChangeFamily.js +2 -2
  297. package/dist/shared-tree/sharedTreeChangeFamily.js.map +1 -1
  298. package/dist/shared-tree/sharedTreeEditBuilder.d.ts +16 -6
  299. package/dist/shared-tree/sharedTreeEditBuilder.d.ts.map +1 -1
  300. package/dist/shared-tree/sharedTreeEditBuilder.js +14 -7
  301. package/dist/shared-tree/sharedTreeEditBuilder.js.map +1 -1
  302. package/dist/shared-tree/tree.d.ts +1 -1
  303. package/dist/shared-tree/tree.js.map +1 -1
  304. package/dist/shared-tree/treeAlpha.d.ts +1 -1
  305. package/dist/shared-tree/treeAlpha.js.map +1 -1
  306. package/dist/shared-tree/treeCheckout.d.ts +13 -11
  307. package/dist/shared-tree/treeCheckout.d.ts.map +1 -1
  308. package/dist/shared-tree/treeCheckout.js +58 -10
  309. package/dist/shared-tree/treeCheckout.js.map +1 -1
  310. package/dist/shared-tree-core/branch.d.ts +3 -2
  311. package/dist/shared-tree-core/branch.d.ts.map +1 -1
  312. package/dist/shared-tree-core/branch.js +4 -3
  313. package/dist/shared-tree-core/branch.js.map +1 -1
  314. package/dist/shared-tree-core/editManager.d.ts +2 -2
  315. package/dist/shared-tree-core/editManager.d.ts.map +1 -1
  316. package/dist/shared-tree-core/editManager.js +9 -9
  317. package/dist/shared-tree-core/editManager.js.map +1 -1
  318. package/dist/shared-tree-core/editManagerCodecs.d.ts +4 -0
  319. package/dist/shared-tree-core/editManagerCodecs.d.ts.map +1 -1
  320. package/dist/shared-tree-core/editManagerCodecs.js +10 -2
  321. package/dist/shared-tree-core/editManagerCodecs.js.map +1 -1
  322. package/dist/shared-tree-core/editManagerCodecsCommons.d.ts +3 -3
  323. package/dist/shared-tree-core/editManagerCodecsCommons.d.ts.map +1 -1
  324. package/dist/shared-tree-core/editManagerCodecsCommons.js +2 -2
  325. package/dist/shared-tree-core/editManagerCodecsCommons.js.map +1 -1
  326. package/dist/shared-tree-core/editManagerCodecsV1toV4.d.ts +2 -2
  327. package/dist/shared-tree-core/editManagerCodecsV1toV4.d.ts.map +1 -1
  328. package/dist/shared-tree-core/editManagerCodecsV1toV4.js +1 -1
  329. package/dist/shared-tree-core/editManagerCodecsV1toV4.js.map +1 -1
  330. package/dist/shared-tree-core/editManagerCodecsVSharedBranches.d.ts +2 -2
  331. package/dist/shared-tree-core/editManagerCodecsVSharedBranches.d.ts.map +1 -1
  332. package/dist/shared-tree-core/editManagerCodecsVSharedBranches.js +1 -1
  333. package/dist/shared-tree-core/editManagerCodecsVSharedBranches.js.map +1 -1
  334. package/dist/shared-tree-core/editManagerFormatCommons.d.ts +1 -0
  335. package/dist/shared-tree-core/editManagerFormatCommons.d.ts.map +1 -1
  336. package/dist/shared-tree-core/editManagerFormatCommons.js +6 -0
  337. package/dist/shared-tree-core/editManagerFormatCommons.js.map +1 -1
  338. package/dist/shared-tree-core/editManagerFormatV1toV4.d.ts +2 -2
  339. package/dist/shared-tree-core/editManagerFormatV1toV4.d.ts.map +1 -1
  340. package/dist/shared-tree-core/editManagerFormatV1toV4.js +1 -0
  341. package/dist/shared-tree-core/editManagerFormatV1toV4.js.map +1 -1
  342. package/dist/shared-tree-core/index.d.ts +2 -2
  343. package/dist/shared-tree-core/index.d.ts.map +1 -1
  344. package/dist/shared-tree-core/index.js +3 -1
  345. package/dist/shared-tree-core/index.js.map +1 -1
  346. package/dist/shared-tree-core/messageCodecV1ToV4.d.ts +1 -1
  347. package/dist/shared-tree-core/messageCodecV1ToV4.d.ts.map +1 -1
  348. package/dist/shared-tree-core/messageCodecV1ToV4.js.map +1 -1
  349. package/dist/shared-tree-core/messageCodecs.d.ts +4 -0
  350. package/dist/shared-tree-core/messageCodecs.d.ts.map +1 -1
  351. package/dist/shared-tree-core/messageCodecs.js +12 -4
  352. package/dist/shared-tree-core/messageCodecs.js.map +1 -1
  353. package/dist/shared-tree-core/messageFormat.d.ts +1 -0
  354. package/dist/shared-tree-core/messageFormat.d.ts.map +1 -1
  355. package/dist/shared-tree-core/messageFormat.js +6 -0
  356. package/dist/shared-tree-core/messageFormat.js.map +1 -1
  357. package/dist/shared-tree-core/messageFormatV1ToV4.d.ts +2 -2
  358. package/dist/shared-tree-core/messageFormatV1ToV4.d.ts.map +1 -1
  359. package/dist/shared-tree-core/messageFormatV1ToV4.js +1 -0
  360. package/dist/shared-tree-core/messageFormatV1ToV4.js.map +1 -1
  361. package/dist/shared-tree-core/sharedTreeCore.d.ts +1 -0
  362. package/dist/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
  363. package/dist/shared-tree-core/sharedTreeCore.js +1 -1
  364. package/dist/shared-tree-core/sharedTreeCore.js.map +1 -1
  365. package/dist/simple-tree/api/index.d.ts +1 -1
  366. package/dist/simple-tree/api/index.d.ts.map +1 -1
  367. package/dist/simple-tree/api/index.js +2 -2
  368. package/dist/simple-tree/api/index.js.map +1 -1
  369. package/dist/simple-tree/api/snapshotCompatibilityChecker.d.ts +148 -29
  370. package/dist/simple-tree/api/snapshotCompatibilityChecker.d.ts.map +1 -1
  371. package/dist/simple-tree/api/snapshotCompatibilityChecker.js +180 -99
  372. package/dist/simple-tree/api/snapshotCompatibilityChecker.js.map +1 -1
  373. package/dist/simple-tree/api/tree.d.ts +1 -1
  374. package/dist/simple-tree/api/tree.js.map +1 -1
  375. package/dist/simple-tree/api/treeBeta.d.ts +1 -1
  376. package/dist/simple-tree/api/treeBeta.js.map +1 -1
  377. package/dist/simple-tree/core/allowedTypes.d.ts +1 -1
  378. package/dist/simple-tree/core/allowedTypes.js.map +1 -1
  379. package/dist/simple-tree/core/unhydratedFlexTree.d.ts +17 -12
  380. package/dist/simple-tree/core/unhydratedFlexTree.d.ts.map +1 -1
  381. package/dist/simple-tree/core/unhydratedFlexTree.js +88 -8
  382. package/dist/simple-tree/core/unhydratedFlexTree.js.map +1 -1
  383. package/dist/simple-tree/fieldSchema.d.ts +4 -4
  384. package/dist/simple-tree/fieldSchema.d.ts.map +1 -1
  385. package/dist/simple-tree/fieldSchema.js.map +1 -1
  386. package/dist/simple-tree/index.d.ts +3 -3
  387. package/dist/simple-tree/index.d.ts.map +1 -1
  388. package/dist/simple-tree/index.js +3 -3
  389. package/dist/simple-tree/index.js.map +1 -1
  390. package/dist/simple-tree/node-kinds/array/arrayNode.d.ts.map +1 -1
  391. package/dist/simple-tree/node-kinds/array/arrayNode.js +9 -16
  392. package/dist/simple-tree/node-kinds/array/arrayNode.js.map +1 -1
  393. package/dist/simple-tree/node-kinds/common.d.ts.map +1 -1
  394. package/dist/simple-tree/node-kinds/common.js +1 -1
  395. package/dist/simple-tree/node-kinds/common.js.map +1 -1
  396. package/dist/simple-tree/node-kinds/map/mapNode.js +2 -2
  397. package/dist/simple-tree/node-kinds/map/mapNode.js.map +1 -1
  398. package/dist/simple-tree/node-kinds/object/objectNode.d.ts.map +1 -1
  399. package/dist/simple-tree/node-kinds/object/objectNode.js +19 -19
  400. package/dist/simple-tree/node-kinds/object/objectNode.js.map +1 -1
  401. package/dist/simple-tree/node-kinds/record/recordNode.d.ts.map +1 -1
  402. package/dist/simple-tree/node-kinds/record/recordNode.js +4 -2
  403. package/dist/simple-tree/node-kinds/record/recordNode.js.map +1 -1
  404. package/dist/simple-tree/prepareForInsertion.d.ts +54 -47
  405. package/dist/simple-tree/prepareForInsertion.d.ts.map +1 -1
  406. package/dist/simple-tree/prepareForInsertion.js +183 -125
  407. package/dist/simple-tree/prepareForInsertion.js.map +1 -1
  408. package/dist/simple-tree/unhydratedFlexTreeFromInsertable.d.ts +8 -3
  409. package/dist/simple-tree/unhydratedFlexTreeFromInsertable.d.ts.map +1 -1
  410. package/dist/simple-tree/unhydratedFlexTreeFromInsertable.js +59 -19
  411. package/dist/simple-tree/unhydratedFlexTreeFromInsertable.js.map +1 -1
  412. package/dist/text/textDomainFormatted.d.ts +3 -3
  413. package/dist/text/textDomainFormatted.d.ts.map +1 -1
  414. package/dist/text/textDomainFormatted.js +48 -32
  415. package/dist/text/textDomainFormatted.js.map +1 -1
  416. package/dist/treeFactory.d.ts.map +1 -1
  417. package/dist/treeFactory.js +12 -2
  418. package/dist/treeFactory.js.map +1 -1
  419. package/dist/util/bTreeUtils.d.ts.map +1 -1
  420. package/dist/util/bTreeUtils.js +6 -6
  421. package/dist/util/bTreeUtils.js.map +1 -1
  422. package/dist/util/index.d.ts +1 -1
  423. package/dist/util/index.d.ts.map +1 -1
  424. package/dist/util/index.js +2 -1
  425. package/dist/util/index.js.map +1 -1
  426. package/dist/util/rangeMap.d.ts +23 -11
  427. package/dist/util/rangeMap.d.ts.map +1 -1
  428. package/dist/util/rangeMap.js +42 -10
  429. package/dist/util/rangeMap.js.map +1 -1
  430. package/lib/alpha.d.ts +3 -3
  431. package/lib/beta.d.ts +1 -0
  432. package/lib/codec/codec.d.ts +3 -39
  433. package/lib/codec/codec.d.ts.map +1 -1
  434. package/lib/codec/codec.js +4 -47
  435. package/lib/codec/codec.js.map +1 -1
  436. package/lib/codec/index.d.ts +1 -1
  437. package/lib/codec/index.d.ts.map +1 -1
  438. package/lib/codec/index.js +1 -1
  439. package/lib/codec/index.js.map +1 -1
  440. package/lib/codec/versioned/codec.d.ts +20 -7
  441. package/lib/codec/versioned/codec.d.ts.map +1 -1
  442. package/lib/codec/versioned/codec.js +59 -33
  443. package/lib/codec/versioned/codec.js.map +1 -1
  444. package/lib/core/change-family/changeFamily.d.ts +4 -1
  445. package/lib/core/change-family/changeFamily.d.ts.map +1 -1
  446. package/lib/core/change-family/changeFamily.js.map +1 -1
  447. package/lib/core/change-family/index.d.ts +1 -1
  448. package/lib/core/change-family/index.d.ts.map +1 -1
  449. package/lib/core/change-family/index.js.map +1 -1
  450. package/lib/core/index.d.ts +3 -3
  451. package/lib/core/index.d.ts.map +1 -1
  452. package/lib/core/index.js +2 -2
  453. package/lib/core/index.js.map +1 -1
  454. package/lib/core/rebase/changeRebaser.d.ts +6 -1
  455. package/lib/core/rebase/changeRebaser.d.ts.map +1 -1
  456. package/lib/core/rebase/changeRebaser.js.map +1 -1
  457. package/lib/core/rebase/index.d.ts +1 -1
  458. package/lib/core/rebase/index.d.ts.map +1 -1
  459. package/lib/core/rebase/index.js +1 -1
  460. package/lib/core/rebase/index.js.map +1 -1
  461. package/lib/core/rebase/types.d.ts +1 -0
  462. package/lib/core/rebase/types.d.ts.map +1 -1
  463. package/lib/core/rebase/types.js +3 -0
  464. package/lib/core/rebase/types.js.map +1 -1
  465. package/lib/core/rebase/utils.d.ts.map +1 -1
  466. package/lib/core/rebase/utils.js +25 -7
  467. package/lib/core/rebase/utils.js.map +1 -1
  468. package/lib/core/tree/delta.d.ts +5 -0
  469. package/lib/core/tree/delta.d.ts.map +1 -1
  470. package/lib/core/tree/delta.js.map +1 -1
  471. package/lib/core/tree/detachedFieldIndex.d.ts +13 -1
  472. package/lib/core/tree/detachedFieldIndex.d.ts.map +1 -1
  473. package/lib/core/tree/detachedFieldIndex.js +15 -2
  474. package/lib/core/tree/detachedFieldIndex.js.map +1 -1
  475. package/lib/core/tree/detachedFieldIndexCodecs.d.ts.map +1 -1
  476. package/lib/core/tree/detachedFieldIndexCodecs.js +6 -4
  477. package/lib/core/tree/detachedFieldIndexCodecs.js.map +1 -1
  478. package/lib/core/tree/detachedFieldIndexTypes.d.ts +4 -0
  479. package/lib/core/tree/detachedFieldIndexTypes.d.ts.map +1 -1
  480. package/lib/core/tree/detachedFieldIndexTypes.js.map +1 -1
  481. package/lib/core/tree/index.d.ts +2 -2
  482. package/lib/core/tree/index.d.ts.map +1 -1
  483. package/lib/core/tree/index.js +1 -1
  484. package/lib/core/tree/index.js.map +1 -1
  485. package/lib/core/tree/pathTree.d.ts +11 -3
  486. package/lib/core/tree/pathTree.d.ts.map +1 -1
  487. package/lib/core/tree/pathTree.js +12 -1
  488. package/lib/core/tree/pathTree.js.map +1 -1
  489. package/lib/core/tree/visitDelta.d.ts.map +1 -1
  490. package/lib/core/tree/visitDelta.js +17 -13
  491. package/lib/core/tree/visitDelta.js.map +1 -1
  492. package/lib/extensibleUnionNode.d.ts +97 -0
  493. package/lib/extensibleUnionNode.d.ts.map +1 -0
  494. package/lib/{extensibleSchemaUnion.js → extensibleUnionNode.js} +28 -18
  495. package/lib/extensibleUnionNode.js.map +1 -0
  496. package/lib/feature-libraries/changeAtomIdBTree.d.ts +3 -2
  497. package/lib/feature-libraries/changeAtomIdBTree.d.ts.map +1 -1
  498. package/lib/feature-libraries/changeAtomIdBTree.js +15 -3
  499. package/lib/feature-libraries/changeAtomIdBTree.js.map +1 -1
  500. package/lib/feature-libraries/chunked-forest/codec/codecs.d.ts +1 -1
  501. package/lib/feature-libraries/chunked-forest/codec/codecs.d.ts.map +1 -1
  502. package/lib/feature-libraries/chunked-forest/codec/codecs.js +5 -5
  503. package/lib/feature-libraries/chunked-forest/codec/codecs.js.map +1 -1
  504. package/lib/feature-libraries/default-schema/defaultEditBuilder.d.ts +92 -44
  505. package/lib/feature-libraries/default-schema/defaultEditBuilder.d.ts.map +1 -1
  506. package/lib/feature-libraries/default-schema/defaultEditBuilder.js +217 -69
  507. package/lib/feature-libraries/default-schema/defaultEditBuilder.js.map +1 -1
  508. package/lib/feature-libraries/default-schema/defaultFieldKinds.d.ts.map +1 -1
  509. package/lib/feature-libraries/default-schema/defaultFieldKinds.js +12 -2
  510. package/lib/feature-libraries/default-schema/defaultFieldKinds.js.map +1 -1
  511. package/lib/feature-libraries/default-schema/index.d.ts +2 -1
  512. package/lib/feature-libraries/default-schema/index.d.ts.map +1 -1
  513. package/lib/feature-libraries/default-schema/index.js +2 -1
  514. package/lib/feature-libraries/default-schema/index.js.map +1 -1
  515. package/lib/feature-libraries/default-schema/locationBasedEditBuilder.d.ts +40 -0
  516. package/lib/feature-libraries/default-schema/locationBasedEditBuilder.d.ts.map +1 -0
  517. package/lib/feature-libraries/default-schema/locationBasedEditBuilder.js +149 -0
  518. package/lib/feature-libraries/default-schema/locationBasedEditBuilder.js.map +1 -0
  519. package/lib/feature-libraries/default-schema/mappedEditBuilder.d.ts +7 -6
  520. package/lib/feature-libraries/default-schema/mappedEditBuilder.d.ts.map +1 -1
  521. package/lib/feature-libraries/default-schema/mappedEditBuilder.js +15 -0
  522. package/lib/feature-libraries/default-schema/mappedEditBuilder.js.map +1 -1
  523. package/lib/feature-libraries/deltaUtils.d.ts +1 -0
  524. package/lib/feature-libraries/deltaUtils.d.ts.map +1 -1
  525. package/lib/feature-libraries/deltaUtils.js +5 -1
  526. package/lib/feature-libraries/deltaUtils.js.map +1 -1
  527. package/lib/feature-libraries/flex-tree/context.d.ts +9 -0
  528. package/lib/feature-libraries/flex-tree/context.d.ts.map +1 -1
  529. package/lib/feature-libraries/flex-tree/context.js +6 -0
  530. package/lib/feature-libraries/flex-tree/context.js.map +1 -1
  531. package/lib/feature-libraries/flex-tree/flexTreeTypes.d.ts +6 -6
  532. package/lib/feature-libraries/flex-tree/flexTreeTypes.d.ts.map +1 -1
  533. package/lib/feature-libraries/flex-tree/flexTreeTypes.js.map +1 -1
  534. package/lib/feature-libraries/flex-tree/lazyField.d.ts +8 -7
  535. package/lib/feature-libraries/flex-tree/lazyField.d.ts.map +1 -1
  536. package/lib/feature-libraries/flex-tree/lazyField.js +40 -9
  537. package/lib/feature-libraries/flex-tree/lazyField.js.map +1 -1
  538. package/lib/feature-libraries/forest-summary/codec.d.ts.map +1 -1
  539. package/lib/feature-libraries/forest-summary/codec.js +8 -2
  540. package/lib/feature-libraries/forest-summary/codec.js.map +1 -1
  541. package/lib/feature-libraries/forest-summary/formatCommon.d.ts +3 -3
  542. package/lib/feature-libraries/forest-summary/formatCommon.d.ts.map +1 -1
  543. package/lib/feature-libraries/forest-summary/formatCommon.js.map +1 -1
  544. package/lib/feature-libraries/forest-summary/formatV1.d.ts +2 -3
  545. package/lib/feature-libraries/forest-summary/formatV1.d.ts.map +1 -1
  546. package/lib/feature-libraries/forest-summary/formatV1.js +1 -2
  547. package/lib/feature-libraries/forest-summary/formatV1.js.map +1 -1
  548. package/lib/feature-libraries/forest-summary/formatV2.d.ts +2 -3
  549. package/lib/feature-libraries/forest-summary/formatV2.d.ts.map +1 -1
  550. package/lib/feature-libraries/forest-summary/formatV2.js +1 -2
  551. package/lib/feature-libraries/forest-summary/formatV2.js.map +1 -1
  552. package/lib/feature-libraries/index.d.ts +3 -3
  553. package/lib/feature-libraries/index.d.ts.map +1 -1
  554. package/lib/feature-libraries/index.js +3 -3
  555. package/lib/feature-libraries/index.js.map +1 -1
  556. package/lib/feature-libraries/mitigatedChangeFamily.d.ts.map +1 -1
  557. package/lib/feature-libraries/mitigatedChangeFamily.js +2 -2
  558. package/lib/feature-libraries/mitigatedChangeFamily.js.map +1 -1
  559. package/lib/feature-libraries/modular-schema/crossFieldQueries.d.ts +100 -24
  560. package/lib/feature-libraries/modular-schema/crossFieldQueries.d.ts.map +1 -1
  561. package/lib/feature-libraries/modular-schema/crossFieldQueries.js +7 -10
  562. package/lib/feature-libraries/modular-schema/crossFieldQueries.js.map +1 -1
  563. package/lib/feature-libraries/modular-schema/fieldChangeHandler.d.ts +85 -51
  564. package/lib/feature-libraries/modular-schema/fieldChangeHandler.d.ts.map +1 -1
  565. package/lib/feature-libraries/modular-schema/fieldChangeHandler.js.map +1 -1
  566. package/lib/feature-libraries/modular-schema/genericFieldKind.d.ts.map +1 -1
  567. package/lib/feature-libraries/modular-schema/genericFieldKind.js +4 -9
  568. package/lib/feature-libraries/modular-schema/genericFieldKind.js.map +1 -1
  569. package/lib/feature-libraries/modular-schema/index.d.ts +3 -3
  570. package/lib/feature-libraries/modular-schema/index.d.ts.map +1 -1
  571. package/lib/feature-libraries/modular-schema/index.js +1 -1
  572. package/lib/feature-libraries/modular-schema/index.js.map +1 -1
  573. package/lib/feature-libraries/modular-schema/modularChangeCodecV1.d.ts +20 -24
  574. package/lib/feature-libraries/modular-schema/modularChangeCodecV1.d.ts.map +1 -1
  575. package/lib/feature-libraries/modular-schema/modularChangeCodecV1.js +268 -145
  576. package/lib/feature-libraries/modular-schema/modularChangeCodecV1.js.map +1 -1
  577. package/lib/feature-libraries/modular-schema/modularChangeCodecV2.d.ts.map +1 -1
  578. package/lib/feature-libraries/modular-schema/modularChangeCodecV2.js +1 -1
  579. package/lib/feature-libraries/modular-schema/modularChangeCodecV2.js.map +1 -1
  580. package/lib/feature-libraries/modular-schema/modularChangeCodecV3.d.ts +15 -0
  581. package/lib/feature-libraries/modular-schema/modularChangeCodecV3.d.ts.map +1 -0
  582. package/lib/feature-libraries/modular-schema/modularChangeCodecV3.js +292 -0
  583. package/lib/feature-libraries/modular-schema/modularChangeCodecV3.js.map +1 -0
  584. package/lib/feature-libraries/modular-schema/modularChangeCodecs.d.ts +1 -0
  585. package/lib/feature-libraries/modular-schema/modularChangeCodecs.d.ts.map +1 -1
  586. package/lib/feature-libraries/modular-schema/modularChangeCodecs.js +8 -0
  587. package/lib/feature-libraries/modular-schema/modularChangeCodecs.js.map +1 -1
  588. package/lib/feature-libraries/modular-schema/modularChangeFamily.d.ts +56 -22
  589. package/lib/feature-libraries/modular-schema/modularChangeFamily.d.ts.map +1 -1
  590. package/lib/feature-libraries/modular-schema/modularChangeFamily.js +1387 -468
  591. package/lib/feature-libraries/modular-schema/modularChangeFamily.js.map +1 -1
  592. package/lib/feature-libraries/modular-schema/modularChangeFormatV1.d.ts.map +1 -1
  593. package/lib/feature-libraries/modular-schema/modularChangeFormatV1.js.map +1 -1
  594. package/lib/feature-libraries/modular-schema/modularChangeFormatV2.d.ts +1 -2
  595. package/lib/feature-libraries/modular-schema/modularChangeFormatV2.d.ts.map +1 -1
  596. package/lib/feature-libraries/modular-schema/modularChangeFormatV2.js +1 -1
  597. package/lib/feature-libraries/modular-schema/modularChangeFormatV2.js.map +1 -1
  598. package/lib/feature-libraries/modular-schema/modularChangeFormatV3.d.ts +74 -0
  599. package/lib/feature-libraries/modular-schema/modularChangeFormatV3.d.ts.map +1 -0
  600. package/lib/feature-libraries/modular-schema/modularChangeFormatV3.js +32 -0
  601. package/lib/feature-libraries/modular-schema/modularChangeFormatV3.js.map +1 -0
  602. package/lib/feature-libraries/modular-schema/modularChangeTypes.d.ts +49 -10
  603. package/lib/feature-libraries/modular-schema/modularChangeTypes.d.ts.map +1 -1
  604. package/lib/feature-libraries/modular-schema/modularChangeTypes.js +1 -1
  605. package/lib/feature-libraries/modular-schema/modularChangeTypes.js.map +1 -1
  606. package/lib/feature-libraries/optional-field/optionalField.d.ts +13 -32
  607. package/lib/feature-libraries/optional-field/optionalField.d.ts.map +1 -1
  608. package/lib/feature-libraries/optional-field/optionalField.js +254 -442
  609. package/lib/feature-libraries/optional-field/optionalField.js.map +1 -1
  610. package/lib/feature-libraries/optional-field/optionalFieldChangeFormatV3.d.ts +23 -0
  611. package/lib/feature-libraries/optional-field/optionalFieldChangeFormatV3.d.ts.map +1 -0
  612. package/lib/feature-libraries/optional-field/optionalFieldChangeFormatV3.js +27 -0
  613. package/lib/feature-libraries/optional-field/optionalFieldChangeFormatV3.js.map +1 -0
  614. package/lib/feature-libraries/optional-field/optionalFieldChangeTypes.d.ts +31 -31
  615. package/lib/feature-libraries/optional-field/optionalFieldChangeTypes.d.ts.map +1 -1
  616. package/lib/feature-libraries/optional-field/optionalFieldChangeTypes.js.map +1 -1
  617. package/lib/feature-libraries/optional-field/optionalFieldCodecV2.d.ts +1 -1
  618. package/lib/feature-libraries/optional-field/optionalFieldCodecV2.d.ts.map +1 -1
  619. package/lib/feature-libraries/optional-field/optionalFieldCodecV2.js +55 -26
  620. package/lib/feature-libraries/optional-field/optionalFieldCodecV2.js.map +1 -1
  621. package/lib/feature-libraries/optional-field/optionalFieldCodecV3.d.ts +12 -0
  622. package/lib/feature-libraries/optional-field/optionalFieldCodecV3.d.ts.map +1 -0
  623. package/lib/feature-libraries/optional-field/optionalFieldCodecV3.js +53 -0
  624. package/lib/feature-libraries/optional-field/optionalFieldCodecV3.js.map +1 -0
  625. package/lib/feature-libraries/optional-field/optionalFieldCodecs.d.ts.map +1 -1
  626. package/lib/feature-libraries/optional-field/optionalFieldCodecs.js +5 -1
  627. package/lib/feature-libraries/optional-field/optionalFieldCodecs.js.map +1 -1
  628. package/lib/feature-libraries/optional-field/requiredField.d.ts +3 -2
  629. package/lib/feature-libraries/optional-field/requiredField.d.ts.map +1 -1
  630. package/lib/feature-libraries/optional-field/requiredField.js +5 -1
  631. package/lib/feature-libraries/optional-field/requiredField.js.map +1 -1
  632. package/lib/feature-libraries/schema-index/codec.d.ts.map +1 -1
  633. package/lib/feature-libraries/schema-index/codec.js +6 -4
  634. package/lib/feature-libraries/schema-index/codec.js.map +1 -1
  635. package/lib/feature-libraries/sequence-field/compose.d.ts +6 -7
  636. package/lib/feature-libraries/sequence-field/compose.d.ts.map +1 -1
  637. package/lib/feature-libraries/sequence-field/compose.js +83 -261
  638. package/lib/feature-libraries/sequence-field/compose.js.map +1 -1
  639. package/lib/feature-libraries/sequence-field/helperTypes.d.ts +14 -10
  640. package/lib/feature-libraries/sequence-field/helperTypes.d.ts.map +1 -1
  641. package/lib/feature-libraries/sequence-field/helperTypes.js.map +1 -1
  642. package/lib/feature-libraries/sequence-field/invert.d.ts +3 -3
  643. package/lib/feature-libraries/sequence-field/invert.d.ts.map +1 -1
  644. package/lib/feature-libraries/sequence-field/invert.js +67 -169
  645. package/lib/feature-libraries/sequence-field/invert.js.map +1 -1
  646. package/lib/feature-libraries/sequence-field/markQueue.d.ts +2 -2
  647. package/lib/feature-libraries/sequence-field/markQueue.d.ts.map +1 -1
  648. package/lib/feature-libraries/sequence-field/markQueue.js.map +1 -1
  649. package/lib/feature-libraries/sequence-field/moveEffectTable.d.ts +4 -56
  650. package/lib/feature-libraries/sequence-field/moveEffectTable.d.ts.map +1 -1
  651. package/lib/feature-libraries/sequence-field/moveEffectTable.js +6 -84
  652. package/lib/feature-libraries/sequence-field/moveEffectTable.js.map +1 -1
  653. package/lib/feature-libraries/sequence-field/rebase.d.ts +3 -3
  654. package/lib/feature-libraries/sequence-field/rebase.d.ts.map +1 -1
  655. package/lib/feature-libraries/sequence-field/rebase.js +111 -118
  656. package/lib/feature-libraries/sequence-field/rebase.js.map +1 -1
  657. package/lib/feature-libraries/sequence-field/replaceRevisions.d.ts.map +1 -1
  658. package/lib/feature-libraries/sequence-field/replaceRevisions.js +19 -32
  659. package/lib/feature-libraries/sequence-field/replaceRevisions.js.map +1 -1
  660. package/lib/feature-libraries/sequence-field/sequenceFieldChangeHandler.d.ts.map +1 -1
  661. package/lib/feature-libraries/sequence-field/sequenceFieldChangeHandler.js +2 -3
  662. package/lib/feature-libraries/sequence-field/sequenceFieldChangeHandler.js.map +1 -1
  663. package/lib/feature-libraries/sequence-field/sequenceFieldCodecV2.d.ts +22 -4
  664. package/lib/feature-libraries/sequence-field/sequenceFieldCodecV2.d.ts.map +1 -1
  665. package/lib/feature-libraries/sequence-field/sequenceFieldCodecV2.js +379 -182
  666. package/lib/feature-libraries/sequence-field/sequenceFieldCodecV2.js.map +1 -1
  667. package/lib/feature-libraries/sequence-field/sequenceFieldCodecV3.d.ts.map +1 -1
  668. package/lib/feature-libraries/sequence-field/sequenceFieldCodecV3.js +21 -63
  669. package/lib/feature-libraries/sequence-field/sequenceFieldCodecV3.js.map +1 -1
  670. package/lib/feature-libraries/sequence-field/sequenceFieldEditor.d.ts +2 -2
  671. package/lib/feature-libraries/sequence-field/sequenceFieldEditor.d.ts.map +1 -1
  672. package/lib/feature-libraries/sequence-field/sequenceFieldEditor.js +13 -13
  673. package/lib/feature-libraries/sequence-field/sequenceFieldEditor.js.map +1 -1
  674. package/lib/feature-libraries/sequence-field/sequenceFieldToDelta.d.ts +3 -2
  675. package/lib/feature-libraries/sequence-field/sequenceFieldToDelta.d.ts.map +1 -1
  676. package/lib/feature-libraries/sequence-field/sequenceFieldToDelta.js +16 -111
  677. package/lib/feature-libraries/sequence-field/sequenceFieldToDelta.js.map +1 -1
  678. package/lib/feature-libraries/sequence-field/types.d.ts +37 -74
  679. package/lib/feature-libraries/sequence-field/types.d.ts.map +1 -1
  680. package/lib/feature-libraries/sequence-field/types.js.map +1 -1
  681. package/lib/feature-libraries/sequence-field/utils.d.ts +20 -25
  682. package/lib/feature-libraries/sequence-field/utils.d.ts.map +1 -1
  683. package/lib/feature-libraries/sequence-field/utils.js +155 -313
  684. package/lib/feature-libraries/sequence-field/utils.js.map +1 -1
  685. package/lib/index.d.ts +2 -2
  686. package/lib/index.d.ts.map +1 -1
  687. package/lib/index.js +2 -2
  688. package/lib/index.js.map +1 -1
  689. package/lib/legacy.d.ts +1 -0
  690. package/lib/packageVersion.d.ts +1 -1
  691. package/lib/packageVersion.d.ts.map +1 -1
  692. package/lib/packageVersion.js +1 -1
  693. package/lib/packageVersion.js.map +1 -1
  694. package/lib/shared-tree/independentView.d.ts.map +1 -1
  695. package/lib/shared-tree/independentView.js +1 -1
  696. package/lib/shared-tree/independentView.js.map +1 -1
  697. package/lib/shared-tree/index.d.ts +1 -1
  698. package/lib/shared-tree/index.d.ts.map +1 -1
  699. package/lib/shared-tree/index.js.map +1 -1
  700. package/lib/shared-tree/schematizeTree.d.ts +4 -4
  701. package/lib/shared-tree/schematizeTree.d.ts.map +1 -1
  702. package/lib/shared-tree/schematizeTree.js +3 -2
  703. package/lib/shared-tree/schematizeTree.js.map +1 -1
  704. package/lib/shared-tree/schematizingTreeView.d.ts +1 -5
  705. package/lib/shared-tree/schematizingTreeView.d.ts.map +1 -1
  706. package/lib/shared-tree/schematizingTreeView.js +24 -38
  707. package/lib/shared-tree/schematizingTreeView.js.map +1 -1
  708. package/lib/shared-tree/sharedTree.d.ts +9 -3
  709. package/lib/shared-tree/sharedTree.d.ts.map +1 -1
  710. package/lib/shared-tree/sharedTree.js +4 -1
  711. package/lib/shared-tree/sharedTree.js.map +1 -1
  712. package/lib/shared-tree/sharedTreeChangeCodecs.d.ts +1 -0
  713. package/lib/shared-tree/sharedTreeChangeCodecs.d.ts.map +1 -1
  714. package/lib/shared-tree/sharedTreeChangeCodecs.js +9 -1
  715. package/lib/shared-tree/sharedTreeChangeCodecs.js.map +1 -1
  716. package/lib/shared-tree/sharedTreeChangeFamily.d.ts +4 -4
  717. package/lib/shared-tree/sharedTreeChangeFamily.d.ts.map +1 -1
  718. package/lib/shared-tree/sharedTreeChangeFamily.js +3 -3
  719. package/lib/shared-tree/sharedTreeChangeFamily.js.map +1 -1
  720. package/lib/shared-tree/sharedTreeEditBuilder.d.ts +16 -6
  721. package/lib/shared-tree/sharedTreeEditBuilder.d.ts.map +1 -1
  722. package/lib/shared-tree/sharedTreeEditBuilder.js +12 -6
  723. package/lib/shared-tree/sharedTreeEditBuilder.js.map +1 -1
  724. package/lib/shared-tree/tree.d.ts +1 -1
  725. package/lib/shared-tree/tree.js.map +1 -1
  726. package/lib/shared-tree/treeAlpha.d.ts +1 -1
  727. package/lib/shared-tree/treeAlpha.js.map +1 -1
  728. package/lib/shared-tree/treeCheckout.d.ts +13 -11
  729. package/lib/shared-tree/treeCheckout.d.ts.map +1 -1
  730. package/lib/shared-tree/treeCheckout.js +61 -13
  731. package/lib/shared-tree/treeCheckout.js.map +1 -1
  732. package/lib/shared-tree-core/branch.d.ts +3 -2
  733. package/lib/shared-tree-core/branch.d.ts.map +1 -1
  734. package/lib/shared-tree-core/branch.js +4 -3
  735. package/lib/shared-tree-core/branch.js.map +1 -1
  736. package/lib/shared-tree-core/editManager.d.ts +2 -2
  737. package/lib/shared-tree-core/editManager.d.ts.map +1 -1
  738. package/lib/shared-tree-core/editManager.js +9 -9
  739. package/lib/shared-tree-core/editManager.js.map +1 -1
  740. package/lib/shared-tree-core/editManagerCodecs.d.ts +4 -0
  741. package/lib/shared-tree-core/editManagerCodecs.d.ts.map +1 -1
  742. package/lib/shared-tree-core/editManagerCodecs.js +8 -1
  743. package/lib/shared-tree-core/editManagerCodecs.js.map +1 -1
  744. package/lib/shared-tree-core/editManagerCodecsCommons.d.ts +3 -3
  745. package/lib/shared-tree-core/editManagerCodecsCommons.d.ts.map +1 -1
  746. package/lib/shared-tree-core/editManagerCodecsCommons.js +2 -2
  747. package/lib/shared-tree-core/editManagerCodecsCommons.js.map +1 -1
  748. package/lib/shared-tree-core/editManagerCodecsV1toV4.d.ts +2 -2
  749. package/lib/shared-tree-core/editManagerCodecsV1toV4.d.ts.map +1 -1
  750. package/lib/shared-tree-core/editManagerCodecsV1toV4.js +2 -2
  751. package/lib/shared-tree-core/editManagerCodecsV1toV4.js.map +1 -1
  752. package/lib/shared-tree-core/editManagerCodecsVSharedBranches.d.ts +2 -2
  753. package/lib/shared-tree-core/editManagerCodecsVSharedBranches.d.ts.map +1 -1
  754. package/lib/shared-tree-core/editManagerCodecsVSharedBranches.js +2 -2
  755. package/lib/shared-tree-core/editManagerCodecsVSharedBranches.js.map +1 -1
  756. package/lib/shared-tree-core/editManagerFormatCommons.d.ts +1 -0
  757. package/lib/shared-tree-core/editManagerFormatCommons.d.ts.map +1 -1
  758. package/lib/shared-tree-core/editManagerFormatCommons.js +6 -0
  759. package/lib/shared-tree-core/editManagerFormatCommons.js.map +1 -1
  760. package/lib/shared-tree-core/editManagerFormatV1toV4.d.ts +2 -2
  761. package/lib/shared-tree-core/editManagerFormatV1toV4.d.ts.map +1 -1
  762. package/lib/shared-tree-core/editManagerFormatV1toV4.js +1 -0
  763. package/lib/shared-tree-core/editManagerFormatV1toV4.js.map +1 -1
  764. package/lib/shared-tree-core/index.d.ts +2 -2
  765. package/lib/shared-tree-core/index.d.ts.map +1 -1
  766. package/lib/shared-tree-core/index.js +2 -2
  767. package/lib/shared-tree-core/index.js.map +1 -1
  768. package/lib/shared-tree-core/messageCodecV1ToV4.d.ts +1 -1
  769. package/lib/shared-tree-core/messageCodecV1ToV4.d.ts.map +1 -1
  770. package/lib/shared-tree-core/messageCodecV1ToV4.js.map +1 -1
  771. package/lib/shared-tree-core/messageCodecs.d.ts +4 -0
  772. package/lib/shared-tree-core/messageCodecs.d.ts.map +1 -1
  773. package/lib/shared-tree-core/messageCodecs.js +10 -3
  774. package/lib/shared-tree-core/messageCodecs.js.map +1 -1
  775. package/lib/shared-tree-core/messageFormat.d.ts +1 -0
  776. package/lib/shared-tree-core/messageFormat.d.ts.map +1 -1
  777. package/lib/shared-tree-core/messageFormat.js +6 -0
  778. package/lib/shared-tree-core/messageFormat.js.map +1 -1
  779. package/lib/shared-tree-core/messageFormatV1ToV4.d.ts +2 -2
  780. package/lib/shared-tree-core/messageFormatV1ToV4.d.ts.map +1 -1
  781. package/lib/shared-tree-core/messageFormatV1ToV4.js +1 -0
  782. package/lib/shared-tree-core/messageFormatV1ToV4.js.map +1 -1
  783. package/lib/shared-tree-core/sharedTreeCore.d.ts +1 -0
  784. package/lib/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
  785. package/lib/shared-tree-core/sharedTreeCore.js +1 -1
  786. package/lib/shared-tree-core/sharedTreeCore.js.map +1 -1
  787. package/lib/simple-tree/api/index.d.ts +1 -1
  788. package/lib/simple-tree/api/index.d.ts.map +1 -1
  789. package/lib/simple-tree/api/index.js +1 -1
  790. package/lib/simple-tree/api/index.js.map +1 -1
  791. package/lib/simple-tree/api/snapshotCompatibilityChecker.d.ts +148 -29
  792. package/lib/simple-tree/api/snapshotCompatibilityChecker.d.ts.map +1 -1
  793. package/lib/simple-tree/api/snapshotCompatibilityChecker.js +179 -98
  794. package/lib/simple-tree/api/snapshotCompatibilityChecker.js.map +1 -1
  795. package/lib/simple-tree/api/tree.d.ts +1 -1
  796. package/lib/simple-tree/api/tree.js.map +1 -1
  797. package/lib/simple-tree/api/treeBeta.d.ts +1 -1
  798. package/lib/simple-tree/api/treeBeta.js.map +1 -1
  799. package/lib/simple-tree/core/allowedTypes.d.ts +1 -1
  800. package/lib/simple-tree/core/allowedTypes.js.map +1 -1
  801. package/lib/simple-tree/core/unhydratedFlexTree.d.ts +17 -12
  802. package/lib/simple-tree/core/unhydratedFlexTree.d.ts.map +1 -1
  803. package/lib/simple-tree/core/unhydratedFlexTree.js +87 -8
  804. package/lib/simple-tree/core/unhydratedFlexTree.js.map +1 -1
  805. package/lib/simple-tree/fieldSchema.d.ts +4 -4
  806. package/lib/simple-tree/fieldSchema.d.ts.map +1 -1
  807. package/lib/simple-tree/fieldSchema.js.map +1 -1
  808. package/lib/simple-tree/index.d.ts +3 -3
  809. package/lib/simple-tree/index.d.ts.map +1 -1
  810. package/lib/simple-tree/index.js +2 -2
  811. package/lib/simple-tree/index.js.map +1 -1
  812. package/lib/simple-tree/node-kinds/array/arrayNode.d.ts.map +1 -1
  813. package/lib/simple-tree/node-kinds/array/arrayNode.js +11 -18
  814. package/lib/simple-tree/node-kinds/array/arrayNode.js.map +1 -1
  815. package/lib/simple-tree/node-kinds/common.d.ts.map +1 -1
  816. package/lib/simple-tree/node-kinds/common.js +2 -2
  817. package/lib/simple-tree/node-kinds/common.js.map +1 -1
  818. package/lib/simple-tree/node-kinds/map/mapNode.js +2 -2
  819. package/lib/simple-tree/node-kinds/map/mapNode.js.map +1 -1
  820. package/lib/simple-tree/node-kinds/object/objectNode.d.ts.map +1 -1
  821. package/lib/simple-tree/node-kinds/object/objectNode.js +20 -20
  822. package/lib/simple-tree/node-kinds/object/objectNode.js.map +1 -1
  823. package/lib/simple-tree/node-kinds/record/recordNode.d.ts.map +1 -1
  824. package/lib/simple-tree/node-kinds/record/recordNode.js +4 -2
  825. package/lib/simple-tree/node-kinds/record/recordNode.js.map +1 -1
  826. package/lib/simple-tree/prepareForInsertion.d.ts +54 -47
  827. package/lib/simple-tree/prepareForInsertion.d.ts.map +1 -1
  828. package/lib/simple-tree/prepareForInsertion.js +184 -125
  829. package/lib/simple-tree/prepareForInsertion.js.map +1 -1
  830. package/lib/simple-tree/unhydratedFlexTreeFromInsertable.d.ts +8 -3
  831. package/lib/simple-tree/unhydratedFlexTreeFromInsertable.d.ts.map +1 -1
  832. package/lib/simple-tree/unhydratedFlexTreeFromInsertable.js +56 -17
  833. package/lib/simple-tree/unhydratedFlexTreeFromInsertable.js.map +1 -1
  834. package/lib/text/textDomainFormatted.d.ts +3 -3
  835. package/lib/text/textDomainFormatted.d.ts.map +1 -1
  836. package/lib/text/textDomainFormatted.js +30 -14
  837. package/lib/text/textDomainFormatted.js.map +1 -1
  838. package/lib/treeFactory.d.ts.map +1 -1
  839. package/lib/treeFactory.js +13 -3
  840. package/lib/treeFactory.js.map +1 -1
  841. package/lib/util/bTreeUtils.d.ts.map +1 -1
  842. package/lib/util/bTreeUtils.js +6 -6
  843. package/lib/util/bTreeUtils.js.map +1 -1
  844. package/lib/util/index.d.ts +1 -1
  845. package/lib/util/index.d.ts.map +1 -1
  846. package/lib/util/index.js +1 -1
  847. package/lib/util/index.js.map +1 -1
  848. package/lib/util/rangeMap.d.ts +23 -11
  849. package/lib/util/rangeMap.d.ts.map +1 -1
  850. package/lib/util/rangeMap.js +40 -9
  851. package/lib/util/rangeMap.js.map +1 -1
  852. package/package.json +23 -23
  853. package/src/codec/codec.ts +10 -112
  854. package/src/codec/index.ts +0 -3
  855. package/src/codec/versioned/codec.ts +119 -83
  856. package/src/core/change-family/changeFamily.ts +5 -0
  857. package/src/core/change-family/index.ts +1 -0
  858. package/src/core/index.ts +4 -1
  859. package/src/core/rebase/changeRebaser.ts +6 -1
  860. package/src/core/rebase/index.ts +1 -0
  861. package/src/core/rebase/types.ts +4 -0
  862. package/src/core/rebase/utils.ts +31 -7
  863. package/src/core/tree/delta.ts +6 -0
  864. package/src/core/tree/detachedFieldIndex.ts +29 -1
  865. package/src/core/tree/detachedFieldIndexCodecs.ts +6 -4
  866. package/src/core/tree/detachedFieldIndexTypes.ts +5 -0
  867. package/src/core/tree/index.ts +13 -12
  868. package/src/core/tree/pathTree.ts +16 -4
  869. package/src/core/tree/visitDelta.ts +31 -11
  870. package/src/{extensibleSchemaUnion.ts → extensibleUnionNode.ts} +61 -19
  871. package/src/feature-libraries/changeAtomIdBTree.ts +28 -3
  872. package/src/feature-libraries/chunked-forest/codec/codecs.ts +5 -11
  873. package/src/feature-libraries/default-schema/defaultEditBuilder.ts +369 -127
  874. package/src/feature-libraries/default-schema/defaultFieldKinds.ts +13 -4
  875. package/src/feature-libraries/default-schema/index.ts +16 -5
  876. package/src/feature-libraries/default-schema/locationBasedEditBuilder.ts +231 -0
  877. package/src/feature-libraries/default-schema/mappedEditBuilder.ts +35 -9
  878. package/src/feature-libraries/deltaUtils.ts +6 -1
  879. package/src/feature-libraries/flex-tree/context.ts +17 -0
  880. package/src/feature-libraries/flex-tree/flexTreeTypes.ts +7 -8
  881. package/src/feature-libraries/flex-tree/lazyField.ts +65 -24
  882. package/src/feature-libraries/forest-summary/codec.ts +8 -7
  883. package/src/feature-libraries/forest-summary/formatCommon.ts +5 -3
  884. package/src/feature-libraries/forest-summary/formatV1.ts +1 -3
  885. package/src/feature-libraries/forest-summary/formatV2.ts +1 -3
  886. package/src/feature-libraries/index.ts +22 -9
  887. package/src/feature-libraries/mitigatedChangeFamily.ts +3 -1
  888. package/src/feature-libraries/modular-schema/crossFieldQueries.ts +144 -47
  889. package/src/feature-libraries/modular-schema/fieldChangeHandler.ts +113 -58
  890. package/src/feature-libraries/modular-schema/genericFieldKind.ts +7 -18
  891. package/src/feature-libraries/modular-schema/index.ts +16 -16
  892. package/src/feature-libraries/modular-schema/modularChangeCodecV1.ts +626 -352
  893. package/src/feature-libraries/modular-schema/modularChangeCodecV2.ts +1 -0
  894. package/src/feature-libraries/modular-schema/modularChangeCodecV3.ts +649 -0
  895. package/src/feature-libraries/modular-schema/modularChangeCodecs.ts +14 -0
  896. package/src/feature-libraries/modular-schema/modularChangeFamily.ts +2694 -748
  897. package/src/feature-libraries/modular-schema/modularChangeFormatV1.ts +1 -0
  898. package/src/feature-libraries/modular-schema/modularChangeFormatV2.ts +1 -1
  899. package/src/feature-libraries/modular-schema/modularChangeFormatV3.ts +67 -0
  900. package/src/feature-libraries/modular-schema/modularChangeTypes.ts +62 -10
  901. package/src/feature-libraries/optional-field/optionalField.ts +359 -568
  902. package/src/feature-libraries/optional-field/optionalFieldChangeFormatV3.ts +45 -0
  903. package/src/feature-libraries/optional-field/optionalFieldChangeTypes.ts +31 -35
  904. package/src/feature-libraries/optional-field/optionalFieldCodecV2.ts +89 -35
  905. package/src/feature-libraries/optional-field/optionalFieldCodecV3.ts +94 -0
  906. package/src/feature-libraries/optional-field/optionalFieldCodecs.ts +5 -1
  907. package/src/feature-libraries/optional-field/requiredField.ts +15 -2
  908. package/src/feature-libraries/schema-index/codec.ts +6 -4
  909. package/src/feature-libraries/sequence-field/compose.ts +137 -522
  910. package/src/feature-libraries/sequence-field/helperTypes.ts +34 -19
  911. package/src/feature-libraries/sequence-field/invert.ts +102 -228
  912. package/src/feature-libraries/sequence-field/markQueue.ts +2 -2
  913. package/src/feature-libraries/sequence-field/moveEffectTable.ts +8 -195
  914. package/src/feature-libraries/sequence-field/rebase.ts +171 -207
  915. package/src/feature-libraries/sequence-field/replaceRevisions.ts +26 -52
  916. package/src/feature-libraries/sequence-field/sequenceFieldChangeHandler.ts +8 -3
  917. package/src/feature-libraries/sequence-field/sequenceFieldCodecV2.ts +677 -229
  918. package/src/feature-libraries/sequence-field/sequenceFieldCodecV3.ts +56 -70
  919. package/src/feature-libraries/sequence-field/sequenceFieldEditor.ts +28 -30
  920. package/src/feature-libraries/sequence-field/sequenceFieldToDelta.ts +21 -131
  921. package/src/feature-libraries/sequence-field/types.ts +40 -79
  922. package/src/feature-libraries/sequence-field/utils.ts +211 -370
  923. package/src/index.ts +3 -3
  924. package/src/packageVersion.ts +1 -1
  925. package/src/shared-tree/independentView.ts +12 -6
  926. package/src/shared-tree/index.ts +3 -2
  927. package/src/shared-tree/schematizeTree.ts +21 -8
  928. package/src/shared-tree/schematizingTreeView.ts +38 -68
  929. package/src/shared-tree/sharedTree.ts +30 -15
  930. package/src/shared-tree/sharedTreeChangeCodecs.ts +10 -2
  931. package/src/shared-tree/sharedTreeChangeFamily.ts +7 -4
  932. package/src/shared-tree/sharedTreeEditBuilder.ts +43 -8
  933. package/src/shared-tree/tree.ts +1 -1
  934. package/src/shared-tree/treeAlpha.ts +1 -1
  935. package/src/shared-tree/treeCheckout.ts +95 -21
  936. package/src/shared-tree-core/branch.ts +8 -2
  937. package/src/shared-tree-core/editManager.ts +16 -2
  938. package/src/shared-tree-core/editManagerCodecs.ts +11 -1
  939. package/src/shared-tree-core/editManagerCodecsCommons.ts +7 -7
  940. package/src/shared-tree-core/editManagerCodecsV1toV4.ts +3 -10
  941. package/src/shared-tree-core/editManagerCodecsVSharedBranches.ts +3 -10
  942. package/src/shared-tree-core/editManagerFormatCommons.ts +6 -0
  943. package/src/shared-tree-core/editManagerFormatV1toV4.ts +3 -1
  944. package/src/shared-tree-core/index.ts +2 -0
  945. package/src/shared-tree-core/messageCodecV1ToV4.ts +2 -1
  946. package/src/shared-tree-core/messageCodecs.ts +13 -7
  947. package/src/shared-tree-core/messageFormat.ts +6 -0
  948. package/src/shared-tree-core/messageFormatV1ToV4.ts +3 -1
  949. package/src/shared-tree-core/sharedTreeCore.ts +4 -1
  950. package/src/simple-tree/api/index.ts +2 -2
  951. package/src/simple-tree/api/snapshotCompatibilityChecker.ts +344 -142
  952. package/src/simple-tree/api/tree.ts +1 -1
  953. package/src/simple-tree/api/treeBeta.ts +1 -1
  954. package/src/simple-tree/core/allowedTypes.ts +1 -1
  955. package/src/simple-tree/core/unhydratedFlexTree.ts +124 -35
  956. package/src/simple-tree/fieldSchema.ts +6 -4
  957. package/src/simple-tree/index.ts +4 -3
  958. package/src/simple-tree/node-kinds/array/arrayNode.ts +20 -24
  959. package/src/simple-tree/node-kinds/common.ts +2 -5
  960. package/src/simple-tree/node-kinds/map/mapNode.ts +4 -4
  961. package/src/simple-tree/node-kinds/object/objectNode.ts +26 -26
  962. package/src/simple-tree/node-kinds/record/recordNode.ts +10 -9
  963. package/src/simple-tree/prepareForInsertion.ts +342 -200
  964. package/src/simple-tree/unhydratedFlexTreeFromInsertable.ts +83 -22
  965. package/src/text/textDomainFormatted.ts +37 -17
  966. package/src/treeFactory.ts +16 -4
  967. package/src/util/bTreeUtils.ts +10 -6
  968. package/src/util/index.ts +3 -0
  969. package/src/util/rangeMap.ts +67 -22
  970. package/api-extractor-lint.json +0 -4
  971. package/dist/extensibleSchemaUnion.d.ts +0 -72
  972. package/dist/extensibleSchemaUnion.d.ts.map +0 -1
  973. package/dist/extensibleSchemaUnion.js.map +0 -1
  974. package/dist/feature-libraries/sequence-field/relevantRemovedRoots.d.ts +0 -9
  975. package/dist/feature-libraries/sequence-field/relevantRemovedRoots.d.ts.map +0 -1
  976. package/dist/feature-libraries/sequence-field/relevantRemovedRoots.js +0 -50
  977. package/dist/feature-libraries/sequence-field/relevantRemovedRoots.js.map +0 -1
  978. package/docs/main/sequence-field/move-composition.md +0 -46
  979. package/lib/extensibleSchemaUnion.d.ts +0 -72
  980. package/lib/extensibleSchemaUnion.d.ts.map +0 -1
  981. package/lib/extensibleSchemaUnion.js.map +0 -1
  982. package/lib/feature-libraries/sequence-field/relevantRemovedRoots.d.ts +0 -9
  983. package/lib/feature-libraries/sequence-field/relevantRemovedRoots.d.ts.map +0 -1
  984. package/lib/feature-libraries/sequence-field/relevantRemovedRoots.js +0 -46
  985. package/lib/feature-libraries/sequence-field/relevantRemovedRoots.js.map +0 -1
  986. package/src/feature-libraries/sequence-field/relevantRemovedRoots.ts +0 -57
@@ -16,7 +16,7 @@ import { getStoredKey, getExplicitStoredKey, FieldSchemaAlpha, normalizeFieldSch
16
16
  import { tryGetTreeNodeForField } from "../../getTreeNodeForField.js";
17
17
  import { prepareForInsertion } from "../../prepareForInsertion.js";
18
18
  import { convertFieldKind } from "../../toStoredSchema.js";
19
- import { unhydratedFlexTreeFromInsertable, unhydratedFlexTreeFromInsertableNode, } from "../../unhydratedFlexTreeFromInsertable.js";
19
+ import { unhydratedFlexTreeFromInsertable, flexTreeFromInsertableNode, } from "../../unhydratedFlexTreeFromInsertable.js";
20
20
  /**
21
21
  * Caches the mappings from property keys to stored keys for the provided object field schemas in {@link simpleKeyToFlexKeyCache}.
22
22
  */
@@ -126,23 +126,25 @@ function createProxyHandler(schema, allowAdditionalProperties) {
126
126
  return handler;
127
127
  }
128
128
  export function setField(field, simpleFieldSchema, value, destinationSchema) {
129
- const mapTree = prepareForInsertion(value, simpleFieldSchema, field.context, destinationSchema);
130
- switch (field.schema) {
131
- case FieldKinds.required.identifier: {
132
- assert(mapTree !== undefined, 0xa04 /* Cannot set a required field to undefined */);
133
- const typedField = field;
134
- typedField.editor.set(mapTree);
135
- break;
136
- }
137
- case FieldKinds.optional.identifier: {
138
- const typedField = field;
139
- typedField.editor.set(mapTree, typedField.length === 0);
140
- break;
141
- }
142
- default: {
143
- fail(0xade /* invalid FieldKind */);
129
+ field.context.runInTransaction(() => {
130
+ const mapTree = prepareForInsertion(value, simpleFieldSchema, field.context, destinationSchema);
131
+ switch (field.schema) {
132
+ case FieldKinds.required.identifier: {
133
+ assert(mapTree !== undefined, 0xa04 /* Cannot set a required field to undefined */);
134
+ const typedField = field;
135
+ typedField.editor.attach(mapTree);
136
+ break;
137
+ }
138
+ case FieldKinds.optional.identifier: {
139
+ const typedField = field;
140
+ typedField.editor.attach(mapTree, typedField.length === 0);
141
+ break;
142
+ }
143
+ default: {
144
+ fail(0xade /* invalid FieldKind */);
145
+ }
144
146
  }
145
- }
147
+ });
146
148
  }
147
149
  /**
148
150
  * {@link FieldSchemaAlpha} including {@link SimpleObjectFieldSchema}.
@@ -332,9 +334,7 @@ function objectToFlexContent(data, schema) {
332
334
  children = isConstant(fieldProvider) ? fieldProvider() : fieldProvider;
333
335
  }
334
336
  else {
335
- children = [
336
- unhydratedFlexTreeFromInsertableNode(value, fieldInfo.schema.allowedTypeSet),
337
- ];
337
+ children = [flexTreeFromInsertableNode(value, fieldInfo.schema.allowedTypeSet)];
338
338
  }
339
339
  const kind = convertFieldKind.get(fieldInfo.schema.kind) ?? fail(0xbb2 /* Invalid field kind */);
340
340
  fields.set(fieldInfo.storedKey, createField(context, kind.identifier, fieldInfo.storedKey, children));
@@ -1 +1 @@
1
- {"version":3,"file":"objectNode.js","sourceRoot":"","sources":["../../../../src/simple-tree/node-kinds/object/objectNode.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,qCAAqC,CAAC;AACtF,OAAO,EAAE,aAAa,E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E,SAAuD,EACvD,KAAoC;IAEpC,MAAM,KAAK,GACV,IAAI,CAAC,IAAI,KAAK,OAAO;QACpB,CAAC,CAAC,IAAI,CAAC,IAAI;QACX,CAAC,CAAC,CAAC,aAAa,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,KAAK,CAAC,mBAAmB,CAAC,CAAC,CAAC;IACtE,MAAM,KAAK,GAAG,YAAY,CAAC,KAAK,CAAC,CAAC;IAClC,MAAM,YAAY,GAAG,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,UAAU,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC;IACnF,MAAM,CACL,YAAY,YAAY,sBAAsB,EAC9C,KAAK,CAAC,qCAAqC,CAC3C,CAAC;IAEF,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,CAAC,WAAW,CAAC,SAAS,CAAC,SAAS,CAAC,KAAK,SAAS,EAAE,CAAC;QACjF,OAAO;IACR,CAAC;IAED,QAAQ,CACP,KAAK,CAAC,QAAQ,CAAC,SAAS,CAAC,SAAS,CAAC,EACnC,SAAS,CAAC,MAAM,EAChB,KAAK,EACL,YAAY,CAAC,cAAc,CAAC,SAAS,CAAC,SAAS,CAAC,CAChD,CAAC;AACH,CAAC","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 { isFluidHandle } from \"@fluidframework/runtime-utils/internal\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\n\nimport {\n\tObjectNodeStoredSchema,\n\ttype FieldKey,\n\ttype TreeFieldStoredSchema,\n} from \"../../../core/index.js\";\nimport {\n\tFieldKinds,\n\tisTreeValue,\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\";\nimport { brand } from \"../../../util/index.js\";\nimport type { ObjectSchemaOptionsAlpha } from \"../../api/index.js\";\nimport {\n\tCompatibilityLevel,\n\ttype TreeNodeSchema,\n\tNodeKind,\n\ttype WithType,\n\t// eslint-disable-next-line import-x/no-deprecated\n\ttypeNameSymbol,\n\ttypeSchemaSymbol,\n\ttype InternalTreeNode,\n\ttype TreeNode,\n\ttype UnhydratedFlexTreeNode,\n\tgetInnerNode,\n\ttype NodeSchemaMetadata,\n\ttype ImplicitAllowedTypes,\n\tTreeNodeValid,\n\ttype MostDerivedData,\n\ttype TreeNodeSchemaInitializedData,\n\tprivateDataSymbol,\n\tcreateTreeNodeSchemaPrivateData,\n\ttype FlexContent,\n\ttype UnhydratedFlexTreeField,\n\tcreateField,\n\ttype TreeNodeSchemaCorePrivate,\n\ttype TreeNodeSchemaPrivateData,\n} from \"../../core/index.js\";\nimport {\n\tgetTreeNodeSchemaInitializedData,\n\tgetUnhydratedContext,\n} from \"../../createContext.js\";\nimport {\n\ttype ImplicitFieldSchema,\n\tgetStoredKey,\n\tgetExplicitStoredKey,\n\ttype TreeFieldFromImplicitField,\n\ttype InsertableTreeFieldFromImplicitField,\n\ttype FieldSchema,\n\tFieldSchemaAlpha,\n\tnormalizeFieldSchema,\n\tFieldKind,\n\ttype FieldProps,\n\ttype ContextualFieldProvider,\n\textractFieldProvider,\n\tisConstant,\n} from \"../../fieldSchema.js\";\nimport { tryGetTreeNodeForField } from \"../../getTreeNodeForField.js\";\nimport { prepareForInsertion } from \"../../prepareForInsertion.js\";\nimport type { SimpleObjectFieldSchema } from \"../../simpleSchema.js\";\nimport { convertFieldKind } from \"../../toStoredSchema.js\";\nimport {\n\tunhydratedFlexTreeFromInsertable,\n\tunhydratedFlexTreeFromInsertableNode,\n\ttype FactoryContent,\n\ttype FactoryContentObject,\n\ttype InsertableContent,\n} from \"../../unhydratedFlexTreeFromInsertable.js\";\n\nimport type {\n\tObjectNodeSchema,\n\tObjectNodeSchemaInternalData,\n\tObjectNodeSchemaPrivate,\n} from \"./objectNodeTypes.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/no-empty-object-type\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 * Field Assignment and Deletion\n * Assigning to a field updates the tree value as long as it is still valid based on the schema.\n * - For required fields, assigning `undefined` is invalid, and will throw.\n * - For optional fields, assigning `undefined` removes the field's contents, and marks it as empty (non-enumerable and value set to undefined).\n *\n * Example:\n * ```ts\n * const Foo = schemaFactory.object(\"Foo\", {bar: schemaFactory.optional(schemaFactory.number)});\n * const node = new Foo({bar: 1})\n *\n * // This clears the field, is non-enumerable, and value is undefined.\n * delete node.bar;\n *\n * // This is equivalent to the delete example.\n * node.bar = undefined\n * ```\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> =\n\tRestrictiveStringRecord<ImplicitFieldSchema> extends T\n\t\t? { arbitraryKey: \"arbitraryValue\" } extends T\n\t\t\t? // {} case\n\t\t\t\tRecord<string, never>\n\t\t\t: // RestrictiveStringRecord<ImplicitFieldSchema> case\n\t\t\t\tnever\n\t\t: FlattenKeys<\n\t\t\t\t{\n\t\t\t\t\treadonly [Property in keyof T]?: InsertableTreeFieldFromImplicitField<\n\t\t\t\t\t\tT[Property & string]\n\t\t\t\t\t>;\n\t\t\t\t} & {\n\t\t\t\t\t// Field does not have a known default, make it required:\n\t\t\t\t\treadonly [Property in keyof T as FieldHasDefault<T[Property & string]> extends false\n\t\t\t\t\t\t? Property\n\t\t\t\t\t\t: never]: InsertableTreeFieldFromImplicitField<T[Property & string]>;\n\t\t\t\t}\n\t\t\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 schema = normalizeFieldSchema(fieldSchema);\n\t\tconst storedKey = getStoredKey(propertyKey, schema);\n\t\tkeyMap.set(propertyKey, { storedKey, schema });\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: ObjectNodeSchemaPrivate,\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 = getInnerNode(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 tryGetTreeNodeForField(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 built 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-x/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\tapplyFieldChange(schema, { kind: \"proxy\", node: proxy }, fieldInfo, value);\n\t\t\treturn true;\n\t\t},\n\t\tdeleteProperty(target, propertyKey): boolean {\n\t\t\tconst fieldInfo = schema.flexKeyMap.get(propertyKey);\n\t\t\tif (fieldInfo === undefined) {\n\t\t\t\treturn allowAdditionalProperties ? Reflect.deleteProperty(target, propertyKey) : false;\n\t\t\t}\n\n\t\t\tapplyFieldChange(schema, { kind: \"target\", node: target }, fieldInfo, undefined);\n\t\t\treturn true;\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 = getInnerNode(proxy).tryGetField(fieldInfo.storedKey);\n\n\t\t\tconst p: PropertyDescriptor = {\n\t\t\t\tvalue: field === undefined ? undefined : tryGetTreeNodeForField(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\tdestinationSchema: TreeFieldStoredSchema,\n): void {\n\tconst mapTree = prepareForInsertion(\n\t\tvalue,\n\t\tsimpleFieldSchema,\n\t\tfield.context,\n\t\tdestinationSchema,\n\t);\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\t}\n\t}\n}\n\n/**\n * {@link FieldSchemaAlpha} including {@link SimpleObjectFieldSchema}.\n */\nexport class ObjectFieldSchema<\n\t\tKind extends FieldKind,\n\t\tTypes extends ImplicitAllowedTypes,\n\t\tTCustomMetadata = unknown,\n\t>\n\textends FieldSchemaAlpha<Kind, Types, TCustomMetadata>\n\timplements SimpleObjectFieldSchema\n{\n\tpublic readonly storedKey: string;\n\n\tpublic constructor(\n\t\tkind: Kind,\n\t\tallowedTypes: Types,\n\t\tprops: FieldProps<TCustomMetadata> & { readonly key: string },\n\t) {\n\t\tsuper(kind, allowedTypes, props);\n\t\tthis.storedKey = props.key;\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<ImplicitFieldSchema>,\n\tconst ImplicitlyConstructable extends boolean,\n\tconst TCustomMetadata = unknown,\n>(\n\tidentifier: TName,\n\tinfo: T,\n\timplicitlyConstructable: ImplicitlyConstructable,\n\tnodeOptions: ObjectSchemaOptionsAlpha<TCustomMetadata>,\n): ObjectNodeSchema<TName, T, ImplicitlyConstructable, TCustomMetadata> &\n\tObjectNodeSchemaInternalData &\n\tTreeNodeSchemaCorePrivate {\n\t// Field set can't be modified after this since derived data is stored in maps.\n\tObject.freeze(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, info);\n\n\t// Performance optimization: cache property key => stored key and schema.\n\tconst flexKeyMap: SimpleKeyMap = createFlexKeyMapping(info);\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 privateData: TreeNodeSchemaPrivateData | undefined;\n\n\tlet handler: ProxyHandler<object>;\n\tlet customizable: boolean;\n\n\tclass CustomObjectNode extends CustomObjectNodeBase<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(value.schema.kind, value.schema.allowedTypes, {\n\t\t\t\t\t...value.schema.props,\n\t\t\t\t\tkey: getStoredKey(key as string, value.schema),\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 =\n\t\t\tnodeOptions.allowUnknownOptionalFields ?? false;\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(): TreeNodeSchemaInitializedData {\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 ObjectNodeSchemaPrivate;\n\t\t\thandler = createProxyHandler(schema, customizable);\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 getTreeNodeSchemaInitializedData(schema, {\n\t\t\t\tshallowCompatibilityTest: (data: FactoryContent): CompatibilityLevel =>\n\t\t\t\t\tshallowCompatibilityTest(data, schema),\n\t\t\t\ttoFlexContent: (\n\t\t\t\t\tdata: FactoryContent,\n\t\t\t\t\tallowedTypes: ReadonlySet<TreeNodeSchema>,\n\t\t\t\t): FlexContent => objectToFlexContent(data, schema),\n\t\t\t});\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> =\n\t\t\tnodeOptions.metadata ?? {};\n\t\tpublic static readonly persistedMetadata: JsonCompatibleReadOnlyObject | undefined =\n\t\t\tnodeOptions.persistedMetadata;\n\n\t\t// eslint-disable-next-line import-x/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\n\t\tpublic static get [privateDataSymbol](): TreeNodeSchemaPrivateData {\n\t\t\treturn (privateData ??= createTreeNodeSchemaPrivateData(\n\t\t\t\tthis,\n\t\t\t\tArray.from(CustomObjectNode.fields.values(), (schema) => schema.allowedTypesFull),\n\t\t\t));\n\t\t}\n\t}\n\ttype Output = typeof CustomObjectNode &\n\t\t(new (\n\t\t\tinput: InsertableObjectFromSchemaRecord<T> | InternalTreeNode,\n\t\t) => TreeObjectNode<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 * {@link TreeNodeSchemaInitializedData.toFlexContent} for object nodes.\n *\n * @param data - The tree data to be transformed. Must be a Record-like object.\n * @param schema - The schema to comply with.\n */\nfunction objectToFlexContent(\n\tdata: FactoryContent,\n\tschema: TreeNodeSchema & ObjectNodeSchemaInternalData,\n): FlexContent {\n\tif (\n\t\ttypeof data !== \"object\" ||\n\t\tdata === null ||\n\t\tSymbol.iterator in data ||\n\t\tisFluidHandle(data)\n\t) {\n\t\t// eslint-disable-next-line @typescript-eslint/no-base-to-string\n\t\tthrow new UsageError(`Input data is incompatible with Object schema: ${data}`);\n\t}\n\n\tconst fields = new Map<FieldKey, UnhydratedFlexTreeField>();\n\tconst context = getUnhydratedContext(schema).flexContext;\n\n\tfor (const [key, fieldInfo] of schema.flexKeyMap) {\n\t\tconst value = getFieldProperty(data, key);\n\n\t\tlet children: UnhydratedFlexTreeNode[] | ContextualFieldProvider;\n\t\tif (value === undefined) {\n\t\t\tconst defaultProvider =\n\t\t\t\tfieldInfo.schema.props?.defaultProvider ??\n\t\t\t\tfail(0xbb1 /* missing field has no default provider */);\n\t\t\tconst fieldProvider = extractFieldProvider(defaultProvider);\n\t\t\tchildren = isConstant(fieldProvider) ? fieldProvider() : fieldProvider;\n\t\t} else {\n\t\t\tchildren = [\n\t\t\t\tunhydratedFlexTreeFromInsertableNode(value, fieldInfo.schema.allowedTypeSet),\n\t\t\t];\n\t\t}\n\n\t\tconst kind =\n\t\t\tconvertFieldKind.get(fieldInfo.schema.kind) ?? fail(0xbb2 /* Invalid field kind */);\n\t\tfields.set(\n\t\t\tfieldInfo.storedKey,\n\t\t\tcreateField(context, kind.identifier, fieldInfo.storedKey, children),\n\t\t);\n\t}\n\n\treturn [{ type: brand(schema.identifier) }, fields];\n}\n\n/**\n * {@link TreeNodeSchemaInitializedData.shallowCompatibilityTest} for Object nodes.\n */\nfunction shallowCompatibilityTest(\n\tdata: FactoryContent,\n\tschema: ObjectNodeSchema & ObjectNodeSchemaInternalData,\n): CompatibilityLevel {\n\tif (isTreeValue(data)) {\n\t\treturn CompatibilityLevel.None;\n\t}\n\n\tif (Symbol.iterator in data) {\n\t\treturn CompatibilityLevel.None;\n\t}\n\n\t// TODO: Improve type inference by making this logic more thorough. Handle at least:\n\t// * Types which are strict subsets of other types in the same polymorphic union\n\t// * Types which have the same keys but different types for those keys in the polymorphic union\n\t// * Types which have the same required fields but different optional fields and enough of those optional fields are populated to disambiguate\n\n\t// TODO#7441: Consider allowing data to be inserted which has keys that are extraneous/unknown to the schema (those keys are ignored)\n\n\t// If the schema has a required key which is not present in the input object, reject it.\n\tfor (const [fieldKey, fieldSchema] of schema.fields) {\n\t\tif (fieldSchema.requiresValue && getFieldProperty(data, fieldKey) === undefined) {\n\t\t\treturn CompatibilityLevel.None;\n\t\t}\n\t}\n\n\treturn CompatibilityLevel.Normal;\n}\n\n/**\n * Check {@link FactoryContentObject} for a property which could be store a field.\n *\n * @returns If the property exists, return its value. Otherwise, returns undefined.\n * @remarks\n * The currently policy is to only consider own properties.\n * See {@link InsertableObjectFromSchemaRecord} for where this policy is documented in the public API.\n *\n * Explicit undefined values are treated the same as missing properties to allow explicit use of undefined with defaulted identifiers.\n *\n * @privateRemarks\n * If we ever want to have an optional field which defaults to something other than undefined, this will need changes.\n * It would need to adjusting the handling of explicit undefined in contexts where undefined is allowed, and a default provider also exists.\n */\nfunction getFieldProperty(\n\tdata: FactoryContentObject,\n\tkey: string | symbol,\n): InsertableContent | undefined {\n\t// This policy only allows own properties.\n\tif (Object.hasOwnProperty.call(data, key)) {\n\t\treturn (data as Record<string, InsertableContent>)[key as string];\n\t}\n\treturn undefined;\n}\n\nfunction applyFieldChange(\n\tschema: ObjectNodeSchemaPrivate,\n\tfrom: { kind: \"proxy\"; node: TreeNode } | { kind: \"target\"; node: object },\n\tfieldInfo: { storedKey: FieldKey; schema: FieldSchema },\n\tvalue: InsertableContent | undefined,\n): void {\n\tconst proxy =\n\t\tfrom.kind === \"proxy\"\n\t\t\t? from.node\n\t\t\t: (targetToProxy.get(from.node) ?? fail(0xc95 /* missing proxy */));\n\tconst inner = getInnerNode(proxy);\n\tconst storedSchema = inner.context.schema.nodeSchema.get(brand(schema.identifier));\n\tassert(\n\t\tstoredSchema instanceof ObjectNodeStoredSchema,\n\t\t0xc96 /* Expected ObjectNodeStoredSchema */,\n\t);\n\n\tif (value === undefined && inner.tryGetField(fieldInfo.storedKey) === undefined) {\n\t\treturn;\n\t}\n\n\tsetField(\n\t\tinner.getBoxed(fieldInfo.storedKey),\n\t\tfieldInfo.schema,\n\t\tvalue,\n\t\tstoredSchema.getFieldSchema(fieldInfo.storedKey),\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,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,qCAAqC,CAAC;AACtF,OAAO,EAAE,aAAa,EAAE,MAAM,wCAAwC,CAAC;AACvE,OAAO,EAAE,UAAU,EAAE,MAAM,0CAA0C,CAAC;AAEtE,OAAO,EACN,sBAAsB,GAGtB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACN,UAAU,EACV,WAAW,GAKX,MAAM,qCAAqC,CAAC;AAM7C,OAAO,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAC;AAE/C,OAAO,EACN,kBAAkB,EAElB,QAAQ;AAER,kDAAkD;AAClD,cAAc,EACd,gBAAgB,EAIhB,YAAY,EAGZ,aAAa,EAGb,iBAAiB,EACjB,+BAA+B,EAG/B,WAAW,GAGX,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACN,gCAAgC,EAChC,oBAAoB,GACpB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAEN,YAAY,EACZ,oBAAoB,EAIpB,gBAAgB,EAChB,oBAAoB,EACpB,SAAS,EAGT,oBAAoB,EACpB,UAAU,GACV,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,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AK,CAAC,WAAW,CAAC,SAAS,CAAC,SAAS,CAAC,KAAK,SAAS,EAAE,CAAC;QACjF,OAAO;IACR,CAAC;IAED,QAAQ,CACP,KAAK,CAAC,QAAQ,CAAC,SAAS,CAAC,SAAS,CAAC,EACnC,SAAS,CAAC,MAAM,EAChB,KAAK,EACL,YAAY,CAAC,cAAc,CAAC,SAAS,CAAC,SAAS,CAAC,CAChD,CAAC;AACH,CAAC","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 { isFluidHandle } from \"@fluidframework/runtime-utils/internal\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\n\nimport {\n\tObjectNodeStoredSchema,\n\ttype FieldKey,\n\ttype TreeFieldStoredSchema,\n} from \"../../../core/index.js\";\nimport {\n\tFieldKinds,\n\tisTreeValue,\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\";\nimport { brand } from \"../../../util/index.js\";\nimport type { ObjectSchemaOptionsAlpha } from \"../../api/index.js\";\nimport {\n\tCompatibilityLevel,\n\ttype TreeNodeSchema,\n\tNodeKind,\n\ttype WithType,\n\t// eslint-disable-next-line import-x/no-deprecated\n\ttypeNameSymbol,\n\ttypeSchemaSymbol,\n\ttype InternalTreeNode,\n\ttype TreeNode,\n\ttype UnhydratedFlexTreeNode,\n\tgetInnerNode,\n\ttype NodeSchemaMetadata,\n\ttype ImplicitAllowedTypes,\n\tTreeNodeValid,\n\ttype MostDerivedData,\n\ttype TreeNodeSchemaInitializedData,\n\tprivateDataSymbol,\n\tcreateTreeNodeSchemaPrivateData,\n\ttype FlexContent,\n\ttype UnhydratedFlexTreeField,\n\tcreateField,\n\ttype TreeNodeSchemaCorePrivate,\n\ttype TreeNodeSchemaPrivateData,\n} from \"../../core/index.js\";\nimport {\n\tgetTreeNodeSchemaInitializedData,\n\tgetUnhydratedContext,\n} from \"../../createContext.js\";\nimport {\n\ttype ImplicitFieldSchema,\n\tgetStoredKey,\n\tgetExplicitStoredKey,\n\ttype TreeFieldFromImplicitField,\n\ttype InsertableTreeFieldFromImplicitField,\n\ttype FieldSchema,\n\tFieldSchemaAlpha,\n\tnormalizeFieldSchema,\n\tFieldKind,\n\ttype FieldProps,\n\ttype ContextualFieldProvider,\n\textractFieldProvider,\n\tisConstant,\n} from \"../../fieldSchema.js\";\nimport { tryGetTreeNodeForField } from \"../../getTreeNodeForField.js\";\nimport { prepareForInsertion } from \"../../prepareForInsertion.js\";\nimport type { SimpleObjectFieldSchema } from \"../../simpleSchema.js\";\nimport { convertFieldKind } from \"../../toStoredSchema.js\";\nimport {\n\tunhydratedFlexTreeFromInsertable,\n\tflexTreeFromInsertableNode,\n\ttype FactoryContent,\n\ttype FactoryContentObject,\n\ttype InsertableContent,\n} from \"../../unhydratedFlexTreeFromInsertable.js\";\n\nimport type {\n\tObjectNodeSchema,\n\tObjectNodeSchemaInternalData,\n\tObjectNodeSchemaPrivate,\n} from \"./objectNodeTypes.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/no-empty-object-type\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 * Field Assignment and Deletion\n * Assigning to a field updates the tree value as long as it is still valid based on the schema.\n * - For required fields, assigning `undefined` is invalid, and will throw.\n * - For optional fields, assigning `undefined` removes the field's contents, and marks it as empty (non-enumerable and value set to undefined).\n *\n * Example:\n * ```ts\n * const Foo = schemaFactory.object(\"Foo\", {bar: schemaFactory.optional(schemaFactory.number)});\n * const node = new Foo({bar: 1})\n *\n * // This clears the field, is non-enumerable, and value is undefined.\n * delete node.bar;\n *\n * // This is equivalent to the delete example.\n * node.bar = undefined\n * ```\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> =\n\tRestrictiveStringRecord<ImplicitFieldSchema> extends T\n\t\t? { arbitraryKey: \"arbitraryValue\" } extends T\n\t\t\t? // {} case\n\t\t\t\tRecord<string, never>\n\t\t\t: // RestrictiveStringRecord<ImplicitFieldSchema> case\n\t\t\t\tnever\n\t\t: FlattenKeys<\n\t\t\t\t{\n\t\t\t\t\treadonly [Property in keyof T]?: InsertableTreeFieldFromImplicitField<\n\t\t\t\t\t\tT[Property & string]\n\t\t\t\t\t>;\n\t\t\t\t} & {\n\t\t\t\t\t// Field does not have a known default, make it required:\n\t\t\t\t\treadonly [Property in keyof T as FieldHasDefault<T[Property & string]> extends false\n\t\t\t\t\t\t? Property\n\t\t\t\t\t\t: never]: InsertableTreeFieldFromImplicitField<T[Property & string]>;\n\t\t\t\t}\n\t\t\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 schema = normalizeFieldSchema(fieldSchema);\n\t\tconst storedKey = getStoredKey(propertyKey, schema);\n\t\tkeyMap.set(propertyKey, { storedKey, schema });\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: ObjectNodeSchemaPrivate,\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 = getInnerNode(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 tryGetTreeNodeForField(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 built 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-x/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\tapplyFieldChange(schema, { kind: \"proxy\", node: proxy }, fieldInfo, value);\n\t\t\treturn true;\n\t\t},\n\t\tdeleteProperty(target, propertyKey): boolean {\n\t\t\tconst fieldInfo = schema.flexKeyMap.get(propertyKey);\n\t\t\tif (fieldInfo === undefined) {\n\t\t\t\treturn allowAdditionalProperties ? Reflect.deleteProperty(target, propertyKey) : false;\n\t\t\t}\n\n\t\t\tapplyFieldChange(schema, { kind: \"target\", node: target }, fieldInfo, undefined);\n\t\t\treturn true;\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 = getInnerNode(proxy).tryGetField(fieldInfo.storedKey);\n\n\t\t\tconst p: PropertyDescriptor = {\n\t\t\t\tvalue: field === undefined ? undefined : tryGetTreeNodeForField(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\tdestinationSchema: TreeFieldStoredSchema,\n): void {\n\tfield.context.runInTransaction(() => {\n\t\tconst mapTree = prepareForInsertion(\n\t\t\tvalue,\n\t\t\tsimpleFieldSchema,\n\t\t\tfield.context,\n\t\t\tdestinationSchema,\n\t\t);\n\n\t\tswitch (field.schema) {\n\t\t\tcase FieldKinds.required.identifier: {\n\t\t\t\tassert(mapTree !== undefined, 0xa04 /* Cannot set a required field to undefined */);\n\t\t\t\tconst typedField = field as FlexTreeRequiredField;\n\t\t\t\ttypedField.editor.attach(mapTree);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase FieldKinds.optional.identifier: {\n\t\t\t\tconst typedField = field as FlexTreeOptionalField;\n\t\t\t\ttypedField.editor.attach(mapTree, typedField.length === 0);\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tdefault: {\n\t\t\t\tfail(0xade /* invalid FieldKind */);\n\t\t\t}\n\t\t}\n\t});\n}\n\n/**\n * {@link FieldSchemaAlpha} including {@link SimpleObjectFieldSchema}.\n */\nexport class ObjectFieldSchema<\n\t\tKind extends FieldKind,\n\t\tTypes extends ImplicitAllowedTypes,\n\t\tTCustomMetadata = unknown,\n\t>\n\textends FieldSchemaAlpha<Kind, Types, TCustomMetadata>\n\timplements SimpleObjectFieldSchema\n{\n\tpublic readonly storedKey: string;\n\n\tpublic constructor(\n\t\tkind: Kind,\n\t\tallowedTypes: Types,\n\t\tprops: FieldProps<TCustomMetadata> & { readonly key: string },\n\t) {\n\t\tsuper(kind, allowedTypes, props);\n\t\tthis.storedKey = props.key;\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<ImplicitFieldSchema>,\n\tconst ImplicitlyConstructable extends boolean,\n\tconst TCustomMetadata = unknown,\n>(\n\tidentifier: TName,\n\tinfo: T,\n\timplicitlyConstructable: ImplicitlyConstructable,\n\tnodeOptions: ObjectSchemaOptionsAlpha<TCustomMetadata>,\n): ObjectNodeSchema<TName, T, ImplicitlyConstructable, TCustomMetadata> &\n\tObjectNodeSchemaInternalData &\n\tTreeNodeSchemaCorePrivate {\n\t// Field set can't be modified after this since derived data is stored in maps.\n\tObject.freeze(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, info);\n\n\t// Performance optimization: cache property key => stored key and schema.\n\tconst flexKeyMap: SimpleKeyMap = createFlexKeyMapping(info);\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 privateData: TreeNodeSchemaPrivateData | undefined;\n\n\tlet handler: ProxyHandler<object>;\n\tlet customizable: boolean;\n\n\tclass CustomObjectNode extends CustomObjectNodeBase<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(value.schema.kind, value.schema.allowedTypes, {\n\t\t\t\t\t...value.schema.props,\n\t\t\t\t\tkey: getStoredKey(key as string, value.schema),\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 =\n\t\t\tnodeOptions.allowUnknownOptionalFields ?? false;\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(): TreeNodeSchemaInitializedData {\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 ObjectNodeSchemaPrivate;\n\t\t\thandler = createProxyHandler(schema, customizable);\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 getTreeNodeSchemaInitializedData(schema, {\n\t\t\t\tshallowCompatibilityTest: (data: FactoryContent): CompatibilityLevel =>\n\t\t\t\t\tshallowCompatibilityTest(data, schema),\n\t\t\t\ttoFlexContent: (\n\t\t\t\t\tdata: FactoryContent,\n\t\t\t\t\tallowedTypes: ReadonlySet<TreeNodeSchema>,\n\t\t\t\t): FlexContent => objectToFlexContent(data, schema),\n\t\t\t});\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> =\n\t\t\tnodeOptions.metadata ?? {};\n\t\tpublic static readonly persistedMetadata: JsonCompatibleReadOnlyObject | undefined =\n\t\t\tnodeOptions.persistedMetadata;\n\n\t\t// eslint-disable-next-line import-x/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\n\t\tpublic static get [privateDataSymbol](): TreeNodeSchemaPrivateData {\n\t\t\treturn (privateData ??= createTreeNodeSchemaPrivateData(\n\t\t\t\tthis,\n\t\t\t\tArray.from(CustomObjectNode.fields.values(), (schema) => schema.allowedTypesFull),\n\t\t\t));\n\t\t}\n\t}\n\ttype Output = typeof CustomObjectNode &\n\t\t(new (\n\t\t\tinput: InsertableObjectFromSchemaRecord<T> | InternalTreeNode,\n\t\t) => TreeObjectNode<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 * {@link TreeNodeSchemaInitializedData.toFlexContent} for object nodes.\n *\n * @param data - The tree data to be transformed. Must be a Record-like object.\n * @param schema - The schema to comply with.\n */\nfunction objectToFlexContent(\n\tdata: FactoryContent,\n\tschema: TreeNodeSchema & ObjectNodeSchemaInternalData,\n): FlexContent {\n\tif (\n\t\ttypeof data !== \"object\" ||\n\t\tdata === null ||\n\t\tSymbol.iterator in data ||\n\t\tisFluidHandle(data)\n\t) {\n\t\t// eslint-disable-next-line @typescript-eslint/no-base-to-string\n\t\tthrow new UsageError(`Input data is incompatible with Object schema: ${data}`);\n\t}\n\n\tconst fields = new Map<FieldKey, UnhydratedFlexTreeField>();\n\tconst context = getUnhydratedContext(schema).flexContext;\n\n\tfor (const [key, fieldInfo] of schema.flexKeyMap) {\n\t\tconst value = getFieldProperty(data, key);\n\n\t\tlet children: FlexTreeNode[] | ContextualFieldProvider;\n\t\tif (value === undefined) {\n\t\t\tconst defaultProvider =\n\t\t\t\tfieldInfo.schema.props?.defaultProvider ??\n\t\t\t\tfail(0xbb1 /* missing field has no default provider */);\n\t\t\tconst fieldProvider = extractFieldProvider(defaultProvider);\n\t\t\tchildren = isConstant(fieldProvider) ? fieldProvider() : fieldProvider;\n\t\t} else {\n\t\t\tchildren = [flexTreeFromInsertableNode(value, fieldInfo.schema.allowedTypeSet)];\n\t\t}\n\n\t\tconst kind =\n\t\t\tconvertFieldKind.get(fieldInfo.schema.kind) ?? fail(0xbb2 /* Invalid field kind */);\n\t\tfields.set(\n\t\t\tfieldInfo.storedKey,\n\t\t\tcreateField(context, kind.identifier, fieldInfo.storedKey, children),\n\t\t);\n\t}\n\n\treturn [{ type: brand(schema.identifier) }, fields];\n}\n\n/**\n * {@link TreeNodeSchemaInitializedData.shallowCompatibilityTest} for Object nodes.\n */\nfunction shallowCompatibilityTest(\n\tdata: FactoryContent,\n\tschema: ObjectNodeSchema & ObjectNodeSchemaInternalData,\n): CompatibilityLevel {\n\tif (isTreeValue(data)) {\n\t\treturn CompatibilityLevel.None;\n\t}\n\n\tif (Symbol.iterator in data) {\n\t\treturn CompatibilityLevel.None;\n\t}\n\n\t// TODO: Improve type inference by making this logic more thorough. Handle at least:\n\t// * Types which are strict subsets of other types in the same polymorphic union\n\t// * Types which have the same keys but different types for those keys in the polymorphic union\n\t// * Types which have the same required fields but different optional fields and enough of those optional fields are populated to disambiguate\n\n\t// TODO#7441: Consider allowing data to be inserted which has keys that are extraneous/unknown to the schema (those keys are ignored)\n\n\t// If the schema has a required key which is not present in the input object, reject it.\n\tfor (const [fieldKey, fieldSchema] of schema.fields) {\n\t\tif (fieldSchema.requiresValue && getFieldProperty(data, fieldKey) === undefined) {\n\t\t\treturn CompatibilityLevel.None;\n\t\t}\n\t}\n\n\treturn CompatibilityLevel.Normal;\n}\n\n/**\n * Check {@link FactoryContentObject} for a property which could be store a field.\n *\n * @returns If the property exists, return its value. Otherwise, returns undefined.\n * @remarks\n * The currently policy is to only consider own properties.\n * See {@link InsertableObjectFromSchemaRecord} for where this policy is documented in the public API.\n *\n * Explicit undefined values are treated the same as missing properties to allow explicit use of undefined with defaulted identifiers.\n *\n * @privateRemarks\n * If we ever want to have an optional field which defaults to something other than undefined, this will need changes.\n * It would need to adjusting the handling of explicit undefined in contexts where undefined is allowed, and a default provider also exists.\n */\nfunction getFieldProperty(\n\tdata: FactoryContentObject,\n\tkey: string | symbol,\n): InsertableContent | undefined {\n\t// This policy only allows own properties.\n\tif (Object.hasOwnProperty.call(data, key)) {\n\t\treturn (data as Record<string, InsertableContent>)[key as string];\n\t}\n\treturn undefined;\n}\n\nfunction applyFieldChange(\n\tschema: ObjectNodeSchemaPrivate,\n\tfrom: { kind: \"proxy\"; node: TreeNode } | { kind: \"target\"; node: object },\n\tfieldInfo: { storedKey: FieldKey; schema: FieldSchema },\n\tvalue: InsertableContent | undefined,\n): void {\n\tconst proxy =\n\t\tfrom.kind === \"proxy\"\n\t\t\t? from.node\n\t\t\t: (targetToProxy.get(from.node) ?? fail(0xc95 /* missing proxy */));\n\tconst inner = getInnerNode(proxy);\n\tconst storedSchema = inner.context.schema.nodeSchema.get(brand(schema.identifier));\n\tassert(\n\t\tstoredSchema instanceof ObjectNodeStoredSchema,\n\t\t0xc96 /* Expected ObjectNodeStoredSchema */,\n\t);\n\n\tif (value === undefined && inner.tryGetField(fieldInfo.storedKey) === undefined) {\n\t\treturn;\n\t}\n\n\tsetField(\n\t\tinner.getBoxed(fieldInfo.storedKey),\n\t\tfieldInfo.schema,\n\t\tvalue,\n\t\tstoredSchema.getFieldSchema(fieldInfo.storedKey),\n\t);\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"recordNode.d.ts","sourceRoot":"","sources":["../../../../src/simple-tree/node-kinds/record/recordNode.ts"],"names":[],"mappings":"AAAA;;;GAGG;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6B,EAG7B,MAAM,sBAAsB,CAAC;AAmJ9B;;;GAGG;AACH,MAAM,WAAW,mBAAmB,CACnC,KAAK,SAAS,MAAM,EACpB,aAAa,SAAS,oBAAoB,EAC1C,wBAAwB,SAAS,OAAO,EACxC,eAAe,GAAG,OAAO;IAEzB;;OAEG;IACH,QAAQ,CAAC,UAAU,EAAE,KAAK,CAAC;IAE3B,QAAQ,CAAC,YAAY,EAAE,OAAO,CAAC;IAE/B;;OAEG;IACH,QAAQ,CAAC,IAAI,EAAE,aAAa,CAAC;IAE7B,QAAQ,CAAC,uBAAuB,EAAE,wBAAwB,CAAC;IAE3D,QAAQ,CAAC,WAAW,CAAC,EAAE,sBAAsB,CAAC,eAAe,CAAC,CAAC;CAC/D;AAED;;;;;GAKG;AAEH,wBAAgB,YAAY,CAC3B,KAAK,SAAS,MAAM,EACpB,KAAK,CAAC,aAAa,SAAS,oBAAoB,EAChD,KAAK,CAAC,wBAAwB,SAAS,OAAO,EAC9C,KAAK,CAAC,eAAe,GAAG,OAAO,EAE/B,OAAO,EAAE,mBAAmB,CAC3B,KAAK,EACL,aAAa,EACb,wBAAwB,EACxB,eAAe,CACf,kRAgKD"}
@@ -74,8 +74,10 @@ function createRecordNodeProxy(proxyTarget, customizable, schema) {
74
74
  const kernel = getKernel(receiver);
75
75
  const innerSchema = innerNode.context.schema.nodeSchema.get(brand(schema.identifier));
76
76
  assert(innerSchema instanceof MapNodeStoredSchema, 0xc1a /* Expected MapNodeStoredSchema */);
77
- const mapTree = prepareForInsertion(value, createFieldSchema(FieldKind.Optional, kernel.schema.info), innerNode.context, innerSchema.mapFields);
78
- field.editor.set(mapTree, field.length === 0);
77
+ field.context.runInTransaction(() => {
78
+ const mapTree = prepareForInsertion(value, createFieldSchema(FieldKind.Optional, kernel.schema.info), innerNode.context, innerSchema.mapFields);
79
+ field.editor.attach(mapTree, field.length === 0);
80
+ });
79
81
  return true;
80
82
  },
81
83
  has: (target, key) => {
@@ -1 +1 @@
1
- {"version":3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M,CAAC;AAClC,CAAC;AAED;;;;;;GAMG;AACH,SAAS,mBAAmB,CAAC,IAAoB,EAAE,MAAwB;IAC1E,IAAI,CAAC,CAAC,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,KAAK,IAAI,CAAC,EAAE,CAAC;QAClD,MAAM,IAAI,UAAU,CAAC,kDAAkD,IAAI,EAAE,CAAC,CAAC;IAChF,CAAC;IAED,MAAM,cAAc,GAAmD,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5F,OAAO,2BAA2B,CAAC,cAAc,EAAE,MAAM,CAAC,CAAC;AAC5D,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, Lazy } from \"@fluidframework/core-utils/internal\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\n\nimport { MapNodeStoredSchema } from \"../../../core/index.js\";\nimport {\n\tisTreeValue,\n\ttype FlexTreeNode,\n\ttype FlexTreeOptionalField,\n} from \"../../../feature-libraries/index.js\";\nimport { type JsonCompatibleReadOnlyObject, brand } from \"../../../util/index.js\";\nimport type { NodeSchemaOptionsAlpha } from \"../../api/index.js\";\nimport {\n\ttype TreeNodeSchema,\n\tNodeKind,\n\t// eslint-disable-next-line import-x/no-deprecated\n\ttypeNameSymbol,\n\ttypeSchemaSymbol,\n\ttype UnhydratedFlexTreeNode,\n\tgetInnerNode,\n\tgetKernel,\n\ttype InternalTreeNode,\n\ttype NodeSchemaMetadata,\n\ttype ImplicitAllowedTypes,\n\tnormalizeAllowedTypes,\n\ttype TreeNodeFromImplicitAllowedTypes,\n\tTreeNodeValid,\n\ttype MostDerivedData,\n\ttype TreeNodeSchemaInitializedData,\n\ttype TreeNodeSchemaCorePrivate,\n\tprivateDataSymbol,\n\tcreateTreeNodeSchemaPrivateData,\n\ttype FlexContent,\n\tCompatibilityLevel,\n\ttype TreeNodeSchemaPrivateData,\n\tAnnotatedAllowedTypesInternal,\n} from \"../../core/index.js\";\nimport { getTreeNodeSchemaInitializedData } from \"../../createContext.js\";\nimport { createFieldSchema, FieldKind } from \"../../fieldSchema.js\";\nimport { tryGetTreeNodeForField } from \"../../getTreeNodeForField.js\";\nimport { prepareForInsertion } from \"../../prepareForInsertion.js\";\nimport type { SchemaType, SimpleAllowedTypeAttributes } from \"../../simpleSchema.js\";\nimport {\n\tunhydratedFlexTreeFromInsertable,\n\ttype FactoryContent,\n\ttype InsertableContent,\n} from \"../../unhydratedFlexTreeFromInsertable.js\";\nimport { recordLikeDataToFlexContent } from \"../common.js\";\n\nimport type {\n\tRecordNodeCustomizableSchema,\n\tRecordNodeInsertableData,\n\tRecordNodePojoEmulationSchema,\n\tRecordNodeSchema,\n\tTreeRecordNode,\n} from \"./recordNodeTypes.js\";\n\n/**\n * Create a proxy which implements the {@link TreeRecordNode} API.\n * @param proxyTarget - Target object of the proxy.\n * @param customizable - See {@link RecordNodeSchemaOptions.customizable}.\n * @param schema - The schema of the record node.\n */\nfunction createRecordNodeProxy(\n\tproxyTarget: object,\n\tcustomizable: boolean,\n\tschema: RecordNodeSchema,\n): TreeRecordNode {\n\tconst proxy: TreeRecordNode = new Proxy<TreeRecordNode>(proxyTarget as TreeRecordNode, {\n\t\tget: (target, key, receiver): unknown => {\n\t\t\tif (typeof key === \"symbol\") {\n\t\t\t\tswitch (key) {\n\t\t\t\t\t// POJO mode records don't have TreeNode's build in members on their targets, so special case them:\n\t\t\t\t\tcase typeSchemaSymbol: {\n\t\t\t\t\t\treturn schema;\n\t\t\t\t\t}\n\t\t\t\t\t// eslint-disable-next-line import-x/no-deprecated\n\t\t\t\t\tcase typeNameSymbol: {\n\t\t\t\t\t\treturn schema.identifier;\n\t\t\t\t\t}\n\t\t\t\t\tcase Symbol.iterator: {\n\t\t\t\t\t\treturn () => recordIterator(proxy);\n\t\t\t\t\t}\n\t\t\t\t\tcase Symbol.toPrimitive: {\n\t\t\t\t\t\t// Handle string interpolation and coercion to string\n\t\t\t\t\t\treturn () => Object.prototype.toString.call(proxy);\n\t\t\t\t\t}\n\t\t\t\t\tcase Symbol.toStringTag: {\n\t\t\t\t\t\t// In order to satisfy deep equality checks in POJO (non-customizable) mode,\n\t\t\t\t\t\t// we cannot override the behavior of this.\n\t\t\t\t\t\tif (customizable) {\n\t\t\t\t\t\t\t// Generates nicer toString behavior for customizable records.\n\t\t\t\t\t\t\t// E.g. `[object My.Record]` instead of `[object Object]`.\n\t\t\t\t\t\t\treturn schema.identifier;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tdefault:\n\t\t\t\t\t// No-op\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (typeof key === \"string\") {\n\t\t\t\tconst innerNode = getInnerNode(receiver);\n\t\t\t\tconst field = innerNode.tryGetField(brand(key));\n\t\t\t\tif (field !== undefined) {\n\t\t\t\t\treturn tryGetTreeNodeForField(field);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn undefined;\n\t\t},\n\t\tset: (target, key, value: InsertableContent | undefined, receiver): boolean => {\n\t\t\tif (typeof key === \"symbol\") {\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\tconst innerNode = getInnerNode(receiver);\n\t\t\tconst field = innerNode.getBoxed(brand(key)) as FlexTreeOptionalField;\n\t\t\tconst kernel = getKernel(receiver);\n\t\t\tconst innerSchema = innerNode.context.schema.nodeSchema.get(brand(schema.identifier));\n\t\t\tassert(\n\t\t\t\tinnerSchema instanceof MapNodeStoredSchema,\n\t\t\t\t0xc1a /* Expected MapNodeStoredSchema */,\n\t\t\t);\n\n\t\t\tconst mapTree = prepareForInsertion(\n\t\t\t\tvalue,\n\t\t\t\tcreateFieldSchema(FieldKind.Optional, kernel.schema.info as ImplicitAllowedTypes),\n\t\t\t\tinnerNode.context,\n\t\t\t\tinnerSchema.mapFields,\n\t\t\t);\n\n\t\t\tfield.editor.set(mapTree, field.length === 0);\n\t\t\treturn true;\n\t\t},\n\t\thas: (target, key): boolean => {\n\t\t\tif (typeof key === \"symbol\") {\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\tconst innerNode = getInnerNode(proxy);\n\t\t\tconst childField = innerNode.tryGetField(brand(key));\n\n\t\t\treturn childField !== undefined;\n\t\t},\n\t\townKeys: (target) => {\n\t\t\tconst innerNode = getInnerNode(proxy);\n\t\t\treturn [...innerNode.keys()];\n\t\t},\n\t\tgetOwnPropertyDescriptor: (target, key) => {\n\t\t\tif (typeof key === \"symbol\") {\n\t\t\t\treturn undefined;\n\t\t\t}\n\n\t\t\tconst innerNode = getInnerNode(proxy);\n\t\t\tconst field = innerNode.tryGetField(brand(key));\n\n\t\t\tif (field === undefined) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\tvalue: tryGetTreeNodeForField(field),\n\t\t\t\twritable: true,\n\t\t\t\tenumerable: true,\n\t\t\t\tconfigurable: true, // Must be 'configurable' if property is absent from proxy target.\n\t\t\t};\n\t\t},\n\t\tdefineProperty(target, key, attributes) {\n\t\t\tthrow new UsageError(\"Shadowing properties of record nodes is not permitted.\");\n\t\t},\n\t\tdeleteProperty(target, key) {\n\t\t\tif (typeof key === \"symbol\") {\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\tconst innerNode = getInnerNode(proxy);\n\t\t\tconst field = innerNode.tryGetField(brand(key)) as FlexTreeOptionalField | undefined;\n\t\t\tif (field !== undefined) {\n\t\t\t\tfield.editor.set(undefined, field.length === 0);\n\t\t\t}\n\n\t\t\treturn true;\n\t\t},\n\t});\n\treturn proxy;\n}\n\nabstract class CustomRecordNodeBase<\n\tconst TAllowedTypes extends ImplicitAllowedTypes,\n> extends TreeNodeValid<RecordNodeInsertableData<TAllowedTypes>> {\n\tpublic static readonly kind = NodeKind.Record;\n\n\tpublic constructor(\n\t\tinput?: InternalTreeNode | RecordNodeInsertableData<TAllowedTypes> | undefined,\n\t) {\n\t\tsuper(input ?? {});\n\t}\n}\n\n/**\n * {@link recordSchema} options.\n * @input\n */\nexport interface RecordSchemaOptions<\n\tTName extends string,\n\tTAllowedTypes extends ImplicitAllowedTypes,\n\tTImplicitlyConstructable extends boolean,\n\tTCustomMetadata = unknown,\n> {\n\t/**\n\t * Unique identifier for this schema within this factory's scope.\n\t */\n\treadonly identifier: TName;\n\n\treadonly customizable: boolean;\n\n\t/**\n\t * The kinds of nodes that are allowed as children of this record.\n\t */\n\treadonly info: TAllowedTypes;\n\n\treadonly implicitlyConstructable: TImplicitlyConstructable;\n\n\treadonly nodeOptions?: NodeSchemaOptionsAlpha<TCustomMetadata>;\n}\n\n/**\n * Define a {@link TreeNodeSchema} for a {@link TreeRecordNode}.\n *\n * @param fields - Schema for fields of the object node's schema. Defines what children can be placed under each key.\n * @param persistedMetadata -\n */\n// eslint-disable-next-line @typescript-eslint/explicit-function-return-type\nexport function recordSchema<\n\tTName extends string,\n\tconst TAllowedTypes extends ImplicitAllowedTypes,\n\tconst TImplicitlyConstructable extends boolean,\n\tconst TCustomMetadata = unknown,\n>(\n\toptions: RecordSchemaOptions<\n\t\tTName,\n\t\tTAllowedTypes,\n\t\tTImplicitlyConstructable,\n\t\tTCustomMetadata\n\t>,\n) {\n\tconst { identifier, info, customizable, implicitlyConstructable, nodeOptions } = options;\n\tconst persistedMetadata = nodeOptions?.persistedMetadata;\n\n\tconst normalizedTypes = normalizeAllowedTypes(info);\n\tconst lazyAllowedTypesIdentifiers = new Lazy(\n\t\t() => new Set(normalizedTypes.evaluate().map((type) => type.identifier)),\n\t);\n\tconst lazySimpleAllowedTypes = new Lazy(() => {\n\t\treturn AnnotatedAllowedTypesInternal.evaluateSimpleAllowedTypes(normalizedTypes);\n\t});\n\n\tlet privateData: TreeNodeSchemaPrivateData | undefined;\n\n\tclass Schema\n\t\textends CustomRecordNodeBase<TAllowedTypes>\n\t\timplements TreeRecordNode<TAllowedTypes>\n\t{\n\t\t/**\n\t\t * Record-like index signature for the node.\n\t\t */\n\t\t[key: string]: TreeNodeFromImplicitAllowedTypes<TAllowedTypes>;\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.record(\"Foo\", 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 Record)\n\t\t\t//\n\t\t\t// \t class Foo extends schemaFactory.record(\"Foo\", 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\t\t\tconst proxyTarget = customizable ? instance : {};\n\t\t\treturn createRecordNodeProxy(\n\t\t\t\tproxyTarget,\n\t\t\t\tcustomizable,\n\t\t\t\tthis as unknown as RecordNodeSchema,\n\t\t\t) as unknown as Schema;\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 typeof Schema);\n\t\t}\n\n\t\tprotected static override oneTimeSetup(): TreeNodeSchemaInitializedData {\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 !== Schema.prototype) {\n\t\t\t\t\tfor (const key of Object.getOwnPropertyNames(prototype)) {\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 could shadow a legal entry. Since child fields are exposed as own properties, shadowing properties of record nodes is not permitted.`,\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 CustomRecordNode, 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 CustomRecordNode 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\tconst schema = this as RecordNodeSchema;\n\t\t\treturn getTreeNodeSchemaInitializedData(this, {\n\t\t\t\tshallowCompatibilityTest,\n\t\t\t\ttoFlexContent: (data: FactoryContent): FlexContent =>\n\t\t\t\t\trecordToFlexContent(data, schema),\n\t\t\t});\n\t\t}\n\n\t\tpublic static get allowedTypesIdentifiers(): ReadonlySet<string> {\n\t\t\treturn lazyAllowedTypesIdentifiers.value;\n\t\t}\n\n\t\tpublic static get simpleAllowedTypes(): ReadonlyMap<\n\t\t\tstring,\n\t\t\tSimpleAllowedTypeAttributes<SchemaType.View>\n\t\t> {\n\t\t\treturn lazySimpleAllowedTypes.value;\n\t\t}\n\n\t\tprotected static override constructorCached: MostDerivedData | undefined = undefined;\n\n\t\tpublic static readonly identifier = identifier;\n\t\tpublic static readonly info = info;\n\t\tpublic static readonly implicitlyConstructable: TImplicitlyConstructable =\n\t\t\timplicitlyConstructable;\n\t\tpublic static get childTypes(): ReadonlySet<TreeNodeSchema> {\n\t\t\treturn normalizedTypes.evaluateSet();\n\t\t}\n\t\tpublic static readonly metadata: NodeSchemaMetadata<TCustomMetadata> =\n\t\t\tnodeOptions?.metadata ?? {};\n\t\tpublic static readonly persistedMetadata: JsonCompatibleReadOnlyObject | undefined =\n\t\t\tpersistedMetadata;\n\n\t\t// eslint-disable-next-line import-x/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 Schema.constructorCached?.constructor as unknown as Output;\n\t\t}\n\n\t\tpublic [Symbol.iterator](): IterableIterator<\n\t\t\t[string, TreeNodeFromImplicitAllowedTypes<TAllowedTypes>]\n\t\t> {\n\t\t\treturn recordIterator(this);\n\t\t}\n\t\tpublic get [Symbol.toStringTag](): string {\n\t\t\treturn identifier;\n\t\t}\n\n\t\tpublic static get [privateDataSymbol](): TreeNodeSchemaPrivateData {\n\t\t\treturn (privateData ??= createTreeNodeSchemaPrivateData(this, [normalizedTypes]));\n\t\t}\n\t}\n\n\ttype Output = RecordNodeCustomizableSchema<\n\t\tTName,\n\t\tTAllowedTypes,\n\t\tTImplicitlyConstructable,\n\t\tTCustomMetadata\n\t> &\n\t\tRecordNodePojoEmulationSchema<\n\t\t\tTName,\n\t\t\tTAllowedTypes,\n\t\t\tTImplicitlyConstructable,\n\t\t\tTCustomMetadata\n\t\t> &\n\t\tTreeNodeSchemaCorePrivate;\n\n\tconst output: Output = Schema;\n\treturn output;\n}\n\nfunction* recordIterator<TAllowedTypes extends ImplicitAllowedTypes>(\n\trecord: TreeRecordNode<TAllowedTypes>,\n): IterableIterator<[string, TreeNodeFromImplicitAllowedTypes<TAllowedTypes>]> {\n\tfor (const [key, value] of Object.entries(record)) {\n\t\tyield [key, value];\n\t}\n}\n\n/**\n * {@link TreeNodeSchemaInitializedData.shallowCompatibilityTest} for Record nodes.\n */\nfunction shallowCompatibilityTest(data: FactoryContent): CompatibilityLevel {\n\tif (isTreeValue(data)) {\n\t\treturn CompatibilityLevel.None;\n\t}\n\n\tif (Symbol.iterator in data) {\n\t\treturn CompatibilityLevel.None;\n\t}\n\n\treturn CompatibilityLevel.Normal;\n}\n\n/**\n * {@link TreeNodeSchemaInitializedData.toFlexContent} for Record nodes.\n *\n * Transforms data under a Record schema.\n * @param data - The tree data to be transformed. Must be a Record-like object.\n * @param schema - The schema to comply with.\n */\nfunction recordToFlexContent(data: FactoryContent, schema: RecordNodeSchema): FlexContent {\n\tif (!(typeof data === \"object\" && data !== null)) {\n\t\tthrow new UsageError(`Input data is incompatible with Record schema: ${data}`);\n\t}\n\n\tconst fieldsIterator: Iterable<readonly [string, InsertableContent]> = Object.entries(data);\n\treturn recordLikeDataToFlexContent(fieldsIterator, schema);\n}\n"]}
1
+ {"version":3,"file":"recordNode.js","sourceRoot":"","sources":["../../../../src/simple-tree/node-kinds/record/recordNode.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,qCAAqC,CAAC;AACnE,OAAO,EAAE,UAAU,EAAE,MAAM,0CAA0C,CAAC;AAEtE,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAC7D,OAAO,EACN,WAAW,GAGX,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EAAqC,KAAK,EAAE,MAAM,wBAAwB,CAAC;AAElF,OAAO,EAEN,QAAQ;AACR,kDAAkD;AAClD,cAAc,EACd,gBAAgB,EAEhB,YAAY,EACZ,SAAS,EAIT,qBAAqB,EAErB,aAAa,EAIb,iBAAiB,EACjB,+BAA+B,EAE/B,kBAAkB,EAElB,6BAA6B,GAC7B,MAAM,qBAAqB,CAAC;A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GAAG,UAAU,CAAC;IACxB,WAAI,GAAG,IAAI,CAAC;IACZ,8BAAuB,GAC7C,uBAAuB,CAAC;IAIF,eAAQ,GAC9B,WAAW,EAAE,QAAQ,IAAI,EAAE,CAAC;IACN,wBAAiB,GACvC,iBAAiB,CAAC;IAsCpB,MAAM,MAAM,GAAW,MAAM,CAAC;IAC9B,OAAO,MAAM,CAAC;AACf,CAAC;AAED,QAAQ,CAAC,CAAC,cAAc,CACvB,MAAqC;IAErC,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;QACnD,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;IACpB,CAAC;AACF,CAAC;AAED;;GAEG;AACH,SAAS,wBAAwB,CAAC,IAAoB;IACrD,IAAI,WAAW,CAAC,IAAI,CAAC,EAAE,CAAC;QACvB,OAAO,kBAAkB,CAAC,IAAI,CAAC;IAChC,CAAC;IAED,IAAI,MAAM,CAAC,QAAQ,IAAI,IAAI,EAAE,CAAC;QAC7B,OAAO,kBAAkB,CAAC,IAAI,CAAC;IAChC,CAAC;IAED,OAAO,kBAAkB,CAAC,MAAM,CAAC;AAClC,CAAC;AAED;;;;;;GAMG;AACH,SAAS,mBAAmB,CAAC,IAAoB,EAAE,MAAwB;IAC1E,IAAI,CAAC,CAAC,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,KAAK,IAAI,CAAC,EAAE,CAAC;QAClD,MAAM,IAAI,UAAU,CAAC,kDAAkD,IAAI,EAAE,CAAC,CAAC;IAChF,CAAC;IAED,MAAM,cAAc,GAAmD,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5F,OAAO,2BAA2B,CAAC,cAAc,EAAE,MAAM,CAAC,CAAC;AAC5D,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, Lazy } from \"@fluidframework/core-utils/internal\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\n\nimport { MapNodeStoredSchema } from \"../../../core/index.js\";\nimport {\n\tisTreeValue,\n\ttype FlexTreeNode,\n\ttype FlexTreeOptionalField,\n} from \"../../../feature-libraries/index.js\";\nimport { type JsonCompatibleReadOnlyObject, brand } from \"../../../util/index.js\";\nimport type { NodeSchemaOptionsAlpha } from \"../../api/index.js\";\nimport {\n\ttype TreeNodeSchema,\n\tNodeKind,\n\t// eslint-disable-next-line import-x/no-deprecated\n\ttypeNameSymbol,\n\ttypeSchemaSymbol,\n\ttype UnhydratedFlexTreeNode,\n\tgetInnerNode,\n\tgetKernel,\n\ttype InternalTreeNode,\n\ttype NodeSchemaMetadata,\n\ttype ImplicitAllowedTypes,\n\tnormalizeAllowedTypes,\n\ttype TreeNodeFromImplicitAllowedTypes,\n\tTreeNodeValid,\n\ttype MostDerivedData,\n\ttype TreeNodeSchemaInitializedData,\n\ttype TreeNodeSchemaCorePrivate,\n\tprivateDataSymbol,\n\tcreateTreeNodeSchemaPrivateData,\n\ttype FlexContent,\n\tCompatibilityLevel,\n\ttype TreeNodeSchemaPrivateData,\n\tAnnotatedAllowedTypesInternal,\n} from \"../../core/index.js\";\nimport { getTreeNodeSchemaInitializedData } from \"../../createContext.js\";\nimport { createFieldSchema, FieldKind } from \"../../fieldSchema.js\";\nimport { tryGetTreeNodeForField } from \"../../getTreeNodeForField.js\";\nimport { prepareForInsertion } from \"../../prepareForInsertion.js\";\nimport type { SchemaType, SimpleAllowedTypeAttributes } from \"../../simpleSchema.js\";\nimport {\n\tunhydratedFlexTreeFromInsertable,\n\ttype FactoryContent,\n\ttype InsertableContent,\n} from \"../../unhydratedFlexTreeFromInsertable.js\";\nimport { recordLikeDataToFlexContent } from \"../common.js\";\n\nimport type {\n\tRecordNodeCustomizableSchema,\n\tRecordNodeInsertableData,\n\tRecordNodePojoEmulationSchema,\n\tRecordNodeSchema,\n\tTreeRecordNode,\n} from \"./recordNodeTypes.js\";\n\n/**\n * Create a proxy which implements the {@link TreeRecordNode} API.\n * @param proxyTarget - Target object of the proxy.\n * @param customizable - See {@link RecordNodeSchemaOptions.customizable}.\n * @param schema - The schema of the record node.\n */\nfunction createRecordNodeProxy(\n\tproxyTarget: object,\n\tcustomizable: boolean,\n\tschema: RecordNodeSchema,\n): TreeRecordNode {\n\tconst proxy: TreeRecordNode = new Proxy<TreeRecordNode>(proxyTarget as TreeRecordNode, {\n\t\tget: (target, key, receiver): unknown => {\n\t\t\tif (typeof key === \"symbol\") {\n\t\t\t\tswitch (key) {\n\t\t\t\t\t// POJO mode records don't have TreeNode's build in members on their targets, so special case them:\n\t\t\t\t\tcase typeSchemaSymbol: {\n\t\t\t\t\t\treturn schema;\n\t\t\t\t\t}\n\t\t\t\t\t// eslint-disable-next-line import-x/no-deprecated\n\t\t\t\t\tcase typeNameSymbol: {\n\t\t\t\t\t\treturn schema.identifier;\n\t\t\t\t\t}\n\t\t\t\t\tcase Symbol.iterator: {\n\t\t\t\t\t\treturn () => recordIterator(proxy);\n\t\t\t\t\t}\n\t\t\t\t\tcase Symbol.toPrimitive: {\n\t\t\t\t\t\t// Handle string interpolation and coercion to string\n\t\t\t\t\t\treturn () => Object.prototype.toString.call(proxy);\n\t\t\t\t\t}\n\t\t\t\t\tcase Symbol.toStringTag: {\n\t\t\t\t\t\t// In order to satisfy deep equality checks in POJO (non-customizable) mode,\n\t\t\t\t\t\t// we cannot override the behavior of this.\n\t\t\t\t\t\tif (customizable) {\n\t\t\t\t\t\t\t// Generates nicer toString behavior for customizable records.\n\t\t\t\t\t\t\t// E.g. `[object My.Record]` instead of `[object Object]`.\n\t\t\t\t\t\t\treturn schema.identifier;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tdefault:\n\t\t\t\t\t// No-op\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (typeof key === \"string\") {\n\t\t\t\tconst innerNode = getInnerNode(receiver);\n\t\t\t\tconst field = innerNode.tryGetField(brand(key));\n\t\t\t\tif (field !== undefined) {\n\t\t\t\t\treturn tryGetTreeNodeForField(field);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn undefined;\n\t\t},\n\t\tset: (target, key, value: InsertableContent | undefined, receiver): boolean => {\n\t\t\tif (typeof key === \"symbol\") {\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\tconst innerNode = getInnerNode(receiver);\n\t\t\tconst field = innerNode.getBoxed(brand(key)) as FlexTreeOptionalField;\n\t\t\tconst kernel = getKernel(receiver);\n\t\t\tconst innerSchema = innerNode.context.schema.nodeSchema.get(brand(schema.identifier));\n\t\t\tassert(\n\t\t\t\tinnerSchema instanceof MapNodeStoredSchema,\n\t\t\t\t0xc1a /* Expected MapNodeStoredSchema */,\n\t\t\t);\n\t\t\tfield.context.runInTransaction(() => {\n\t\t\t\tconst mapTree = prepareForInsertion(\n\t\t\t\t\tvalue,\n\t\t\t\t\tcreateFieldSchema(FieldKind.Optional, kernel.schema.info as ImplicitAllowedTypes),\n\t\t\t\t\tinnerNode.context,\n\t\t\t\t\tinnerSchema.mapFields,\n\t\t\t\t);\n\n\t\t\t\tfield.editor.attach(mapTree, field.length === 0);\n\t\t\t});\n\t\t\treturn true;\n\t\t},\n\t\thas: (target, key): boolean => {\n\t\t\tif (typeof key === \"symbol\") {\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\tconst innerNode = getInnerNode(proxy);\n\t\t\tconst childField = innerNode.tryGetField(brand(key));\n\n\t\t\treturn childField !== undefined;\n\t\t},\n\t\townKeys: (target) => {\n\t\t\tconst innerNode = getInnerNode(proxy);\n\t\t\treturn [...innerNode.keys()];\n\t\t},\n\t\tgetOwnPropertyDescriptor: (target, key) => {\n\t\t\tif (typeof key === \"symbol\") {\n\t\t\t\treturn undefined;\n\t\t\t}\n\n\t\t\tconst innerNode = getInnerNode(proxy);\n\t\t\tconst field = innerNode.tryGetField(brand(key));\n\n\t\t\tif (field === undefined) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\tvalue: tryGetTreeNodeForField(field),\n\t\t\t\twritable: true,\n\t\t\t\tenumerable: true,\n\t\t\t\tconfigurable: true, // Must be 'configurable' if property is absent from proxy target.\n\t\t\t};\n\t\t},\n\t\tdefineProperty(target, key, attributes) {\n\t\t\tthrow new UsageError(\"Shadowing properties of record nodes is not permitted.\");\n\t\t},\n\t\tdeleteProperty(target, key) {\n\t\t\tif (typeof key === \"symbol\") {\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\tconst innerNode = getInnerNode(proxy);\n\t\t\tconst field = innerNode.tryGetField(brand(key)) as FlexTreeOptionalField | undefined;\n\t\t\tif (field !== undefined) {\n\t\t\t\tfield.editor.set(undefined, field.length === 0);\n\t\t\t}\n\n\t\t\treturn true;\n\t\t},\n\t});\n\treturn proxy;\n}\n\nabstract class CustomRecordNodeBase<\n\tconst TAllowedTypes extends ImplicitAllowedTypes,\n> extends TreeNodeValid<RecordNodeInsertableData<TAllowedTypes>> {\n\tpublic static readonly kind = NodeKind.Record;\n\n\tpublic constructor(\n\t\tinput?: InternalTreeNode | RecordNodeInsertableData<TAllowedTypes> | undefined,\n\t) {\n\t\tsuper(input ?? {});\n\t}\n}\n\n/**\n * {@link recordSchema} options.\n * @input\n */\nexport interface RecordSchemaOptions<\n\tTName extends string,\n\tTAllowedTypes extends ImplicitAllowedTypes,\n\tTImplicitlyConstructable extends boolean,\n\tTCustomMetadata = unknown,\n> {\n\t/**\n\t * Unique identifier for this schema within this factory's scope.\n\t */\n\treadonly identifier: TName;\n\n\treadonly customizable: boolean;\n\n\t/**\n\t * The kinds of nodes that are allowed as children of this record.\n\t */\n\treadonly info: TAllowedTypes;\n\n\treadonly implicitlyConstructable: TImplicitlyConstructable;\n\n\treadonly nodeOptions?: NodeSchemaOptionsAlpha<TCustomMetadata>;\n}\n\n/**\n * Define a {@link TreeNodeSchema} for a {@link TreeRecordNode}.\n *\n * @param fields - Schema for fields of the object node's schema. Defines what children can be placed under each key.\n * @param persistedMetadata -\n */\n// eslint-disable-next-line @typescript-eslint/explicit-function-return-type\nexport function recordSchema<\n\tTName extends string,\n\tconst TAllowedTypes extends ImplicitAllowedTypes,\n\tconst TImplicitlyConstructable extends boolean,\n\tconst TCustomMetadata = unknown,\n>(\n\toptions: RecordSchemaOptions<\n\t\tTName,\n\t\tTAllowedTypes,\n\t\tTImplicitlyConstructable,\n\t\tTCustomMetadata\n\t>,\n) {\n\tconst { identifier, info, customizable, implicitlyConstructable, nodeOptions } = options;\n\tconst persistedMetadata = nodeOptions?.persistedMetadata;\n\n\tconst normalizedTypes = normalizeAllowedTypes(info);\n\tconst lazyAllowedTypesIdentifiers = new Lazy(\n\t\t() => new Set(normalizedTypes.evaluate().map((type) => type.identifier)),\n\t);\n\tconst lazySimpleAllowedTypes = new Lazy(() => {\n\t\treturn AnnotatedAllowedTypesInternal.evaluateSimpleAllowedTypes(normalizedTypes);\n\t});\n\n\tlet privateData: TreeNodeSchemaPrivateData | undefined;\n\n\tclass Schema\n\t\textends CustomRecordNodeBase<TAllowedTypes>\n\t\timplements TreeRecordNode<TAllowedTypes>\n\t{\n\t\t/**\n\t\t * Record-like index signature for the node.\n\t\t */\n\t\t[key: string]: TreeNodeFromImplicitAllowedTypes<TAllowedTypes>;\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.record(\"Foo\", 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 Record)\n\t\t\t//\n\t\t\t// \t class Foo extends schemaFactory.record(\"Foo\", 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\t\t\tconst proxyTarget = customizable ? instance : {};\n\t\t\treturn createRecordNodeProxy(\n\t\t\t\tproxyTarget,\n\t\t\t\tcustomizable,\n\t\t\t\tthis as unknown as RecordNodeSchema,\n\t\t\t) as unknown as Schema;\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 typeof Schema);\n\t\t}\n\n\t\tprotected static override oneTimeSetup(): TreeNodeSchemaInitializedData {\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 !== Schema.prototype) {\n\t\t\t\t\tfor (const key of Object.getOwnPropertyNames(prototype)) {\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 could shadow a legal entry. Since child fields are exposed as own properties, shadowing properties of record nodes is not permitted.`,\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 CustomRecordNode, 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 CustomRecordNode 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\tconst schema = this as RecordNodeSchema;\n\t\t\treturn getTreeNodeSchemaInitializedData(this, {\n\t\t\t\tshallowCompatibilityTest,\n\t\t\t\ttoFlexContent: (data: FactoryContent): FlexContent =>\n\t\t\t\t\trecordToFlexContent(data, schema),\n\t\t\t});\n\t\t}\n\n\t\tpublic static get allowedTypesIdentifiers(): ReadonlySet<string> {\n\t\t\treturn lazyAllowedTypesIdentifiers.value;\n\t\t}\n\n\t\tpublic static get simpleAllowedTypes(): ReadonlyMap<\n\t\t\tstring,\n\t\t\tSimpleAllowedTypeAttributes<SchemaType.View>\n\t\t> {\n\t\t\treturn lazySimpleAllowedTypes.value;\n\t\t}\n\n\t\tprotected static override constructorCached: MostDerivedData | undefined = undefined;\n\n\t\tpublic static readonly identifier = identifier;\n\t\tpublic static readonly info = info;\n\t\tpublic static readonly implicitlyConstructable: TImplicitlyConstructable =\n\t\t\timplicitlyConstructable;\n\t\tpublic static get childTypes(): ReadonlySet<TreeNodeSchema> {\n\t\t\treturn normalizedTypes.evaluateSet();\n\t\t}\n\t\tpublic static readonly metadata: NodeSchemaMetadata<TCustomMetadata> =\n\t\t\tnodeOptions?.metadata ?? {};\n\t\tpublic static readonly persistedMetadata: JsonCompatibleReadOnlyObject | undefined =\n\t\t\tpersistedMetadata;\n\n\t\t// eslint-disable-next-line import-x/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 Schema.constructorCached?.constructor as unknown as Output;\n\t\t}\n\n\t\tpublic [Symbol.iterator](): IterableIterator<\n\t\t\t[string, TreeNodeFromImplicitAllowedTypes<TAllowedTypes>]\n\t\t> {\n\t\t\treturn recordIterator(this);\n\t\t}\n\t\tpublic get [Symbol.toStringTag](): string {\n\t\t\treturn identifier;\n\t\t}\n\n\t\tpublic static get [privateDataSymbol](): TreeNodeSchemaPrivateData {\n\t\t\treturn (privateData ??= createTreeNodeSchemaPrivateData(this, [normalizedTypes]));\n\t\t}\n\t}\n\n\ttype Output = RecordNodeCustomizableSchema<\n\t\tTName,\n\t\tTAllowedTypes,\n\t\tTImplicitlyConstructable,\n\t\tTCustomMetadata\n\t> &\n\t\tRecordNodePojoEmulationSchema<\n\t\t\tTName,\n\t\t\tTAllowedTypes,\n\t\t\tTImplicitlyConstructable,\n\t\t\tTCustomMetadata\n\t\t> &\n\t\tTreeNodeSchemaCorePrivate;\n\n\tconst output: Output = Schema;\n\treturn output;\n}\n\nfunction* recordIterator<TAllowedTypes extends ImplicitAllowedTypes>(\n\trecord: TreeRecordNode<TAllowedTypes>,\n): IterableIterator<[string, TreeNodeFromImplicitAllowedTypes<TAllowedTypes>]> {\n\tfor (const [key, value] of Object.entries(record)) {\n\t\tyield [key, value];\n\t}\n}\n\n/**\n * {@link TreeNodeSchemaInitializedData.shallowCompatibilityTest} for Record nodes.\n */\nfunction shallowCompatibilityTest(data: FactoryContent): CompatibilityLevel {\n\tif (isTreeValue(data)) {\n\t\treturn CompatibilityLevel.None;\n\t}\n\n\tif (Symbol.iterator in data) {\n\t\treturn CompatibilityLevel.None;\n\t}\n\n\treturn CompatibilityLevel.Normal;\n}\n\n/**\n * {@link TreeNodeSchemaInitializedData.toFlexContent} for Record nodes.\n *\n * Transforms data under a Record schema.\n * @param data - The tree data to be transformed. Must be a Record-like object.\n * @param schema - The schema to comply with.\n */\nfunction recordToFlexContent(data: FactoryContent, schema: RecordNodeSchema): FlexContent {\n\tif (!(typeof data === \"object\" && data !== null)) {\n\t\tthrow new UsageError(`Input data is incompatible with Record schema: ${data}`);\n\t}\n\n\tconst fieldsIterator: Iterable<readonly [string, InsertableContent]> = Object.entries(data);\n\treturn recordLikeDataToFlexContent(fieldsIterator, schema);\n}\n"]}
@@ -2,11 +2,10 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
- import type { SchemaAndPolicy, UpPath, TreeFieldStoredSchema, TreeTypeSet } from "../core/index.js";
6
- import { type FlexTreeContext, type FlexTreeHydratedContextMinimal, type FlexibleFieldContent, type FlexibleNodeContent } from "../feature-libraries/index.js";
7
- import { type Mutable } from "../util/index.js";
8
- import { type ImplicitAllowedTypes, type TreeNode, type UnhydratedFlexTreeNode } from "./core/index.js";
9
- import type { ImplicitFieldSchema } from "./fieldSchema.js";
5
+ import type { SchemaAndPolicy, TreeFieldStoredSchema, TreeTypeSet } from "../core/index.js";
6
+ import { type FlexTreeContext, type FlexTreeHydratedContextMinimal, type FlexibleFieldContent, type FlexibleNodeContent, type FlexTreeNode, type DetachedRootsLocation } from "../feature-libraries/index.js";
7
+ import { type ImplicitAllowedTypes } from "./core/index.js";
8
+ import { type ImplicitFieldSchema } from "./fieldSchema.js";
10
9
  import { type InsertableContent } from "./unhydratedFlexTreeFromInsertable.js";
11
10
  /**
12
11
  * Prepare content from a user for insertion into a tree.
@@ -31,58 +30,66 @@ export declare function prepareForInsertion<TIn extends InsertableContent | unde
31
30
  * due to how the eventing in prepareContentForHydration works.
32
31
  */
33
32
  export declare function prepareArrayContentForInsertion(data: readonly InsertableContent[], schema: ImplicitAllowedTypes, destinationContext: FlexTreeContext, destinationSchema: TreeTypeSet): FlexibleFieldContent;
33
+ export interface PreparedContent {
34
+ /**
35
+ * New content which to be attached. Rooted in detached fields.
36
+ * @remarks
37
+ * When destination is a hydrated context, this will contain hydrated flex tree nodes.
38
+ * The corresponding TreeNodes will not yet be hydrated, and some subtrees may be in separate detached fields.
39
+ *
40
+ * TODO: Eventually, this should be a single detached field, not an array of nodes each in their own detached field.
41
+ */
42
+ readonly toAttach?: readonly FlexTreeNode[];
43
+ /**
44
+ * Location of toAttach.
45
+ * @remarks
46
+ * This is redundant with `toAttach.key` but in a different format/type.
47
+ * Only provided for hydrated destinations.
48
+ */
49
+ readonly rootsLocations?: DetachedRootsLocation;
50
+ /**
51
+ * Finalizes the prepared content. Moves in missing subtrees from detached fields, and hydrates TreeNodes as needed.
52
+ *
53
+ * @param attached - The nodes that were attached to the tree.
54
+ *
55
+ * @remarks
56
+ * Call this exactly once, after `toAttach` has been attached to its final location.
57
+ * There must be no app facing events between creation of this `PreparedContent` and its finalization since during this time TreeNodes may be in an invalid state (inner node hydrated, but TreeNode not).
58
+ *
59
+ * The implementation of this must not assume the context provided to `prepareForInsertion*` is still valid.
60
+ */
61
+ readonly finalize: (attached: readonly FlexTreeNode[]) => void;
62
+ }
34
63
  /**
35
- * Split out from {@link prepareForInsertion} as to allow use without a context.
36
- *
37
- * @param hydratedData - If specified, the `mapTrees` will be prepared for hydration into this context.
38
- * `undefined` when `mapTrees` are being inserted into an {@link Unhydrated} tree.
39
- *
40
- * @remarks
41
- * Adding this entry point is a workaround for initialize not currently having a context.
42
- */
43
- export declare function prepareForInsertionContextless<TIn extends InsertableContent | undefined>(data: TIn, schema: ImplicitFieldSchema, schemaAndPolicy: SchemaAndPolicy, hydratedData: FlexTreeHydratedContextMinimal | undefined, destinationSchema: TreeFieldStoredSchema, scheduleHydrationOverride?: HydrationScheduler): TIn extends undefined ? undefined : FlexibleNodeContent;
44
- /**
45
- * The path from the included node to the root of the content tree it was inserted as part of.
64
+ * This exists to handle the required root initialize case where the flex tree nodes get invalidated by a schema change and thus new node instances need to be provided.
46
65
  */
47
- interface RelativeNodePath {
48
- readonly path: UpPath;
49
- readonly node: TreeNode;
66
+ export interface PreparedContentInitialize extends PreparedContent {
67
+ /**
68
+ * {@inheritDoc PreparedContent.rootIds}
69
+ */
70
+ readonly rootsLocations: DetachedRootsLocation;
50
71
  }
51
72
  /**
52
- * {@link RelativeNodePath}s for every {@link TreeNode} in the content tree inserted as an atomic operation.
73
+ * This exists to handle the required root initialize case where the flex tree nodes get invalidated by a schema change and thus new node instances need to be provided.
53
74
  */
54
- interface LocatedNodesBatch {
75
+ export interface PreparedContentRegular extends PreparedContent {
76
+ /**
77
+ * {@inheritDoc PreparedContent.toAttach}
78
+ */
79
+ readonly toAttach: readonly FlexTreeNode[];
55
80
  /**
56
- * UpPath shared by all {@link RelativeNodePath}s in this batch corresponding to the root of the inserted content.
81
+ * {@link PreparedContent.finalize} but without `attached` parameter: assumes `toAttach` is the same is still valid and uses that.
57
82
  */
58
- readonly rootPath: Mutable<UpPath>;
59
- readonly paths: RelativeNodePath[];
83
+ readonly finalize: () => void;
60
84
  }
61
85
  /**
62
- * 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.
63
- * Additionally populates any {@link UnhydratedFlexTreeField.pendingDefault}s using the provided `context`.
86
+ * Split out from {@link prepareForInsertion} as to allow use without a context.
64
87
  *
65
- * @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.
66
- * Specifically, no other content may be inserted into the tree between the invocation of this function and the insertion of `content`.
67
- * The insertion of `content` must occur or else this function will cause memory leaks.
88
+ * @param hydratedData - If specified, the `mapTrees` will be prepared for hydration into this context.
89
+ * `undefined` when `mapTrees` are being inserted into an {@link Unhydrated} tree.
68
90
  *
69
- * Exported for testing purposes: otherwise should not be used outside this module.
70
- * @param content - the content subsequence to be inserted, of which might deeply contain {@link TreeNode}s which need to be hydrated.
71
- * @param forest - the forest the content is being inserted into.
72
- */
73
- export declare function prepareContentForHydration(content: readonly UnhydratedFlexTreeNode[], scheduler: HydrationScheduler, context: FlexTreeHydratedContextMinimal): void;
74
- /**
75
- * A function which can schedule hydration of batches of nodes to occur at a later time (which must be after they have been inserted into the tree).
76
- */
77
- type HydrationScheduler = (locatedNodes: readonly LocatedNodesBatch[],
78
- /**
79
- * Does the actual hydration. Should be called for each index in `locatedNodes` once the corresponding content has been inserted into the tree.
80
- */
81
- doHydration: Hydrator) => void;
82
- /**
83
- * Does the actual hydration.
84
- * The provided `attachPath` is the path the content is currently under (where it was attached in the tree).
91
+ * @remarks
92
+ * Adding this entry point is a workaround for initialize not currently having a context.
85
93
  */
86
- type Hydrator = (batch: LocatedNodesBatch, attachPath: UpPath) => void;
87
- export {};
94
+ export declare function prepareForInsertionContextless<TIn extends InsertableContent | undefined>(data: TIn, schema: ImplicitFieldSchema, schemaAndPolicy: SchemaAndPolicy, hydratedData: FlexTreeHydratedContextMinimal, destinationSchema: TreeFieldStoredSchema): PreparedContentInitialize;
88
95
  //# 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;AAKH,OAAO,KAAK,EACX,eAAe,EAEf,MAAM,EAGN,qBAAqB,EACrB,WAAW,EACX,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACN,KAAK,eAAe,EAEpB,KAAK,8BAA8B,EAEnC,KAAK,oBAAoB,EACzB,KAAK,mBAAmB,EAMxB,MAAM,+BAA+B,CAAC;AAEvC,OAAO,EAAS,KAAK,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAEvD,OAAO,EAEN,KAAK,oBAAoB,EACzB,KAAK,QAAQ,EACb,KAAK,sBAAsB,EAC3B,MAAM,iBAAiB,CAAC;AACzB,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAC5D,OAAO,EACN,KAAK,iBAAiB,EAEtB,MAAM,uCAAuC,CAAC;AAU/C;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CAAC,GAAG,SAAS,iBAAiB,GAAG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