@fluidframework/tree 2.1.0 → 2.3.0-288113

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 (1464) hide show
  1. package/.mocharc.customBenchmarks.cjs +33 -0
  2. package/CHANGELOG.md +297 -0
  3. package/README.md +34 -4
  4. package/api-extractor.json +17 -0
  5. package/api-report/tree.alpha.api.md +158 -28
  6. package/api-report/tree.beta.api.md +59 -28
  7. package/api-report/tree.public.api.md +59 -28
  8. package/dist/beta.d.ts +4 -1
  9. package/dist/codec/discriminatedUnions.d.ts +11 -5
  10. package/dist/codec/discriminatedUnions.d.ts.map +1 -1
  11. package/dist/codec/discriminatedUnions.js.map +1 -1
  12. package/dist/codec/index.d.ts +1 -1
  13. package/dist/codec/index.d.ts.map +1 -1
  14. package/dist/codec/index.js.map +1 -1
  15. package/dist/core/forest/editableForest.d.ts +1 -5
  16. package/dist/core/forest/editableForest.d.ts.map +1 -1
  17. package/dist/core/forest/editableForest.js.map +1 -1
  18. package/dist/core/forest/forest.d.ts +0 -6
  19. package/dist/core/forest/forest.d.ts.map +1 -1
  20. package/dist/core/forest/forest.js +0 -2
  21. package/dist/core/forest/forest.js.map +1 -1
  22. package/dist/core/index.d.ts +2 -2
  23. package/dist/core/index.d.ts.map +1 -1
  24. package/dist/core/index.js +3 -4
  25. package/dist/core/index.js.map +1 -1
  26. package/dist/core/rebase/changeRebaser.d.ts +0 -4
  27. package/dist/core/rebase/changeRebaser.d.ts.map +1 -1
  28. package/dist/core/rebase/changeRebaser.js.map +1 -1
  29. package/dist/core/rebase/index.d.ts +1 -1
  30. package/dist/core/rebase/index.d.ts.map +1 -1
  31. package/dist/core/rebase/index.js +1 -3
  32. package/dist/core/rebase/index.js.map +1 -1
  33. package/dist/core/rebase/types.d.ts +1 -8
  34. package/dist/core/rebase/types.d.ts.map +1 -1
  35. package/dist/core/rebase/types.js +1 -9
  36. package/dist/core/rebase/types.js.map +1 -1
  37. package/dist/core/rebase/utils.d.ts +0 -1
  38. package/dist/core/rebase/utils.d.ts.map +1 -1
  39. package/dist/core/rebase/utils.js +12 -7
  40. package/dist/core/rebase/utils.js.map +1 -1
  41. package/dist/core/schema-stored/multiplicity.d.ts +0 -1
  42. package/dist/core/schema-stored/multiplicity.d.ts.map +1 -1
  43. package/dist/core/schema-stored/multiplicity.js +0 -1
  44. package/dist/core/schema-stored/multiplicity.js.map +1 -1
  45. package/dist/core/schema-stored/schema.d.ts +0 -7
  46. package/dist/core/schema-stored/schema.d.ts.map +1 -1
  47. package/dist/core/schema-stored/schema.js +0 -4
  48. package/dist/core/schema-stored/schema.js.map +1 -1
  49. package/dist/core/schema-stored/storedSchemaRepository.d.ts +0 -3
  50. package/dist/core/schema-stored/storedSchemaRepository.d.ts.map +1 -1
  51. package/dist/core/schema-stored/storedSchemaRepository.js.map +1 -1
  52. package/dist/core/schema-view/view.d.ts +0 -3
  53. package/dist/core/schema-view/view.d.ts.map +1 -1
  54. package/dist/core/schema-view/view.js +0 -1
  55. package/dist/core/schema-view/view.js.map +1 -1
  56. package/dist/core/tree/anchorSet.d.ts +4 -16
  57. package/dist/core/tree/anchorSet.d.ts.map +1 -1
  58. package/dist/core/tree/anchorSet.js +12 -5
  59. package/dist/core/tree/anchorSet.js.map +1 -1
  60. package/dist/core/tree/cursor.d.ts +1 -6
  61. package/dist/core/tree/cursor.d.ts.map +1 -1
  62. package/dist/core/tree/cursor.js +0 -2
  63. package/dist/core/tree/cursor.js.map +1 -1
  64. package/dist/core/tree/delta.d.ts +0 -11
  65. package/dist/core/tree/delta.d.ts.map +1 -1
  66. package/dist/core/tree/delta.js.map +1 -1
  67. package/dist/core/tree/detachedFieldIndexCodec.d.ts.map +1 -1
  68. package/dist/core/tree/detachedFieldIndexCodec.js +3 -2
  69. package/dist/core/tree/detachedFieldIndexCodec.js.map +1 -1
  70. package/dist/core/tree/detachedFieldIndexTypes.d.ts +0 -1
  71. package/dist/core/tree/detachedFieldIndexTypes.d.ts.map +1 -1
  72. package/dist/core/tree/detachedFieldIndexTypes.js.map +1 -1
  73. package/dist/core/tree/index.d.ts +1 -1
  74. package/dist/core/tree/index.d.ts.map +1 -1
  75. package/dist/core/tree/index.js +3 -1
  76. package/dist/core/tree/index.js.map +1 -1
  77. package/dist/core/tree/mapTree.d.ts +20 -4
  78. package/dist/core/tree/mapTree.d.ts.map +1 -1
  79. package/dist/core/tree/mapTree.js +29 -0
  80. package/dist/core/tree/mapTree.js.map +1 -1
  81. package/dist/core/tree/pathTree.d.ts +0 -11
  82. package/dist/core/tree/pathTree.d.ts.map +1 -1
  83. package/dist/core/tree/pathTree.js.map +1 -1
  84. package/dist/core/tree/treeTextFormat.d.ts.map +1 -1
  85. package/dist/core/tree/treeTextFormat.js +3 -2
  86. package/dist/core/tree/treeTextFormat.js.map +1 -1
  87. package/dist/core/tree/types.d.ts +0 -11
  88. package/dist/core/tree/types.d.ts.map +1 -1
  89. package/dist/core/tree/types.js +0 -4
  90. package/dist/core/tree/types.js.map +1 -1
  91. package/dist/core/tree/visitDelta.d.ts +0 -1
  92. package/dist/core/tree/visitDelta.d.ts.map +1 -1
  93. package/dist/core/tree/visitDelta.js +2 -2
  94. package/dist/core/tree/visitDelta.js.map +1 -1
  95. package/dist/core/tree/visitPath.d.ts +0 -2
  96. package/dist/core/tree/visitPath.d.ts.map +1 -1
  97. package/dist/core/tree/visitPath.js.map +1 -1
  98. package/dist/core/tree/visitorUtils.d.ts +0 -1
  99. package/dist/core/tree/visitorUtils.d.ts.map +1 -1
  100. package/dist/core/tree/visitorUtils.js.map +1 -1
  101. package/dist/domains/index.d.ts +1 -1
  102. package/dist/domains/index.d.ts.map +1 -1
  103. package/dist/domains/index.js +2 -1
  104. package/dist/domains/index.js.map +1 -1
  105. package/dist/domains/json/index.d.ts +1 -1
  106. package/dist/domains/json/index.d.ts.map +1 -1
  107. package/dist/domains/json/index.js +2 -1
  108. package/dist/domains/json/index.js.map +1 -1
  109. package/dist/domains/json/jsonCursor.d.ts +36 -2
  110. package/dist/domains/json/jsonCursor.d.ts.map +1 -1
  111. package/dist/domains/json/jsonCursor.js +76 -5
  112. package/dist/domains/json/jsonCursor.js.map +1 -1
  113. package/dist/domains/json/jsonDomainSchema.d.ts +13 -3
  114. package/dist/domains/json/jsonDomainSchema.d.ts.map +1 -1
  115. package/dist/domains/json/jsonDomainSchema.js +12 -4
  116. package/dist/domains/json/jsonDomainSchema.js.map +1 -1
  117. package/dist/domains/leafDomain.d.ts +0 -1
  118. package/dist/domains/leafDomain.d.ts.map +1 -1
  119. package/dist/domains/leafDomain.js +0 -1
  120. package/dist/domains/leafDomain.js.map +1 -1
  121. package/dist/domains/schemaBuilder.d.ts +1 -7
  122. package/dist/domains/schemaBuilder.d.ts.map +1 -1
  123. package/dist/domains/schemaBuilder.js +0 -10
  124. package/dist/domains/schemaBuilder.js.map +1 -1
  125. package/dist/events/events.d.ts +7 -5
  126. package/dist/events/events.d.ts.map +1 -1
  127. package/dist/events/events.js +5 -3
  128. package/dist/events/events.js.map +1 -1
  129. package/dist/feature-libraries/chunked-forest/basicChunk.d.ts.map +1 -1
  130. package/dist/feature-libraries/chunked-forest/basicChunk.js +8 -3
  131. package/dist/feature-libraries/chunked-forest/basicChunk.js.map +1 -1
  132. package/dist/feature-libraries/chunked-forest/chunk.d.ts +1 -1
  133. package/dist/feature-libraries/chunked-forest/chunk.d.ts.map +1 -1
  134. package/dist/feature-libraries/chunked-forest/chunk.js.map +1 -1
  135. package/dist/feature-libraries/chunked-forest/chunkTree.js +3 -3
  136. package/dist/feature-libraries/chunked-forest/chunkTree.js.map +1 -1
  137. package/dist/feature-libraries/chunked-forest/chunkedForest.d.ts.map +1 -1
  138. package/dist/feature-libraries/chunked-forest/chunkedForest.js +7 -5
  139. package/dist/feature-libraries/chunked-forest/chunkedForest.js.map +1 -1
  140. package/dist/feature-libraries/chunked-forest/codec/chunkCodecUtilities.js +1 -1
  141. package/dist/feature-libraries/chunked-forest/codec/chunkCodecUtilities.js.map +1 -1
  142. package/dist/feature-libraries/chunked-forest/codec/chunkDecoding.d.ts.map +1 -1
  143. package/dist/feature-libraries/chunked-forest/codec/chunkDecoding.js +8 -5
  144. package/dist/feature-libraries/chunked-forest/codec/chunkDecoding.js.map +1 -1
  145. package/dist/feature-libraries/chunked-forest/uniformChunk.d.ts.map +1 -1
  146. package/dist/feature-libraries/chunked-forest/uniformChunk.js +5 -3
  147. package/dist/feature-libraries/chunked-forest/uniformChunk.js.map +1 -1
  148. package/dist/feature-libraries/default-schema/defaultEditBuilder.d.ts +12 -24
  149. package/dist/feature-libraries/default-schema/defaultEditBuilder.d.ts.map +1 -1
  150. package/dist/feature-libraries/default-schema/defaultEditBuilder.js +9 -19
  151. package/dist/feature-libraries/default-schema/defaultEditBuilder.js.map +1 -1
  152. package/dist/feature-libraries/default-schema/defaultFieldKinds.d.ts +0 -6
  153. package/dist/feature-libraries/default-schema/defaultFieldKinds.d.ts.map +1 -1
  154. package/dist/feature-libraries/default-schema/defaultFieldKinds.js +11 -1
  155. package/dist/feature-libraries/default-schema/defaultFieldKinds.js.map +1 -1
  156. package/dist/feature-libraries/default-schema/defaultSchema.d.ts +0 -1
  157. package/dist/feature-libraries/default-schema/defaultSchema.d.ts.map +1 -1
  158. package/dist/feature-libraries/default-schema/defaultSchema.js +0 -1
  159. package/dist/feature-libraries/default-schema/defaultSchema.js.map +1 -1
  160. package/dist/feature-libraries/default-schema/index.d.ts +1 -1
  161. package/dist/feature-libraries/default-schema/index.d.ts.map +1 -1
  162. package/dist/feature-libraries/default-schema/index.js +2 -1
  163. package/dist/feature-libraries/default-schema/index.js.map +1 -1
  164. package/dist/feature-libraries/default-schema/schemaChecker.d.ts +6 -0
  165. package/dist/feature-libraries/default-schema/schemaChecker.d.ts.map +1 -1
  166. package/dist/feature-libraries/default-schema/schemaChecker.js +6 -0
  167. package/dist/feature-libraries/default-schema/schemaChecker.js.map +1 -1
  168. package/dist/feature-libraries/editableTreeBinder.d.ts +0 -67
  169. package/dist/feature-libraries/editableTreeBinder.d.ts.map +1 -1
  170. package/dist/feature-libraries/editableTreeBinder.js +5 -24
  171. package/dist/feature-libraries/editableTreeBinder.js.map +1 -1
  172. package/dist/feature-libraries/fieldGenerator.d.ts +0 -3
  173. package/dist/feature-libraries/fieldGenerator.d.ts.map +1 -1
  174. package/dist/feature-libraries/fieldGenerator.js +0 -1
  175. package/dist/feature-libraries/fieldGenerator.js.map +1 -1
  176. package/dist/feature-libraries/flex-map-tree/index.d.ts +1 -1
  177. package/dist/feature-libraries/flex-map-tree/index.d.ts.map +1 -1
  178. package/dist/feature-libraries/flex-map-tree/index.js +2 -2
  179. package/dist/feature-libraries/flex-map-tree/index.js.map +1 -1
  180. package/dist/feature-libraries/flex-map-tree/mapTreeNode.d.ts +57 -51
  181. package/dist/feature-libraries/flex-map-tree/mapTreeNode.d.ts.map +1 -1
  182. package/dist/feature-libraries/flex-map-tree/mapTreeNode.js +171 -180
  183. package/dist/feature-libraries/flex-map-tree/mapTreeNode.js.map +1 -1
  184. package/dist/feature-libraries/flex-tree/context.d.ts +0 -1
  185. package/dist/feature-libraries/flex-tree/context.d.ts.map +1 -1
  186. package/dist/feature-libraries/flex-tree/context.js.map +1 -1
  187. package/dist/feature-libraries/flex-tree/flexTreeTypes.d.ts +17 -373
  188. package/dist/feature-libraries/flex-tree/flexTreeTypes.d.ts.map +1 -1
  189. package/dist/feature-libraries/flex-tree/flexTreeTypes.js +1 -34
  190. package/dist/feature-libraries/flex-tree/flexTreeTypes.js.map +1 -1
  191. package/dist/feature-libraries/flex-tree/index.d.ts +2 -2
  192. package/dist/feature-libraries/flex-tree/index.d.ts.map +1 -1
  193. package/dist/feature-libraries/flex-tree/index.js +1 -3
  194. package/dist/feature-libraries/flex-tree/index.js.map +1 -1
  195. package/dist/feature-libraries/flex-tree/lazyField.d.ts +9 -27
  196. package/dist/feature-libraries/flex-tree/lazyField.d.ts.map +1 -1
  197. package/dist/feature-libraries/flex-tree/lazyField.js +26 -102
  198. package/dist/feature-libraries/flex-tree/lazyField.js.map +1 -1
  199. package/dist/feature-libraries/flex-tree/lazyNode.d.ts +3 -18
  200. package/dist/feature-libraries/flex-tree/lazyNode.d.ts.map +1 -1
  201. package/dist/feature-libraries/flex-tree/lazyNode.js +2 -126
  202. package/dist/feature-libraries/flex-tree/lazyNode.js.map +1 -1
  203. package/dist/feature-libraries/flex-tree/treeEvents.d.ts +0 -2
  204. package/dist/feature-libraries/flex-tree/treeEvents.d.ts.map +1 -1
  205. package/dist/feature-libraries/flex-tree/treeEvents.js.map +1 -1
  206. package/dist/feature-libraries/flex-tree/utilities.d.ts +2 -1
  207. package/dist/feature-libraries/flex-tree/utilities.d.ts.map +1 -1
  208. package/dist/feature-libraries/flex-tree/utilities.js +4 -0
  209. package/dist/feature-libraries/flex-tree/utilities.js.map +1 -1
  210. package/dist/feature-libraries/forest-summary/codec.js +2 -2
  211. package/dist/feature-libraries/forest-summary/codec.js.map +1 -1
  212. package/dist/feature-libraries/index.d.ts +6 -8
  213. package/dist/feature-libraries/index.d.ts.map +1 -1
  214. package/dist/feature-libraries/index.js +7 -20
  215. package/dist/feature-libraries/index.js.map +1 -1
  216. package/dist/feature-libraries/mapTreeCursor.d.ts +6 -2
  217. package/dist/feature-libraries/mapTreeCursor.d.ts.map +1 -1
  218. package/dist/feature-libraries/mapTreeCursor.js +9 -1
  219. package/dist/feature-libraries/mapTreeCursor.js.map +1 -1
  220. package/dist/feature-libraries/memoizedIdRangeAllocator.d.ts +0 -4
  221. package/dist/feature-libraries/memoizedIdRangeAllocator.d.ts.map +1 -1
  222. package/dist/feature-libraries/memoizedIdRangeAllocator.js +0 -1
  223. package/dist/feature-libraries/memoizedIdRangeAllocator.js.map +1 -1
  224. package/dist/feature-libraries/modular-schema/crossFieldQueries.d.ts +0 -2
  225. package/dist/feature-libraries/modular-schema/crossFieldQueries.d.ts.map +1 -1
  226. package/dist/feature-libraries/modular-schema/crossFieldQueries.js +0 -1
  227. package/dist/feature-libraries/modular-schema/crossFieldQueries.js.map +1 -1
  228. package/dist/feature-libraries/modular-schema/discrepancies.d.ts +18 -0
  229. package/dist/feature-libraries/modular-schema/discrepancies.d.ts.map +1 -1
  230. package/dist/feature-libraries/modular-schema/discrepancies.js +105 -2
  231. package/dist/feature-libraries/modular-schema/discrepancies.js.map +1 -1
  232. package/dist/feature-libraries/modular-schema/fieldChangeHandler.d.ts +0 -8
  233. package/dist/feature-libraries/modular-schema/fieldChangeHandler.d.ts.map +1 -1
  234. package/dist/feature-libraries/modular-schema/fieldChangeHandler.js +0 -1
  235. package/dist/feature-libraries/modular-schema/fieldChangeHandler.js.map +1 -1
  236. package/dist/feature-libraries/modular-schema/fieldKind.d.ts +1 -3
  237. package/dist/feature-libraries/modular-schema/fieldKind.d.ts.map +1 -1
  238. package/dist/feature-libraries/modular-schema/fieldKind.js +1 -2
  239. package/dist/feature-libraries/modular-schema/fieldKind.js.map +1 -1
  240. package/dist/feature-libraries/modular-schema/genericFieldKind.d.ts +1 -2
  241. package/dist/feature-libraries/modular-schema/genericFieldKind.d.ts.map +1 -1
  242. package/dist/feature-libraries/modular-schema/genericFieldKind.js +57 -85
  243. package/dist/feature-libraries/modular-schema/genericFieldKind.js.map +1 -1
  244. package/dist/feature-libraries/modular-schema/genericFieldKindCodecs.d.ts +1 -1
  245. package/dist/feature-libraries/modular-schema/genericFieldKindCodecs.d.ts.map +1 -1
  246. package/dist/feature-libraries/modular-schema/genericFieldKindCodecs.js +5 -8
  247. package/dist/feature-libraries/modular-schema/genericFieldKindCodecs.js.map +1 -1
  248. package/dist/feature-libraries/modular-schema/genericFieldKindTypes.d.ts +3 -14
  249. package/dist/feature-libraries/modular-schema/genericFieldKindTypes.d.ts.map +1 -1
  250. package/dist/feature-libraries/modular-schema/genericFieldKindTypes.js +6 -0
  251. package/dist/feature-libraries/modular-schema/genericFieldKindTypes.js.map +1 -1
  252. package/dist/feature-libraries/modular-schema/index.d.ts +2 -2
  253. package/dist/feature-libraries/modular-schema/index.d.ts.map +1 -1
  254. package/dist/feature-libraries/modular-schema/index.js +2 -1
  255. package/dist/feature-libraries/modular-schema/index.js.map +1 -1
  256. package/dist/feature-libraries/modular-schema/modularChangeCodecs.d.ts.map +1 -1
  257. package/dist/feature-libraries/modular-schema/modularChangeCodecs.js +39 -22
  258. package/dist/feature-libraries/modular-schema/modularChangeCodecs.js.map +1 -1
  259. package/dist/feature-libraries/modular-schema/modularChangeFamily.d.ts +9 -8
  260. package/dist/feature-libraries/modular-schema/modularChangeFamily.d.ts.map +1 -1
  261. package/dist/feature-libraries/modular-schema/modularChangeFamily.js +192 -228
  262. package/dist/feature-libraries/modular-schema/modularChangeFamily.js.map +1 -1
  263. package/dist/feature-libraries/modular-schema/modularChangeTypes.d.ts +8 -14
  264. package/dist/feature-libraries/modular-schema/modularChangeTypes.d.ts.map +1 -1
  265. package/dist/feature-libraries/modular-schema/modularChangeTypes.js.map +1 -1
  266. package/dist/feature-libraries/node-key/nodeKey.d.ts +0 -4
  267. package/dist/feature-libraries/node-key/nodeKey.d.ts.map +1 -1
  268. package/dist/feature-libraries/node-key/nodeKey.js +0 -2
  269. package/dist/feature-libraries/node-key/nodeKey.js.map +1 -1
  270. package/dist/feature-libraries/node-key/nodeKeyManager.d.ts +0 -1
  271. package/dist/feature-libraries/node-key/nodeKeyManager.d.ts.map +1 -1
  272. package/dist/feature-libraries/node-key/nodeKeyManager.js.map +1 -1
  273. package/dist/feature-libraries/object-forest/objectForest.d.ts.map +1 -1
  274. package/dist/feature-libraries/object-forest/objectForest.js +1 -10
  275. package/dist/feature-libraries/object-forest/objectForest.js.map +1 -1
  276. package/dist/feature-libraries/optional-field/optionalFieldChangeFormatV1.d.ts +6 -6
  277. package/dist/feature-libraries/optional-field/optionalFieldChangeFormatV1.d.ts.map +1 -1
  278. package/dist/feature-libraries/optional-field/optionalFieldChangeFormatV2.d.ts +7 -7
  279. package/dist/feature-libraries/optional-field/optionalFieldChangeFormatV2.d.ts.map +1 -1
  280. package/dist/feature-libraries/schemaBuilderBase.d.ts +2 -28
  281. package/dist/feature-libraries/schemaBuilderBase.d.ts.map +1 -1
  282. package/dist/feature-libraries/schemaBuilderBase.js +1 -27
  283. package/dist/feature-libraries/schemaBuilderBase.js.map +1 -1
  284. package/dist/feature-libraries/sequence-field/compose.d.ts.map +1 -1
  285. package/dist/feature-libraries/sequence-field/compose.js +24 -21
  286. package/dist/feature-libraries/sequence-field/compose.js.map +1 -1
  287. package/dist/feature-libraries/sequence-field/formatV2.d.ts +3 -3
  288. package/dist/feature-libraries/sequence-field/formatV2.d.ts.map +1 -1
  289. package/dist/feature-libraries/sequence-field/formatV2.js +7 -6
  290. package/dist/feature-libraries/sequence-field/formatV2.js.map +1 -1
  291. package/dist/feature-libraries/sequence-field/formatV3.d.ts +195 -0
  292. package/dist/feature-libraries/sequence-field/formatV3.d.ts.map +1 -0
  293. package/dist/feature-libraries/sequence-field/formatV3.js +23 -0
  294. package/dist/feature-libraries/sequence-field/formatV3.js.map +1 -0
  295. package/dist/feature-libraries/sequence-field/helperTypes.d.ts +11 -0
  296. package/dist/feature-libraries/sequence-field/helperTypes.d.ts.map +1 -1
  297. package/dist/feature-libraries/sequence-field/helperTypes.js.map +1 -1
  298. package/dist/feature-libraries/sequence-field/index.d.ts +1 -1
  299. package/dist/feature-libraries/sequence-field/index.d.ts.map +1 -1
  300. package/dist/feature-libraries/sequence-field/index.js.map +1 -1
  301. package/dist/feature-libraries/sequence-field/invert.d.ts.map +1 -1
  302. package/dist/feature-libraries/sequence-field/invert.js +21 -13
  303. package/dist/feature-libraries/sequence-field/invert.js.map +1 -1
  304. package/dist/feature-libraries/sequence-field/markQueue.js +1 -1
  305. package/dist/feature-libraries/sequence-field/markQueue.js.map +1 -1
  306. package/dist/feature-libraries/sequence-field/moveEffectTable.d.ts +2 -2
  307. package/dist/feature-libraries/sequence-field/moveEffectTable.d.ts.map +1 -1
  308. package/dist/feature-libraries/sequence-field/moveEffectTable.js.map +1 -1
  309. package/dist/feature-libraries/sequence-field/rebase.d.ts.map +1 -1
  310. package/dist/feature-libraries/sequence-field/rebase.js +24 -6
  311. package/dist/feature-libraries/sequence-field/rebase.js.map +1 -1
  312. package/dist/feature-libraries/sequence-field/replaceRevisions.d.ts.map +1 -1
  313. package/dist/feature-libraries/sequence-field/replaceRevisions.js +16 -3
  314. package/dist/feature-libraries/sequence-field/replaceRevisions.js.map +1 -1
  315. package/dist/feature-libraries/sequence-field/sequenceFieldCodecV1.d.ts.map +1 -1
  316. package/dist/feature-libraries/sequence-field/sequenceFieldCodecV1.js +38 -4
  317. package/dist/feature-libraries/sequence-field/sequenceFieldCodecV1.js.map +1 -1
  318. package/dist/feature-libraries/sequence-field/sequenceFieldCodecV2.d.ts +4 -1
  319. package/dist/feature-libraries/sequence-field/sequenceFieldCodecV2.d.ts.map +1 -1
  320. package/dist/feature-libraries/sequence-field/sequenceFieldCodecV2.js +54 -9
  321. package/dist/feature-libraries/sequence-field/sequenceFieldCodecV2.js.map +1 -1
  322. package/dist/feature-libraries/sequence-field/sequenceFieldCodecV3.d.ts +11 -0
  323. package/dist/feature-libraries/sequence-field/sequenceFieldCodecV3.d.ts.map +1 -0
  324. package/dist/feature-libraries/sequence-field/sequenceFieldCodecV3.js +85 -0
  325. package/dist/feature-libraries/sequence-field/sequenceFieldCodecV3.js.map +1 -0
  326. package/dist/feature-libraries/sequence-field/sequenceFieldCodecs.d.ts.map +1 -1
  327. package/dist/feature-libraries/sequence-field/sequenceFieldCodecs.js +2 -0
  328. package/dist/feature-libraries/sequence-field/sequenceFieldCodecs.js.map +1 -1
  329. package/dist/feature-libraries/sequence-field/sequenceFieldToDelta.d.ts.map +1 -1
  330. package/dist/feature-libraries/sequence-field/sequenceFieldToDelta.js +4 -1
  331. package/dist/feature-libraries/sequence-field/sequenceFieldToDelta.js.map +1 -1
  332. package/dist/feature-libraries/sequence-field/types.d.ts +23 -4
  333. package/dist/feature-libraries/sequence-field/types.d.ts.map +1 -1
  334. package/dist/feature-libraries/sequence-field/types.js.map +1 -1
  335. package/dist/feature-libraries/sequence-field/utils.d.ts +5 -4
  336. package/dist/feature-libraries/sequence-field/utils.d.ts.map +1 -1
  337. package/dist/feature-libraries/sequence-field/utils.js +70 -42
  338. package/dist/feature-libraries/sequence-field/utils.js.map +1 -1
  339. package/dist/feature-libraries/storedToViewSchema.d.ts +0 -1
  340. package/dist/feature-libraries/storedToViewSchema.d.ts.map +1 -1
  341. package/dist/feature-libraries/storedToViewSchema.js +0 -1
  342. package/dist/feature-libraries/storedToViewSchema.js.map +1 -1
  343. package/dist/feature-libraries/treeCursorUtils.d.ts +0 -6
  344. package/dist/feature-libraries/treeCursorUtils.d.ts.map +1 -1
  345. package/dist/feature-libraries/treeCursorUtils.js +8 -6
  346. package/dist/feature-libraries/treeCursorUtils.js.map +1 -1
  347. package/dist/feature-libraries/treeTextCursor.d.ts +0 -2
  348. package/dist/feature-libraries/treeTextCursor.d.ts.map +1 -1
  349. package/dist/feature-libraries/treeTextCursor.js +0 -2
  350. package/dist/feature-libraries/treeTextCursor.js.map +1 -1
  351. package/dist/feature-libraries/typed-schema/flexList.d.ts +0 -3
  352. package/dist/feature-libraries/typed-schema/flexList.d.ts.map +1 -1
  353. package/dist/feature-libraries/typed-schema/flexList.js.map +1 -1
  354. package/dist/feature-libraries/typed-schema/index.d.ts +1 -1
  355. package/dist/feature-libraries/typed-schema/index.d.ts.map +1 -1
  356. package/dist/feature-libraries/typed-schema/index.js +1 -3
  357. package/dist/feature-libraries/typed-schema/index.js.map +1 -1
  358. package/dist/feature-libraries/typed-schema/schemaCollection.d.ts.map +1 -1
  359. package/dist/feature-libraries/typed-schema/schemaCollection.js +0 -4
  360. package/dist/feature-libraries/typed-schema/schemaCollection.js.map +1 -1
  361. package/dist/feature-libraries/typed-schema/typedTreeSchema.d.ts +2 -41
  362. package/dist/feature-libraries/typed-schema/typedTreeSchema.d.ts.map +1 -1
  363. package/dist/feature-libraries/typed-schema/typedTreeSchema.js +1 -40
  364. package/dist/feature-libraries/typed-schema/typedTreeSchema.js.map +1 -1
  365. package/dist/feature-libraries/typed-schema/view.d.ts +0 -1
  366. package/dist/feature-libraries/typed-schema/view.d.ts.map +1 -1
  367. package/dist/feature-libraries/typed-schema/view.js.map +1 -1
  368. package/dist/index.d.ts +8 -9
  369. package/dist/index.d.ts.map +1 -1
  370. package/dist/index.js +36 -90
  371. package/dist/index.js.map +1 -1
  372. package/dist/internalTypes.d.ts +1 -1
  373. package/dist/internalTypes.d.ts.map +1 -1
  374. package/dist/internalTypes.js.map +1 -1
  375. package/dist/packageVersion.d.ts +1 -1
  376. package/dist/packageVersion.d.ts.map +1 -1
  377. package/dist/packageVersion.js +1 -1
  378. package/dist/packageVersion.js.map +1 -1
  379. package/dist/public.d.ts +4 -1
  380. package/dist/shared-tree/schematizeTree.d.ts +2 -11
  381. package/dist/shared-tree/schematizeTree.d.ts.map +1 -1
  382. package/dist/shared-tree/schematizeTree.js +13 -2
  383. package/dist/shared-tree/schematizeTree.js.map +1 -1
  384. package/dist/shared-tree/schematizingTreeView.d.ts +4 -4
  385. package/dist/shared-tree/schematizingTreeView.d.ts.map +1 -1
  386. package/dist/shared-tree/schematizingTreeView.js +2 -2
  387. package/dist/shared-tree/schematizingTreeView.js.map +1 -1
  388. package/dist/shared-tree/sharedTree.d.ts +4 -17
  389. package/dist/shared-tree/sharedTree.d.ts.map +1 -1
  390. package/dist/shared-tree/sharedTree.js +4 -8
  391. package/dist/shared-tree/sharedTree.js.map +1 -1
  392. package/dist/shared-tree/sharedTreeChangeCodecs.d.ts.map +1 -1
  393. package/dist/shared-tree/sharedTreeChangeCodecs.js +4 -0
  394. package/dist/shared-tree/sharedTreeChangeCodecs.js.map +1 -1
  395. package/dist/shared-tree/sharedTreeChangeFamily.js +2 -2
  396. package/dist/shared-tree/sharedTreeChangeFamily.js.map +1 -1
  397. package/dist/shared-tree/sharedTreeEditBuilder.d.ts +0 -2
  398. package/dist/shared-tree/sharedTreeEditBuilder.d.ts.map +1 -1
  399. package/dist/shared-tree/sharedTreeEditBuilder.js.map +1 -1
  400. package/dist/shared-tree/treeApi.js +2 -2
  401. package/dist/shared-tree/treeApi.js.map +1 -1
  402. package/dist/shared-tree/treeCheckout.d.ts +0 -5
  403. package/dist/shared-tree/treeCheckout.d.ts.map +1 -1
  404. package/dist/shared-tree/treeCheckout.js +5 -3
  405. package/dist/shared-tree/treeCheckout.js.map +1 -1
  406. package/dist/shared-tree/treeView.d.ts +3 -6
  407. package/dist/shared-tree/treeView.d.ts.map +1 -1
  408. package/dist/shared-tree/treeView.js.map +1 -1
  409. package/dist/shared-tree-core/branch.d.ts.map +1 -1
  410. package/dist/shared-tree-core/branch.js +11 -6
  411. package/dist/shared-tree-core/branch.js.map +1 -1
  412. package/dist/shared-tree-core/defaultResubmitMachine.js +3 -3
  413. package/dist/shared-tree-core/defaultResubmitMachine.js.map +1 -1
  414. package/dist/shared-tree-core/editManagerCodecs.d.ts.map +1 -1
  415. package/dist/shared-tree-core/editManagerCodecs.js +1 -0
  416. package/dist/shared-tree-core/editManagerCodecs.js.map +1 -1
  417. package/dist/shared-tree-core/editManagerFormat.d.ts +2 -2
  418. package/dist/shared-tree-core/editManagerFormat.d.ts.map +1 -1
  419. package/dist/shared-tree-core/editManagerFormat.js +6 -1
  420. package/dist/shared-tree-core/editManagerFormat.js.map +1 -1
  421. package/dist/shared-tree-core/messageCodecs.d.ts.map +1 -1
  422. package/dist/shared-tree-core/messageCodecs.js +1 -0
  423. package/dist/shared-tree-core/messageCodecs.js.map +1 -1
  424. package/dist/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
  425. package/dist/shared-tree-core/sharedTreeCore.js +3 -1
  426. package/dist/shared-tree-core/sharedTreeCore.js.map +1 -1
  427. package/dist/simple-tree/api/create.d.ts +54 -0
  428. package/dist/simple-tree/api/create.d.ts.map +1 -0
  429. package/dist/simple-tree/api/create.js +99 -0
  430. package/dist/simple-tree/api/create.js.map +1 -0
  431. package/dist/simple-tree/api/index.d.ts +12 -0
  432. package/dist/simple-tree/api/index.d.ts.map +1 -0
  433. package/dist/simple-tree/api/index.js +28 -0
  434. package/dist/simple-tree/api/index.js.map +1 -0
  435. package/{lib/simple-tree → dist/simple-tree/api}/schemaCreationUtilities.d.ts +7 -4
  436. package/dist/simple-tree/api/schemaCreationUtilities.d.ts.map +1 -0
  437. package/dist/simple-tree/{schemaCreationUtilities.js → api/schemaCreationUtilities.js} +1 -1
  438. package/dist/simple-tree/api/schemaCreationUtilities.js.map +1 -0
  439. package/dist/simple-tree/{schemaFactory.d.ts → api/schemaFactory.d.ts} +15 -14
  440. package/dist/simple-tree/api/schemaFactory.d.ts.map +1 -0
  441. package/dist/simple-tree/{schemaFactory.js → api/schemaFactory.js} +10 -9
  442. package/dist/simple-tree/api/schemaFactory.js.map +1 -0
  443. package/{lib/simple-tree → dist/simple-tree/api}/schemaFactoryRecursive.d.ts +40 -7
  444. package/dist/simple-tree/api/schemaFactoryRecursive.d.ts.map +1 -0
  445. package/dist/simple-tree/{schemaFactoryRecursive.js → api/schemaFactoryRecursive.js} +1 -1
  446. package/dist/simple-tree/api/schemaFactoryRecursive.js.map +1 -0
  447. package/dist/simple-tree/api/testRecursiveDomain.d.ts +62 -0
  448. package/dist/simple-tree/api/testRecursiveDomain.d.ts.map +1 -0
  449. package/dist/simple-tree/api/testRecursiveDomain.js.map +1 -0
  450. package/{lib/simple-tree → dist/simple-tree/api}/tree.d.ts +111 -20
  451. package/dist/simple-tree/api/tree.d.ts.map +1 -0
  452. package/dist/simple-tree/api/tree.js +173 -0
  453. package/dist/simple-tree/api/tree.js.map +1 -0
  454. package/dist/simple-tree/{treeNodeApi.d.ts → api/treeNodeApi.d.ts} +7 -6
  455. package/dist/simple-tree/api/treeNodeApi.d.ts.map +1 -0
  456. package/dist/simple-tree/{treeNodeApi.js → api/treeNodeApi.js} +57 -21
  457. package/dist/simple-tree/api/treeNodeApi.js.map +1 -0
  458. package/dist/simple-tree/api/verboseTree.d.ts +136 -0
  459. package/dist/simple-tree/api/verboseTree.d.ts.map +1 -0
  460. package/dist/simple-tree/api/verboseTree.js +220 -0
  461. package/dist/simple-tree/api/verboseTree.js.map +1 -0
  462. package/dist/simple-tree/arrayNode.d.ts +3 -3
  463. package/dist/simple-tree/arrayNode.d.ts.map +1 -1
  464. package/dist/simple-tree/arrayNode.js +72 -85
  465. package/dist/simple-tree/arrayNode.js.map +1 -1
  466. package/dist/simple-tree/core/index.d.ts +10 -0
  467. package/dist/simple-tree/core/index.d.ts.map +1 -0
  468. package/dist/simple-tree/core/index.js +27 -0
  469. package/dist/simple-tree/core/index.js.map +1 -0
  470. package/{lib/simple-tree → dist/simple-tree/core}/schemaCaching.d.ts +2 -9
  471. package/dist/simple-tree/core/schemaCaching.d.ts.map +1 -0
  472. package/dist/simple-tree/{schemaCaching.js → core/schemaCaching.js} +2 -23
  473. package/dist/simple-tree/core/schemaCaching.js.map +1 -0
  474. package/dist/simple-tree/core/treeNodeKernel.d.ts +70 -0
  475. package/dist/simple-tree/core/treeNodeKernel.d.ts.map +1 -0
  476. package/dist/simple-tree/core/treeNodeKernel.js +164 -0
  477. package/dist/simple-tree/core/treeNodeKernel.js.map +1 -0
  478. package/dist/simple-tree/core/treeNodeSchema.d.ts +149 -0
  479. package/dist/simple-tree/core/treeNodeSchema.d.ts.map +1 -0
  480. package/dist/simple-tree/core/treeNodeSchema.js +35 -0
  481. package/dist/simple-tree/core/treeNodeSchema.js.map +1 -0
  482. package/{lib/simple-tree → dist/simple-tree/core}/types.d.ts +50 -79
  483. package/dist/simple-tree/core/types.d.ts.map +1 -0
  484. package/dist/simple-tree/core/types.js +117 -0
  485. package/dist/simple-tree/core/types.js.map +1 -0
  486. package/dist/simple-tree/core/withType.d.ts +82 -0
  487. package/dist/simple-tree/core/withType.d.ts.map +1 -0
  488. package/dist/simple-tree/core/withType.js +39 -0
  489. package/dist/simple-tree/core/withType.js.map +1 -0
  490. package/dist/simple-tree/getJsonSchema.d.ts +55 -0
  491. package/dist/simple-tree/getJsonSchema.d.ts.map +1 -0
  492. package/dist/simple-tree/getJsonSchema.js +69 -0
  493. package/dist/simple-tree/getJsonSchema.js.map +1 -0
  494. package/dist/simple-tree/getSimpleFieldSchema.d.ts +14 -0
  495. package/dist/simple-tree/getSimpleFieldSchema.d.ts.map +1 -0
  496. package/dist/simple-tree/getSimpleFieldSchema.js +29 -0
  497. package/dist/simple-tree/getSimpleFieldSchema.js.map +1 -0
  498. package/dist/simple-tree/getSimpleSchema.d.ts +58 -0
  499. package/dist/simple-tree/getSimpleSchema.d.ts.map +1 -0
  500. package/dist/simple-tree/getSimpleSchema.js +68 -0
  501. package/dist/simple-tree/getSimpleSchema.js.map +1 -0
  502. package/dist/simple-tree/index.d.ts +12 -13
  503. package/dist/simple-tree/index.d.ts.map +1 -1
  504. package/dist/simple-tree/index.js +26 -23
  505. package/dist/simple-tree/index.js.map +1 -1
  506. package/dist/simple-tree/jsonSchema.d.ts +206 -0
  507. package/dist/simple-tree/jsonSchema.d.ts.map +1 -0
  508. package/dist/{feature-libraries/schema-aware/index.js → simple-tree/jsonSchema.js} +1 -1
  509. package/dist/simple-tree/jsonSchema.js.map +1 -0
  510. package/dist/simple-tree/leafNodeSchema.d.ts +1 -1
  511. package/dist/simple-tree/leafNodeSchema.d.ts.map +1 -1
  512. package/dist/simple-tree/leafNodeSchema.js +3 -4
  513. package/dist/simple-tree/leafNodeSchema.js.map +1 -1
  514. package/dist/simple-tree/mapNode.d.ts +9 -3
  515. package/dist/simple-tree/mapNode.d.ts.map +1 -1
  516. package/dist/simple-tree/mapNode.js +33 -35
  517. package/dist/simple-tree/mapNode.js.map +1 -1
  518. package/dist/simple-tree/objectNode.d.ts +18 -16
  519. package/dist/simple-tree/objectNode.d.ts.map +1 -1
  520. package/dist/simple-tree/objectNode.js +43 -44
  521. package/dist/simple-tree/objectNode.js.map +1 -1
  522. package/dist/simple-tree/objectNodeTypes.d.ts +38 -0
  523. package/dist/simple-tree/objectNodeTypes.d.ts.map +1 -0
  524. package/dist/simple-tree/objectNodeTypes.js +19 -0
  525. package/dist/simple-tree/objectNodeTypes.js.map +1 -0
  526. package/dist/simple-tree/proxies.d.ts +6 -25
  527. package/dist/simple-tree/proxies.d.ts.map +1 -1
  528. package/dist/simple-tree/proxies.js +50 -63
  529. package/dist/simple-tree/proxies.js.map +1 -1
  530. package/dist/simple-tree/proxyBinding.d.ts +45 -22
  531. package/dist/simple-tree/proxyBinding.d.ts.map +1 -1
  532. package/dist/simple-tree/proxyBinding.js +94 -59
  533. package/dist/simple-tree/proxyBinding.js.map +1 -1
  534. package/dist/simple-tree/schemaTypes.d.ts +10 -159
  535. package/dist/simple-tree/schemaTypes.d.ts.map +1 -1
  536. package/dist/simple-tree/schemaTypes.js +11 -42
  537. package/dist/simple-tree/schemaTypes.js.map +1 -1
  538. package/dist/simple-tree/simpleSchema.d.ts +124 -0
  539. package/dist/simple-tree/simpleSchema.d.ts.map +1 -0
  540. package/dist/{feature-libraries/schema-aware/schemaAware.js → simple-tree/simpleSchema.js} +1 -1
  541. package/dist/simple-tree/simpleSchema.js.map +1 -0
  542. package/dist/simple-tree/simpleSchemaToJsonSchema.d.ts +12 -0
  543. package/dist/simple-tree/simpleSchemaToJsonSchema.d.ts.map +1 -0
  544. package/dist/simple-tree/simpleSchemaToJsonSchema.js +146 -0
  545. package/dist/simple-tree/simpleSchemaToJsonSchema.js.map +1 -0
  546. package/dist/simple-tree/toFlexSchema.d.ts +4 -12
  547. package/dist/simple-tree/toFlexSchema.d.ts.map +1 -1
  548. package/dist/simple-tree/toFlexSchema.js +42 -52
  549. package/dist/simple-tree/toFlexSchema.js.map +1 -1
  550. package/dist/simple-tree/toMapTree.d.ts +39 -39
  551. package/dist/simple-tree/toMapTree.d.ts.map +1 -1
  552. package/dist/simple-tree/toMapTree.js +227 -171
  553. package/dist/simple-tree/toMapTree.js.map +1 -1
  554. package/dist/simple-tree/treeNodeValid.d.ts +74 -0
  555. package/dist/simple-tree/treeNodeValid.d.ts.map +1 -0
  556. package/dist/simple-tree/{types.js → treeNodeValid.js} +18 -111
  557. package/dist/simple-tree/treeNodeValid.js.map +1 -0
  558. package/dist/simple-tree/typesUnsafe.d.ts +35 -4
  559. package/dist/simple-tree/typesUnsafe.d.ts.map +1 -1
  560. package/dist/simple-tree/typesUnsafe.js.map +1 -1
  561. package/dist/simple-tree/viewSchemaToSimpleSchema.d.ts +11 -0
  562. package/dist/simple-tree/viewSchemaToSimpleSchema.d.ts.map +1 -0
  563. package/dist/simple-tree/viewSchemaToSimpleSchema.js +171 -0
  564. package/dist/simple-tree/viewSchemaToSimpleSchema.js.map +1 -0
  565. package/dist/util/brand.d.ts +0 -3
  566. package/dist/util/brand.d.ts.map +1 -1
  567. package/dist/util/brand.js +1 -2
  568. package/dist/util/brand.js.map +1 -1
  569. package/dist/util/brandedMap.d.ts +0 -5
  570. package/dist/util/brandedMap.d.ts.map +1 -1
  571. package/dist/util/brandedMap.js +0 -1
  572. package/dist/util/brandedMap.js.map +1 -1
  573. package/dist/util/idAllocator.d.ts +0 -2
  574. package/dist/util/idAllocator.d.ts.map +1 -1
  575. package/dist/util/idAllocator.js +0 -1
  576. package/dist/util/idAllocator.js.map +1 -1
  577. package/dist/util/index.d.ts +2 -2
  578. package/dist/util/index.d.ts.map +1 -1
  579. package/dist/util/index.js +4 -2
  580. package/dist/util/index.js.map +1 -1
  581. package/dist/util/nestedMap.d.ts +5 -19
  582. package/dist/util/nestedMap.d.ts.map +1 -1
  583. package/dist/util/nestedMap.js +17 -17
  584. package/dist/util/nestedMap.js.map +1 -1
  585. package/dist/util/opaque.d.ts +0 -4
  586. package/dist/util/opaque.d.ts.map +1 -1
  587. package/dist/util/opaque.js +0 -2
  588. package/dist/util/opaque.js.map +1 -1
  589. package/dist/util/rangeMap.d.ts +0 -2
  590. package/dist/util/rangeMap.d.ts.map +1 -1
  591. package/dist/util/rangeMap.js +4 -3
  592. package/dist/util/rangeMap.js.map +1 -1
  593. package/dist/util/transactionResult.d.ts +0 -1
  594. package/dist/util/transactionResult.d.ts.map +1 -1
  595. package/dist/util/transactionResult.js +0 -1
  596. package/dist/util/transactionResult.js.map +1 -1
  597. package/dist/util/typeCheck.d.ts +2 -20
  598. package/dist/util/typeCheck.d.ts.map +1 -1
  599. package/dist/util/typeCheck.js.map +1 -1
  600. package/dist/util/typeCheckTests.d.ts +4 -4
  601. package/dist/util/typeCheckTests.d.ts.map +1 -1
  602. package/dist/util/typeCheckTests.js.map +1 -1
  603. package/dist/util/typeUtils.d.ts +0 -7
  604. package/dist/util/typeUtils.d.ts.map +1 -1
  605. package/dist/util/typeUtils.js.map +1 -1
  606. package/dist/util/utils.d.ts +6 -8
  607. package/dist/util/utils.d.ts.map +1 -1
  608. package/dist/util/utils.js +14 -5
  609. package/dist/util/utils.js.map +1 -1
  610. package/lib/beta.d.ts +4 -1
  611. package/lib/codec/discriminatedUnions.d.ts +11 -5
  612. package/lib/codec/discriminatedUnions.d.ts.map +1 -1
  613. package/lib/codec/discriminatedUnions.js.map +1 -1
  614. package/lib/codec/index.d.ts +1 -1
  615. package/lib/codec/index.d.ts.map +1 -1
  616. package/lib/codec/index.js +1 -1
  617. package/lib/codec/index.js.map +1 -1
  618. package/lib/core/forest/editableForest.d.ts +1 -5
  619. package/lib/core/forest/editableForest.d.ts.map +1 -1
  620. package/lib/core/forest/editableForest.js.map +1 -1
  621. package/lib/core/forest/forest.d.ts +0 -6
  622. package/lib/core/forest/forest.d.ts.map +1 -1
  623. package/lib/core/forest/forest.js +0 -2
  624. package/lib/core/forest/forest.js.map +1 -1
  625. package/lib/core/index.d.ts +2 -2
  626. package/lib/core/index.d.ts.map +1 -1
  627. package/lib/core/index.js +2 -2
  628. package/lib/core/index.js.map +1 -1
  629. package/lib/core/rebase/changeRebaser.d.ts +0 -4
  630. package/lib/core/rebase/changeRebaser.d.ts.map +1 -1
  631. package/lib/core/rebase/changeRebaser.js.map +1 -1
  632. package/lib/core/rebase/index.d.ts +1 -1
  633. package/lib/core/rebase/index.d.ts.map +1 -1
  634. package/lib/core/rebase/index.js +1 -1
  635. package/lib/core/rebase/index.js.map +1 -1
  636. package/lib/core/rebase/types.d.ts +1 -8
  637. package/lib/core/rebase/types.d.ts.map +1 -1
  638. package/lib/core/rebase/types.js +1 -7
  639. package/lib/core/rebase/types.js.map +1 -1
  640. package/lib/core/rebase/utils.d.ts +0 -1
  641. package/lib/core/rebase/utils.d.ts.map +1 -1
  642. package/lib/core/rebase/utils.js +13 -8
  643. package/lib/core/rebase/utils.js.map +1 -1
  644. package/lib/core/schema-stored/multiplicity.d.ts +0 -1
  645. package/lib/core/schema-stored/multiplicity.d.ts.map +1 -1
  646. package/lib/core/schema-stored/multiplicity.js +0 -1
  647. package/lib/core/schema-stored/multiplicity.js.map +1 -1
  648. package/lib/core/schema-stored/schema.d.ts +0 -7
  649. package/lib/core/schema-stored/schema.d.ts.map +1 -1
  650. package/lib/core/schema-stored/schema.js +0 -4
  651. package/lib/core/schema-stored/schema.js.map +1 -1
  652. package/lib/core/schema-stored/storedSchemaRepository.d.ts +0 -3
  653. package/lib/core/schema-stored/storedSchemaRepository.d.ts.map +1 -1
  654. package/lib/core/schema-stored/storedSchemaRepository.js.map +1 -1
  655. package/lib/core/schema-view/view.d.ts +0 -3
  656. package/lib/core/schema-view/view.d.ts.map +1 -1
  657. package/lib/core/schema-view/view.js +0 -1
  658. package/lib/core/schema-view/view.js.map +1 -1
  659. package/lib/core/tree/anchorSet.d.ts +4 -16
  660. package/lib/core/tree/anchorSet.d.ts.map +1 -1
  661. package/lib/core/tree/anchorSet.js +12 -5
  662. package/lib/core/tree/anchorSet.js.map +1 -1
  663. package/lib/core/tree/cursor.d.ts +1 -6
  664. package/lib/core/tree/cursor.d.ts.map +1 -1
  665. package/lib/core/tree/cursor.js +0 -2
  666. package/lib/core/tree/cursor.js.map +1 -1
  667. package/lib/core/tree/delta.d.ts +0 -11
  668. package/lib/core/tree/delta.d.ts.map +1 -1
  669. package/lib/core/tree/delta.js.map +1 -1
  670. package/lib/core/tree/detachedFieldIndexCodec.d.ts.map +1 -1
  671. package/lib/core/tree/detachedFieldIndexCodec.js +4 -3
  672. package/lib/core/tree/detachedFieldIndexCodec.js.map +1 -1
  673. package/lib/core/tree/detachedFieldIndexTypes.d.ts +0 -1
  674. package/lib/core/tree/detachedFieldIndexTypes.d.ts.map +1 -1
  675. package/lib/core/tree/detachedFieldIndexTypes.js.map +1 -1
  676. package/lib/core/tree/index.d.ts +1 -1
  677. package/lib/core/tree/index.d.ts.map +1 -1
  678. package/lib/core/tree/index.js +1 -0
  679. package/lib/core/tree/index.js.map +1 -1
  680. package/lib/core/tree/mapTree.d.ts +20 -4
  681. package/lib/core/tree/mapTree.d.ts.map +1 -1
  682. package/lib/core/tree/mapTree.js +27 -1
  683. package/lib/core/tree/mapTree.js.map +1 -1
  684. package/lib/core/tree/pathTree.d.ts +0 -11
  685. package/lib/core/tree/pathTree.d.ts.map +1 -1
  686. package/lib/core/tree/pathTree.js.map +1 -1
  687. package/lib/core/tree/treeTextFormat.d.ts.map +1 -1
  688. package/lib/core/tree/treeTextFormat.js +3 -2
  689. package/lib/core/tree/treeTextFormat.js.map +1 -1
  690. package/lib/core/tree/types.d.ts +0 -11
  691. package/lib/core/tree/types.d.ts.map +1 -1
  692. package/lib/core/tree/types.js +0 -4
  693. package/lib/core/tree/types.js.map +1 -1
  694. package/lib/core/tree/visitDelta.d.ts +0 -1
  695. package/lib/core/tree/visitDelta.d.ts.map +1 -1
  696. package/lib/core/tree/visitDelta.js +2 -2
  697. package/lib/core/tree/visitDelta.js.map +1 -1
  698. package/lib/core/tree/visitPath.d.ts +0 -2
  699. package/lib/core/tree/visitPath.d.ts.map +1 -1
  700. package/lib/core/tree/visitPath.js.map +1 -1
  701. package/lib/core/tree/visitorUtils.d.ts +0 -1
  702. package/lib/core/tree/visitorUtils.d.ts.map +1 -1
  703. package/lib/core/tree/visitorUtils.js.map +1 -1
  704. package/lib/domains/index.d.ts +1 -1
  705. package/lib/domains/index.d.ts.map +1 -1
  706. package/lib/domains/index.js +1 -1
  707. package/lib/domains/index.js.map +1 -1
  708. package/lib/domains/json/index.d.ts +1 -1
  709. package/lib/domains/json/index.d.ts.map +1 -1
  710. package/lib/domains/json/index.js +1 -1
  711. package/lib/domains/json/index.js.map +1 -1
  712. package/lib/domains/json/jsonCursor.d.ts +36 -2
  713. package/lib/domains/json/jsonCursor.d.ts.map +1 -1
  714. package/lib/domains/json/jsonCursor.js +76 -5
  715. package/lib/domains/json/jsonCursor.js.map +1 -1
  716. package/lib/domains/json/jsonDomainSchema.d.ts +13 -3
  717. package/lib/domains/json/jsonDomainSchema.d.ts.map +1 -1
  718. package/lib/domains/json/jsonDomainSchema.js +9 -1
  719. package/lib/domains/json/jsonDomainSchema.js.map +1 -1
  720. package/lib/domains/leafDomain.d.ts +0 -1
  721. package/lib/domains/leafDomain.d.ts.map +1 -1
  722. package/lib/domains/leafDomain.js +0 -1
  723. package/lib/domains/leafDomain.js.map +1 -1
  724. package/lib/domains/schemaBuilder.d.ts +1 -7
  725. package/lib/domains/schemaBuilder.d.ts.map +1 -1
  726. package/lib/domains/schemaBuilder.js +1 -11
  727. package/lib/domains/schemaBuilder.js.map +1 -1
  728. package/lib/events/events.d.ts +7 -5
  729. package/lib/events/events.d.ts.map +1 -1
  730. package/lib/events/events.js +5 -3
  731. package/lib/events/events.js.map +1 -1
  732. package/lib/feature-libraries/chunked-forest/basicChunk.d.ts.map +1 -1
  733. package/lib/feature-libraries/chunked-forest/basicChunk.js +9 -4
  734. package/lib/feature-libraries/chunked-forest/basicChunk.js.map +1 -1
  735. package/lib/feature-libraries/chunked-forest/chunk.d.ts +1 -1
  736. package/lib/feature-libraries/chunked-forest/chunk.d.ts.map +1 -1
  737. package/lib/feature-libraries/chunked-forest/chunk.js.map +1 -1
  738. package/lib/feature-libraries/chunked-forest/chunkTree.js +4 -4
  739. package/lib/feature-libraries/chunked-forest/chunkTree.js.map +1 -1
  740. package/lib/feature-libraries/chunked-forest/chunkedForest.d.ts.map +1 -1
  741. package/lib/feature-libraries/chunked-forest/chunkedForest.js +8 -6
  742. package/lib/feature-libraries/chunked-forest/chunkedForest.js.map +1 -1
  743. package/lib/feature-libraries/chunked-forest/codec/chunkCodecUtilities.js +2 -2
  744. package/lib/feature-libraries/chunked-forest/codec/chunkCodecUtilities.js.map +1 -1
  745. package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.d.ts.map +1 -1
  746. package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.js +9 -6
  747. package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.js.map +1 -1
  748. package/lib/feature-libraries/chunked-forest/uniformChunk.d.ts.map +1 -1
  749. package/lib/feature-libraries/chunked-forest/uniformChunk.js +6 -4
  750. package/lib/feature-libraries/chunked-forest/uniformChunk.js.map +1 -1
  751. package/lib/feature-libraries/default-schema/defaultEditBuilder.d.ts +12 -24
  752. package/lib/feature-libraries/default-schema/defaultEditBuilder.d.ts.map +1 -1
  753. package/lib/feature-libraries/default-schema/defaultEditBuilder.js +6 -16
  754. package/lib/feature-libraries/default-schema/defaultEditBuilder.js.map +1 -1
  755. package/lib/feature-libraries/default-schema/defaultFieldKinds.d.ts +0 -6
  756. package/lib/feature-libraries/default-schema/defaultFieldKinds.d.ts.map +1 -1
  757. package/lib/feature-libraries/default-schema/defaultFieldKinds.js +11 -1
  758. package/lib/feature-libraries/default-schema/defaultFieldKinds.js.map +1 -1
  759. package/lib/feature-libraries/default-schema/defaultSchema.d.ts +0 -1
  760. package/lib/feature-libraries/default-schema/defaultSchema.d.ts.map +1 -1
  761. package/lib/feature-libraries/default-schema/defaultSchema.js +0 -1
  762. package/lib/feature-libraries/default-schema/defaultSchema.js.map +1 -1
  763. package/lib/feature-libraries/default-schema/index.d.ts +1 -1
  764. package/lib/feature-libraries/default-schema/index.d.ts.map +1 -1
  765. package/lib/feature-libraries/default-schema/index.js +1 -1
  766. package/lib/feature-libraries/default-schema/index.js.map +1 -1
  767. package/lib/feature-libraries/default-schema/schemaChecker.d.ts +6 -0
  768. package/lib/feature-libraries/default-schema/schemaChecker.d.ts.map +1 -1
  769. package/lib/feature-libraries/default-schema/schemaChecker.js +6 -0
  770. package/lib/feature-libraries/default-schema/schemaChecker.js.map +1 -1
  771. package/lib/feature-libraries/editableTreeBinder.d.ts +0 -67
  772. package/lib/feature-libraries/editableTreeBinder.d.ts.map +1 -1
  773. package/lib/feature-libraries/editableTreeBinder.js +6 -25
  774. package/lib/feature-libraries/editableTreeBinder.js.map +1 -1
  775. package/lib/feature-libraries/fieldGenerator.d.ts +0 -3
  776. package/lib/feature-libraries/fieldGenerator.d.ts.map +1 -1
  777. package/lib/feature-libraries/fieldGenerator.js +0 -1
  778. package/lib/feature-libraries/fieldGenerator.js.map +1 -1
  779. package/lib/feature-libraries/flex-map-tree/index.d.ts +1 -1
  780. package/lib/feature-libraries/flex-map-tree/index.d.ts.map +1 -1
  781. package/lib/feature-libraries/flex-map-tree/index.js +1 -1
  782. package/lib/feature-libraries/flex-map-tree/index.js.map +1 -1
  783. package/lib/feature-libraries/flex-map-tree/mapTreeNode.d.ts +57 -51
  784. package/lib/feature-libraries/flex-map-tree/mapTreeNode.d.ts.map +1 -1
  785. package/lib/feature-libraries/flex-map-tree/mapTreeNode.js +172 -180
  786. package/lib/feature-libraries/flex-map-tree/mapTreeNode.js.map +1 -1
  787. package/lib/feature-libraries/flex-tree/context.d.ts +0 -1
  788. package/lib/feature-libraries/flex-tree/context.d.ts.map +1 -1
  789. package/lib/feature-libraries/flex-tree/context.js.map +1 -1
  790. package/lib/feature-libraries/flex-tree/flexTreeTypes.d.ts +17 -373
  791. package/lib/feature-libraries/flex-tree/flexTreeTypes.d.ts.map +1 -1
  792. package/lib/feature-libraries/flex-tree/flexTreeTypes.js +0 -33
  793. package/lib/feature-libraries/flex-tree/flexTreeTypes.js.map +1 -1
  794. package/lib/feature-libraries/flex-tree/index.d.ts +2 -2
  795. package/lib/feature-libraries/flex-tree/index.d.ts.map +1 -1
  796. package/lib/feature-libraries/flex-tree/index.js +1 -1
  797. package/lib/feature-libraries/flex-tree/index.js.map +1 -1
  798. package/lib/feature-libraries/flex-tree/lazyField.d.ts +9 -27
  799. package/lib/feature-libraries/flex-tree/lazyField.d.ts.map +1 -1
  800. package/lib/feature-libraries/flex-tree/lazyField.js +28 -104
  801. package/lib/feature-libraries/flex-tree/lazyField.js.map +1 -1
  802. package/lib/feature-libraries/flex-tree/lazyNode.d.ts +3 -18
  803. package/lib/feature-libraries/flex-tree/lazyNode.d.ts.map +1 -1
  804. package/lib/feature-libraries/flex-tree/lazyNode.js +5 -126
  805. package/lib/feature-libraries/flex-tree/lazyNode.js.map +1 -1
  806. package/lib/feature-libraries/flex-tree/treeEvents.d.ts +0 -2
  807. package/lib/feature-libraries/flex-tree/treeEvents.d.ts.map +1 -1
  808. package/lib/feature-libraries/flex-tree/treeEvents.js.map +1 -1
  809. package/lib/feature-libraries/flex-tree/utilities.d.ts +2 -1
  810. package/lib/feature-libraries/flex-tree/utilities.d.ts.map +1 -1
  811. package/lib/feature-libraries/flex-tree/utilities.js +4 -0
  812. package/lib/feature-libraries/flex-tree/utilities.js.map +1 -1
  813. package/lib/feature-libraries/forest-summary/codec.js +3 -3
  814. package/lib/feature-libraries/forest-summary/codec.js.map +1 -1
  815. package/lib/feature-libraries/index.d.ts +6 -8
  816. package/lib/feature-libraries/index.d.ts.map +1 -1
  817. package/lib/feature-libraries/index.js +6 -7
  818. package/lib/feature-libraries/index.js.map +1 -1
  819. package/lib/feature-libraries/mapTreeCursor.d.ts +6 -2
  820. package/lib/feature-libraries/mapTreeCursor.d.ts.map +1 -1
  821. package/lib/feature-libraries/mapTreeCursor.js +7 -0
  822. package/lib/feature-libraries/mapTreeCursor.js.map +1 -1
  823. package/lib/feature-libraries/memoizedIdRangeAllocator.d.ts +0 -4
  824. package/lib/feature-libraries/memoizedIdRangeAllocator.d.ts.map +1 -1
  825. package/lib/feature-libraries/memoizedIdRangeAllocator.js +0 -1
  826. package/lib/feature-libraries/memoizedIdRangeAllocator.js.map +1 -1
  827. package/lib/feature-libraries/modular-schema/crossFieldQueries.d.ts +0 -2
  828. package/lib/feature-libraries/modular-schema/crossFieldQueries.d.ts.map +1 -1
  829. package/lib/feature-libraries/modular-schema/crossFieldQueries.js +0 -1
  830. package/lib/feature-libraries/modular-schema/crossFieldQueries.js.map +1 -1
  831. package/lib/feature-libraries/modular-schema/discrepancies.d.ts +18 -0
  832. package/lib/feature-libraries/modular-schema/discrepancies.d.ts.map +1 -1
  833. package/lib/feature-libraries/modular-schema/discrepancies.js +103 -1
  834. package/lib/feature-libraries/modular-schema/discrepancies.js.map +1 -1
  835. package/lib/feature-libraries/modular-schema/fieldChangeHandler.d.ts +0 -8
  836. package/lib/feature-libraries/modular-schema/fieldChangeHandler.d.ts.map +1 -1
  837. package/lib/feature-libraries/modular-schema/fieldChangeHandler.js +0 -1
  838. package/lib/feature-libraries/modular-schema/fieldChangeHandler.js.map +1 -1
  839. package/lib/feature-libraries/modular-schema/fieldKind.d.ts +1 -3
  840. package/lib/feature-libraries/modular-schema/fieldKind.d.ts.map +1 -1
  841. package/lib/feature-libraries/modular-schema/fieldKind.js +1 -2
  842. package/lib/feature-libraries/modular-schema/fieldKind.js.map +1 -1
  843. package/lib/feature-libraries/modular-schema/genericFieldKind.d.ts +1 -2
  844. package/lib/feature-libraries/modular-schema/genericFieldKind.d.ts.map +1 -1
  845. package/lib/feature-libraries/modular-schema/genericFieldKind.js +56 -83
  846. package/lib/feature-libraries/modular-schema/genericFieldKind.js.map +1 -1
  847. package/lib/feature-libraries/modular-schema/genericFieldKindCodecs.d.ts +1 -1
  848. package/lib/feature-libraries/modular-schema/genericFieldKindCodecs.d.ts.map +1 -1
  849. package/lib/feature-libraries/modular-schema/genericFieldKindCodecs.js +6 -9
  850. package/lib/feature-libraries/modular-schema/genericFieldKindCodecs.js.map +1 -1
  851. package/lib/feature-libraries/modular-schema/genericFieldKindTypes.d.ts +3 -14
  852. package/lib/feature-libraries/modular-schema/genericFieldKindTypes.d.ts.map +1 -1
  853. package/lib/feature-libraries/modular-schema/genericFieldKindTypes.js +4 -1
  854. package/lib/feature-libraries/modular-schema/genericFieldKindTypes.js.map +1 -1
  855. package/lib/feature-libraries/modular-schema/index.d.ts +2 -2
  856. package/lib/feature-libraries/modular-schema/index.d.ts.map +1 -1
  857. package/lib/feature-libraries/modular-schema/index.js +1 -1
  858. package/lib/feature-libraries/modular-schema/index.js.map +1 -1
  859. package/lib/feature-libraries/modular-schema/modularChangeCodecs.d.ts.map +1 -1
  860. package/lib/feature-libraries/modular-schema/modularChangeCodecs.js +42 -25
  861. package/lib/feature-libraries/modular-schema/modularChangeCodecs.js.map +1 -1
  862. package/lib/feature-libraries/modular-schema/modularChangeFamily.d.ts +9 -8
  863. package/lib/feature-libraries/modular-schema/modularChangeFamily.d.ts.map +1 -1
  864. package/lib/feature-libraries/modular-schema/modularChangeFamily.js +169 -206
  865. package/lib/feature-libraries/modular-schema/modularChangeFamily.js.map +1 -1
  866. package/lib/feature-libraries/modular-schema/modularChangeTypes.d.ts +8 -14
  867. package/lib/feature-libraries/modular-schema/modularChangeTypes.d.ts.map +1 -1
  868. package/lib/feature-libraries/modular-schema/modularChangeTypes.js.map +1 -1
  869. package/lib/feature-libraries/node-key/nodeKey.d.ts +0 -4
  870. package/lib/feature-libraries/node-key/nodeKey.d.ts.map +1 -1
  871. package/lib/feature-libraries/node-key/nodeKey.js +0 -2
  872. package/lib/feature-libraries/node-key/nodeKey.js.map +1 -1
  873. package/lib/feature-libraries/node-key/nodeKeyManager.d.ts +0 -1
  874. package/lib/feature-libraries/node-key/nodeKeyManager.d.ts.map +1 -1
  875. package/lib/feature-libraries/node-key/nodeKeyManager.js.map +1 -1
  876. package/lib/feature-libraries/object-forest/objectForest.d.ts.map +1 -1
  877. package/lib/feature-libraries/object-forest/objectForest.js +2 -11
  878. package/lib/feature-libraries/object-forest/objectForest.js.map +1 -1
  879. package/lib/feature-libraries/optional-field/optionalFieldChangeFormatV1.d.ts +6 -6
  880. package/lib/feature-libraries/optional-field/optionalFieldChangeFormatV1.d.ts.map +1 -1
  881. package/lib/feature-libraries/optional-field/optionalFieldChangeFormatV2.d.ts +7 -7
  882. package/lib/feature-libraries/optional-field/optionalFieldChangeFormatV2.d.ts.map +1 -1
  883. package/lib/feature-libraries/schemaBuilderBase.d.ts +2 -28
  884. package/lib/feature-libraries/schemaBuilderBase.d.ts.map +1 -1
  885. package/lib/feature-libraries/schemaBuilderBase.js +2 -28
  886. package/lib/feature-libraries/schemaBuilderBase.js.map +1 -1
  887. package/lib/feature-libraries/sequence-field/compose.d.ts.map +1 -1
  888. package/lib/feature-libraries/sequence-field/compose.js +25 -22
  889. package/lib/feature-libraries/sequence-field/compose.js.map +1 -1
  890. package/lib/feature-libraries/sequence-field/formatV2.d.ts +3 -3
  891. package/lib/feature-libraries/sequence-field/formatV2.d.ts.map +1 -1
  892. package/lib/feature-libraries/sequence-field/formatV2.js +3 -3
  893. package/lib/feature-libraries/sequence-field/formatV2.js.map +1 -1
  894. package/lib/feature-libraries/sequence-field/formatV3.d.ts +195 -0
  895. package/lib/feature-libraries/sequence-field/formatV3.d.ts.map +1 -0
  896. package/lib/feature-libraries/sequence-field/formatV3.js +19 -0
  897. package/lib/feature-libraries/sequence-field/formatV3.js.map +1 -0
  898. package/lib/feature-libraries/sequence-field/helperTypes.d.ts +11 -0
  899. package/lib/feature-libraries/sequence-field/helperTypes.d.ts.map +1 -1
  900. package/lib/feature-libraries/sequence-field/helperTypes.js.map +1 -1
  901. package/lib/feature-libraries/sequence-field/index.d.ts +1 -1
  902. package/lib/feature-libraries/sequence-field/index.d.ts.map +1 -1
  903. package/lib/feature-libraries/sequence-field/index.js.map +1 -1
  904. package/lib/feature-libraries/sequence-field/invert.d.ts.map +1 -1
  905. package/lib/feature-libraries/sequence-field/invert.js +22 -14
  906. package/lib/feature-libraries/sequence-field/invert.js.map +1 -1
  907. package/lib/feature-libraries/sequence-field/markQueue.js +2 -2
  908. package/lib/feature-libraries/sequence-field/markQueue.js.map +1 -1
  909. package/lib/feature-libraries/sequence-field/moveEffectTable.d.ts +2 -2
  910. package/lib/feature-libraries/sequence-field/moveEffectTable.d.ts.map +1 -1
  911. package/lib/feature-libraries/sequence-field/moveEffectTable.js.map +1 -1
  912. package/lib/feature-libraries/sequence-field/rebase.d.ts.map +1 -1
  913. package/lib/feature-libraries/sequence-field/rebase.js +25 -7
  914. package/lib/feature-libraries/sequence-field/rebase.js.map +1 -1
  915. package/lib/feature-libraries/sequence-field/replaceRevisions.d.ts.map +1 -1
  916. package/lib/feature-libraries/sequence-field/replaceRevisions.js +16 -3
  917. package/lib/feature-libraries/sequence-field/replaceRevisions.js.map +1 -1
  918. package/lib/feature-libraries/sequence-field/sequenceFieldCodecV1.d.ts.map +1 -1
  919. package/lib/feature-libraries/sequence-field/sequenceFieldCodecV1.js +40 -6
  920. package/lib/feature-libraries/sequence-field/sequenceFieldCodecV1.js.map +1 -1
  921. package/lib/feature-libraries/sequence-field/sequenceFieldCodecV2.d.ts +4 -1
  922. package/lib/feature-libraries/sequence-field/sequenceFieldCodecV2.d.ts.map +1 -1
  923. package/lib/feature-libraries/sequence-field/sequenceFieldCodecV2.js +55 -11
  924. package/lib/feature-libraries/sequence-field/sequenceFieldCodecV2.js.map +1 -1
  925. package/lib/feature-libraries/sequence-field/sequenceFieldCodecV3.d.ts +11 -0
  926. package/lib/feature-libraries/sequence-field/sequenceFieldCodecV3.d.ts.map +1 -0
  927. package/lib/feature-libraries/sequence-field/sequenceFieldCodecV3.js +81 -0
  928. package/lib/feature-libraries/sequence-field/sequenceFieldCodecV3.js.map +1 -0
  929. package/lib/feature-libraries/sequence-field/sequenceFieldCodecs.d.ts.map +1 -1
  930. package/lib/feature-libraries/sequence-field/sequenceFieldCodecs.js +2 -0
  931. package/lib/feature-libraries/sequence-field/sequenceFieldCodecs.js.map +1 -1
  932. package/lib/feature-libraries/sequence-field/sequenceFieldToDelta.d.ts.map +1 -1
  933. package/lib/feature-libraries/sequence-field/sequenceFieldToDelta.js +5 -2
  934. package/lib/feature-libraries/sequence-field/sequenceFieldToDelta.js.map +1 -1
  935. package/lib/feature-libraries/sequence-field/types.d.ts +23 -4
  936. package/lib/feature-libraries/sequence-field/types.d.ts.map +1 -1
  937. package/lib/feature-libraries/sequence-field/types.js.map +1 -1
  938. package/lib/feature-libraries/sequence-field/utils.d.ts +5 -4
  939. package/lib/feature-libraries/sequence-field/utils.d.ts.map +1 -1
  940. package/lib/feature-libraries/sequence-field/utils.js +67 -41
  941. package/lib/feature-libraries/sequence-field/utils.js.map +1 -1
  942. package/lib/feature-libraries/storedToViewSchema.d.ts +0 -1
  943. package/lib/feature-libraries/storedToViewSchema.d.ts.map +1 -1
  944. package/lib/feature-libraries/storedToViewSchema.js +0 -1
  945. package/lib/feature-libraries/storedToViewSchema.js.map +1 -1
  946. package/lib/feature-libraries/treeCursorUtils.d.ts +0 -6
  947. package/lib/feature-libraries/treeCursorUtils.d.ts.map +1 -1
  948. package/lib/feature-libraries/treeCursorUtils.js +9 -7
  949. package/lib/feature-libraries/treeCursorUtils.js.map +1 -1
  950. package/lib/feature-libraries/treeTextCursor.d.ts +0 -2
  951. package/lib/feature-libraries/treeTextCursor.d.ts.map +1 -1
  952. package/lib/feature-libraries/treeTextCursor.js +0 -2
  953. package/lib/feature-libraries/treeTextCursor.js.map +1 -1
  954. package/lib/feature-libraries/typed-schema/flexList.d.ts +0 -3
  955. package/lib/feature-libraries/typed-schema/flexList.d.ts.map +1 -1
  956. package/lib/feature-libraries/typed-schema/flexList.js.map +1 -1
  957. package/lib/feature-libraries/typed-schema/index.d.ts +1 -1
  958. package/lib/feature-libraries/typed-schema/index.d.ts.map +1 -1
  959. package/lib/feature-libraries/typed-schema/index.js +1 -1
  960. package/lib/feature-libraries/typed-schema/index.js.map +1 -1
  961. package/lib/feature-libraries/typed-schema/schemaCollection.d.ts.map +1 -1
  962. package/lib/feature-libraries/typed-schema/schemaCollection.js +1 -5
  963. package/lib/feature-libraries/typed-schema/schemaCollection.js.map +1 -1
  964. package/lib/feature-libraries/typed-schema/typedTreeSchema.d.ts +2 -41
  965. package/lib/feature-libraries/typed-schema/typedTreeSchema.d.ts.map +1 -1
  966. package/lib/feature-libraries/typed-schema/typedTreeSchema.js +1 -38
  967. package/lib/feature-libraries/typed-schema/typedTreeSchema.js.map +1 -1
  968. package/lib/feature-libraries/typed-schema/view.d.ts +0 -1
  969. package/lib/feature-libraries/typed-schema/view.d.ts.map +1 -1
  970. package/lib/feature-libraries/typed-schema/view.js.map +1 -1
  971. package/lib/index.d.ts +8 -9
  972. package/lib/index.d.ts.map +1 -1
  973. package/lib/index.js +8 -9
  974. package/lib/index.js.map +1 -1
  975. package/lib/internalTypes.d.ts +1 -1
  976. package/lib/internalTypes.d.ts.map +1 -1
  977. package/lib/internalTypes.js.map +1 -1
  978. package/lib/packageVersion.d.ts +1 -1
  979. package/lib/packageVersion.d.ts.map +1 -1
  980. package/lib/packageVersion.js +1 -1
  981. package/lib/packageVersion.js.map +1 -1
  982. package/lib/public.d.ts +4 -1
  983. package/lib/shared-tree/schematizeTree.d.ts +2 -11
  984. package/lib/shared-tree/schematizeTree.d.ts.map +1 -1
  985. package/lib/shared-tree/schematizeTree.js +15 -4
  986. package/lib/shared-tree/schematizeTree.js.map +1 -1
  987. package/lib/shared-tree/schematizingTreeView.d.ts +4 -4
  988. package/lib/shared-tree/schematizingTreeView.d.ts.map +1 -1
  989. package/lib/shared-tree/schematizingTreeView.js +3 -3
  990. package/lib/shared-tree/schematizingTreeView.js.map +1 -1
  991. package/lib/shared-tree/sharedTree.d.ts +4 -17
  992. package/lib/shared-tree/sharedTree.d.ts.map +1 -1
  993. package/lib/shared-tree/sharedTree.js +6 -10
  994. package/lib/shared-tree/sharedTree.js.map +1 -1
  995. package/lib/shared-tree/sharedTreeChangeCodecs.d.ts.map +1 -1
  996. package/lib/shared-tree/sharedTreeChangeCodecs.js +4 -0
  997. package/lib/shared-tree/sharedTreeChangeCodecs.js.map +1 -1
  998. package/lib/shared-tree/sharedTreeChangeFamily.js +3 -3
  999. package/lib/shared-tree/sharedTreeChangeFamily.js.map +1 -1
  1000. package/lib/shared-tree/sharedTreeEditBuilder.d.ts +0 -2
  1001. package/lib/shared-tree/sharedTreeEditBuilder.d.ts.map +1 -1
  1002. package/lib/shared-tree/sharedTreeEditBuilder.js.map +1 -1
  1003. package/lib/shared-tree/treeApi.js +3 -3
  1004. package/lib/shared-tree/treeApi.js.map +1 -1
  1005. package/lib/shared-tree/treeCheckout.d.ts +0 -5
  1006. package/lib/shared-tree/treeCheckout.d.ts.map +1 -1
  1007. package/lib/shared-tree/treeCheckout.js +6 -4
  1008. package/lib/shared-tree/treeCheckout.js.map +1 -1
  1009. package/lib/shared-tree/treeView.d.ts +3 -6
  1010. package/lib/shared-tree/treeView.d.ts.map +1 -1
  1011. package/lib/shared-tree/treeView.js.map +1 -1
  1012. package/lib/shared-tree-core/branch.d.ts.map +1 -1
  1013. package/lib/shared-tree-core/branch.js +12 -7
  1014. package/lib/shared-tree-core/branch.js.map +1 -1
  1015. package/lib/shared-tree-core/defaultResubmitMachine.js +4 -4
  1016. package/lib/shared-tree-core/defaultResubmitMachine.js.map +1 -1
  1017. package/lib/shared-tree-core/editManagerCodecs.d.ts.map +1 -1
  1018. package/lib/shared-tree-core/editManagerCodecs.js +1 -0
  1019. package/lib/shared-tree-core/editManagerCodecs.js.map +1 -1
  1020. package/lib/shared-tree-core/editManagerFormat.d.ts +2 -2
  1021. package/lib/shared-tree-core/editManagerFormat.d.ts.map +1 -1
  1022. package/lib/shared-tree-core/editManagerFormat.js +6 -1
  1023. package/lib/shared-tree-core/editManagerFormat.js.map +1 -1
  1024. package/lib/shared-tree-core/messageCodecs.d.ts.map +1 -1
  1025. package/lib/shared-tree-core/messageCodecs.js +1 -0
  1026. package/lib/shared-tree-core/messageCodecs.js.map +1 -1
  1027. package/lib/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
  1028. package/lib/shared-tree-core/sharedTreeCore.js +4 -2
  1029. package/lib/shared-tree-core/sharedTreeCore.js.map +1 -1
  1030. package/lib/simple-tree/api/create.d.ts +54 -0
  1031. package/lib/simple-tree/api/create.d.ts.map +1 -0
  1032. package/lib/simple-tree/api/create.js +92 -0
  1033. package/lib/simple-tree/api/create.js.map +1 -0
  1034. package/lib/simple-tree/api/index.d.ts +12 -0
  1035. package/lib/simple-tree/api/index.d.ts.map +1 -0
  1036. package/lib/simple-tree/api/index.js +13 -0
  1037. package/lib/simple-tree/api/index.js.map +1 -0
  1038. package/{dist/simple-tree → lib/simple-tree/api}/schemaCreationUtilities.d.ts +7 -4
  1039. package/lib/simple-tree/api/schemaCreationUtilities.d.ts.map +1 -0
  1040. package/lib/simple-tree/{schemaCreationUtilities.js → api/schemaCreationUtilities.js} +1 -1
  1041. package/lib/simple-tree/api/schemaCreationUtilities.js.map +1 -0
  1042. package/lib/simple-tree/{schemaFactory.d.ts → api/schemaFactory.d.ts} +15 -14
  1043. package/lib/simple-tree/api/schemaFactory.d.ts.map +1 -0
  1044. package/lib/simple-tree/{schemaFactory.js → api/schemaFactory.js} +9 -8
  1045. package/lib/simple-tree/api/schemaFactory.js.map +1 -0
  1046. package/{dist/simple-tree → lib/simple-tree/api}/schemaFactoryRecursive.d.ts +40 -7
  1047. package/lib/simple-tree/api/schemaFactoryRecursive.d.ts.map +1 -0
  1048. package/lib/simple-tree/{schemaFactoryRecursive.js → api/schemaFactoryRecursive.js} +1 -1
  1049. package/lib/simple-tree/api/schemaFactoryRecursive.js.map +1 -0
  1050. package/lib/simple-tree/api/testRecursiveDomain.d.ts +62 -0
  1051. package/lib/simple-tree/api/testRecursiveDomain.d.ts.map +1 -0
  1052. package/lib/simple-tree/api/testRecursiveDomain.js.map +1 -0
  1053. package/{dist/simple-tree → lib/simple-tree/api}/tree.d.ts +111 -20
  1054. package/lib/simple-tree/api/tree.d.ts.map +1 -0
  1055. package/lib/simple-tree/api/tree.js +165 -0
  1056. package/lib/simple-tree/api/tree.js.map +1 -0
  1057. package/lib/simple-tree/{treeNodeApi.d.ts → api/treeNodeApi.d.ts} +7 -6
  1058. package/lib/simple-tree/api/treeNodeApi.d.ts.map +1 -0
  1059. package/lib/simple-tree/{treeNodeApi.js → api/treeNodeApi.js} +55 -19
  1060. package/lib/simple-tree/api/treeNodeApi.js.map +1 -0
  1061. package/lib/simple-tree/api/verboseTree.d.ts +136 -0
  1062. package/lib/simple-tree/api/verboseTree.d.ts.map +1 -0
  1063. package/lib/simple-tree/api/verboseTree.js +213 -0
  1064. package/lib/simple-tree/api/verboseTree.js.map +1 -0
  1065. package/lib/simple-tree/arrayNode.d.ts +3 -3
  1066. package/lib/simple-tree/arrayNode.d.ts.map +1 -1
  1067. package/lib/simple-tree/arrayNode.js +59 -70
  1068. package/lib/simple-tree/arrayNode.js.map +1 -1
  1069. package/lib/simple-tree/core/index.d.ts +10 -0
  1070. package/lib/simple-tree/core/index.d.ts.map +1 -0
  1071. package/lib/simple-tree/core/index.js +10 -0
  1072. package/lib/simple-tree/core/index.js.map +1 -0
  1073. package/{dist/simple-tree → lib/simple-tree/core}/schemaCaching.d.ts +2 -9
  1074. package/lib/simple-tree/core/schemaCaching.d.ts.map +1 -0
  1075. package/lib/simple-tree/{schemaCaching.js → core/schemaCaching.js} +1 -21
  1076. package/lib/simple-tree/core/schemaCaching.js.map +1 -0
  1077. package/lib/simple-tree/core/treeNodeKernel.d.ts +70 -0
  1078. package/lib/simple-tree/core/treeNodeKernel.d.ts.map +1 -0
  1079. package/lib/simple-tree/core/treeNodeKernel.js +157 -0
  1080. package/lib/simple-tree/core/treeNodeKernel.js.map +1 -0
  1081. package/lib/simple-tree/core/treeNodeSchema.d.ts +149 -0
  1082. package/lib/simple-tree/core/treeNodeSchema.d.ts.map +1 -0
  1083. package/lib/simple-tree/core/treeNodeSchema.js +32 -0
  1084. package/lib/simple-tree/core/treeNodeSchema.js.map +1 -0
  1085. package/{dist/simple-tree → lib/simple-tree/core}/types.d.ts +50 -79
  1086. package/lib/simple-tree/core/types.d.ts.map +1 -0
  1087. package/lib/simple-tree/core/types.js +111 -0
  1088. package/lib/simple-tree/core/types.js.map +1 -0
  1089. package/lib/simple-tree/core/withType.d.ts +82 -0
  1090. package/lib/simple-tree/core/withType.d.ts.map +1 -0
  1091. package/lib/simple-tree/core/withType.js +36 -0
  1092. package/lib/simple-tree/core/withType.js.map +1 -0
  1093. package/lib/simple-tree/getJsonSchema.d.ts +55 -0
  1094. package/lib/simple-tree/getJsonSchema.d.ts.map +1 -0
  1095. package/lib/simple-tree/getJsonSchema.js +65 -0
  1096. package/lib/simple-tree/getJsonSchema.js.map +1 -0
  1097. package/lib/simple-tree/getSimpleFieldSchema.d.ts +14 -0
  1098. package/lib/simple-tree/getSimpleFieldSchema.d.ts.map +1 -0
  1099. package/lib/simple-tree/getSimpleFieldSchema.js +25 -0
  1100. package/lib/simple-tree/getSimpleFieldSchema.js.map +1 -0
  1101. package/lib/simple-tree/getSimpleSchema.d.ts +58 -0
  1102. package/lib/simple-tree/getSimpleSchema.d.ts.map +1 -0
  1103. package/lib/simple-tree/getSimpleSchema.js +64 -0
  1104. package/lib/simple-tree/getSimpleSchema.js.map +1 -0
  1105. package/lib/simple-tree/index.d.ts +12 -13
  1106. package/lib/simple-tree/index.d.ts.map +1 -1
  1107. package/lib/simple-tree/index.js +8 -11
  1108. package/lib/simple-tree/index.js.map +1 -1
  1109. package/lib/simple-tree/jsonSchema.d.ts +206 -0
  1110. package/lib/simple-tree/jsonSchema.d.ts.map +1 -0
  1111. package/lib/simple-tree/{nodeKeys.js → jsonSchema.js} +1 -1
  1112. package/lib/simple-tree/jsonSchema.js.map +1 -0
  1113. package/lib/simple-tree/leafNodeSchema.d.ts +1 -1
  1114. package/lib/simple-tree/leafNodeSchema.d.ts.map +1 -1
  1115. package/lib/simple-tree/leafNodeSchema.js +1 -2
  1116. package/lib/simple-tree/leafNodeSchema.js.map +1 -1
  1117. package/lib/simple-tree/mapNode.d.ts +9 -3
  1118. package/lib/simple-tree/mapNode.d.ts.map +1 -1
  1119. package/lib/simple-tree/mapNode.js +36 -36
  1120. package/lib/simple-tree/mapNode.js.map +1 -1
  1121. package/lib/simple-tree/objectNode.d.ts +18 -16
  1122. package/lib/simple-tree/objectNode.d.ts.map +1 -1
  1123. package/lib/simple-tree/objectNode.js +36 -34
  1124. package/lib/simple-tree/objectNode.js.map +1 -1
  1125. package/lib/simple-tree/objectNodeTypes.d.ts +38 -0
  1126. package/lib/simple-tree/objectNodeTypes.d.ts.map +1 -0
  1127. package/lib/simple-tree/objectNodeTypes.js +15 -0
  1128. package/lib/simple-tree/objectNodeTypes.js.map +1 -0
  1129. package/lib/simple-tree/proxies.d.ts +6 -25
  1130. package/lib/simple-tree/proxies.d.ts.map +1 -1
  1131. package/lib/simple-tree/proxies.js +46 -57
  1132. package/lib/simple-tree/proxies.js.map +1 -1
  1133. package/lib/simple-tree/proxyBinding.d.ts +45 -22
  1134. package/lib/simple-tree/proxyBinding.d.ts.map +1 -1
  1135. package/lib/simple-tree/proxyBinding.js +89 -52
  1136. package/lib/simple-tree/proxyBinding.js.map +1 -1
  1137. package/lib/simple-tree/schemaTypes.d.ts +10 -159
  1138. package/lib/simple-tree/schemaTypes.d.ts.map +1 -1
  1139. package/lib/simple-tree/schemaTypes.js +9 -41
  1140. package/lib/simple-tree/schemaTypes.js.map +1 -1
  1141. package/lib/simple-tree/simpleSchema.d.ts +124 -0
  1142. package/lib/simple-tree/simpleSchema.d.ts.map +1 -0
  1143. package/lib/{feature-libraries/schema-aware/schemaAware.js → simple-tree/simpleSchema.js} +1 -1
  1144. package/lib/simple-tree/simpleSchema.js.map +1 -0
  1145. package/lib/simple-tree/simpleSchemaToJsonSchema.d.ts +12 -0
  1146. package/lib/simple-tree/simpleSchemaToJsonSchema.d.ts.map +1 -0
  1147. package/lib/simple-tree/simpleSchemaToJsonSchema.js +142 -0
  1148. package/lib/simple-tree/simpleSchemaToJsonSchema.js.map +1 -0
  1149. package/lib/simple-tree/toFlexSchema.d.ts +4 -12
  1150. package/lib/simple-tree/toFlexSchema.d.ts.map +1 -1
  1151. package/lib/simple-tree/toFlexSchema.js +9 -18
  1152. package/lib/simple-tree/toFlexSchema.js.map +1 -1
  1153. package/lib/simple-tree/toMapTree.d.ts +39 -39
  1154. package/lib/simple-tree/toMapTree.d.ts.map +1 -1
  1155. package/lib/simple-tree/toMapTree.js +214 -158
  1156. package/lib/simple-tree/toMapTree.js.map +1 -1
  1157. package/lib/simple-tree/treeNodeValid.d.ts +74 -0
  1158. package/lib/simple-tree/treeNodeValid.d.ts.map +1 -0
  1159. package/lib/simple-tree/{types.js → treeNodeValid.js} +8 -98
  1160. package/lib/simple-tree/treeNodeValid.js.map +1 -0
  1161. package/lib/simple-tree/typesUnsafe.d.ts +35 -4
  1162. package/lib/simple-tree/typesUnsafe.d.ts.map +1 -1
  1163. package/lib/simple-tree/typesUnsafe.js.map +1 -1
  1164. package/lib/simple-tree/viewSchemaToSimpleSchema.d.ts +11 -0
  1165. package/lib/simple-tree/viewSchemaToSimpleSchema.d.ts.map +1 -0
  1166. package/lib/simple-tree/viewSchemaToSimpleSchema.js +167 -0
  1167. package/lib/simple-tree/viewSchemaToSimpleSchema.js.map +1 -0
  1168. package/lib/util/brand.d.ts +0 -3
  1169. package/lib/util/brand.d.ts.map +1 -1
  1170. package/lib/util/brand.js +1 -2
  1171. package/lib/util/brand.js.map +1 -1
  1172. package/lib/util/brandedMap.d.ts +0 -5
  1173. package/lib/util/brandedMap.d.ts.map +1 -1
  1174. package/lib/util/brandedMap.js +0 -1
  1175. package/lib/util/brandedMap.js.map +1 -1
  1176. package/lib/util/idAllocator.d.ts +0 -2
  1177. package/lib/util/idAllocator.d.ts.map +1 -1
  1178. package/lib/util/idAllocator.js +0 -1
  1179. package/lib/util/idAllocator.js.map +1 -1
  1180. package/lib/util/index.d.ts +2 -2
  1181. package/lib/util/index.d.ts.map +1 -1
  1182. package/lib/util/index.js +2 -2
  1183. package/lib/util/index.js.map +1 -1
  1184. package/lib/util/nestedMap.d.ts +5 -19
  1185. package/lib/util/nestedMap.d.ts.map +1 -1
  1186. package/lib/util/nestedMap.js +15 -16
  1187. package/lib/util/nestedMap.js.map +1 -1
  1188. package/lib/util/opaque.d.ts +0 -4
  1189. package/lib/util/opaque.d.ts.map +1 -1
  1190. package/lib/util/opaque.js +0 -2
  1191. package/lib/util/opaque.js.map +1 -1
  1192. package/lib/util/rangeMap.d.ts +0 -2
  1193. package/lib/util/rangeMap.d.ts.map +1 -1
  1194. package/lib/util/rangeMap.js +4 -3
  1195. package/lib/util/rangeMap.js.map +1 -1
  1196. package/lib/util/transactionResult.d.ts +0 -1
  1197. package/lib/util/transactionResult.d.ts.map +1 -1
  1198. package/lib/util/transactionResult.js +0 -1
  1199. package/lib/util/transactionResult.js.map +1 -1
  1200. package/lib/util/typeCheck.d.ts +2 -20
  1201. package/lib/util/typeCheck.d.ts.map +1 -1
  1202. package/lib/util/typeCheck.js.map +1 -1
  1203. package/lib/util/typeCheckTests.d.ts +4 -4
  1204. package/lib/util/typeCheckTests.d.ts.map +1 -1
  1205. package/lib/util/typeCheckTests.js.map +1 -1
  1206. package/lib/util/typeUtils.d.ts +0 -7
  1207. package/lib/util/typeUtils.d.ts.map +1 -1
  1208. package/lib/util/typeUtils.js.map +1 -1
  1209. package/lib/util/utils.d.ts +6 -8
  1210. package/lib/util/utils.d.ts.map +1 -1
  1211. package/lib/util/utils.js +12 -4
  1212. package/lib/util/utils.js.map +1 -1
  1213. package/package.json +25 -24
  1214. package/src/codec/discriminatedUnions.ts +20 -10
  1215. package/src/codec/index.ts +5 -1
  1216. package/src/core/forest/README.md +4 -2
  1217. package/src/core/forest/editableForest.ts +1 -6
  1218. package/src/core/forest/forest.ts +0 -6
  1219. package/src/core/index.ts +2 -2
  1220. package/src/core/rebase/changeRebaser.ts +0 -4
  1221. package/src/core/rebase/index.ts +0 -2
  1222. package/src/core/rebase/types.ts +1 -23
  1223. package/src/core/rebase/utils.ts +13 -11
  1224. package/src/core/schema-stored/multiplicity.ts +0 -1
  1225. package/src/core/schema-stored/schema.ts +0 -7
  1226. package/src/core/schema-stored/storedSchemaRepository.ts +0 -3
  1227. package/src/core/schema-view/view.ts +0 -3
  1228. package/src/core/tree/anchorSet.ts +27 -26
  1229. package/src/core/tree/cursor.ts +1 -6
  1230. package/src/core/tree/delta.ts +0 -11
  1231. package/src/core/tree/detachedFieldIndexCodec.ts +4 -3
  1232. package/src/core/tree/detachedFieldIndexTypes.ts +0 -1
  1233. package/src/core/tree/index.ts +1 -1
  1234. package/src/core/tree/mapTree.ts +45 -4
  1235. package/src/core/tree/pathTree.ts +0 -11
  1236. package/src/core/tree/treeTextFormat.ts +3 -2
  1237. package/src/core/tree/types.ts +0 -11
  1238. package/src/core/tree/visitDelta.ts +2 -3
  1239. package/src/core/tree/visitPath.ts +0 -2
  1240. package/src/core/tree/visitorUtils.ts +0 -1
  1241. package/src/domains/index.ts +3 -0
  1242. package/src/domains/json/index.ts +7 -1
  1243. package/src/domains/json/jsonCursor.ts +113 -6
  1244. package/src/domains/json/jsonDomainSchema.ts +4 -5
  1245. package/src/domains/leafDomain.ts +0 -1
  1246. package/src/domains/schemaBuilder.ts +0 -22
  1247. package/src/events/events.ts +10 -6
  1248. package/src/feature-libraries/chunked-forest/README.md +9 -1
  1249. package/src/feature-libraries/chunked-forest/basicChunk.ts +14 -9
  1250. package/src/feature-libraries/chunked-forest/chunk.ts +1 -1
  1251. package/src/feature-libraries/chunked-forest/chunkTree.ts +4 -4
  1252. package/src/feature-libraries/chunked-forest/chunkedForest.ts +8 -6
  1253. package/src/feature-libraries/chunked-forest/codec/chunkCodecUtilities.ts +2 -2
  1254. package/src/feature-libraries/chunked-forest/codec/chunkDecoding.ts +9 -6
  1255. package/src/feature-libraries/chunked-forest/uniformChunk.ts +6 -4
  1256. package/src/feature-libraries/default-schema/defaultEditBuilder.ts +18 -46
  1257. package/src/feature-libraries/default-schema/defaultFieldKinds.ts +11 -6
  1258. package/src/feature-libraries/default-schema/defaultSchema.ts +0 -1
  1259. package/src/feature-libraries/default-schema/index.ts +1 -1
  1260. package/src/feature-libraries/default-schema/schemaChecker.ts +6 -0
  1261. package/src/feature-libraries/editableTreeBinder.ts +6 -78
  1262. package/src/feature-libraries/fieldGenerator.ts +0 -3
  1263. package/src/feature-libraries/flex-map-tree/index.ts +2 -1
  1264. package/src/feature-libraries/flex-map-tree/mapTreeNode.ts +238 -288
  1265. package/src/feature-libraries/flex-tree/context.ts +0 -1
  1266. package/src/feature-libraries/flex-tree/flexTreeTypes.ts +27 -524
  1267. package/src/feature-libraries/flex-tree/index.ts +1 -18
  1268. package/src/feature-libraries/flex-tree/lazyField.ts +38 -214
  1269. package/src/feature-libraries/flex-tree/lazyNode.ts +3 -215
  1270. package/src/feature-libraries/flex-tree/treeEvents.ts +0 -2
  1271. package/src/feature-libraries/flex-tree/utilities.ts +6 -1
  1272. package/src/feature-libraries/forest-summary/codec.ts +3 -3
  1273. package/src/feature-libraries/index.ts +5 -49
  1274. package/src/feature-libraries/mapTreeCursor.ts +13 -4
  1275. package/src/feature-libraries/memoizedIdRangeAllocator.ts +0 -4
  1276. package/src/feature-libraries/modular-schema/crossFieldQueries.ts +0 -2
  1277. package/src/feature-libraries/modular-schema/discrepancies.ts +117 -1
  1278. package/src/feature-libraries/modular-schema/fieldChangeHandler.ts +0 -8
  1279. package/src/feature-libraries/modular-schema/fieldKind.ts +1 -3
  1280. package/src/feature-libraries/modular-schema/genericFieldKind.ts +69 -92
  1281. package/src/feature-libraries/modular-schema/genericFieldKindCodecs.ts +7 -14
  1282. package/src/feature-libraries/modular-schema/genericFieldKindTypes.ts +6 -15
  1283. package/src/feature-libraries/modular-schema/index.ts +2 -2
  1284. package/src/feature-libraries/modular-schema/modularChangeCodecs.ts +68 -34
  1285. package/src/feature-libraries/modular-schema/modularChangeFamily.ts +330 -336
  1286. package/src/feature-libraries/modular-schema/modularChangeTypes.ts +7 -14
  1287. package/src/feature-libraries/node-key/nodeKey.ts +0 -4
  1288. package/src/feature-libraries/node-key/nodeKeyManager.ts +0 -1
  1289. package/src/feature-libraries/object-forest/objectForest.ts +1 -13
  1290. package/src/feature-libraries/schemaBuilderBase.ts +1 -49
  1291. package/src/feature-libraries/sequence-field/compose.ts +41 -20
  1292. package/src/feature-libraries/sequence-field/formatV2.ts +3 -3
  1293. package/src/feature-libraries/sequence-field/formatV3.ts +65 -0
  1294. package/src/feature-libraries/sequence-field/helperTypes.ts +33 -0
  1295. package/src/feature-libraries/sequence-field/index.ts +1 -0
  1296. package/src/feature-libraries/sequence-field/invert.ts +28 -18
  1297. package/src/feature-libraries/sequence-field/markQueue.ts +2 -2
  1298. package/src/feature-libraries/sequence-field/moveEffectTable.ts +2 -2
  1299. package/src/feature-libraries/sequence-field/rebase.ts +30 -13
  1300. package/src/feature-libraries/sequence-field/replaceRevisions.ts +27 -3
  1301. package/src/feature-libraries/sequence-field/sequenceFieldCodecV1.ts +52 -7
  1302. package/src/feature-libraries/sequence-field/sequenceFieldCodecV2.ts +92 -19
  1303. package/src/feature-libraries/sequence-field/sequenceFieldCodecV3.ts +134 -0
  1304. package/src/feature-libraries/sequence-field/sequenceFieldCodecs.ts +2 -0
  1305. package/src/feature-libraries/sequence-field/sequenceFieldToDelta.ts +8 -2
  1306. package/src/feature-libraries/sequence-field/types.ts +24 -4
  1307. package/src/feature-libraries/sequence-field/utils.ts +78 -50
  1308. package/src/feature-libraries/storedToViewSchema.ts +0 -1
  1309. package/src/feature-libraries/treeCursorUtils.ts +11 -11
  1310. package/src/feature-libraries/treeTextCursor.ts +0 -2
  1311. package/src/feature-libraries/typed-schema/flexList.ts +0 -3
  1312. package/src/feature-libraries/typed-schema/index.ts +0 -2
  1313. package/src/feature-libraries/typed-schema/schemaCollection.ts +0 -5
  1314. package/src/feature-libraries/typed-schema/typedTreeSchema.ts +2 -68
  1315. package/src/feature-libraries/typed-schema/view.ts +0 -1
  1316. package/src/index.ts +32 -242
  1317. package/src/internalTypes.ts +1 -0
  1318. package/src/packageVersion.ts +1 -1
  1319. package/src/shared-tree/schematizeTree.ts +25 -21
  1320. package/src/shared-tree/schematizingTreeView.ts +6 -6
  1321. package/src/shared-tree/sharedTree.ts +8 -39
  1322. package/src/shared-tree/sharedTreeChangeCodecs.ts +8 -0
  1323. package/src/shared-tree/sharedTreeChangeFamily.ts +3 -3
  1324. package/src/shared-tree/sharedTreeEditBuilder.ts +0 -2
  1325. package/src/shared-tree/treeApi.ts +3 -3
  1326. package/src/shared-tree/treeCheckout.ts +6 -8
  1327. package/src/shared-tree/treeView.ts +3 -6
  1328. package/src/shared-tree-core/branch.ts +20 -8
  1329. package/src/shared-tree-core/defaultResubmitMachine.ts +4 -4
  1330. package/src/shared-tree-core/editManagerCodecs.ts +1 -0
  1331. package/src/shared-tree-core/editManagerFormat.ts +7 -2
  1332. package/src/shared-tree-core/messageCodecs.ts +2 -1
  1333. package/src/shared-tree-core/sharedTreeCore.ts +5 -3
  1334. package/src/simple-tree/ProxyBinding.md +2 -0
  1335. package/src/simple-tree/api/README.md +7 -0
  1336. package/src/simple-tree/api/create.ts +179 -0
  1337. package/src/simple-tree/api/index.ts +36 -0
  1338. package/src/simple-tree/{schemaCreationUtilities.ts → api/schemaCreationUtilities.ts} +13 -5
  1339. package/src/simple-tree/{schemaFactory.ts → api/schemaFactory.ts} +36 -34
  1340. package/src/simple-tree/{schemaFactoryRecursive.ts → api/schemaFactoryRecursive.ts} +47 -10
  1341. package/src/simple-tree/{testRecursiveDomain.ts → api/testRecursiveDomain.ts} +3 -1
  1342. package/src/simple-tree/{tree.ts → api/tree.ts} +246 -34
  1343. package/src/simple-tree/{treeNodeApi.ts → api/treeNodeApi.ts} +84 -41
  1344. package/src/simple-tree/api/verboseTree.ts +415 -0
  1345. package/src/simple-tree/arrayNode.ts +103 -110
  1346. package/src/simple-tree/core/README.md +11 -0
  1347. package/src/simple-tree/core/index.ts +34 -0
  1348. package/src/simple-tree/{schemaCaching.ts → core/schemaCaching.ts} +3 -37
  1349. package/src/simple-tree/core/treeNodeKernel.ts +200 -0
  1350. package/src/simple-tree/core/treeNodeSchema.ts +184 -0
  1351. package/src/simple-tree/core/types.ts +281 -0
  1352. package/src/simple-tree/core/withType.ts +89 -0
  1353. package/src/simple-tree/getJsonSchema.ts +70 -0
  1354. package/src/simple-tree/getSimpleFieldSchema.ts +36 -0
  1355. package/src/simple-tree/getSimpleSchema.ts +69 -0
  1356. package/src/simple-tree/index.ts +59 -33
  1357. package/src/simple-tree/jsonSchema.ts +230 -0
  1358. package/src/simple-tree/leafNodeSchema.ts +6 -3
  1359. package/src/simple-tree/mapNode.ts +56 -55
  1360. package/src/simple-tree/objectNode.ts +66 -90
  1361. package/src/simple-tree/objectNodeTypes.ts +68 -0
  1362. package/src/simple-tree/proxies.ts +52 -68
  1363. package/src/simple-tree/proxyBinding.ts +127 -72
  1364. package/src/simple-tree/schemaTypes.ts +29 -194
  1365. package/src/simple-tree/simpleSchema.ts +138 -0
  1366. package/src/simple-tree/simpleSchemaToJsonSchema.ts +178 -0
  1367. package/src/simple-tree/toFlexSchema.ts +9 -42
  1368. package/src/simple-tree/toMapTree.ts +270 -296
  1369. package/src/simple-tree/{types.ts → treeNodeValid.ts} +16 -232
  1370. package/src/simple-tree/typesUnsafe.ts +51 -5
  1371. package/src/simple-tree/viewSchemaToSimpleSchema.ts +209 -0
  1372. package/src/util/brand.ts +1 -4
  1373. package/src/util/brandedMap.ts +0 -5
  1374. package/src/util/idAllocator.ts +0 -2
  1375. package/src/util/index.ts +2 -0
  1376. package/src/util/nestedMap.ts +23 -20
  1377. package/src/util/opaque.ts +0 -4
  1378. package/src/util/rangeMap.ts +5 -5
  1379. package/src/util/transactionResult.ts +0 -1
  1380. package/src/util/typeCheck.ts +2 -20
  1381. package/src/util/typeCheckTests.ts +4 -4
  1382. package/src/util/typeUtils.ts +0 -7
  1383. package/src/util/utils.ts +13 -8
  1384. package/tsconfig.json +0 -1
  1385. package/dist/feature-libraries/contextuallyTyped.d.ts +0 -209
  1386. package/dist/feature-libraries/contextuallyTyped.d.ts.map +0 -1
  1387. package/dist/feature-libraries/contextuallyTyped.js +0 -328
  1388. package/dist/feature-libraries/contextuallyTyped.js.map +0 -1
  1389. package/dist/feature-libraries/schema-aware/index.d.ts +0 -6
  1390. package/dist/feature-libraries/schema-aware/index.d.ts.map +0 -1
  1391. package/dist/feature-libraries/schema-aware/index.js.map +0 -1
  1392. package/dist/feature-libraries/schema-aware/schemaAware.d.ts +0 -76
  1393. package/dist/feature-libraries/schema-aware/schemaAware.d.ts.map +0 -1
  1394. package/dist/feature-libraries/schema-aware/schemaAware.js.map +0 -1
  1395. package/dist/simple-tree/nodeKeys.d.ts +0 -41
  1396. package/dist/simple-tree/nodeKeys.d.ts.map +0 -1
  1397. package/dist/simple-tree/nodeKeys.js +0 -7
  1398. package/dist/simple-tree/nodeKeys.js.map +0 -1
  1399. package/dist/simple-tree/schemaCaching.d.ts.map +0 -1
  1400. package/dist/simple-tree/schemaCaching.js.map +0 -1
  1401. package/dist/simple-tree/schemaCreationUtilities.d.ts.map +0 -1
  1402. package/dist/simple-tree/schemaCreationUtilities.js.map +0 -1
  1403. package/dist/simple-tree/schemaFactory.d.ts.map +0 -1
  1404. package/dist/simple-tree/schemaFactory.js.map +0 -1
  1405. package/dist/simple-tree/schemaFactoryRecursive.d.ts.map +0 -1
  1406. package/dist/simple-tree/schemaFactoryRecursive.js.map +0 -1
  1407. package/dist/simple-tree/testRecursiveDomain.d.ts +0 -61
  1408. package/dist/simple-tree/testRecursiveDomain.d.ts.map +0 -1
  1409. package/dist/simple-tree/testRecursiveDomain.js.map +0 -1
  1410. package/dist/simple-tree/tree.d.ts.map +0 -1
  1411. package/dist/simple-tree/tree.js +0 -73
  1412. package/dist/simple-tree/tree.js.map +0 -1
  1413. package/dist/simple-tree/treeNodeApi.d.ts.map +0 -1
  1414. package/dist/simple-tree/treeNodeApi.js.map +0 -1
  1415. package/dist/simple-tree/treeNodeKernel.d.ts +0 -26
  1416. package/dist/simple-tree/treeNodeKernel.d.ts.map +0 -1
  1417. package/dist/simple-tree/treeNodeKernel.js +0 -83
  1418. package/dist/simple-tree/treeNodeKernel.js.map +0 -1
  1419. package/dist/simple-tree/types.d.ts.map +0 -1
  1420. package/dist/simple-tree/types.js.map +0 -1
  1421. package/lib/feature-libraries/contextuallyTyped.d.ts +0 -209
  1422. package/lib/feature-libraries/contextuallyTyped.d.ts.map +0 -1
  1423. package/lib/feature-libraries/contextuallyTyped.js +0 -311
  1424. package/lib/feature-libraries/contextuallyTyped.js.map +0 -1
  1425. package/lib/feature-libraries/schema-aware/index.d.ts +0 -6
  1426. package/lib/feature-libraries/schema-aware/index.d.ts.map +0 -1
  1427. package/lib/feature-libraries/schema-aware/index.js +0 -6
  1428. package/lib/feature-libraries/schema-aware/index.js.map +0 -1
  1429. package/lib/feature-libraries/schema-aware/schemaAware.d.ts +0 -76
  1430. package/lib/feature-libraries/schema-aware/schemaAware.d.ts.map +0 -1
  1431. package/lib/feature-libraries/schema-aware/schemaAware.js.map +0 -1
  1432. package/lib/simple-tree/nodeKeys.d.ts +0 -41
  1433. package/lib/simple-tree/nodeKeys.d.ts.map +0 -1
  1434. package/lib/simple-tree/nodeKeys.js.map +0 -1
  1435. package/lib/simple-tree/schemaCaching.d.ts.map +0 -1
  1436. package/lib/simple-tree/schemaCaching.js.map +0 -1
  1437. package/lib/simple-tree/schemaCreationUtilities.d.ts.map +0 -1
  1438. package/lib/simple-tree/schemaCreationUtilities.js.map +0 -1
  1439. package/lib/simple-tree/schemaFactory.d.ts.map +0 -1
  1440. package/lib/simple-tree/schemaFactory.js.map +0 -1
  1441. package/lib/simple-tree/schemaFactoryRecursive.d.ts.map +0 -1
  1442. package/lib/simple-tree/schemaFactoryRecursive.js.map +0 -1
  1443. package/lib/simple-tree/testRecursiveDomain.d.ts +0 -61
  1444. package/lib/simple-tree/testRecursiveDomain.d.ts.map +0 -1
  1445. package/lib/simple-tree/testRecursiveDomain.js.map +0 -1
  1446. package/lib/simple-tree/tree.d.ts.map +0 -1
  1447. package/lib/simple-tree/tree.js +0 -66
  1448. package/lib/simple-tree/tree.js.map +0 -1
  1449. package/lib/simple-tree/treeNodeApi.d.ts.map +0 -1
  1450. package/lib/simple-tree/treeNodeApi.js.map +0 -1
  1451. package/lib/simple-tree/treeNodeKernel.d.ts +0 -26
  1452. package/lib/simple-tree/treeNodeKernel.d.ts.map +0 -1
  1453. package/lib/simple-tree/treeNodeKernel.js +0 -79
  1454. package/lib/simple-tree/treeNodeKernel.js.map +0 -1
  1455. package/lib/simple-tree/types.d.ts.map +0 -1
  1456. package/lib/simple-tree/types.js.map +0 -1
  1457. package/src/feature-libraries/contextuallyTyped.ts +0 -582
  1458. package/src/feature-libraries/schema-aware/README.md +0 -19
  1459. package/src/feature-libraries/schema-aware/index.ts +0 -16
  1460. package/src/feature-libraries/schema-aware/schemaAware.ts +0 -135
  1461. package/src/simple-tree/nodeKeys.ts +0 -42
  1462. package/src/simple-tree/treeNodeKernel.ts +0 -91
  1463. /package/dist/simple-tree/{testRecursiveDomain.js → api/testRecursiveDomain.js} +0 -0
  1464. /package/lib/simple-tree/{testRecursiveDomain.js → api/testRecursiveDomain.js} +0 -0
@@ -0,0 +1,173 @@
1
+ "use strict";
2
+ /*!
3
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
4
+ * Licensed under the MIT License.
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.walkAllowedTypes = exports.walkFieldSchema = exports.walkNodeSchema = exports.checkUnion = exports.TreeViewConfiguration = void 0;
8
+ const internal_1 = require("@fluidframework/telemetry-utils/internal");
9
+ const schemaTypes_js_1 = require("../schemaTypes.js");
10
+ const index_js_1 = require("../core/index.js");
11
+ const toFlexSchema_js_1 = require("../toFlexSchema.js");
12
+ const leafNodeSchema_js_1 = require("../leafNodeSchema.js");
13
+ const internal_2 = require("@fluidframework/core-utils/internal");
14
+ const objectNodeTypes_js_1 = require("../objectNodeTypes.js");
15
+ const schemaFactory_js_1 = require("./schemaFactory.js");
16
+ const index_js_2 = require("../../util/index.js");
17
+ const defaultTreeConfigurationOptions = {
18
+ enableSchemaValidation: false,
19
+ preventAmbiguity: false,
20
+ };
21
+ /**
22
+ * Configuration for {@link ITree.viewWith}.
23
+ * @sealed @public
24
+ */
25
+ class TreeViewConfiguration {
26
+ /**
27
+ * @param props - Property bag of configuration options.
28
+ */
29
+ constructor(props) {
30
+ const config = { ...defaultTreeConfigurationOptions, ...props };
31
+ this.schema = config.schema;
32
+ this.enableSchemaValidation = config.enableSchemaValidation;
33
+ this.preventAmbiguity = config.preventAmbiguity;
34
+ // Ambiguity errors are lower priority to report than invalid schema errors, so collect these in an array and report them all at once.
35
+ const ambiguityErrors = [];
36
+ walkFieldSchema(config.schema, {
37
+ // Ensure all reachable schema are marked as most derived.
38
+ // This ensures if multiple schema extending the same schema factory generated class are present (or have been constructed, or get constructed in the future),
39
+ // an error is reported.
40
+ node: schemaFactory_js_1.markSchemaMostDerived,
41
+ allowedTypes(types) {
42
+ if (config.preventAmbiguity) {
43
+ checkUnion(types, ambiguityErrors);
44
+ }
45
+ },
46
+ });
47
+ if (ambiguityErrors.length !== 0) {
48
+ // Duplicate errors are common since when two types conflict, both orders error:
49
+ const deduplicated = new Set(ambiguityErrors);
50
+ throw new internal_1.UsageError(`Ambigious schema found:\n${[...deduplicated].join("\n")}`);
51
+ }
52
+ // Eagerly perform this conversion to surface errors sooner.
53
+ (0, toFlexSchema_js_1.toFlexSchema)(config.schema);
54
+ }
55
+ }
56
+ exports.TreeViewConfiguration = TreeViewConfiguration;
57
+ /**
58
+ * Pretty print a set of types for use in error messages.
59
+ */
60
+ function formatTypes(allowed) {
61
+ // Use JSON.stringify to quote and escape identifiers.
62
+ // Don't just use a single array JSON.stringify since that omits spaces between items
63
+ return `[${Array.from(allowed, (s) => JSON.stringify(s.identifier)).join(", ")}]`;
64
+ }
65
+ /**
66
+ * Detect cases documented in {@link ITreeConfigurationOptions.preventAmbiguity}.
67
+ */
68
+ function checkUnion(union, errors) {
69
+ const checked = new Set();
70
+ const maps = [];
71
+ const arrays = [];
72
+ const objects = [];
73
+ // Map from key to schema using that key
74
+ const allObjectKeys = new Map();
75
+ for (const schema of union) {
76
+ if (checked.has(schema)) {
77
+ throw new internal_1.UsageError(`Duplicate schema in allowed types: ${schema.identifier}`);
78
+ }
79
+ checked.add(schema);
80
+ if (schema instanceof leafNodeSchema_js_1.LeafNodeSchema) {
81
+ // nothing to do
82
+ }
83
+ else if ((0, objectNodeTypes_js_1.isObjectNodeSchema)(schema)) {
84
+ objects.push(schema);
85
+ for (const key of schema.fields.keys()) {
86
+ (0, index_js_2.getOrCreate)(allObjectKeys, key, () => new Set()).add(schema);
87
+ }
88
+ }
89
+ else if (schema.kind === index_js_1.NodeKind.Array) {
90
+ arrays.push(schema);
91
+ }
92
+ else {
93
+ (0, internal_2.assert)(schema.kind === index_js_1.NodeKind.Map, 0x9e7 /* invalid schema */);
94
+ maps.push(schema);
95
+ }
96
+ }
97
+ if (arrays.length > 1) {
98
+ errors.push(`More than one kind of array allowed within union (${formatTypes(arrays)}). This would require type disambiguation which is not supported by arrays during import or export.`);
99
+ }
100
+ if (maps.length > 1) {
101
+ errors.push(`More than one kind of map allowed within union (${formatTypes(maps)}). This would require type disambiguation which is not supported by maps during import or export.`);
102
+ }
103
+ if (maps.length > 0 && arrays.length > 0) {
104
+ errors.push(`Both a map and an array allowed within union (${formatTypes([...arrays, ...maps])}). Both can be implicitly constructed from iterables like arrays, which are ambiguous when the array is empty.`);
105
+ }
106
+ if (objects.length > 0 && maps.length > 0) {
107
+ errors.push(`Both a object and a map allowed within union (${formatTypes([...objects, ...maps])}). Both can be constructed from objects and can be ambiguous.`);
108
+ }
109
+ // Check for objects which fully overlap:
110
+ for (const schema of objects) {
111
+ // All objects which might be ambiguous relative to `schema`.
112
+ const possiblyAmbiguous = new Set(objects);
113
+ // A schema can't be ambiguous with itself
114
+ possiblyAmbiguous.delete(schema);
115
+ // For each field of schema, remove schema from possiblyAmbiguous that do not have that field
116
+ for (const [key, field] of schema.fields) {
117
+ if (field.kind === schemaTypes_js_1.FieldKind.Required) {
118
+ const withKey = allObjectKeys.get(key) ?? (0, index_js_2.fail)("missing schema");
119
+ for (const candidate of possiblyAmbiguous) {
120
+ if (!withKey.has(candidate)) {
121
+ possiblyAmbiguous.delete(candidate);
122
+ }
123
+ }
124
+ }
125
+ }
126
+ if (possiblyAmbiguous.size > 0) {
127
+ // TODO: make this check more permissive.
128
+ // Allow using the type of the field to disambiguate, at least for leaf types.
129
+ // Add "constant" fields which can be used to disambiguate even more cases without adding persisted data: maybe make them optional in constructor?
130
+ // Consider separating unambiguous implicit construction format from constructor arguments at type level, allowing constructor to superset the implicit construction options (ex: optional constant fields).
131
+ // The policy here however must remain at least as conservative as shallowCompatibilityTest in src/simple-tree/toMapTree.ts.
132
+ errors.push(`The required fields of ${JSON.stringify(schema.identifier)} are insufficient to differentiate it from the following types: ${formatTypes(possiblyAmbiguous)}. For objects to be considered unambiguous, each must have required fields that do not all occur on any other object in the union.`);
133
+ }
134
+ }
135
+ }
136
+ exports.checkUnion = checkUnion;
137
+ function walkNodeSchema(schema, visitor, visitedSet) {
138
+ if (visitedSet.has(schema)) {
139
+ return;
140
+ }
141
+ visitedSet.add(schema);
142
+ if (schema instanceof leafNodeSchema_js_1.LeafNodeSchema) {
143
+ // nothing to do
144
+ }
145
+ else if ((0, objectNodeTypes_js_1.isObjectNodeSchema)(schema)) {
146
+ for (const field of schema.fields.values()) {
147
+ walkFieldSchema(field, visitor, visitedSet);
148
+ }
149
+ }
150
+ else {
151
+ (0, internal_2.assert)(schema.kind === index_js_1.NodeKind.Array || schema.kind === index_js_1.NodeKind.Map, 0x9b3 /* invalid schema */);
152
+ const childTypes = schema.info;
153
+ walkAllowedTypes((0, schemaTypes_js_1.normalizeAllowedTypes)(childTypes), visitor, visitedSet);
154
+ }
155
+ // This visit is done at the end so the traversal order is most inner types first.
156
+ // This was picked since when fixing errors,
157
+ // working from the inner types out to the types that use them will probably go better than the reverse.
158
+ // This does not however ensure all types referenced by a type are visited before it, since in recursive cases thats impossible.
159
+ visitor.node?.(schema);
160
+ }
161
+ exports.walkNodeSchema = walkNodeSchema;
162
+ function walkFieldSchema(schema, visitor, visitedSet = new Set()) {
163
+ walkAllowedTypes((0, schemaTypes_js_1.normalizeFieldSchema)(schema).allowedTypeSet, visitor, visitedSet);
164
+ }
165
+ exports.walkFieldSchema = walkFieldSchema;
166
+ function walkAllowedTypes(allowedTypes, visitor, visitedSet) {
167
+ for (const childType of allowedTypes) {
168
+ walkNodeSchema(childType, visitor, visitedSet);
169
+ }
170
+ visitor.allowedTypes?.(allowedTypes);
171
+ }
172
+ exports.walkAllowedTypes = walkAllowedTypes;
173
+ //# sourceMappingURL=tree.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tree.js","sourceRoot":"","sources":["../../../src/simple-tree/api/tree.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,uEAAsE;AAMtE,sDAQ2B;AAC3B,+CAAiE;AACjE,wDAAkD;AAClD,4DAAsD;AACtD,kEAA6D;AAC7D,8DAAkF;AAClF,yDAA2D;AAC3D,kDAAwD;AA4IxD,MAAM,+BAA+B,GAAwC;IAC5E,sBAAsB,EAAE,KAAK;IAC7B,gBAAgB,EAAE,KAAK;CACvB,CAAC;AAeF;;;GAGG;AACH,MAAa,qBAAqB;IAoBjC;;OAEG;IACH,YAAmB,KAAsC;QACxD,MAAM,MAAM,GAAG,EAAE,GAAG,+BAA+B,EAAE,GAAG,KAAK,EAAE,CAAC;QAChE,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC;QAC5B,IAAI,CAAC,sBAAsB,GAAG,MAAM,CAAC,sBAAsB,CAAC;QAC5D,IAAI,CAAC,gBAAgB,GAAG,MAAM,CAAC,gBAAgB,CAAC;QAEhD,sIAAsI;QACtI,MAAM,eAAe,GAAa,EAAE,CAAC;QAErC,eAAe,CAAC,MAAM,CAAC,MAAM,EAAE;YAC9B,0DAA0D;YA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CAAC,cAAc,EAAE,OAAO,EAAE,UAAU,CAAC,CAAC;AACpF,CAAC;AAND,0CAMC;AAED,SAAgB,gBAAgB,CAC/B,YAAsC,EACtC,OAAsB,EACtB,UAA+B;IAE/B,KAAK,MAAM,SAAS,IAAI,YAAY,EAAE,CAAC;QACtC,cAAc,CAAC,SAAS,EAAE,OAAO,EAAE,UAAU,CAAC,CAAC;IAChD,CAAC;IACD,OAAO,CAAC,YAAY,EAAE,CAAC,YAAY,CAAC,CAAC;AACtC,CAAC;AATD,4CASC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { IFluidLoadable, IDisposable } from \"@fluidframework/core-interfaces\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\n\nimport type { CommitMetadata } from \"../../core/index.js\";\nimport type { Listenable } from \"../../events/index.js\";\nimport type { RevertibleFactory } from \"../../shared-tree/index.js\";\n\nimport {\n\ttype ImplicitAllowedTypes,\n\tnormalizeFieldSchema,\n\ttype ImplicitFieldSchema,\n\ttype InsertableTreeFieldFromImplicitField,\n\ttype TreeFieldFromImplicitField,\n\tFieldKind,\n\tnormalizeAllowedTypes,\n} from \"../schemaTypes.js\";\nimport { NodeKind, type TreeNodeSchema } from \"../core/index.js\";\nimport { toFlexSchema } from \"../toFlexSchema.js\";\nimport { LeafNodeSchema } from \"../leafNodeSchema.js\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport { isObjectNodeSchema, type ObjectNodeSchema } from \"../objectNodeTypes.js\";\nimport { markSchemaMostDerived } from \"./schemaFactory.js\";\nimport { fail, getOrCreate } from \"../../util/index.js\";\nimport type { MakeNominal } from \"../../util/index.js\";\n/**\n * Channel for a Fluid Tree DDS.\n * @remarks\n * Allows storing and collaboratively editing schema-aware hierarchial data.\n * @sealed @public\n */\nexport interface ITree extends IFluidLoadable {\n\t/**\n\t * Returns a {@link TreeView} using the provided schema.\n\t * If the stored schema is compatible with the view schema specified by `config`,\n\t * the returned {@link TreeView} will expose the root with a schema-aware API based on the provided view schema.\n\t * If the provided schema is incompatible with the stored schema, the view will instead expose a status indicating the incompatibility.\n\t *\n\t * @remarks\n\t * If the tree is uninitialized (has no schema and no content), use {@link TreeView.initialize} on the returned view to set the schema and content together.\n\t * Using `viewWith` followed by {@link TreeView.upgradeSchema} to initialize only the schema for a document is technically valid when the schema\n\t * permits trees with no content.\n\t *\n\t * Note that other clients can modify the document at any time, causing the view to change its compatibility status: see {@link TreeView.events} for how to handle invalidation in these cases.\n\t *\n\t * Only one schematized view may exist for a given ITree at a time.\n\t * If creating a second, the first must be disposed before calling `viewWith` again.\n\t *\n\t * @privateRemarks\n\t * TODO: Provide a way to make a generic view schema for any document.\n\t * TODO: Support adapters for handling out-of-schema data.\n\t *\n\t * Doing initialization here allows a small API that is hard to use incorrectly.\n\t * Other approaches tend to have easy-to-make mistakes.\n\t * For example, having a separate initialization function means apps can forget to call it, making an app that can only open existing documents,\n\t * or call it unconditionally leaving an app that can only create new documents.\n\t * It also would require the schema to be passed into separate places and could cause issues if they didn't match.\n\t * Since the initialization function couldn't return a typed tree, the type checking wouldn't help catch that.\n\t * Also, if an app manages to create a document, but the initialization fails to get persisted, an app that only calls the initialization function\n\t * on the create code-path (for example how a schematized factory might do it),\n\t * would leave the document in an unusable state which could not be repaired when it is reopened (by the same or other clients).\n\t * Additionally, once out of schema content adapters are properly supported (with lazy document updates),\n\t * this initialization could become just another out of schema content adapter and this initialization is no longer a special case.\n\t */\n\tviewWith<TRoot extends ImplicitFieldSchema>(\n\t\tconfig: TreeViewConfiguration<TRoot>,\n\t): TreeView<TRoot>;\n}\n\n/**\n * Options when constructing a tree view.\n * @public\n */\nexport interface ITreeConfigurationOptions {\n\t/**\n\t * If `true`, the tree will validate new content against its stored schema at insertion time\n\t * and throw an error if the new content doesn't match the expected schema.\n\t *\n\t * @defaultValue `false`.\n\t *\n\t * @remarks Enabling schema validation has a performance penalty when inserting new content into the tree because\n\t * additional checks are done. Enable this option only in scenarios where you are ok with that operation being a\n\t * bit slower.\n\t */\n\tenableSchemaValidation?: boolean;\n\n\t/**\n\t * A flag used to opt into strict rules ensuring that the schema avoids cases which can make the type of nodes ambiguous when importing or exporting data.\n\t * @defaultValue `false`.\n\t *\n\t * @remarks\n\t * When this is true, it ensures that the compile time type safety for data when constructing nodes is sufficient to ensure that the runtime behavior will not give node data ambiguity errors.\n\t *\n\t * This ensures that the canonical JSON-like representation of all unions in the tree are lossless and unambiguous.\n\t * This canonical JSON-like representation consists of arrays, plain old JavaScript objects with string keys, booleans, numbers (excluding NaN, -0 and infinities), strings, null and {@link @fluidframework/core-interfaces#IFluidHandle}s.\n\t * It is compatible with the node creation APIs (such as schema class constructors) and is also compatible with JSON assuming any IFluidHandles get special handling (since they are not JSON compatible).\n\t * Currently these cases can cause ambiguity in a union:\n\t *\n\t * - More than one ArrayNode type: it's impossible to tell which array type is intended in the case of empty arrays (`[]`).\n\t *\n\t * - More than one MapNode type: it's impossible to tell which map type is intended in the case of an empty map (`{}`).\n\t *\n\t * - Both a MapNode and an ArrayNode: this case is not a problem for the canonical JSON representation, but is an issue when constructing from an Iterable, which is supported for both MapNode and ArrayNode.\n\t *\n\t * - Both a MapNode and an ObjectNode: when the input is valid for the ObjectNode, the current parser always considers it ambiguous with being a MapNode.\n\t *\n\t * - ObjectNodes which have fields (required or optional) which include all required fields of another ObjectNode: currently each ObjectNode is differentiated by the presence of its required fields.\n\t *\n\t * This check is conservative: some complex cases may error if the current simple algorithm cannot show no ambiguity is possible.\n\t * This check may become more permissive over time.\n\t *\n\t * @example Ambiguous schema (with `preventAmbiguity: false`), and how to disambiguate it using {@link Unhydrated} nodes:\n\t * ```typescript\n\t * const schemaFactory = new SchemaFactory(\"com.example\");\n\t * class Feet extends schemaFactory.object(\"Feet\", { length: schemaFactory.number }) {}\n\t * class Meters extends schemaFactory.object(\"Meters\", { length: schemaFactory.number }) {}\n\t * const config = new TreeViewConfiguration({\n\t * \t// This combination of schema can lead to ambiguous cases and will error if `preventAmbiguity` is true.\n\t * \tschema: [Feet, Meters],\n\t * \tpreventAmbiguity: false,\n\t * });\n\t * const view = tree.viewWith(config);\n\t * // This is invalid since it is ambiguous which type of node is being constructed:\n\t * // view.initialize({ length: 5 });\n\t * // To work, an explicit type can be provided by using an {@link Unhydrated} Node:\n\t * view.initialize(new Meters({ length: 5 }));\n\t * ```\n\t *\n\t * @example Schema disambiguated by adjusting field names, validated with `preventAmbiguity: true:`\n\t * ```typescript\n\t * const schemaFactory = new SchemaFactory(\"com.example\");\n\t * class Feet extends schemaFactory.object(\"Feet\", { length: schemaFactory.number }) {}\n\t * class Meters extends schemaFactory.object(\"Meters\", {\n\t * \t// To avoid ambiguity when parsing unions of Feet and Meters, this renames the length field to \"meters\".\n\t * \t// To preserve compatibility with existing data from the ambiguous case,\n\t * \t// `{ key: \"length\" }` is set, so when persisted in the tree \"length\" is used as the field name.\n\t * \tmeters: schemaFactory.required(schemaFactory.number, { key: \"length\" }),\n\t * }) {}\n\t * const config = new TreeViewConfiguration({\n\t * \t// This combination of schema is not ambiguous because `Feet` and `Meters` have different required keys.\n\t * \tschema: [Feet, Meters],\n\t * \tpreventAmbiguity: true,\n\t * });\n\t * const view = tree.viewWith(config);\n\t * // This now works, since the field is sufficient to determine this is a `Meters` node.\n\t * view.initialize({ meters: 5 });\n\t * ```\n\t *\n\t * @privateRemarks\n\t * In the future, we can support lossless round tripping via the canonical JSON-like representation above when unambiguous.\n\t * This could be done via methods added to `Tree` to export and import such objects, which would give us a place to explicitly define the type of this representation.\n\t *\n\t * To make this more permissive in the future we can:\n\t *\n\t * - Make toMapTree more permissive (ex: allow disambiguation based on leaf type)\n\t * - Update this check to more tightly match toMapTree\n\t * - Add options to help schema authors disambiguate their types, such as \"constant fields\" which are not persisted, and always have a constant value.\n\t *\n\t * The above examples exist in executable form in this files tests, and should be updated there then copied back here.\n\t */\n\treadonly preventAmbiguity?: boolean;\n}\n\nconst defaultTreeConfigurationOptions: Required<ITreeConfigurationOptions> = {\n\tenableSchemaValidation: false,\n\tpreventAmbiguity: false,\n};\n\n/**\n * Property-bag configuration for {@link TreeViewConfiguration} construction.\n * @public\n */\nexport interface ITreeViewConfiguration<\n\tTSchema extends ImplicitFieldSchema = ImplicitFieldSchema,\n> extends ITreeConfigurationOptions {\n\t/**\n\t * The schema which the application wants to view the tree with.\n\t */\n\treadonly schema: TSchema;\n}\n\n/**\n * Configuration for {@link ITree.viewWith}.\n * @sealed @public\n */\nexport class TreeViewConfiguration<TSchema extends ImplicitFieldSchema = ImplicitFieldSchema>\n\timplements Required<ITreeViewConfiguration<TSchema>>\n{\n\tprotected _typeCheck!: MakeNominal;\n\n\t/**\n\t * {@inheritDoc ITreeViewConfiguration.schema}\n\t */\n\tpublic readonly schema: TSchema;\n\n\t/**\n\t * {@inheritDoc ITreeConfigurationOptions.enableSchemaValidation}\n\t */\n\tpublic readonly enableSchemaValidation: boolean;\n\n\t/**\n\t * {@inheritDoc ITreeConfigurationOptions.preventAmbiguity}\n\t */\n\tpublic readonly preventAmbiguity: boolean;\n\n\t/**\n\t * @param props - Property bag of configuration options.\n\t */\n\tpublic constructor(props: ITreeViewConfiguration<TSchema>) {\n\t\tconst config = { ...defaultTreeConfigurationOptions, ...props };\n\t\tthis.schema = config.schema;\n\t\tthis.enableSchemaValidation = config.enableSchemaValidation;\n\t\tthis.preventAmbiguity = config.preventAmbiguity;\n\n\t\t// Ambiguity errors are lower priority to report than invalid schema errors, so collect these in an array and report them all at once.\n\t\tconst ambiguityErrors: string[] = [];\n\n\t\twalkFieldSchema(config.schema, {\n\t\t\t// Ensure all reachable schema are marked as most derived.\n\t\t\t// This ensures if multiple schema extending the same schema factory generated class are present (or have been constructed, or get constructed in the future),\n\t\t\t// an error is reported.\n\n\t\t\tnode: markSchemaMostDerived,\n\t\t\tallowedTypes(types): void {\n\t\t\t\tif (config.preventAmbiguity) {\n\t\t\t\t\tcheckUnion(types, ambiguityErrors);\n\t\t\t\t}\n\t\t\t},\n\t\t});\n\n\t\tif (ambiguityErrors.length !== 0) {\n\t\t\t// Duplicate errors are common since when two types conflict, both orders error:\n\t\t\tconst deduplicated = new Set(ambiguityErrors);\n\t\t\tthrow new UsageError(`Ambigious schema found:\\n${[...deduplicated].join(\"\\n\")}`);\n\t\t}\n\n\t\t// Eagerly perform this conversion to surface errors sooner.\n\t\ttoFlexSchema(config.schema);\n\t}\n}\n\n/**\n * Pretty print a set of types for use in error messages.\n */\nfunction formatTypes(allowed: Iterable<TreeNodeSchema>): string {\n\t// Use JSON.stringify to quote and escape identifiers.\n\t// Don't just use a single array JSON.stringify since that omits spaces between items\n\treturn `[${Array.from(allowed, (s) => JSON.stringify(s.identifier)).join(\", \")}]`;\n}\n\n/**\n * Detect cases documented in {@link ITreeConfigurationOptions.preventAmbiguity}.\n */\nexport function checkUnion(union: Iterable<TreeNodeSchema>, errors: string[]): void {\n\tconst checked: Set<TreeNodeSchema> = new Set();\n\tconst maps: TreeNodeSchema[] = [];\n\tconst arrays: TreeNodeSchema[] = [];\n\n\tconst objects: ObjectNodeSchema[] = [];\n\t// Map from key to schema using that key\n\tconst allObjectKeys: Map<string, Set<TreeNodeSchema>> = new Map();\n\n\tfor (const schema of union) {\n\t\tif (checked.has(schema)) {\n\t\t\tthrow new UsageError(`Duplicate schema in allowed types: ${schema.identifier}`);\n\t\t}\n\t\tchecked.add(schema);\n\n\t\tif (schema instanceof LeafNodeSchema) {\n\t\t\t// nothing to do\n\t\t} else if (isObjectNodeSchema(schema)) {\n\t\t\tobjects.push(schema);\n\t\t\tfor (const key of schema.fields.keys()) {\n\t\t\t\tgetOrCreate(allObjectKeys, key, () => new Set()).add(schema);\n\t\t\t}\n\t\t} else if (schema.kind === NodeKind.Array) {\n\t\t\tarrays.push(schema);\n\t\t} else {\n\t\t\tassert(schema.kind === NodeKind.Map, 0x9e7 /* invalid schema */);\n\t\t\tmaps.push(schema);\n\t\t}\n\t}\n\n\tif (arrays.length > 1) {\n\t\terrors.push(\n\t\t\t`More than one kind of array allowed within union (${formatTypes(arrays)}). This would require type disambiguation which is not supported by arrays during import or export.`,\n\t\t);\n\t}\n\n\tif (maps.length > 1) {\n\t\terrors.push(\n\t\t\t`More than one kind of map allowed within union (${formatTypes(maps)}). This would require type disambiguation which is not supported by maps during import or export.`,\n\t\t);\n\t}\n\n\tif (maps.length > 0 && arrays.length > 0) {\n\t\terrors.push(\n\t\t\t`Both a map and an array allowed within union (${formatTypes([...arrays, ...maps])}). Both can be implicitly constructed from iterables like arrays, which are ambiguous when the array is empty.`,\n\t\t);\n\t}\n\n\tif (objects.length > 0 && maps.length > 0) {\n\t\terrors.push(\n\t\t\t`Both a object and a map allowed within union (${formatTypes([...objects, ...maps])}). Both can be constructed from objects and can be ambiguous.`,\n\t\t);\n\t}\n\n\t// Check for objects which fully overlap:\n\tfor (const schema of objects) {\n\t\t// All objects which might be ambiguous relative to `schema`.\n\t\tconst possiblyAmbiguous = new Set(objects);\n\n\t\t// A schema can't be ambiguous with itself\n\t\tpossiblyAmbiguous.delete(schema);\n\n\t\t// For each field of schema, remove schema from possiblyAmbiguous that do not have that field\n\t\tfor (const [key, field] of schema.fields) {\n\t\t\tif (field.kind === FieldKind.Required) {\n\t\t\t\tconst withKey = allObjectKeys.get(key) ?? fail(\"missing schema\");\n\t\t\t\tfor (const candidate of possiblyAmbiguous) {\n\t\t\t\t\tif (!withKey.has(candidate)) {\n\t\t\t\t\t\tpossiblyAmbiguous.delete(candidate);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (possiblyAmbiguous.size > 0) {\n\t\t\t// TODO: make this check more permissive.\n\t\t\t// Allow using the type of the field to disambiguate, at least for leaf types.\n\t\t\t// Add \"constant\" fields which can be used to disambiguate even more cases without adding persisted data: maybe make them optional in constructor?\n\t\t\t// Consider separating unambiguous implicit construction format from constructor arguments at type level, allowing constructor to superset the implicit construction options (ex: optional constant fields).\n\t\t\t// The policy here however must remain at least as conservative as shallowCompatibilityTest in src/simple-tree/toMapTree.ts.\n\n\t\t\terrors.push(\n\t\t\t\t`The required fields of ${JSON.stringify(schema.identifier)} are insufficient to differentiate it from the following types: ${formatTypes(possiblyAmbiguous)}. For objects to be considered unambiguous, each must have required fields that do not all occur on any other object in the union.`,\n\t\t\t);\n\t\t}\n\t}\n}\n\nexport function walkNodeSchema(\n\tschema: TreeNodeSchema,\n\tvisitor: SchemaVisitor,\n\tvisitedSet: Set<TreeNodeSchema>,\n): void {\n\tif (visitedSet.has(schema)) {\n\t\treturn;\n\t}\n\tvisitedSet.add(schema);\n\tif (schema instanceof LeafNodeSchema) {\n\t\t// nothing to do\n\t} else if (isObjectNodeSchema(schema)) {\n\t\tfor (const field of schema.fields.values()) {\n\t\t\twalkFieldSchema(field, visitor, visitedSet);\n\t\t}\n\t} else {\n\t\tassert(\n\t\t\tschema.kind === NodeKind.Array || schema.kind === NodeKind.Map,\n\t\t\t0x9b3 /* invalid schema */,\n\t\t);\n\t\tconst childTypes = schema.info as ImplicitAllowedTypes;\n\t\twalkAllowedTypes(normalizeAllowedTypes(childTypes), visitor, visitedSet);\n\t}\n\t// This visit is done at the end so the traversal order is most inner types first.\n\t// This was picked since when fixing errors,\n\t// working from the inner types out to the types that use them will probably go better than the reverse.\n\t// This does not however ensure all types referenced by a type are visited before it, since in recursive cases thats impossible.\n\tvisitor.node?.(schema);\n}\n\nexport function walkFieldSchema(\n\tschema: ImplicitFieldSchema,\n\tvisitor: SchemaVisitor,\n\tvisitedSet: Set<TreeNodeSchema> = new Set(),\n): void {\n\twalkAllowedTypes(normalizeFieldSchema(schema).allowedTypeSet, visitor, visitedSet);\n}\n\nexport function walkAllowedTypes(\n\tallowedTypes: Iterable<TreeNodeSchema>,\n\tvisitor: SchemaVisitor,\n\tvisitedSet: Set<TreeNodeSchema>,\n): void {\n\tfor (const childType of allowedTypes) {\n\t\twalkNodeSchema(childType, visitor, visitedSet);\n\t}\n\tvisitor.allowedTypes?.(allowedTypes);\n}\n\n/**\n * Callbacks for use in {@link walkFieldSchema} / {@link walkAllowedTypes} / {@link walkNodeSchema}.\n */\nexport interface SchemaVisitor {\n\t/**\n\t * Called once for each node schema.\n\t */\n\tnode?: (schema: TreeNodeSchema) => void;\n\t/**\n\t * Called once for each set of allowed types.\n\t * Includes implicit allowed types (when a single type was used instead of an array).\n\t *\n\t * This includes every field, but also the allowed types array for maps and arrays and the root if starting at {@link walkAllowedTypes}.\n\t */\n\tallowedTypes?: (allowedTypes: Iterable<TreeNodeSchema>) => void;\n}\n\n/**\n * An editable view of a (version control style) branch of a shared tree based on some schema.\n *\n * This schema--known as the view schema--may or may not align the stored schema of the document.\n * Information about discrepancies between the two schemas is available via {@link TreeView.compatibility | compatibility}.\n *\n * Application authors are encouraged to read [schema-evolution.md](../../docs/user-facing/schema-evolution.md) and\n * choose a schema compatibility policy that aligns with their application's needs.\n *\n * @privateRemarks\n * From an API design perspective, `upgradeSchema` could be merged into `viewWith` and/or `viewWith` could return errors explicitly on incompatible documents.\n * Such approaches would make it discoverable that out of schema handling may need to be done.\n * Doing that would however complicate trivial \"hello world\" style example slightly, as well as be a breaking API change.\n * It also seems more complex to handle invalidation with that pattern.\n * Thus this design was chosen at the risk of apps blindly accessing `root` then breaking unexpectedly when the document is incompatible.\n * @sealed @public\n */\nexport interface TreeView<TSchema extends ImplicitFieldSchema> extends IDisposable {\n\t/**\n\t * The current root of the tree.\n\t *\n\t * If the view schema not sufficiently compatible with the stored schema, accessing this will throw.\n\t * To handle this case, check {@link TreeView.compatibility | compatibility}'s {@link SchemaCompatibilityStatus.canView | canView} before using.\n\t *\n\t * To get notified about changes to this field,\n\t * use {@link TreeViewEvents.rootChanged} via `view.events.on(\"rootChanged\", callback)`.\n\t *\n\t * To get notified about changes to stored schema (which may affect compatibility between this view's schema and\n\t * the stored schema), use {@link TreeViewEvents.schemaChanged} via `view.events.on(\"schemaChanged\", callback)`.\n\t */\n\tget root(): TreeFieldFromImplicitField<TSchema>;\n\n\tset root(newRoot: InsertableTreeFieldFromImplicitField<TSchema>);\n\n\t/**\n\t * Description of the current compatibility status between the view schema and stored schema.\n\t *\n\t * {@link TreeViewEvents.schemaChanged} is fired when the compatibility status changes.\n\t */\n\treadonly compatibility: SchemaCompatibilityStatus;\n\n\t/**\n\t * When the schemas are not an exact match and {@link SchemaCompatibilityStatus.canUpgrade} is true,\n\t * this can be used to modify the stored schema to make it match the view schema.\n\t * This will update the compatibility state, and allow access to `root`.\n\t * Beware that this may impact other clients' ability to view the document depending on the application's schema compatibility policy!\n\t * @remarks\n\t * It is an error to call this when {@link SchemaCompatibilityStatus.canUpgrade} is false, and a no-op when the stored and view schema are already an exact match.\n\t * @privateRemarks\n\t * In the future, more upgrade options could be provided here.\n\t * Some options that could be added:\n\t * - check the actual document contents (not just the schema) and attempt an atomic document update if the data is compatible.\n\t * - apply converters and upgrade the document.\n\t * - apply converters to lazily to adapt the document to the requested view schema (with optional lazy schema updates or transparent conversions on write).\n\t */\n\tupgradeSchema(): void;\n\n\t/**\n\t * Initialize the tree, setting the stored schema to match this view's schema and setting the tree content.\n\t *\n\t * Only valid to call when this view's {@link SchemaCompatibilityStatus.canInitialize} is true.\n\t *\n\t * Applications should typically call this function before attaching a `SharedTree`.\n\t * @param content - The content to initialize the tree with.\n\t */\n\tinitialize(content: InsertableTreeFieldFromImplicitField<TSchema>): void;\n\n\t/**\n\t * Events for the tree.\n\t */\n\treadonly events: Listenable<TreeViewEvents>;\n}\n\n/**\n * Information about a view schema's compatibility with the document's stored schema.\n *\n * See SharedTree's README for more information about choosing a compatibility policy.\n * @sealed @public\n */\nexport interface SchemaCompatibilityStatus {\n\t/**\n\t * Whether the view schema allows exactly the same set of documents as the stored schema.\n\t *\n\t * @remarks\n\t * Equivalence here is defined in terms of allowed documents because there are some degenerate cases where schemas are not\n\t * exact matches in a strict (schema-based) sense but still allow the same documents, and the document notion is more useful to applications.\n\t *\n\t * Examples which are expressible where this may occur include:\n\t * - schema repository `A` has extra schema which schema `B` doesn't have, but they are unused (i.e. not reachable from the root schema)\n\t * - field in schema `A` has allowed field members which the corresponding field in schema `B` does not have, but those types are not constructible (ex: an object node type containing a required field with no allowed types)\n\t *\n\t * These cases are typically not interesting to applications.\n\t */\n\treadonly isEquivalent: boolean;\n\n\t/**\n\t * Whether the current view schema is sufficiently compatible with the stored schema to allow viewing tree data.\n\t * If false, {@link TreeView.root} will throw upon access.\n\t *\n\t * Currently, this field is true iff `isEquivalent` is true.\n\t * Do not rely on this:\n\t * there are near-term plans to extend support for viewing documents when the stored schema contains additional optional fields not present in the view schema.\n\t * The other two types of backward-compatible changes (field relaxations and addition of allowed field types) will eventually be supported as well,\n\t * likely through out-of-schema content adapters that the application can provide alongside their view schema.\n\t *\n\t * Be aware that even with these SharedTree limitations fixed, application logic may not correctly tolerate the documents allowable by the stored schema!\n\t * Application authors are encouraged to read docs/user-facing/schema-evolution.md and choose a schema compatibility policy that\n\t * aligns with their application's needs.\n\t *\n\t * @remarks\n\t * When the documents allowed by the view schema is a strict superset of those by the stored schema,\n\t * this is false because writes to the document using the view schema could make the document violate its stored schema.\n\t * In this case, the stored schema could be updated to match the provided view schema, allowing read-write access to the tree.\n\t * See {@link SchemaCompatibilityStatus.canUpgrade}.\n\t *\n\t * Future version of SharedTree may provide readonly access to the document in this case because that would be safe,\n\t * but this is not currently supported.\n\t *\n\t * @privateRemarks\n\t * A necessary condition for this to be true is that the documents allowed by the view schema are a subset of those allowed by the stored schema.\n\t * This is not sufficient: the simple-tree layer's read APIs do not tolerate out-of-schema data.\n\t * For example, if the view schema for a node has a required `Point` field but the stored schema has an optional `Point` field,\n\t * read APIs on the view schema do not work correctly when the document has a node with a missing `Point` field.\n\t * Similar issues happen when the view schema has a field with less allowed types than the stored schema and the document actually leverages those types.\n\t */\n\treadonly canView: boolean;\n\n\t/**\n\t * True iff the view schema supports all possible documents permitted by the stored schema.\n\t * When true, it is valid to call {@link TreeView.upgradeSchema} (though if the stored schema is already an exact match, this is a no-op).\n\t */\n\treadonly canUpgrade: boolean;\n\n\t/**\n\t * True iff the document is uninitialized (i.e. it has no schema and no content).\n\t *\n\t * To initialize the document, call {@link TreeView.initialize}.\n\t *\n\t * @remarks\n\t * It's not necessary to check this field before calling {@link TreeView.initialize} in most scenarios; application authors typically know from\n\t * context that they're in a flow which creates a new `SharedTree` and would like to initialize it.\n\t */\n\treadonly canInitialize: boolean;\n\n\t// TODO: Consider extending this status to include:\n\t// - application-defined metadata about the stored schema\n\t// - details about the differences between the stored and view schema sufficient for implementing \"safe mismatch\" policies\n}\n\n/**\n * Events for {@link TreeView}.\n * @sealed @public\n */\nexport interface TreeViewEvents {\n\t/**\n\t * Raised whenever {@link TreeView.root} is invalidated.\n\t *\n\t * This includes changes to the document schema.\n\t * It also includes changes to the field containing the root such as setting or clearing an optional root or changing which node is the root.\n\t * This does NOT include changes to the content (fields/children) of the root node: for that case subscribe to events on the root node.\n\t */\n\trootChanged(): void;\n\n\t/**\n\t * The stored schema for the document has changed.\n\t * This may affect the compatibility between the view schema and the stored schema, and thus the ability to use the view.\n\t *\n\t * @remarks\n\t * This event implies that the old {@link TreeView.root} is no longer valid, but applications need not handle that separately:\n\t * {@link TreeViewEvents.rootChanged} will be fired after this event.\n\t */\n\tschemaChanged(): void;\n\n\t/**\n\t * Fired when:\n\t * - a local commit is applied outside of a transaction\n\t * - a local transaction is committed\n\t *\n\t * The event is not fired when:\n\t * - a local commit is applied within a transaction\n\t * - a remote commit is applied\n\t *\n\t * @param data - information about the commit that was applied\n\t * @param getRevertible - a function provided that allows users to get a revertible for the commit that was applied. If not provided,\n\t * this commit is not revertible.\n\t */\n\tcommitApplied(data: CommitMetadata, getRevertible?: RevertibleFactory): void;\n}\n"]}
@@ -2,9 +2,9 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
- import { type TreeStatus } from "../feature-libraries/index.js";
6
- import { NodeKind, type TreeLeafValue, type TreeNodeSchema, type ImplicitAllowedTypes, type TreeNodeFromImplicitAllowedTypes } from "./schemaTypes.js";
7
- import type { TreeNode, TreeChangeEvents } from "./types.js";
5
+ import { type TreeStatus } from "../../feature-libraries/index.js";
6
+ import { type TreeLeafValue, type ImplicitAllowedTypes, type TreeNodeFromImplicitAllowedTypes } from "../schemaTypes.js";
7
+ import { type TreeNodeSchema, type TreeNode, type TreeChangeEvents } from "../core/index.js";
8
8
  /**
9
9
  * Provides various functions for analyzing {@link TreeNode}s.
10
10
  * * @remarks
@@ -21,7 +21,7 @@ export interface TreeNodeApi {
21
21
  /**
22
22
  * The schema information for this node.
23
23
  */
24
- schema<T extends TreeNode | TreeLeafValue>(node: T): TreeNodeSchema<string, NodeKind, unknown, T>;
24
+ schema(node: TreeNode | TreeLeafValue): TreeNodeSchema;
25
25
  /**
26
26
  * Narrow the type of the given value if it satisfies the given schema.
27
27
  * @example
@@ -51,7 +51,7 @@ export interface TreeNodeApi {
51
51
  * @returns A callback function which will deregister the event.
52
52
  * This callback should be called only once.
53
53
  */
54
- on<K extends keyof TreeChangeEvents>(node: TreeNode, eventName: K, listener: TreeChangeEvents[K]): () => void;
54
+ on<K extends keyof TreeChangeEvents<TNode>, TNode extends TreeNode>(node: TNode, eventName: K, listener: TreeChangeEvents<TNode>[K]): () => void;
55
55
  /**
56
56
  * Returns the {@link TreeStatus} of the given node.
57
57
  */
@@ -60,6 +60,7 @@ export interface TreeNodeApi {
60
60
  * Returns the {@link SchemaFactory.identifier | identifier} of the given node in the most compressed form possible.
61
61
  * @remarks
62
62
  * If the node's identifier is a valid UUID that was automatically generated by the SharedTree, then this will return a process-unique integer corresponding to that identifier.
63
+ * Note that the node must already have been inserted into the tree in order to retrieve a generated UUID (or shortId will error).
63
64
  * This is useful for performance-sensitive scenarios involving many nodes with identifiers that need to be compactly retained in memory or used for efficient lookup.
64
65
  *
65
66
  * If the node's identifier is any other user-provided string, then this will return that string.
@@ -82,5 +83,5 @@ export declare const treeNodeApi: TreeNodeApi;
82
83
  * Returns a schema for a value if the value is a {@link TreeNode} or a {@link TreeLeafValue}.
83
84
  * Returns undefined for other values.
84
85
  */
85
- export declare function tryGetSchema<T>(value: T): undefined | TreeNodeSchema<string, NodeKind, unknown, T>;
86
+ export declare function tryGetSchema(value: unknown): undefined | TreeNodeSchema;
86
87
  //# sourceMappingURL=treeNodeApi.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"treeNodeApi.d.ts","sourceRoot":"","sources":["../../../src/simple-tree/api/treeNodeApi.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,EAEN,KAAK,UAAU,EAKf,MAAM,kCAAkC,CAAC;AAK1C,OAAO,EACN,KAAK,aAAa,EAGlB,KAAK,oBAAoB,EACzB,KAAK,gCAAgC,EACrC,MAAM,mBAAmB,CAAC;AAW3B,OAAO,EAGN,KAAK,cAAc,EAEnB,KAAK,QAAQ,EACb,KAAK,gBAAgB,EAErB,MAAM,kBAAkB,CAAC;AAG1B;;;;;;;;;;;GAWG;AACH,MAAM,WAAW,WAAW;IAC3B;;OAEG;IACH,MAAM,CAAC,IAAI,EAAE,QAAQ,GAAG,aAAa,GAAG,cAAc,CAAC;IAEvD;;;;;;;;OAQG;IACH,EAAE,CAAC,OAAO,SAAS,oBAAoB,EACtC,KAAK,EAAE,OAAO,EACd,MAAM,EAAE,OAAO,GACb,KAAK,IAAI,gCAAgC,CAAC,OAAO,CAAC,CAAC;IAEtD;;OAEG;IACH,MAAM,CAAC,IAAI,EAAE,QAAQ,GAAG,QAAQ,GAAG,SAAS,CAAC;IAE7C;;;;;OAKG;IACH,GAAG,CAAC,IAAI,EAAE,QAAQ,GAAG,MAAM,GAAG,MAAM,CAAC;IAErC;;;;;;;OAOG;IACH,EAAE,CAAC,CAAC,SAAS,MAAM,gBAAgB,CAAC,KAAK,CAAC,EAAE,KAAK,SAAS,QAAQ,EACjE,IAAI,EAAE,KAAK,EACX,SAAS,EAAE,CAAC,EACZ,QAAQ,EAAE,gBAAgB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,GAClC,MAAM,IAAI,CAAC;IAEd;;OAEG;IACH,MAAM,CAAC,IAAI,EAAE,QAAQ,GAAG,UAAU,CAAC;IAEnC;;;;;;;;;;;;;;;;OAgBG;IACH,OAAO,CAAC,IAAI,EAAE,QAAQ,GAAG,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;CACrD;AAED;;GAEG;AACH,eAAO,MAAM,WAAW,EAAE,WAgIzB,CAAC;AAEF;;;GAGG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,OAAO,GAAG,SAAS,GAAG,cAAc,CAuBvE"}
@@ -6,26 +6,27 @@
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
7
  exports.tryGetSchema = exports.treeNodeApi = void 0;
8
8
  const internal_1 = require("@fluidframework/core-utils/internal");
9
- const index_js_1 = require("../core/index.js");
10
- const index_js_2 = require("../feature-libraries/index.js");
11
- const index_js_3 = require("../util/index.js");
12
- const proxies_js_1 = require("./proxies.js");
13
- const proxyBinding_js_1 = require("./proxyBinding.js");
14
- const schemaCaching_js_1 = require("./schemaCaching.js");
15
- const schemaTypes_js_1 = require("./schemaTypes.js");
16
- const leafNodeSchema_js_1 = require("./leafNodeSchema.js");
9
+ const index_js_1 = require("../../core/index.js");
10
+ const index_js_2 = require("../../feature-libraries/index.js");
11
+ const index_js_3 = require("../../util/index.js");
12
+ const proxies_js_1 = require("../proxies.js");
13
+ const proxyBinding_js_1 = require("../proxyBinding.js");
14
+ const schemaTypes_js_1 = require("../schemaTypes.js");
15
+ const leafNodeSchema_js_1 = require("../leafNodeSchema.js");
17
16
  const internal_2 = require("@fluidframework/runtime-utils/internal");
18
17
  const internal_3 = require("@fluidframework/telemetry-utils/internal");
18
+ const index_js_4 = require("../core/index.js");
19
+ const objectNodeTypes_js_1 = require("../objectNodeTypes.js");
19
20
  /**
20
21
  * The `Tree` object holds various functions for analyzing {@link TreeNode}s.
21
22
  */
22
23
  exports.treeNodeApi = {
23
24
  parent(node) {
24
- const editNode = (0, proxyBinding_js_1.getFlexNode)(node).parentField.parent.parent;
25
+ const editNode = (0, proxyBinding_js_1.getOrCreateInnerNode)(node).parentField.parent.parent;
25
26
  if (editNode === undefined) {
26
27
  return undefined;
27
28
  }
28
- const output = (0, proxies_js_1.getOrCreateNodeProxy)(editNode);
29
+ const output = (0, proxies_js_1.getOrCreateNodeFromFlexTreeNode)(editNode);
29
30
  (0, internal_1.assert)(!(0, index_js_2.isTreeValue)(output), 0x87f /* Parent can't be a leaf, so it should be a node not a value */);
30
31
  return output;
31
32
  },
@@ -45,10 +46,37 @@ exports.treeNodeApi = {
45
46
  return viewKey;
46
47
  },
47
48
  on(node, eventName, listener) {
48
- return (0, proxyBinding_js_1.getKernel)(node).on(eventName, listener);
49
+ const kernel = (0, index_js_4.getKernel)(node);
50
+ switch (eventName) {
51
+ case "nodeChanged": {
52
+ const nodeSchema = kernel.schema;
53
+ if ((0, objectNodeTypes_js_1.isObjectNodeSchema)(nodeSchema)) {
54
+ return kernel.on("childrenChangedAfterBatch", ({ changedFields }) => {
55
+ const changedProperties = new Set(Array.from(changedFields, (field) => nodeSchema.storedKeyToPropertyKey.get(field) ??
56
+ (0, index_js_3.fail)(`Could not find stored key '${field}' in schema.`)));
57
+ listener({ changedProperties });
58
+ });
59
+ }
60
+ else if (nodeSchema.kind === index_js_4.NodeKind.Array) {
61
+ return kernel.on("childrenChangedAfterBatch", () => {
62
+ listener({ changedProperties: undefined });
63
+ });
64
+ }
65
+ else {
66
+ return kernel.on("childrenChangedAfterBatch", ({ changedFields }) => {
67
+ listener({ changedProperties: changedFields });
68
+ });
69
+ }
70
+ }
71
+ case "treeChanged": {
72
+ return kernel.on("subtreeChangedAfterBatch", () => listener({}));
73
+ }
74
+ default:
75
+ throw new internal_3.UsageError(`No event named ${JSON.stringify(eventName)}.`);
76
+ }
49
77
  },
50
78
  status(node) {
51
- return (0, proxyBinding_js_1.getKernel)(node).getStatus();
79
+ return (0, index_js_4.getKernel)(node).getStatus();
52
80
  },
53
81
  is(value, schema) {
54
82
  const actualSchema = tryGetSchema(value);
@@ -65,6 +93,8 @@ exports.treeNodeApi = {
65
93
  return false;
66
94
  }
67
95
  else {
96
+ // Linter is incorrect about this bering unnecessary: it does not compile without the type assertion.
97
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
68
98
  return schema === actualSchema;
69
99
  }
70
100
  },
@@ -72,15 +102,21 @@ exports.treeNodeApi = {
72
102
  return tryGetSchema(node) ?? (0, index_js_3.fail)("Not a tree node");
73
103
  },
74
104
  shortId(node) {
75
- const flexNode = (0, proxyBinding_js_1.getFlexNode)(node);
105
+ const flexNode = (0, proxyBinding_js_1.getOrCreateInnerNode)(node);
76
106
  const flexSchema = flexNode.schema;
77
107
  const identifierFieldKeys = flexSchema instanceof index_js_2.FlexObjectNodeSchema ? flexSchema.identifierFieldKeys : [];
78
108
  switch (identifierFieldKeys.length) {
79
109
  case 0:
80
110
  return undefined;
81
111
  case 1: {
82
- const identifier = flexNode.tryGetField(identifierFieldKeys[0])?.boxedAt(0);
83
- (0, internal_1.assert)(identifier !== undefined, 0x927 /* The identifier must exist */);
112
+ const identifier = flexNode.tryGetField(identifierFieldKeys[0] ?? (0, internal_1.oob)())?.boxedAt(0);
113
+ if ((0, index_js_2.isMapTreeNode)(flexNode)) {
114
+ if (identifier === undefined) {
115
+ throw new internal_3.UsageError("Tree.shortId cannot access default identifiers on unhydrated nodes");
116
+ }
117
+ return identifier.value;
118
+ }
119
+ (0, internal_1.assert)(identifier?.context !== undefined, 0xa12 /* Expected LazyIdentifierField */);
84
120
  const identifierValue = identifier.value;
85
121
  const localNodeKey = identifier.context.nodeKeyManager.tryLocalizeNodeKey(identifierValue);
86
122
  return localNodeKey !== undefined ? (0, index_js_3.extractFromOpaque)(localNodeKey) : identifierValue;
@@ -103,9 +139,9 @@ function tryGetSchema(value) {
103
139
  case "boolean":
104
140
  return leafNodeSchema_js_1.booleanSchema;
105
141
  case "object": {
106
- if ((0, proxies_js_1.isTreeNode)(value)) {
107
- // This case could be optimized, for example by placing the simple schema in a symbol on tree nodes.
108
- return (0, schemaCaching_js_1.tryGetSimpleNodeSchema)((0, proxyBinding_js_1.getFlexNode)(value).schema);
142
+ if ((0, index_js_4.isTreeNode)(value)) {
143
+ // TODO: This case could be optimized, for example by placing the simple schema in a symbol on tree nodes.
144
+ return (0, index_js_4.tryGetTreeNodeSchema)(value);
109
145
  }
110
146
  if (value === null) {
111
147
  return leafNodeSchema_js_1.nullSchema;
@@ -125,12 +161,12 @@ exports.tryGetSchema = tryGetSchema;
125
161
  function getStoredKey(node) {
126
162
  // Note: the flex domain strictly works with "stored keys", and knows nothing about the developer-facing
127
163
  // "view keys".
128
- const parentField = (0, proxyBinding_js_1.getFlexNode)(node).parentField;
164
+ const parentField = (0, proxyBinding_js_1.getOrCreateInnerNode)(node).parentField;
129
165
  if (parentField.parent.schema.kind.multiplicity === index_js_1.Multiplicity.Sequence) {
130
166
  // The parent of `node` is an array node
131
167
  return parentField.index;
132
168
  }
133
- // The parent of `node` is an object, a map, or undefined (and therefore `node` is a root/detached node).
169
+ // The parent of `node` is an object, a map, or undefined. If undefined, then `node` is a root/detached node.
134
170
  return parentField.parent.key;
135
171
  }
136
172
  /**
@@ -139,7 +175,7 @@ function getStoredKey(node) {
139
175
  function getViewKeyFromStoredKey(schema, storedKey) {
140
176
  // Only object nodes have the concept of a "stored key", differentiated from the developer-facing "view key".
141
177
  // For any other kind of node, the stored key and the view key are the same.
142
- if (schema.kind !== schemaTypes_js_1.NodeKind.Object) {
178
+ if (schema.kind !== index_js_4.NodeKind.Object) {
143
179
  return storedKey;
144
180
  }
145
181
  const fields = schema.info;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"treeNodeApi.js","sourceRoot":"","sources":["../../../src/simple-tree/api/treeNodeApi.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAAkE;AAElE,kDAAiE;AACjE,+DAO0C;AAC1C,kDAA+E;AAE/E,8CAAgE;AAChE,wD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AS,CAAC;AAClB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, oob } from \"@fluidframework/core-utils/internal\";\n\nimport { Multiplicity, rootFieldKey } from \"../../core/index.js\";\nimport {\n\ttype LazyItem,\n\ttype TreeStatus,\n\tisLazy,\n\tisTreeValue,\n\tFlexObjectNodeSchema,\n\tisMapTreeNode,\n} from \"../../feature-libraries/index.js\";\nimport { fail, extractFromOpaque, isReadonlyArray } from \"../../util/index.js\";\n\nimport { getOrCreateNodeFromFlexTreeNode } from \"../proxies.js\";\nimport { getOrCreateInnerNode } from \"../proxyBinding.js\";\nimport {\n\ttype TreeLeafValue,\n\ttype ImplicitFieldSchema,\n\tFieldSchema,\n\ttype ImplicitAllowedTypes,\n\ttype TreeNodeFromImplicitAllowedTypes,\n} from \"../schemaTypes.js\";\nimport {\n\tbooleanSchema,\n\thandleSchema,\n\tnullSchema,\n\tnumberSchema,\n\tstringSchema,\n} from \"../leafNodeSchema.js\";\nimport { isFluidHandle } from \"@fluidframework/runtime-utils/internal\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\nimport type { Off } from \"../../events/index.js\";\nimport {\n\tgetKernel,\n\tisTreeNode,\n\ttype TreeNodeSchema,\n\tNodeKind,\n\ttype TreeNode,\n\ttype TreeChangeEvents,\n\ttryGetTreeNodeSchema,\n} from \"../core/index.js\";\nimport { isObjectNodeSchema } from \"../objectNodeTypes.js\";\n\n/**\n * Provides various functions for analyzing {@link TreeNode}s.\n * * @remarks\n * This type should only be used via the public `Tree` export.\n * @privateRemarks\n * Due to limitations of API-Extractor link resolution, this type can't be moved into internalTypes but should be considered just an implementation detail of the `Tree` export.\n *\n * Inlining the typing of this interface onto the `Tree` object provides slightly different .d.ts generation,\n * which avoids typescript expanding the type of TreeNodeSchema and thus encountering\n * https://github.com/microsoft/rushstack/issues/1958.\n * @sealed @public\n */\nexport interface TreeNodeApi {\n\t/**\n\t * The schema information for this node.\n\t */\n\tschema(node: TreeNode | TreeLeafValue): TreeNodeSchema;\n\n\t/**\n\t * Narrow the type of the given value if it satisfies the given schema.\n\t * @example\n\t * ```ts\n\t * if (node.is(myNode, Point)) {\n\t * const y = myNode.y; // `myNode` is now known to satisfy the `Point` schema and therefore has a `y` coordinate.\n\t * }\n\t * ```\n\t */\n\tis<TSchema extends ImplicitAllowedTypes>(\n\t\tvalue: unknown,\n\t\tschema: TSchema,\n\t): value is TreeNodeFromImplicitAllowedTypes<TSchema>;\n\n\t/**\n\t * Return the node under which this node resides in the tree (or undefined if this is a root node of the tree).\n\t */\n\tparent(node: TreeNode): TreeNode | undefined;\n\n\t/**\n\t * The key of the given node under its parent.\n\t * @remarks\n\t * If `node` is an element in a {@link (TreeArrayNode:interface)}, this returns the index of `node` in the array node (a `number`).\n\t * Otherwise, this returns the key of the field that it is under (a `string`).\n\t */\n\tkey(node: TreeNode): string | number;\n\n\t/**\n\t * Register an event listener on the given node.\n\t * @param node - The node whose events should be subscribed to.\n\t * @param eventName - Which event to subscribe to.\n\t * @param listener - The callback to trigger for the event. The tree can be read during the callback, but it is invalid to modify the tree during this callback.\n\t * @returns A callback function which will deregister the event.\n\t * This callback should be called only once.\n\t */\n\ton<K extends keyof TreeChangeEvents<TNode>, TNode extends TreeNode>(\n\t\tnode: TNode,\n\t\teventName: K,\n\t\tlistener: TreeChangeEvents<TNode>[K],\n\t): () => void;\n\n\t/**\n\t * Returns the {@link TreeStatus} of the given node.\n\t */\n\tstatus(node: TreeNode): TreeStatus;\n\n\t/**\n\t * Returns the {@link SchemaFactory.identifier | identifier} of the given node in the most compressed form possible.\n\t * @remarks\n\t * If the node's identifier is a valid UUID that was automatically generated by the SharedTree, then this will return a process-unique integer corresponding to that identifier.\n\t * Note that the node must already have been inserted into the tree in order to retrieve a generated UUID (or shortId will error).\n\t * This is useful for performance-sensitive scenarios involving many nodes with identifiers that need to be compactly retained in memory or used for efficient lookup.\n\t *\n\t * If the node's identifier is any other user-provided string, then this will return that string.\n\t *\n\t * If the node has no identifier (that is, it has no {@link SchemaFactory.identifier | identifier} field), then this returns `undefined`.\n\t *\n\t * If the node has more than one identifier, then this will throw an error.\n\t *\n\t * The returned integer must not be serialized or preserved outside of the current process.\n\t * Its lifetime is that of the current in-memory instance of the FF container for this client, and it is not guaranteed to be unique or stable outside of that context.\n\t * The same node's identifier may, for example, be different across multiple sessions for the same client and document, or different across two clients in the same session.\n\t */\n\tshortId(node: TreeNode): number | string | undefined;\n}\n\n/**\n * The `Tree` object holds various functions for analyzing {@link TreeNode}s.\n */\nexport const treeNodeApi: TreeNodeApi = {\n\tparent(node: TreeNode): TreeNode | undefined {\n\t\tconst editNode = getOrCreateInnerNode(node).parentField.parent.parent;\n\t\tif (editNode === undefined) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst output = getOrCreateNodeFromFlexTreeNode(editNode);\n\t\tassert(\n\t\t\t!isTreeValue(output),\n\t\t\t0x87f /* Parent can't be a leaf, so it should be a node not a value */,\n\t\t);\n\t\treturn output;\n\t},\n\tkey(node: TreeNode): string | number {\n\t\t// If the parent is undefined, then this node is under the root field,\n\t\t// so we know its key is the special root one.\n\t\tconst parent = treeNodeApi.parent(node);\n\t\tif (parent === undefined) {\n\t\t\treturn rootFieldKey;\n\t\t}\n\n\t\t// The flex-domain strictly operates in terms of \"stored keys\".\n\t\t// To find the associated developer-facing \"view key\", we need to look up the field associated with\n\t\t// the stored key from the flex-domain, and get view key its simple-domain counterpart was created with.\n\t\tconst storedKey = getStoredKey(node);\n\t\tconst parentSchema = treeNodeApi.schema(parent);\n\t\tconst viewKey = getViewKeyFromStoredKey(parentSchema, storedKey);\n\t\treturn viewKey;\n\t},\n\ton<K extends keyof TreeChangeEvents>(\n\t\tnode: TreeNode,\n\t\teventName: K,\n\t\tlistener: TreeChangeEvents[K],\n\t): Off {\n\t\tconst kernel = getKernel(node);\n\t\tswitch (eventName) {\n\t\t\tcase \"nodeChanged\": {\n\t\t\t\tconst nodeSchema = kernel.schema;\n\t\t\t\tif (isObjectNodeSchema(nodeSchema)) {\n\t\t\t\t\treturn kernel.on(\"childrenChangedAfterBatch\", ({ changedFields }) => {\n\t\t\t\t\t\tconst changedProperties = new Set(\n\t\t\t\t\t\t\tArray.from(\n\t\t\t\t\t\t\t\tchangedFields,\n\t\t\t\t\t\t\t\t(field) =>\n\t\t\t\t\t\t\t\t\tnodeSchema.storedKeyToPropertyKey.get(field) ??\n\t\t\t\t\t\t\t\t\tfail(`Could not find stored key '${field}' in schema.`),\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t);\n\t\t\t\t\t\tlistener({ changedProperties });\n\t\t\t\t\t});\n\t\t\t\t} else if (nodeSchema.kind === NodeKind.Array) {\n\t\t\t\t\treturn kernel.on(\"childrenChangedAfterBatch\", () => {\n\t\t\t\t\t\tlistener({ changedProperties: undefined });\n\t\t\t\t\t});\n\t\t\t\t} else {\n\t\t\t\t\treturn kernel.on(\"childrenChangedAfterBatch\", ({ changedFields }) => {\n\t\t\t\t\t\tlistener({ changedProperties: changedFields });\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t\tcase \"treeChanged\": {\n\t\t\t\treturn kernel.on(\"subtreeChangedAfterBatch\", () => listener({}));\n\t\t\t}\n\t\t\tdefault:\n\t\t\t\tthrow new UsageError(`No event named ${JSON.stringify(eventName)}.`);\n\t\t}\n\t},\n\tstatus(node: TreeNode): TreeStatus {\n\t\treturn getKernel(node).getStatus();\n\t},\n\tis<TSchema extends ImplicitAllowedTypes>(\n\t\tvalue: unknown,\n\t\tschema: TSchema,\n\t): value is TreeNodeFromImplicitAllowedTypes<TSchema> {\n\t\tconst actualSchema = tryGetSchema(value);\n\t\tif (actualSchema === undefined) {\n\t\t\treturn false;\n\t\t}\n\t\tif (isReadonlyArray<LazyItem<TreeNodeSchema>>(schema)) {\n\t\t\tfor (const singleSchema of schema) {\n\t\t\t\tconst testSchema = isLazy(singleSchema) ? singleSchema() : singleSchema;\n\t\t\t\tif (testSchema === actualSchema) {\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn false;\n\t\t} else {\n\t\t\t// Linter is incorrect about this bering unnecessary: it does not compile without the type assertion.\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion\n\t\t\treturn (schema as TreeNodeSchema) === actualSchema;\n\t\t}\n\t},\n\tschema(node: TreeNode | TreeLeafValue): TreeNodeSchema {\n\t\treturn tryGetSchema(node) ?? fail(\"Not a tree node\");\n\t},\n\tshortId(node: TreeNode): number | string | undefined {\n\t\tconst flexNode = getOrCreateInnerNode(node);\n\t\tconst flexSchema = flexNode.schema;\n\t\tconst identifierFieldKeys =\n\t\t\tflexSchema instanceof FlexObjectNodeSchema ? flexSchema.identifierFieldKeys : [];\n\n\t\tswitch (identifierFieldKeys.length) {\n\t\t\tcase 0:\n\t\t\t\treturn undefined;\n\t\t\tcase 1: {\n\t\t\t\tconst identifier = flexNode.tryGetField(identifierFieldKeys[0] ?? oob())?.boxedAt(0);\n\t\t\t\tif (isMapTreeNode(flexNode)) {\n\t\t\t\t\tif (identifier === undefined) {\n\t\t\t\t\t\tthrow new UsageError(\n\t\t\t\t\t\t\t\"Tree.shortId cannot access default identifiers on unhydrated nodes\",\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\treturn identifier.value as string;\n\t\t\t\t}\n\t\t\t\tassert(identifier?.context !== undefined, 0xa12 /* Expected LazyIdentifierField */);\n\t\t\t\tconst identifierValue = identifier.value as string;\n\n\t\t\t\tconst localNodeKey =\n\t\t\t\t\tidentifier.context.nodeKeyManager.tryLocalizeNodeKey(identifierValue);\n\t\t\t\treturn localNodeKey !== undefined ? extractFromOpaque(localNodeKey) : identifierValue;\n\t\t\t}\n\t\t\tdefault:\n\t\t\t\tthrow new UsageError(\n\t\t\t\t\t\"shortId() may not be called on a node with more than one identifier. Consider converting extraneous identifier fields to string fields.\",\n\t\t\t\t);\n\t\t}\n\t},\n};\n\n/**\n * Returns a schema for a value if the value is a {@link TreeNode} or a {@link TreeLeafValue}.\n * Returns undefined for other values.\n */\nexport function tryGetSchema(value: unknown): undefined | TreeNodeSchema {\n\tswitch (typeof value) {\n\t\tcase \"string\":\n\t\t\treturn stringSchema;\n\t\tcase \"number\":\n\t\t\treturn numberSchema;\n\t\tcase \"boolean\":\n\t\t\treturn booleanSchema;\n\t\tcase \"object\": {\n\t\t\tif (isTreeNode(value)) {\n\t\t\t\t// TODO: This case could be optimized, for example by placing the simple schema in a symbol on tree nodes.\n\t\t\t\treturn tryGetTreeNodeSchema(value);\n\t\t\t}\n\t\t\tif (value === null) {\n\t\t\t\treturn nullSchema;\n\t\t\t}\n\t\t\tif (isFluidHandle(value)) {\n\t\t\t\treturn handleSchema;\n\t\t\t}\n\t\t}\n\t\tdefault:\n\t\t\treturn undefined;\n\t}\n}\n\n/**\n * Gets the stored key with which the provided node is associated in the parent.\n */\nfunction getStoredKey(node: TreeNode): string | number {\n\t// Note: the flex domain strictly works with \"stored keys\", and knows nothing about the developer-facing\n\t// \"view keys\".\n\tconst parentField = getOrCreateInnerNode(node).parentField;\n\tif (parentField.parent.schema.kind.multiplicity === Multiplicity.Sequence) {\n\t\t// The parent of `node` is an array node\n\t\treturn parentField.index;\n\t}\n\n\t// The parent of `node` is an object, a map, or undefined. If undefined, then `node` is a root/detached node.\n\treturn parentField.parent.key;\n}\n\n/**\n * Given a node schema, gets the view key corresponding with the provided {@link FieldProps.key | stored key}.\n */\nfunction getViewKeyFromStoredKey(\n\tschema: TreeNodeSchema,\n\tstoredKey: string | number,\n): string | number {\n\t// Only object nodes have the concept of a \"stored key\", differentiated from the developer-facing \"view key\".\n\t// For any other kind of node, the stored key and the view key are the same.\n\tif (schema.kind !== NodeKind.Object) {\n\t\treturn storedKey;\n\t}\n\n\tconst fields = schema.info as Record<string, ImplicitFieldSchema>;\n\n\t// Invariants:\n\t// - The set of all view keys under an object must be unique.\n\t// - The set of all stored keys (including those implicitly created from view keys) must be unique.\n\t// To find the view key associated with the provided stored key, first check for any stored key matches (which are optionally populated).\n\t// If we don't find any, then search for a matching view key.\n\tfor (const [viewKey, fieldSchema] of Object.entries(fields)) {\n\t\tif (fieldSchema instanceof FieldSchema && fieldSchema.props?.key === storedKey) {\n\t\t\treturn viewKey;\n\t\t}\n\t}\n\n\tif (fields[storedKey] === undefined) {\n\t\tfail(\"Existing stored key should always map to a view key\");\n\t}\n\n\treturn storedKey;\n}\n"]}
@@ -0,0 +1,136 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ import type { IFluidHandle } from "@fluidframework/core-interfaces";
6
+ import { type FieldKey, type ITreeCursor, type ITreeCursorSynchronous } from "../../core/index.js";
7
+ import type { TreeLeafValue, ImplicitFieldSchema, ImplicitAllowedTypes } from "../schemaTypes.js";
8
+ /**
9
+ * Verbose encoding of a {@link TreeNode} or {@link TreeValue}.
10
+ * @remarks
11
+ * This is verbose meaning that every {@link TreeNode} is a {@link VerboseTreeNode}.
12
+ * Any IFluidHandle values have been replaced by `THandle`.
13
+ * @privateRemarks
14
+ * This can store all possible simple trees, but it can not store all possible trees representable by our internal representations like FlexTree and JsonableTree.
15
+ */
16
+ export type VerboseTree<THandle = IFluidHandle> = VerboseTreeNode<THandle> | Exclude<TreeLeafValue, IFluidHandle> | THandle;
17
+ /**
18
+ * Verbose encoding of a {@link TreeNode}.
19
+ * @remarks
20
+ * This is verbose meaning that every {@link TreeNode} has an explicit `type` property, and `fields`.
21
+ * This allowed VerboseTreeNode to be unambiguous regarding which type each node is without relying on symbols or hidden state.
22
+ *
23
+ * Any IFluidHandle values have been replaced by `THandle`. If the `THandle` is JSON compatible, then this type is JSON compatible as well.
24
+ *
25
+ * @privateRemarks
26
+ * This type is only used for data which is copied into and out of the tree.
27
+ * When being copied out, its fine to have the data be mutable since its a copy.
28
+ *
29
+ * When being copied in, we don't need to mutate, so we could use a readonly variant of this type.
30
+ * however the copy in case (createFromVerbose) probably isn't harmed much by just reusing this type as is,
31
+ * since if the caller has immutable data, TypeScript doesn't prevent assigning immutable data to a mutable type anyway.
32
+ * Also relaxing the input methods to take readonly data would be a non-breaking change so it can be done later if desired.
33
+ *
34
+ * This format is simple-tree specialized alternative to {@link JsonableTree}.
35
+ * This format allows for all simple-tree compatible trees to be represented.
36
+ *
37
+ * Unlike `JsonableTree`, leaf nodes are not boxed into node objects, and instead have their schema inferred from the value.
38
+ * Additionally, sequence fields can only occur on a node that has a single sequence field (with the empty key) replicating the behavior of simple-tree ArrayNodes.
39
+ */
40
+ export interface VerboseTreeNode<THandle = IFluidHandle> {
41
+ /**
42
+ * The meaning of this node.
43
+ * Provides contexts/semantics for this node and its content.
44
+ * @remarks
45
+ * Typically used to associate a node with metadata (including a schema) and source code (types, behaviors, etc).
46
+ * When used with this package's schema system, it will be the {@link TreeNodeSchemaCore.identifier}.
47
+ */
48
+ type: string;
49
+ /**
50
+ * Content of this node.
51
+ * For array nodes, an array of children.
52
+ * For map and object nodes, an object which children under keys.
53
+ * @remarks
54
+ * For object nodes, the keys could be either the stored keys, or the property keys depending on usage.
55
+ */
56
+ fields: VerboseTree<THandle>[] | {
57
+ [key: string]: VerboseTree<THandle>;
58
+ };
59
+ }
60
+ /**
61
+ * Options for how to interpret a `VerboseTree<TCustom>` when schema information is available.
62
+ */
63
+ export interface ParseOptions<TCustom> {
64
+ /**
65
+ * Fixup custom input formats.
66
+ * @remarks
67
+ * Main usage is to handle IFluidHandles.
68
+ * When targeting JSON compatibility,
69
+ * this may be by throwing an error or including a placeholder.
70
+ * Since IFluidHandles are special references to FLuid data which is garbage collected when not referenced by the container for long enough,
71
+ * any scheme for encoding handles for storage outside the container (or in formats the container does not understand) is unreliable.
72
+ */
73
+ valueConverter(data: VerboseTree<TCustom>): TreeLeafValue | VerboseTreeNode<TCustom>;
74
+ /**
75
+ * If true, interpret the input keys of object nodes as stored keys.
76
+ * If false, interpret them as property keys.
77
+ * @defaultValue false.
78
+ */
79
+ readonly useStoredKeys?: boolean;
80
+ }
81
+ /**
82
+ * Options for how to interpret a `VerboseTree<TCustom>` without relying on schema.
83
+ */
84
+ export interface SchemalessParseOptions<TCustom> {
85
+ /**
86
+ * Fixup custom input formats.
87
+ * @remarks
88
+ * See note on {@link ParseOptions.valueConverter}.
89
+ */
90
+ valueConverter(data: VerboseTree<TCustom>): TreeLeafValue | VerboseTreeNode<TCustom>;
91
+ /**
92
+ * Converts stored keys into whatever key the tree is using in its encoding.
93
+ */
94
+ keyConverter?: {
95
+ parse(type: string, inputKey: string): FieldKey;
96
+ encode(type: string, key: FieldKey): string;
97
+ };
98
+ }
99
+ /**
100
+ * Options for how to interpret a `VerboseTree<TCustom>` without relying on schema.
101
+ */
102
+ export interface EncodeOptions<TCustom> {
103
+ /**
104
+ * Fixup custom input formats.
105
+ * @remarks
106
+ * See note on {@link ParseOptions.valueConverter}.
107
+ */
108
+ valueConverter(data: IFluidHandle): TCustom;
109
+ /**
110
+ * If true, interpret the input keys of object nodes as stored keys.
111
+ * If false, interpret them as property keys.
112
+ * @defaultValue false.
113
+ */
114
+ readonly useStoredKeys?: boolean;
115
+ }
116
+ /**
117
+ * Use info from `schema` to convert `options` to {@link SchemalessParseOptions}.
118
+ */
119
+ export declare function applySchemaToParserOptions<TCustom>(schema: ImplicitFieldSchema, options: ParseOptions<TCustom>): SchemalessParseOptions<TCustom>;
120
+ /**
121
+ * Used to read a VerboseTree as a node cursor.
122
+ *
123
+ * @returns an {@link ITreeCursorSynchronous} for a single node in nodes mode.
124
+ */
125
+ export declare function cursorFromVerbose<TCustom>(data: VerboseTree<TCustom>, options: SchemalessParseOptions<TCustom>): ITreeCursorSynchronous;
126
+ /**
127
+ * Used to read a VerboseTree[] as a field cursor.
128
+ *
129
+ * @returns an {@link ITreeCursorSynchronous} for a single field in fields mode.
130
+ */
131
+ export declare function fieldCursorFromVerbose<TCustom>(data: VerboseTree<TCustom>[], options: SchemalessParseOptions<TCustom>): ITreeCursorSynchronous;
132
+ /**
133
+ * Used to read a node cursor as a VerboseTree.
134
+ */
135
+ export declare function verboseFromCursor<TCustom>(reader: ITreeCursor, rootSchema: ImplicitAllowedTypes, options: EncodeOptions<TCustom>): VerboseTree<TCustom>;
136
+ //# sourceMappingURL=verboseTree.d.ts.map