@fluidframework/tree 2.0.0-dev-rc.4.0.0.261659 → 2.0.0-dev-rc.5.0.0.265721

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 (1022) hide show
  1. package/.eslintrc.cjs +25 -2
  2. package/CHANGELOG.md +17 -0
  3. package/api-report/tree.api.md +46 -36
  4. package/dist/beta.d.ts +2 -1
  5. package/dist/codec/codec.d.ts +1 -1
  6. package/dist/codec/codec.d.ts.map +1 -1
  7. package/dist/codec/codec.js.map +1 -1
  8. package/dist/codec/discriminatedUnions.d.ts.map +1 -1
  9. package/dist/codec/discriminatedUnions.js +1 -0
  10. package/dist/codec/discriminatedUnions.js.map +1 -1
  11. package/dist/core/forest/forest.d.ts +5 -6
  12. package/dist/core/forest/forest.d.ts.map +1 -1
  13. package/dist/core/forest/forest.js.map +1 -1
  14. package/dist/core/index.d.ts +1 -1
  15. package/dist/core/index.d.ts.map +1 -1
  16. package/dist/core/index.js +2 -1
  17. package/dist/core/index.js.map +1 -1
  18. package/dist/core/rebase/index.d.ts +1 -1
  19. package/dist/core/rebase/index.d.ts.map +1 -1
  20. package/dist/core/rebase/index.js +2 -1
  21. package/dist/core/rebase/index.js.map +1 -1
  22. package/dist/core/rebase/revisionTagCodec.js.map +1 -1
  23. package/dist/core/rebase/types.d.ts +1 -0
  24. package/dist/core/rebase/types.d.ts.map +1 -1
  25. package/dist/core/rebase/types.js +5 -1
  26. package/dist/core/rebase/types.js.map +1 -1
  27. package/dist/core/rebase/utils.d.ts.map +1 -1
  28. package/dist/core/rebase/utils.js.map +1 -1
  29. package/dist/core/rebase/verifyChangeRebaser.js.map +1 -1
  30. package/dist/core/schema-stored/schema.d.ts +4 -0
  31. package/dist/core/schema-stored/schema.d.ts.map +1 -1
  32. package/dist/core/schema-stored/schema.js.map +1 -1
  33. package/dist/core/schema-stored/storedSchemaRepository.js.map +1 -1
  34. package/dist/core/tree/anchorSet.d.ts.map +1 -1
  35. package/dist/core/tree/anchorSet.js +4 -0
  36. package/dist/core/tree/anchorSet.js.map +1 -1
  37. package/dist/core/tree/cursor.d.ts.map +1 -1
  38. package/dist/core/tree/cursor.js +3 -1
  39. package/dist/core/tree/cursor.js.map +1 -1
  40. package/dist/core/tree/deltaUtil.js.map +1 -1
  41. package/dist/core/tree/detachedFieldIndex.d.ts.map +1 -1
  42. package/dist/core/tree/detachedFieldIndex.js.map +1 -1
  43. package/dist/core/tree/detachedFieldIndexCodec.d.ts.map +1 -1
  44. package/dist/core/tree/detachedFieldIndexCodec.js.map +1 -1
  45. package/dist/core/tree/mapTree.js.map +1 -1
  46. package/dist/core/tree/pathTree.js.map +1 -1
  47. package/dist/core/tree/persistedTreeTextFormat.d.ts +4 -4
  48. package/dist/core/tree/persistedTreeTextFormat.d.ts.map +1 -1
  49. package/dist/core/tree/persistedTreeTextFormat.js +1 -0
  50. package/dist/core/tree/persistedTreeTextFormat.js.map +1 -1
  51. package/dist/core/tree/sparseTree.js.map +1 -1
  52. package/dist/core/tree/treeTextFormat.js.map +1 -1
  53. package/dist/core/tree/visitDelta.js.map +1 -1
  54. package/dist/core/tree/visitorUtils.js.map +1 -1
  55. package/dist/domains/index.d.ts +0 -1
  56. package/dist/domains/index.d.ts.map +1 -1
  57. package/dist/domains/index.js +1 -5
  58. package/dist/domains/index.js.map +1 -1
  59. package/dist/domains/json/jsonCursor.js +1 -1
  60. package/dist/domains/json/jsonCursor.js.map +1 -1
  61. package/dist/domains/json/jsonDomainSchema.js.map +1 -1
  62. package/dist/domains/schemaBuilder.d.ts.map +1 -1
  63. package/dist/domains/schemaBuilder.js +1 -0
  64. package/dist/domains/schemaBuilder.js.map +1 -1
  65. package/dist/domains/testRecursiveDomain.js.map +1 -1
  66. package/dist/events/events.d.ts +1 -1
  67. package/dist/events/events.d.ts.map +1 -1
  68. package/dist/events/events.js +1 -0
  69. package/dist/events/events.js.map +1 -1
  70. package/dist/feature-libraries/chunked-forest/basicChunk.js.map +1 -1
  71. package/dist/feature-libraries/chunked-forest/chunkTree.js.map +1 -1
  72. package/dist/feature-libraries/chunked-forest/chunkedForest.d.ts.map +1 -1
  73. package/dist/feature-libraries/chunked-forest/chunkedForest.js +4 -2
  74. package/dist/feature-libraries/chunked-forest/chunkedForest.js.map +1 -1
  75. package/dist/feature-libraries/chunked-forest/codec/chunkCodecUtilities.d.ts.map +1 -1
  76. package/dist/feature-libraries/chunked-forest/codec/chunkCodecUtilities.js.map +1 -1
  77. package/dist/feature-libraries/chunked-forest/codec/chunkDecoding.js.map +1 -1
  78. package/dist/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.js.map +1 -1
  79. package/dist/feature-libraries/chunked-forest/codec/chunkEncodingGeneric.js.map +1 -1
  80. package/dist/feature-libraries/chunked-forest/codec/codecs.js.map +1 -1
  81. package/dist/feature-libraries/chunked-forest/codec/compressedEncode.d.ts.map +1 -1
  82. package/dist/feature-libraries/chunked-forest/codec/compressedEncode.js.map +1 -1
  83. package/dist/feature-libraries/chunked-forest/codec/formatGeneric.d.ts.map +1 -1
  84. package/dist/feature-libraries/chunked-forest/codec/formatGeneric.js.map +1 -1
  85. package/dist/feature-libraries/chunked-forest/codec/nodeShape.d.ts +1 -1
  86. package/dist/feature-libraries/chunked-forest/codec/nodeShape.d.ts.map +1 -1
  87. package/dist/feature-libraries/chunked-forest/codec/nodeShape.js.map +1 -1
  88. package/dist/feature-libraries/chunked-forest/codec/schemaBasedEncoding.js.map +1 -1
  89. package/dist/feature-libraries/chunked-forest/codec/uncompressedEncode.js.map +1 -1
  90. package/dist/feature-libraries/chunked-forest/sequenceChunk.js.map +1 -1
  91. package/dist/feature-libraries/chunked-forest/uniformChunk.js.map +1 -1
  92. package/dist/feature-libraries/contextuallyTyped.d.ts.map +1 -1
  93. package/dist/feature-libraries/contextuallyTyped.js.map +1 -1
  94. package/dist/feature-libraries/default-schema/defaultEditBuilder.d.ts.map +1 -1
  95. package/dist/feature-libraries/default-schema/defaultEditBuilder.js +13 -9
  96. package/dist/feature-libraries/default-schema/defaultEditBuilder.js.map +1 -1
  97. package/dist/feature-libraries/default-schema/defaultFieldKinds.d.ts +0 -6
  98. package/dist/feature-libraries/default-schema/defaultFieldKinds.d.ts.map +1 -1
  99. package/dist/feature-libraries/default-schema/defaultFieldKinds.js +12 -1
  100. package/dist/feature-libraries/default-schema/defaultFieldKinds.js.map +1 -1
  101. package/dist/feature-libraries/default-schema/defaultSchema.d.ts.map +1 -1
  102. package/dist/feature-libraries/default-schema/defaultSchema.js +1 -0
  103. package/dist/feature-libraries/default-schema/defaultSchema.js.map +1 -1
  104. package/dist/feature-libraries/default-schema/index.d.ts +2 -1
  105. package/dist/feature-libraries/default-schema/index.d.ts.map +1 -1
  106. package/dist/feature-libraries/default-schema/index.js +4 -1
  107. package/dist/feature-libraries/default-schema/index.js.map +1 -1
  108. package/dist/feature-libraries/default-schema/schemaChecker.js.map +1 -1
  109. package/dist/feature-libraries/deltaUtils.js.map +1 -1
  110. package/dist/feature-libraries/detachedFieldIndexSummarizer.d.ts +2 -2
  111. package/dist/feature-libraries/detachedFieldIndexSummarizer.d.ts.map +1 -1
  112. package/dist/feature-libraries/detachedFieldIndexSummarizer.js.map +1 -1
  113. package/dist/feature-libraries/editableTreeBinder.js.map +1 -1
  114. package/dist/feature-libraries/flex-tree/context.d.ts +10 -16
  115. package/dist/feature-libraries/flex-tree/context.d.ts.map +1 -1
  116. package/dist/feature-libraries/flex-tree/context.js +14 -20
  117. package/dist/feature-libraries/flex-tree/context.js.map +1 -1
  118. package/dist/feature-libraries/flex-tree/flexTreeTypes.d.ts +14 -13
  119. package/dist/feature-libraries/flex-tree/flexTreeTypes.d.ts.map +1 -1
  120. package/dist/feature-libraries/flex-tree/flexTreeTypes.js +0 -1
  121. package/dist/feature-libraries/flex-tree/flexTreeTypes.js.map +1 -1
  122. package/dist/feature-libraries/flex-tree/index.d.ts +1 -0
  123. package/dist/feature-libraries/flex-tree/index.d.ts.map +1 -1
  124. package/dist/feature-libraries/flex-tree/index.js +3 -1
  125. package/dist/feature-libraries/flex-tree/index.js.map +1 -1
  126. package/dist/feature-libraries/flex-tree/lazyEntity.js.map +1 -1
  127. package/dist/feature-libraries/flex-tree/lazyField.d.ts +3 -10
  128. package/dist/feature-libraries/flex-tree/lazyField.d.ts.map +1 -1
  129. package/dist/feature-libraries/flex-tree/lazyField.js +9 -39
  130. package/dist/feature-libraries/flex-tree/lazyField.js.map +1 -1
  131. package/dist/feature-libraries/flex-tree/lazyNode.d.ts +3 -7
  132. package/dist/feature-libraries/flex-tree/lazyNode.d.ts.map +1 -1
  133. package/dist/feature-libraries/flex-tree/lazyNode.js +6 -29
  134. package/dist/feature-libraries/flex-tree/lazyNode.js.map +1 -1
  135. package/dist/feature-libraries/flex-tree/navigation.d.ts.map +1 -1
  136. package/dist/feature-libraries/flex-tree/navigation.js.map +1 -1
  137. package/dist/feature-libraries/flex-tree/unboxed.js.map +1 -1
  138. package/dist/feature-libraries/flex-tree/utilities.d.ts +8 -2
  139. package/dist/feature-libraries/flex-tree/utilities.d.ts.map +1 -1
  140. package/dist/feature-libraries/flex-tree/utilities.js +13 -1
  141. package/dist/feature-libraries/flex-tree/utilities.js.map +1 -1
  142. package/dist/feature-libraries/forest-summary/codec.js.map +1 -1
  143. package/dist/feature-libraries/forest-summary/forestSummarizer.d.ts +2 -2
  144. package/dist/feature-libraries/forest-summary/forestSummarizer.d.ts.map +1 -1
  145. package/dist/feature-libraries/forest-summary/forestSummarizer.js.map +1 -1
  146. package/dist/feature-libraries/index.d.ts +3 -3
  147. package/dist/feature-libraries/index.d.ts.map +1 -1
  148. package/dist/feature-libraries/index.js +5 -3
  149. package/dist/feature-libraries/index.js.map +1 -1
  150. package/dist/feature-libraries/mapTreeCursor.js +1 -1
  151. package/dist/feature-libraries/mapTreeCursor.js.map +1 -1
  152. package/dist/feature-libraries/memoizedIdRangeAllocator.js.map +1 -1
  153. package/dist/feature-libraries/mitigatedChangeFamily.js.map +1 -1
  154. package/dist/feature-libraries/modular-schema/comparison.js.map +1 -1
  155. package/dist/feature-libraries/modular-schema/fieldKindWithEditor.d.ts +1 -1
  156. package/dist/feature-libraries/modular-schema/fieldKindWithEditor.d.ts.map +1 -1
  157. package/dist/feature-libraries/modular-schema/fieldKindWithEditor.js +4 -1
  158. package/dist/feature-libraries/modular-schema/fieldKindWithEditor.js.map +1 -1
  159. package/dist/feature-libraries/modular-schema/genericFieldKind.js.map +1 -1
  160. package/dist/feature-libraries/modular-schema/genericFieldKindFormat.d.ts.map +1 -1
  161. package/dist/feature-libraries/modular-schema/genericFieldKindFormat.js +3 -0
  162. package/dist/feature-libraries/modular-schema/genericFieldKindFormat.js.map +1 -1
  163. package/dist/feature-libraries/modular-schema/isNeverTree.js.map +1 -1
  164. package/dist/feature-libraries/modular-schema/modularChangeCodecs.js +2 -1
  165. package/dist/feature-libraries/modular-schema/modularChangeCodecs.js.map +1 -1
  166. package/dist/feature-libraries/modular-schema/modularChangeFamily.d.ts +0 -1
  167. package/dist/feature-libraries/modular-schema/modularChangeFamily.d.ts.map +1 -1
  168. package/dist/feature-libraries/modular-schema/modularChangeFamily.js +1 -5
  169. package/dist/feature-libraries/modular-schema/modularChangeFamily.js.map +1 -1
  170. package/dist/feature-libraries/modular-schema/modularChangeTypes.d.ts +1 -9
  171. package/dist/feature-libraries/modular-schema/modularChangeTypes.d.ts.map +1 -1
  172. package/dist/feature-libraries/modular-schema/modularChangeTypes.js.map +1 -1
  173. package/dist/feature-libraries/node-key/index.d.ts +1 -1
  174. package/dist/feature-libraries/node-key/index.d.ts.map +1 -1
  175. package/dist/feature-libraries/node-key/index.js +1 -2
  176. package/dist/feature-libraries/node-key/index.js.map +1 -1
  177. package/dist/feature-libraries/node-key/nodeKey.d.ts +0 -8
  178. package/dist/feature-libraries/node-key/nodeKey.d.ts.map +1 -1
  179. package/dist/feature-libraries/node-key/nodeKey.js +1 -9
  180. package/dist/feature-libraries/node-key/nodeKey.js.map +1 -1
  181. package/dist/feature-libraries/node-key/nodeKeyIndex.d.ts +1 -1
  182. package/dist/feature-libraries/node-key/nodeKeyIndex.d.ts.map +1 -1
  183. package/dist/feature-libraries/node-key/nodeKeyIndex.js.map +1 -1
  184. package/dist/feature-libraries/node-key/nodeKeyManager.d.ts +12 -2
  185. package/dist/feature-libraries/node-key/nodeKeyManager.d.ts.map +1 -1
  186. package/dist/feature-libraries/node-key/nodeKeyManager.js +3 -3
  187. package/dist/feature-libraries/node-key/nodeKeyManager.js.map +1 -1
  188. package/dist/feature-libraries/object-forest/objectForest.d.ts.map +1 -1
  189. package/dist/feature-libraries/object-forest/objectForest.js +13 -3
  190. package/dist/feature-libraries/object-forest/objectForest.js.map +1 -1
  191. package/dist/feature-libraries/optional-field/optionalField.js.map +1 -1
  192. package/dist/feature-libraries/optional-field/optionalFieldChangeFormatV1.d.ts.map +1 -1
  193. package/dist/feature-libraries/optional-field/optionalFieldChangeFormatV1.js +4 -0
  194. package/dist/feature-libraries/optional-field/optionalFieldChangeFormatV1.js.map +1 -1
  195. package/dist/feature-libraries/optional-field/optionalFieldChangeFormatV2.d.ts.map +1 -1
  196. package/dist/feature-libraries/optional-field/optionalFieldChangeFormatV2.js +4 -0
  197. package/dist/feature-libraries/optional-field/optionalFieldChangeFormatV2.js.map +1 -1
  198. package/dist/feature-libraries/optional-field/optionalFieldCodecV1.js.map +1 -1
  199. package/dist/feature-libraries/optional-field/optionalFieldCodecV2.js.map +1 -1
  200. package/dist/feature-libraries/schema-aware/schemaAware.d.ts +1 -1
  201. package/dist/feature-libraries/schema-aware/schemaAware.d.ts.map +1 -1
  202. package/dist/feature-libraries/schema-aware/schemaAware.js.map +1 -1
  203. package/dist/feature-libraries/schema-index/codec.js.map +1 -1
  204. package/dist/feature-libraries/schema-index/schemaSummarizer.d.ts +2 -2
  205. package/dist/feature-libraries/schema-index/schemaSummarizer.d.ts.map +1 -1
  206. package/dist/feature-libraries/schema-index/schemaSummarizer.js.map +1 -1
  207. package/dist/feature-libraries/schemaBuilderBase.js.map +1 -1
  208. package/dist/feature-libraries/sequence-field/compose.d.ts.map +1 -1
  209. package/dist/feature-libraries/sequence-field/compose.js +33 -104
  210. package/dist/feature-libraries/sequence-field/compose.js.map +1 -1
  211. package/dist/feature-libraries/sequence-field/{format.d.ts → formatV1.d.ts} +41 -41
  212. package/dist/feature-libraries/sequence-field/formatV1.d.ts.map +1 -0
  213. package/dist/feature-libraries/sequence-field/{format.js → formatV1.js} +5 -1
  214. package/dist/feature-libraries/sequence-field/formatV1.js.map +1 -0
  215. package/dist/feature-libraries/sequence-field/formatV2.d.ts +261 -0
  216. package/dist/feature-libraries/sequence-field/formatV2.d.ts.map +1 -0
  217. package/dist/feature-libraries/sequence-field/formatV2.js +71 -0
  218. package/dist/feature-libraries/sequence-field/formatV2.js.map +1 -0
  219. package/dist/feature-libraries/sequence-field/index.d.ts +2 -2
  220. package/dist/feature-libraries/sequence-field/index.d.ts.map +1 -1
  221. package/dist/feature-libraries/sequence-field/index.js +2 -2
  222. package/dist/feature-libraries/sequence-field/index.js.map +1 -1
  223. package/dist/feature-libraries/sequence-field/invert.d.ts.map +1 -1
  224. package/dist/feature-libraries/sequence-field/invert.js +4 -21
  225. package/dist/feature-libraries/sequence-field/invert.js.map +1 -1
  226. package/dist/feature-libraries/sequence-field/markListFactory.d.ts.map +1 -1
  227. package/dist/feature-libraries/sequence-field/markListFactory.js +0 -4
  228. package/dist/feature-libraries/sequence-field/markListFactory.js.map +1 -1
  229. package/dist/feature-libraries/sequence-field/markQueue.js.map +1 -1
  230. package/dist/feature-libraries/sequence-field/moveEffectTable.d.ts.map +1 -1
  231. package/dist/feature-libraries/sequence-field/moveEffectTable.js.map +1 -1
  232. package/dist/feature-libraries/sequence-field/prune.js.map +1 -1
  233. package/dist/feature-libraries/sequence-field/rebase.d.ts +1 -2
  234. package/dist/feature-libraries/sequence-field/rebase.d.ts.map +1 -1
  235. package/dist/feature-libraries/sequence-field/rebase.js +15 -359
  236. package/dist/feature-libraries/sequence-field/rebase.js.map +1 -1
  237. package/dist/feature-libraries/sequence-field/relevantRemovedRoots.js.map +1 -1
  238. package/dist/feature-libraries/sequence-field/replaceRevisions.js.map +1 -1
  239. package/dist/feature-libraries/sequence-field/sequenceFieldCodecV1.d.ts +11 -0
  240. package/dist/feature-libraries/sequence-field/sequenceFieldCodecV1.d.ts.map +1 -0
  241. package/dist/feature-libraries/sequence-field/sequenceFieldCodecV1.js +211 -0
  242. package/dist/feature-libraries/sequence-field/sequenceFieldCodecV1.js.map +1 -0
  243. package/dist/feature-libraries/sequence-field/sequenceFieldCodecV2.d.ts +11 -0
  244. package/dist/feature-libraries/sequence-field/sequenceFieldCodecV2.d.ts.map +1 -0
  245. package/dist/feature-libraries/sequence-field/sequenceFieldCodecV2.js +192 -0
  246. package/dist/feature-libraries/sequence-field/sequenceFieldCodecV2.js.map +1 -0
  247. package/dist/feature-libraries/sequence-field/sequenceFieldCodecs.d.ts +3 -2
  248. package/dist/feature-libraries/sequence-field/sequenceFieldCodecs.d.ts.map +1 -1
  249. package/dist/feature-libraries/sequence-field/sequenceFieldCodecs.js +6 -235
  250. package/dist/feature-libraries/sequence-field/sequenceFieldCodecs.js.map +1 -1
  251. package/dist/feature-libraries/sequence-field/sequenceFieldEditor.d.ts +9 -7
  252. package/dist/feature-libraries/sequence-field/sequenceFieldEditor.d.ts.map +1 -1
  253. package/dist/feature-libraries/sequence-field/sequenceFieldEditor.js +14 -15
  254. package/dist/feature-libraries/sequence-field/sequenceFieldEditor.js.map +1 -1
  255. package/dist/feature-libraries/sequence-field/sequenceFieldToDelta.js.map +1 -1
  256. package/dist/feature-libraries/sequence-field/types.d.ts +2 -45
  257. package/dist/feature-libraries/sequence-field/types.d.ts.map +1 -1
  258. package/dist/feature-libraries/sequence-field/types.js.map +1 -1
  259. package/dist/feature-libraries/sequence-field/utils.d.ts +1 -12
  260. package/dist/feature-libraries/sequence-field/utils.d.ts.map +1 -1
  261. package/dist/feature-libraries/sequence-field/utils.js +7 -115
  262. package/dist/feature-libraries/sequence-field/utils.js.map +1 -1
  263. package/dist/feature-libraries/storedToViewSchema.js.map +1 -1
  264. package/dist/feature-libraries/treeCursorUtils.js.map +1 -1
  265. package/dist/feature-libraries/treeTextCursor.js.map +1 -1
  266. package/dist/feature-libraries/typed-schema/flexList.js.map +1 -1
  267. package/dist/feature-libraries/typed-schema/schemaCollection.js.map +1 -1
  268. package/dist/feature-libraries/typed-schema/typedTreeSchema.js.map +1 -1
  269. package/dist/feature-libraries/typed-schema/view.js.map +1 -1
  270. package/dist/feature-libraries/valueUtilities.d.ts +1 -1
  271. package/dist/feature-libraries/valueUtilities.d.ts.map +1 -1
  272. package/dist/feature-libraries/valueUtilities.js.map +1 -1
  273. package/dist/index.d.ts +3 -3
  274. package/dist/index.d.ts.map +1 -1
  275. package/dist/index.js +2 -3
  276. package/dist/index.js.map +1 -1
  277. package/dist/packageVersion.d.ts +1 -1
  278. package/dist/packageVersion.js +1 -1
  279. package/dist/packageVersion.js.map +1 -1
  280. package/dist/public.d.ts +2 -1
  281. package/dist/shared-tree/defaultCommitEnricher.js +3 -3
  282. package/dist/shared-tree/defaultCommitEnricher.js.map +1 -1
  283. package/dist/shared-tree/schematizeTree.js.map +1 -1
  284. package/dist/shared-tree/schematizingTreeView.d.ts +2 -4
  285. package/dist/shared-tree/schematizingTreeView.d.ts.map +1 -1
  286. package/dist/shared-tree/schematizingTreeView.js +15 -8
  287. package/dist/shared-tree/schematizingTreeView.js.map +1 -1
  288. package/dist/shared-tree/sharedTree.d.ts +4 -4
  289. package/dist/shared-tree/sharedTree.d.ts.map +1 -1
  290. package/dist/shared-tree/sharedTree.js +3 -4
  291. package/dist/shared-tree/sharedTree.js.map +1 -1
  292. package/dist/shared-tree/sharedTreeChangeCodecs.d.ts.map +1 -1
  293. package/dist/shared-tree/sharedTreeChangeCodecs.js +4 -0
  294. package/dist/shared-tree/sharedTreeChangeCodecs.js.map +1 -1
  295. package/dist/shared-tree/sharedTreeChangeEnricher.js.map +1 -1
  296. package/dist/shared-tree/sharedTreeChangeFamily.js.map +1 -1
  297. package/dist/shared-tree/treeApi.js.map +1 -1
  298. package/dist/shared-tree/treeCheckout.d.ts.map +1 -1
  299. package/dist/shared-tree/treeCheckout.js +16 -5
  300. package/dist/shared-tree/treeCheckout.js.map +1 -1
  301. package/dist/shared-tree/treeView.d.ts +1 -3
  302. package/dist/shared-tree/treeView.d.ts.map +1 -1
  303. package/dist/shared-tree/treeView.js +5 -4
  304. package/dist/shared-tree/treeView.js.map +1 -1
  305. package/dist/shared-tree-core/branch.d.ts +0 -1
  306. package/dist/shared-tree-core/branch.d.ts.map +1 -1
  307. package/dist/shared-tree-core/branch.js +0 -1
  308. package/dist/shared-tree-core/branch.js.map +1 -1
  309. package/dist/shared-tree-core/editManager.d.ts.map +1 -1
  310. package/dist/shared-tree-core/editManager.js +0 -1
  311. package/dist/shared-tree-core/editManager.js.map +1 -1
  312. package/dist/shared-tree-core/editManagerCodecs.d.ts.map +1 -1
  313. package/dist/shared-tree-core/editManagerCodecs.js +2 -0
  314. package/dist/shared-tree-core/editManagerCodecs.js.map +1 -1
  315. package/dist/shared-tree-core/editManagerFormat.d.ts +8 -9
  316. package/dist/shared-tree-core/editManagerFormat.d.ts.map +1 -1
  317. package/dist/shared-tree-core/editManagerFormat.js +4 -1
  318. package/dist/shared-tree-core/editManagerFormat.js.map +1 -1
  319. package/dist/shared-tree-core/editManagerSummarizer.d.ts +2 -2
  320. package/dist/shared-tree-core/editManagerSummarizer.d.ts.map +1 -1
  321. package/dist/shared-tree-core/editManagerSummarizer.js.map +1 -1
  322. package/dist/shared-tree-core/messageCodecs.d.ts.map +1 -1
  323. package/dist/shared-tree-core/messageCodecs.js +1 -0
  324. package/dist/shared-tree-core/messageCodecs.js.map +1 -1
  325. package/dist/shared-tree-core/messageFormat.d.ts.map +1 -1
  326. package/dist/shared-tree-core/messageFormat.js +2 -0
  327. package/dist/shared-tree-core/messageFormat.js.map +1 -1
  328. package/dist/shared-tree-core/sequenceIdUtils.d.ts +2 -8
  329. package/dist/shared-tree-core/sequenceIdUtils.d.ts.map +1 -1
  330. package/dist/shared-tree-core/sequenceIdUtils.js.map +1 -1
  331. package/dist/shared-tree-core/sharedTreeCore.d.ts +3 -4
  332. package/dist/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
  333. package/dist/shared-tree-core/sharedTreeCore.js +5 -5
  334. package/dist/shared-tree-core/sharedTreeCore.js.map +1 -1
  335. package/dist/shared-tree-core/transactionStack.d.ts +1 -2
  336. package/dist/shared-tree-core/transactionStack.d.ts.map +1 -1
  337. package/dist/shared-tree-core/transactionStack.js +1 -2
  338. package/dist/shared-tree-core/transactionStack.js.map +1 -1
  339. package/dist/simple-tree/arrayNode.d.ts +8 -2
  340. package/dist/simple-tree/arrayNode.d.ts.map +1 -1
  341. package/dist/simple-tree/arrayNode.js +34 -7
  342. package/dist/simple-tree/arrayNode.js.map +1 -1
  343. package/dist/simple-tree/index.d.ts +3 -3
  344. package/dist/simple-tree/index.d.ts.map +1 -1
  345. package/dist/simple-tree/index.js +2 -2
  346. package/dist/simple-tree/index.js.map +1 -1
  347. package/dist/simple-tree/leafNodeSchema.d.ts +1 -1
  348. package/dist/simple-tree/leafNodeSchema.d.ts.map +1 -1
  349. package/dist/simple-tree/leafNodeSchema.js.map +1 -1
  350. package/dist/simple-tree/mapNode.d.ts +33 -1
  351. package/dist/simple-tree/mapNode.d.ts.map +1 -1
  352. package/dist/simple-tree/mapNode.js +4 -2
  353. package/dist/simple-tree/mapNode.js.map +1 -1
  354. package/dist/simple-tree/nodeKeys.d.ts +2 -1
  355. package/dist/simple-tree/nodeKeys.d.ts.map +1 -1
  356. package/dist/simple-tree/nodeKeys.js.map +1 -1
  357. package/dist/simple-tree/objectNode.d.ts +2 -3
  358. package/dist/simple-tree/objectNode.d.ts.map +1 -1
  359. package/dist/simple-tree/objectNode.js +4 -7
  360. package/dist/simple-tree/objectNode.js.map +1 -1
  361. package/dist/simple-tree/proxies.d.ts +1 -1
  362. package/dist/simple-tree/proxies.d.ts.map +1 -1
  363. package/dist/simple-tree/proxies.js.map +1 -1
  364. package/dist/simple-tree/proxyBinding.js +2 -2
  365. package/dist/simple-tree/proxyBinding.js.map +1 -1
  366. package/dist/simple-tree/rawNode.js.map +1 -1
  367. package/dist/simple-tree/schemaCaching.d.ts.map +1 -1
  368. package/dist/simple-tree/schemaCaching.js +4 -0
  369. package/dist/simple-tree/schemaCaching.js.map +1 -1
  370. package/dist/simple-tree/schemaCreationUtilities.d.ts.map +1 -1
  371. package/dist/simple-tree/schemaCreationUtilities.js +7 -0
  372. package/dist/simple-tree/schemaCreationUtilities.js.map +1 -1
  373. package/dist/simple-tree/schemaFactory.d.ts +6 -6
  374. package/dist/simple-tree/schemaFactory.d.ts.map +1 -1
  375. package/dist/simple-tree/schemaFactory.js +20 -2
  376. package/dist/simple-tree/schemaFactory.js.map +1 -1
  377. package/dist/simple-tree/schemaTypes.d.ts +28 -6
  378. package/dist/simple-tree/schemaTypes.d.ts.map +1 -1
  379. package/dist/simple-tree/schemaTypes.js +9 -1
  380. package/dist/simple-tree/schemaTypes.js.map +1 -1
  381. package/dist/simple-tree/toFlexSchema.d.ts +15 -3
  382. package/dist/simple-tree/toFlexSchema.d.ts.map +1 -1
  383. package/dist/simple-tree/toFlexSchema.js +18 -5
  384. package/dist/simple-tree/toFlexSchema.js.map +1 -1
  385. package/dist/simple-tree/toMapTree.d.ts +24 -6
  386. package/dist/simple-tree/toMapTree.d.ts.map +1 -1
  387. package/dist/simple-tree/toMapTree.js +84 -38
  388. package/dist/simple-tree/toMapTree.js.map +1 -1
  389. package/dist/simple-tree/tree.d.ts +26 -4
  390. package/dist/simple-tree/tree.d.ts.map +1 -1
  391. package/dist/simple-tree/tree.js +7 -2
  392. package/dist/simple-tree/tree.js.map +1 -1
  393. package/{lib/simple-tree/treeApi.d.ts → dist/simple-tree/treeNodeApi.d.ts} +10 -5
  394. package/dist/simple-tree/treeNodeApi.d.ts.map +1 -0
  395. package/dist/simple-tree/{treeApi.js → treeNodeApi.js} +49 -12
  396. package/dist/simple-tree/treeNodeApi.js.map +1 -0
  397. package/dist/simple-tree/types.d.ts.map +1 -1
  398. package/dist/simple-tree/types.js +5 -5
  399. package/dist/simple-tree/types.js.map +1 -1
  400. package/dist/simple-tree/typesUnsafe.d.ts +2 -2
  401. package/dist/simple-tree/typesUnsafe.d.ts.map +1 -1
  402. package/dist/simple-tree/typesUnsafe.js +1 -0
  403. package/dist/simple-tree/typesUnsafe.js.map +1 -1
  404. package/dist/treeFactory.d.ts +9 -8
  405. package/dist/treeFactory.d.ts.map +1 -1
  406. package/dist/treeFactory.js +3 -3
  407. package/dist/treeFactory.js.map +1 -1
  408. package/dist/util/brandedMap.d.ts.map +1 -1
  409. package/dist/util/brandedMap.js +1 -0
  410. package/dist/util/brandedMap.js.map +1 -1
  411. package/dist/util/idAllocator.js.map +1 -1
  412. package/dist/util/nestedMap.d.ts.map +1 -1
  413. package/dist/util/nestedMap.js.map +1 -1
  414. package/dist/util/offsetList.js.map +1 -1
  415. package/dist/util/opaque.d.ts.map +1 -1
  416. package/dist/util/opaque.js +2 -0
  417. package/dist/util/opaque.js.map +1 -1
  418. package/dist/util/rangeMap.js.map +1 -1
  419. package/dist/util/referenceCounting.js.map +1 -1
  420. package/dist/util/stackyIterator.js.map +1 -1
  421. package/dist/util/typeCheckTests.d.ts.map +1 -1
  422. package/dist/util/typeCheckTests.js.map +1 -1
  423. package/dist/util/typeUtils.js.map +1 -1
  424. package/dist/util/typeboxBrand.d.ts +3 -3
  425. package/dist/util/typeboxBrand.d.ts.map +1 -1
  426. package/dist/util/typeboxBrand.js +1 -1
  427. package/dist/util/typeboxBrand.js.map +1 -1
  428. package/dist/util/utils.d.ts.map +1 -1
  429. package/dist/util/utils.js.map +1 -1
  430. package/docs/.attachments/RefresherNotNeeded.png +0 -0
  431. package/docs/.attachments/StaleRefresher.png +0 -0
  432. package/docs/.attachments/SuperfluousRefresher.png +0 -0
  433. package/docs/.attachments/UndoDangerZone.drawio +787 -1
  434. package/docs/README.md +2 -3
  435. package/docs/main/compatibility.md +11 -0
  436. package/docs/main/detached-trees.md +480 -0
  437. package/docs/main/undo.md +10 -8
  438. package/docs/main/v1-undo.md +52 -560
  439. package/lib/beta.d.ts +2 -1
  440. package/lib/codec/codec.d.ts +1 -1
  441. package/lib/codec/codec.d.ts.map +1 -1
  442. package/lib/codec/codec.js.map +1 -1
  443. package/lib/codec/discriminatedUnions.d.ts.map +1 -1
  444. package/lib/codec/discriminatedUnions.js +1 -0
  445. package/lib/codec/discriminatedUnions.js.map +1 -1
  446. package/lib/core/forest/forest.d.ts +5 -6
  447. package/lib/core/forest/forest.d.ts.map +1 -1
  448. package/lib/core/forest/forest.js.map +1 -1
  449. package/lib/core/index.d.ts +1 -1
  450. package/lib/core/index.d.ts.map +1 -1
  451. package/lib/core/index.js +1 -1
  452. package/lib/core/index.js.map +1 -1
  453. package/lib/core/rebase/index.d.ts +1 -1
  454. package/lib/core/rebase/index.d.ts.map +1 -1
  455. package/lib/core/rebase/index.js +1 -1
  456. package/lib/core/rebase/index.js.map +1 -1
  457. package/lib/core/rebase/revisionTagCodec.js.map +1 -1
  458. package/lib/core/rebase/types.d.ts +1 -0
  459. package/lib/core/rebase/types.d.ts.map +1 -1
  460. package/lib/core/rebase/types.js +4 -1
  461. package/lib/core/rebase/types.js.map +1 -1
  462. package/lib/core/rebase/utils.d.ts.map +1 -1
  463. package/lib/core/rebase/utils.js.map +1 -1
  464. package/lib/core/rebase/verifyChangeRebaser.js.map +1 -1
  465. package/lib/core/schema-stored/schema.d.ts +4 -0
  466. package/lib/core/schema-stored/schema.d.ts.map +1 -1
  467. package/lib/core/schema-stored/schema.js.map +1 -1
  468. package/lib/core/schema-stored/storedSchemaRepository.js.map +1 -1
  469. package/lib/core/tree/anchorSet.d.ts.map +1 -1
  470. package/lib/core/tree/anchorSet.js +4 -0
  471. package/lib/core/tree/anchorSet.js.map +1 -1
  472. package/lib/core/tree/cursor.d.ts.map +1 -1
  473. package/lib/core/tree/cursor.js +3 -1
  474. package/lib/core/tree/cursor.js.map +1 -1
  475. package/lib/core/tree/deltaUtil.js.map +1 -1
  476. package/lib/core/tree/detachedFieldIndex.d.ts.map +1 -1
  477. package/lib/core/tree/detachedFieldIndex.js.map +1 -1
  478. package/lib/core/tree/detachedFieldIndexCodec.d.ts.map +1 -1
  479. package/lib/core/tree/detachedFieldIndexCodec.js.map +1 -1
  480. package/lib/core/tree/mapTree.js.map +1 -1
  481. package/lib/core/tree/pathTree.js.map +1 -1
  482. package/lib/core/tree/persistedTreeTextFormat.d.ts +4 -4
  483. package/lib/core/tree/persistedTreeTextFormat.d.ts.map +1 -1
  484. package/lib/core/tree/persistedTreeTextFormat.js +1 -0
  485. package/lib/core/tree/persistedTreeTextFormat.js.map +1 -1
  486. package/lib/core/tree/sparseTree.js.map +1 -1
  487. package/lib/core/tree/treeTextFormat.js.map +1 -1
  488. package/lib/core/tree/visitDelta.js.map +1 -1
  489. package/lib/core/tree/visitorUtils.js.map +1 -1
  490. package/lib/domains/index.d.ts +0 -1
  491. package/lib/domains/index.d.ts.map +1 -1
  492. package/lib/domains/index.js +0 -1
  493. package/lib/domains/index.js.map +1 -1
  494. package/lib/domains/json/jsonCursor.js +1 -1
  495. package/lib/domains/json/jsonCursor.js.map +1 -1
  496. package/lib/domains/json/jsonDomainSchema.js.map +1 -1
  497. package/lib/domains/schemaBuilder.d.ts.map +1 -1
  498. package/lib/domains/schemaBuilder.js +1 -0
  499. package/lib/domains/schemaBuilder.js.map +1 -1
  500. package/lib/domains/testRecursiveDomain.js.map +1 -1
  501. package/lib/events/events.d.ts +1 -1
  502. package/lib/events/events.d.ts.map +1 -1
  503. package/lib/events/events.js +1 -0
  504. package/lib/events/events.js.map +1 -1
  505. package/lib/feature-libraries/chunked-forest/basicChunk.js.map +1 -1
  506. package/lib/feature-libraries/chunked-forest/chunkTree.js.map +1 -1
  507. package/lib/feature-libraries/chunked-forest/chunkedForest.d.ts.map +1 -1
  508. package/lib/feature-libraries/chunked-forest/chunkedForest.js +4 -2
  509. package/lib/feature-libraries/chunked-forest/chunkedForest.js.map +1 -1
  510. package/lib/feature-libraries/chunked-forest/codec/chunkCodecUtilities.d.ts.map +1 -1
  511. package/lib/feature-libraries/chunked-forest/codec/chunkCodecUtilities.js.map +1 -1
  512. package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.js.map +1 -1
  513. package/lib/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.js.map +1 -1
  514. package/lib/feature-libraries/chunked-forest/codec/chunkEncodingGeneric.js.map +1 -1
  515. package/lib/feature-libraries/chunked-forest/codec/codecs.js.map +1 -1
  516. package/lib/feature-libraries/chunked-forest/codec/compressedEncode.d.ts.map +1 -1
  517. package/lib/feature-libraries/chunked-forest/codec/compressedEncode.js.map +1 -1
  518. package/lib/feature-libraries/chunked-forest/codec/formatGeneric.d.ts.map +1 -1
  519. package/lib/feature-libraries/chunked-forest/codec/formatGeneric.js.map +1 -1
  520. package/lib/feature-libraries/chunked-forest/codec/nodeShape.d.ts +1 -1
  521. package/lib/feature-libraries/chunked-forest/codec/nodeShape.d.ts.map +1 -1
  522. package/lib/feature-libraries/chunked-forest/codec/nodeShape.js.map +1 -1
  523. package/lib/feature-libraries/chunked-forest/codec/schemaBasedEncoding.js.map +1 -1
  524. package/lib/feature-libraries/chunked-forest/codec/uncompressedEncode.js.map +1 -1
  525. package/lib/feature-libraries/chunked-forest/sequenceChunk.js.map +1 -1
  526. package/lib/feature-libraries/chunked-forest/uniformChunk.js.map +1 -1
  527. package/lib/feature-libraries/contextuallyTyped.d.ts.map +1 -1
  528. package/lib/feature-libraries/contextuallyTyped.js.map +1 -1
  529. package/lib/feature-libraries/default-schema/defaultEditBuilder.d.ts.map +1 -1
  530. package/lib/feature-libraries/default-schema/defaultEditBuilder.js +13 -9
  531. package/lib/feature-libraries/default-schema/defaultEditBuilder.js.map +1 -1
  532. package/lib/feature-libraries/default-schema/defaultFieldKinds.d.ts +0 -6
  533. package/lib/feature-libraries/default-schema/defaultFieldKinds.d.ts.map +1 -1
  534. package/lib/feature-libraries/default-schema/defaultFieldKinds.js +12 -1
  535. package/lib/feature-libraries/default-schema/defaultFieldKinds.js.map +1 -1
  536. package/lib/feature-libraries/default-schema/defaultSchema.d.ts.map +1 -1
  537. package/lib/feature-libraries/default-schema/defaultSchema.js +1 -0
  538. package/lib/feature-libraries/default-schema/defaultSchema.js.map +1 -1
  539. package/lib/feature-libraries/default-schema/index.d.ts +2 -1
  540. package/lib/feature-libraries/default-schema/index.d.ts.map +1 -1
  541. package/lib/feature-libraries/default-schema/index.js +1 -0
  542. package/lib/feature-libraries/default-schema/index.js.map +1 -1
  543. package/lib/feature-libraries/default-schema/schemaChecker.js.map +1 -1
  544. package/lib/feature-libraries/deltaUtils.js.map +1 -1
  545. package/lib/feature-libraries/detachedFieldIndexSummarizer.d.ts +2 -2
  546. package/lib/feature-libraries/detachedFieldIndexSummarizer.d.ts.map +1 -1
  547. package/lib/feature-libraries/detachedFieldIndexSummarizer.js.map +1 -1
  548. package/lib/feature-libraries/editableTreeBinder.js.map +1 -1
  549. package/lib/feature-libraries/flex-tree/context.d.ts +10 -16
  550. package/lib/feature-libraries/flex-tree/context.d.ts.map +1 -1
  551. package/lib/feature-libraries/flex-tree/context.js +14 -20
  552. package/lib/feature-libraries/flex-tree/context.js.map +1 -1
  553. package/lib/feature-libraries/flex-tree/flexTreeTypes.d.ts +14 -13
  554. package/lib/feature-libraries/flex-tree/flexTreeTypes.d.ts.map +1 -1
  555. package/lib/feature-libraries/flex-tree/flexTreeTypes.js +0 -1
  556. package/lib/feature-libraries/flex-tree/flexTreeTypes.js.map +1 -1
  557. package/lib/feature-libraries/flex-tree/index.d.ts +1 -0
  558. package/lib/feature-libraries/flex-tree/index.d.ts.map +1 -1
  559. package/lib/feature-libraries/flex-tree/index.js +1 -0
  560. package/lib/feature-libraries/flex-tree/index.js.map +1 -1
  561. package/lib/feature-libraries/flex-tree/lazyEntity.js.map +1 -1
  562. package/lib/feature-libraries/flex-tree/lazyField.d.ts +3 -10
  563. package/lib/feature-libraries/flex-tree/lazyField.d.ts.map +1 -1
  564. package/lib/feature-libraries/flex-tree/lazyField.js +9 -38
  565. package/lib/feature-libraries/flex-tree/lazyField.js.map +1 -1
  566. package/lib/feature-libraries/flex-tree/lazyNode.d.ts +3 -7
  567. package/lib/feature-libraries/flex-tree/lazyNode.d.ts.map +1 -1
  568. package/lib/feature-libraries/flex-tree/lazyNode.js +6 -28
  569. package/lib/feature-libraries/flex-tree/lazyNode.js.map +1 -1
  570. package/lib/feature-libraries/flex-tree/navigation.d.ts.map +1 -1
  571. package/lib/feature-libraries/flex-tree/navigation.js.map +1 -1
  572. package/lib/feature-libraries/flex-tree/unboxed.js.map +1 -1
  573. package/lib/feature-libraries/flex-tree/utilities.d.ts +8 -2
  574. package/lib/feature-libraries/flex-tree/utilities.d.ts.map +1 -1
  575. package/lib/feature-libraries/flex-tree/utilities.js +11 -0
  576. package/lib/feature-libraries/flex-tree/utilities.js.map +1 -1
  577. package/lib/feature-libraries/forest-summary/codec.js.map +1 -1
  578. package/lib/feature-libraries/forest-summary/forestSummarizer.d.ts +2 -2
  579. package/lib/feature-libraries/forest-summary/forestSummarizer.d.ts.map +1 -1
  580. package/lib/feature-libraries/forest-summary/forestSummarizer.js.map +1 -1
  581. package/lib/feature-libraries/index.d.ts +3 -3
  582. package/lib/feature-libraries/index.d.ts.map +1 -1
  583. package/lib/feature-libraries/index.js +3 -3
  584. package/lib/feature-libraries/index.js.map +1 -1
  585. package/lib/feature-libraries/mapTreeCursor.js +1 -1
  586. package/lib/feature-libraries/mapTreeCursor.js.map +1 -1
  587. package/lib/feature-libraries/memoizedIdRangeAllocator.js.map +1 -1
  588. package/lib/feature-libraries/mitigatedChangeFamily.js.map +1 -1
  589. package/lib/feature-libraries/modular-schema/comparison.js.map +1 -1
  590. package/lib/feature-libraries/modular-schema/fieldKindWithEditor.d.ts +1 -1
  591. package/lib/feature-libraries/modular-schema/fieldKindWithEditor.d.ts.map +1 -1
  592. package/lib/feature-libraries/modular-schema/fieldKindWithEditor.js +4 -1
  593. package/lib/feature-libraries/modular-schema/fieldKindWithEditor.js.map +1 -1
  594. package/lib/feature-libraries/modular-schema/genericFieldKind.js.map +1 -1
  595. package/lib/feature-libraries/modular-schema/genericFieldKindFormat.d.ts.map +1 -1
  596. package/lib/feature-libraries/modular-schema/genericFieldKindFormat.js +3 -0
  597. package/lib/feature-libraries/modular-schema/genericFieldKindFormat.js.map +1 -1
  598. package/lib/feature-libraries/modular-schema/isNeverTree.js.map +1 -1
  599. package/lib/feature-libraries/modular-schema/modularChangeCodecs.js +2 -1
  600. package/lib/feature-libraries/modular-schema/modularChangeCodecs.js.map +1 -1
  601. package/lib/feature-libraries/modular-schema/modularChangeFamily.d.ts +0 -1
  602. package/lib/feature-libraries/modular-schema/modularChangeFamily.d.ts.map +1 -1
  603. package/lib/feature-libraries/modular-schema/modularChangeFamily.js +1 -5
  604. package/lib/feature-libraries/modular-schema/modularChangeFamily.js.map +1 -1
  605. package/lib/feature-libraries/modular-schema/modularChangeTypes.d.ts +1 -9
  606. package/lib/feature-libraries/modular-schema/modularChangeTypes.d.ts.map +1 -1
  607. package/lib/feature-libraries/modular-schema/modularChangeTypes.js.map +1 -1
  608. package/lib/feature-libraries/node-key/index.d.ts +1 -1
  609. package/lib/feature-libraries/node-key/index.d.ts.map +1 -1
  610. package/lib/feature-libraries/node-key/index.js +1 -1
  611. package/lib/feature-libraries/node-key/index.js.map +1 -1
  612. package/lib/feature-libraries/node-key/nodeKey.d.ts +0 -8
  613. package/lib/feature-libraries/node-key/nodeKey.d.ts.map +1 -1
  614. package/lib/feature-libraries/node-key/nodeKey.js +0 -8
  615. package/lib/feature-libraries/node-key/nodeKey.js.map +1 -1
  616. package/lib/feature-libraries/node-key/nodeKeyIndex.d.ts +1 -1
  617. package/lib/feature-libraries/node-key/nodeKeyIndex.d.ts.map +1 -1
  618. package/lib/feature-libraries/node-key/nodeKeyIndex.js.map +1 -1
  619. package/lib/feature-libraries/node-key/nodeKeyManager.d.ts +12 -2
  620. package/lib/feature-libraries/node-key/nodeKeyManager.d.ts.map +1 -1
  621. package/lib/feature-libraries/node-key/nodeKeyManager.js +4 -4
  622. package/lib/feature-libraries/node-key/nodeKeyManager.js.map +1 -1
  623. package/lib/feature-libraries/object-forest/objectForest.d.ts.map +1 -1
  624. package/lib/feature-libraries/object-forest/objectForest.js +13 -3
  625. package/lib/feature-libraries/object-forest/objectForest.js.map +1 -1
  626. package/lib/feature-libraries/optional-field/optionalField.js.map +1 -1
  627. package/lib/feature-libraries/optional-field/optionalFieldChangeFormatV1.d.ts.map +1 -1
  628. package/lib/feature-libraries/optional-field/optionalFieldChangeFormatV1.js +4 -0
  629. package/lib/feature-libraries/optional-field/optionalFieldChangeFormatV1.js.map +1 -1
  630. package/lib/feature-libraries/optional-field/optionalFieldChangeFormatV2.d.ts.map +1 -1
  631. package/lib/feature-libraries/optional-field/optionalFieldChangeFormatV2.js +4 -0
  632. package/lib/feature-libraries/optional-field/optionalFieldChangeFormatV2.js.map +1 -1
  633. package/lib/feature-libraries/optional-field/optionalFieldCodecV1.js.map +1 -1
  634. package/lib/feature-libraries/optional-field/optionalFieldCodecV2.js.map +1 -1
  635. package/lib/feature-libraries/schema-aware/schemaAware.d.ts +1 -1
  636. package/lib/feature-libraries/schema-aware/schemaAware.d.ts.map +1 -1
  637. package/lib/feature-libraries/schema-aware/schemaAware.js.map +1 -1
  638. package/lib/feature-libraries/schema-index/codec.js.map +1 -1
  639. package/lib/feature-libraries/schema-index/schemaSummarizer.d.ts +2 -2
  640. package/lib/feature-libraries/schema-index/schemaSummarizer.d.ts.map +1 -1
  641. package/lib/feature-libraries/schema-index/schemaSummarizer.js.map +1 -1
  642. package/lib/feature-libraries/schemaBuilderBase.js.map +1 -1
  643. package/lib/feature-libraries/sequence-field/compose.d.ts.map +1 -1
  644. package/lib/feature-libraries/sequence-field/compose.js +15 -86
  645. package/lib/feature-libraries/sequence-field/compose.js.map +1 -1
  646. package/lib/feature-libraries/sequence-field/{format.d.ts → formatV1.d.ts} +41 -41
  647. package/lib/feature-libraries/sequence-field/formatV1.d.ts.map +1 -0
  648. package/lib/feature-libraries/sequence-field/{format.js → formatV1.js} +5 -1
  649. package/lib/feature-libraries/sequence-field/formatV1.js.map +1 -0
  650. package/lib/feature-libraries/sequence-field/formatV2.d.ts +261 -0
  651. package/lib/feature-libraries/sequence-field/formatV2.d.ts.map +1 -0
  652. package/lib/feature-libraries/sequence-field/formatV2.js +67 -0
  653. package/lib/feature-libraries/sequence-field/formatV2.js.map +1 -0
  654. package/lib/feature-libraries/sequence-field/index.d.ts +2 -2
  655. package/lib/feature-libraries/sequence-field/index.d.ts.map +1 -1
  656. package/lib/feature-libraries/sequence-field/index.js +1 -1
  657. package/lib/feature-libraries/sequence-field/index.js.map +1 -1
  658. package/lib/feature-libraries/sequence-field/invert.d.ts.map +1 -1
  659. package/lib/feature-libraries/sequence-field/invert.js +5 -22
  660. package/lib/feature-libraries/sequence-field/invert.js.map +1 -1
  661. package/lib/feature-libraries/sequence-field/markListFactory.d.ts.map +1 -1
  662. package/lib/feature-libraries/sequence-field/markListFactory.js +0 -4
  663. package/lib/feature-libraries/sequence-field/markListFactory.js.map +1 -1
  664. package/lib/feature-libraries/sequence-field/markQueue.js.map +1 -1
  665. package/lib/feature-libraries/sequence-field/moveEffectTable.d.ts.map +1 -1
  666. package/lib/feature-libraries/sequence-field/moveEffectTable.js.map +1 -1
  667. package/lib/feature-libraries/sequence-field/prune.js.map +1 -1
  668. package/lib/feature-libraries/sequence-field/rebase.d.ts +1 -2
  669. package/lib/feature-libraries/sequence-field/rebase.d.ts.map +1 -1
  670. package/lib/feature-libraries/sequence-field/rebase.js +17 -360
  671. package/lib/feature-libraries/sequence-field/rebase.js.map +1 -1
  672. package/lib/feature-libraries/sequence-field/relevantRemovedRoots.js.map +1 -1
  673. package/lib/feature-libraries/sequence-field/replaceRevisions.js.map +1 -1
  674. package/lib/feature-libraries/sequence-field/sequenceFieldCodecV1.d.ts +11 -0
  675. package/lib/feature-libraries/sequence-field/sequenceFieldCodecV1.d.ts.map +1 -0
  676. package/lib/feature-libraries/sequence-field/sequenceFieldCodecV1.js +207 -0
  677. package/lib/feature-libraries/sequence-field/sequenceFieldCodecV1.js.map +1 -0
  678. package/lib/feature-libraries/sequence-field/sequenceFieldCodecV2.d.ts +11 -0
  679. package/lib/feature-libraries/sequence-field/sequenceFieldCodecV2.d.ts.map +1 -0
  680. package/lib/feature-libraries/sequence-field/sequenceFieldCodecV2.js +188 -0
  681. package/lib/feature-libraries/sequence-field/sequenceFieldCodecV2.js.map +1 -0
  682. package/lib/feature-libraries/sequence-field/sequenceFieldCodecs.d.ts +3 -2
  683. package/lib/feature-libraries/sequence-field/sequenceFieldCodecs.d.ts.map +1 -1
  684. package/lib/feature-libraries/sequence-field/sequenceFieldCodecs.js +7 -236
  685. package/lib/feature-libraries/sequence-field/sequenceFieldCodecs.js.map +1 -1
  686. package/lib/feature-libraries/sequence-field/sequenceFieldEditor.d.ts +9 -7
  687. package/lib/feature-libraries/sequence-field/sequenceFieldEditor.d.ts.map +1 -1
  688. package/lib/feature-libraries/sequence-field/sequenceFieldEditor.js +14 -15
  689. package/lib/feature-libraries/sequence-field/sequenceFieldEditor.js.map +1 -1
  690. package/lib/feature-libraries/sequence-field/sequenceFieldToDelta.js.map +1 -1
  691. package/lib/feature-libraries/sequence-field/types.d.ts +2 -45
  692. package/lib/feature-libraries/sequence-field/types.d.ts.map +1 -1
  693. package/lib/feature-libraries/sequence-field/types.js.map +1 -1
  694. package/lib/feature-libraries/sequence-field/utils.d.ts +1 -12
  695. package/lib/feature-libraries/sequence-field/utils.d.ts.map +1 -1
  696. package/lib/feature-libraries/sequence-field/utils.js +6 -110
  697. package/lib/feature-libraries/sequence-field/utils.js.map +1 -1
  698. package/lib/feature-libraries/storedToViewSchema.js.map +1 -1
  699. package/lib/feature-libraries/treeCursorUtils.js.map +1 -1
  700. package/lib/feature-libraries/treeTextCursor.js.map +1 -1
  701. package/lib/feature-libraries/typed-schema/flexList.js.map +1 -1
  702. package/lib/feature-libraries/typed-schema/schemaCollection.js.map +1 -1
  703. package/lib/feature-libraries/typed-schema/typedTreeSchema.js.map +1 -1
  704. package/lib/feature-libraries/typed-schema/view.js.map +1 -1
  705. package/lib/feature-libraries/valueUtilities.d.ts +1 -1
  706. package/lib/feature-libraries/valueUtilities.d.ts.map +1 -1
  707. package/lib/feature-libraries/valueUtilities.js.map +1 -1
  708. package/lib/index.d.ts +3 -3
  709. package/lib/index.d.ts.map +1 -1
  710. package/lib/index.js +1 -1
  711. package/lib/index.js.map +1 -1
  712. package/lib/packageVersion.d.ts +1 -1
  713. package/lib/packageVersion.js +1 -1
  714. package/lib/packageVersion.js.map +1 -1
  715. package/lib/public.d.ts +2 -1
  716. package/lib/shared-tree/defaultCommitEnricher.js +3 -3
  717. package/lib/shared-tree/defaultCommitEnricher.js.map +1 -1
  718. package/lib/shared-tree/schematizeTree.js.map +1 -1
  719. package/lib/shared-tree/schematizingTreeView.d.ts +2 -4
  720. package/lib/shared-tree/schematizingTreeView.d.ts.map +1 -1
  721. package/lib/shared-tree/schematizingTreeView.js +15 -8
  722. package/lib/shared-tree/schematizingTreeView.js.map +1 -1
  723. package/lib/shared-tree/sharedTree.d.ts +4 -4
  724. package/lib/shared-tree/sharedTree.d.ts.map +1 -1
  725. package/lib/shared-tree/sharedTree.js +4 -5
  726. package/lib/shared-tree/sharedTree.js.map +1 -1
  727. package/lib/shared-tree/sharedTreeChangeCodecs.d.ts.map +1 -1
  728. package/lib/shared-tree/sharedTreeChangeCodecs.js +4 -0
  729. package/lib/shared-tree/sharedTreeChangeCodecs.js.map +1 -1
  730. package/lib/shared-tree/sharedTreeChangeEnricher.js.map +1 -1
  731. package/lib/shared-tree/sharedTreeChangeFamily.js.map +1 -1
  732. package/lib/shared-tree/treeApi.js.map +1 -1
  733. package/lib/shared-tree/treeCheckout.d.ts.map +1 -1
  734. package/lib/shared-tree/treeCheckout.js +16 -5
  735. package/lib/shared-tree/treeCheckout.js.map +1 -1
  736. package/lib/shared-tree/treeView.d.ts +1 -3
  737. package/lib/shared-tree/treeView.d.ts.map +1 -1
  738. package/lib/shared-tree/treeView.js +5 -4
  739. package/lib/shared-tree/treeView.js.map +1 -1
  740. package/lib/shared-tree-core/branch.d.ts +0 -1
  741. package/lib/shared-tree-core/branch.d.ts.map +1 -1
  742. package/lib/shared-tree-core/branch.js +0 -1
  743. package/lib/shared-tree-core/branch.js.map +1 -1
  744. package/lib/shared-tree-core/editManager.d.ts.map +1 -1
  745. package/lib/shared-tree-core/editManager.js +0 -1
  746. package/lib/shared-tree-core/editManager.js.map +1 -1
  747. package/lib/shared-tree-core/editManagerCodecs.d.ts.map +1 -1
  748. package/lib/shared-tree-core/editManagerCodecs.js +2 -0
  749. package/lib/shared-tree-core/editManagerCodecs.js.map +1 -1
  750. package/lib/shared-tree-core/editManagerFormat.d.ts +8 -9
  751. package/lib/shared-tree-core/editManagerFormat.d.ts.map +1 -1
  752. package/lib/shared-tree-core/editManagerFormat.js +4 -1
  753. package/lib/shared-tree-core/editManagerFormat.js.map +1 -1
  754. package/lib/shared-tree-core/editManagerSummarizer.d.ts +2 -2
  755. package/lib/shared-tree-core/editManagerSummarizer.d.ts.map +1 -1
  756. package/lib/shared-tree-core/editManagerSummarizer.js.map +1 -1
  757. package/lib/shared-tree-core/messageCodecs.d.ts.map +1 -1
  758. package/lib/shared-tree-core/messageCodecs.js +1 -0
  759. package/lib/shared-tree-core/messageCodecs.js.map +1 -1
  760. package/lib/shared-tree-core/messageFormat.d.ts.map +1 -1
  761. package/lib/shared-tree-core/messageFormat.js +2 -0
  762. package/lib/shared-tree-core/messageFormat.js.map +1 -1
  763. package/lib/shared-tree-core/sequenceIdUtils.d.ts +2 -8
  764. package/lib/shared-tree-core/sequenceIdUtils.d.ts.map +1 -1
  765. package/lib/shared-tree-core/sequenceIdUtils.js.map +1 -1
  766. package/lib/shared-tree-core/sharedTreeCore.d.ts +3 -4
  767. package/lib/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
  768. package/lib/shared-tree-core/sharedTreeCore.js +5 -5
  769. package/lib/shared-tree-core/sharedTreeCore.js.map +1 -1
  770. package/lib/shared-tree-core/transactionStack.d.ts +1 -2
  771. package/lib/shared-tree-core/transactionStack.d.ts.map +1 -1
  772. package/lib/shared-tree-core/transactionStack.js +1 -2
  773. package/lib/shared-tree-core/transactionStack.js.map +1 -1
  774. package/lib/simple-tree/arrayNode.d.ts +8 -2
  775. package/lib/simple-tree/arrayNode.d.ts.map +1 -1
  776. package/lib/simple-tree/arrayNode.js +32 -5
  777. package/lib/simple-tree/arrayNode.js.map +1 -1
  778. package/lib/simple-tree/index.d.ts +3 -3
  779. package/lib/simple-tree/index.d.ts.map +1 -1
  780. package/lib/simple-tree/index.js +2 -2
  781. package/lib/simple-tree/index.js.map +1 -1
  782. package/lib/simple-tree/leafNodeSchema.d.ts +1 -1
  783. package/lib/simple-tree/leafNodeSchema.d.ts.map +1 -1
  784. package/lib/simple-tree/leafNodeSchema.js.map +1 -1
  785. package/lib/simple-tree/mapNode.d.ts +33 -1
  786. package/lib/simple-tree/mapNode.d.ts.map +1 -1
  787. package/lib/simple-tree/mapNode.js +4 -2
  788. package/lib/simple-tree/mapNode.js.map +1 -1
  789. package/lib/simple-tree/nodeKeys.d.ts +2 -1
  790. package/lib/simple-tree/nodeKeys.d.ts.map +1 -1
  791. package/lib/simple-tree/nodeKeys.js.map +1 -1
  792. package/lib/simple-tree/objectNode.d.ts +2 -3
  793. package/lib/simple-tree/objectNode.d.ts.map +1 -1
  794. package/lib/simple-tree/objectNode.js +6 -9
  795. package/lib/simple-tree/objectNode.js.map +1 -1
  796. package/lib/simple-tree/proxies.d.ts +1 -1
  797. package/lib/simple-tree/proxies.d.ts.map +1 -1
  798. package/lib/simple-tree/proxies.js.map +1 -1
  799. package/lib/simple-tree/proxyBinding.js +2 -2
  800. package/lib/simple-tree/proxyBinding.js.map +1 -1
  801. package/lib/simple-tree/rawNode.js.map +1 -1
  802. package/lib/simple-tree/schemaCaching.d.ts.map +1 -1
  803. package/lib/simple-tree/schemaCaching.js +4 -0
  804. package/lib/simple-tree/schemaCaching.js.map +1 -1
  805. package/lib/simple-tree/schemaCreationUtilities.d.ts.map +1 -1
  806. package/lib/simple-tree/schemaCreationUtilities.js +7 -0
  807. package/lib/simple-tree/schemaCreationUtilities.js.map +1 -1
  808. package/lib/simple-tree/schemaFactory.d.ts +6 -6
  809. package/lib/simple-tree/schemaFactory.d.ts.map +1 -1
  810. package/lib/simple-tree/schemaFactory.js +22 -4
  811. package/lib/simple-tree/schemaFactory.js.map +1 -1
  812. package/lib/simple-tree/schemaTypes.d.ts +28 -6
  813. package/lib/simple-tree/schemaTypes.d.ts.map +1 -1
  814. package/lib/simple-tree/schemaTypes.js +6 -0
  815. package/lib/simple-tree/schemaTypes.js.map +1 -1
  816. package/lib/simple-tree/toFlexSchema.d.ts +15 -3
  817. package/lib/simple-tree/toFlexSchema.d.ts.map +1 -1
  818. package/lib/simple-tree/toFlexSchema.js +18 -5
  819. package/lib/simple-tree/toFlexSchema.js.map +1 -1
  820. package/lib/simple-tree/toMapTree.d.ts +24 -6
  821. package/lib/simple-tree/toMapTree.d.ts.map +1 -1
  822. package/lib/simple-tree/toMapTree.js +83 -38
  823. package/lib/simple-tree/toMapTree.js.map +1 -1
  824. package/lib/simple-tree/tree.d.ts +26 -4
  825. package/lib/simple-tree/tree.d.ts.map +1 -1
  826. package/lib/simple-tree/tree.js +7 -2
  827. package/lib/simple-tree/tree.js.map +1 -1
  828. package/{dist/simple-tree/treeApi.d.ts → lib/simple-tree/treeNodeApi.d.ts} +10 -5
  829. package/lib/simple-tree/treeNodeApi.d.ts.map +1 -0
  830. package/lib/simple-tree/{treeApi.js → treeNodeApi.js} +51 -15
  831. package/lib/simple-tree/treeNodeApi.js.map +1 -0
  832. package/lib/simple-tree/types.d.ts.map +1 -1
  833. package/lib/simple-tree/types.js +5 -5
  834. package/lib/simple-tree/types.js.map +1 -1
  835. package/lib/simple-tree/typesUnsafe.d.ts +2 -2
  836. package/lib/simple-tree/typesUnsafe.d.ts.map +1 -1
  837. package/lib/simple-tree/typesUnsafe.js +1 -0
  838. package/lib/simple-tree/typesUnsafe.js.map +1 -1
  839. package/lib/treeFactory.d.ts +9 -8
  840. package/lib/treeFactory.d.ts.map +1 -1
  841. package/lib/treeFactory.js +4 -4
  842. package/lib/treeFactory.js.map +1 -1
  843. package/lib/tsdoc-metadata.json +1 -1
  844. package/lib/util/brandedMap.d.ts.map +1 -1
  845. package/lib/util/brandedMap.js +1 -0
  846. package/lib/util/brandedMap.js.map +1 -1
  847. package/lib/util/idAllocator.js.map +1 -1
  848. package/lib/util/nestedMap.d.ts.map +1 -1
  849. package/lib/util/nestedMap.js.map +1 -1
  850. package/lib/util/offsetList.js.map +1 -1
  851. package/lib/util/opaque.d.ts.map +1 -1
  852. package/lib/util/opaque.js +2 -0
  853. package/lib/util/opaque.js.map +1 -1
  854. package/lib/util/rangeMap.js.map +1 -1
  855. package/lib/util/referenceCounting.js.map +1 -1
  856. package/lib/util/stackyIterator.js.map +1 -1
  857. package/lib/util/typeCheckTests.d.ts.map +1 -1
  858. package/lib/util/typeCheckTests.js.map +1 -1
  859. package/lib/util/typeUtils.js.map +1 -1
  860. package/lib/util/typeboxBrand.d.ts +3 -3
  861. package/lib/util/typeboxBrand.d.ts.map +1 -1
  862. package/lib/util/typeboxBrand.js +1 -1
  863. package/lib/util/typeboxBrand.js.map +1 -1
  864. package/lib/util/utils.d.ts.map +1 -1
  865. package/lib/util/utils.js.map +1 -1
  866. package/package.json +25 -25
  867. package/src/codec/codec.ts +21 -15
  868. package/src/codec/discriminatedUnions.ts +1 -0
  869. package/src/core/forest/forest.ts +5 -7
  870. package/src/core/index.ts +1 -0
  871. package/src/core/rebase/index.ts +1 -0
  872. package/src/core/rebase/types.ts +5 -0
  873. package/src/core/rebase/utils.ts +4 -4
  874. package/src/core/rebase/verifyChangeRebaser.ts +3 -3
  875. package/src/core/schema-stored/schema.ts +6 -1
  876. package/src/core/tree/anchorSet.ts +8 -2
  877. package/src/core/tree/cursor.ts +5 -1
  878. package/src/core/tree/detachedFieldIndex.ts +2 -2
  879. package/src/core/tree/detachedFieldIndexCodec.ts +3 -3
  880. package/src/core/tree/persistedTreeTextFormat.ts +5 -0
  881. package/src/core/tree/visitDelta.ts +4 -4
  882. package/src/domains/index.ts +0 -2
  883. package/src/domains/schemaBuilder.ts +1 -0
  884. package/src/events/events.ts +4 -1
  885. package/src/feature-libraries/chunked-forest/chunkedForest.ts +5 -3
  886. package/src/feature-libraries/chunked-forest/codec/chunkCodecUtilities.ts +2 -2
  887. package/src/feature-libraries/chunked-forest/codec/chunkEncodingGeneric.ts +2 -2
  888. package/src/feature-libraries/chunked-forest/codec/compressedEncode.ts +4 -4
  889. package/src/feature-libraries/chunked-forest/codec/formatGeneric.ts +2 -0
  890. package/src/feature-libraries/chunked-forest/codec/nodeShape.ts +8 -5
  891. package/src/feature-libraries/contextuallyTyped.ts +1 -1
  892. package/src/feature-libraries/default-schema/defaultEditBuilder.ts +21 -12
  893. package/src/feature-libraries/default-schema/defaultFieldKinds.ts +12 -6
  894. package/src/feature-libraries/default-schema/defaultSchema.ts +1 -0
  895. package/src/feature-libraries/default-schema/index.ts +2 -1
  896. package/src/feature-libraries/detachedFieldIndexSummarizer.ts +2 -2
  897. package/src/feature-libraries/editableTreeBinder.ts +3 -3
  898. package/src/feature-libraries/flex-tree/context.ts +16 -25
  899. package/src/feature-libraries/flex-tree/flexTreeTypes.ts +26 -17
  900. package/src/feature-libraries/flex-tree/index.ts +2 -0
  901. package/src/feature-libraries/flex-tree/lazyField.ts +13 -53
  902. package/src/feature-libraries/flex-tree/lazyNode.ts +11 -44
  903. package/src/feature-libraries/flex-tree/navigation.ts +2 -2
  904. package/src/feature-libraries/flex-tree/utilities.ts +14 -1
  905. package/src/feature-libraries/forest-summary/forestSummarizer.ts +2 -2
  906. package/src/feature-libraries/index.ts +3 -2
  907. package/src/feature-libraries/modular-schema/fieldKindWithEditor.ts +6 -2
  908. package/src/feature-libraries/modular-schema/genericFieldKind.ts +1 -1
  909. package/src/feature-libraries/modular-schema/genericFieldKindFormat.ts +5 -0
  910. package/src/feature-libraries/modular-schema/modularChangeCodecs.ts +2 -1
  911. package/src/feature-libraries/modular-schema/modularChangeFamily.ts +20 -13
  912. package/src/feature-libraries/modular-schema/modularChangeTypes.ts +0 -10
  913. package/src/feature-libraries/node-key/index.ts +0 -1
  914. package/src/feature-libraries/node-key/nodeKey.ts +0 -9
  915. package/src/feature-libraries/node-key/nodeKeyIndex.ts +1 -1
  916. package/src/feature-libraries/node-key/nodeKeyManager.ts +6 -11
  917. package/src/feature-libraries/object-forest/objectForest.ts +18 -7
  918. package/src/feature-libraries/optional-field/optionalFieldChangeFormatV1.ts +4 -0
  919. package/src/feature-libraries/optional-field/optionalFieldChangeFormatV2.ts +4 -0
  920. package/src/feature-libraries/schema-aware/schemaAware.ts +3 -1
  921. package/src/feature-libraries/schema-index/schemaSummarizer.ts +3 -3
  922. package/src/feature-libraries/schemaBuilderBase.ts +1 -1
  923. package/src/feature-libraries/sequence-field/compose.ts +31 -143
  924. package/src/feature-libraries/sequence-field/{format.ts → formatV1.ts} +6 -0
  925. package/src/feature-libraries/sequence-field/formatV2.ts +136 -0
  926. package/src/feature-libraries/sequence-field/index.ts +1 -5
  927. package/src/feature-libraries/sequence-field/invert.ts +4 -25
  928. package/src/feature-libraries/sequence-field/markListFactory.ts +0 -4
  929. package/src/feature-libraries/sequence-field/moveEffectTable.ts +1 -1
  930. package/src/feature-libraries/sequence-field/rebase.ts +27 -529
  931. package/src/feature-libraries/sequence-field/sequenceFieldCodecV1.ts +296 -0
  932. package/src/feature-libraries/sequence-field/sequenceFieldCodecV2.ts +272 -0
  933. package/src/feature-libraries/sequence-field/sequenceFieldCodecs.ts +9 -326
  934. package/src/feature-libraries/sequence-field/sequenceFieldEditor.ts +55 -30
  935. package/src/feature-libraries/sequence-field/types.ts +2 -51
  936. package/src/feature-libraries/sequence-field/utils.ts +8 -145
  937. package/src/feature-libraries/typed-schema/schemaCollection.ts +3 -3
  938. package/src/feature-libraries/valueUtilities.ts +1 -1
  939. package/src/index.ts +2 -2
  940. package/src/packageVersion.ts +1 -1
  941. package/src/shared-tree/defaultCommitEnricher.ts +3 -3
  942. package/src/shared-tree/schematizingTreeView.ts +18 -14
  943. package/src/shared-tree/sharedTree.ts +6 -10
  944. package/src/shared-tree/sharedTreeChangeCodecs.ts +8 -0
  945. package/src/shared-tree/treeCheckout.ts +24 -22
  946. package/src/shared-tree/treeView.ts +4 -15
  947. package/src/shared-tree-core/branch.ts +1 -2
  948. package/src/shared-tree-core/editManager.ts +0 -1
  949. package/src/shared-tree-core/editManagerCodecs.ts +4 -0
  950. package/src/shared-tree-core/editManagerFormat.ts +8 -2
  951. package/src/shared-tree-core/editManagerSummarizer.ts +2 -2
  952. package/src/shared-tree-core/messageCodecs.ts +2 -1
  953. package/src/shared-tree-core/messageFormat.ts +2 -0
  954. package/src/shared-tree-core/sequenceIdUtils.ts +5 -4
  955. package/src/shared-tree-core/sharedTreeCore.ts +15 -13
  956. package/src/shared-tree-core/transactionStack.ts +2 -3
  957. package/src/simple-tree/arrayNode.ts +119 -42
  958. package/src/simple-tree/index.ts +10 -2
  959. package/src/simple-tree/mapNode.ts +61 -6
  960. package/src/simple-tree/nodeKeys.ts +2 -1
  961. package/src/simple-tree/objectNode.ts +14 -12
  962. package/src/simple-tree/proxies.ts +1 -1
  963. package/src/simple-tree/proxyBinding.ts +3 -3
  964. package/src/simple-tree/schemaCaching.ts +4 -0
  965. package/src/simple-tree/schemaCreationUtilities.ts +7 -0
  966. package/src/simple-tree/schemaFactory.ts +36 -8
  967. package/src/simple-tree/schemaTypes.ts +35 -8
  968. package/src/simple-tree/toFlexSchema.ts +40 -6
  969. package/src/simple-tree/toMapTree.ts +140 -38
  970. package/src/simple-tree/tree.ts +35 -4
  971. package/src/simple-tree/{treeApi.ts → treeNodeApi.ts} +68 -29
  972. package/src/simple-tree/types.ts +9 -6
  973. package/src/simple-tree/typesUnsafe.ts +5 -2
  974. package/src/treeFactory.ts +15 -10
  975. package/src/util/brandedMap.ts +5 -0
  976. package/src/util/idAllocator.ts +1 -1
  977. package/src/util/nestedMap.ts +1 -1
  978. package/src/util/opaque.ts +4 -0
  979. package/src/util/typeCheckTests.ts +1 -0
  980. package/src/util/typeboxBrand.ts +3 -3
  981. package/src/util/utils.ts +4 -4
  982. package/dist/domains/nodeKey/index.d.ts +0 -6
  983. package/dist/domains/nodeKey/index.d.ts.map +0 -1
  984. package/dist/domains/nodeKey/index.js +0 -12
  985. package/dist/domains/nodeKey/index.js.map +0 -1
  986. package/dist/domains/nodeKey/nodeKeySchema.d.ts +0 -30
  987. package/dist/domains/nodeKey/nodeKeySchema.d.ts.map +0 -1
  988. package/dist/domains/nodeKey/nodeKeySchema.js +0 -36
  989. package/dist/domains/nodeKey/nodeKeySchema.js.map +0 -1
  990. package/dist/feature-libraries/sequence-field/config.d.ts +0 -13
  991. package/dist/feature-libraries/sequence-field/config.d.ts.map +0 -1
  992. package/dist/feature-libraries/sequence-field/config.js +0 -16
  993. package/dist/feature-libraries/sequence-field/config.js.map +0 -1
  994. package/dist/feature-libraries/sequence-field/format.d.ts.map +0 -1
  995. package/dist/feature-libraries/sequence-field/format.js.map +0 -1
  996. package/dist/simple-tree/treeApi.d.ts.map +0 -1
  997. package/dist/simple-tree/treeApi.js.map +0 -1
  998. package/docs/.attachments/UndoAfterCollab.png +0 -0
  999. package/docs/.attachments/UndoAfterCollabFast.png +0 -0
  1000. package/docs/.attachments/UndoDuringCollab.png +0 -0
  1001. package/docs/main/repair-data.md +0 -274
  1002. package/docs/main/v1-undo-example-flow.md +0 -273
  1003. package/lib/domains/nodeKey/index.d.ts +0 -6
  1004. package/lib/domains/nodeKey/index.d.ts.map +0 -1
  1005. package/lib/domains/nodeKey/index.js +0 -6
  1006. package/lib/domains/nodeKey/index.js.map +0 -1
  1007. package/lib/domains/nodeKey/nodeKeySchema.d.ts +0 -30
  1008. package/lib/domains/nodeKey/nodeKeySchema.d.ts.map +0 -1
  1009. package/lib/domains/nodeKey/nodeKeySchema.js +0 -33
  1010. package/lib/domains/nodeKey/nodeKeySchema.js.map +0 -1
  1011. package/lib/feature-libraries/sequence-field/config.d.ts +0 -13
  1012. package/lib/feature-libraries/sequence-field/config.d.ts.map +0 -1
  1013. package/lib/feature-libraries/sequence-field/config.js +0 -13
  1014. package/lib/feature-libraries/sequence-field/config.js.map +0 -1
  1015. package/lib/feature-libraries/sequence-field/format.d.ts.map +0 -1
  1016. package/lib/feature-libraries/sequence-field/format.js.map +0 -1
  1017. package/lib/simple-tree/treeApi.d.ts.map +0 -1
  1018. package/lib/simple-tree/treeApi.js.map +0 -1
  1019. package/src/domains/nodeKey/fence.json +0 -5
  1020. package/src/domains/nodeKey/index.ts +0 -6
  1021. package/src/domains/nodeKey/nodeKeySchema.ts +0 -44
  1022. package/src/feature-libraries/sequence-field/config.ts +0 -17
package/.eslintrc.cjs CHANGED
@@ -14,7 +14,7 @@ module.exports = {
14
14
  rules: {
15
15
  "@typescript-eslint/no-namespace": "off",
16
16
  "@typescript-eslint/no-empty-interface": "off",
17
- "@typescript-eslint/explicit-member-accessibility": "error",
17
+
18
18
  // This package is build with noUnusedLocals disabled for a specific use case (see note in tsconfig.json),
19
19
  // but should reject other cases using this rule:
20
20
  "@typescript-eslint/no-unused-vars": [
@@ -25,8 +25,30 @@ module.exports = {
25
25
  caughtErrorsIgnorePattern: "^_",
26
26
  },
27
27
  ],
28
- // This rule can be removed once the client release group has eslint-config-fluid 5.2.0+
28
+
29
+ // TODO: Remove this override once dependency on eslint-config-fluid has been updated to 5.2.0+
29
30
  "import/order": "off",
31
+
32
+ // TODO: Remove these overrides once this config has been updated to extend at least the "recommended" base config.
33
+ "@typescript-eslint/no-explicit-any": [
34
+ "error",
35
+ {
36
+ ignoreRestArgs: true,
37
+ },
38
+ ],
39
+ "@typescript-eslint/explicit-function-return-type": [
40
+ "error",
41
+ {
42
+ allowExpressions: true,
43
+ allowTypedFunctionExpressions: true,
44
+ allowHigherOrderFunctions: true,
45
+ allowDirectConstAssertionInArrowFunctions: true,
46
+ allowConciseArrowFunctionExpressionsStartingWithVoid: false,
47
+ },
48
+ ],
49
+
50
+ // TODO: Remove these overrides once this config has been updated to extend the "strict" base config.
51
+ "@typescript-eslint/explicit-member-accessibility": "error",
30
52
  },
31
53
  overrides: [
32
54
  {
@@ -36,6 +58,7 @@ module.exports = {
36
58
  },
37
59
  rules: {
38
60
  "@typescript-eslint/no-unused-vars": ["off"],
61
+ "@typescript-eslint/explicit-function-return-type": "off",
39
62
  },
40
63
  },
41
64
  ],
package/CHANGELOG.md CHANGED
@@ -1,5 +1,22 @@
1
1
  # @fluidframework/tree
2
2
 
3
+ ## 2.0.0-rc.4.0.0
4
+
5
+ ### Minor Changes
6
+
7
+ - Deprecated members of IFluidHandle are split off into new IFluidHandleInternal interface [96872186d0](https://github.com/microsoft/FluidFramework/commit/96872186d0d0f245c1fece7d19b3743e501679b6)
8
+
9
+ Split IFluidHandle into two interfaces, `IFluidHandle` and `IFluidHandleInternal`.
10
+ Code depending on the previously deprecated members of IFluidHandle can access them by using `toFluidHandleInternal` from `@fluidframework/runtime-utils/legacy`.
11
+
12
+ External implementation of the `IFluidHandle` interface are not supported: this change makes the typing better convey this using the `ErasedType` pattern.
13
+ Any existing and previously working, and now broken, external implementations of `IFluidHandle` should still work at runtime, but will need some unsafe type casts to compile.
14
+ Such handle implementation may break in the future and thus should be replaced with use of handles produced by the Fluid Framework client packages.
15
+
16
+ - Minor API fixes for "@fluidframework/tree" package. [96872186d0](https://github.com/microsoft/FluidFramework/commit/96872186d0d0f245c1fece7d19b3743e501679b6)
17
+
18
+ Changes constructor for `FieldSchema` from public to private. Users should call `makeFieldSchema` to create instance of `FieldSchema`.
19
+
3
20
  ## 2.0.0-rc.3.0.0
4
21
 
5
22
  ### Major Changes
@@ -5,13 +5,12 @@
5
5
  ```ts
6
6
 
7
7
  import { ErasedType } from '@fluidframework/core-interfaces';
8
- import { FluidObject } from '@fluidframework/core-interfaces';
9
- import { IChannel } from '@fluidframework/datastore-definitions';
10
8
  import { IFluidHandle } from '@fluidframework/core-interfaces';
11
9
  import { IFluidLoadable } from '@fluidframework/core-interfaces';
12
- import { ISharedObject } from '@fluidframework/shared-object-base';
13
- import { ISharedObjectKind } from '@fluidframework/shared-object-base';
10
+ import { ISharedObject } from '@fluidframework/shared-object-base/internal';
11
+ import { ISharedObjectKind } from '@fluidframework/shared-object-base/internal';
14
12
  import { SessionSpaceCompressedId } from '@fluidframework/id-compressor';
13
+ import { SharedObjectKind } from '@fluidframework/shared-object-base';
15
14
  import { StableId } from '@fluidframework/id-compressor';
16
15
  import type { Static } from '@sinclair/typebox';
17
16
  import type { TSchema } from '@sinclair/typebox';
@@ -136,7 +135,11 @@ export const Any: "Any";
136
135
  export type Any = typeof Any;
137
136
 
138
137
  // @public
139
- export type ApplyKind<T, Kind extends FieldKind> = Kind extends FieldKind.Required ? T : undefined | T;
138
+ export type ApplyKind<T, Kind extends FieldKind, DefaultsAreOptional extends boolean> = {
139
+ [FieldKind.Required]: T;
140
+ [FieldKind.Optional]: T | undefined;
141
+ [FieldKind.Identifier]: DefaultsAreOptional extends true ? T | undefined : T;
142
+ }[Kind];
140
143
 
141
144
  // @internal
142
145
  export type ApplyMultiplicity<TMultiplicity extends Multiplicity, TypedChild> = {
@@ -240,7 +243,7 @@ export interface CommitMetadata {
240
243
  export function compareLocalNodeKeys(a: LocalNodeKey, b: LocalNodeKey): -1 | 0 | 1;
241
244
 
242
245
  // @internal
243
- export function configuredSharedTree(options: SharedTreeOptions): ISharedObjectKind<ITree>;
246
+ export function configuredSharedTree(options: SharedTreeOptions): ISharedObjectKind<ITree> & SharedObjectKind<ITree>;
244
247
 
245
248
  // @internal
246
249
  export type ContextuallyTypedFieldData = ContextuallyTypedNodeData | undefined;
@@ -304,6 +307,10 @@ export interface CursorWithNode<TNode> extends ITreeCursorSynchronous {
304
307
  getNode(): TNode;
305
308
  }
306
309
 
310
+ // @public
311
+ export interface DefaultProvider extends ErasedType<"@fluidframework/tree.FieldProvider"> {
312
+ }
313
+
307
314
  // @internal
308
315
  export const defaultSchemaPolicy: FullSchemaPolicy;
309
316
 
@@ -480,7 +487,6 @@ export const FieldKinds: {
480
487
  readonly required: Required_2;
481
488
  readonly optional: Optional;
482
489
  readonly sequence: Sequence;
483
- readonly nodeKey: NodeKeyFieldKind;
484
490
  readonly identifier: Identifier;
485
491
  readonly forbidden: Forbidden;
486
492
  };
@@ -501,6 +507,7 @@ export interface FieldMapObject<TChild> {
501
507
 
502
508
  // @public
503
509
  export interface FieldProps {
510
+ readonly defaultProvider?: DefaultProvider;
504
511
  readonly key?: string;
505
512
  }
506
513
 
@@ -630,7 +637,7 @@ export class FlexObjectNodeSchema<const out Name extends string = string, const
630
637
 
631
638
  // @internal
632
639
  export interface FlexTreeContext extends ISubscribable<ForestEvents> {
633
- readonly forest: IForestSubscription;
640
+ readonly checkout: ITreeCheckout;
634
641
  // (undocumented)
635
642
  readonly nodeKeyManager: NodeKeyManager;
636
643
  get root(): FlexTreeField;
@@ -823,14 +830,14 @@ export interface FlexTreeSequenceField<in out TTypes extends FlexAllowedTypes> e
823
830
  moveToStart(sourceIndex: number): void;
824
831
  moveToStart(sourceIndex: number, source: FlexTreeSequenceField<FlexAllowedTypes>): void;
825
832
  removeAt(index: number): void;
826
- removeRange(start?: number, end?: number): void;
833
+ sequenceEditor(): SequenceFieldEditBuilder;
827
834
  }
828
835
 
829
836
  // @internal
830
837
  export type FlexTreeTypedField<TSchema extends FlexFieldSchema> = FlexTreeTypedFieldInner<TSchema["kind"], TSchema["allowedTypes"]>;
831
838
 
832
839
  // @internal
833
- export type FlexTreeTypedFieldInner<Kind extends FlexFieldKind, Types extends FlexAllowedTypes> = Kind extends typeof FieldKinds.sequence ? FlexTreeSequenceField<Types> : Kind extends typeof FieldKinds.required ? FlexTreeRequiredField<Types> : Kind extends typeof FieldKinds.optional ? FlexTreeOptionalField<Types> : Kind extends typeof FieldKinds.nodeKey ? FlexTreeNodeKeyField : FlexTreeField;
840
+ export type FlexTreeTypedFieldInner<Kind extends FlexFieldKind, Types extends FlexAllowedTypes> = Kind extends typeof FieldKinds.sequence ? FlexTreeSequenceField<Types> : Kind extends typeof FieldKinds.required ? FlexTreeRequiredField<Types> : Kind extends typeof FieldKinds.optional ? FlexTreeOptionalField<Types> : FlexTreeField;
834
841
 
835
842
  // @internal
836
843
  export type FlexTreeTypedNode<TSchema extends FlexTreeNodeSchema> = TSchema extends LeafNodeSchema ? FlexTreeLeafNode<TSchema> : TSchema extends FlexMapNodeSchema ? FlexTreeMapNode<TSchema> : TSchema extends FlexFieldNodeSchema ? FlexTreeFieldNode<TSchema> : TSchema extends FlexObjectNodeSchema ? FlexTreeObjectNodeTyped<TSchema> : FlexTreeNode;
@@ -842,7 +849,7 @@ export type FlexTreeTypedNodeUnion<T extends FlexAllowedTypes> = T extends FlexL
842
849
  export type FlexTreeUnboxField<TSchema extends FlexFieldSchema, Emptiness extends "maybeEmpty" | "notEmpty" = "maybeEmpty"> = FlexTreeUnboxFieldInner<TSchema["kind"], TSchema["allowedTypes"], Emptiness>;
843
850
 
844
851
  // @internal
845
- export type FlexTreeUnboxFieldInner<Kind extends FlexFieldKind, TTypes extends FlexAllowedTypes, Emptiness extends "maybeEmpty" | "notEmpty"> = Kind extends typeof FieldKinds.sequence ? FlexTreeSequenceField<TTypes> : Kind extends typeof FieldKinds.required ? FlexTreeUnboxNodeUnion<TTypes> : Kind extends typeof FieldKinds.optional ? FlexTreeUnboxNodeUnion<TTypes> | (Emptiness extends "notEmpty" ? never : undefined) : Kind extends typeof FieldKinds.nodeKey ? FlexTreeNodeKeyField : unknown;
852
+ export type FlexTreeUnboxFieldInner<Kind extends FlexFieldKind, TTypes extends FlexAllowedTypes, Emptiness extends "maybeEmpty" | "notEmpty"> = Kind extends typeof FieldKinds.sequence ? FlexTreeSequenceField<TTypes> : Kind extends typeof FieldKinds.required ? FlexTreeUnboxNodeUnion<TTypes> : Kind extends typeof FieldKinds.optional ? FlexTreeUnboxNodeUnion<TTypes> | (Emptiness extends "notEmpty" ? never : undefined) : unknown;
846
853
 
847
854
  // @internal
848
855
  export type FlexTreeUnboxNode<TSchema extends FlexTreeNodeSchema> = TSchema extends LeafNodeSchema ? TreeValue<TSchema["info"]> : TSchema extends FlexMapNodeSchema ? FlexTreeMapNode<TSchema> : TSchema extends FlexFieldNodeSchema ? FlexTreeFieldNode<TSchema> : TSchema extends FlexObjectNodeSchema ? FlexTreeObjectNodeTyped<TSchema> : FlexTreeUnknownUnboxed;
@@ -872,7 +879,6 @@ export const forbiddenFieldKindIdentifier = "Forbidden";
872
879
 
873
880
  // @internal
874
881
  export interface ForestEvents {
875
- afterChange(): void;
876
882
  afterRootFieldCreated(key: FieldKey): void;
877
883
  beforeChange(): void;
878
884
  }
@@ -985,7 +991,7 @@ ApplyMultiplicity<TField["kind"]["multiplicity"], AllowedTypesToFlexInsertableTr
985
991
  // @internal
986
992
  export type InsertableFlexNode<TSchema extends FlexTreeNodeSchema> = FlattenKeys<CollectOptions<TSchema extends FlexObjectNodeSchema<string, infer TFields extends FlexObjectNodeFields> ? TypedFields<TFields> : TSchema extends FlexFieldNodeSchema<string, infer TField extends FlexFieldSchema> ? InsertableFlexField<TField> : TSchema extends FlexMapNodeSchema<string, infer TField extends FlexFieldSchema> ? {
987
993
  readonly [P in string]: InsertableFlexField<TField>;
988
- } : EmptyObject, TSchema extends LeafNodeSchema<string, infer TValueSchema> ? TValueSchema : undefined, TSchema["name"]>>;
994
+ } : EmptyObject, TSchema extends LeafNodeSchema<string, infer TValueSchema extends ValueSchema> ? TValueSchema : undefined, TSchema["name"]>>;
989
995
 
990
996
  // @public
991
997
  export type InsertableObjectFromSchemaRecord<T extends RestrictiveReadonlyRecord<string, ImplicitFieldSchema>> = {
@@ -998,10 +1004,10 @@ export type InsertableObjectFromSchemaRecordUnsafe<T extends Unenforced<Restrict
998
1004
  };
999
1005
 
1000
1006
  // @public
1001
- export type InsertableTreeFieldFromImplicitField<TSchema extends ImplicitFieldSchema = FieldSchema> = TSchema extends FieldSchema<infer Kind, infer Types> ? ApplyKind<InsertableTreeNodeFromImplicitAllowedTypes<Types>, Kind> : TSchema extends ImplicitAllowedTypes ? InsertableTreeNodeFromImplicitAllowedTypes<TSchema> : unknown;
1007
+ export type InsertableTreeFieldFromImplicitField<TSchema extends ImplicitFieldSchema = FieldSchema> = TSchema extends FieldSchema<infer Kind, infer Types> ? ApplyKind<InsertableTreeNodeFromImplicitAllowedTypes<Types>, Kind, true> : TSchema extends ImplicitAllowedTypes ? InsertableTreeNodeFromImplicitAllowedTypes<TSchema> : unknown;
1002
1008
 
1003
1009
  // @public
1004
- export type InsertableTreeFieldFromImplicitFieldUnsafe<TSchema extends Unenforced<ImplicitFieldSchema>> = TSchema extends FieldSchemaUnsafe<infer Kind, infer Types> ? ApplyKind<InsertableTreeNodeFromImplicitAllowedTypesUnsafe<Types>, Kind> : InsertableTreeNodeFromImplicitAllowedTypesUnsafe<TSchema>;
1010
+ export type InsertableTreeFieldFromImplicitFieldUnsafe<TSchema extends Unenforced<ImplicitFieldSchema>> = TSchema extends FieldSchemaUnsafe<infer Kind, infer Types> ? ApplyKind<InsertableTreeNodeFromImplicitAllowedTypesUnsafe<Types>, Kind, true> : InsertableTreeNodeFromImplicitAllowedTypesUnsafe<TSchema>;
1005
1011
 
1006
1012
  // @public
1007
1013
  export type InsertableTreeNodeFromImplicitAllowedTypes<TSchema extends ImplicitAllowedTypes = TreeNodeSchema> = TSchema extends TreeNodeSchema ? InsertableTypedNode<TSchema> : TSchema extends AllowedTypes ? InsertableTypedNode<FlexListToUnion<TSchema>> : never;
@@ -1077,7 +1083,7 @@ export interface ITransaction {
1077
1083
  }
1078
1084
 
1079
1085
  // @public
1080
- export interface ITree extends IChannel {
1086
+ export interface ITree extends IFluidLoadable {
1081
1087
  schematize<TRoot extends ImplicitFieldSchema>(config: TreeConfiguration<TRoot>): TreeView<TRoot>;
1082
1088
  }
1083
1089
 
@@ -1102,6 +1108,11 @@ export interface ITreeCheckoutFork extends ITreeCheckout, IDisposable {
1102
1108
  rebaseOnto(view: ITreeCheckout): void;
1103
1109
  }
1104
1110
 
1111
+ // @public
1112
+ export interface ITreeConfigurationOptions {
1113
+ enableSchemaValidation?: boolean;
1114
+ }
1115
+
1105
1116
  // @internal
1106
1117
  export interface ITreeCursor {
1107
1118
  readonly [CursorMarker]: true;
@@ -1313,13 +1324,6 @@ export interface NodeInDocumentConstraint {
1313
1324
  type: "nodeInDocument";
1314
1325
  }
1315
1326
 
1316
- // @internal
1317
- export const nodeKeyFieldKey = "__n_id__";
1318
-
1319
- // @internal (undocumented)
1320
- export interface NodeKeyFieldKind extends FlexFieldKind<"NodeKey", Multiplicity.Single> {
1321
- }
1322
-
1323
1327
  // @internal
1324
1328
  export interface NodeKeyManager {
1325
1329
  generateLocalNodeKey(): LocalNodeKey;
@@ -1482,7 +1486,7 @@ export const reservedObjectNodeFieldPropertyNamePrefixes: readonly ["set", "boxe
1482
1486
  export type ReservedObjectNodeFieldPropertyNames = (typeof reservedObjectNodeFieldPropertyNames)[number];
1483
1487
 
1484
1488
  // @internal
1485
- export const reservedObjectNodeFieldPropertyNames: readonly ["anchorNode", "constructor", "context", "is", "on", "parentField", "schema", "treeStatus", "tryGetField", "type", "value", "localNodeKey", "boxedIterator", "iterator", "getBoxed"];
1489
+ export const reservedObjectNodeFieldPropertyNames: readonly ["anchorNode", "constructor", "context", "is", "on", "parentField", "schema", "treeStatus", "tryGetField", "type", "value", "boxedIterator", "iterator", "getBoxed"];
1486
1490
 
1487
1491
  // @public
1488
1492
  export type RestrictiveReadonlyRecord<K extends symbol | string, T> = {
@@ -1601,8 +1605,8 @@ export class SchemaFactory<out TScope extends string | undefined = string | unde
1601
1605
  [Symbol.iterator](): Iterator<InsertableTreeNodeFromImplicitAllowedTypesUnsafe<T>>;
1602
1606
  }, false, T>;
1603
1607
  readonly boolean: TreeNodeSchema<"com.fluidframework.leaf.boolean", NodeKind.Leaf, boolean, boolean>;
1604
- readonly handle: TreeNodeSchema<"com.fluidframework.leaf.handle", NodeKind.Leaf, IFluidHandle<FluidObject & IFluidLoadable>, IFluidHandle<FluidObject & IFluidLoadable>>;
1605
- get identifier(): FieldSchema<FieldKind.Identifier>;
1608
+ readonly handle: TreeNodeSchema<"com.fluidframework.leaf.handle", NodeKind.Leaf, IFluidHandle<unknown>, IFluidHandle<unknown>>;
1609
+ get identifier(): FieldSchema<FieldKind.Identifier, typeof SchemaFactory.string>;
1606
1610
  map<const T extends TreeNodeSchema | readonly TreeNodeSchema[]>(allowedTypes: T): TreeNodeSchema<ScopedSchemaName<TScope, `Map<${string}>`>, NodeKind.Map, TreeMapNode<T> & WithType<ScopedSchemaName<TScope, `Map<${string}>`>>, Iterable<[string, InsertableTreeNodeFromImplicitAllowedTypes<T>]>, true, T>;
1607
1611
  map<Name extends TName, const T extends ImplicitAllowedTypes>(name: Name, allowedTypes: T): TreeNodeSchemaClass<ScopedSchemaName<TScope, Name>, NodeKind.Map, TreeMapNode<T> & WithType<ScopedSchemaName<TScope, Name>>, Iterable<[string, InsertableTreeNodeFromImplicitAllowedTypes<T>]>, true, T>;
1608
1612
  mapRecursive<Name extends TName, const T extends Unenforced<ImplicitAllowedTypes>>(name: Name, allowedTypes: T): TreeNodeSchemaClass<ScopedSchemaName<TScope, Name>, NodeKind.Map, TreeMapNodeUnsafe<T> & WithType<ScopedSchemaName<TScope, Name>>, {
@@ -1615,10 +1619,10 @@ export class SchemaFactory<out TScope extends string | undefined = string | unde
1615
1619
  readonly number: TreeNodeSchema<"com.fluidframework.leaf.number", NodeKind.Leaf, number, number>;
1616
1620
  object<const Name extends TName, const T extends RestrictiveReadonlyRecord<string, ImplicitFieldSchema>>(name: Name, fields: T): TreeNodeSchemaClass<ScopedSchemaName<TScope, Name>, NodeKind.Object, TreeObjectNode<T, ScopedSchemaName<TScope, Name>>, object & InsertableObjectFromSchemaRecord<T>, true, T>;
1617
1621
  objectRecursive<const Name extends TName, const T extends Unenforced<RestrictiveReadonlyRecord<string, ImplicitFieldSchema>>>(name: Name, t: T): TreeNodeSchemaClass<ScopedSchemaName<TScope, Name>, NodeKind.Object, TreeObjectNodeUnsafe<T, ScopedSchemaName<TScope, Name>>, object & InsertableObjectFromSchemaRecordUnsafe<T>, false, T>;
1618
- optional<const T extends ImplicitAllowedTypes>(t: T, props?: FieldProps): FieldSchema<FieldKind.Optional, T>;
1619
- optionalRecursive<const T extends Unenforced<ImplicitAllowedTypes>>(t: T, props?: FieldProps): FieldSchemaUnsafe<FieldKind.Optional, T>;
1620
- required<const T extends ImplicitAllowedTypes>(t: T, props?: FieldProps): FieldSchema<FieldKind.Required, T>;
1621
- requiredRecursive<const T extends Unenforced<ImplicitAllowedTypes>>(t: T, props?: FieldProps): FieldSchemaUnsafe<FieldKind.Required, T>;
1622
+ optional<const T extends ImplicitAllowedTypes>(t: T, props?: Omit<FieldProps, "defaultProvider">): FieldSchema<FieldKind.Optional, T>;
1623
+ optionalRecursive<const T extends Unenforced<ImplicitAllowedTypes>>(t: T, props?: Omit<FieldProps, "defaultProvider">): FieldSchemaUnsafe<FieldKind.Optional, T>;
1624
+ required<const T extends ImplicitAllowedTypes>(t: T, props?: Omit<FieldProps, "defaultProvider">): FieldSchema<FieldKind.Required, T>;
1625
+ requiredRecursive<const T extends Unenforced<ImplicitAllowedTypes>>(t: T, props?: Omit<FieldProps, "defaultProvider">): FieldSchemaUnsafe<FieldKind.Required, T>;
1622
1626
  // (undocumented)
1623
1627
  readonly scope: TScope;
1624
1628
  readonly string: TreeNodeSchema<"com.fluidframework.leaf.string", NodeKind.Leaf, string, string>;
@@ -1665,6 +1669,7 @@ export interface SchemaLintConfiguration {
1665
1669
  // @internal
1666
1670
  export interface SchemaPolicy {
1667
1671
  readonly fieldKinds: ReadonlyMap<FieldKindIdentifier, FieldKindData>;
1672
+ readonly validateSchema: boolean;
1668
1673
  }
1669
1674
 
1670
1675
  // @internal
@@ -1692,8 +1697,8 @@ export interface SequenceFieldEditBuilder {
1692
1697
  remove(index: number, count: number): void;
1693
1698
  }
1694
1699
 
1695
- // @public
1696
- export const SharedTree: ISharedObjectKind<ITree>;
1700
+ // @alpha
1701
+ export const SharedTree: ISharedObjectKind<ITree> & SharedObjectKind<ITree>;
1697
1702
 
1698
1703
  // @internal
1699
1704
  export interface SharedTreeContentSnapshot {
@@ -1845,9 +1850,10 @@ export enum TreeCompressionStrategy {
1845
1850
 
1846
1851
  // @public
1847
1852
  export class TreeConfiguration<TSchema extends ImplicitFieldSchema = ImplicitFieldSchema> {
1848
- constructor(schema: TSchema, initialTree: () => InsertableTreeFieldFromImplicitField<TSchema>);
1853
+ constructor(schema: TSchema, initialTree: () => InsertableTreeFieldFromImplicitField<TSchema>, options?: ITreeConfigurationOptions);
1849
1854
  // (undocumented)
1850
1855
  readonly initialTree: () => InsertableTreeFieldFromImplicitField<TSchema>;
1856
+ readonly options: Required<ITreeConfigurationOptions>;
1851
1857
  // (undocumented)
1852
1858
  readonly schema: TSchema;
1853
1859
  }
@@ -1864,10 +1870,10 @@ export interface TreeDataContext {
1864
1870
  }
1865
1871
 
1866
1872
  // @public
1867
- export type TreeFieldFromImplicitField<TSchema extends ImplicitFieldSchema = FieldSchema> = TSchema extends FieldSchema<infer Kind, infer Types> ? ApplyKind<TreeNodeFromImplicitAllowedTypes<Types>, Kind> : TSchema extends ImplicitAllowedTypes ? TreeNodeFromImplicitAllowedTypes<TSchema> : unknown;
1873
+ export type TreeFieldFromImplicitField<TSchema extends ImplicitFieldSchema = FieldSchema> = TSchema extends FieldSchema<infer Kind, infer Types> ? ApplyKind<TreeNodeFromImplicitAllowedTypes<Types>, Kind, false> : TSchema extends ImplicitAllowedTypes ? TreeNodeFromImplicitAllowedTypes<TSchema> : unknown;
1868
1874
 
1869
1875
  // @public
1870
- export type TreeFieldFromImplicitFieldUnsafe<TSchema extends Unenforced<ImplicitFieldSchema>> = TSchema extends FieldSchemaUnsafe<infer Kind, infer Types> ? ApplyKind<TreeNodeFromImplicitAllowedTypesUnsafe<Types>, Kind> : TSchema extends ImplicitAllowedTypes ? TreeNodeFromImplicitAllowedTypesUnsafe<TSchema> : unknown;
1876
+ export type TreeFieldFromImplicitFieldUnsafe<TSchema extends Unenforced<ImplicitFieldSchema>> = TSchema extends FieldSchemaUnsafe<infer Kind, infer Types> ? ApplyKind<TreeNodeFromImplicitAllowedTypesUnsafe<Types>, Kind, false> : TSchema extends ImplicitAllowedTypes ? TreeNodeFromImplicitAllowedTypesUnsafe<TSchema> : unknown;
1871
1877
 
1872
1878
  // @internal
1873
1879
  export interface TreeFieldStoredSchema {
@@ -1890,7 +1896,11 @@ export interface TreeLocation {
1890
1896
  // @public
1891
1897
  export interface TreeMapNode<T extends ImplicitAllowedTypes = ImplicitAllowedTypes> extends ReadonlyMap<string, TreeNodeFromImplicitAllowedTypes<T>>, TreeNode {
1892
1898
  delete(key: string): void;
1899
+ entries(): IterableIterator<[string, TreeNodeFromImplicitAllowedTypes<T>]>;
1900
+ forEach(callbackfn: (value: TreeNodeFromImplicitAllowedTypes<T>, key: string, map: ReadonlyMap<string, TreeNodeFromImplicitAllowedTypes<T>>) => void, thisArg?: any): void;
1901
+ keys(): IterableIterator<string>;
1893
1902
  set(key: string, value: InsertableTreeNodeFromImplicitAllowedTypes<T> | undefined): void;
1903
+ values(): IterableIterator<TreeNodeFromImplicitAllowedTypes<T>>;
1894
1904
  }
1895
1905
 
1896
1906
  // @public
@@ -1914,7 +1924,7 @@ export abstract class TreeNode implements WithType {
1914
1924
 
1915
1925
  // @public
1916
1926
  export interface TreeNodeApi {
1917
- is<TSchema extends TreeNodeSchema>(value: unknown, schema: TSchema): value is NodeFromSchema<TSchema>;
1927
+ is<TSchema extends ImplicitAllowedTypes>(value: unknown, schema: TSchema): value is TreeNodeFromImplicitAllowedTypes<TSchema>;
1918
1928
  key(node: TreeNode): string | number;
1919
1929
  on<K extends keyof TreeChangeEvents>(node: TreeNode, eventName: K, listener: TreeChangeEvents[K]): () => void;
1920
1930
  parent(node: TreeNode): TreeNode | undefined;
package/dist/beta.d.ts CHANGED
@@ -14,6 +14,7 @@ export {
14
14
  ApplyKind,
15
15
  CommitKind,
16
16
  CommitMetadata,
17
+ DefaultProvider,
17
18
  Events,
18
19
  ExtractItemType,
19
20
  FieldKind,
@@ -25,6 +26,7 @@ export {
25
26
  IDisposable,
26
27
  ISubscribable,
27
28
  ITree,
29
+ ITreeConfigurationOptions,
28
30
  ImplicitAllowedTypes,
29
31
  ImplicitFieldSchema,
30
32
  InsertableObjectFromSchemaRecord,
@@ -56,7 +58,6 @@ export {
56
58
  SchemaFactory,
57
59
  SchemaIncompatible,
58
60
  ScopedSchemaName,
59
- SharedTree,
60
61
  TransactionConstraint,
61
62
  Tree,
62
63
  TreeApi,
@@ -174,7 +174,7 @@ export declare function ensureBinaryEncoding<TDecoded, TContext>(codec: IMultiFo
174
174
  /**
175
175
  * Codec for objects which carry no information.
176
176
  */
177
- export declare const unitCodec: IMultiFormatCodec<0, JsonCompatibleReadOnly, JsonCompatibleReadOnly, any>;
177
+ export declare const unitCodec: IMultiFormatCodec<0, JsonCompatibleReadOnly, JsonCompatibleReadOnly, unknown>;
178
178
  /**
179
179
  * Wraps a codec with JSON schema validation for its encoded type.
180
180
  * @returns An {@link IJsonCodec} which validates the data it encodes and decodes matches the provided schema.
@@ -1 +1 @@
1
- {"version":3,"file":"codec.d.ts","sourceRoot":"","sources":["../../src/codec/codec.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,SAAS,EAAkB,MAAM,8BAA8B,CAAC;AAEzE,OAAO,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAErE,OAAO,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,C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AC,KAAK,CAAC,OAAO,CAAC,EAAE;gBACnC,IAAA,eAAI,EAAC,gCAAgC,CAAC,CAAC;aACvC;YACD,OAAO,OAAO,CAAC;QAChB,CAAC;QACD,MAAM,EAAE,CAAC,OAAkB,EAAE,OAAiB,EAAE,EAAE;YACjD,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE;gBACnC,IAAA,eAAI,EAAC,gCAAgC,CAAC,CAAC;aACvC;YACD,2GAA2G;YAC3G,OAAO,KAAK,CAAC,MAAM,CAAC,OAAO,EAAE,OAAO,CAA+B,CAAC;QACrE,CAAC;KACD,CAAC;AACH,CAAC;AA/BD,oDA+BC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IsoBuffer, bufferToString } from \"@fluid-internal/client-utils\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport type { Static, TAnySchema, TSchema } from \"@sinclair/typebox\";\n\nimport { ChangeEncodingContext } from \"../core/index.js\";\nimport { JsonCompatibleReadOnly, fail } from \"../util/index.js\";\n\n/**\n * Translates decoded data to encoded data.\n * @remarks Typically paired with an {@link IEncoder}.\n */\nexport interface IEncoder<TDecoded, TEncoded, TContext> {\n\t/**\n\t * Encodes `obj` into some encoded format.\n\t */\n\tencode(obj: TDecoded, context: TContext): TEncoded;\n}\n\n/**\n * Translates encoded data to decoded data.\n * @remarks Typically paired with an {@link IEncoder}.\n */\nexport interface IDecoder<TDecoded, TEncoded, TContext> {\n\t/**\n\t * Decodes `obj` from some encoded format.\n\t */\n\tdecode(obj: TEncoded, context: TContext): TDecoded;\n}\n\n/**\n * Validates data complies with some particular schema.\n * Implementations are typically created by a {@link JsonValidator}.\n * @internal\n */\nexport interface SchemaValidationFunction<Schema extends TSchema> {\n\t/**\n\t * @returns Whether the data matches a schema.\n\t */\n\tcheck(data: unknown): data is Static<Schema>;\n}\n\n/**\n * JSON schema validator compliant with draft 6 schema. See https://json-schema.org.\n * @internal\n */\nexport interface JsonValidator {\n\t/**\n\t * Compiles the provided JSON schema into a validator for that schema.\n\t * @param schema - A valid draft 6 JSON schema\n\t * @remarks IFluidHandles--which have circular property references--are used in various places in SharedTree's persisted\n\t * format. Handles should only be contained in sections of data which are validated against the empty schema `{}`\n\t * (see https://datatracker.ietf.org/doc/html/draft-wright-json-schema-01#section-4.4).\n\t *\n\t * Implementations of `JsonValidator` must therefore tolerate these values, despite the input not being valid JSON.\n\t */\n\tcompile<Schema extends TSchema>(schema: Schema): SchemaValidationFunction<Schema>;\n}\n\n/**\n * Options relating to handling of persisted data.\n * @internal\n */\nexport interface ICodecOptions {\n\t/**\n\t * {@link JsonValidator} which SharedTree uses to validate persisted data it reads & writes\n\t * matches the expected encoded format (i.e. the wire format for ops and summaries).\n\t *\n\t * See {@link noopValidator} and {@link typeboxValidator} for out-of-the-box implementations.\n\t *\n\t * This option is not \"on-by-default\" because JSON schema validation comes with a small but noticeable\n\t * runtime performance cost, and popular schema validation libraries have relatively large bundle size.\n\t *\n\t * SharedTree users are still encouraged to use a non-trivial validator (i.e. not `noopValidator`)\n\t * whenever reasonable: it gives better fail-fast behavior when unexpected encoded data is found,\n\t * which reduces the risk of unrecoverable data corruption.\n\t */\n\treadonly jsonValidator: JsonValidator;\n}\n\n/**\n * `TContext` allows passing context to the codec which may configure how data is encoded/decoded.\n * This parameter is typically used for:\n * - Codecs which can pick from multiple encoding options, and imbue the encoded data with information about which option was used.\n * The caller of such a codec can provide context about which encoding choice to make as part of the `encode` call without creating\n * additional codecs. Note that this pattern can always be implemented by having the caller create multiple codecs and selecting the\n * appropriate one, but depending on API layering this might be less ergonomic.\n * - Context for the object currently being encoded, which might enable more efficient encoding. When used in this fashion, the codec author\n * should be careful to include the context somewhere in the encoded data such that decoding can correctly round-trip.\n * For example, a composed set of codecs could implement a form of [dictionary coding](https://en.wikipedia.org/wiki/Dictionary_coder)\n * using a context map which was created by the top-level codec and passed to the inner codecs.\n * This pattern is used:\n * - To avoid repeatedly encoding session ids on commits (only recording it once at the top level)\n * @remarks `TEncoded` should always be valid Json (i.e. not contain functions), but due to TypeScript's handling\n * of index signatures and `JsonCompatibleReadOnly`'s index signature in the Json object case, specifying this as a\n * type-system level constraint makes code that uses this interface more difficult to write.\n *\n * If provided, `TValidate` allows the input type passed to `decode` to be different than `TEncoded`.\n * This is useful when, for example, the type being decoded is `unknown` and must be validated to be a `TEncoded` before being decoded to a `TDecoded`.\n */\nexport interface IJsonCodec<\n\tTDecoded,\n\tTEncoded = JsonCompatibleReadOnly,\n\tTValidate = TEncoded,\n\tTContext = void,\n> extends IEncoder<TDecoded, TEncoded, TContext>,\n\t\tIDecoder<TDecoded, TValidate, TContext> {\n\tencodedSchema?: TAnySchema;\n}\n\n/**\n * @remarks TODO: We might consider using DataView or some kind of writer instead of IsoBuffer.\n */\nexport interface IBinaryCodec<TDecoded, TContext = void>\n\textends IEncoder<TDecoded, IsoBuffer, TContext>,\n\t\tIDecoder<TDecoded, IsoBuffer, TContext> {}\n\n/**\n * Contains knowledge of how to encode some in-memory type into JSON and binary formats,\n * as well as how to decode those representations.\n *\n * @remarks Codecs are typically used in shared-tree to convert data into some persisted format.\n * For this common use case, any format for encoding that was ever actually used needs to\n * be supported for decoding in all future code versions.\n *\n * Using an {@link ICodecFamily} is the recommended strategy for managing this support, keeping in\n * mind evolution of encodings over time.\n */\nexport interface IMultiFormatCodec<\n\tTDecoded,\n\tTJsonEncoded extends JsonCompatibleReadOnly = JsonCompatibleReadOnly,\n\tTJsonValidate = TJsonEncoded,\n\tTContext = void,\n> {\n\tjson: IJsonCodec<TDecoded, TJsonEncoded, TJsonValidate, TContext>;\n\tbinary: IBinaryCodec<TDecoded, TContext>;\n\n\t/** Ensures multi-format codecs cannot also be single-format codecs. */\n\tencode?: never;\n\t/** Ensures multi-format codecs cannot also be single-format codecs. */\n\tdecode?: never;\n}\n\n/**\n * Represents a family of codecs that can be used to encode and decode data in different formats.\n * The family is identified by a format version, which is typically used to select the codec to use.\n *\n * Separating codecs into families rather than having a single codec support multiple versions (i.e. currying\n * the `formatVersion` parameter)\n * allows avoiding some duplicate work at encode/decode time, since the vast majority of document usage will not\n * involve mixed format versions.\n *\n * @privateRemarks - This interface currently assumes all codecs in a family require the same encode/decode context,\n * which isn't necessarily true.\n * This may need to be relaxed in the future.\n */\nexport interface ICodecFamily<TDecoded, TContext = void> {\n\t/**\n\t * @returns a codec that can be used to encode and decode data in the specified format.\n\t * @throws - if the format version is not supported by this family.\n\t * @remarks Implementations should typically emit telemetry (either indirectly by throwing a well-known error with\n\t * logged properties or directly using some logger) when a format version is requested that is not supported.\n\t * This ensures that applications can diagnose compatibility issues.\n\t */\n\tresolve(\n\t\tformatVersion: FormatVersion,\n\t): IMultiFormatCodec<TDecoded, JsonCompatibleReadOnly, JsonCompatibleReadOnly, TContext>;\n\n\t/**\n\t * @returns an iterable of all format versions supported by this family.\n\t */\n\tgetSupportedFormats(): Iterable<FormatVersion>;\n}\n\n/**\n * A version stamp for encoded data.\n *\n * Undefined is tolerated to enable the scenario where data was not initially versioned.\n */\nexport type FormatVersion = number | undefined;\n\n/**\n * Creates a codec family from a registry of codecs.\n * Any codec that is not a {@link IMultiFormatCodec} will be wrapped with a default binary encoding.\n */\nexport function makeCodecFamily<TDecoded, TContext>(\n\tregistry: Iterable<\n\t\t[\n\t\t\tformatVersion: FormatVersion,\n\t\t\tcodec:\n\t\t\t\t| IMultiFormatCodec<\n\t\t\t\t\t\tTDecoded,\n\t\t\t\t\t\tJsonCompatibleReadOnly,\n\t\t\t\t\t\tJsonCompatibleReadOnly,\n\t\t\t\t\t\tTContext\n\t\t\t\t >\n\t\t\t\t| IJsonCodec<TDecoded, JsonCompatibleReadOnly, JsonCompatibleReadOnly, TContext>,\n\t\t]\n\t>,\n): ICodecFamily<TDecoded, TContext> {\n\tconst codecs: Map<\n\t\tFormatVersion,\n\t\tIMultiFormatCodec<TDecoded, JsonCompatibleReadOnly, JsonCompatibleReadOnly, TContext>\n\t> = new Map();\n\tfor (const [formatVersion, codec] of registry) {\n\t\tif (codecs.has(formatVersion)) {\n\t\t\tfail(\"Duplicate codecs specified.\");\n\t\t}\n\t\tcodecs.set(formatVersion, ensureBinaryEncoding(codec));\n\t}\n\n\treturn {\n\t\tresolve(formatVersion: number) {\n\t\t\tconst codec = codecs.get(formatVersion);\n\t\t\tassert(codec !== undefined, 0x5e6 /* Requested coded for unsupported format. */);\n\t\t\treturn codec;\n\t\t},\n\t\tgetSupportedFormats() {\n\t\t\treturn codecs.keys();\n\t\t},\n\t};\n}\n\nclass DefaultBinaryCodec<TDecoded, TContext> implements IBinaryCodec<TDecoded, TContext> {\n\tpublic constructor(\n\t\tprivate readonly jsonCodec: IJsonCodec<TDecoded, unknown, unknown, TContext>,\n\t) {}\n\n\tpublic encode(change: TDecoded, context: TContext): IsoBuffer {\n\t\tconst jsonable = this.jsonCodec.encode(change, context);\n\t\tconst json = JSON.stringify(jsonable);\n\t\treturn IsoBuffer.from(json);\n\t}\n\n\tpublic decode(change: IsoBuffer, context: TContext): TDecoded {\n\t\tconst json = bufferToString(change, \"utf8\");\n\t\tconst jsonable = JSON.parse(json);\n\t\treturn this.jsonCodec.decode(jsonable, context);\n\t}\n}\n\nfunction isJsonCodec<TDecoded, TContext>(\n\tcodec:\n\t\t| IMultiFormatCodec<TDecoded, JsonCompatibleReadOnly, JsonCompatibleReadOnly, TContext>\n\t\t| IJsonCodec<TDecoded, JsonCompatibleReadOnly, JsonCompatibleReadOnly, TContext>,\n): codec is IJsonCodec<TDecoded, JsonCompatibleReadOnly, JsonCompatibleReadOnly, TContext> {\n\treturn typeof codec.encode === \"function\" && typeof codec.decode === \"function\";\n}\n\n/**\n * Constructs a {@link IMultiFormatCodec} from a `IJsonCodec` using a generic binary encoding that simply writes\n * the json representation of the object to a buffer.\n */\nexport function withDefaultBinaryEncoding<TDecoded, TContext>(\n\tjsonCodec: IJsonCodec<TDecoded, JsonCompatibleReadOnly, JsonCompatibleReadOnly, TContext>,\n): IMultiFormatCodec<TDecoded, JsonCompatibleReadOnly, JsonCompatibleReadOnly, TContext> {\n\treturn {\n\t\tjson: jsonCodec,\n\t\tbinary: new DefaultBinaryCodec(jsonCodec),\n\t};\n}\n\n/**\n * Ensures that the provided single or multi-format codec has a binary encoding.\n * Adapts the json encoding using {@link withDefaultBinaryEncoding} if necessary.\n */\nexport function ensureBinaryEncoding<TDecoded, TContext>(\n\tcodec:\n\t\t| IMultiFormatCodec<TDecoded, JsonCompatibleReadOnly, JsonCompatibleReadOnly, TContext>\n\t\t| IJsonCodec<TDecoded, JsonCompatibleReadOnly, JsonCompatibleReadOnly, TContext>,\n): IMultiFormatCodec<TDecoded, JsonCompatibleReadOnly, JsonCompatibleReadOnly, TContext> {\n\treturn isJsonCodec(codec) ? withDefaultBinaryEncoding(codec) : codec;\n}\n\n/**\n * Codec for objects which carry no information.\n */\nexport const unitCodec: IMultiFormatCodec<0, JsonCompatibleReadOnly, JsonCompatibleReadOnly, any> =\n\t{\n\t\tjson: {\n\t\t\tencode: () => 0,\n\t\t\tdecode: () => 0,\n\t\t},\n\t\tbinary: {\n\t\t\tencode: () => IsoBuffer.from(\"\"),\n\t\t\tdecode: () => 0,\n\t\t},\n\t};\n\n/**\n * Wraps a codec with JSON schema validation for its encoded type.\n * @returns An {@link IJsonCodec} which validates the data it encodes and decodes matches the provided schema.\n */\nexport function withSchemaValidation<\n\tTInMemoryFormat,\n\tEncodedSchema extends TSchema,\n\tTEncodedFormat = JsonCompatibleReadOnly,\n\tTValidate = TEncodedFormat,\n\tTContext = ChangeEncodingContext,\n>(\n\tschema: EncodedSchema,\n\tcodec: IJsonCodec<TInMemoryFormat, TEncodedFormat, TValidate, TContext>,\n\tvalidator?: JsonValidator,\n): IJsonCodec<TInMemoryFormat, TEncodedFormat, TValidate, TContext> {\n\tif (!validator) {\n\t\treturn codec;\n\t}\n\tconst compiledFormat = validator.compile(schema);\n\treturn {\n\t\tencode: (obj: TInMemoryFormat, context: TContext) => {\n\t\t\tconst encoded = codec.encode(obj, context);\n\t\t\tif (!compiledFormat.check(encoded)) {\n\t\t\t\tfail(\"Encoded schema should validate\");\n\t\t\t}\n\t\t\treturn encoded;\n\t\t},\n\t\tdecode: (encoded: TValidate, context: TContext) => {\n\t\t\tif (!compiledFormat.check(encoded)) {\n\t\t\t\tfail(\"Encoded schema should validate\");\n\t\t\t}\n\t\t\t// TODO: would be nice to provide a more specific validate type to the inner codec than the outer one gets.\n\t\t\treturn codec.decode(encoded, context) as unknown as TInMemoryFormat;\n\t\t},\n\t};\n}\n"]}
1
+ {"version":3,"file":"codec.js","sourceRoot":"","sources":["../../src/codec/codec.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAAyE;AACzE,kEAA6D;AAI7D,+CAAgE;AA+KhE;;;GAGG;AACH,SAAgB,eAAe,CAC9B,QAYC;IAED,MAAM,MAAM,GAGR,IAAI,GAAG,EAAE,CAAC;IACd,KAAK,MAAM,CAAC,aAAa,EAAE,KAAK,CAAC,IAAI,QAAQ,EAAE,CAAC;QAC/C,IAAI,MAAM,CAAC,GAAG,CAAC,aAAa,CAAC,EAAE,CAAC;YAC/B,IAAA,eAAI,EAAC,6BAA6B,CAAC,CAAC;QACrC,CAAC;QACD,MAAM,CAAC,GAAG,CAAC,aAAa,EAAE,oBAAoB,CAAC,KAAK,CAAC,CAAC,CAAC;IACxD,CAAC;IAED,OAAO;QACN,OAAO,CACN,aAAqB;YAErB,MAAM,KAAK,GAAG,MAAM,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;YACxC,IAAA,iBAAM,EAAC,KAAK,KAAK,SAAS,EAAE,KAAK,CAAC,6CAA6C,CAAC,CAAC;YACjF,OAAO,KAAK,CAAC;QACd,CAAC;QACD,mBAAmB;YAClB,OAAO,MAAM,CAAC,IAAI,EAAE,CAAC;QACtB,CAAC;KACD,CAAC;AACH,CAAC;AAtCD,0CAsCC;AAED,MAAM,kBAAkB;IACvB,YACkB,SAA2D;QAA3D,cAAS,G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EAAE,GAAG,EAAE,CAAC,wBAAS,CAAC,IAAI,CAAC,EAAE,CAAC;QAChC,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC;KACf;CACD,CAAC;AAEF;;;GAGG;AACH,SAAgB,oBAAoB,CAOnC,MAAqB,EACrB,KAAuE,EACvE,SAAyB;IAEzB,IAAI,CAAC,SAAS,EAAE,CAAC;QAChB,OAAO,KAAK,CAAC;IACd,CAAC;IACD,MAAM,cAAc,GAAG,SAAS,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IACjD,OAAO;QACN,MAAM,EAAE,CAAC,GAAoB,EAAE,OAAiB,EAAkB,EAAE;YACnE,MAAM,OAAO,GAAG,KAAK,CAAC,MAAM,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;YAC3C,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,CAAC;gBACpC,IAAA,eAAI,EAAC,gCAAgC,CAAC,CAAC;YACxC,CAAC;YACD,OAAO,OAAO,CAAC;QAChB,CAAC;QACD,MAAM,EAAE,CAAC,OAAkB,EAAE,OAAiB,EAAmB,EAAE;YAClE,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,CAAC;gBACpC,IAAA,eAAI,EAAC,gCAAgC,CAAC,CAAC;YACxC,CAAC;YACD,2GAA2G;YAC3G,OAAO,KAAK,CAAC,MAAM,CAAC,OAAO,EAAE,OAAO,CAA+B,CAAC;QACrE,CAAC;KACD,CAAC;AACH,CAAC;AA/BD,oDA+BC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IsoBuffer, bufferToString } from \"@fluid-internal/client-utils\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport type { Static, TAnySchema, TSchema } from \"@sinclair/typebox\";\n\nimport { ChangeEncodingContext } from \"../core/index.js\";\nimport { JsonCompatibleReadOnly, fail } from \"../util/index.js\";\n\n/**\n * Translates decoded data to encoded data.\n * @remarks Typically paired with an {@link IEncoder}.\n */\nexport interface IEncoder<TDecoded, TEncoded, TContext> {\n\t/**\n\t * Encodes `obj` into some encoded format.\n\t */\n\tencode(obj: TDecoded, context: TContext): TEncoded;\n}\n\n/**\n * Translates encoded data to decoded data.\n * @remarks Typically paired with an {@link IEncoder}.\n */\nexport interface IDecoder<TDecoded, TEncoded, TContext> {\n\t/**\n\t * Decodes `obj` from some encoded format.\n\t */\n\tdecode(obj: TEncoded, context: TContext): TDecoded;\n}\n\n/**\n * Validates data complies with some particular schema.\n * Implementations are typically created by a {@link JsonValidator}.\n * @internal\n */\nexport interface SchemaValidationFunction<Schema extends TSchema> {\n\t/**\n\t * @returns Whether the data matches a schema.\n\t */\n\tcheck(data: unknown): data is Static<Schema>;\n}\n\n/**\n * JSON schema validator compliant with draft 6 schema. See https://json-schema.org.\n * @internal\n */\nexport interface JsonValidator {\n\t/**\n\t * Compiles the provided JSON schema into a validator for that schema.\n\t * @param schema - A valid draft 6 JSON schema\n\t * @remarks IFluidHandles--which have circular property references--are used in various places in SharedTree's persisted\n\t * format. Handles should only be contained in sections of data which are validated against the empty schema `{}`\n\t * (see https://datatracker.ietf.org/doc/html/draft-wright-json-schema-01#section-4.4).\n\t *\n\t * Implementations of `JsonValidator` must therefore tolerate these values, despite the input not being valid JSON.\n\t */\n\tcompile<Schema extends TSchema>(schema: Schema): SchemaValidationFunction<Schema>;\n}\n\n/**\n * Options relating to handling of persisted data.\n * @internal\n */\nexport interface ICodecOptions {\n\t/**\n\t * {@link JsonValidator} which SharedTree uses to validate persisted data it reads & writes\n\t * matches the expected encoded format (i.e. the wire format for ops and summaries).\n\t *\n\t * See {@link noopValidator} and {@link typeboxValidator} for out-of-the-box implementations.\n\t *\n\t * This option is not \"on-by-default\" because JSON schema validation comes with a small but noticeable\n\t * runtime performance cost, and popular schema validation libraries have relatively large bundle size.\n\t *\n\t * SharedTree users are still encouraged to use a non-trivial validator (i.e. not `noopValidator`)\n\t * whenever reasonable: it gives better fail-fast behavior when unexpected encoded data is found,\n\t * which reduces the risk of unrecoverable data corruption.\n\t */\n\treadonly jsonValidator: JsonValidator;\n}\n\n/**\n * `TContext` allows passing context to the codec which may configure how data is encoded/decoded.\n * This parameter is typically used for:\n * - Codecs which can pick from multiple encoding options, and imbue the encoded data with information about which option was used.\n * The caller of such a codec can provide context about which encoding choice to make as part of the `encode` call without creating\n * additional codecs. Note that this pattern can always be implemented by having the caller create multiple codecs and selecting the\n * appropriate one, but depending on API layering this might be less ergonomic.\n * - Context for the object currently being encoded, which might enable more efficient encoding. When used in this fashion, the codec author\n * should be careful to include the context somewhere in the encoded data such that decoding can correctly round-trip.\n * For example, a composed set of codecs could implement a form of [dictionary coding](https://en.wikipedia.org/wiki/Dictionary_coder)\n * using a context map which was created by the top-level codec and passed to the inner codecs.\n * This pattern is used:\n * - To avoid repeatedly encoding session ids on commits (only recording it once at the top level)\n * @remarks `TEncoded` should always be valid Json (i.e. not contain functions), but due to TypeScript's handling\n * of index signatures and `JsonCompatibleReadOnly`'s index signature in the Json object case, specifying this as a\n * type-system level constraint makes code that uses this interface more difficult to write.\n *\n * If provided, `TValidate` allows the input type passed to `decode` to be different than `TEncoded`.\n * This is useful when, for example, the type being decoded is `unknown` and must be validated to be a `TEncoded` before being decoded to a `TDecoded`.\n */\nexport interface IJsonCodec<\n\tTDecoded,\n\tTEncoded = JsonCompatibleReadOnly,\n\tTValidate = TEncoded,\n\tTContext = void,\n> extends IEncoder<TDecoded, TEncoded, TContext>,\n\t\tIDecoder<TDecoded, TValidate, TContext> {\n\tencodedSchema?: TAnySchema;\n}\n\n/**\n * @remarks TODO: We might consider using DataView or some kind of writer instead of IsoBuffer.\n */\nexport interface IBinaryCodec<TDecoded, TContext = void>\n\textends IEncoder<TDecoded, IsoBuffer, TContext>,\n\t\tIDecoder<TDecoded, IsoBuffer, TContext> {}\n\n/**\n * Contains knowledge of how to encode some in-memory type into JSON and binary formats,\n * as well as how to decode those representations.\n *\n * @remarks Codecs are typically used in shared-tree to convert data into some persisted format.\n * For this common use case, any format for encoding that was ever actually used needs to\n * be supported for decoding in all future code versions.\n *\n * Using an {@link ICodecFamily} is the recommended strategy for managing this support, keeping in\n * mind evolution of encodings over time.\n */\nexport interface IMultiFormatCodec<\n\tTDecoded,\n\tTJsonEncoded extends JsonCompatibleReadOnly = JsonCompatibleReadOnly,\n\tTJsonValidate = TJsonEncoded,\n\tTContext = void,\n> {\n\tjson: IJsonCodec<TDecoded, TJsonEncoded, TJsonValidate, TContext>;\n\tbinary: IBinaryCodec<TDecoded, TContext>;\n\n\t/** Ensures multi-format codecs cannot also be single-format codecs. */\n\tencode?: never;\n\t/** Ensures multi-format codecs cannot also be single-format codecs. */\n\tdecode?: never;\n}\n\n/**\n * Represents a family of codecs that can be used to encode and decode data in different formats.\n * The family is identified by a format version, which is typically used to select the codec to use.\n *\n * Separating codecs into families rather than having a single codec support multiple versions (i.e. currying\n * the `formatVersion` parameter)\n * allows avoiding some duplicate work at encode/decode time, since the vast majority of document usage will not\n * involve mixed format versions.\n *\n * @privateRemarks - This interface currently assumes all codecs in a family require the same encode/decode context,\n * which isn't necessarily true.\n * This may need to be relaxed in the future.\n */\nexport interface ICodecFamily<TDecoded, TContext = void> {\n\t/**\n\t * @returns a codec that can be used to encode and decode data in the specified format.\n\t * @throws - if the format version is not supported by this family.\n\t * @remarks Implementations should typically emit telemetry (either indirectly by throwing a well-known error with\n\t * logged properties or directly using some logger) when a format version is requested that is not supported.\n\t * This ensures that applications can diagnose compatibility issues.\n\t */\n\tresolve(\n\t\tformatVersion: FormatVersion,\n\t): IMultiFormatCodec<TDecoded, JsonCompatibleReadOnly, JsonCompatibleReadOnly, TContext>;\n\n\t/**\n\t * @returns an iterable of all format versions supported by this family.\n\t */\n\tgetSupportedFormats(): Iterable<FormatVersion>;\n}\n\n/**\n * A version stamp for encoded data.\n *\n * Undefined is tolerated to enable the scenario where data was not initially versioned.\n */\nexport type FormatVersion = number | undefined;\n\n/**\n * Creates a codec family from a registry of codecs.\n * Any codec that is not a {@link IMultiFormatCodec} will be wrapped with a default binary encoding.\n */\nexport function makeCodecFamily<TDecoded, TContext>(\n\tregistry: Iterable<\n\t\t[\n\t\t\tformatVersion: FormatVersion,\n\t\t\tcodec:\n\t\t\t\t| IMultiFormatCodec<\n\t\t\t\t\t\tTDecoded,\n\t\t\t\t\t\tJsonCompatibleReadOnly,\n\t\t\t\t\t\tJsonCompatibleReadOnly,\n\t\t\t\t\t\tTContext\n\t\t\t\t >\n\t\t\t\t| IJsonCodec<TDecoded, JsonCompatibleReadOnly, JsonCompatibleReadOnly, TContext>,\n\t\t]\n\t>,\n): ICodecFamily<TDecoded, TContext> {\n\tconst codecs: Map<\n\t\tFormatVersion,\n\t\tIMultiFormatCodec<TDecoded, JsonCompatibleReadOnly, JsonCompatibleReadOnly, TContext>\n\t> = new Map();\n\tfor (const [formatVersion, codec] of registry) {\n\t\tif (codecs.has(formatVersion)) {\n\t\t\tfail(\"Duplicate codecs specified.\");\n\t\t}\n\t\tcodecs.set(formatVersion, ensureBinaryEncoding(codec));\n\t}\n\n\treturn {\n\t\tresolve(\n\t\t\tformatVersion: number,\n\t\t): IMultiFormatCodec<TDecoded, JsonCompatibleReadOnly, JsonCompatibleReadOnly, TContext> {\n\t\t\tconst codec = codecs.get(formatVersion);\n\t\t\tassert(codec !== undefined, 0x5e6 /* Requested coded for unsupported format. */);\n\t\t\treturn codec;\n\t\t},\n\t\tgetSupportedFormats(): Iterable<FormatVersion> {\n\t\t\treturn codecs.keys();\n\t\t},\n\t};\n}\n\nclass DefaultBinaryCodec<TDecoded, TContext> implements IBinaryCodec<TDecoded, TContext> {\n\tpublic constructor(\n\t\tprivate readonly jsonCodec: IJsonCodec<TDecoded, unknown, unknown, TContext>,\n\t) {}\n\n\tpublic encode(change: TDecoded, context: TContext): IsoBuffer {\n\t\tconst jsonable = this.jsonCodec.encode(change, context);\n\t\tconst json = JSON.stringify(jsonable);\n\t\treturn IsoBuffer.from(json);\n\t}\n\n\tpublic decode(change: IsoBuffer, context: TContext): TDecoded {\n\t\tconst json = bufferToString(change, \"utf8\");\n\t\tconst jsonable = JSON.parse(json);\n\t\treturn this.jsonCodec.decode(jsonable, context);\n\t}\n}\n\nfunction isJsonCodec<TDecoded, TContext>(\n\tcodec:\n\t\t| IMultiFormatCodec<TDecoded, JsonCompatibleReadOnly, JsonCompatibleReadOnly, TContext>\n\t\t| IJsonCodec<TDecoded, JsonCompatibleReadOnly, JsonCompatibleReadOnly, TContext>,\n): codec is IJsonCodec<TDecoded, JsonCompatibleReadOnly, JsonCompatibleReadOnly, TContext> {\n\treturn typeof codec.encode === \"function\" && typeof codec.decode === \"function\";\n}\n\n/**\n * Constructs a {@link IMultiFormatCodec} from a `IJsonCodec` using a generic binary encoding that simply writes\n * the json representation of the object to a buffer.\n */\nexport function withDefaultBinaryEncoding<TDecoded, TContext>(\n\tjsonCodec: IJsonCodec<TDecoded, JsonCompatibleReadOnly, JsonCompatibleReadOnly, TContext>,\n): IMultiFormatCodec<TDecoded, JsonCompatibleReadOnly, JsonCompatibleReadOnly, TContext> {\n\treturn {\n\t\tjson: jsonCodec,\n\t\tbinary: new DefaultBinaryCodec(jsonCodec),\n\t};\n}\n\n/**\n * Ensures that the provided single or multi-format codec has a binary encoding.\n * Adapts the json encoding using {@link withDefaultBinaryEncoding} if necessary.\n */\nexport function ensureBinaryEncoding<TDecoded, TContext>(\n\tcodec:\n\t\t| IMultiFormatCodec<TDecoded, JsonCompatibleReadOnly, JsonCompatibleReadOnly, TContext>\n\t\t| IJsonCodec<TDecoded, JsonCompatibleReadOnly, JsonCompatibleReadOnly, TContext>,\n): IMultiFormatCodec<TDecoded, JsonCompatibleReadOnly, JsonCompatibleReadOnly, TContext> {\n\treturn isJsonCodec(codec) ? withDefaultBinaryEncoding(codec) : codec;\n}\n\n/**\n * Codec for objects which carry no information.\n */\nexport const unitCodec: IMultiFormatCodec<\n\t0,\n\tJsonCompatibleReadOnly,\n\tJsonCompatibleReadOnly,\n\tunknown\n> = {\n\tjson: {\n\t\tencode: () => 0,\n\t\tdecode: () => 0,\n\t},\n\tbinary: {\n\t\tencode: () => IsoBuffer.from(\"\"),\n\t\tdecode: () => 0,\n\t},\n};\n\n/**\n * Wraps a codec with JSON schema validation for its encoded type.\n * @returns An {@link IJsonCodec} which validates the data it encodes and decodes matches the provided schema.\n */\nexport function withSchemaValidation<\n\tTInMemoryFormat,\n\tEncodedSchema extends TSchema,\n\tTEncodedFormat = JsonCompatibleReadOnly,\n\tTValidate = TEncodedFormat,\n\tTContext = ChangeEncodingContext,\n>(\n\tschema: EncodedSchema,\n\tcodec: IJsonCodec<TInMemoryFormat, TEncodedFormat, TValidate, TContext>,\n\tvalidator?: JsonValidator,\n): IJsonCodec<TInMemoryFormat, TEncodedFormat, TValidate, TContext> {\n\tif (!validator) {\n\t\treturn codec;\n\t}\n\tconst compiledFormat = validator.compile(schema);\n\treturn {\n\t\tencode: (obj: TInMemoryFormat, context: TContext): TEncodedFormat => {\n\t\t\tconst encoded = codec.encode(obj, context);\n\t\t\tif (!compiledFormat.check(encoded)) {\n\t\t\t\tfail(\"Encoded schema should validate\");\n\t\t\t}\n\t\t\treturn encoded;\n\t\t},\n\t\tdecode: (encoded: TValidate, context: TContext): TInMemoryFormat => {\n\t\t\tif (!compiledFormat.check(encoded)) {\n\t\t\t\tfail(\"Encoded schema should validate\");\n\t\t\t}\n\t\t\t// TODO: would be nice to provide a more specific validate type to the inner codec than the outer one gets.\n\t\t\treturn codec.decode(encoded, context) as unknown as TInMemoryFormat;\n\t\t},\n\t};\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"discriminatedUnions.d.ts","sourceRoot":"","sources":["../../src/codec/discriminatedUnions.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAElD,OAAO,EAAE,YAAY,EAAqB,MAAM,kBAAkB,CAAC;AAEnE;;;;GAIG;AAEH;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K,KACV,OAAO;SACZ;KACD,CAAC,YAAY,CAAC;IAOT,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,KAAK,GAAG,OAAO;CAYvD"}
@@ -77,6 +77,7 @@ exports.unionOptions = {
77
77
  * ```
78
78
  * where only a single property of `EncodedOperation` is populated for a given encoded value.
79
79
  */
80
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
80
81
  class DiscriminatedUnionDispatcher {
81
82
  constructor(library) {
82
83
  this.library = (0, index_js_1.objectToMap)(library);
@@ -1 +1 @@
1
- {"version":3,"file":"discriminatedUnions.js","sourceRoot":"","sources":["../../src/codec/discriminatedUnions.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAA6D;AAG7D,+CAAmE;AAEnE;;;;GAIG;AAEH;;;;GAIG;AACU,QAAA,YAAY,GAAkB;IAC1C,oBAAoB,EAAE,KAAK;IAC3B,aAAa,EAAE,CAAC;IAChB,aAAa,EAAE,CAAC;CAChB,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsDG;AACH,MAAa,4BAA4B;IAMxC,YACC,OAOe;QAEf,IAAI,CAAC,OAAO,GAAG,IAAA,sBAAW,EACzB,OAA4E,CAC5E,CAAC;IACH,CAAC;IAEM,QAAQ,CAAC,KAAa,EAAE,GAAG,IAAW;QAC5C,MAAM,IAAI,GAAG,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;QACpC,IAAA,iBAAM,EACL,IAAI,CAAC,MAAM,KAAK,CAAC,EACjB,KAAK,CAAC,6DAA6D,CACnE,CAAC;QACF,MAAM,GAAG,GAAiB,IAAI,CAAC,CAAC,CAAiB,CAAC;QAClD,MAAM,KAAK,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC;QACzB,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,IAAA,eAAI,EAAC,mCAAmC,CAAC,CAAC;QACnF,MAAM,MAAM,GAAG,OAAO,CAAC,KAAK,EAAE,GAAG,IAAI,CAAC,CAAC;QACvC,OAAO,MAAM,CAAC;IACf,CAAC;CACD;AAjCD,oEAiCC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport { ObjectOptions } from \"@sinclair/typebox\";\n\nimport { _InlineTrick, fail, objectToMap } from \"../util/index.js\";\n\n/**\n * This module contains utilities for an encoding of a discriminated union that is efficient to validate using\n * a JSON schema validator.\n * See {@link DiscriminatedUnionDispatcher} for more information on this pattern.\n */\n\n/**\n * Options to configure a TypeBox schema as a discriminated union that is simple to validate data against.\n *\n * See {@link DiscriminatedUnionDispatcher} for more information on this pattern.\n */\nexport const unionOptions: ObjectOptions = {\n\tadditionalProperties: false,\n\tminProperties: 1,\n\tmaxProperties: 1,\n};\n\n/**\n * Applies a function to the content of a [discriminated union](https://en.wikipedia.org/wiki/Tagged_union)\n * where the function to apply depends on which value from the union it holds.\n *\n * This uses a rather non-standard encoding of the union where it is an object with many differently named optional fields,\n * and which of the fields is populated determines the content type.\n * This union encoding has the advantage that schema validation (such as that implemented by TypeBox) can validate the data efficiently.\n * Other encodings--such as using an untagged union, then tagging the content types with a marker enum--require the schema validator to disambiguate the union members.\n * Most JSON validator implementations fail to recognize the marker enum determines which component of the discriminated union the data must be,\n * and end up checking against all candidate members of the union.\n *\n * @example\n *\n * The following union:\n * ```typescript\n * type Operation = Add | Subtract | Multiply | Divide;\n *\n * interface BinaryOperation {\n * readonly left: number;\n * readonly right: number;\n * }\n *\n * interface Add extends BinaryOperation {\n * readonly type: \"add\";\n * }\n *\n * interface Subtract extends BinaryOperation {\n * readonly type: \"subtract\";\n * }\n *\n * interface Multiply extends BinaryOperation {\n * readonly type: \"multiply\";\n * }\n *\n * interface Divide extends BinaryOperation {\n * readonly type: \"divide\";\n * }\n *\n * ```\n * Would be encoded using this strategy as:\n * ```typescript\n * interface EncodedBinaryOperation {\n * readonly left: number;\n * readonly right: number;\n * }\n *\n * interface EncodedOperation {\n * add?: EncodedBinaryOperation;\n * subtract?: EncodedBinaryOperation;\n * multiply?: EncodedBinaryOperation;\n * divide?: EncodedBinaryOperation;\n * }\n * ```\n * where only a single property of `EncodedOperation` is populated for a given encoded value.\n */\nexport class DiscriminatedUnionDispatcher<TUnion extends object, TArgs extends any[], TResult> {\n\tprivate readonly library: ReadonlyMap<\n\t\tkeyof TUnion,\n\t\t(value: unknown, ...args: TArgs) => TResult\n\t>;\n\n\tpublic constructor(\n\t\tlibrary: [\n\t\t\t{\n\t\t\t\treadonly [Property in keyof TUnion]-?: (\n\t\t\t\t\tvalue: Required<TUnion>[Property],\n\t\t\t\t\t...args: TArgs\n\t\t\t\t) => TResult;\n\t\t\t},\n\t\t][_InlineTrick],\n\t) {\n\t\tthis.library = objectToMap(\n\t\t\tlibrary as Record<keyof TUnion, (value: unknown, ...args: TArgs) => TResult>,\n\t\t);\n\t}\n\n\tpublic dispatch(union: TUnion, ...args: TArgs): TResult {\n\t\tconst keys = Reflect.ownKeys(union);\n\t\tassert(\n\t\t\tkeys.length === 1,\n\t\t\t0x733 /* discriminated union type should have exactly one member */,\n\t\t);\n\t\tconst key: keyof TUnion = keys[0] as keyof TUnion;\n\t\tconst value = union[key];\n\t\tconst factory = this.library.get(key) ?? fail(\"missing function for union member\");\n\t\tconst result = factory(value, ...args);\n\t\treturn result;\n\t}\n}\n"]}
1
+ {"version":3,"file":"discriminatedUnions.js","sourceRoot":"","sources":["../../src/codec/discriminatedUnions.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAA6D;AAG7D,+CAAmE;AAEnE;;;;GAIG;AAEH;;;;GAIG;AACU,QAAA,YAAY,GAAkB;IAC1C,oBAAoB,EAAE,KAAK;IAC3B,aAAa,EAAE,CAAC;IAChB,aAAa,EAAE,CAAC;CAChB,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsDG;AACH,8DAA8D;AAC9D,MAAa,4BAA4B;IAMxC,YACC,OAOe;QAEf,IAAI,CAAC,OAAO,GAAG,IAAA,sBAAW,EACzB,OAA4E,CAC5E,CAAC;IACH,CAAC;IAEM,QAAQ,CAAC,KAAa,EAAE,GAAG,IAAW;QAC5C,MAAM,IAAI,GAAG,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;QACpC,IAAA,iBAAM,EACL,IAAI,CAAC,MAAM,KAAK,CAAC,EACjB,KAAK,CAAC,6DAA6D,CACnE,CAAC;QACF,MAAM,GAAG,GAAiB,IAAI,CAAC,CAAC,CAAiB,CAAC;QAClD,MAAM,KAAK,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC;QACzB,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,IAAA,eAAI,EAAC,mCAAmC,CAAC,CAAC;QACnF,MAAM,MAAM,GAAG,OAAO,CAAC,KAAK,EAAE,GAAG,IAAI,CAAC,CAAC;QACvC,OAAO,MAAM,CAAC;IACf,CAAC;CACD;AAjCD,oEAiCC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport { ObjectOptions } from \"@sinclair/typebox\";\n\nimport { _InlineTrick, fail, objectToMap } from \"../util/index.js\";\n\n/**\n * This module contains utilities for an encoding of a discriminated union that is efficient to validate using\n * a JSON schema validator.\n * See {@link DiscriminatedUnionDispatcher} for more information on this pattern.\n */\n\n/**\n * Options to configure a TypeBox schema as a discriminated union that is simple to validate data against.\n *\n * See {@link DiscriminatedUnionDispatcher} for more information on this pattern.\n */\nexport const unionOptions: ObjectOptions = {\n\tadditionalProperties: false,\n\tminProperties: 1,\n\tmaxProperties: 1,\n};\n\n/**\n * Applies a function to the content of a [discriminated union](https://en.wikipedia.org/wiki/Tagged_union)\n * where the function to apply depends on which value from the union it holds.\n *\n * This uses a rather non-standard encoding of the union where it is an object with many differently named optional fields,\n * and which of the fields is populated determines the content type.\n * This union encoding has the advantage that schema validation (such as that implemented by TypeBox) can validate the data efficiently.\n * Other encodings--such as using an untagged union, then tagging the content types with a marker enum--require the schema validator to disambiguate the union members.\n * Most JSON validator implementations fail to recognize the marker enum determines which component of the discriminated union the data must be,\n * and end up checking against all candidate members of the union.\n *\n * @example\n *\n * The following union:\n * ```typescript\n * type Operation = Add | Subtract | Multiply | Divide;\n *\n * interface BinaryOperation {\n * readonly left: number;\n * readonly right: number;\n * }\n *\n * interface Add extends BinaryOperation {\n * readonly type: \"add\";\n * }\n *\n * interface Subtract extends BinaryOperation {\n * readonly type: \"subtract\";\n * }\n *\n * interface Multiply extends BinaryOperation {\n * readonly type: \"multiply\";\n * }\n *\n * interface Divide extends BinaryOperation {\n * readonly type: \"divide\";\n * }\n *\n * ```\n * Would be encoded using this strategy as:\n * ```typescript\n * interface EncodedBinaryOperation {\n * readonly left: number;\n * readonly right: number;\n * }\n *\n * interface EncodedOperation {\n * add?: EncodedBinaryOperation;\n * subtract?: EncodedBinaryOperation;\n * multiply?: EncodedBinaryOperation;\n * divide?: EncodedBinaryOperation;\n * }\n * ```\n * where only a single property of `EncodedOperation` is populated for a given encoded value.\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport class DiscriminatedUnionDispatcher<TUnion extends object, TArgs extends any[], TResult> {\n\tprivate readonly library: ReadonlyMap<\n\t\tkeyof TUnion,\n\t\t(value: unknown, ...args: TArgs) => TResult\n\t>;\n\n\tpublic constructor(\n\t\tlibrary: [\n\t\t\t{\n\t\t\t\treadonly [Property in keyof TUnion]-?: (\n\t\t\t\t\tvalue: Required<TUnion>[Property],\n\t\t\t\t\t...args: TArgs\n\t\t\t\t) => TResult;\n\t\t\t},\n\t\t][_InlineTrick],\n\t) {\n\t\tthis.library = objectToMap(\n\t\t\tlibrary as Record<keyof TUnion, (value: unknown, ...args: TArgs) => TResult>,\n\t\t);\n\t}\n\n\tpublic dispatch(union: TUnion, ...args: TArgs): TResult {\n\t\tconst keys = Reflect.ownKeys(union);\n\t\tassert(\n\t\t\tkeys.length === 1,\n\t\t\t0x733 /* discriminated union type should have exactly one member */,\n\t\t);\n\t\tconst key: keyof TUnion = keys[0] as keyof TUnion;\n\t\tconst value = union[key];\n\t\tconst factory = this.library.get(key) ?? fail(\"missing function for union member\");\n\t\tconst result = factory(value, ...args);\n\t\treturn result;\n\t}\n}\n"]}
@@ -27,14 +27,13 @@ export interface ForestEvents {
27
27
  afterRootFieldCreated(key: FieldKey): void;
28
28
  /**
29
29
  * The forest is about to be changed.
30
- * Emitted before the first change in a batch of changes.
30
+ * Emitted before each change in a batch of changes.
31
+ * @remarks
32
+ * This is the last chance for users of the forest to remove cursors from the forest before the edit.
33
+ * Removing these cursors is important since they are not allowed to live across edits and
34
+ * not clearing them can lead to corruption of in memory structures.
31
35
  */
32
36
  beforeChange(): void;
33
- /**
34
- * The forest was just changed.
35
- * Emitted after the last change in a batch of changes.
36
- */
37
- afterChange(): void;
38
37
  }
39
38
  /**
40
39
  * Invalidates whenever the tree content changes.
@@ -1 +1 @@
1
- {"version":3,"file":"forest.d.ts","sourceRoot":"","sources":["../../../src/core/forest/forest.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,QAAQ,EAAE,4BAA4B,EAAE,MAAM,2BAA2B,CAAC;AACnF,OAAO,EACN,MAAM,EACN,SAAS,EACT,aAAa,EACb,WAAW,EACX,sBAAsB,EACtB,MAAM,EAGN,MAAM,kBAAkB,CAAC;AAE1B,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAE3D;;;;;;;GAOG;AAEH;;;;;GAKG;AACH,MAAM,WAAW,YAAY;IAC5B;;OAEG;IACH,qBAAq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H,IAAY,4BAaX;AAbD,WAAY,4BAA4B;IACvC;;OAEG;IACH,qFAAO,CAAA;IACP;;OAEG;IACH,qFAAO,CAAA;IACP;;OAEG;IACH,iFAAK,CAAA;AACN,CAAC,EAbW,4BAA4B,4CAA5B,4BAA4B,QAavC;AAED;;GAEG;AACH,IAAkB,oBAejB;AAfD,WAAkB,oBAAoB;IACrC;;OAEG;IACH,wEAAa,CAAA;IAEb;;OAEG;IACH,qEAAW,CAAA;IAEX;;OAEG;IACH,2DAAM,CAAA;AACP,CAAC,EAfiB,oBAAoB,oCAApB,oBAAoB,QAerC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\n\nimport { ISubscribable } from \"../../events/index.js\";\nimport { FieldKey, TreeStoredSchemaSubscription } from \"../schema-stored/index.js\";\nimport {\n\tAnchor,\n\tAnchorSet,\n\tDetachedField,\n\tITreeCursor,\n\tITreeCursorSynchronous,\n\tUpPath,\n\tdetachedFieldAsKey,\n\trootField,\n} from \"../tree/index.js\";\n\nimport type { IEditableForest } from \"./editableForest.js\";\n\n/**\n * APIs for forest designed so the implementation can be copy on write,\n * or mutate in place, and we can ensure no references are dangling into the forest to allow this.\n *\n * This results in rather manual memory management,\n * but makes it practical to provide highly optimized implementations,\n * for example WASM powered binary formats that can track reference counts and only copy when needed.\n */\n\n/**\n * Events for {@link IForestSubscription}.\n *\n * TODO: consider having before and after events per subtree instead while applying anchor (and this just shows what happens at the root).\n * @internal\n */\nexport interface ForestEvents {\n\t/**\n\t * A new root field was just created in this forest.\n\t */\n\tafterRootFieldCreated(key: FieldKey): void;\n\n\t/**\n\t * The forest is about to be changed.\n\t * Emitted before the first change in a batch of changes.\n\t */\n\tbeforeChange(): void;\n\n\t/**\n\t * The forest was just changed.\n\t * Emitted after the last change in a batch of changes.\n\t */\n\tafterChange(): void;\n}\n\n/**\n * Invalidates whenever the tree content changes.\n * For now (might change later) downloading new parts of the forest counts as a change.\n * Not invalidated when schema changes.\n *\n * When invalidating, all outstanding cursors must be freed or cleared.\n * @internal\n */\nexport interface IForestSubscription extends ISubscribable<ForestEvents> {\n\t/**\n\t * Set of anchors this forest is tracking.\n\t *\n\t * To keep these anchors usable, this AnchorSet must be updated / rebased for any changes made to the forest.\n\t * It is the responsibility of the caller of the forest-editing methods to do this, not the forest itself.\n\t * The caller performs these updates because it has more semantic knowledge about the edits, which can be needed to\n\t * update the anchors in a semantically optimal way.\n\t */\n\treadonly anchors: AnchorSet;\n\n\t/**\n\t * Create an independent copy of this forest, that uses the provided schema and anchors.\n\t *\n\t * The new copy will not invalidate observers (dependents) of the old one.\n\t */\n\tclone(schema: TreeStoredSchemaSubscription, anchors: AnchorSet): IEditableForest;\n\n\t/**\n\t * Allocates a cursor in the \"cleared\" state.\n\t */\n\tallocateCursor(): ITreeSubscriptionCursor;\n\n\t/**\n\t * Frees an Anchor, stopping tracking its position across edits.\n\t */\n\tforgetAnchor(anchor: Anchor): void;\n\n\t/**\n\t * It is an error not to free `cursorToMove` before the next edit.\n\t * Must provide a `cursorToMove` from this subscription (acquired via `allocateCursor`).\n\t */\n\ttryMoveCursorToNode(\n\t\tdestination: Anchor,\n\t\tcursorToMove: ITreeSubscriptionCursor,\n\t): TreeNavigationResult;\n\n\t/**\n\t * It is an error not to free `cursorToMove` before the next edit.\n\t * Must provide a `cursorToMove` from this subscription (acquired via `allocateCursor`).\n\t */\n\ttryMoveCursorToField(\n\t\tdestination: FieldAnchor,\n\t\tcursorToMove: ITreeSubscriptionCursor,\n\t): TreeNavigationResult;\n\n\t/**\n\t * Set `cursorToMove` to location described by path.\n\t * This is NOT a relative move: current position is discarded.\n\t * Path must point to existing node.\n\t */\n\tmoveCursorToPath(destination: UpPath, cursorToMove: ITreeSubscriptionCursor): void;\n\n\t/**\n\t * The cursor is moved to a special dummy node above the detached fields.\n\t * This dummy node can be used to read the detached fields,\n\t * but other operations (such as inspecting the dummy node's type or path) should not be relied upon.\n\t * While this method does not return an {@link ITreeSubscriptionCursor}, similar restrictions apply to its use:\n\t * the returned cursor must not used after any edits are made to the forest.\n\t */\n\tgetCursorAboveDetachedFields(): ITreeCursorSynchronous;\n\n\t/**\n\t * True if there are no nodes in the forest at all.\n\t *\n\t * @remarks\n\t * This means no nodes under any detached field, not just the special document root one.\n\t */\n\treadonly isEmpty: boolean;\n}\n\n/**\n * @param field - defaults to {@link rootField}.\n * @returns anchor to `field`.\n */\nexport function rootAnchor(field: DetachedField = rootField): FieldAnchor {\n\treturn {\n\t\tparent: undefined,\n\t\tfieldKey: detachedFieldAsKey(field),\n\t};\n}\n\n/**\n * @param field - defaults to {@link rootField}.\n * @returns anchor to `field`.\n */\nexport function moveToDetachedField(\n\tforest: IForestSubscription,\n\tcursorToMove: ITreeSubscriptionCursor,\n\tfield: DetachedField = rootField,\n): void {\n\tconst result = forest.tryMoveCursorToField(rootAnchor(field), cursorToMove);\n\tassert(\n\t\tresult === TreeNavigationResult.Ok,\n\t\t0x42d /* Navigation to detached fields should never fail */,\n\t);\n}\n\n/**\n * Anchor to a field.\n * This is structurally based on the parent, so it will move only as the parent moves.\n * @internal\n */\nexport interface FieldAnchor {\n\t/**\n\t * Node above this field.\n\t * If `undefined`, field is a detached field.\n\t */\n\tparent: Anchor | undefined;\n\tfieldKey: FieldKey;\n}\n\n/**\n * ITreeCursor supporting IForestSubscription and its changes over time.\n * @internal\n */\nexport interface ITreeSubscriptionCursor extends ITreeCursor {\n\t/**\n\t * @returns an independent copy of this cursor at the same location in the tree.\n\t */\n\tfork(): ITreeSubscriptionCursor;\n\n\t/**\n\t * Release any resources this cursor is holding onto.\n\t * After doing this, further use of this object other than reading `state` is forbidden (undefined behavior).\n\t */\n\tfree(): void;\n\n\t/**\n\t * Release any resources this cursor is holding onto.\n\t * After doing this, further use of this object other than reading `state` or passing to `tryGet`\n\t * or calling `free` is forbidden (undefined behavior).\n\t */\n\tclear(): void;\n\n\t/**\n\t * Construct an `Anchor` which the IForestSubscription will keep rebased to `current`.\n\t * Note that maintaining an Anchor has cost: free them to stop incurring that cost.\n\t *\n\t * Only valid when `mode` is `Nodes`.\n\t */\n\tbuildAnchor(): Anchor;\n\n\t/**\n\t * Construct a `FieldAnchor` which the IForestSubscription will keep rebased to `current`.\n\t * Note that maintaining an Anchor has cost: free them to stop incurring that cost.\n\t *\n\t * Only valid when `mode` is `Fields`.\n\t */\n\tbuildFieldAnchor(): FieldAnchor;\n\n\t/**\n\t * Current state.\n\t */\n\treadonly state: ITreeSubscriptionCursorState;\n\n\t/**\n\t * @returns location within parent field or range.\n\t */\n\t// TODO: maybe support this.\n\t// getParentInfo(id: NodeId): TreeLocation;\n}\n\n/**\n * @internal\n */\nexport enum ITreeSubscriptionCursorState {\n\t/**\n\t * On the current revision of the forest.\n\t */\n\tCurrent,\n\t/**\n\t * Empty, but can be reused.\n\t */\n\tCleared,\n\t/**\n\t * Freed and must not be used.\n\t */\n\tFreed,\n}\n\n/**\n * @internal\n */\nexport const enum TreeNavigationResult {\n\t/**\n\t * Attempt to navigate cursor to a key or index that is outside the client's view.\n\t */\n\tNotFound = -1,\n\n\t/**\n\t * Attempt to navigate cursor to a portion of the tree that has not yet been loaded.\n\t */\n\tPending = 0,\n\n\t/**\n\t * ITreeReader successfully navigated to the desired node.\n\t */\n\tOk = 1,\n}\n\n/**\n * TreeNavigationResult, but never \"Pending\".\n * Can be used when data is never pending.\n */\nexport type SynchronousNavigationResult = TreeNavigationResult.Ok | TreeNavigationResult.NotFound;\n"]}
1
+ {"version":3,"file":"forest.js","sourceRoot":"","sources":["../../../src/core/forest/forest.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAA6D;AAI7D,+CAS0B;AAmH1B;;;GAGG;AACH,SAAgB,UAAU,CAAC,QAAuB,oBAAS;IAC1D,OAAO;QACN,MAAM,EAAE,SAAS;QACjB,QAAQ,EAAE,IAAA,6BAAkB,EAAC,KAAK,CAAC;KACnC,CAAC;AACH,CAAC;AALD,gCAKC;AAED;;;GAGG;AACH,SAAgB,mBAAmB,CAClC,MAA2B,EAC3B,YAAqC,EACrC,QAAuB,oBAAS;IAEhC,MAAM,MAAM,GAAG,MAAM,CAAC,oBAAoB,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE,YAAY,CAAC,CAAC;IAC5E,IAAA,iBAAM,EACL,MAAM,oCAA4B,EAClC,KAAK,CAAC,qDAAqD,CAC3D,CAAC;AACH,CAAC;AAVD,kDAUC;AAmED;;GAEG;AACH,IAAY,4BAaX;AAbD,WAAY,4BAA4B;IACvC;;OAEG;IACH,qFAAO,CAAA;IACP;;OAEG;IACH,qFAAO,CAAA;IACP;;OAEG;IACH,iFAAK,CAAA;AACN,CAAC,EAbW,4BAA4B,4CAA5B,4BAA4B,QAavC;AAED;;GAEG;AACH,IAAkB,oBAejB;AAfD,WAAkB,oBAAoB;IACrC;;OAEG;IACH,wEAAa,CAAA;IAEb;;OAEG;IACH,qEAAW,CAAA;IAEX;;OAEG;IACH,2DAAM,CAAA;AACP,CAAC,EAfiB,oBAAoB,oCAApB,oBAAoB,QAerC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\n\nimport { ISubscribable } from \"../../events/index.js\";\nimport { FieldKey, TreeStoredSchemaSubscription } from \"../schema-stored/index.js\";\nimport {\n\tAnchor,\n\tAnchorSet,\n\tDetachedField,\n\tITreeCursor,\n\tITreeCursorSynchronous,\n\tUpPath,\n\tdetachedFieldAsKey,\n\trootField,\n} from \"../tree/index.js\";\n\nimport type { IEditableForest } from \"./editableForest.js\";\n\n/**\n * APIs for forest designed so the implementation can be copy on write,\n * or mutate in place, and we can ensure no references are dangling into the forest to allow this.\n *\n * This results in rather manual memory management,\n * but makes it practical to provide highly optimized implementations,\n * for example WASM powered binary formats that can track reference counts and only copy when needed.\n */\n\n/**\n * Events for {@link IForestSubscription}.\n *\n * TODO: consider having before and after events per subtree instead while applying anchor (and this just shows what happens at the root).\n * @internal\n */\nexport interface ForestEvents {\n\t/**\n\t * A new root field was just created in this forest.\n\t */\n\tafterRootFieldCreated(key: FieldKey): void;\n\n\t/**\n\t * The forest is about to be changed.\n\t * Emitted before each change in a batch of changes.\n\t * @remarks\n\t * This is the last chance for users of the forest to remove cursors from the forest before the edit.\n\t * Removing these cursors is important since they are not allowed to live across edits and\n\t * not clearing them can lead to corruption of in memory structures.\n\t */\n\tbeforeChange(): void;\n}\n\n/**\n * Invalidates whenever the tree content changes.\n * For now (might change later) downloading new parts of the forest counts as a change.\n * Not invalidated when schema changes.\n *\n * When invalidating, all outstanding cursors must be freed or cleared.\n * @internal\n */\nexport interface IForestSubscription extends ISubscribable<ForestEvents> {\n\t/**\n\t * Set of anchors this forest is tracking.\n\t *\n\t * To keep these anchors usable, this AnchorSet must be updated / rebased for any changes made to the forest.\n\t * It is the responsibility of the caller of the forest-editing methods to do this, not the forest itself.\n\t * The caller performs these updates because it has more semantic knowledge about the edits, which can be needed to\n\t * update the anchors in a semantically optimal way.\n\t */\n\treadonly anchors: AnchorSet;\n\n\t/**\n\t * Create an independent copy of this forest, that uses the provided schema and anchors.\n\t *\n\t * The new copy will not invalidate observers (dependents) of the old one.\n\t */\n\tclone(schema: TreeStoredSchemaSubscription, anchors: AnchorSet): IEditableForest;\n\n\t/**\n\t * Allocates a cursor in the \"cleared\" state.\n\t */\n\tallocateCursor(): ITreeSubscriptionCursor;\n\n\t/**\n\t * Frees an Anchor, stopping tracking its position across edits.\n\t */\n\tforgetAnchor(anchor: Anchor): void;\n\n\t/**\n\t * It is an error not to free `cursorToMove` before the next edit.\n\t * Must provide a `cursorToMove` from this subscription (acquired via `allocateCursor`).\n\t */\n\ttryMoveCursorToNode(\n\t\tdestination: Anchor,\n\t\tcursorToMove: ITreeSubscriptionCursor,\n\t): TreeNavigationResult;\n\n\t/**\n\t * It is an error not to free `cursorToMove` before the next edit.\n\t * Must provide a `cursorToMove` from this subscription (acquired via `allocateCursor`).\n\t */\n\ttryMoveCursorToField(\n\t\tdestination: FieldAnchor,\n\t\tcursorToMove: ITreeSubscriptionCursor,\n\t): TreeNavigationResult;\n\n\t/**\n\t * Set `cursorToMove` to location described by path.\n\t * This is NOT a relative move: current position is discarded.\n\t * Path must point to existing node.\n\t */\n\tmoveCursorToPath(destination: UpPath, cursorToMove: ITreeSubscriptionCursor): void;\n\n\t/**\n\t * The cursor is moved to a special dummy node above the detached fields.\n\t * This dummy node can be used to read the detached fields,\n\t * but other operations (such as inspecting the dummy node's type or path) should not be relied upon.\n\t * While this method does not return an {@link ITreeSubscriptionCursor}, similar restrictions apply to its use:\n\t * the returned cursor must not used after any edits are made to the forest.\n\t */\n\tgetCursorAboveDetachedFields(): ITreeCursorSynchronous;\n\n\t/**\n\t * True if there are no nodes in the forest at all.\n\t *\n\t * @remarks\n\t * This means no nodes under any detached field, not just the special document root one.\n\t */\n\treadonly isEmpty: boolean;\n}\n\n/**\n * @param field - defaults to {@link rootField}.\n * @returns anchor to `field`.\n */\nexport function rootAnchor(field: DetachedField = rootField): FieldAnchor {\n\treturn {\n\t\tparent: undefined,\n\t\tfieldKey: detachedFieldAsKey(field),\n\t};\n}\n\n/**\n * @param field - defaults to {@link rootField}.\n * @returns anchor to `field`.\n */\nexport function moveToDetachedField(\n\tforest: IForestSubscription,\n\tcursorToMove: ITreeSubscriptionCursor,\n\tfield: DetachedField = rootField,\n): void {\n\tconst result = forest.tryMoveCursorToField(rootAnchor(field), cursorToMove);\n\tassert(\n\t\tresult === TreeNavigationResult.Ok,\n\t\t0x42d /* Navigation to detached fields should never fail */,\n\t);\n}\n\n/**\n * Anchor to a field.\n * This is structurally based on the parent, so it will move only as the parent moves.\n * @internal\n */\nexport interface FieldAnchor {\n\t/**\n\t * Node above this field.\n\t * If `undefined`, field is a detached field.\n\t */\n\tparent: Anchor | undefined;\n\tfieldKey: FieldKey;\n}\n\n/**\n * ITreeCursor supporting IForestSubscription and its changes over time.\n * @internal\n */\nexport interface ITreeSubscriptionCursor extends ITreeCursor {\n\t/**\n\t * @returns an independent copy of this cursor at the same location in the tree.\n\t */\n\tfork(): ITreeSubscriptionCursor;\n\n\t/**\n\t * Release any resources this cursor is holding onto.\n\t * After doing this, further use of this object other than reading `state` is forbidden (undefined behavior).\n\t */\n\tfree(): void;\n\n\t/**\n\t * Release any resources this cursor is holding onto.\n\t * After doing this, further use of this object other than reading `state` or passing to `tryGet`\n\t * or calling `free` is forbidden (undefined behavior).\n\t */\n\tclear(): void;\n\n\t/**\n\t * Construct an `Anchor` which the IForestSubscription will keep rebased to `current`.\n\t * Note that maintaining an Anchor has cost: free them to stop incurring that cost.\n\t *\n\t * Only valid when `mode` is `Nodes`.\n\t */\n\tbuildAnchor(): Anchor;\n\n\t/**\n\t * Construct a `FieldAnchor` which the IForestSubscription will keep rebased to `current`.\n\t * Note that maintaining an Anchor has cost: free them to stop incurring that cost.\n\t *\n\t * Only valid when `mode` is `Fields`.\n\t */\n\tbuildFieldAnchor(): FieldAnchor;\n\n\t/**\n\t * Current state.\n\t */\n\treadonly state: ITreeSubscriptionCursorState;\n\n\t/**\n\t * @returns location within parent field or range.\n\t */\n\t// TODO: maybe support this.\n\t// getParentInfo(id: NodeId): TreeLocation;\n}\n\n/**\n * @internal\n */\nexport enum ITreeSubscriptionCursorState {\n\t/**\n\t * On the current revision of the forest.\n\t */\n\tCurrent,\n\t/**\n\t * Empty, but can be reused.\n\t */\n\tCleared,\n\t/**\n\t * Freed and must not be used.\n\t */\n\tFreed,\n}\n\n/**\n * @internal\n */\nexport const enum TreeNavigationResult {\n\t/**\n\t * Attempt to navigate cursor to a key or index that is outside the client's view.\n\t */\n\tNotFound = -1,\n\n\t/**\n\t * Attempt to navigate cursor to a portion of the tree that has not yet been loaded.\n\t */\n\tPending = 0,\n\n\t/**\n\t * ITreeReader successfully navigated to the desired node.\n\t */\n\tOk = 1,\n}\n\n/**\n * TreeNavigationResult, but never \"Pending\".\n * Can be used when data is never pending.\n */\nexport type SynchronousNavigationResult = TreeNavigationResult.Ok | TreeNavigationResult.NotFound;\n"]}
@@ -6,7 +6,7 @@ export { EmptyKey, TreeType, Value, TreeValue, AnchorSet, DetachedField, UpPath,
6
6
  export { TreeNavigationResult, IEditableForest, IForestSubscription, TreeLocation, FieldLocation, ForestLocation, ITreeSubscriptionCursor, ITreeSubscriptionCursorState, initializeForest, FieldAnchor, moveToDetachedField, ForestEvents, } from "./forest/index.js";
7
7
  export { FieldKey, TreeNodeSchemaIdentifier, TreeFieldStoredSchema, ValueSchema, TreeNodeStoredSchema, TreeStoredSchemaSubscription as TreeStoredSchemaSubscription, MutableTreeStoredSchema, FieldKindIdentifier, FieldKindData, TreeTypeSet, TreeStoredSchema, TreeStoredSchemaRepository, schemaDataIsEmpty, SchemaEvents, forbiddenFieldKindIdentifier, storedEmptyFieldSchema, StoredSchemaCollection, schemaFormat, LeafNodeStoredSchema, ObjectNodeStoredSchema, MapNodeStoredSchema, toTreeNodeSchemaDataFormat, decodeFieldSchema, encodeFieldSchema, storedSchemaDecodeDispatcher, ErasedTreeNodeSchemaDataFormat, SchemaAndPolicy, Multiplicity, SchemaPolicy, } from "./schema-stored/index.js";
8
8
  export { ChangeFamily, ChangeFamilyCodec, ChangeEncodingContext, ChangeFamilyEditor, EditBuilder, } from "./change-family/index.js";
9
- export { areEqualChangeAtomIds, makeChangeAtomId, asChangeAtomId, ChangeRebaser, findAncestor, findCommonAncestor, GraphCommit, CommitKind, CommitMetadata, RevisionTag, RevisionTagSchema, RevisionTagCodec, ChangesetLocalId, ChangeAtomId, ChangeAtomIdMap, TaggedChange, makeAnonChange, tagChange, mapTaggedChange, noFailure, OutputType, verifyChangeRebaser, tagRollbackInverse, SessionIdSchema, mintCommit, rebaseBranch, BranchRebaseResult, rebaseChange, rebaseChangeOverChanges, RevisionMetadataSource, revisionMetadataSourceFromInfo, RevisionInfo, EncodedRevisionTag, EncodedChangeAtomId, taggedAtomId, taggedOptAtomId, replaceAtomRevisions, } from "./rebase/index.js";
9
+ export { areEqualChangeAtomIds, makeChangeAtomId, asChangeAtomId, ChangeRebaser, findAncestor, findCommonAncestor, GraphCommit, CommitKind, CommitMetadata, RevisionTag, RevisionTagSchema, RevisionTagCodec, ChangesetLocalId, ChangeAtomId, ChangeAtomIdMap, TaggedChange, makeAnonChange, tagChange, mapTaggedChange, noFailure, OutputType, verifyChangeRebaser, tagRollbackInverse, SessionIdSchema, mintCommit, rebaseBranch, BranchRebaseResult, rebaseChange, rebaseChangeOverChanges, RevisionMetadataSource, revisionMetadataSourceFromInfo, RevisionInfo, EncodedRevisionTag, EncodedChangeAtomId, taggedAtomId, taggedOptAtomId, offsetChangeAtomId, replaceAtomRevisions, } from "./rebase/index.js";
10
10
  export { Adapters, AdaptedViewSchema, Compatibility, TreeAdapter, AllowedUpdateType, } from "./schema-view/index.js";
11
11
  export { Revertible, RevertibleStatus } from "./revertible/index.js";
12
12
  //# sourceMappingURL=index.d.ts.map