@fluidframework/tree 2.21.0 → 2.23.0-323641

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 (358) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/README.md +1 -0
  3. package/api-report/tree.alpha.api.md +29 -4
  4. package/api-report/tree.beta.api.md +29 -4
  5. package/api-report/tree.legacy.alpha.api.md +29 -4
  6. package/api-report/tree.legacy.public.api.md +29 -4
  7. package/api-report/tree.public.api.md +29 -4
  8. package/dist/alpha.d.ts +1 -0
  9. package/dist/beta.d.ts +1 -0
  10. package/dist/core/forest/editableForest.js +1 -1
  11. package/dist/core/forest/editableForest.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.map +1 -1
  15. package/dist/core/tree/anchorSet.d.ts +2 -5
  16. package/dist/core/tree/anchorSet.d.ts.map +1 -1
  17. package/dist/core/tree/anchorSet.js +16 -162
  18. package/dist/core/tree/anchorSet.js.map +1 -1
  19. package/dist/core/tree/index.d.ts +1 -2
  20. package/dist/core/tree/index.d.ts.map +1 -1
  21. package/dist/core/tree/index.js.map +1 -1
  22. package/dist/core/tree/pathTree.d.ts +0 -11
  23. package/dist/core/tree/pathTree.d.ts.map +1 -1
  24. package/dist/core/tree/pathTree.js.map +1 -1
  25. package/dist/feature-libraries/chunked-forest/codec/compressedEncode.js +1 -1
  26. package/dist/feature-libraries/chunked-forest/codec/compressedEncode.js.map +1 -1
  27. package/dist/feature-libraries/default-schema/defaultFieldKinds.js +1 -1
  28. package/dist/feature-libraries/default-schema/defaultFieldKinds.js.map +1 -1
  29. package/dist/feature-libraries/detachedFieldIndexSummarizer.d.ts +1 -2
  30. package/dist/feature-libraries/detachedFieldIndexSummarizer.d.ts.map +1 -1
  31. package/dist/feature-libraries/detachedFieldIndexSummarizer.js +0 -9
  32. package/dist/feature-libraries/detachedFieldIndexSummarizer.js.map +1 -1
  33. package/dist/feature-libraries/flex-tree/treeEvents.d.ts +2 -4
  34. package/dist/feature-libraries/flex-tree/treeEvents.d.ts.map +1 -1
  35. package/dist/feature-libraries/flex-tree/treeEvents.js.map +1 -1
  36. package/dist/feature-libraries/forest-summary/forestSummarizer.d.ts +1 -2
  37. package/dist/feature-libraries/forest-summary/forestSummarizer.d.ts.map +1 -1
  38. package/dist/feature-libraries/forest-summary/forestSummarizer.js +0 -9
  39. package/dist/feature-libraries/forest-summary/forestSummarizer.js.map +1 -1
  40. package/dist/feature-libraries/modular-schema/fieldChangeHandler.d.ts +6 -2
  41. package/dist/feature-libraries/modular-schema/fieldChangeHandler.d.ts.map +1 -1
  42. package/dist/feature-libraries/modular-schema/fieldChangeHandler.js.map +1 -1
  43. package/dist/feature-libraries/modular-schema/genericFieldKind.d.ts +2 -4
  44. package/dist/feature-libraries/modular-schema/genericFieldKind.d.ts.map +1 -1
  45. package/dist/feature-libraries/modular-schema/genericFieldKind.js +4 -19
  46. package/dist/feature-libraries/modular-schema/genericFieldKind.js.map +1 -1
  47. package/dist/feature-libraries/modular-schema/modularChangeFamily.d.ts.map +1 -1
  48. package/dist/feature-libraries/modular-schema/modularChangeFamily.js +16 -18
  49. package/dist/feature-libraries/modular-schema/modularChangeFamily.js.map +1 -1
  50. package/dist/feature-libraries/node-key/mockNodeKeyManager.js +1 -1
  51. package/dist/feature-libraries/node-key/mockNodeKeyManager.js.map +1 -1
  52. package/dist/feature-libraries/optional-field/optionalField.d.ts.map +1 -1
  53. package/dist/feature-libraries/optional-field/optionalField.js +7 -3
  54. package/dist/feature-libraries/optional-field/optionalField.js.map +1 -1
  55. package/dist/feature-libraries/schema-index/schemaSummarizer.d.ts +3 -5
  56. package/dist/feature-libraries/schema-index/schemaSummarizer.d.ts.map +1 -1
  57. package/dist/feature-libraries/schema-index/schemaSummarizer.js +1 -11
  58. package/dist/feature-libraries/schema-index/schemaSummarizer.js.map +1 -1
  59. package/dist/feature-libraries/sequence-field/sequenceFieldEditor.d.ts +1 -1
  60. package/dist/feature-libraries/sequence-field/sequenceFieldEditor.d.ts.map +1 -1
  61. package/dist/feature-libraries/sequence-field/sequenceFieldEditor.js +13 -1
  62. package/dist/feature-libraries/sequence-field/sequenceFieldEditor.js.map +1 -1
  63. package/dist/index.d.ts +3 -3
  64. package/dist/index.d.ts.map +1 -1
  65. package/dist/index.js +4 -4
  66. package/dist/index.js.map +1 -1
  67. package/dist/legacy.d.ts +1 -0
  68. package/dist/packageVersion.d.ts +1 -1
  69. package/dist/packageVersion.d.ts.map +1 -1
  70. package/dist/packageVersion.js +1 -1
  71. package/dist/packageVersion.js.map +1 -1
  72. package/dist/public.d.ts +1 -0
  73. package/dist/shared-tree/index.d.ts +1 -3
  74. package/dist/shared-tree/index.d.ts.map +1 -1
  75. package/dist/shared-tree/index.js +1 -7
  76. package/dist/shared-tree/index.js.map +1 -1
  77. package/dist/shared-tree/schematizingTreeView.d.ts +4 -5
  78. package/dist/shared-tree/schematizingTreeView.d.ts.map +1 -1
  79. package/dist/shared-tree/schematizingTreeView.js +9 -10
  80. package/dist/shared-tree/schematizingTreeView.js.map +1 -1
  81. package/dist/shared-tree/sharedTree.d.ts +40 -39
  82. package/dist/shared-tree/sharedTree.d.ts.map +1 -1
  83. package/dist/shared-tree/sharedTree.js +84 -52
  84. package/dist/shared-tree/sharedTree.js.map +1 -1
  85. package/dist/shared-tree/treeApi.d.ts +2 -2
  86. package/dist/shared-tree/treeApi.d.ts.map +1 -1
  87. package/dist/shared-tree/treeApi.js +9 -3
  88. package/dist/shared-tree/treeApi.js.map +1 -1
  89. package/dist/shared-tree/treeCheckout.d.ts +3 -3
  90. package/dist/shared-tree/treeCheckout.d.ts.map +1 -1
  91. package/dist/shared-tree/treeCheckout.js +3 -2
  92. package/dist/shared-tree/treeCheckout.js.map +1 -1
  93. package/dist/shared-tree-core/editManager.d.ts +11 -2
  94. package/dist/shared-tree-core/editManager.d.ts.map +1 -1
  95. package/dist/shared-tree-core/editManager.js +64 -29
  96. package/dist/shared-tree-core/editManager.js.map +1 -1
  97. package/dist/shared-tree-core/editManagerSummarizer.d.ts +1 -2
  98. package/dist/shared-tree-core/editManagerSummarizer.d.ts.map +1 -1
  99. package/dist/shared-tree-core/editManagerSummarizer.js +0 -9
  100. package/dist/shared-tree-core/editManagerSummarizer.js.map +1 -1
  101. package/dist/shared-tree-core/resubmitMachine.d.ts +2 -0
  102. package/dist/shared-tree-core/resubmitMachine.d.ts.map +1 -1
  103. package/dist/shared-tree-core/resubmitMachine.js.map +1 -1
  104. package/dist/shared-tree-core/sequenceIdUtils.d.ts +12 -1
  105. package/dist/shared-tree-core/sequenceIdUtils.d.ts.map +1 -1
  106. package/dist/shared-tree-core/sequenceIdUtils.js +25 -7
  107. package/dist/shared-tree-core/sequenceIdUtils.js.map +1 -1
  108. package/dist/shared-tree-core/sharedTreeCore.d.ts +33 -30
  109. package/dist/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
  110. package/dist/shared-tree-core/sharedTreeCore.js +62 -56
  111. package/dist/shared-tree-core/sharedTreeCore.js.map +1 -1
  112. package/dist/simple-tree/api/index.d.ts +3 -2
  113. package/dist/simple-tree/api/index.d.ts.map +1 -1
  114. package/dist/simple-tree/api/index.js +3 -1
  115. package/dist/simple-tree/api/index.js.map +1 -1
  116. package/dist/simple-tree/api/schemaFactory.d.ts +156 -63
  117. package/dist/simple-tree/api/schemaFactory.d.ts.map +1 -1
  118. package/dist/simple-tree/api/schemaFactory.js +179 -86
  119. package/dist/simple-tree/api/schemaFactory.js.map +1 -1
  120. package/dist/{shared-tree → simple-tree/api}/transactionTypes.d.ts +1 -1
  121. package/dist/simple-tree/api/transactionTypes.d.ts.map +1 -0
  122. package/dist/{shared-tree → simple-tree/api}/transactionTypes.js.map +1 -1
  123. package/dist/simple-tree/api/tree.d.ts +23 -2
  124. package/dist/simple-tree/api/tree.d.ts.map +1 -1
  125. package/dist/simple-tree/api/tree.js.map +1 -1
  126. package/dist/simple-tree/index.d.ts +1 -1
  127. package/dist/simple-tree/index.d.ts.map +1 -1
  128. package/dist/simple-tree/index.js +3 -2
  129. package/dist/simple-tree/index.js.map +1 -1
  130. package/dist/simple-tree/schemaTypes.d.ts +2 -2
  131. package/dist/simple-tree/schemaTypes.js +1 -1
  132. package/dist/simple-tree/schemaTypes.js.map +1 -1
  133. package/dist/simple-tree/treeNodeValid.js +1 -2
  134. package/dist/simple-tree/treeNodeValid.js.map +1 -1
  135. package/dist/treeFactory.d.ts +16 -5
  136. package/dist/treeFactory.d.ts.map +1 -1
  137. package/dist/treeFactory.js +21 -12
  138. package/dist/treeFactory.js.map +1 -1
  139. package/dist/util/breakable.d.ts +1 -1
  140. package/dist/util/breakable.d.ts.map +1 -1
  141. package/dist/util/breakable.js.map +1 -1
  142. package/dist/util/index.d.ts +1 -1
  143. package/dist/util/index.d.ts.map +1 -1
  144. package/dist/util/index.js +3 -2
  145. package/dist/util/index.js.map +1 -1
  146. package/dist/util/rangeMap.d.ts +1 -1
  147. package/dist/util/rangeMap.js +1 -1
  148. package/dist/util/rangeMap.js.map +1 -1
  149. package/dist/util/utils.d.ts +16 -0
  150. package/dist/util/utils.d.ts.map +1 -1
  151. package/dist/util/utils.js +29 -1
  152. package/dist/util/utils.js.map +1 -1
  153. package/lib/alpha.d.ts +1 -0
  154. package/lib/beta.d.ts +1 -0
  155. package/lib/core/forest/editableForest.js +1 -1
  156. package/lib/core/forest/editableForest.js.map +1 -1
  157. package/lib/core/index.d.ts +1 -1
  158. package/lib/core/index.d.ts.map +1 -1
  159. package/lib/core/index.js.map +1 -1
  160. package/lib/core/tree/anchorSet.d.ts +2 -5
  161. package/lib/core/tree/anchorSet.d.ts.map +1 -1
  162. package/lib/core/tree/anchorSet.js +17 -163
  163. package/lib/core/tree/anchorSet.js.map +1 -1
  164. package/lib/core/tree/index.d.ts +1 -2
  165. package/lib/core/tree/index.d.ts.map +1 -1
  166. package/lib/core/tree/index.js.map +1 -1
  167. package/lib/core/tree/pathTree.d.ts +0 -11
  168. package/lib/core/tree/pathTree.d.ts.map +1 -1
  169. package/lib/core/tree/pathTree.js.map +1 -1
  170. package/lib/feature-libraries/chunked-forest/codec/compressedEncode.js +1 -1
  171. package/lib/feature-libraries/chunked-forest/codec/compressedEncode.js.map +1 -1
  172. package/lib/feature-libraries/default-schema/defaultFieldKinds.js +1 -1
  173. package/lib/feature-libraries/default-schema/defaultFieldKinds.js.map +1 -1
  174. package/lib/feature-libraries/detachedFieldIndexSummarizer.d.ts +1 -2
  175. package/lib/feature-libraries/detachedFieldIndexSummarizer.d.ts.map +1 -1
  176. package/lib/feature-libraries/detachedFieldIndexSummarizer.js +0 -9
  177. package/lib/feature-libraries/detachedFieldIndexSummarizer.js.map +1 -1
  178. package/lib/feature-libraries/flex-tree/treeEvents.d.ts +2 -4
  179. package/lib/feature-libraries/flex-tree/treeEvents.d.ts.map +1 -1
  180. package/lib/feature-libraries/flex-tree/treeEvents.js.map +1 -1
  181. package/lib/feature-libraries/forest-summary/forestSummarizer.d.ts +1 -2
  182. package/lib/feature-libraries/forest-summary/forestSummarizer.d.ts.map +1 -1
  183. package/lib/feature-libraries/forest-summary/forestSummarizer.js +0 -9
  184. package/lib/feature-libraries/forest-summary/forestSummarizer.js.map +1 -1
  185. package/lib/feature-libraries/modular-schema/fieldChangeHandler.d.ts +6 -2
  186. package/lib/feature-libraries/modular-schema/fieldChangeHandler.d.ts.map +1 -1
  187. package/lib/feature-libraries/modular-schema/fieldChangeHandler.js.map +1 -1
  188. package/lib/feature-libraries/modular-schema/genericFieldKind.d.ts +2 -4
  189. package/lib/feature-libraries/modular-schema/genericFieldKind.d.ts.map +1 -1
  190. package/lib/feature-libraries/modular-schema/genericFieldKind.js +4 -19
  191. package/lib/feature-libraries/modular-schema/genericFieldKind.js.map +1 -1
  192. package/lib/feature-libraries/modular-schema/modularChangeFamily.d.ts.map +1 -1
  193. package/lib/feature-libraries/modular-schema/modularChangeFamily.js +17 -19
  194. package/lib/feature-libraries/modular-schema/modularChangeFamily.js.map +1 -1
  195. package/lib/feature-libraries/node-key/mockNodeKeyManager.js +1 -1
  196. package/lib/feature-libraries/node-key/mockNodeKeyManager.js.map +1 -1
  197. package/lib/feature-libraries/optional-field/optionalField.d.ts.map +1 -1
  198. package/lib/feature-libraries/optional-field/optionalField.js +7 -3
  199. package/lib/feature-libraries/optional-field/optionalField.js.map +1 -1
  200. package/lib/feature-libraries/schema-index/schemaSummarizer.d.ts +3 -5
  201. package/lib/feature-libraries/schema-index/schemaSummarizer.d.ts.map +1 -1
  202. package/lib/feature-libraries/schema-index/schemaSummarizer.js +1 -11
  203. package/lib/feature-libraries/schema-index/schemaSummarizer.js.map +1 -1
  204. package/lib/feature-libraries/sequence-field/sequenceFieldEditor.d.ts +1 -1
  205. package/lib/feature-libraries/sequence-field/sequenceFieldEditor.d.ts.map +1 -1
  206. package/lib/feature-libraries/sequence-field/sequenceFieldEditor.js +13 -1
  207. package/lib/feature-libraries/sequence-field/sequenceFieldEditor.js.map +1 -1
  208. package/lib/index.d.ts +3 -3
  209. package/lib/index.d.ts.map +1 -1
  210. package/lib/index.js +3 -3
  211. package/lib/index.js.map +1 -1
  212. package/lib/legacy.d.ts +1 -0
  213. package/lib/packageVersion.d.ts +1 -1
  214. package/lib/packageVersion.d.ts.map +1 -1
  215. package/lib/packageVersion.js +1 -1
  216. package/lib/packageVersion.js.map +1 -1
  217. package/lib/public.d.ts +1 -0
  218. package/lib/shared-tree/index.d.ts +1 -3
  219. package/lib/shared-tree/index.d.ts.map +1 -1
  220. package/lib/shared-tree/index.js +1 -3
  221. package/lib/shared-tree/index.js.map +1 -1
  222. package/lib/shared-tree/schematizingTreeView.d.ts +4 -5
  223. package/lib/shared-tree/schematizingTreeView.d.ts.map +1 -1
  224. package/lib/shared-tree/schematizingTreeView.js +4 -5
  225. package/lib/shared-tree/schematizingTreeView.js.map +1 -1
  226. package/lib/shared-tree/sharedTree.d.ts +40 -39
  227. package/lib/shared-tree/sharedTree.d.ts.map +1 -1
  228. package/lib/shared-tree/sharedTree.js +82 -50
  229. package/lib/shared-tree/sharedTree.js.map +1 -1
  230. package/lib/shared-tree/treeApi.d.ts +2 -2
  231. package/lib/shared-tree/treeApi.d.ts.map +1 -1
  232. package/lib/shared-tree/treeApi.js +8 -2
  233. package/lib/shared-tree/treeApi.js.map +1 -1
  234. package/lib/shared-tree/treeCheckout.d.ts +3 -3
  235. package/lib/shared-tree/treeCheckout.d.ts.map +1 -1
  236. package/lib/shared-tree/treeCheckout.js +4 -3
  237. package/lib/shared-tree/treeCheckout.js.map +1 -1
  238. package/lib/shared-tree-core/editManager.d.ts +11 -2
  239. package/lib/shared-tree-core/editManager.d.ts.map +1 -1
  240. package/lib/shared-tree-core/editManager.js +65 -30
  241. package/lib/shared-tree-core/editManager.js.map +1 -1
  242. package/lib/shared-tree-core/editManagerSummarizer.d.ts +1 -2
  243. package/lib/shared-tree-core/editManagerSummarizer.d.ts.map +1 -1
  244. package/lib/shared-tree-core/editManagerSummarizer.js +0 -9
  245. package/lib/shared-tree-core/editManagerSummarizer.js.map +1 -1
  246. package/lib/shared-tree-core/resubmitMachine.d.ts +2 -0
  247. package/lib/shared-tree-core/resubmitMachine.d.ts.map +1 -1
  248. package/lib/shared-tree-core/resubmitMachine.js.map +1 -1
  249. package/lib/shared-tree-core/sequenceIdUtils.d.ts +12 -1
  250. package/lib/shared-tree-core/sequenceIdUtils.d.ts.map +1 -1
  251. package/lib/shared-tree-core/sequenceIdUtils.js +23 -5
  252. package/lib/shared-tree-core/sequenceIdUtils.js.map +1 -1
  253. package/lib/shared-tree-core/sharedTreeCore.d.ts +33 -30
  254. package/lib/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
  255. package/lib/shared-tree-core/sharedTreeCore.js +61 -55
  256. package/lib/shared-tree-core/sharedTreeCore.js.map +1 -1
  257. package/lib/simple-tree/api/index.d.ts +3 -2
  258. package/lib/simple-tree/api/index.d.ts.map +1 -1
  259. package/lib/simple-tree/api/index.js +1 -0
  260. package/lib/simple-tree/api/index.js.map +1 -1
  261. package/lib/simple-tree/api/schemaFactory.d.ts +156 -63
  262. package/lib/simple-tree/api/schemaFactory.d.ts.map +1 -1
  263. package/lib/simple-tree/api/schemaFactory.js +178 -85
  264. package/lib/simple-tree/api/schemaFactory.js.map +1 -1
  265. package/lib/{shared-tree → simple-tree/api}/transactionTypes.d.ts +1 -1
  266. package/lib/simple-tree/api/transactionTypes.d.ts.map +1 -0
  267. package/lib/{shared-tree → simple-tree/api}/transactionTypes.js.map +1 -1
  268. package/lib/simple-tree/api/tree.d.ts +23 -2
  269. package/lib/simple-tree/api/tree.d.ts.map +1 -1
  270. package/lib/simple-tree/api/tree.js.map +1 -1
  271. package/lib/simple-tree/index.d.ts +1 -1
  272. package/lib/simple-tree/index.d.ts.map +1 -1
  273. package/lib/simple-tree/index.js +1 -1
  274. package/lib/simple-tree/index.js.map +1 -1
  275. package/lib/simple-tree/schemaTypes.d.ts +2 -2
  276. package/lib/simple-tree/schemaTypes.js +1 -1
  277. package/lib/simple-tree/schemaTypes.js.map +1 -1
  278. package/lib/simple-tree/treeNodeValid.js +1 -2
  279. package/lib/simple-tree/treeNodeValid.js.map +1 -1
  280. package/lib/treeFactory.d.ts +16 -5
  281. package/lib/treeFactory.d.ts.map +1 -1
  282. package/lib/treeFactory.js +20 -11
  283. package/lib/treeFactory.js.map +1 -1
  284. package/lib/util/breakable.d.ts +1 -1
  285. package/lib/util/breakable.d.ts.map +1 -1
  286. package/lib/util/breakable.js.map +1 -1
  287. package/lib/util/index.d.ts +1 -1
  288. package/lib/util/index.d.ts.map +1 -1
  289. package/lib/util/index.js +1 -1
  290. package/lib/util/index.js.map +1 -1
  291. package/lib/util/rangeMap.d.ts +1 -1
  292. package/lib/util/rangeMap.js +1 -1
  293. package/lib/util/rangeMap.js.map +1 -1
  294. package/lib/util/utils.d.ts +16 -0
  295. package/lib/util/utils.d.ts.map +1 -1
  296. package/lib/util/utils.js +27 -0
  297. package/lib/util/utils.js.map +1 -1
  298. package/package.json +23 -23
  299. package/src/core/forest/editableForest.ts +1 -1
  300. package/src/core/index.ts +0 -3
  301. package/src/core/tree/anchorSet.ts +38 -221
  302. package/src/core/tree/index.ts +0 -3
  303. package/src/core/tree/pathTree.ts +0 -13
  304. package/src/feature-libraries/default-schema/defaultFieldKinds.ts +1 -1
  305. package/src/feature-libraries/detachedFieldIndexSummarizer.ts +0 -11
  306. package/src/feature-libraries/flex-tree/treeEvents.ts +2 -4
  307. package/src/feature-libraries/forest-summary/forestSummarizer.ts +0 -11
  308. package/src/feature-libraries/modular-schema/fieldChangeHandler.ts +6 -2
  309. package/src/feature-libraries/modular-schema/genericFieldKind.ts +3 -35
  310. package/src/feature-libraries/modular-schema/modularChangeFamily.ts +18 -48
  311. package/src/feature-libraries/optional-field/optionalField.ts +10 -3
  312. package/src/feature-libraries/schema-index/schemaSummarizer.ts +1 -16
  313. package/src/feature-libraries/sequence-field/sequenceFieldEditor.ts +13 -2
  314. package/src/index.ts +15 -12
  315. package/src/packageVersion.ts +1 -1
  316. package/src/shared-tree/index.ts +3 -19
  317. package/src/shared-tree/schematizingTreeView.ts +18 -16
  318. package/src/shared-tree/sharedTree.ts +208 -100
  319. package/src/shared-tree/treeApi.ts +10 -1
  320. package/src/shared-tree/treeCheckout.ts +11 -8
  321. package/src/shared-tree-core/editManager.ts +80 -43
  322. package/src/shared-tree-core/editManagerSummarizer.ts +0 -11
  323. package/src/shared-tree-core/resubmitMachine.ts +2 -0
  324. package/src/shared-tree-core/sequenceIdUtils.ts +26 -5
  325. package/src/shared-tree-core/sharedTreeCore.ts +88 -99
  326. package/src/simple-tree/api/index.ts +15 -0
  327. package/src/simple-tree/api/schemaFactory.ts +203 -89
  328. package/src/{shared-tree → simple-tree/api}/transactionTypes.ts +1 -1
  329. package/src/simple-tree/api/tree.ts +31 -6
  330. package/src/simple-tree/index.ts +12 -0
  331. package/src/simple-tree/schemaTypes.ts +2 -2
  332. package/src/treeFactory.ts +29 -11
  333. package/src/util/breakable.ts +1 -1
  334. package/src/util/index.ts +1 -0
  335. package/src/util/rangeMap.ts +1 -1
  336. package/src/util/utils.ts +32 -0
  337. package/dist/core/tree/visitPath.d.ts +0 -101
  338. package/dist/core/tree/visitPath.d.ts.map +0 -1
  339. package/dist/core/tree/visitPath.js +0 -7
  340. package/dist/core/tree/visitPath.js.map +0 -1
  341. package/dist/shared-tree/publicContracts.d.ts +0 -18
  342. package/dist/shared-tree/publicContracts.d.ts.map +0 -1
  343. package/dist/shared-tree/publicContracts.js +0 -24
  344. package/dist/shared-tree/publicContracts.js.map +0 -1
  345. package/dist/shared-tree/transactionTypes.d.ts.map +0 -1
  346. package/lib/core/tree/visitPath.d.ts +0 -101
  347. package/lib/core/tree/visitPath.d.ts.map +0 -1
  348. package/lib/core/tree/visitPath.js +0 -6
  349. package/lib/core/tree/visitPath.js.map +0 -1
  350. package/lib/shared-tree/publicContracts.d.ts +0 -18
  351. package/lib/shared-tree/publicContracts.d.ts.map +0 -1
  352. package/lib/shared-tree/publicContracts.js +0 -21
  353. package/lib/shared-tree/publicContracts.js.map +0 -1
  354. package/lib/shared-tree/transactionTypes.d.ts.map +0 -1
  355. package/src/core/tree/visitPath.ts +0 -124
  356. package/src/shared-tree/publicContracts.ts +0 -24
  357. /package/dist/{shared-tree → simple-tree/api}/transactionTypes.js +0 -0
  358. /package/lib/{shared-tree → simple-tree/api}/transactionTypes.js +0 -0
@@ -171,6 +171,141 @@ export type ScopedSchemaName<
171
171
  > = TScope extends undefined ? `${TName}` : `${TScope}.${TName}`;
172
172
  // > = `${TScope extends undefined ? "" : `${TScope}.`}${TName}`;
173
173
 
174
+ /**
175
+ * Stateless APIs exposed via {@link SchemaFactory} as both instance properties and as statics.
176
+ * @privateRemarks
177
+ * We have no way to make linkable members which exist both as statics and instance properties since API-Extractor does not support this.
178
+ * As a workaround, we have this type as a third place which can be linked.
179
+ * @system @sealed @public
180
+ */
181
+ export const schemaStatics = {
182
+ /**
183
+ * {@link TreeNodeSchema} for holding a JavaScript `string`.
184
+ *
185
+ * @remarks
186
+ * Strings containing unpaired UTF-16 surrogate pair code units may not be handled correctly.
187
+ *
188
+ * These limitations come from the use of UTF-8 encoding of the strings, which requires them to be valid unicode.
189
+ * JavaScript does not make this requirement for its strings so not all possible JavaScript strings are supported.
190
+ * @privateRemarks
191
+ * TODO:
192
+ * We should be much more clear about what happens if you use problematic values.
193
+ * We should validate and/or normalize them when inserting content.
194
+ */
195
+ string: stringSchema,
196
+
197
+ /**
198
+ * {@link TreeNodeSchema} for holding a JavaScript `number`.
199
+ *
200
+ * @remarks
201
+ * The number is a {@link https://en.wikipedia.org/wiki/Double-precision_floating-point_format | double-precision 64-bit binary format IEEE 754} value, however there are some exceptions:
202
+ * - `NaN`, and the infinities are converted to `null` (and may therefore only be used where `null` is allowed by the schema).
203
+ * - `-0` may be converted to `0` in some cases.
204
+ *
205
+ * These limitations match the limitations of JSON.
206
+ * @privateRemarks
207
+ * TODO:
208
+ * We should be much more clear about what happens if you use problematic values.
209
+ * We should validate and/or normalize them when inserting content.
210
+ */
211
+ number: numberSchema,
212
+
213
+ /**
214
+ * {@link TreeNodeSchema} for holding a boolean.
215
+ */
216
+ boolean: booleanSchema,
217
+
218
+ /**
219
+ * {@link TreeNodeSchema} for JavaScript `null`.
220
+ *
221
+ * @remarks
222
+ * There are good {@link https://www.npmjs.com/package/%40rushstack/eslint-plugin#rushstackno-new-null | reasons to avoid using null} in JavaScript, however sometimes it is desired.
223
+ * This {@link TreeNodeSchema} node provides the option to include nulls in trees when desired.
224
+ * Unless directly inter-operating with existing data using null, consider other approaches, like wrapping the value in an optional field, or using a more specifically named empty object node.
225
+ */
226
+ null: nullSchema,
227
+
228
+ /**
229
+ * {@link TreeNodeSchema} for holding an {@link @fluidframework/core-interfaces#(IFluidHandle:interface)}.
230
+ */
231
+ handle: handleSchema,
232
+
233
+ /**
234
+ * {@link AllowedTypes} for holding any of the leaf types.
235
+ */
236
+ leaves: [stringSchema, numberSchema, booleanSchema, nullSchema, handleSchema],
237
+
238
+ /**
239
+ * Make a field optional instead of the default, which is required.
240
+ *
241
+ * @param t - The types allowed under the field.
242
+ * @param props - Optional properties to associate with the field.
243
+ *
244
+ * @typeParam TCustomMetadata - Custom metadata properties to associate with the field.
245
+ * See {@link FieldSchemaMetadata.custom}.
246
+ */
247
+ optional: <const T extends ImplicitAllowedTypes, const TCustomMetadata = unknown>(
248
+ t: T,
249
+ props?: Omit<FieldProps<TCustomMetadata>, "defaultProvider">,
250
+ ): FieldSchema<FieldKind.Optional, T, TCustomMetadata> => {
251
+ const defaultOptionalProvider: DefaultProvider = getDefaultProvider(() => {
252
+ return undefined;
253
+ });
254
+ return createFieldSchema(FieldKind.Optional, t, {
255
+ defaultProvider: defaultOptionalProvider,
256
+ ...props,
257
+ });
258
+ },
259
+
260
+ /**
261
+ * Make a field explicitly required.
262
+ *
263
+ * @param t - The types allowed under the field.
264
+ * @param props - Optional properties to associate with the field.
265
+ *
266
+ * @remarks
267
+ * Fields are required by default, but this API can be used to make the required nature explicit in the schema,
268
+ * and allows associating custom {@link FieldProps | properties} with the field.
269
+ *
270
+ * @typeParam TCustomMetadata - Custom metadata properties to associate with the field.
271
+ * See {@link FieldSchemaMetadata.custom}.
272
+ */
273
+ required: <const T extends ImplicitAllowedTypes, const TCustomMetadata = unknown>(
274
+ t: T,
275
+ props?: Omit<FieldProps<TCustomMetadata>, "defaultProvider">,
276
+ ): FieldSchema<FieldKind.Required, T, TCustomMetadata> => {
277
+ return createFieldSchema(FieldKind.Required, t, props);
278
+ },
279
+
280
+ /**
281
+ * {@link schemaStatics.optional} except tweaked to work better for recursive types.
282
+ * Use with {@link ValidateRecursiveSchema} for improved type safety.
283
+ * @remarks
284
+ * This version of {@link schemaStatics.optional} has fewer type constraints to work around TypeScript limitations, see {@link Unenforced}.
285
+ * See {@link ValidateRecursiveSchema} for additional information about using recursive schema.
286
+ */
287
+ optionalRecursive: <const T extends Unenforced<ImplicitAllowedTypes>>(
288
+ t: T,
289
+ props?: Omit<FieldProps, "defaultProvider">,
290
+ ): FieldSchemaUnsafe<FieldKind.Optional, T> => {
291
+ return createFieldSchemaUnsafe(FieldKind.Optional, t, props);
292
+ },
293
+
294
+ /**
295
+ * {@link schemaStatics.required} except tweaked to work better for recursive types.
296
+ * Use with {@link ValidateRecursiveSchema} for improved type safety.
297
+ * @remarks
298
+ * This version of {@link schemaStatics.required} has fewer type constraints to work around TypeScript limitations, see {@link Unenforced}.
299
+ * See {@link ValidateRecursiveSchema} for additional information about using recursive schema.
300
+ */
301
+ requiredRecursive: <const T extends Unenforced<ImplicitAllowedTypes>>(
302
+ t: T,
303
+ props?: Omit<FieldProps, "defaultProvider">,
304
+ ): FieldSchemaUnsafe<FieldKind.Required, T> => {
305
+ return createFieldSchemaUnsafe(FieldKind.Required, t, props);
306
+ },
307
+ } as const;
308
+
174
309
  // TODO:
175
310
  // SchemaFactory.array references should link to the correct overloads, however the syntax for this does not seems to work currently for methods unless the they are not qualified with the class.
176
311
  // API-Extractor requires such links to be qualified with the class, so it can't work.
@@ -328,56 +463,65 @@ export class SchemaFactory<
328
463
  }
329
464
 
330
465
  /**
331
- * {@link TreeNodeSchema} for holding a JavaScript `string`.
332
- *
333
- * @remarks
334
- * Strings containing unpaired UTF-16 surrogate pair code units may not be handled correctly.
335
- *
336
- * These limitations come from the use of UTF-8 encoding of the strings, which requires them to be valid unicode.
337
- * JavaScript does not make this requirement for its strings so not all possible JavaScript strings are supported.
338
- * @privateRemarks
339
- * TODO:
340
- * We should be much more clear about what happens if you use problematic values.
341
- * We should validate and/or normalize them when inserting content.
466
+ * {@inheritDoc schemaStatics.string}
342
467
  */
343
468
  public readonly string = stringSchema;
344
469
 
345
470
  /**
346
- * {@link TreeNodeSchema} for holding a JavaScript `number`.
347
- *
348
- * @remarks
349
- * The number is a [double-precision 64-bit binary format IEEE 754](https://en.wikipedia.org/wiki/Double-precision_floating-point_format) value, however there are some exceptions:
350
- * - `NaN`, and the infinities are converted to `null` (and may therefore only be used where `null` is allowed by the schema).
351
- * - `-0` may be converted to `0` in some cases.
352
- *
353
- * These limitations match the limitations of JSON.
354
- * @privateRemarks
355
- * TODO:
356
- * We should be much more clear about what happens if you use problematic values.
357
- * We should validate and/or normalize them when inserting content.
471
+ * {@inheritDoc schemaStatics.number}
358
472
  */
359
473
  public readonly number = numberSchema;
360
474
 
361
475
  /**
362
- * {@link TreeNodeSchema} for holding a boolean.
476
+ * {@inheritDoc schemaStatics.boolean}
363
477
  */
364
478
  public readonly boolean = booleanSchema;
365
479
 
366
480
  /**
367
- * {@link TreeNodeSchema} for JavaScript `null`.
368
- *
369
- * @remarks
370
- * There are good [reasons to avoid using null](https://www.npmjs.com/package/%40rushstack/eslint-plugin#rushstackno-new-null) in JavaScript, however sometimes it is desired.
371
- * This {@link TreeNodeSchema} node provides the option to include nulls in trees when desired.
372
- * Unless directly inter-operating with existing data using null, consider other approaches, like wrapping the value in an optional field, or using a more specifically named empty object node.
481
+ * {@inheritDoc schemaStatics.null}
373
482
  */
374
483
  public readonly null = nullSchema;
375
484
 
376
485
  /**
377
- * {@link TreeNodeSchema} for holding an {@link @fluidframework/core-interfaces#(IFluidHandle:interface)}.
486
+ * {@inheritDoc schemaStatics.handle}
378
487
  */
379
488
  public readonly handle = handleSchema;
380
489
 
490
+ /**
491
+ * {@inheritDoc schemaStatics.leaves}
492
+ */
493
+ public readonly leaves = schemaStatics.leaves;
494
+
495
+ /**
496
+ * {@inheritDoc schemaStatics.string}
497
+ */
498
+ public static readonly string = stringSchema;
499
+
500
+ /**
501
+ * {@inheritDoc schemaStatics.number}
502
+ */
503
+ public static readonly number = numberSchema;
504
+
505
+ /**
506
+ * {@inheritDoc schemaStatics.boolean}
507
+ */
508
+ public static readonly boolean = booleanSchema;
509
+
510
+ /**
511
+ * {@inheritDoc schemaStatics.null}
512
+ */
513
+ public static readonly null = nullSchema;
514
+
515
+ /**
516
+ * {@inheritDoc schemaStatics.handle}
517
+ */
518
+ public static readonly handle = handleSchema;
519
+
520
+ /**
521
+ * {@inheritDoc schemaStatics.leaves}
522
+ */
523
+ public static readonly leaves = schemaStatics.leaves;
524
+
381
525
  /**
382
526
  * Define a {@link TreeNodeSchemaClass} for a {@link TreeObjectNode}.
383
527
  *
@@ -696,74 +840,44 @@ export class SchemaFactory<
696
840
  }
697
841
 
698
842
  /**
699
- * Make a field optional instead of the default, which is required.
700
- *
701
- * @param t - The types allowed under the field.
702
- * @param props - Optional properties to associate with the field.
703
- *
704
- * @typeParam TCustomMetadata - Custom metadata properties to associate with the field.
705
- * See {@link FieldSchemaMetadata.custom}.
843
+ * {@inheritDoc schemaStatics.optional}
706
844
  */
707
- public optional<const T extends ImplicitAllowedTypes, const TCustomMetadata = unknown>(
708
- t: T,
709
- props?: Omit<FieldProps<TCustomMetadata>, "defaultProvider">,
710
- ): FieldSchema<FieldKind.Optional, T, TCustomMetadata> {
711
- const defaultOptionalProvider: DefaultProvider = getDefaultProvider(() => {
712
- return undefined;
713
- });
714
- return createFieldSchema(FieldKind.Optional, t, {
715
- defaultProvider: defaultOptionalProvider,
716
- ...props,
717
- });
718
- }
845
+ public readonly optional = schemaStatics.optional;
719
846
 
720
847
  /**
721
- * Make a field explicitly required.
722
- *
723
- * @param t - The types allowed under the field.
724
- * @param props - Optional properties to associate with the field.
725
- *
726
- * @remarks
727
- * Fields are required by default, but this API can be used to make the required nature explicit in the schema,
728
- * and allows associating custom {@link FieldProps | properties} with the field.
729
- *
730
- * @typeParam TCustomMetadata - Custom metadata properties to associate with the field.
731
- * See {@link FieldSchemaMetadata.custom}.
848
+ * {@inheritDoc schemaStatics.required}
732
849
  */
733
- public required<const T extends ImplicitAllowedTypes, const TCustomMetadata = unknown>(
734
- t: T,
735
- props?: Omit<FieldProps<TCustomMetadata>, "defaultProvider">,
736
- ): FieldSchema<FieldKind.Required, T, TCustomMetadata> {
737
- return createFieldSchema(FieldKind.Required, t, props);
738
- }
850
+ public readonly required = schemaStatics.required;
739
851
 
740
852
  /**
741
- * {@link SchemaFactory.optional} except tweaked to work better for recursive types.
742
- * Use with {@link ValidateRecursiveSchema} for improved type safety.
743
- * @remarks
744
- * This version of {@link SchemaFactory.optional} has fewer type constraints to work around TypeScript limitations, see {@link Unenforced}.
745
- * See {@link ValidateRecursiveSchema} for additional information about using recursive schema.
853
+ * {@inheritDoc schemaStatics.optionalRecursive}
746
854
  */
747
- public optionalRecursive<const T extends Unenforced<ImplicitAllowedTypes>>(
748
- t: T,
749
- props?: Omit<FieldProps, "defaultProvider">,
750
- ): FieldSchemaUnsafe<FieldKind.Optional, T> {
751
- return createFieldSchemaUnsafe(FieldKind.Optional, t, props);
752
- }
855
+ public readonly optionalRecursive = schemaStatics.optionalRecursive;
753
856
 
754
857
  /**
755
- * {@link SchemaFactory.required} except tweaked to work better for recursive types.
756
- * Use with {@link ValidateRecursiveSchema} for improved type safety.
757
- * @remarks
758
- * This version of {@link SchemaFactory.required} has fewer type constraints to work around TypeScript limitations, see {@link Unenforced}.
759
- * See {@link ValidateRecursiveSchema} for additional information about using recursive schema.
858
+ * {@inheritDoc schemaStatics.requiredRecursive}
760
859
  */
761
- public requiredRecursive<const T extends Unenforced<ImplicitAllowedTypes>>(
762
- t: T,
763
- props?: Omit<FieldProps, "defaultProvider">,
764
- ): FieldSchemaUnsafe<FieldKind.Required, T> {
765
- return createFieldSchemaUnsafe(FieldKind.Required, t, props);
766
- }
860
+ public readonly requiredRecursive = schemaStatics.requiredRecursive;
861
+
862
+ /**
863
+ * {@inheritDoc schemaStatics.optional}
864
+ */
865
+ public static readonly optional = schemaStatics.optional;
866
+
867
+ /**
868
+ * {@inheritDoc schemaStatics.required}
869
+ */
870
+ public static readonly required = schemaStatics.required;
871
+
872
+ /**
873
+ * {@inheritDoc schemaStatics.optionalRecursive}
874
+ */
875
+ public static readonly optionalRecursive = schemaStatics.optionalRecursive;
876
+
877
+ /**
878
+ * {@inheritDoc schemaStatics.requiredRecursive}
879
+ */
880
+ public static readonly requiredRecursive = schemaStatics.requiredRecursive;
767
881
 
768
882
  /**
769
883
  * A special field which holds a unique identifier for an object node.
@@ -3,7 +3,7 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
 
6
- import type { TreeNode } from "../simple-tree/index.js";
6
+ import type { TreeNode } from "../core/index.js";
7
7
 
8
8
  /**
9
9
  * A special object that signifies when a SharedTree {@link RunTransaction | transaction} should "roll back".
@@ -13,11 +13,6 @@ import type {
13
13
  } from "../../core/index.js";
14
14
 
15
15
  import type {
16
- RunTransactionParams,
17
- VoidTransactionCallbackStatus,
18
- TransactionCallbackStatus,
19
- TransactionResult,
20
- TransactionResultExt,
21
16
  // This is referenced by doc comments.
22
17
  // eslint-disable-next-line @typescript-eslint/no-unused-vars, unused-imports/no-unused-imports
23
18
  TreeAlpha,
@@ -42,6 +37,15 @@ import { markSchemaMostDerived } from "./schemaFactory.js";
42
37
  import { fail, getOrCreate } from "../../util/index.js";
43
38
  import type { MakeNominal } from "../../util/index.js";
44
39
  import { walkFieldSchema } from "../walkFieldSchema.js";
40
+ import type { VerboseTree } from "./verboseTree.js";
41
+ import type { SimpleTreeSchema } from "./simpleSchema.js";
42
+ import type {
43
+ RunTransactionParams,
44
+ TransactionCallbackStatus,
45
+ TransactionResult,
46
+ TransactionResultExt,
47
+ VoidTransactionCallbackStatus,
48
+ } from "./transactionTypes.js";
45
49
  /**
46
50
  * A tree from which a {@link TreeView} can be created.
47
51
  *
@@ -52,7 +56,6 @@ import { walkFieldSchema } from "../walkFieldSchema.js";
52
56
  * Maybe rename "exportJsonSchema" to align on "concise" terminology.
53
57
  * Ensure schema exporting APIs here align and reference APIs for exporting view schema to the same formats (which should include stored vs property key choice).
54
58
  * Make sure users of independentView can use these export APIs (maybe provide a reference back to the ViewableTree from the TreeView to accomplish that).
55
- * Some of these APIs are on ISharedTree and can get moved here.
56
59
  * @system @sealed @public
57
60
  */
58
61
  export interface ViewableTree {
@@ -101,6 +104,28 @@ export interface ViewableTree {
101
104
  */
102
105
  export interface ITree extends ViewableTree, IFluidLoadable {}
103
106
 
107
+ /**
108
+ * {@link ITree} extended with some alpha APIs.
109
+ * @privateRemarks
110
+ * TODO: Promote this to alpha.
111
+ * @internal
112
+ */
113
+ export interface ITreeAlpha extends ITree {
114
+ /**
115
+ * Exports root in the same format as {@link TreeAlpha.(exportVerbose:1)} using stored keys.
116
+ * @remarks
117
+ * This is `undefined` if and only if the root field is empty (this can only happen if the root field is optional).
118
+ */
119
+ exportVerbose(): VerboseTree | undefined;
120
+
121
+ /**
122
+ * Exports the SimpleTreeSchema that is stored in the tree, using stored keys for object fields.
123
+ * @remarks
124
+ * To get the schema using property keys, use {@link getSimpleSchema} on the view schema.
125
+ */
126
+ exportSimpleSchema(): SimpleTreeSchema;
127
+ }
128
+
104
129
  /**
105
130
  * Options when constructing a tree view.
106
131
  * @public
@@ -124,6 +124,18 @@ export {
124
124
  type CustomTreeNode,
125
125
  type CustomTreeValue,
126
126
  tryStoredSchemaAsArray,
127
+ type schemaStatics,
128
+ type ITreeAlpha,
129
+ type TransactionConstraint,
130
+ type NodeInDocumentConstraint,
131
+ type RunTransactionParams,
132
+ type VoidTransactionCallbackStatus,
133
+ type TransactionCallbackStatus,
134
+ type TransactionResult,
135
+ type TransactionResultExt,
136
+ type TransactionResultSuccess,
137
+ type TransactionResultFailed,
138
+ rollback,
127
139
  } from "./api/index.js";
128
140
  export {
129
141
  type NodeFromSchema,
@@ -281,7 +281,7 @@ export let createFieldSchema: <
281
281
  * including functionality that does not have to be kept consistent across versions or deterministic.
282
282
  *
283
283
  * This can include policy for how to use this schema for "view" purposes, and well as how to expose editing APIs.
284
- * Use {@link SchemaFactory} to create the FieldSchema instances, for example {@link SchemaFactory.optional}.
284
+ * Use {@link SchemaFactory} to create the FieldSchema instances, for example {@link schemaStatics.optional}.
285
285
  * @privateRemarks
286
286
  * Public access to the constructor is removed to prevent creating expressible but unsupported (or not stable) configurations.
287
287
  * {@link createFieldSchema} can be used internally to create instances.
@@ -822,7 +822,7 @@ export type NodeBuilderData<T extends TreeNodeSchemaCore<string, NodeKind, boole
822
822
  /**
823
823
  * Value that may be stored as a leaf node.
824
824
  * @remarks
825
- * Some limitations apply, see the documentation for {@link SchemaFactory.number} and {@link SchemaFactory.string} for those restrictions.
825
+ * Some limitations apply, see the documentation for {@link schemaStatics.number} and {@link schemaStatics.string} for those restrictions.
826
826
  * @public
827
827
  */
828
828
  // eslint-disable-next-line @rushstack/no-new-null
@@ -15,25 +15,43 @@ import {
15
15
  createSharedObjectKind,
16
16
  } from "@fluidframework/shared-object-base/internal";
17
17
 
18
- import { pkgVersion } from "./packageVersion.js";
19
- import { SharedTree as SharedTreeImpl, type SharedTreeOptions } from "./shared-tree/index.js";
18
+ import {
19
+ SharedTree as SharedTreeImpl,
20
+ type SharedTreeOptions,
21
+ type SharedTreeOptionsInternal,
22
+ } from "./shared-tree/index.js";
20
23
  import type { ITree } from "./simple-tree/index.js";
21
24
 
25
+ import { pkgVersion } from "./packageVersion.js";
26
+
27
+ /**
28
+ * {@inheritDoc @fluidframework/shared-object-base#ISharedObjectFactory."type"}
29
+ * @alpha
30
+ * @legacy
31
+ */
32
+ export const SharedTreeFactoryType = "https://graph.microsoft.com/types/tree";
33
+
34
+ /**
35
+ * {@inheritDoc @fluidframework/shared-object-base#ISharedObjectFactory.attributes}
36
+ * @alpha
37
+ * @legacy
38
+ */
39
+ export const SharedTreeAttributes: IChannelAttributes = {
40
+ type: SharedTreeFactoryType,
41
+ snapshotFormatVersion: "0.0.0",
42
+ packageVersion: pkgVersion,
43
+ };
44
+
22
45
  /**
23
46
  * A channel factory that creates an {@link ITree}.
24
47
  */
25
48
  export class TreeFactory implements IChannelFactory<ITree> {
26
- public static readonly Type = "https://graph.microsoft.com/types/tree";
27
- public static readonly attributes: IChannelAttributes = {
28
- type: this.Type,
29
- snapshotFormatVersion: "0.0.0",
30
- packageVersion: pkgVersion,
31
- };
49
+ public static Type: string = SharedTreeFactoryType;
50
+ public readonly type: string = SharedTreeFactoryType;
32
51
 
33
- public readonly type = TreeFactory.Type;
34
- public readonly attributes: IChannelAttributes = TreeFactory.attributes;
52
+ public readonly attributes: IChannelAttributes = SharedTreeAttributes;
35
53
 
36
- public constructor(private readonly options: SharedTreeOptions) {}
54
+ public constructor(private readonly options: SharedTreeOptionsInternal) {}
37
55
 
38
56
  public async load(
39
57
  runtime: IFluidDataStoreRuntime,
@@ -47,7 +47,7 @@ export class Breakable {
47
47
  * @privateRemarks
48
48
  * If there is a use-case, this should be made public.
49
49
  */
50
- private rethrowCaught(brokenBy: unknown): never {
50
+ public rethrowCaught(brokenBy: unknown): never {
51
51
  if (brokenBy instanceof Error) {
52
52
  this.break(brokenBy);
53
53
  }
package/src/util/index.ts CHANGED
@@ -56,6 +56,7 @@ export type {
56
56
  export { StackyIterator } from "./stackyIterator.js";
57
57
  export {
58
58
  asMutable,
59
+ balancedReduce,
59
60
  clone,
60
61
  compareSets,
61
62
  fail,
@@ -61,7 +61,7 @@ export class RangeMap<K, V> {
61
61
  * Retrieves the values for all keys in the query range.
62
62
  *
63
63
  * @param start - The first key in the range being queried
64
- * @param length - The length of the query range
64
+ * @param length - The length of the query range
65
65
  * @returns A list of entries, each describing the value for some subrange of the query.
66
66
  * The entries are in the same order as the keys, and there is an entry for every key with a non `undefined` value.
67
67
  */
package/src/util/utils.ts CHANGED
@@ -616,3 +616,35 @@ export function copyPropertyIfDefined<
616
616
  }
617
617
  }
618
618
  }
619
+
620
+ /**
621
+ * Reduces an array of values into a single value.
622
+ * This is similar to `Array.prototype.reduce`,
623
+ * except that it recursively reduces the left and right halves of the input before reducing their respective reductions.
624
+ *
625
+ * When compared with an approach like reducing all the values left-to-right,
626
+ * this balanced approach is beneficial when the cost of invoking `callbackFn` is proportional to the number reduced values that its parameters collectively represent.
627
+ * For example, if `T` is an array, and `callbackFn` concatenates its inputs,
628
+ * then `balancedReduce` will have O(N*log(N)) time complexity instead of `Array.prototype.reduce`'s O(N²).
629
+ * However, if `callbackFn` is O(1) then both `balancedReduce` and `Array.prototype.reduce` will have O(N) complexity.
630
+ *
631
+ * @param array - The array to reduce.
632
+ * @param callbackFn - The function to execute for each pairwise reduction.
633
+ * @param emptyCase - A factory function that provides the value to return if the input array is empty.
634
+ */
635
+ export function balancedReduce<T>(
636
+ array: readonly T[],
637
+ callbackFn: (left: T, right: T) => T,
638
+ emptyCase: () => T,
639
+ ): T {
640
+ if (hasSingle(array)) {
641
+ return array[0];
642
+ }
643
+ if (!hasSome(array)) {
644
+ return emptyCase();
645
+ }
646
+ const mid = Math.floor(array.length / 2);
647
+ const left = balancedReduce(array.slice(0, mid), callbackFn, emptyCase);
648
+ const right = balancedReduce(array.slice(mid), callbackFn, emptyCase);
649
+ return callbackFn(left, right);
650
+ }
@@ -1,101 +0,0 @@
1
- /*!
2
- * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
- * Licensed under the MIT License.
4
- */
5
- import type { ProtoNodes } from "./delta.js";
6
- import type { DetachedPlaceUpPath, DetachedRangeUpPath, PlaceUpPath, RangeUpPath, UpPath } from "./pathTree.js";
7
- /**
8
- * Delta visitor for the path tree.
9
- *
10
- * For any of these events, the paths are guaranteed to be valid at the time of the event,
11
- * and it is valid to read from the Forest at that path.
12
- */
13
- export interface PathVisitor {
14
- /**
15
- * Invoked after the creation of a range of nodes.
16
- * @param content - The content that was created.
17
- */
18
- afterCreate(content: DetachedRangeUpPath): void;
19
- /**
20
- * Invoked before the attaching of a range of nodes.
21
- * Not invoked for replacements.
22
- * @param source - The content that will be attached.
23
- * @param destination - The location where the content will be attached.
24
- * @param kind - The kind of replacement that will occur.
25
- */
26
- beforeAttach(source: DetachedRangeUpPath, destination: PlaceUpPath): void;
27
- /**
28
- * Invoked after the attaching of a range of nodes.
29
- * Not invoked for replacements.
30
- * @param source - The location where the content originated.
31
- * @param destination - The content that was attached.
32
- * @param kind - The kind of replacement that will occur.
33
- */
34
- afterAttach(source: DetachedPlaceUpPath, destination: RangeUpPath): void;
35
- /**
36
- * Invoked before the detaching of a range of nodes.
37
- * Not invoked for replacements.
38
- * @param source - The content that will be detached.
39
- * @param destination - The location where the content will be sent to.
40
- * @param kind - The kind of replacement that will occur.
41
- */
42
- beforeDetach(source: RangeUpPath, destination: DetachedPlaceUpPath): void;
43
- /**
44
- * Invoked after the detaching of a range of nodes.
45
- * Not invoked for replacements.
46
- * @param source - The content that was detached.
47
- * @param destination - The location where the content will be attached.
48
- * @param kind - The kind of replacement that will occur.
49
- */
50
- afterDetach(source: PlaceUpPath, destination: DetachedRangeUpPath): void;
51
- /**
52
- * Invoked before the replacement of a range of nodes.
53
- *
54
- * Note that the `newContent` range length will always match the `oldContent` range length.
55
- * A replace might actually be separate detaches and attaches which have been coalesced.
56
- *
57
- * @param newContent - The content that will be attached in place of the old.
58
- * @param oldContent - The old that will be replaced.
59
- * @param oldContentDestination - The destination of the old content.
60
- * @param kind - The kind of replacement that will occur.
61
- */
62
- beforeReplace(newContent: DetachedRangeUpPath, oldContent: RangeUpPath, oldContentDestination: DetachedPlaceUpPath): void;
63
- /**
64
- * Invoked after the replacement of a range of nodes.
65
- *
66
- * Note that the `newContent` range length will always match the `oldContent` range length.
67
- * A replace might actually be separate detaches and attaches which have been coalesced.
68
- *
69
- * @param newContentSource - The place that the new content came from.
70
- * @param newContent - The new content.
71
- * @param oldContent - The content that was replaced.
72
- */
73
- afterReplace(newContentSource: DetachedPlaceUpPath, newContent: RangeUpPath, oldContent: DetachedRangeUpPath): void;
74
- /**
75
- * Invoked before content is destroyed.
76
- * @param content - The content that will be destroyed
77
- */
78
- beforeDestroy(content: DetachedRangeUpPath): void;
79
- /**
80
- * A sequence of nodes of length `count` is being removed starting with `path`.
81
- * Called when these nodes are no longer parented under their previous parent, and do not have a new parent.
82
- * It is possible they may be restored in the future (for example by a conflicted merge or undo).
83
- *
84
- * Not called for children of removed nodes.
85
- *
86
- * @param path - first node in the removed range.
87
- * @param count - length of removed range.
88
- *
89
- * @deprecated Migrate to using the other events.
90
- */
91
- onRemove(path: UpPath, count: number): void;
92
- /**
93
- * @param path - location which first node of inserted range will have after insert.
94
- * Any nodes at this index (or after it) will be moved to the right (have their indexes increased by `content.length`).
95
- * @param content - content which is being inserted.
96
- *
97
- * @deprecated Migrate to using the other events.
98
- */
99
- onInsert(path: UpPath, content: ProtoNodes): void;
100
- }
101
- //# sourceMappingURL=visitPath.d.ts.map