@fluidframework/tree 2.0.0-rc.3.0.2 → 2.0.0-rc.4.0.0

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 (811) hide show
  1. package/.eslintrc.cjs +35 -2
  2. package/.vscode/settings.json +3 -0
  3. package/CHANGELOG.md +17 -0
  4. package/README.md +17 -5
  5. package/api-report/tree.api.md +66 -62
  6. package/dist/beta.d.ts +5 -1
  7. package/dist/codec/codec.d.ts.map +1 -1
  8. package/dist/codec/codec.js.map +1 -1
  9. package/dist/core/change-family/changeFamily.d.ts +2 -1
  10. package/dist/core/change-family/changeFamily.d.ts.map +1 -1
  11. package/dist/core/change-family/changeFamily.js.map +1 -1
  12. package/dist/core/index.d.ts +1 -1
  13. package/dist/core/index.d.ts.map +1 -1
  14. package/dist/core/index.js +2 -1
  15. package/dist/core/index.js.map +1 -1
  16. package/dist/core/rebase/changeRebaser.d.ts +2 -1
  17. package/dist/core/rebase/changeRebaser.d.ts.map +1 -1
  18. package/dist/core/rebase/changeRebaser.js.map +1 -1
  19. package/dist/core/rebase/index.d.ts +1 -1
  20. package/dist/core/rebase/index.d.ts.map +1 -1
  21. package/dist/core/rebase/index.js +2 -1
  22. package/dist/core/rebase/index.js.map +1 -1
  23. package/dist/core/rebase/revisionTagCodec.d.ts.map +1 -1
  24. package/dist/core/rebase/revisionTagCodec.js.map +1 -1
  25. package/dist/core/rebase/types.d.ts +1 -0
  26. package/dist/core/rebase/types.d.ts.map +1 -1
  27. package/dist/core/rebase/types.js +12 -1
  28. package/dist/core/rebase/types.js.map +1 -1
  29. package/dist/core/rebase/utils.d.ts +2 -2
  30. package/dist/core/rebase/utils.d.ts.map +1 -1
  31. package/dist/core/rebase/utils.js +16 -9
  32. package/dist/core/rebase/utils.js.map +1 -1
  33. package/dist/core/rebase/verifyChangeRebaser.js +1 -1
  34. package/dist/core/rebase/verifyChangeRebaser.js.map +1 -1
  35. package/dist/core/schema-stored/schema.d.ts +3 -3
  36. package/dist/core/schema-stored/schema.js +3 -3
  37. package/dist/core/schema-stored/schema.js.map +1 -1
  38. package/dist/core/tree/anchorSet.js.map +1 -1
  39. package/dist/core/tree/detachedFieldIndexCodec.d.ts.map +1 -1
  40. package/dist/core/tree/detachedFieldIndexCodec.js +1 -0
  41. package/dist/core/tree/detachedFieldIndexCodec.js.map +1 -1
  42. package/dist/core/tree/persistedTreeTextFormat.d.ts +4 -4
  43. package/dist/core/tree/treeTextFormat.d.ts +2 -0
  44. package/dist/core/tree/treeTextFormat.d.ts.map +1 -1
  45. package/dist/core/tree/treeTextFormat.js.map +1 -1
  46. package/dist/domains/index.d.ts +0 -1
  47. package/dist/domains/index.d.ts.map +1 -1
  48. package/dist/domains/index.js +1 -5
  49. package/dist/domains/index.js.map +1 -1
  50. package/dist/domains/json/jsonCursor.d.ts.map +1 -1
  51. package/dist/domains/json/jsonCursor.js +2 -1
  52. package/dist/domains/json/jsonCursor.js.map +1 -1
  53. package/dist/feature-libraries/changeAtomIdCodec.js +2 -2
  54. package/dist/feature-libraries/changeAtomIdCodec.js.map +1 -1
  55. package/dist/feature-libraries/chunked-forest/chunkedForest.js.map +1 -1
  56. package/dist/feature-libraries/chunked-forest/codec/chunkCodecUtilities.d.ts.map +1 -1
  57. package/dist/feature-libraries/chunked-forest/codec/chunkCodecUtilities.js.map +1 -1
  58. package/dist/feature-libraries/chunked-forest/codec/chunkEncodingGeneric.js.map +1 -1
  59. package/dist/feature-libraries/chunked-forest/codec/nodeShape.d.ts +1 -1
  60. package/dist/feature-libraries/chunked-forest/codec/nodeShape.d.ts.map +1 -1
  61. package/dist/feature-libraries/chunked-forest/codec/nodeShape.js.map +1 -1
  62. package/dist/feature-libraries/contextuallyTyped.d.ts.map +1 -1
  63. package/dist/feature-libraries/contextuallyTyped.js +1 -1
  64. package/dist/feature-libraries/contextuallyTyped.js.map +1 -1
  65. package/dist/feature-libraries/default-schema/defaultEditBuilder.d.ts +1 -1
  66. package/dist/feature-libraries/default-schema/defaultEditBuilder.d.ts.map +1 -1
  67. package/dist/feature-libraries/default-schema/defaultEditBuilder.js +2 -2
  68. package/dist/feature-libraries/default-schema/defaultEditBuilder.js.map +1 -1
  69. package/dist/feature-libraries/default-schema/defaultFieldKinds.d.ts +0 -6
  70. package/dist/feature-libraries/default-schema/defaultFieldKinds.d.ts.map +1 -1
  71. package/dist/feature-libraries/default-schema/defaultFieldKinds.js +1 -1
  72. package/dist/feature-libraries/default-schema/defaultFieldKinds.js.map +1 -1
  73. package/dist/feature-libraries/default-schema/index.d.ts +1 -1
  74. package/dist/feature-libraries/default-schema/index.d.ts.map +1 -1
  75. package/dist/feature-libraries/default-schema/index.js.map +1 -1
  76. package/dist/feature-libraries/default-schema/schemaChecker.d.ts +27 -0
  77. package/dist/feature-libraries/default-schema/schemaChecker.d.ts.map +1 -0
  78. package/dist/feature-libraries/default-schema/schemaChecker.js +120 -0
  79. package/dist/feature-libraries/default-schema/schemaChecker.js.map +1 -0
  80. package/dist/feature-libraries/deltaUtils.d.ts +2 -2
  81. package/dist/feature-libraries/deltaUtils.d.ts.map +1 -1
  82. package/dist/feature-libraries/deltaUtils.js +2 -2
  83. package/dist/feature-libraries/deltaUtils.js.map +1 -1
  84. package/dist/feature-libraries/editableTreeBinder.d.ts.map +1 -1
  85. package/dist/feature-libraries/editableTreeBinder.js +1 -1
  86. package/dist/feature-libraries/editableTreeBinder.js.map +1 -1
  87. package/dist/feature-libraries/flex-tree/context.d.ts +12 -19
  88. package/dist/feature-libraries/flex-tree/context.d.ts.map +1 -1
  89. package/dist/feature-libraries/flex-tree/context.js +15 -29
  90. package/dist/feature-libraries/flex-tree/context.js.map +1 -1
  91. package/dist/feature-libraries/flex-tree/flexTreeTypes.d.ts +8 -13
  92. package/dist/feature-libraries/flex-tree/flexTreeTypes.d.ts.map +1 -1
  93. package/dist/feature-libraries/flex-tree/flexTreeTypes.js +0 -1
  94. package/dist/feature-libraries/flex-tree/flexTreeTypes.js.map +1 -1
  95. package/dist/feature-libraries/flex-tree/index.d.ts +0 -1
  96. package/dist/feature-libraries/flex-tree/index.d.ts.map +1 -1
  97. package/dist/feature-libraries/flex-tree/index.js.map +1 -1
  98. package/dist/feature-libraries/flex-tree/lazyField.d.ts +3 -10
  99. package/dist/feature-libraries/flex-tree/lazyField.d.ts.map +1 -1
  100. package/dist/feature-libraries/flex-tree/lazyField.js +10 -40
  101. package/dist/feature-libraries/flex-tree/lazyField.js.map +1 -1
  102. package/dist/feature-libraries/flex-tree/lazyNode.d.ts +2 -6
  103. package/dist/feature-libraries/flex-tree/lazyNode.d.ts.map +1 -1
  104. package/dist/feature-libraries/flex-tree/lazyNode.js +7 -30
  105. package/dist/feature-libraries/flex-tree/lazyNode.js.map +1 -1
  106. package/dist/feature-libraries/flex-tree/utilities.d.ts +2 -2
  107. package/dist/feature-libraries/flex-tree/utilities.d.ts.map +1 -1
  108. package/dist/feature-libraries/flex-tree/utilities.js +5 -5
  109. package/dist/feature-libraries/flex-tree/utilities.js.map +1 -1
  110. package/dist/feature-libraries/index.d.ts +5 -5
  111. package/dist/feature-libraries/index.d.ts.map +1 -1
  112. package/dist/feature-libraries/index.js +4 -5
  113. package/dist/feature-libraries/index.js.map +1 -1
  114. package/dist/feature-libraries/mitigatedChangeFamily.d.ts.map +1 -1
  115. package/dist/feature-libraries/mitigatedChangeFamily.js +1 -0
  116. package/dist/feature-libraries/mitigatedChangeFamily.js.map +1 -1
  117. package/dist/feature-libraries/modular-schema/fieldChangeHandler.d.ts +9 -10
  118. package/dist/feature-libraries/modular-schema/fieldChangeHandler.d.ts.map +1 -1
  119. package/dist/feature-libraries/modular-schema/fieldChangeHandler.js +4 -3
  120. package/dist/feature-libraries/modular-schema/fieldChangeHandler.js.map +1 -1
  121. package/dist/feature-libraries/modular-schema/genericFieldKind.d.ts.map +1 -1
  122. package/dist/feature-libraries/modular-schema/genericFieldKind.js +16 -9
  123. package/dist/feature-libraries/modular-schema/genericFieldKind.js.map +1 -1
  124. package/dist/feature-libraries/modular-schema/index.d.ts +1 -1
  125. package/dist/feature-libraries/modular-schema/index.d.ts.map +1 -1
  126. package/dist/feature-libraries/modular-schema/index.js +2 -1
  127. package/dist/feature-libraries/modular-schema/index.js.map +1 -1
  128. package/dist/feature-libraries/modular-schema/modularChangeCodecs.js +23 -8
  129. package/dist/feature-libraries/modular-schema/modularChangeCodecs.js.map +1 -1
  130. package/dist/feature-libraries/modular-schema/modularChangeFamily.d.ts +14 -8
  131. package/dist/feature-libraries/modular-schema/modularChangeFamily.d.ts.map +1 -1
  132. package/dist/feature-libraries/modular-schema/modularChangeFamily.js +145 -117
  133. package/dist/feature-libraries/modular-schema/modularChangeFamily.js.map +1 -1
  134. package/dist/feature-libraries/node-key/index.d.ts +1 -1
  135. package/dist/feature-libraries/node-key/index.d.ts.map +1 -1
  136. package/dist/feature-libraries/node-key/index.js +1 -2
  137. package/dist/feature-libraries/node-key/index.js.map +1 -1
  138. package/dist/feature-libraries/node-key/nodeKey.d.ts +0 -8
  139. package/dist/feature-libraries/node-key/nodeKey.d.ts.map +1 -1
  140. package/dist/feature-libraries/node-key/nodeKey.js +1 -9
  141. package/dist/feature-libraries/node-key/nodeKey.js.map +1 -1
  142. package/dist/feature-libraries/node-key/nodeKeyManager.d.ts +20 -2
  143. package/dist/feature-libraries/node-key/nodeKeyManager.d.ts.map +1 -1
  144. package/dist/feature-libraries/node-key/nodeKeyManager.js +27 -5
  145. package/dist/feature-libraries/node-key/nodeKeyManager.js.map +1 -1
  146. package/dist/feature-libraries/optional-field/optionalField.d.ts +2 -2
  147. package/dist/feature-libraries/optional-field/optionalField.d.ts.map +1 -1
  148. package/dist/feature-libraries/optional-field/optionalField.js +85 -63
  149. package/dist/feature-libraries/optional-field/optionalField.js.map +1 -1
  150. package/dist/feature-libraries/schema-aware/schemaAware.d.ts +1 -1
  151. package/dist/feature-libraries/schema-aware/schemaAware.d.ts.map +1 -1
  152. package/dist/feature-libraries/schema-aware/schemaAware.js.map +1 -1
  153. package/dist/feature-libraries/sequence-field/compose.d.ts +3 -4
  154. package/dist/feature-libraries/sequence-field/compose.d.ts.map +1 -1
  155. package/dist/feature-libraries/sequence-field/compose.js +46 -48
  156. package/dist/feature-libraries/sequence-field/compose.js.map +1 -1
  157. package/dist/feature-libraries/sequence-field/format.d.ts +40 -40
  158. package/dist/feature-libraries/sequence-field/invert.d.ts +2 -2
  159. package/dist/feature-libraries/sequence-field/invert.d.ts.map +1 -1
  160. package/dist/feature-libraries/sequence-field/invert.js +20 -20
  161. package/dist/feature-libraries/sequence-field/invert.js.map +1 -1
  162. package/dist/feature-libraries/sequence-field/markQueue.d.ts +1 -3
  163. package/dist/feature-libraries/sequence-field/markQueue.d.ts.map +1 -1
  164. package/dist/feature-libraries/sequence-field/markQueue.js +2 -3
  165. package/dist/feature-libraries/sequence-field/markQueue.js.map +1 -1
  166. package/dist/feature-libraries/sequence-field/moveEffectTable.d.ts +1 -1
  167. package/dist/feature-libraries/sequence-field/moveEffectTable.d.ts.map +1 -1
  168. package/dist/feature-libraries/sequence-field/moveEffectTable.js +5 -5
  169. package/dist/feature-libraries/sequence-field/moveEffectTable.js.map +1 -1
  170. package/dist/feature-libraries/sequence-field/rebase.d.ts +1 -2
  171. package/dist/feature-libraries/sequence-field/rebase.d.ts.map +1 -1
  172. package/dist/feature-libraries/sequence-field/rebase.js +51 -52
  173. package/dist/feature-libraries/sequence-field/rebase.js.map +1 -1
  174. package/dist/feature-libraries/sequence-field/relevantRemovedRoots.d.ts +2 -2
  175. package/dist/feature-libraries/sequence-field/relevantRemovedRoots.d.ts.map +1 -1
  176. package/dist/feature-libraries/sequence-field/relevantRemovedRoots.js +2 -2
  177. package/dist/feature-libraries/sequence-field/relevantRemovedRoots.js.map +1 -1
  178. package/dist/feature-libraries/sequence-field/replaceRevisions.d.ts +8 -0
  179. package/dist/feature-libraries/sequence-field/replaceRevisions.d.ts.map +1 -0
  180. package/dist/feature-libraries/sequence-field/replaceRevisions.js +63 -0
  181. package/dist/feature-libraries/sequence-field/replaceRevisions.js.map +1 -0
  182. package/dist/feature-libraries/sequence-field/sequenceFieldChangeRebaser.d.ts +2 -0
  183. package/dist/feature-libraries/sequence-field/sequenceFieldChangeRebaser.d.ts.map +1 -1
  184. package/dist/feature-libraries/sequence-field/sequenceFieldChangeRebaser.js +2 -0
  185. package/dist/feature-libraries/sequence-field/sequenceFieldChangeRebaser.js.map +1 -1
  186. package/dist/feature-libraries/sequence-field/sequenceFieldCodecs.js +22 -27
  187. package/dist/feature-libraries/sequence-field/sequenceFieldCodecs.js.map +1 -1
  188. package/dist/feature-libraries/sequence-field/sequenceFieldToDelta.d.ts +2 -2
  189. package/dist/feature-libraries/sequence-field/sequenceFieldToDelta.d.ts.map +1 -1
  190. package/dist/feature-libraries/sequence-field/sequenceFieldToDelta.js +7 -7
  191. package/dist/feature-libraries/sequence-field/sequenceFieldToDelta.js.map +1 -1
  192. package/dist/feature-libraries/sequence-field/utils.d.ts +10 -10
  193. package/dist/feature-libraries/sequence-field/utils.d.ts.map +1 -1
  194. package/dist/feature-libraries/sequence-field/utils.js +28 -32
  195. package/dist/feature-libraries/sequence-field/utils.js.map +1 -1
  196. package/dist/feature-libraries/valueUtilities.d.ts +1 -2
  197. package/dist/feature-libraries/valueUtilities.d.ts.map +1 -1
  198. package/dist/feature-libraries/valueUtilities.js +7 -25
  199. package/dist/feature-libraries/valueUtilities.js.map +1 -1
  200. package/dist/index.d.ts +4 -4
  201. package/dist/index.d.ts.map +1 -1
  202. package/dist/index.js +3 -4
  203. package/dist/index.js.map +1 -1
  204. package/dist/packageVersion.d.ts +1 -1
  205. package/dist/packageVersion.js +1 -1
  206. package/dist/packageVersion.js.map +1 -1
  207. package/dist/public.d.ts +5 -1
  208. package/dist/shared-tree/defaultCommitEnricher.d.ts +91 -0
  209. package/dist/shared-tree/defaultCommitEnricher.d.ts.map +1 -0
  210. package/dist/shared-tree/defaultCommitEnricher.js +121 -0
  211. package/dist/shared-tree/defaultCommitEnricher.js.map +1 -0
  212. package/dist/shared-tree/index.d.ts +1 -1
  213. package/dist/shared-tree/index.d.ts.map +1 -1
  214. package/dist/shared-tree/index.js +2 -1
  215. package/dist/shared-tree/index.js.map +1 -1
  216. package/dist/shared-tree/schematizingTreeView.d.ts +2 -4
  217. package/dist/shared-tree/schematizingTreeView.d.ts.map +1 -1
  218. package/dist/shared-tree/schematizingTreeView.js +6 -7
  219. package/dist/shared-tree/schematizingTreeView.js.map +1 -1
  220. package/dist/shared-tree/sharedTree.d.ts +1 -2
  221. package/dist/shared-tree/sharedTree.d.ts.map +1 -1
  222. package/dist/shared-tree/sharedTree.js +11 -9
  223. package/dist/shared-tree/sharedTree.js.map +1 -1
  224. package/dist/shared-tree/sharedTreeChangeCodecs.js +1 -0
  225. package/dist/shared-tree/sharedTreeChangeCodecs.js.map +1 -1
  226. package/dist/shared-tree/sharedTreeChangeEnricher.d.ts +24 -0
  227. package/dist/shared-tree/sharedTreeChangeEnricher.d.ts.map +1 -0
  228. package/dist/shared-tree/sharedTreeChangeEnricher.js +65 -0
  229. package/dist/shared-tree/sharedTreeChangeEnricher.js.map +1 -0
  230. package/dist/shared-tree/sharedTreeChangeFamily.d.ts +12 -3
  231. package/dist/shared-tree/sharedTreeChangeFamily.d.ts.map +1 -1
  232. package/dist/shared-tree/sharedTreeChangeFamily.js +83 -7
  233. package/dist/shared-tree/sharedTreeChangeFamily.js.map +1 -1
  234. package/dist/shared-tree/treeApi.d.ts +208 -16
  235. package/dist/shared-tree/treeApi.d.ts.map +1 -1
  236. package/dist/shared-tree/treeApi.js +39 -18
  237. package/dist/shared-tree/treeApi.js.map +1 -1
  238. package/dist/shared-tree/treeCheckout.d.ts.map +1 -1
  239. package/dist/shared-tree/treeCheckout.js +7 -9
  240. package/dist/shared-tree/treeCheckout.js.map +1 -1
  241. package/dist/shared-tree/treeView.d.ts +2 -4
  242. package/dist/shared-tree/treeView.d.ts.map +1 -1
  243. package/dist/shared-tree/treeView.js +3 -4
  244. package/dist/shared-tree/treeView.js.map +1 -1
  245. package/dist/shared-tree-core/branch.d.ts +22 -2
  246. package/dist/shared-tree-core/branch.d.ts.map +1 -1
  247. package/dist/shared-tree-core/branch.js +18 -12
  248. package/dist/shared-tree-core/branch.js.map +1 -1
  249. package/dist/shared-tree-core/commitEnricher.d.ts +35 -0
  250. package/dist/shared-tree-core/commitEnricher.d.ts.map +1 -0
  251. package/dist/{domains/nodeKey/index.d.ts → shared-tree-core/commitEnricher.js} +3 -2
  252. package/dist/shared-tree-core/commitEnricher.js.map +1 -0
  253. package/dist/shared-tree-core/editManager.d.ts +8 -5
  254. package/dist/shared-tree-core/editManager.d.ts.map +1 -1
  255. package/dist/shared-tree-core/editManager.js +11 -3
  256. package/dist/shared-tree-core/editManager.js.map +1 -1
  257. package/dist/shared-tree-core/editManagerCodecs.js +22 -7
  258. package/dist/shared-tree-core/editManagerCodecs.js.map +1 -1
  259. package/dist/shared-tree-core/editManagerFormat.d.ts +6 -7
  260. package/dist/shared-tree-core/editManagerFormat.d.ts.map +1 -1
  261. package/dist/shared-tree-core/index.d.ts +1 -0
  262. package/dist/shared-tree-core/index.d.ts.map +1 -1
  263. package/dist/shared-tree-core/index.js.map +1 -1
  264. package/dist/shared-tree-core/messageCodecs.js +12 -4
  265. package/dist/shared-tree-core/messageCodecs.js.map +1 -1
  266. package/dist/shared-tree-core/sharedTreeCore.d.ts +12 -5
  267. package/dist/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
  268. package/dist/shared-tree-core/sharedTreeCore.js +50 -15
  269. package/dist/shared-tree-core/sharedTreeCore.js.map +1 -1
  270. package/dist/simple-tree/arrayNode.d.ts +20 -6
  271. package/dist/simple-tree/arrayNode.d.ts.map +1 -1
  272. package/dist/simple-tree/arrayNode.js +252 -234
  273. package/dist/simple-tree/arrayNode.js.map +1 -1
  274. package/dist/simple-tree/index.d.ts +3 -3
  275. package/dist/simple-tree/index.d.ts.map +1 -1
  276. package/dist/simple-tree/index.js +2 -2
  277. package/dist/simple-tree/index.js.map +1 -1
  278. package/dist/simple-tree/leafNodeSchema.d.ts +1 -1
  279. package/dist/simple-tree/leafNodeSchema.d.ts.map +1 -1
  280. package/dist/simple-tree/mapNode.d.ts +3 -11
  281. package/dist/simple-tree/mapNode.d.ts.map +1 -1
  282. package/dist/simple-tree/mapNode.js +84 -133
  283. package/dist/simple-tree/mapNode.js.map +1 -1
  284. package/{lib/feature-libraries/flex-tree → dist/simple-tree}/nodeKeys.d.ts +10 -11
  285. package/dist/simple-tree/nodeKeys.d.ts.map +1 -0
  286. package/{lib/domains/nodeKey/index.js → dist/simple-tree/nodeKeys.js} +3 -2
  287. package/dist/simple-tree/nodeKeys.js.map +1 -0
  288. package/dist/simple-tree/objectNode.d.ts +16 -7
  289. package/dist/simple-tree/objectNode.d.ts.map +1 -1
  290. package/dist/simple-tree/objectNode.js +66 -56
  291. package/dist/simple-tree/objectNode.js.map +1 -1
  292. package/dist/simple-tree/proxies.d.ts +1 -1
  293. package/dist/simple-tree/proxies.d.ts.map +1 -1
  294. package/dist/simple-tree/proxies.js +7 -6
  295. package/dist/simple-tree/proxies.js.map +1 -1
  296. package/dist/simple-tree/proxyBinding.d.ts +2 -2
  297. package/dist/simple-tree/proxyBinding.d.ts.map +1 -1
  298. package/dist/simple-tree/proxyBinding.js +2 -2
  299. package/dist/simple-tree/proxyBinding.js.map +1 -1
  300. package/dist/simple-tree/schemaFactory.d.ts +24 -17
  301. package/dist/simple-tree/schemaFactory.d.ts.map +1 -1
  302. package/dist/simple-tree/schemaFactory.js +46 -61
  303. package/dist/simple-tree/schemaFactory.js.map +1 -1
  304. package/dist/simple-tree/schemaFactoryRecursive.d.ts +2 -2
  305. package/dist/simple-tree/schemaFactoryRecursive.d.ts.map +1 -1
  306. package/dist/simple-tree/schemaFactoryRecursive.js +2 -2
  307. package/dist/simple-tree/schemaFactoryRecursive.js.map +1 -1
  308. package/dist/simple-tree/schemaTypes.d.ts +45 -22
  309. package/dist/simple-tree/schemaTypes.d.ts.map +1 -1
  310. package/dist/simple-tree/schemaTypes.js +23 -9
  311. package/dist/simple-tree/schemaTypes.js.map +1 -1
  312. package/dist/simple-tree/toFlexSchema.d.ts +2 -2
  313. package/dist/simple-tree/toFlexSchema.d.ts.map +1 -1
  314. package/dist/simple-tree/toFlexSchema.js +5 -6
  315. package/dist/simple-tree/toFlexSchema.js.map +1 -1
  316. package/dist/simple-tree/toMapTree.d.ts +12 -4
  317. package/dist/simple-tree/toMapTree.d.ts.map +1 -1
  318. package/dist/simple-tree/toMapTree.js +41 -30
  319. package/dist/simple-tree/toMapTree.js.map +1 -1
  320. package/dist/simple-tree/{treeApi.d.ts → treeNodeApi.d.ts} +18 -5
  321. package/dist/simple-tree/treeNodeApi.d.ts.map +1 -0
  322. package/dist/simple-tree/{treeApi.js → treeNodeApi.js} +62 -24
  323. package/dist/simple-tree/treeNodeApi.js.map +1 -0
  324. package/dist/simple-tree/types.d.ts +63 -0
  325. package/dist/simple-tree/types.d.ts.map +1 -1
  326. package/dist/simple-tree/types.js +109 -1
  327. package/dist/simple-tree/types.js.map +1 -1
  328. package/dist/simple-tree/typesUnsafe.d.ts +2 -2
  329. package/dist/simple-tree/typesUnsafe.d.ts.map +1 -1
  330. package/dist/simple-tree/typesUnsafe.js.map +1 -1
  331. package/dist/treeFactory.d.ts +1 -1
  332. package/dist/treeFactory.d.ts.map +1 -1
  333. package/dist/treeFactory.js +12 -14
  334. package/dist/treeFactory.js.map +1 -1
  335. package/dist/util/idAllocator.js.map +1 -1
  336. package/dist/util/nestedMap.d.ts.map +1 -1
  337. package/dist/util/nestedMap.js.map +1 -1
  338. package/dist/util/typeboxBrand.d.ts +3 -3
  339. package/dist/util/typeboxBrand.d.ts.map +1 -1
  340. package/dist/util/typeboxBrand.js +1 -1
  341. package/dist/util/typeboxBrand.js.map +1 -1
  342. package/dist/util/utils.d.ts.map +1 -1
  343. package/dist/util/utils.js.map +1 -1
  344. package/docs/.attachments/merge-semantics.drawio +835 -0
  345. package/docs/.attachments/ms-set-color-red-and-blue.png +0 -0
  346. package/docs/.attachments/ms-set-color-red-then-blue.png +0 -0
  347. package/docs/.attachments/ms-set-color-red.png +0 -0
  348. package/docs/SharedTree Philosophy.md +319 -0
  349. package/docs/main/merge-semantics.md +529 -0
  350. package/lib/beta.d.ts +5 -1
  351. package/lib/codec/codec.d.ts.map +1 -1
  352. package/lib/codec/codec.js.map +1 -1
  353. package/lib/core/change-family/changeFamily.d.ts +2 -1
  354. package/lib/core/change-family/changeFamily.d.ts.map +1 -1
  355. package/lib/core/change-family/changeFamily.js.map +1 -1
  356. package/lib/core/index.d.ts +1 -1
  357. package/lib/core/index.d.ts.map +1 -1
  358. package/lib/core/index.js +1 -1
  359. package/lib/core/index.js.map +1 -1
  360. package/lib/core/rebase/changeRebaser.d.ts +2 -1
  361. package/lib/core/rebase/changeRebaser.d.ts.map +1 -1
  362. package/lib/core/rebase/changeRebaser.js.map +1 -1
  363. package/lib/core/rebase/index.d.ts +1 -1
  364. package/lib/core/rebase/index.d.ts.map +1 -1
  365. package/lib/core/rebase/index.js +1 -1
  366. package/lib/core/rebase/index.js.map +1 -1
  367. package/lib/core/rebase/revisionTagCodec.d.ts.map +1 -1
  368. package/lib/core/rebase/revisionTagCodec.js.map +1 -1
  369. package/lib/core/rebase/types.d.ts +1 -0
  370. package/lib/core/rebase/types.d.ts.map +1 -1
  371. package/lib/core/rebase/types.js +10 -0
  372. package/lib/core/rebase/types.js.map +1 -1
  373. package/lib/core/rebase/utils.d.ts +2 -2
  374. package/lib/core/rebase/utils.d.ts.map +1 -1
  375. package/lib/core/rebase/utils.js +17 -10
  376. package/lib/core/rebase/utils.js.map +1 -1
  377. package/lib/core/rebase/verifyChangeRebaser.js +1 -1
  378. package/lib/core/rebase/verifyChangeRebaser.js.map +1 -1
  379. package/lib/core/schema-stored/schema.d.ts +3 -3
  380. package/lib/core/schema-stored/schema.js +3 -3
  381. package/lib/core/schema-stored/schema.js.map +1 -1
  382. package/lib/core/tree/anchorSet.js.map +1 -1
  383. package/lib/core/tree/detachedFieldIndexCodec.d.ts.map +1 -1
  384. package/lib/core/tree/detachedFieldIndexCodec.js +1 -0
  385. package/lib/core/tree/detachedFieldIndexCodec.js.map +1 -1
  386. package/lib/core/tree/persistedTreeTextFormat.d.ts +4 -4
  387. package/lib/core/tree/treeTextFormat.d.ts +2 -0
  388. package/lib/core/tree/treeTextFormat.d.ts.map +1 -1
  389. package/lib/core/tree/treeTextFormat.js.map +1 -1
  390. package/lib/domains/index.d.ts +0 -1
  391. package/lib/domains/index.d.ts.map +1 -1
  392. package/lib/domains/index.js +0 -1
  393. package/lib/domains/index.js.map +1 -1
  394. package/lib/domains/json/jsonCursor.d.ts.map +1 -1
  395. package/lib/domains/json/jsonCursor.js +2 -1
  396. package/lib/domains/json/jsonCursor.js.map +1 -1
  397. package/lib/feature-libraries/changeAtomIdCodec.js +2 -2
  398. package/lib/feature-libraries/changeAtomIdCodec.js.map +1 -1
  399. package/lib/feature-libraries/chunked-forest/chunkedForest.js.map +1 -1
  400. package/lib/feature-libraries/chunked-forest/codec/chunkCodecUtilities.d.ts.map +1 -1
  401. package/lib/feature-libraries/chunked-forest/codec/chunkCodecUtilities.js.map +1 -1
  402. package/lib/feature-libraries/chunked-forest/codec/chunkEncodingGeneric.js.map +1 -1
  403. package/lib/feature-libraries/chunked-forest/codec/nodeShape.d.ts +1 -1
  404. package/lib/feature-libraries/chunked-forest/codec/nodeShape.d.ts.map +1 -1
  405. package/lib/feature-libraries/chunked-forest/codec/nodeShape.js.map +1 -1
  406. package/lib/feature-libraries/contextuallyTyped.d.ts.map +1 -1
  407. package/lib/feature-libraries/contextuallyTyped.js +1 -1
  408. package/lib/feature-libraries/contextuallyTyped.js.map +1 -1
  409. package/lib/feature-libraries/default-schema/defaultEditBuilder.d.ts +1 -1
  410. package/lib/feature-libraries/default-schema/defaultEditBuilder.d.ts.map +1 -1
  411. package/lib/feature-libraries/default-schema/defaultEditBuilder.js +2 -2
  412. package/lib/feature-libraries/default-schema/defaultEditBuilder.js.map +1 -1
  413. package/lib/feature-libraries/default-schema/defaultFieldKinds.d.ts +0 -6
  414. package/lib/feature-libraries/default-schema/defaultFieldKinds.d.ts.map +1 -1
  415. package/lib/feature-libraries/default-schema/defaultFieldKinds.js +1 -1
  416. package/lib/feature-libraries/default-schema/defaultFieldKinds.js.map +1 -1
  417. package/lib/feature-libraries/default-schema/index.d.ts +1 -1
  418. package/lib/feature-libraries/default-schema/index.d.ts.map +1 -1
  419. package/lib/feature-libraries/default-schema/index.js.map +1 -1
  420. package/lib/feature-libraries/default-schema/schemaChecker.d.ts +27 -0
  421. package/lib/feature-libraries/default-schema/schemaChecker.d.ts.map +1 -0
  422. package/lib/feature-libraries/default-schema/schemaChecker.js +114 -0
  423. package/lib/feature-libraries/default-schema/schemaChecker.js.map +1 -0
  424. package/lib/feature-libraries/deltaUtils.d.ts +2 -2
  425. package/lib/feature-libraries/deltaUtils.d.ts.map +1 -1
  426. package/lib/feature-libraries/deltaUtils.js +3 -3
  427. package/lib/feature-libraries/deltaUtils.js.map +1 -1
  428. package/lib/feature-libraries/editableTreeBinder.d.ts.map +1 -1
  429. package/lib/feature-libraries/editableTreeBinder.js +1 -1
  430. package/lib/feature-libraries/editableTreeBinder.js.map +1 -1
  431. package/lib/feature-libraries/flex-tree/context.d.ts +12 -19
  432. package/lib/feature-libraries/flex-tree/context.d.ts.map +1 -1
  433. package/lib/feature-libraries/flex-tree/context.js +15 -29
  434. package/lib/feature-libraries/flex-tree/context.js.map +1 -1
  435. package/lib/feature-libraries/flex-tree/flexTreeTypes.d.ts +8 -13
  436. package/lib/feature-libraries/flex-tree/flexTreeTypes.d.ts.map +1 -1
  437. package/lib/feature-libraries/flex-tree/flexTreeTypes.js +0 -1
  438. package/lib/feature-libraries/flex-tree/flexTreeTypes.js.map +1 -1
  439. package/lib/feature-libraries/flex-tree/index.d.ts +0 -1
  440. package/lib/feature-libraries/flex-tree/index.d.ts.map +1 -1
  441. package/lib/feature-libraries/flex-tree/index.js.map +1 -1
  442. package/lib/feature-libraries/flex-tree/lazyField.d.ts +3 -10
  443. package/lib/feature-libraries/flex-tree/lazyField.d.ts.map +1 -1
  444. package/lib/feature-libraries/flex-tree/lazyField.js +10 -39
  445. package/lib/feature-libraries/flex-tree/lazyField.js.map +1 -1
  446. package/lib/feature-libraries/flex-tree/lazyNode.d.ts +2 -6
  447. package/lib/feature-libraries/flex-tree/lazyNode.d.ts.map +1 -1
  448. package/lib/feature-libraries/flex-tree/lazyNode.js +7 -29
  449. package/lib/feature-libraries/flex-tree/lazyNode.js.map +1 -1
  450. package/lib/feature-libraries/flex-tree/utilities.d.ts +2 -2
  451. package/lib/feature-libraries/flex-tree/utilities.d.ts.map +1 -1
  452. package/lib/feature-libraries/flex-tree/utilities.js +5 -5
  453. package/lib/feature-libraries/flex-tree/utilities.js.map +1 -1
  454. package/lib/feature-libraries/index.d.ts +5 -5
  455. package/lib/feature-libraries/index.d.ts.map +1 -1
  456. package/lib/feature-libraries/index.js +3 -3
  457. package/lib/feature-libraries/index.js.map +1 -1
  458. package/lib/feature-libraries/mitigatedChangeFamily.d.ts.map +1 -1
  459. package/lib/feature-libraries/mitigatedChangeFamily.js +1 -0
  460. package/lib/feature-libraries/mitigatedChangeFamily.js.map +1 -1
  461. package/lib/feature-libraries/modular-schema/fieldChangeHandler.d.ts +9 -10
  462. package/lib/feature-libraries/modular-schema/fieldChangeHandler.d.ts.map +1 -1
  463. package/lib/feature-libraries/modular-schema/fieldChangeHandler.js +4 -3
  464. package/lib/feature-libraries/modular-schema/fieldChangeHandler.js.map +1 -1
  465. package/lib/feature-libraries/modular-schema/genericFieldKind.d.ts.map +1 -1
  466. package/lib/feature-libraries/modular-schema/genericFieldKind.js +17 -10
  467. package/lib/feature-libraries/modular-schema/genericFieldKind.js.map +1 -1
  468. package/lib/feature-libraries/modular-schema/index.d.ts +1 -1
  469. package/lib/feature-libraries/modular-schema/index.d.ts.map +1 -1
  470. package/lib/feature-libraries/modular-schema/index.js +1 -1
  471. package/lib/feature-libraries/modular-schema/index.js.map +1 -1
  472. package/lib/feature-libraries/modular-schema/modularChangeCodecs.js +23 -8
  473. package/lib/feature-libraries/modular-schema/modularChangeCodecs.js.map +1 -1
  474. package/lib/feature-libraries/modular-schema/modularChangeFamily.d.ts +14 -8
  475. package/lib/feature-libraries/modular-schema/modularChangeFamily.d.ts.map +1 -1
  476. package/lib/feature-libraries/modular-schema/modularChangeFamily.js +147 -119
  477. package/lib/feature-libraries/modular-schema/modularChangeFamily.js.map +1 -1
  478. package/lib/feature-libraries/node-key/index.d.ts +1 -1
  479. package/lib/feature-libraries/node-key/index.d.ts.map +1 -1
  480. package/lib/feature-libraries/node-key/index.js +1 -1
  481. package/lib/feature-libraries/node-key/index.js.map +1 -1
  482. package/lib/feature-libraries/node-key/nodeKey.d.ts +0 -8
  483. package/lib/feature-libraries/node-key/nodeKey.d.ts.map +1 -1
  484. package/lib/feature-libraries/node-key/nodeKey.js +0 -8
  485. package/lib/feature-libraries/node-key/nodeKey.js.map +1 -1
  486. package/lib/feature-libraries/node-key/nodeKeyManager.d.ts +20 -2
  487. package/lib/feature-libraries/node-key/nodeKeyManager.d.ts.map +1 -1
  488. package/lib/feature-libraries/node-key/nodeKeyManager.js +27 -6
  489. package/lib/feature-libraries/node-key/nodeKeyManager.js.map +1 -1
  490. package/lib/feature-libraries/optional-field/optionalField.d.ts +2 -2
  491. package/lib/feature-libraries/optional-field/optionalField.d.ts.map +1 -1
  492. package/lib/feature-libraries/optional-field/optionalField.js +86 -64
  493. package/lib/feature-libraries/optional-field/optionalField.js.map +1 -1
  494. package/lib/feature-libraries/schema-aware/schemaAware.d.ts +1 -1
  495. package/lib/feature-libraries/schema-aware/schemaAware.d.ts.map +1 -1
  496. package/lib/feature-libraries/schema-aware/schemaAware.js.map +1 -1
  497. package/lib/feature-libraries/sequence-field/compose.d.ts +3 -4
  498. package/lib/feature-libraries/sequence-field/compose.d.ts.map +1 -1
  499. package/lib/feature-libraries/sequence-field/compose.js +46 -48
  500. package/lib/feature-libraries/sequence-field/compose.js.map +1 -1
  501. package/lib/feature-libraries/sequence-field/format.d.ts +40 -40
  502. package/lib/feature-libraries/sequence-field/invert.d.ts +2 -2
  503. package/lib/feature-libraries/sequence-field/invert.d.ts.map +1 -1
  504. package/lib/feature-libraries/sequence-field/invert.js +20 -20
  505. package/lib/feature-libraries/sequence-field/invert.js.map +1 -1
  506. package/lib/feature-libraries/sequence-field/markQueue.d.ts +1 -3
  507. package/lib/feature-libraries/sequence-field/markQueue.d.ts.map +1 -1
  508. package/lib/feature-libraries/sequence-field/markQueue.js +2 -3
  509. package/lib/feature-libraries/sequence-field/markQueue.js.map +1 -1
  510. package/lib/feature-libraries/sequence-field/moveEffectTable.d.ts +1 -1
  511. package/lib/feature-libraries/sequence-field/moveEffectTable.d.ts.map +1 -1
  512. package/lib/feature-libraries/sequence-field/moveEffectTable.js +5 -5
  513. package/lib/feature-libraries/sequence-field/moveEffectTable.js.map +1 -1
  514. package/lib/feature-libraries/sequence-field/rebase.d.ts +1 -2
  515. package/lib/feature-libraries/sequence-field/rebase.d.ts.map +1 -1
  516. package/lib/feature-libraries/sequence-field/rebase.js +51 -52
  517. package/lib/feature-libraries/sequence-field/rebase.js.map +1 -1
  518. package/lib/feature-libraries/sequence-field/relevantRemovedRoots.d.ts +2 -2
  519. package/lib/feature-libraries/sequence-field/relevantRemovedRoots.d.ts.map +1 -1
  520. package/lib/feature-libraries/sequence-field/relevantRemovedRoots.js +2 -2
  521. package/lib/feature-libraries/sequence-field/relevantRemovedRoots.js.map +1 -1
  522. package/lib/feature-libraries/sequence-field/replaceRevisions.d.ts +8 -0
  523. package/lib/feature-libraries/sequence-field/replaceRevisions.d.ts.map +1 -0
  524. package/lib/feature-libraries/sequence-field/replaceRevisions.js +59 -0
  525. package/lib/feature-libraries/sequence-field/replaceRevisions.js.map +1 -0
  526. package/lib/feature-libraries/sequence-field/sequenceFieldChangeRebaser.d.ts +2 -0
  527. package/lib/feature-libraries/sequence-field/sequenceFieldChangeRebaser.d.ts.map +1 -1
  528. package/lib/feature-libraries/sequence-field/sequenceFieldChangeRebaser.js +2 -0
  529. package/lib/feature-libraries/sequence-field/sequenceFieldChangeRebaser.js.map +1 -1
  530. package/lib/feature-libraries/sequence-field/sequenceFieldCodecs.js +23 -28
  531. package/lib/feature-libraries/sequence-field/sequenceFieldCodecs.js.map +1 -1
  532. package/lib/feature-libraries/sequence-field/sequenceFieldToDelta.d.ts +2 -2
  533. package/lib/feature-libraries/sequence-field/sequenceFieldToDelta.d.ts.map +1 -1
  534. package/lib/feature-libraries/sequence-field/sequenceFieldToDelta.js +7 -7
  535. package/lib/feature-libraries/sequence-field/sequenceFieldToDelta.js.map +1 -1
  536. package/lib/feature-libraries/sequence-field/utils.d.ts +10 -10
  537. package/lib/feature-libraries/sequence-field/utils.d.ts.map +1 -1
  538. package/lib/feature-libraries/sequence-field/utils.js +28 -32
  539. package/lib/feature-libraries/sequence-field/utils.js.map +1 -1
  540. package/lib/feature-libraries/valueUtilities.d.ts +1 -2
  541. package/lib/feature-libraries/valueUtilities.d.ts.map +1 -1
  542. package/lib/feature-libraries/valueUtilities.js +1 -18
  543. package/lib/feature-libraries/valueUtilities.js.map +1 -1
  544. package/lib/index.d.ts +4 -4
  545. package/lib/index.d.ts.map +1 -1
  546. package/lib/index.js +2 -2
  547. package/lib/index.js.map +1 -1
  548. package/lib/packageVersion.d.ts +1 -1
  549. package/lib/packageVersion.js +1 -1
  550. package/lib/packageVersion.js.map +1 -1
  551. package/lib/public.d.ts +5 -1
  552. package/lib/shared-tree/defaultCommitEnricher.d.ts +91 -0
  553. package/lib/shared-tree/defaultCommitEnricher.d.ts.map +1 -0
  554. package/lib/shared-tree/defaultCommitEnricher.js +117 -0
  555. package/lib/shared-tree/defaultCommitEnricher.js.map +1 -0
  556. package/lib/shared-tree/index.d.ts +1 -1
  557. package/lib/shared-tree/index.d.ts.map +1 -1
  558. package/lib/shared-tree/index.js +1 -1
  559. package/lib/shared-tree/index.js.map +1 -1
  560. package/lib/shared-tree/schematizingTreeView.d.ts +2 -4
  561. package/lib/shared-tree/schematizingTreeView.d.ts.map +1 -1
  562. package/lib/shared-tree/schematizingTreeView.js +6 -7
  563. package/lib/shared-tree/schematizingTreeView.js.map +1 -1
  564. package/lib/shared-tree/sharedTree.d.ts +1 -2
  565. package/lib/shared-tree/sharedTree.d.ts.map +1 -1
  566. package/lib/shared-tree/sharedTree.js +13 -11
  567. package/lib/shared-tree/sharedTree.js.map +1 -1
  568. package/lib/shared-tree/sharedTreeChangeCodecs.js +1 -0
  569. package/lib/shared-tree/sharedTreeChangeCodecs.js.map +1 -1
  570. package/lib/shared-tree/sharedTreeChangeEnricher.d.ts +24 -0
  571. package/lib/shared-tree/sharedTreeChangeEnricher.d.ts.map +1 -0
  572. package/lib/shared-tree/sharedTreeChangeEnricher.js +61 -0
  573. package/lib/shared-tree/sharedTreeChangeEnricher.js.map +1 -0
  574. package/lib/shared-tree/sharedTreeChangeFamily.d.ts +12 -3
  575. package/lib/shared-tree/sharedTreeChangeFamily.d.ts.map +1 -1
  576. package/lib/shared-tree/sharedTreeChangeFamily.js +82 -7
  577. package/lib/shared-tree/sharedTreeChangeFamily.js.map +1 -1
  578. package/lib/shared-tree/treeApi.d.ts +208 -16
  579. package/lib/shared-tree/treeApi.d.ts.map +1 -1
  580. package/lib/shared-tree/treeApi.js +37 -17
  581. package/lib/shared-tree/treeApi.js.map +1 -1
  582. package/lib/shared-tree/treeCheckout.d.ts.map +1 -1
  583. package/lib/shared-tree/treeCheckout.js +8 -10
  584. package/lib/shared-tree/treeCheckout.js.map +1 -1
  585. package/lib/shared-tree/treeView.d.ts +2 -4
  586. package/lib/shared-tree/treeView.d.ts.map +1 -1
  587. package/lib/shared-tree/treeView.js +3 -4
  588. package/lib/shared-tree/treeView.js.map +1 -1
  589. package/lib/shared-tree-core/branch.d.ts +22 -2
  590. package/lib/shared-tree-core/branch.d.ts.map +1 -1
  591. package/lib/shared-tree-core/branch.js +18 -12
  592. package/lib/shared-tree-core/branch.js.map +1 -1
  593. package/lib/shared-tree-core/commitEnricher.d.ts +35 -0
  594. package/lib/shared-tree-core/commitEnricher.d.ts.map +1 -0
  595. package/{src/domains/nodeKey/index.ts → lib/shared-tree-core/commitEnricher.js} +2 -2
  596. package/lib/shared-tree-core/commitEnricher.js.map +1 -0
  597. package/lib/shared-tree-core/editManager.d.ts +8 -5
  598. package/lib/shared-tree-core/editManager.d.ts.map +1 -1
  599. package/lib/shared-tree-core/editManager.js +13 -5
  600. package/lib/shared-tree-core/editManager.js.map +1 -1
  601. package/lib/shared-tree-core/editManagerCodecs.js +22 -7
  602. package/lib/shared-tree-core/editManagerCodecs.js.map +1 -1
  603. package/lib/shared-tree-core/editManagerFormat.d.ts +6 -7
  604. package/lib/shared-tree-core/editManagerFormat.d.ts.map +1 -1
  605. package/lib/shared-tree-core/index.d.ts +1 -0
  606. package/lib/shared-tree-core/index.d.ts.map +1 -1
  607. package/lib/shared-tree-core/index.js.map +1 -1
  608. package/lib/shared-tree-core/messageCodecs.js +12 -4
  609. package/lib/shared-tree-core/messageCodecs.js.map +1 -1
  610. package/lib/shared-tree-core/sharedTreeCore.d.ts +12 -5
  611. package/lib/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
  612. package/lib/shared-tree-core/sharedTreeCore.js +50 -15
  613. package/lib/shared-tree-core/sharedTreeCore.js.map +1 -1
  614. package/lib/simple-tree/arrayNode.d.ts +20 -6
  615. package/lib/simple-tree/arrayNode.d.ts.map +1 -1
  616. package/lib/simple-tree/arrayNode.js +252 -235
  617. package/lib/simple-tree/arrayNode.js.map +1 -1
  618. package/lib/simple-tree/index.d.ts +3 -3
  619. package/lib/simple-tree/index.d.ts.map +1 -1
  620. package/lib/simple-tree/index.js +1 -1
  621. package/lib/simple-tree/index.js.map +1 -1
  622. package/lib/simple-tree/leafNodeSchema.d.ts +1 -1
  623. package/lib/simple-tree/leafNodeSchema.d.ts.map +1 -1
  624. package/lib/simple-tree/mapNode.d.ts +3 -11
  625. package/lib/simple-tree/mapNode.d.ts.map +1 -1
  626. package/lib/simple-tree/mapNode.js +84 -132
  627. package/lib/simple-tree/mapNode.js.map +1 -1
  628. package/{dist/feature-libraries/flex-tree → lib/simple-tree}/nodeKeys.d.ts +10 -11
  629. package/lib/simple-tree/nodeKeys.d.ts.map +1 -0
  630. package/lib/{domains/nodeKey/index.d.ts → simple-tree/nodeKeys.js} +2 -2
  631. package/lib/simple-tree/nodeKeys.js.map +1 -0
  632. package/lib/simple-tree/objectNode.d.ts +16 -7
  633. package/lib/simple-tree/objectNode.d.ts.map +1 -1
  634. package/lib/simple-tree/objectNode.js +65 -56
  635. package/lib/simple-tree/objectNode.js.map +1 -1
  636. package/lib/simple-tree/proxies.d.ts +1 -1
  637. package/lib/simple-tree/proxies.d.ts.map +1 -1
  638. package/lib/simple-tree/proxies.js +2 -1
  639. package/lib/simple-tree/proxies.js.map +1 -1
  640. package/lib/simple-tree/proxyBinding.d.ts +2 -2
  641. package/lib/simple-tree/proxyBinding.d.ts.map +1 -1
  642. package/lib/simple-tree/proxyBinding.js +2 -2
  643. package/lib/simple-tree/proxyBinding.js.map +1 -1
  644. package/lib/simple-tree/schemaFactory.d.ts +24 -17
  645. package/lib/simple-tree/schemaFactory.d.ts.map +1 -1
  646. package/lib/simple-tree/schemaFactory.js +47 -62
  647. package/lib/simple-tree/schemaFactory.js.map +1 -1
  648. package/lib/simple-tree/schemaFactoryRecursive.d.ts +2 -2
  649. package/lib/simple-tree/schemaFactoryRecursive.d.ts.map +1 -1
  650. package/lib/simple-tree/schemaFactoryRecursive.js +3 -3
  651. package/lib/simple-tree/schemaFactoryRecursive.js.map +1 -1
  652. package/lib/simple-tree/schemaTypes.d.ts +45 -22
  653. package/lib/simple-tree/schemaTypes.d.ts.map +1 -1
  654. package/lib/simple-tree/schemaTypes.js +24 -8
  655. package/lib/simple-tree/schemaTypes.js.map +1 -1
  656. package/lib/simple-tree/toFlexSchema.d.ts +2 -2
  657. package/lib/simple-tree/toFlexSchema.d.ts.map +1 -1
  658. package/lib/simple-tree/toFlexSchema.js +5 -6
  659. package/lib/simple-tree/toFlexSchema.js.map +1 -1
  660. package/lib/simple-tree/toMapTree.d.ts +12 -4
  661. package/lib/simple-tree/toMapTree.d.ts.map +1 -1
  662. package/lib/simple-tree/toMapTree.js +40 -30
  663. package/lib/simple-tree/toMapTree.js.map +1 -1
  664. package/lib/simple-tree/{treeApi.d.ts → treeNodeApi.d.ts} +18 -5
  665. package/lib/simple-tree/treeNodeApi.d.ts.map +1 -0
  666. package/lib/simple-tree/{treeApi.js → treeNodeApi.js} +64 -27
  667. package/lib/simple-tree/treeNodeApi.js.map +1 -0
  668. package/lib/simple-tree/types.d.ts +63 -0
  669. package/lib/simple-tree/types.d.ts.map +1 -1
  670. package/lib/simple-tree/types.js +106 -0
  671. package/lib/simple-tree/types.js.map +1 -1
  672. package/lib/simple-tree/typesUnsafe.d.ts +2 -2
  673. package/lib/simple-tree/typesUnsafe.d.ts.map +1 -1
  674. package/lib/simple-tree/typesUnsafe.js.map +1 -1
  675. package/lib/treeFactory.d.ts +1 -1
  676. package/lib/treeFactory.d.ts.map +1 -1
  677. package/lib/treeFactory.js +12 -14
  678. package/lib/treeFactory.js.map +1 -1
  679. package/lib/tsdoc-metadata.json +1 -1
  680. package/lib/util/idAllocator.js.map +1 -1
  681. package/lib/util/nestedMap.d.ts.map +1 -1
  682. package/lib/util/nestedMap.js.map +1 -1
  683. package/lib/util/typeboxBrand.d.ts +3 -3
  684. package/lib/util/typeboxBrand.d.ts.map +1 -1
  685. package/lib/util/typeboxBrand.js +1 -1
  686. package/lib/util/typeboxBrand.js.map +1 -1
  687. package/lib/util/utils.d.ts.map +1 -1
  688. package/lib/util/utils.js.map +1 -1
  689. package/package.json +25 -25
  690. package/src/codec/codec.ts +6 -4
  691. package/src/core/change-family/changeFamily.ts +2 -1
  692. package/src/core/forest/README.md +1 -1
  693. package/src/core/index.ts +1 -0
  694. package/src/core/rebase/changeRebaser.ts +7 -1
  695. package/src/core/rebase/index.ts +1 -0
  696. package/src/core/rebase/revisionTagCodec.ts +1 -0
  697. package/src/core/rebase/types.ts +17 -0
  698. package/src/core/rebase/utils.ts +23 -15
  699. package/src/core/rebase/verifyChangeRebaser.ts +4 -4
  700. package/src/core/schema-stored/schema.ts +4 -4
  701. package/src/core/tree/anchorSet.ts +1 -1
  702. package/src/core/tree/detachedFieldIndexCodec.ts +1 -0
  703. package/src/core/tree/treeTextFormat.ts +2 -0
  704. package/src/domains/index.ts +0 -2
  705. package/src/domains/json/jsonCursor.ts +2 -5
  706. package/src/feature-libraries/changeAtomIdCodec.ts +2 -2
  707. package/src/feature-libraries/chunked-forest/chunkedForest.ts +1 -1
  708. package/src/feature-libraries/chunked-forest/codec/chunkCodecUtilities.ts +2 -2
  709. package/src/feature-libraries/chunked-forest/codec/chunkEncodingGeneric.ts +1 -1
  710. package/src/feature-libraries/chunked-forest/codec/nodeShape.ts +8 -5
  711. package/src/feature-libraries/contextuallyTyped.ts +1 -1
  712. package/src/feature-libraries/default-schema/defaultEditBuilder.ts +2 -4
  713. package/src/feature-libraries/default-schema/defaultFieldKinds.ts +1 -6
  714. package/src/feature-libraries/default-schema/index.ts +0 -1
  715. package/src/feature-libraries/default-schema/schemaChecker.ts +140 -0
  716. package/src/feature-libraries/deltaUtils.ts +3 -12
  717. package/src/feature-libraries/editableTreeBinder.ts +1 -1
  718. package/src/feature-libraries/flex-tree/context.ts +19 -35
  719. package/src/feature-libraries/flex-tree/flexTreeTypes.ts +19 -17
  720. package/src/feature-libraries/flex-tree/index.ts +0 -2
  721. package/src/feature-libraries/flex-tree/lazyField.ts +10 -54
  722. package/src/feature-libraries/flex-tree/lazyNode.ts +11 -44
  723. package/src/feature-libraries/flex-tree/utilities.ts +5 -6
  724. package/src/feature-libraries/index.ts +2 -4
  725. package/src/feature-libraries/mitigatedChangeFamily.ts +8 -1
  726. package/src/feature-libraries/modular-schema/fieldChangeHandler.ts +18 -15
  727. package/src/feature-libraries/modular-schema/genericFieldKind.ts +33 -26
  728. package/src/feature-libraries/modular-schema/index.ts +1 -0
  729. package/src/feature-libraries/modular-schema/modularChangeCodecs.ts +33 -11
  730. package/src/feature-libraries/modular-schema/modularChangeFamily.ts +209 -209
  731. package/src/feature-libraries/node-key/index.ts +0 -1
  732. package/src/feature-libraries/node-key/nodeKey.ts +0 -9
  733. package/src/feature-libraries/node-key/nodeKeyManager.ts +41 -6
  734. package/src/feature-libraries/optional-field/optionalField.ts +112 -94
  735. package/src/feature-libraries/schema-aware/schemaAware.ts +3 -1
  736. package/src/feature-libraries/sequence-field/compose.ts +40 -96
  737. package/src/feature-libraries/sequence-field/invert.ts +20 -47
  738. package/src/feature-libraries/sequence-field/markQueue.ts +1 -5
  739. package/src/feature-libraries/sequence-field/moveEffectTable.ts +5 -10
  740. package/src/feature-libraries/sequence-field/rebase.ts +42 -139
  741. package/src/feature-libraries/sequence-field/relevantRemovedRoots.ts +3 -3
  742. package/src/feature-libraries/sequence-field/replaceRevisions.ts +87 -0
  743. package/src/feature-libraries/sequence-field/sequenceFieldChangeRebaser.ts +2 -0
  744. package/src/feature-libraries/sequence-field/sequenceFieldCodecs.ts +40 -32
  745. package/src/feature-libraries/sequence-field/sequenceFieldToDelta.ts +7 -13
  746. package/src/feature-libraries/sequence-field/utils.ts +22 -46
  747. package/src/feature-libraries/valueUtilities.ts +2 -22
  748. package/src/index.ts +5 -4
  749. package/src/packageVersion.ts +1 -1
  750. package/src/shared-tree/defaultCommitEnricher.ts +176 -0
  751. package/src/shared-tree/index.ts +2 -0
  752. package/src/shared-tree/schematizingTreeView.ts +9 -13
  753. package/src/shared-tree/sharedTree.ts +18 -10
  754. package/src/shared-tree/sharedTreeChangeCodecs.ts +1 -0
  755. package/src/shared-tree/sharedTreeChangeEnricher.ts +87 -0
  756. package/src/shared-tree/sharedTreeChangeFamily.ts +124 -8
  757. package/src/shared-tree/treeApi.ts +284 -46
  758. package/src/shared-tree/treeCheckout.ts +17 -17
  759. package/src/shared-tree/treeView.ts +3 -16
  760. package/src/shared-tree-core/branch.ts +49 -12
  761. package/src/shared-tree-core/commitEnricher.ts +39 -0
  762. package/src/shared-tree-core/editManager.ts +32 -15
  763. package/src/shared-tree-core/editManagerCodecs.ts +23 -7
  764. package/src/shared-tree-core/index.ts +2 -0
  765. package/src/shared-tree-core/messageCodecs.ts +18 -4
  766. package/src/shared-tree-core/sharedTreeCore.ts +82 -18
  767. package/src/simple-tree/arrayNode.ts +411 -334
  768. package/src/simple-tree/index.ts +3 -2
  769. package/src/simple-tree/mapNode.ts +120 -169
  770. package/src/{feature-libraries/flex-tree → simple-tree}/nodeKeys.ts +10 -20
  771. package/src/simple-tree/objectNode.ts +128 -98
  772. package/src/simple-tree/proxies.ts +2 -2
  773. package/src/simple-tree/proxyBinding.ts +5 -3
  774. package/src/simple-tree/schemaFactory.ts +64 -96
  775. package/src/simple-tree/schemaFactoryRecursive.ts +8 -6
  776. package/src/simple-tree/schemaTypes.ts +70 -18
  777. package/src/simple-tree/toFlexSchema.ts +9 -5
  778. package/src/simple-tree/toMapTree.ts +71 -29
  779. package/src/simple-tree/{treeApi.ts → treeNodeApi.ts} +91 -48
  780. package/src/simple-tree/types.ts +160 -1
  781. package/src/simple-tree/typesUnsafe.ts +2 -2
  782. package/src/treeFactory.ts +12 -15
  783. package/src/util/idAllocator.ts +1 -1
  784. package/src/util/nestedMap.ts +1 -1
  785. package/src/util/typeboxBrand.ts +3 -3
  786. package/src/util/utils.ts +4 -4
  787. package/dist/domains/nodeKey/index.d.ts.map +0 -1
  788. package/dist/domains/nodeKey/index.js +0 -12
  789. package/dist/domains/nodeKey/index.js.map +0 -1
  790. package/dist/domains/nodeKey/nodeKeySchema.d.ts +0 -30
  791. package/dist/domains/nodeKey/nodeKeySchema.d.ts.map +0 -1
  792. package/dist/domains/nodeKey/nodeKeySchema.js +0 -36
  793. package/dist/domains/nodeKey/nodeKeySchema.js.map +0 -1
  794. package/dist/feature-libraries/flex-tree/nodeKeys.d.ts.map +0 -1
  795. package/dist/feature-libraries/flex-tree/nodeKeys.js +0 -24
  796. package/dist/feature-libraries/flex-tree/nodeKeys.js.map +0 -1
  797. package/dist/simple-tree/treeApi.d.ts.map +0 -1
  798. package/dist/simple-tree/treeApi.js.map +0 -1
  799. package/lib/domains/nodeKey/index.d.ts.map +0 -1
  800. package/lib/domains/nodeKey/index.js.map +0 -1
  801. package/lib/domains/nodeKey/nodeKeySchema.d.ts +0 -30
  802. package/lib/domains/nodeKey/nodeKeySchema.d.ts.map +0 -1
  803. package/lib/domains/nodeKey/nodeKeySchema.js +0 -33
  804. package/lib/domains/nodeKey/nodeKeySchema.js.map +0 -1
  805. package/lib/feature-libraries/flex-tree/nodeKeys.d.ts.map +0 -1
  806. package/lib/feature-libraries/flex-tree/nodeKeys.js +0 -20
  807. package/lib/feature-libraries/flex-tree/nodeKeys.js.map +0 -1
  808. package/lib/simple-tree/treeApi.d.ts.map +0 -1
  809. package/lib/simple-tree/treeApi.js.map +0 -1
  810. package/src/domains/nodeKey/fence.json +0 -5
  811. package/src/domains/nodeKey/nodeKeySchema.ts +0 -44
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,12 @@ 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 the "strict" base config.
33
+ "@typescript-eslint/explicit-member-accessibility": "error",
30
34
  },
31
35
  overrides: [
32
36
  {
@@ -39,4 +43,33 @@ module.exports = {
39
43
  },
40
44
  },
41
45
  ],
46
+ settings: {
47
+ "import/extensions": [".ts", ".tsx", ".d.ts", ".js", ".jsx"],
48
+ "import/parsers": {
49
+ "@typescript-eslint/parser": [".ts", ".tsx", ".d.ts"],
50
+ },
51
+ "import/resolver": {
52
+ typescript: {
53
+ extensions: [".ts", ".tsx", ".d.ts", ".js", ".jsx"],
54
+ conditionNames: [
55
+ "allow-ff-test-exports",
56
+
57
+ // Default condition names below, see https://www.npmjs.com/package/eslint-import-resolver-typescript#conditionnames
58
+ "types",
59
+ "import",
60
+
61
+ // APF: https://angular.io/guide/angular-package-format
62
+ "esm2020",
63
+ "es2020",
64
+ "es2015",
65
+
66
+ "require",
67
+ "node",
68
+ "node-addons",
69
+ "browser",
70
+ "default",
71
+ ],
72
+ },
73
+ },
74
+ },
42
75
  };
@@ -12,5 +12,8 @@
12
12
  ],
13
13
  "mochaExplorer.configFile": ".mocharc.cjs",
14
14
  "mochaExplorer.timeout": 999999,
15
+ // This extension appears to invoke mocha programmatically, meaning that the enablement of this option in the common
16
+ // mocha test config isn't sufficient; it also needs to be enabled here.
17
+ "mochaExplorer.nodeArgv": ["--conditions", "allow-ff-test-exports"],
15
18
  "cSpell.words": ["deprioritized", "endregion", "insertable", "reentrantly", "unhydrated"],
16
19
  }
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
package/README.md CHANGED
@@ -1,6 +1,11 @@
1
1
  # @fluidframework/tree
2
2
 
3
- For a high-level overview of the goals of this project, see the [roadmap](docs/roadmap.md).
3
+ A [tree](<https://en.wikipedia.org/wiki/Tree_(data_structure)>) data structure for the [Fluid Framework](https://fluidframework.com/).
4
+
5
+ The contents of this package are also reported as part of the [`fluid-framework` package](https://www.npmjs.com/package/fluid-framework) which provides an alternative way to consume the functionality from this package.
6
+
7
+ [SharedTree Philosophy](./docs/SharedTree%20Philosophy.md) covers the goals of the SharedTree project,
8
+ and some of the implications of those goals for developers working on this package.
4
9
 
5
10
  ## Status
6
11
 
@@ -12,7 +17,13 @@ Notable consideration that early adopters should be wary of:
12
17
  - SharedTree currently has unbounded memory growth:
13
18
  - Removed content is retained forever.
14
19
  - Accessing an `EditableField` object (from its parent, e.g., with `getField`) in a loop will leak unbounded memory.
15
- - All changes are atomized by the `visitDelta` function. This means that, when inserting/removing/moving 2 contiguous nodes, the `visitDelta` function will call the `DeltaVisitor` twice (once for each node) instead of once for both nodes. Change notification consumers that are downstream from the `DeltaVisitor` will therefore also see those changes as atomized.
20
+ - All changes are atomized by the `visitDelta` function.
21
+ This means that, when inserting/removing/moving 2 contiguous nodes, the `visitDelta` function will call the `DeltaVisitor` twice (once for each node) instead of once for both nodes.
22
+ Change notification consumers that are downstream from the `DeltaVisitor` will therefore also see those changes as atomized.
23
+ - Some documentation (such as this readme and [the roadmap](docs/roadmap.md)) are out of date.
24
+ The [API documentation](https://fluidframework.com/docs/api/v2/tree) which is derived from the documentation comments in the source code should be more up to date.
25
+
26
+ More details on the development status of various features can be found in the [roadmap](docs/roadmap.md).
16
27
 
17
28
  <!-- AUTO-GENERATED-CONTENT:START (README_DEPENDENCY_GUIDELINES_SECTION:includeHeading=TRUE) -->
18
29
 
@@ -89,11 +100,12 @@ This tree serves to get these feature into the hands of users much faster than c
89
100
 
90
101
  This package can be developed using any of the [regular workflows for working on Fluid Framework](../../../README.md) and/or its Client release group of packages, but for work only touching the tree package, there is an optional workflow that might be more ergonomic:
91
102
 
103
+ - Follow the [Setup and Building](../../../README.md#setup-and-building) instructions.
92
104
  - Open the [.vscode/Tree.code-workspace](.vscode/Tree.code-workspace) in VS Code.
93
105
  This will recommend a test runner extension, which should be installed.
94
- - Build the Client release group as normal (for example: `pnpm i && npm run build:fast` in the repository root).
95
- - After editing the tree project, run `npm run build` in its directory.
96
- - Run tests using the "Testing" side panel in VS Code, or using the inline `Run | Debug` buttons which should show up above tests in the source:
106
+ - Build the the tree package as normal (for run example: `pnpm i && pnpm run build` in the `tree` directory).
107
+ - After editing the tree project, run `npm run build` (still in the `tree`) directory.
108
+ - Run and debug tests using the "Testing" side panel in VS Code, or using the inline `Run | Debug` buttons which should show up above tests in the source:
97
109
  both of these are provided by the mocha testing extension thats recommended by the workspace.
98
110
  Note that this does not build the tests, so always be sure to build first.
99
111
 
@@ -4,15 +4,9 @@
4
4
 
5
5
  ```ts
6
6
 
7
- import type { ErasedType } from '@fluidframework/core-interfaces';
8
- import { FluidObject } from '@fluidframework/core-interfaces';
7
+ import { ErasedType } from '@fluidframework/core-interfaces';
9
8
  import { IChannel } from '@fluidframework/datastore-definitions';
10
- import { IChannelAttributes } from '@fluidframework/datastore-definitions';
11
- import { IChannelFactory } from '@fluidframework/datastore-definitions';
12
- import { IChannelServices } from '@fluidframework/datastore-definitions';
13
- import { IFluidDataStoreRuntime } from '@fluidframework/datastore-definitions';
14
9
  import { IFluidHandle } from '@fluidframework/core-interfaces';
15
- import { IFluidLoadable } from '@fluidframework/core-interfaces';
16
10
  import { ISharedObject } from '@fluidframework/shared-object-base';
17
11
  import { ISharedObjectKind } from '@fluidframework/shared-object-base';
18
12
  import { SessionSpaceCompressedId } from '@fluidframework/id-compressor';
@@ -140,7 +134,11 @@ export const Any: "Any";
140
134
  export type Any = typeof Any;
141
135
 
142
136
  // @public
143
- export type ApplyKind<T, Kind extends FieldKind> = Kind extends FieldKind.Required ? T : undefined | T;
137
+ export type ApplyKind<T, Kind extends FieldKind, DefaultsAreOptional extends boolean> = {
138
+ [FieldKind.Required]: T;
139
+ [FieldKind.Optional]: T | undefined;
140
+ [FieldKind.Identifier]: DefaultsAreOptional extends true ? T | undefined : T;
141
+ }[Kind];
144
142
 
145
143
  // @internal
146
144
  export type ApplyMultiplicity<TMultiplicity extends Multiplicity, TypedChild> = {
@@ -308,6 +306,10 @@ export interface CursorWithNode<TNode> extends ITreeCursorSynchronous {
308
306
  getNode(): TNode;
309
307
  }
310
308
 
309
+ // @public
310
+ export interface DefaultProvider extends ErasedType<"@fluidframework/tree.FieldProvider"> {
311
+ }
312
+
311
313
  // @internal
312
314
  export const defaultSchemaPolicy: FullSchemaPolicy;
313
315
 
@@ -463,6 +465,7 @@ export type FieldKey = Brand<string, "tree.FieldKey">;
463
465
 
464
466
  // @public
465
467
  export enum FieldKind {
468
+ Identifier = 2,
466
469
  Optional = 0,
467
470
  Required = 1
468
471
  }
@@ -483,7 +486,6 @@ export const FieldKinds: {
483
486
  readonly required: Required_2;
484
487
  readonly optional: Optional;
485
488
  readonly sequence: Sequence;
486
- readonly nodeKey: NodeKeyFieldKind;
487
489
  readonly identifier: Identifier;
488
490
  readonly forbidden: Forbidden;
489
491
  };
@@ -504,15 +506,12 @@ export interface FieldMapObject<TChild> {
504
506
 
505
507
  // @public
506
508
  export interface FieldProps {
509
+ readonly defaultProvider?: DefaultProvider;
507
510
  readonly key?: string;
508
511
  }
509
512
 
510
513
  // @public @sealed
511
514
  export class FieldSchema<out Kind extends FieldKind = FieldKind, out Types extends ImplicitAllowedTypes = ImplicitAllowedTypes> {
512
- constructor(
513
- kind: Kind,
514
- allowedTypes: Types,
515
- props?: FieldProps | undefined);
516
515
  readonly allowedTypes: Types;
517
516
  get allowedTypeSet(): ReadonlySet<TreeNodeSchema>;
518
517
  readonly kind: Kind;
@@ -637,9 +636,9 @@ export class FlexObjectNodeSchema<const out Name extends string = string, const
637
636
 
638
637
  // @internal
639
638
  export interface FlexTreeContext extends ISubscribable<ForestEvents> {
640
- readonly forest: IForestSubscription;
639
+ readonly checkout: ITreeCheckout;
641
640
  // (undocumented)
642
- readonly nodeKeys: NodeKeys;
641
+ readonly nodeKeyManager: NodeKeyManager;
643
642
  get root(): FlexTreeField;
644
643
  readonly schema: FlexTreeSchema;
645
644
  }
@@ -830,14 +829,14 @@ export interface FlexTreeSequenceField<in out TTypes extends FlexAllowedTypes> e
830
829
  moveToStart(sourceIndex: number): void;
831
830
  moveToStart(sourceIndex: number, source: FlexTreeSequenceField<FlexAllowedTypes>): void;
832
831
  removeAt(index: number): void;
833
- removeRange(start?: number, end?: number): void;
832
+ sequenceEditor(): SequenceFieldEditBuilder;
834
833
  }
835
834
 
836
835
  // @internal
837
836
  export type FlexTreeTypedField<TSchema extends FlexFieldSchema> = FlexTreeTypedFieldInner<TSchema["kind"], TSchema["allowedTypes"]>;
838
837
 
839
838
  // @internal
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> : Kind extends typeof FieldKinds.nodeKey ? FlexTreeNodeKeyField : FlexTreeField;
839
+ 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;
841
840
 
842
841
  // @internal
843
842
  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;
@@ -849,7 +848,7 @@ export type FlexTreeTypedNodeUnion<T extends FlexAllowedTypes> = T extends FlexL
849
848
  export type FlexTreeUnboxField<TSchema extends FlexFieldSchema, Emptiness extends "maybeEmpty" | "notEmpty" = "maybeEmpty"> = FlexTreeUnboxFieldInner<TSchema["kind"], TSchema["allowedTypes"], Emptiness>;
850
849
 
851
850
  // @internal
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) : Kind extends typeof FieldKinds.nodeKey ? FlexTreeNodeKeyField : unknown;
851
+ 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;
853
852
 
854
853
  // @internal
855
854
  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;
@@ -992,7 +991,7 @@ ApplyMultiplicity<TField["kind"]["multiplicity"], AllowedTypesToFlexInsertableTr
992
991
  // @internal
993
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> ? {
994
993
  readonly [P in string]: InsertableFlexField<TField>;
995
- } : 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"]>>;
996
995
 
997
996
  // @public
998
997
  export type InsertableObjectFromSchemaRecord<T extends RestrictiveReadonlyRecord<string, ImplicitFieldSchema>> = {
@@ -1005,10 +1004,10 @@ export type InsertableObjectFromSchemaRecordUnsafe<T extends Unenforced<Restrict
1005
1004
  };
1006
1005
 
1007
1006
  // @public
1008
- 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;
1009
1008
 
1010
1009
  // @public
1011
- 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>;
1012
1011
 
1013
1012
  // @public
1014
1013
  export type InsertableTreeNodeFromImplicitAllowedTypes<TSchema extends ImplicitAllowedTypes = TreeNodeSchema> = TSchema extends TreeNodeSchema ? InsertableTypedNode<TSchema> : TSchema extends AllowedTypes ? InsertableTypedNode<FlexListToUnion<TSchema>> : never;
@@ -1026,6 +1025,10 @@ export type InsertableTypedNodeUnsafe<T extends Unenforced<TreeNodeSchema>> = Un
1026
1025
  implicitlyConstructable: true;
1027
1026
  } ? NodeBuilderDataUnsafe<T> : never);
1028
1027
 
1028
+ // @public
1029
+ export interface InternalTreeNode extends ErasedType<"@fluidframework/tree.InternalTreeNode"> {
1030
+ }
1031
+
1029
1032
  // @internal
1030
1033
  export interface Invariant<in out T> extends Contravariant<T>, Covariant<T> {
1031
1034
  }
@@ -1317,18 +1320,11 @@ export interface NodeInDocumentConstraint {
1317
1320
  }
1318
1321
 
1319
1322
  // @internal
1320
- export const nodeKeyFieldKey = "__n_id__";
1321
-
1322
- // @internal (undocumented)
1323
- export interface NodeKeyFieldKind extends FlexFieldKind<"NodeKey", Multiplicity.Single> {
1324
- }
1325
-
1326
- // @internal
1327
- export interface NodeKeys {
1328
- generate(): LocalNodeKey;
1329
- localize(key: StableNodeKey): LocalNodeKey;
1330
- readonly map: ReadonlyMap<LocalNodeKey, FlexTreeObjectNode>;
1331
- stabilize(key: LocalNodeKey): StableNodeKey;
1323
+ export interface NodeKeyManager {
1324
+ generateLocalNodeKey(): LocalNodeKey;
1325
+ localizeNodeKey(key: StableNodeKey): LocalNodeKey;
1326
+ stabilizeNodeKey(key: LocalNodeKey): StableNodeKey;
1327
+ tryLocalizeNodeKey(key: string): LocalNodeKey | undefined;
1332
1328
  }
1333
1329
 
1334
1330
  // @public
@@ -1485,7 +1481,7 @@ export const reservedObjectNodeFieldPropertyNamePrefixes: readonly ["set", "boxe
1485
1481
  export type ReservedObjectNodeFieldPropertyNames = (typeof reservedObjectNodeFieldPropertyNames)[number];
1486
1482
 
1487
1483
  // @internal
1488
- export const reservedObjectNodeFieldPropertyNames: readonly ["anchorNode", "constructor", "context", "is", "on", "parentField", "schema", "treeStatus", "tryGetField", "type", "value", "localNodeKey", "boxedIterator", "iterator", "getBoxed"];
1484
+ export const reservedObjectNodeFieldPropertyNames: readonly ["anchorNode", "constructor", "context", "is", "on", "parentField", "schema", "treeStatus", "tryGetField", "type", "value", "boxedIterator", "iterator", "getBoxed"];
1489
1485
 
1490
1486
  // @public
1491
1487
  export type RestrictiveReadonlyRecord<K extends symbol | string, T> = {
@@ -1512,6 +1508,9 @@ export enum RevertibleStatus {
1512
1508
  // @internal
1513
1509
  export type RevisionTag = SessionSpaceCompressedId | "root";
1514
1510
 
1511
+ // @public
1512
+ export const rollback: unique symbol;
1513
+
1515
1514
  // @internal
1516
1515
  export interface RootField {
1517
1516
  // (undocumented)
@@ -1527,6 +1526,23 @@ export const rootFieldKey: FieldKey;
1527
1526
  // @internal
1528
1527
  export function runSynchronous(view: ITreeCheckout, transaction: (view: ITreeCheckout) => TransactionResult | void): TransactionResult;
1529
1528
 
1529
+ // @public
1530
+ export interface RunTransaction {
1531
+ <TNode extends TreeNode, TResult>(node: TNode, transaction: (node: TNode) => TResult): TResult;
1532
+ <TView extends TreeView<ImplicitFieldSchema>, TResult>(tree: TView, transaction: (root: TView["root"]) => TResult): TResult;
1533
+ <TNode extends TreeNode, TResult>(node: TNode, transaction: (node: TNode) => TResult | typeof rollback): TResult | typeof rollback;
1534
+ <TView extends TreeView<ImplicitFieldSchema>, TResult>(tree: TView, transaction: (root: TView["root"]) => TResult | typeof rollback): TResult | typeof rollback;
1535
+ <TNode extends TreeNode>(node: TNode, transaction: (node: TNode) => void): void;
1536
+ <TView extends TreeView<ImplicitFieldSchema>>(tree: TView, transaction: (root: TView["root"]) => void): void;
1537
+ <TNode extends TreeNode, TResult>(node: TNode, transaction: (node: TNode) => TResult, preconditions?: TransactionConstraint[]): TResult;
1538
+ <TView extends TreeView<ImplicitFieldSchema>, TResult>(tree: TView, transaction: (root: TView["root"]) => TResult, preconditions?: TransactionConstraint[]): TResult;
1539
+ <TNode extends TreeNode, TResult>(node: TNode, transaction: (node: TNode) => TResult | typeof rollback, preconditions?: TransactionConstraint[]): TResult | typeof rollback;
1540
+ <TView extends TreeView<ImplicitFieldSchema>, TResult>(tree: TView, transaction: (root: TView["root"]) => TResult | typeof rollback, preconditions?: TransactionConstraint[]): TResult | typeof rollback;
1541
+ <TNode extends TreeNode>(node: TNode, transaction: (node: TNode) => void, preconditions?: TransactionConstraint[]): void;
1542
+ <TView extends TreeView<ImplicitFieldSchema>>(tree: TView, transaction: (root: TView["root"]) => void, preconditions?: TransactionConstraint[]): void;
1543
+ readonly rollback: typeof rollback;
1544
+ }
1545
+
1530
1546
  // @internal
1531
1547
  export class SchemaBuilderBase<TScope extends string, TDefaultKind extends FlexFieldKind, TName extends number | string = string> {
1532
1548
  constructor(defaultKind: TDefaultKind, options: SchemaBuilderOptions<TScope>);
@@ -1584,7 +1600,8 @@ export class SchemaFactory<out TScope extends string | undefined = string | unde
1584
1600
  [Symbol.iterator](): Iterator<InsertableTreeNodeFromImplicitAllowedTypesUnsafe<T>>;
1585
1601
  }, false, T>;
1586
1602
  readonly boolean: TreeNodeSchema<"com.fluidframework.leaf.boolean", NodeKind.Leaf, boolean, boolean>;
1587
- readonly handle: TreeNodeSchema<"com.fluidframework.leaf.handle", NodeKind.Leaf, IFluidHandle<FluidObject & IFluidLoadable>, IFluidHandle<FluidObject & IFluidLoadable>>;
1603
+ readonly handle: TreeNodeSchema<"com.fluidframework.leaf.handle", NodeKind.Leaf, IFluidHandle<unknown>, IFluidHandle<unknown>>;
1604
+ get identifier(): FieldSchema<FieldKind.Identifier>;
1588
1605
  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>;
1589
1606
  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>;
1590
1607
  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>>, {
@@ -1597,9 +1614,10 @@ export class SchemaFactory<out TScope extends string | undefined = string | unde
1597
1614
  readonly number: TreeNodeSchema<"com.fluidframework.leaf.number", NodeKind.Leaf, number, number>;
1598
1615
  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>;
1599
1616
  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>;
1600
- optional<const T extends ImplicitAllowedTypes>(t: T, props?: FieldProps): FieldSchema<FieldKind.Optional, T>;
1601
- optionalRecursive<const T extends Unenforced<readonly (() => TreeNodeSchema)[]>>(t: T): FieldSchemaUnsafe<FieldKind.Optional, T>;
1602
- required<const T extends ImplicitAllowedTypes>(t: T, props?: FieldProps): FieldSchema<FieldKind.Required, T>;
1617
+ optional<const T extends ImplicitAllowedTypes>(t: T, props?: Omit<FieldProps, "defaultProvider">): FieldSchema<FieldKind.Optional, T>;
1618
+ optionalRecursive<const T extends Unenforced<ImplicitAllowedTypes>>(t: T, props?: Omit<FieldProps, "defaultProvider">): FieldSchemaUnsafe<FieldKind.Optional, T>;
1619
+ required<const T extends ImplicitAllowedTypes>(t: T, props?: Omit<FieldProps, "defaultProvider">): FieldSchema<FieldKind.Required, T>;
1620
+ requiredRecursive<const T extends Unenforced<ImplicitAllowedTypes>>(t: T, props?: Omit<FieldProps, "defaultProvider">): FieldSchemaUnsafe<FieldKind.Required, T>;
1603
1621
  // (undocumented)
1604
1622
  readonly scope: TScope;
1605
1623
  readonly string: TreeNodeSchema<"com.fluidframework.leaf.string", NodeKind.Leaf, string, string>;
@@ -1683,19 +1701,6 @@ export interface SharedTreeContentSnapshot {
1683
1701
  readonly tree: JsonableTree[];
1684
1702
  }
1685
1703
 
1686
- // @internal
1687
- export class SharedTreeFactory implements IChannelFactory<ISharedTree> {
1688
- constructor(options?: SharedTreeOptions);
1689
- // (undocumented)
1690
- readonly attributes: IChannelAttributes;
1691
- // (undocumented)
1692
- create(runtime: IFluidDataStoreRuntime, id: string): ISharedTree;
1693
- // (undocumented)
1694
- load(runtime: IFluidDataStoreRuntime, id: string, services: IChannelServices, channelAttributes: Readonly<IChannelAttributes>): Promise<ISharedTree>;
1695
- // (undocumented)
1696
- readonly type: string;
1697
- }
1698
-
1699
1704
  // @internal
1700
1705
  export interface SharedTreeFormatOptions {
1701
1706
  formatVersion: SharedTreeFormatVersion[keyof SharedTreeFormatVersion];
@@ -1788,10 +1793,7 @@ export interface TreeAdapter {
1788
1793
  // @public
1789
1794
  export interface TreeApi extends TreeNodeApi {
1790
1795
  contains(node: TreeNode, other: TreeNode): boolean;
1791
- runTransaction<TNode extends TreeNode>(node: TNode, transaction: (node: TNode) => void | "rollback"): void;
1792
- runTransaction<TNode extends TreeNode>(node: TNode, transaction: (node: TNode) => void | "rollback", preconditions?: TransactionConstraint[]): void;
1793
- runTransaction<TView extends TreeView<ImplicitFieldSchema>>(tree: TView, transaction: (root: TView["root"]) => void | "rollback"): void;
1794
- runTransaction<TView extends TreeView<ImplicitFieldSchema>>(tree: TView, transaction: (root: TView["root"]) => void | "rollback", preconditions?: TransactionConstraint[]): void;
1796
+ readonly runTransaction: RunTransaction;
1795
1797
  }
1796
1798
 
1797
1799
  // @public
@@ -1805,9 +1807,9 @@ export const TreeArrayNode: {
1805
1807
 
1806
1808
  // @public
1807
1809
  export interface TreeArrayNodeBase<out T, in TNew, in TMoveFrom> extends ReadonlyArray<T>, TreeNode {
1808
- insertAt(index: number, ...value: (TNew | IterableTreeArrayContent<TNew>)[]): void;
1809
- insertAtEnd(...value: (TNew | IterableTreeArrayContent<TNew>)[]): void;
1810
- insertAtStart(...value: (TNew | IterableTreeArrayContent<TNew>)[]): void;
1810
+ insertAt(index: number, ...value: readonly (TNew | IterableTreeArrayContent<TNew>)[]): void;
1811
+ insertAtEnd(...value: readonly (TNew | IterableTreeArrayContent<TNew>)[]): void;
1812
+ insertAtStart(...value: readonly (TNew | IterableTreeArrayContent<TNew>)[]): void;
1811
1813
  moveRangeToEnd(sourceStart: number, sourceEnd: number): void;
1812
1814
  moveRangeToEnd(sourceStart: number, sourceEnd: number, source: TMoveFrom): void;
1813
1815
  moveRangeToIndex(index: number, sourceStart: number, sourceEnd: number): void;
@@ -1861,10 +1863,10 @@ export interface TreeDataContext {
1861
1863
  }
1862
1864
 
1863
1865
  // @public
1864
- export type TreeFieldFromImplicitField<TSchema extends ImplicitFieldSchema = FieldSchema> = TSchema extends FieldSchema<infer Kind, infer Types> ? ApplyKind<TreeNodeFromImplicitAllowedTypes<Types>, Kind> : TSchema extends ImplicitAllowedTypes ? TreeNodeFromImplicitAllowedTypes<TSchema> : unknown;
1866
+ 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;
1865
1867
 
1866
1868
  // @public
1867
- export type TreeFieldFromImplicitFieldUnsafe<TSchema extends Unenforced<ImplicitFieldSchema>> = TSchema extends FieldSchemaUnsafe<infer Kind, infer Types> ? ApplyKind<TreeNodeFromImplicitAllowedTypesUnsafe<Types>, Kind> : TSchema extends ImplicitAllowedTypes ? TreeNodeFromImplicitAllowedTypesUnsafe<TSchema> : unknown;
1869
+ 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;
1868
1870
 
1869
1871
  // @internal
1870
1872
  export interface TreeFieldStoredSchema {
@@ -1906,15 +1908,17 @@ export const enum TreeNavigationResult {
1906
1908
  // @public
1907
1909
  export abstract class TreeNode implements WithType {
1908
1910
  abstract get [type](): string;
1911
+ protected constructor();
1909
1912
  }
1910
1913
 
1911
1914
  // @public
1912
1915
  export interface TreeNodeApi {
1913
- is<TSchema extends TreeNodeSchema>(value: unknown, schema: TSchema): value is NodeFromSchema<TSchema>;
1916
+ is<TSchema extends ImplicitAllowedTypes>(value: unknown, schema: TSchema): value is TreeNodeFromImplicitAllowedTypes<TSchema>;
1914
1917
  key(node: TreeNode): string | number;
1915
1918
  on<K extends keyof TreeChangeEvents>(node: TreeNode, eventName: K, listener: TreeChangeEvents[K]): () => void;
1916
1919
  parent(node: TreeNode): TreeNode | undefined;
1917
1920
  schema<T extends TreeNode | TreeLeafValue>(node: T): TreeNodeSchema<string, NodeKind, unknown, T>;
1921
+ shortId(node: TreeNode): number | string | undefined;
1918
1922
  readonly status: (node: TreeNode) => TreeStatus;
1919
1923
  }
1920
1924
 
@@ -1947,7 +1951,7 @@ export abstract class TreeNodeSchemaBase<const out Name extends string = string,
1947
1951
  // @public
1948
1952
  export interface TreeNodeSchemaClass<out Name extends string = string, out Kind extends NodeKind = NodeKind, out TNode = unknown, in TInsertable = never, out ImplicitlyConstructable extends boolean = boolean, out Info = unknown> extends TreeNodeSchemaCore<Name, Kind, ImplicitlyConstructable, Info> {
1949
1953
  // @sealed
1950
- new (data: TInsertable): Unhydrated<TNode>;
1954
+ new (data: TInsertable | InternalTreeNode): Unhydrated<TNode>;
1951
1955
  }
1952
1956
 
1953
1957
  // @public
package/dist/beta.d.ts CHANGED
@@ -9,11 +9,12 @@
9
9
  */
10
10
 
11
11
  export {
12
- // public APIs
12
+ // @public APIs
13
13
  AllowedTypes,
14
14
  ApplyKind,
15
15
  CommitKind,
16
16
  CommitMetadata,
17
+ DefaultProvider,
17
18
  Events,
18
19
  ExtractItemType,
19
20
  FieldKind,
@@ -35,6 +36,7 @@ export {
35
36
  InsertableTreeNodeFromImplicitAllowedTypesUnsafe,
36
37
  InsertableTypedNode,
37
38
  InsertableTypedNodeUnsafe,
39
+ InternalTreeNode,
38
40
  IsEvent,
39
41
  IterableTreeArrayContent,
40
42
  LazyItem,
@@ -51,6 +53,7 @@ export {
51
53
  Revertible,
52
54
  RevertibleFactory,
53
55
  RevertibleStatus,
56
+ RunTransaction,
54
57
  SchemaFactory,
55
58
  SchemaIncompatible,
56
59
  ScopedSchemaName,
@@ -86,5 +89,6 @@ export {
86
89
  ValidateRecursiveSchema,
87
90
  WithType,
88
91
  disposeSymbol,
92
+ rollback,
89
93
  type
90
94
  } from "./index.js";
@@ -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,CAAC;AACzD,OAAO,EAAE,sBAAsB,EAAQ,MAAM,kBAAkB,CAAC;AAEhE;;;GAGG;AACH,MAAM,WAAW,QAAQ,CAAC,QAAQ,EAAE,QAAQ,EAAE,QAAQ;IACrD;;OAEG;IACH,MAAM,CAAC,GAAG,EAAE,QAAQ,EAAE,OAAO,EAAE,QAAQ,GAAG,QAAQ,CAAC;CACnD;AAED;;;GAGG;AACH,MAAM,WAAW,QAAQ,CAAC,QAAQ,EAAE,QAAQ,EAAE,QAAQ;IACrD;;OAEG;IACH,MAAM,CAAC,GAAG,EAAE,QAAQ,EAAE,OAAO,EAAE,QAAQ,GAAG,QAAQ,CAAC;CACnD;AAED;;;;GAIG;AACH,MAAM,WAAW,wBAAwB,CAAC,MAAM,SAAS,OAAO;IAC/D;;OAEG;IACH,KAAK,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,IAAI,MAAM,CAAC,MAAM,CAAC,CAAC;CAC7C;AAED;;;GAGG;AACH,MAAM,WAAW,aAAa;IAC7B;;;;;;;;OAQG;IACH,OAAO,CAAC,MA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C,CAAC;QACf,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC;KACf;IACD,MAAM,EAAE;QACP,MAAM,EAAE,GAAG,EAAE,CAAC,wBAAS,CAAC,IAAI,CAAC,EAAE,CAAC;QAChC,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC;KACf;CACD,CAAC;AAEH;;;GAGG;AACH,SAAgB,oBAAoB,CAOnC,MAAqB,EACrB,KAAuE,EACvE,SAAyB;IAEzB,IAAI,CAAC,SAAS,EAAE;QACf,OAAO,KAAK,CAAC;KACb;IACD,MAAM,cAAc,GAAG,SAAS,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IACjD,OAAO;QACN,MAAM,EAAE,CAAC,GAAoB,EAAE,OAAiB,EAAE,EAAE;YACnD,MAAM,OAAO,GAAG,KAAK,CAAC,MAAM,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;YAC3C,IAAI,CAAC,cAAc,CAAC,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;QAC9C,IAAI,MAA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AAC,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(\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<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): 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"]}
@@ -6,7 +6,7 @@ import { SessionId } from "@fluidframework/id-compressor";
6
6
  import { ICodecFamily, IJsonCodec } from "../../codec/index.js";
7
7
  import { SchemaAndPolicy } from "../../core/index.js";
8
8
  import { JsonCompatibleReadOnly } from "../../util/index.js";
9
- import { ChangeRebaser } from "../rebase/index.js";
9
+ import { ChangeRebaser, RevisionTag } from "../rebase/index.js";
10
10
  export interface ChangeFamily<TEditor extends ChangeFamilyEditor, TChange> {
11
11
  buildEditor(changeReceiver: (change: TChange) => void): TEditor;
12
12
  readonly rebaser: ChangeRebaser<TChange>;
@@ -14,6 +14,7 @@ export interface ChangeFamily<TEditor extends ChangeFamilyEditor, TChange> {
14
14
  }
15
15
  export interface ChangeEncodingContext {
16
16
  readonly originatorId: SessionId;
17
+ readonly revision: RevisionTag | undefined;
17
18
  readonly schema?: SchemaAndPolicy;
18
19
  }
19
20
  export type ChangeFamilyCodec<TChange> = IJsonCodec<TChange, JsonCompatibleReadOnly, JsonCompatibleReadOnly, ChangeEncodingContext>;
@@ -1 +1 @@
1
- {"version":3,"file":"changeFamily.d.ts","sourceRoot":"","sources":["../../../src/core/change-family/changeFamily.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAE1D,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAChE,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAA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