@fluidframework/tree 2.3.0-288113 → 2.4.0-294316

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 (900) hide show
  1. package/.dependency-cruiser-known-violations.json +28 -40
  2. package/.vscode/Tree.code-workspace +0 -2
  3. package/CHANGELOG.md +92 -0
  4. package/README.md +6 -0
  5. package/alpha.d.ts +11 -0
  6. package/api-extractor/api-extractor-lint-alpha.cjs.json +5 -0
  7. package/api-extractor/api-extractor-lint-alpha.esm.json +5 -0
  8. package/api-extractor/api-extractor-lint-legacy.cjs.json +5 -0
  9. package/api-extractor/api-extractor-lint-legacy.esm.json +5 -0
  10. package/api-extractor/api-extractor.current.json +8 -0
  11. package/api-extractor/api-extractor.legacy.json +4 -0
  12. package/api-extractor.json +1 -1
  13. package/api-report/tree.alpha.api.md +42 -54
  14. package/api-report/tree.beta.api.md +35 -16
  15. package/api-report/tree.legacy.alpha.api.md +571 -0
  16. package/api-report/tree.legacy.public.api.md +568 -0
  17. package/api-report/tree.public.api.md +22 -18
  18. package/dist/alpha.d.ts +103 -0
  19. package/dist/beta.d.ts +7 -2
  20. package/dist/core/index.d.ts +2 -2
  21. package/dist/core/index.d.ts.map +1 -1
  22. package/dist/core/index.js +4 -3
  23. package/dist/core/index.js.map +1 -1
  24. package/dist/core/rebase/index.d.ts +1 -1
  25. package/dist/core/rebase/index.d.ts.map +1 -1
  26. package/dist/core/rebase/index.js +2 -1
  27. package/dist/core/rebase/index.js.map +1 -1
  28. package/dist/core/rebase/types.d.ts +1 -0
  29. package/dist/core/rebase/types.d.ts.map +1 -1
  30. package/dist/core/rebase/types.js +8 -1
  31. package/dist/core/rebase/types.js.map +1 -1
  32. package/dist/core/{revertible/revertible.d.ts → revertible.d.ts} +12 -0
  33. package/dist/core/revertible.d.ts.map +1 -0
  34. package/dist/core/revertible.js.map +1 -0
  35. package/dist/core/schema-stored/format.d.ts +3 -3
  36. package/dist/core/schema-stored/format.js +1 -1
  37. package/dist/core/schema-stored/format.js.map +1 -1
  38. package/dist/core/schema-stored/schema.d.ts +2 -7
  39. package/dist/core/schema-stored/schema.d.ts.map +1 -1
  40. package/dist/core/schema-stored/schema.js +4 -6
  41. package/dist/core/schema-stored/schema.js.map +1 -1
  42. package/dist/core/schema-stored/storedSchemaRepository.d.ts +1 -1
  43. package/dist/core/schema-stored/storedSchemaRepository.d.ts.map +1 -1
  44. package/dist/core/tree/anchorSet.d.ts.map +1 -1
  45. package/dist/core/tree/anchorSet.js +6 -2
  46. package/dist/core/tree/anchorSet.js.map +1 -1
  47. package/dist/core/tree/detachedFieldIndex.d.ts +0 -1
  48. package/dist/core/tree/detachedFieldIndex.d.ts.map +1 -1
  49. package/dist/core/tree/detachedFieldIndex.js +1 -0
  50. package/dist/core/tree/detachedFieldIndex.js.map +1 -1
  51. package/dist/core/tree/visitDelta.d.ts +7 -2
  52. package/dist/core/tree/visitDelta.d.ts.map +1 -1
  53. package/dist/core/tree/visitDelta.js.map +1 -1
  54. package/dist/events/emitter.d.ts +127 -0
  55. package/dist/events/emitter.d.ts.map +1 -0
  56. package/dist/events/{events.js → emitter.js} +48 -30
  57. package/dist/events/emitter.js.map +1 -0
  58. package/dist/events/index.d.ts +2 -1
  59. package/dist/events/index.d.ts.map +1 -1
  60. package/dist/events/index.js +4 -5
  61. package/dist/events/index.js.map +1 -1
  62. package/dist/events/interop.d.ts +36 -0
  63. package/dist/events/interop.d.ts.map +1 -0
  64. package/dist/{core/revertible/index.d.ts → events/interop.js} +3 -2
  65. package/dist/events/interop.js.map +1 -0
  66. package/dist/events/listeners.d.ts +65 -0
  67. package/dist/events/listeners.d.ts.map +1 -0
  68. package/{lib/core/revertible/index.d.ts → dist/events/listeners.js} +3 -2
  69. package/dist/events/listeners.js.map +1 -0
  70. package/dist/feature-libraries/chunked-forest/chunkTree.d.ts +25 -7
  71. package/dist/feature-libraries/chunked-forest/chunkTree.d.ts.map +1 -1
  72. package/dist/feature-libraries/chunked-forest/chunkTree.js +36 -15
  73. package/dist/feature-libraries/chunked-forest/chunkTree.js.map +1 -1
  74. package/dist/feature-libraries/chunked-forest/chunkedForest.d.ts +4 -2
  75. package/dist/feature-libraries/chunked-forest/chunkedForest.d.ts.map +1 -1
  76. package/dist/feature-libraries/chunked-forest/chunkedForest.js +12 -5
  77. package/dist/feature-libraries/chunked-forest/chunkedForest.js.map +1 -1
  78. package/dist/feature-libraries/chunked-forest/uniformChunk.d.ts +15 -2
  79. package/dist/feature-libraries/chunked-forest/uniformChunk.d.ts.map +1 -1
  80. package/dist/feature-libraries/chunked-forest/uniformChunk.js +28 -2
  81. package/dist/feature-libraries/chunked-forest/uniformChunk.js.map +1 -1
  82. package/dist/feature-libraries/default-schema/defaultEditBuilder.d.ts +3 -1
  83. package/dist/feature-libraries/default-schema/defaultEditBuilder.d.ts.map +1 -1
  84. package/dist/feature-libraries/default-schema/defaultEditBuilder.js +5 -4
  85. package/dist/feature-libraries/default-schema/defaultEditBuilder.js.map +1 -1
  86. package/dist/feature-libraries/flex-map-tree/index.d.ts +1 -1
  87. package/dist/feature-libraries/flex-map-tree/index.d.ts.map +1 -1
  88. package/dist/feature-libraries/flex-map-tree/index.js +2 -1
  89. package/dist/feature-libraries/flex-map-tree/index.js.map +1 -1
  90. package/dist/feature-libraries/flex-map-tree/mapTreeNode.d.ts +35 -33
  91. package/dist/feature-libraries/flex-map-tree/mapTreeNode.d.ts.map +1 -1
  92. package/dist/feature-libraries/flex-map-tree/mapTreeNode.js +82 -103
  93. package/dist/feature-libraries/flex-map-tree/mapTreeNode.js.map +1 -1
  94. package/dist/feature-libraries/flex-tree/context.d.ts +30 -14
  95. package/dist/feature-libraries/flex-tree/context.d.ts.map +1 -1
  96. package/dist/feature-libraries/flex-tree/context.js +10 -7
  97. package/dist/feature-libraries/flex-tree/context.js.map +1 -1
  98. package/dist/feature-libraries/flex-tree/flexTreeTypes.d.ts +57 -190
  99. package/dist/feature-libraries/flex-tree/flexTreeTypes.d.ts.map +1 -1
  100. package/dist/feature-libraries/flex-tree/flexTreeTypes.js +15 -3
  101. package/dist/feature-libraries/flex-tree/flexTreeTypes.js.map +1 -1
  102. package/dist/feature-libraries/flex-tree/index.d.ts +2 -3
  103. package/dist/feature-libraries/flex-tree/index.d.ts.map +1 -1
  104. package/dist/feature-libraries/flex-tree/index.js.map +1 -1
  105. package/dist/feature-libraries/flex-tree/lazyEntity.d.ts +3 -3
  106. package/dist/feature-libraries/flex-tree/lazyEntity.d.ts.map +1 -1
  107. package/dist/feature-libraries/flex-tree/lazyEntity.js +2 -10
  108. package/dist/feature-libraries/flex-tree/lazyEntity.js.map +1 -1
  109. package/dist/feature-libraries/flex-tree/lazyField.d.ts +26 -28
  110. package/dist/feature-libraries/flex-tree/lazyField.d.ts.map +1 -1
  111. package/dist/feature-libraries/flex-tree/lazyField.js +11 -14
  112. package/dist/feature-libraries/flex-tree/lazyField.js.map +1 -1
  113. package/dist/feature-libraries/flex-tree/lazyNode.d.ts +5 -26
  114. package/dist/feature-libraries/flex-tree/lazyNode.d.ts.map +1 -1
  115. package/dist/feature-libraries/flex-tree/lazyNode.js +23 -74
  116. package/dist/feature-libraries/flex-tree/lazyNode.js.map +1 -1
  117. package/dist/feature-libraries/flex-tree/unboxed.d.ts +4 -16
  118. package/dist/feature-libraries/flex-tree/unboxed.d.ts.map +1 -1
  119. package/dist/feature-libraries/flex-tree/unboxed.js +7 -41
  120. package/dist/feature-libraries/flex-tree/unboxed.js.map +1 -1
  121. package/dist/feature-libraries/flex-tree/utilities.d.ts +2 -2
  122. package/dist/feature-libraries/flex-tree/utilities.d.ts.map +1 -1
  123. package/dist/feature-libraries/flex-tree/utilities.js +3 -6
  124. package/dist/feature-libraries/flex-tree/utilities.js.map +1 -1
  125. package/dist/feature-libraries/forest-summary/forestSummarizer.d.ts.map +1 -1
  126. package/dist/feature-libraries/forest-summary/forestSummarizer.js +4 -1
  127. package/dist/feature-libraries/forest-summary/forestSummarizer.js.map +1 -1
  128. package/dist/feature-libraries/index.d.ts +3 -5
  129. package/dist/feature-libraries/index.d.ts.map +1 -1
  130. package/dist/feature-libraries/index.js +5 -11
  131. package/dist/feature-libraries/index.js.map +1 -1
  132. package/dist/feature-libraries/modular-schema/comparison.d.ts.map +1 -1
  133. package/dist/feature-libraries/modular-schema/comparison.js +3 -6
  134. package/dist/feature-libraries/modular-schema/comparison.js.map +1 -1
  135. package/dist/feature-libraries/modular-schema/discrepancies.d.ts.map +1 -1
  136. package/dist/feature-libraries/modular-schema/discrepancies.js +3 -13
  137. package/dist/feature-libraries/modular-schema/discrepancies.js.map +1 -1
  138. package/dist/feature-libraries/modular-schema/modularChangeCodecs.js +4 -1
  139. package/dist/feature-libraries/modular-schema/modularChangeCodecs.js.map +1 -1
  140. package/dist/feature-libraries/modular-schema/modularChangeFamily.d.ts +9 -1
  141. package/dist/feature-libraries/modular-schema/modularChangeFamily.d.ts.map +1 -1
  142. package/dist/feature-libraries/modular-schema/modularChangeFamily.js +73 -22
  143. package/dist/feature-libraries/modular-schema/modularChangeFamily.js.map +1 -1
  144. package/dist/feature-libraries/schema-edits/schemaChangeFormat.d.ts +6 -6
  145. package/dist/feature-libraries/schema-index/format.d.ts +3 -3
  146. package/dist/feature-libraries/sequence-field/compose.d.ts.map +1 -1
  147. package/dist/feature-libraries/sequence-field/compose.js +3 -0
  148. package/dist/feature-libraries/sequence-field/compose.js.map +1 -1
  149. package/dist/feature-libraries/sequence-field/utils.d.ts.map +1 -1
  150. package/dist/feature-libraries/sequence-field/utils.js +1 -4
  151. package/dist/feature-libraries/sequence-field/utils.js.map +1 -1
  152. package/dist/feature-libraries/storedToViewSchema.d.ts.map +1 -1
  153. package/dist/feature-libraries/storedToViewSchema.js +2 -4
  154. package/dist/feature-libraries/storedToViewSchema.js.map +1 -1
  155. package/dist/feature-libraries/typed-schema/flexList.d.ts +3 -3
  156. package/dist/feature-libraries/typed-schema/flexList.js.map +1 -1
  157. package/dist/feature-libraries/typed-schema/index.d.ts +2 -2
  158. package/dist/feature-libraries/typed-schema/index.d.ts.map +1 -1
  159. package/dist/feature-libraries/typed-schema/index.js +2 -2
  160. package/dist/feature-libraries/typed-schema/index.js.map +1 -1
  161. package/dist/feature-libraries/typed-schema/schemaCollection.d.ts.map +1 -1
  162. package/dist/feature-libraries/typed-schema/schemaCollection.js +8 -10
  163. package/dist/feature-libraries/typed-schema/schemaCollection.js.map +1 -1
  164. package/dist/feature-libraries/typed-schema/typedTreeSchema.d.ts +17 -48
  165. package/dist/feature-libraries/typed-schema/typedTreeSchema.d.ts.map +1 -1
  166. package/dist/feature-libraries/typed-schema/typedTreeSchema.js +5 -37
  167. package/dist/feature-libraries/typed-schema/typedTreeSchema.js.map +1 -1
  168. package/dist/feature-libraries/typed-schema/view.d.ts +4 -6
  169. package/dist/feature-libraries/typed-schema/view.d.ts.map +1 -1
  170. package/dist/feature-libraries/typed-schema/view.js +5 -4
  171. package/dist/feature-libraries/typed-schema/view.js.map +1 -1
  172. package/dist/index.d.ts +4 -4
  173. package/dist/index.d.ts.map +1 -1
  174. package/dist/index.js +33 -36
  175. package/dist/index.js.map +1 -1
  176. package/dist/legacy.d.ts +84 -0
  177. package/dist/packageVersion.d.ts +1 -1
  178. package/dist/packageVersion.js +1 -1
  179. package/dist/packageVersion.js.map +1 -1
  180. package/dist/public.d.ts +1 -1
  181. package/dist/shared-tree/checkoutFlexTreeView.d.ts +53 -0
  182. package/dist/shared-tree/checkoutFlexTreeView.d.ts.map +1 -0
  183. package/dist/shared-tree/{treeView.js → checkoutFlexTreeView.js} +28 -6
  184. package/dist/shared-tree/checkoutFlexTreeView.js.map +1 -0
  185. package/dist/shared-tree/index.d.ts +3 -3
  186. package/dist/shared-tree/index.d.ts.map +1 -1
  187. package/dist/shared-tree/index.js +2 -2
  188. package/dist/shared-tree/index.js.map +1 -1
  189. package/dist/shared-tree/schematizeTree.d.ts +15 -4
  190. package/dist/shared-tree/schematizeTree.d.ts.map +1 -1
  191. package/dist/shared-tree/schematizeTree.js +7 -8
  192. package/dist/shared-tree/schematizeTree.js.map +1 -1
  193. package/dist/shared-tree/schematizingTreeView.d.ts +10 -4
  194. package/dist/shared-tree/schematizingTreeView.d.ts.map +1 -1
  195. package/dist/shared-tree/schematizingTreeView.js +28 -12
  196. package/dist/shared-tree/schematizingTreeView.js.map +1 -1
  197. package/dist/shared-tree/sharedTree.d.ts.map +1 -1
  198. package/dist/shared-tree/sharedTree.js +2 -2
  199. package/dist/shared-tree/sharedTree.js.map +1 -1
  200. package/dist/shared-tree/sharedTreeChangeEnricher.d.ts +3 -1
  201. package/dist/shared-tree/sharedTreeChangeEnricher.d.ts.map +1 -1
  202. package/dist/shared-tree/sharedTreeChangeEnricher.js +6 -2
  203. package/dist/shared-tree/sharedTreeChangeEnricher.js.map +1 -1
  204. package/dist/shared-tree/sharedTreeChangeFamily.d.ts +3 -1
  205. package/dist/shared-tree/sharedTreeChangeFamily.d.ts.map +1 -1
  206. package/dist/shared-tree/sharedTreeChangeFamily.js +3 -2
  207. package/dist/shared-tree/sharedTreeChangeFamily.js.map +1 -1
  208. package/dist/shared-tree/sharedTreeEditBuilder.d.ts +2 -1
  209. package/dist/shared-tree/sharedTreeEditBuilder.d.ts.map +1 -1
  210. package/dist/shared-tree/sharedTreeEditBuilder.js +2 -2
  211. package/dist/shared-tree/sharedTreeEditBuilder.js.map +1 -1
  212. package/dist/shared-tree/treeApi.d.ts +1 -3
  213. package/dist/shared-tree/treeApi.d.ts.map +1 -1
  214. package/dist/shared-tree/treeApi.js +6 -4
  215. package/dist/shared-tree/treeApi.js.map +1 -1
  216. package/dist/shared-tree/treeCheckout.d.ts +2 -13
  217. package/dist/shared-tree/treeCheckout.d.ts.map +1 -1
  218. package/dist/shared-tree/treeCheckout.js +17 -1
  219. package/dist/shared-tree/treeCheckout.js.map +1 -1
  220. package/dist/shared-tree-core/branch.js +1 -1
  221. package/dist/shared-tree-core/branch.js.map +1 -1
  222. package/dist/simple-tree/api/create.d.ts.map +1 -1
  223. package/dist/simple-tree/api/create.js +1 -1
  224. package/dist/simple-tree/api/create.js.map +1 -1
  225. package/{lib/simple-tree → dist/simple-tree/api}/getJsonSchema.d.ts +1 -1
  226. package/dist/simple-tree/api/getJsonSchema.d.ts.map +1 -0
  227. package/dist/simple-tree/{getJsonSchema.js → api/getJsonSchema.js} +1 -1
  228. package/dist/simple-tree/api/getJsonSchema.js.map +1 -0
  229. package/{lib/simple-tree → dist/simple-tree/api}/getSimpleSchema.d.ts +1 -1
  230. package/dist/simple-tree/api/getSimpleSchema.d.ts.map +1 -0
  231. package/dist/simple-tree/{getSimpleSchema.js → api/getSimpleSchema.js} +1 -1
  232. package/dist/simple-tree/api/getSimpleSchema.js.map +1 -0
  233. package/dist/simple-tree/api/index.d.ts +5 -0
  234. package/dist/simple-tree/api/index.d.ts.map +1 -1
  235. package/dist/simple-tree/api/index.js +7 -1
  236. package/dist/simple-tree/api/index.js.map +1 -1
  237. package/{lib/simple-tree → dist/simple-tree/api}/jsonSchema.d.ts +14 -15
  238. package/dist/simple-tree/api/jsonSchema.d.ts.map +1 -0
  239. package/dist/simple-tree/api/jsonSchema.js.map +1 -0
  240. package/dist/simple-tree/api/schemaFactory.d.ts +53 -16
  241. package/dist/simple-tree/api/schemaFactory.d.ts.map +1 -1
  242. package/dist/simple-tree/api/schemaFactory.js +49 -12
  243. package/dist/simple-tree/api/schemaFactory.js.map +1 -1
  244. package/dist/simple-tree/{simpleSchema.d.ts → api/simpleSchema.d.ts} +8 -4
  245. package/dist/simple-tree/api/simpleSchema.d.ts.map +1 -0
  246. package/dist/simple-tree/api/simpleSchema.js.map +1 -0
  247. package/dist/simple-tree/api/simpleSchemaToJsonSchema.d.ts.map +1 -0
  248. package/dist/simple-tree/{simpleSchemaToJsonSchema.js → api/simpleSchemaToJsonSchema.js} +34 -21
  249. package/dist/simple-tree/api/simpleSchemaToJsonSchema.js.map +1 -0
  250. package/dist/simple-tree/api/tree.d.ts +5 -21
  251. package/dist/simple-tree/api/tree.d.ts.map +1 -1
  252. package/dist/simple-tree/api/tree.js +3 -38
  253. package/dist/simple-tree/api/tree.js.map +1 -1
  254. package/dist/simple-tree/api/treeApiBeta.d.ts +79 -0
  255. package/dist/simple-tree/api/treeApiBeta.d.ts.map +1 -0
  256. package/dist/simple-tree/api/treeApiBeta.js +26 -0
  257. package/dist/simple-tree/api/treeApiBeta.js.map +1 -0
  258. package/dist/simple-tree/api/treeNodeApi.d.ts +1 -1
  259. package/dist/simple-tree/api/treeNodeApi.d.ts.map +1 -1
  260. package/dist/simple-tree/api/treeNodeApi.js +21 -19
  261. package/dist/simple-tree/api/treeNodeApi.js.map +1 -1
  262. package/dist/simple-tree/api/verboseTree.js +2 -2
  263. package/dist/simple-tree/api/verboseTree.js.map +1 -1
  264. package/dist/simple-tree/{viewSchemaToSimpleSchema.d.ts → api/viewSchemaToSimpleSchema.d.ts} +1 -1
  265. package/dist/simple-tree/api/viewSchemaToSimpleSchema.d.ts.map +1 -0
  266. package/dist/simple-tree/{viewSchemaToSimpleSchema.js → api/viewSchemaToSimpleSchema.js} +8 -4
  267. package/dist/simple-tree/api/viewSchemaToSimpleSchema.js.map +1 -0
  268. package/dist/simple-tree/arrayNode.d.ts +2 -2
  269. package/dist/simple-tree/arrayNode.d.ts.map +1 -1
  270. package/dist/simple-tree/arrayNode.js +30 -21
  271. package/dist/simple-tree/arrayNode.js.map +1 -1
  272. package/dist/simple-tree/core/index.d.ts +3 -3
  273. package/dist/simple-tree/core/index.d.ts.map +1 -1
  274. package/dist/simple-tree/core/index.js +4 -1
  275. package/dist/simple-tree/core/index.js.map +1 -1
  276. package/dist/simple-tree/core/schemaCaching.d.ts +5 -0
  277. package/dist/simple-tree/core/schemaCaching.d.ts.map +1 -1
  278. package/dist/simple-tree/core/schemaCaching.js +10 -1
  279. package/dist/simple-tree/core/schemaCaching.js.map +1 -1
  280. package/dist/simple-tree/core/treeNodeKernel.d.ts +61 -3
  281. package/dist/simple-tree/core/treeNodeKernel.d.ts.map +1 -1
  282. package/dist/simple-tree/core/treeNodeKernel.js +166 -13
  283. package/dist/simple-tree/core/treeNodeKernel.js.map +1 -1
  284. package/dist/simple-tree/core/treeNodeSchema.d.ts +1 -1
  285. package/dist/simple-tree/core/treeNodeSchema.js.map +1 -1
  286. package/dist/simple-tree/core/types.d.ts +17 -20
  287. package/dist/simple-tree/core/types.d.ts.map +1 -1
  288. package/dist/simple-tree/core/types.js.map +1 -1
  289. package/dist/simple-tree/core/withType.d.ts +3 -2
  290. package/dist/simple-tree/core/withType.d.ts.map +1 -1
  291. package/dist/simple-tree/core/withType.js.map +1 -1
  292. package/dist/simple-tree/index.d.ts +8 -10
  293. package/dist/simple-tree/index.d.ts.map +1 -1
  294. package/dist/simple-tree/index.js +15 -6
  295. package/dist/simple-tree/index.js.map +1 -1
  296. package/dist/simple-tree/leafNodeSchema.d.ts +7 -9
  297. package/dist/simple-tree/leafNodeSchema.d.ts.map +1 -1
  298. package/dist/simple-tree/leafNodeSchema.js +13 -11
  299. package/dist/simple-tree/leafNodeSchema.js.map +1 -1
  300. package/dist/simple-tree/mapNode.d.ts +1 -1
  301. package/dist/simple-tree/mapNode.d.ts.map +1 -1
  302. package/dist/simple-tree/mapNode.js +38 -29
  303. package/dist/simple-tree/mapNode.js.map +1 -1
  304. package/dist/simple-tree/objectNode.d.ts +9 -7
  305. package/dist/simple-tree/objectNode.d.ts.map +1 -1
  306. package/dist/simple-tree/objectNode.js +37 -31
  307. package/dist/simple-tree/objectNode.js.map +1 -1
  308. package/dist/simple-tree/proxies.d.ts +1 -14
  309. package/dist/simple-tree/proxies.d.ts.map +1 -1
  310. package/dist/simple-tree/proxies.js +12 -15
  311. package/dist/simple-tree/proxies.js.map +1 -1
  312. package/dist/simple-tree/proxyBinding.d.ts +2 -62
  313. package/dist/simple-tree/proxyBinding.d.ts.map +1 -1
  314. package/dist/simple-tree/proxyBinding.js +8 -181
  315. package/dist/simple-tree/proxyBinding.js.map +1 -1
  316. package/dist/simple-tree/schemaTypes.d.ts +51 -11
  317. package/dist/simple-tree/schemaTypes.d.ts.map +1 -1
  318. package/dist/simple-tree/schemaTypes.js +14 -4
  319. package/dist/simple-tree/schemaTypes.js.map +1 -1
  320. package/dist/simple-tree/toFlexSchema.d.ts +11 -1
  321. package/dist/simple-tree/toFlexSchema.d.ts.map +1 -1
  322. package/dist/simple-tree/toFlexSchema.js +54 -31
  323. package/dist/simple-tree/toFlexSchema.js.map +1 -1
  324. package/dist/simple-tree/toMapTree.d.ts +25 -37
  325. package/dist/simple-tree/toMapTree.d.ts.map +1 -1
  326. package/dist/simple-tree/toMapTree.js +53 -16
  327. package/dist/simple-tree/toMapTree.js.map +1 -1
  328. package/dist/simple-tree/treeNodeValid.d.ts.map +1 -1
  329. package/dist/simple-tree/treeNodeValid.js +7 -10
  330. package/dist/simple-tree/treeNodeValid.js.map +1 -1
  331. package/dist/simple-tree/typesUnsafe.d.ts +13 -13
  332. package/dist/simple-tree/typesUnsafe.js.map +1 -1
  333. package/dist/simple-tree/walkSchema.d.ts +26 -0
  334. package/dist/simple-tree/walkSchema.d.ts.map +1 -0
  335. package/dist/simple-tree/walkSchema.js +49 -0
  336. package/dist/simple-tree/walkSchema.js.map +1 -0
  337. package/dist/treeFactory.d.ts +2 -1
  338. package/dist/treeFactory.d.ts.map +1 -1
  339. package/dist/treeFactory.js +2 -1
  340. package/dist/treeFactory.js.map +1 -1
  341. package/dist/util/typeUtils.d.ts +2 -2
  342. package/dist/util/typeUtils.js.map +1 -1
  343. package/legacy.d.ts +11 -0
  344. package/lib/alpha.d.ts +103 -0
  345. package/lib/beta.d.ts +7 -2
  346. package/lib/core/index.d.ts +2 -2
  347. package/lib/core/index.d.ts.map +1 -1
  348. package/lib/core/index.js +2 -2
  349. package/lib/core/index.js.map +1 -1
  350. package/lib/core/rebase/index.d.ts +1 -1
  351. package/lib/core/rebase/index.d.ts.map +1 -1
  352. package/lib/core/rebase/index.js +1 -1
  353. package/lib/core/rebase/index.js.map +1 -1
  354. package/lib/core/rebase/types.d.ts +1 -0
  355. package/lib/core/rebase/types.d.ts.map +1 -1
  356. package/lib/core/rebase/types.js +6 -0
  357. package/lib/core/rebase/types.js.map +1 -1
  358. package/lib/core/{revertible/revertible.d.ts → revertible.d.ts} +12 -0
  359. package/lib/core/revertible.d.ts.map +1 -0
  360. package/lib/core/revertible.js.map +1 -0
  361. package/lib/core/schema-stored/format.d.ts +3 -3
  362. package/lib/core/schema-stored/format.js +1 -1
  363. package/lib/core/schema-stored/format.js.map +1 -1
  364. package/lib/core/schema-stored/schema.d.ts +2 -7
  365. package/lib/core/schema-stored/schema.d.ts.map +1 -1
  366. package/lib/core/schema-stored/schema.js +4 -6
  367. package/lib/core/schema-stored/schema.js.map +1 -1
  368. package/lib/core/schema-stored/storedSchemaRepository.d.ts +1 -1
  369. package/lib/core/schema-stored/storedSchemaRepository.d.ts.map +1 -1
  370. package/lib/core/tree/anchorSet.d.ts.map +1 -1
  371. package/lib/core/tree/anchorSet.js +6 -2
  372. package/lib/core/tree/anchorSet.js.map +1 -1
  373. package/lib/core/tree/detachedFieldIndex.d.ts +0 -1
  374. package/lib/core/tree/detachedFieldIndex.d.ts.map +1 -1
  375. package/lib/core/tree/detachedFieldIndex.js +1 -0
  376. package/lib/core/tree/detachedFieldIndex.js.map +1 -1
  377. package/lib/core/tree/visitDelta.d.ts +7 -2
  378. package/lib/core/tree/visitDelta.d.ts.map +1 -1
  379. package/lib/core/tree/visitDelta.js.map +1 -1
  380. package/lib/events/emitter.d.ts +127 -0
  381. package/lib/events/emitter.d.ts.map +1 -0
  382. package/lib/events/{events.js → emitter.js} +48 -29
  383. package/lib/events/emitter.js.map +1 -0
  384. package/lib/events/index.d.ts +2 -1
  385. package/lib/events/index.d.ts.map +1 -1
  386. package/lib/events/index.js +1 -1
  387. package/lib/events/index.js.map +1 -1
  388. package/lib/events/interop.d.ts +36 -0
  389. package/lib/events/interop.d.ts.map +1 -0
  390. package/{src/core/revertible/index.ts → lib/events/interop.js} +2 -2
  391. package/lib/events/interop.js.map +1 -0
  392. package/lib/events/listeners.d.ts +65 -0
  393. package/lib/events/listeners.d.ts.map +1 -0
  394. package/lib/{core/revertible/index.js → events/listeners.js} +2 -2
  395. package/lib/events/listeners.js.map +1 -0
  396. package/lib/feature-libraries/chunked-forest/chunkTree.d.ts +25 -7
  397. package/lib/feature-libraries/chunked-forest/chunkTree.d.ts.map +1 -1
  398. package/lib/feature-libraries/chunked-forest/chunkTree.js +37 -16
  399. package/lib/feature-libraries/chunked-forest/chunkTree.js.map +1 -1
  400. package/lib/feature-libraries/chunked-forest/chunkedForest.d.ts +4 -2
  401. package/lib/feature-libraries/chunked-forest/chunkedForest.d.ts.map +1 -1
  402. package/lib/feature-libraries/chunked-forest/chunkedForest.js +12 -5
  403. package/lib/feature-libraries/chunked-forest/chunkedForest.js.map +1 -1
  404. package/lib/feature-libraries/chunked-forest/uniformChunk.d.ts +15 -2
  405. package/lib/feature-libraries/chunked-forest/uniformChunk.d.ts.map +1 -1
  406. package/lib/feature-libraries/chunked-forest/uniformChunk.js +28 -2
  407. package/lib/feature-libraries/chunked-forest/uniformChunk.js.map +1 -1
  408. package/lib/feature-libraries/default-schema/defaultEditBuilder.d.ts +3 -1
  409. package/lib/feature-libraries/default-schema/defaultEditBuilder.d.ts.map +1 -1
  410. package/lib/feature-libraries/default-schema/defaultEditBuilder.js +5 -4
  411. package/lib/feature-libraries/default-schema/defaultEditBuilder.js.map +1 -1
  412. package/lib/feature-libraries/flex-map-tree/index.d.ts +1 -1
  413. package/lib/feature-libraries/flex-map-tree/index.d.ts.map +1 -1
  414. package/lib/feature-libraries/flex-map-tree/index.js +1 -1
  415. package/lib/feature-libraries/flex-map-tree/index.js.map +1 -1
  416. package/lib/feature-libraries/flex-map-tree/mapTreeNode.d.ts +35 -33
  417. package/lib/feature-libraries/flex-map-tree/mapTreeNode.d.ts.map +1 -1
  418. package/lib/feature-libraries/flex-map-tree/mapTreeNode.js +83 -104
  419. package/lib/feature-libraries/flex-map-tree/mapTreeNode.js.map +1 -1
  420. package/lib/feature-libraries/flex-tree/context.d.ts +30 -14
  421. package/lib/feature-libraries/flex-tree/context.d.ts.map +1 -1
  422. package/lib/feature-libraries/flex-tree/context.js +10 -7
  423. package/lib/feature-libraries/flex-tree/context.js.map +1 -1
  424. package/lib/feature-libraries/flex-tree/flexTreeTypes.d.ts +57 -190
  425. package/lib/feature-libraries/flex-tree/flexTreeTypes.d.ts.map +1 -1
  426. package/lib/feature-libraries/flex-tree/flexTreeTypes.js +15 -2
  427. package/lib/feature-libraries/flex-tree/flexTreeTypes.js.map +1 -1
  428. package/lib/feature-libraries/flex-tree/index.d.ts +2 -3
  429. package/lib/feature-libraries/flex-tree/index.d.ts.map +1 -1
  430. package/lib/feature-libraries/flex-tree/index.js +1 -1
  431. package/lib/feature-libraries/flex-tree/index.js.map +1 -1
  432. package/lib/feature-libraries/flex-tree/lazyEntity.d.ts +3 -3
  433. package/lib/feature-libraries/flex-tree/lazyEntity.d.ts.map +1 -1
  434. package/lib/feature-libraries/flex-tree/lazyEntity.js +2 -10
  435. package/lib/feature-libraries/flex-tree/lazyEntity.js.map +1 -1
  436. package/lib/feature-libraries/flex-tree/lazyField.d.ts +26 -28
  437. package/lib/feature-libraries/flex-tree/lazyField.d.ts.map +1 -1
  438. package/lib/feature-libraries/flex-tree/lazyField.js +11 -13
  439. package/lib/feature-libraries/flex-tree/lazyField.js.map +1 -1
  440. package/lib/feature-libraries/flex-tree/lazyNode.d.ts +5 -26
  441. package/lib/feature-libraries/flex-tree/lazyNode.d.ts.map +1 -1
  442. package/lib/feature-libraries/flex-tree/lazyNode.js +23 -72
  443. package/lib/feature-libraries/flex-tree/lazyNode.js.map +1 -1
  444. package/lib/feature-libraries/flex-tree/unboxed.d.ts +4 -16
  445. package/lib/feature-libraries/flex-tree/unboxed.d.ts.map +1 -1
  446. package/lib/feature-libraries/flex-tree/unboxed.js +5 -37
  447. package/lib/feature-libraries/flex-tree/unboxed.js.map +1 -1
  448. package/lib/feature-libraries/flex-tree/utilities.d.ts +2 -2
  449. package/lib/feature-libraries/flex-tree/utilities.d.ts.map +1 -1
  450. package/lib/feature-libraries/flex-tree/utilities.js +3 -6
  451. package/lib/feature-libraries/flex-tree/utilities.js.map +1 -1
  452. package/lib/feature-libraries/forest-summary/forestSummarizer.d.ts.map +1 -1
  453. package/lib/feature-libraries/forest-summary/forestSummarizer.js +4 -1
  454. package/lib/feature-libraries/forest-summary/forestSummarizer.js.map +1 -1
  455. package/lib/feature-libraries/index.d.ts +3 -5
  456. package/lib/feature-libraries/index.d.ts.map +1 -1
  457. package/lib/feature-libraries/index.js +5 -5
  458. package/lib/feature-libraries/index.js.map +1 -1
  459. package/lib/feature-libraries/modular-schema/comparison.d.ts.map +1 -1
  460. package/lib/feature-libraries/modular-schema/comparison.js +3 -6
  461. package/lib/feature-libraries/modular-schema/comparison.js.map +1 -1
  462. package/lib/feature-libraries/modular-schema/discrepancies.d.ts.map +1 -1
  463. package/lib/feature-libraries/modular-schema/discrepancies.js +3 -13
  464. package/lib/feature-libraries/modular-schema/discrepancies.js.map +1 -1
  465. package/lib/feature-libraries/modular-schema/modularChangeCodecs.js +4 -1
  466. package/lib/feature-libraries/modular-schema/modularChangeCodecs.js.map +1 -1
  467. package/lib/feature-libraries/modular-schema/modularChangeFamily.d.ts +9 -1
  468. package/lib/feature-libraries/modular-schema/modularChangeFamily.d.ts.map +1 -1
  469. package/lib/feature-libraries/modular-schema/modularChangeFamily.js +74 -23
  470. package/lib/feature-libraries/modular-schema/modularChangeFamily.js.map +1 -1
  471. package/lib/feature-libraries/schema-edits/schemaChangeFormat.d.ts +6 -6
  472. package/lib/feature-libraries/schema-index/format.d.ts +3 -3
  473. package/lib/feature-libraries/sequence-field/compose.d.ts.map +1 -1
  474. package/lib/feature-libraries/sequence-field/compose.js +3 -0
  475. package/lib/feature-libraries/sequence-field/compose.js.map +1 -1
  476. package/lib/feature-libraries/sequence-field/utils.d.ts.map +1 -1
  477. package/lib/feature-libraries/sequence-field/utils.js +2 -5
  478. package/lib/feature-libraries/sequence-field/utils.js.map +1 -1
  479. package/lib/feature-libraries/storedToViewSchema.d.ts.map +1 -1
  480. package/lib/feature-libraries/storedToViewSchema.js +3 -5
  481. package/lib/feature-libraries/storedToViewSchema.js.map +1 -1
  482. package/lib/feature-libraries/typed-schema/flexList.d.ts +3 -3
  483. package/lib/feature-libraries/typed-schema/flexList.js.map +1 -1
  484. package/lib/feature-libraries/typed-schema/index.d.ts +2 -2
  485. package/lib/feature-libraries/typed-schema/index.d.ts.map +1 -1
  486. package/lib/feature-libraries/typed-schema/index.js +2 -2
  487. package/lib/feature-libraries/typed-schema/index.js.map +1 -1
  488. package/lib/feature-libraries/typed-schema/schemaCollection.d.ts.map +1 -1
  489. package/lib/feature-libraries/typed-schema/schemaCollection.js +9 -11
  490. package/lib/feature-libraries/typed-schema/schemaCollection.js.map +1 -1
  491. package/lib/feature-libraries/typed-schema/typedTreeSchema.d.ts +17 -48
  492. package/lib/feature-libraries/typed-schema/typedTreeSchema.d.ts.map +1 -1
  493. package/lib/feature-libraries/typed-schema/typedTreeSchema.js +5 -36
  494. package/lib/feature-libraries/typed-schema/typedTreeSchema.js.map +1 -1
  495. package/lib/feature-libraries/typed-schema/view.d.ts +4 -6
  496. package/lib/feature-libraries/typed-schema/view.d.ts.map +1 -1
  497. package/lib/feature-libraries/typed-schema/view.js +5 -4
  498. package/lib/feature-libraries/typed-schema/view.js.map +1 -1
  499. package/lib/index.d.ts +4 -4
  500. package/lib/index.d.ts.map +1 -1
  501. package/lib/index.js +3 -5
  502. package/lib/index.js.map +1 -1
  503. package/lib/legacy.d.ts +84 -0
  504. package/lib/packageVersion.d.ts +1 -1
  505. package/lib/packageVersion.js +1 -1
  506. package/lib/packageVersion.js.map +1 -1
  507. package/lib/public.d.ts +1 -1
  508. package/lib/shared-tree/checkoutFlexTreeView.d.ts +53 -0
  509. package/lib/shared-tree/checkoutFlexTreeView.d.ts.map +1 -0
  510. package/lib/shared-tree/{treeView.js → checkoutFlexTreeView.js} +26 -5
  511. package/lib/shared-tree/checkoutFlexTreeView.js.map +1 -0
  512. package/lib/shared-tree/index.d.ts +3 -3
  513. package/lib/shared-tree/index.d.ts.map +1 -1
  514. package/lib/shared-tree/index.js +1 -1
  515. package/lib/shared-tree/index.js.map +1 -1
  516. package/lib/shared-tree/schematizeTree.d.ts +15 -4
  517. package/lib/shared-tree/schematizeTree.d.ts.map +1 -1
  518. package/lib/shared-tree/schematizeTree.js +8 -9
  519. package/lib/shared-tree/schematizeTree.js.map +1 -1
  520. package/lib/shared-tree/schematizingTreeView.d.ts +10 -4
  521. package/lib/shared-tree/schematizingTreeView.d.ts.map +1 -1
  522. package/lib/shared-tree/schematizingTreeView.js +29 -13
  523. package/lib/shared-tree/schematizingTreeView.js.map +1 -1
  524. package/lib/shared-tree/sharedTree.d.ts.map +1 -1
  525. package/lib/shared-tree/sharedTree.js +2 -2
  526. package/lib/shared-tree/sharedTree.js.map +1 -1
  527. package/lib/shared-tree/sharedTreeChangeEnricher.d.ts +3 -1
  528. package/lib/shared-tree/sharedTreeChangeEnricher.d.ts.map +1 -1
  529. package/lib/shared-tree/sharedTreeChangeEnricher.js +6 -2
  530. package/lib/shared-tree/sharedTreeChangeEnricher.js.map +1 -1
  531. package/lib/shared-tree/sharedTreeChangeFamily.d.ts +3 -1
  532. package/lib/shared-tree/sharedTreeChangeFamily.d.ts.map +1 -1
  533. package/lib/shared-tree/sharedTreeChangeFamily.js +3 -2
  534. package/lib/shared-tree/sharedTreeChangeFamily.js.map +1 -1
  535. package/lib/shared-tree/sharedTreeEditBuilder.d.ts +2 -1
  536. package/lib/shared-tree/sharedTreeEditBuilder.d.ts.map +1 -1
  537. package/lib/shared-tree/sharedTreeEditBuilder.js +2 -2
  538. package/lib/shared-tree/sharedTreeEditBuilder.js.map +1 -1
  539. package/lib/shared-tree/treeApi.d.ts +1 -3
  540. package/lib/shared-tree/treeApi.d.ts.map +1 -1
  541. package/lib/shared-tree/treeApi.js +7 -5
  542. package/lib/shared-tree/treeApi.js.map +1 -1
  543. package/lib/shared-tree/treeCheckout.d.ts +2 -13
  544. package/lib/shared-tree/treeCheckout.d.ts.map +1 -1
  545. package/lib/shared-tree/treeCheckout.js +18 -2
  546. package/lib/shared-tree/treeCheckout.js.map +1 -1
  547. package/lib/shared-tree-core/branch.js +1 -1
  548. package/lib/shared-tree-core/branch.js.map +1 -1
  549. package/lib/simple-tree/api/create.d.ts.map +1 -1
  550. package/lib/simple-tree/api/create.js +2 -2
  551. package/lib/simple-tree/api/create.js.map +1 -1
  552. package/{dist/simple-tree → lib/simple-tree/api}/getJsonSchema.d.ts +1 -1
  553. package/lib/simple-tree/api/getJsonSchema.d.ts.map +1 -0
  554. package/lib/simple-tree/{getJsonSchema.js → api/getJsonSchema.js} +1 -1
  555. package/lib/simple-tree/api/getJsonSchema.js.map +1 -0
  556. package/{dist/simple-tree → lib/simple-tree/api}/getSimpleSchema.d.ts +1 -1
  557. package/lib/simple-tree/api/getSimpleSchema.d.ts.map +1 -0
  558. package/lib/simple-tree/{getSimpleSchema.js → api/getSimpleSchema.js} +1 -1
  559. package/lib/simple-tree/api/getSimpleSchema.js.map +1 -0
  560. package/lib/simple-tree/api/index.d.ts +5 -0
  561. package/lib/simple-tree/api/index.d.ts.map +1 -1
  562. package/lib/simple-tree/api/index.js +3 -0
  563. package/lib/simple-tree/api/index.js.map +1 -1
  564. package/{dist/simple-tree → lib/simple-tree/api}/jsonSchema.d.ts +14 -15
  565. package/lib/simple-tree/api/jsonSchema.d.ts.map +1 -0
  566. package/lib/simple-tree/api/jsonSchema.js.map +1 -0
  567. package/lib/simple-tree/api/schemaFactory.d.ts +53 -16
  568. package/lib/simple-tree/api/schemaFactory.d.ts.map +1 -1
  569. package/lib/simple-tree/api/schemaFactory.js +49 -12
  570. package/lib/simple-tree/api/schemaFactory.js.map +1 -1
  571. package/lib/simple-tree/{simpleSchema.d.ts → api/simpleSchema.d.ts} +8 -4
  572. package/lib/simple-tree/api/simpleSchema.d.ts.map +1 -0
  573. package/lib/simple-tree/api/simpleSchema.js.map +1 -0
  574. package/lib/simple-tree/api/simpleSchemaToJsonSchema.d.ts.map +1 -0
  575. package/lib/simple-tree/{simpleSchemaToJsonSchema.js → api/simpleSchemaToJsonSchema.js} +35 -22
  576. package/lib/simple-tree/api/simpleSchemaToJsonSchema.js.map +1 -0
  577. package/lib/simple-tree/api/tree.d.ts +5 -21
  578. package/lib/simple-tree/api/tree.d.ts.map +1 -1
  579. package/lib/simple-tree/api/tree.js +2 -34
  580. package/lib/simple-tree/api/tree.js.map +1 -1
  581. package/lib/simple-tree/api/treeApiBeta.d.ts +79 -0
  582. package/lib/simple-tree/api/treeApiBeta.d.ts.map +1 -0
  583. package/lib/simple-tree/api/treeApiBeta.js +23 -0
  584. package/lib/simple-tree/api/treeApiBeta.js.map +1 -0
  585. package/lib/simple-tree/api/treeNodeApi.d.ts +1 -1
  586. package/lib/simple-tree/api/treeNodeApi.d.ts.map +1 -1
  587. package/lib/simple-tree/api/treeNodeApi.js +23 -21
  588. package/lib/simple-tree/api/treeNodeApi.js.map +1 -1
  589. package/lib/simple-tree/api/verboseTree.js +1 -1
  590. package/lib/simple-tree/api/verboseTree.js.map +1 -1
  591. package/lib/simple-tree/{viewSchemaToSimpleSchema.d.ts → api/viewSchemaToSimpleSchema.d.ts} +1 -1
  592. package/lib/simple-tree/api/viewSchemaToSimpleSchema.d.ts.map +1 -0
  593. package/lib/simple-tree/{viewSchemaToSimpleSchema.js → api/viewSchemaToSimpleSchema.js} +8 -4
  594. package/lib/simple-tree/api/viewSchemaToSimpleSchema.js.map +1 -0
  595. package/lib/simple-tree/arrayNode.d.ts +2 -2
  596. package/lib/simple-tree/arrayNode.d.ts.map +1 -1
  597. package/lib/simple-tree/arrayNode.js +33 -24
  598. package/lib/simple-tree/arrayNode.js.map +1 -1
  599. package/lib/simple-tree/core/index.d.ts +3 -3
  600. package/lib/simple-tree/core/index.d.ts.map +1 -1
  601. package/lib/simple-tree/core/index.js +2 -2
  602. package/lib/simple-tree/core/index.js.map +1 -1
  603. package/lib/simple-tree/core/schemaCaching.d.ts +5 -0
  604. package/lib/simple-tree/core/schemaCaching.d.ts.map +1 -1
  605. package/lib/simple-tree/core/schemaCaching.js +8 -0
  606. package/lib/simple-tree/core/schemaCaching.js.map +1 -1
  607. package/lib/simple-tree/core/treeNodeKernel.d.ts +61 -3
  608. package/lib/simple-tree/core/treeNodeKernel.d.ts.map +1 -1
  609. package/lib/simple-tree/core/treeNodeKernel.js +156 -5
  610. package/lib/simple-tree/core/treeNodeKernel.js.map +1 -1
  611. package/lib/simple-tree/core/treeNodeSchema.d.ts +1 -1
  612. package/lib/simple-tree/core/treeNodeSchema.js.map +1 -1
  613. package/lib/simple-tree/core/types.d.ts +17 -20
  614. package/lib/simple-tree/core/types.d.ts.map +1 -1
  615. package/lib/simple-tree/core/types.js.map +1 -1
  616. package/lib/simple-tree/core/withType.d.ts +3 -2
  617. package/lib/simple-tree/core/withType.d.ts.map +1 -1
  618. package/lib/simple-tree/core/withType.js.map +1 -1
  619. package/lib/simple-tree/index.d.ts +8 -10
  620. package/lib/simple-tree/index.d.ts.map +1 -1
  621. package/lib/simple-tree/index.js +5 -5
  622. package/lib/simple-tree/index.js.map +1 -1
  623. package/lib/simple-tree/leafNodeSchema.d.ts +7 -9
  624. package/lib/simple-tree/leafNodeSchema.d.ts.map +1 -1
  625. package/lib/simple-tree/leafNodeSchema.js +14 -12
  626. package/lib/simple-tree/leafNodeSchema.js.map +1 -1
  627. package/lib/simple-tree/mapNode.d.ts +1 -1
  628. package/lib/simple-tree/mapNode.d.ts.map +1 -1
  629. package/lib/simple-tree/mapNode.js +38 -29
  630. package/lib/simple-tree/mapNode.js.map +1 -1
  631. package/lib/simple-tree/objectNode.d.ts +9 -7
  632. package/lib/simple-tree/objectNode.d.ts.map +1 -1
  633. package/lib/simple-tree/objectNode.js +40 -34
  634. package/lib/simple-tree/objectNode.js.map +1 -1
  635. package/lib/simple-tree/proxies.d.ts +1 -14
  636. package/lib/simple-tree/proxies.d.ts.map +1 -1
  637. package/lib/simple-tree/proxies.js +11 -14
  638. package/lib/simple-tree/proxies.js.map +1 -1
  639. package/lib/simple-tree/proxyBinding.d.ts +2 -62
  640. package/lib/simple-tree/proxyBinding.d.ts.map +1 -1
  641. package/lib/simple-tree/proxyBinding.js +6 -174
  642. package/lib/simple-tree/proxyBinding.js.map +1 -1
  643. package/lib/simple-tree/schemaTypes.d.ts +51 -11
  644. package/lib/simple-tree/schemaTypes.d.ts.map +1 -1
  645. package/lib/simple-tree/schemaTypes.js +14 -4
  646. package/lib/simple-tree/schemaTypes.js.map +1 -1
  647. package/lib/simple-tree/toFlexSchema.d.ts +11 -1
  648. package/lib/simple-tree/toFlexSchema.d.ts.map +1 -1
  649. package/lib/simple-tree/toFlexSchema.js +29 -8
  650. package/lib/simple-tree/toFlexSchema.js.map +1 -1
  651. package/lib/simple-tree/toMapTree.d.ts +25 -37
  652. package/lib/simple-tree/toMapTree.d.ts.map +1 -1
  653. package/lib/simple-tree/toMapTree.js +54 -17
  654. package/lib/simple-tree/toMapTree.js.map +1 -1
  655. package/lib/simple-tree/treeNodeValid.d.ts.map +1 -1
  656. package/lib/simple-tree/treeNodeValid.js +8 -11
  657. package/lib/simple-tree/treeNodeValid.js.map +1 -1
  658. package/lib/simple-tree/typesUnsafe.d.ts +13 -13
  659. package/lib/simple-tree/typesUnsafe.js.map +1 -1
  660. package/lib/simple-tree/walkSchema.d.ts +26 -0
  661. package/lib/simple-tree/walkSchema.d.ts.map +1 -0
  662. package/lib/simple-tree/walkSchema.js +43 -0
  663. package/lib/simple-tree/walkSchema.js.map +1 -0
  664. package/lib/treeFactory.d.ts +2 -1
  665. package/lib/treeFactory.d.ts.map +1 -1
  666. package/lib/treeFactory.js +2 -1
  667. package/lib/treeFactory.js.map +1 -1
  668. package/lib/tsdoc-metadata.json +1 -1
  669. package/lib/util/typeUtils.d.ts +2 -2
  670. package/lib/util/typeUtils.js.map +1 -1
  671. package/package.json +68 -26
  672. package/src/core/index.ts +2 -1
  673. package/src/core/rebase/index.ts +1 -0
  674. package/src/core/rebase/types.ts +11 -0
  675. package/src/core/{revertible/revertible.ts → revertible.ts} +15 -0
  676. package/src/core/schema-stored/format.ts +1 -1
  677. package/src/core/schema-stored/schema.ts +7 -13
  678. package/src/core/tree/anchorSet.ts +18 -3
  679. package/src/core/tree/detachedFieldIndex.ts +6 -5
  680. package/src/core/tree/visitDelta.ts +7 -2
  681. package/src/events/{events.ts → emitter.ts} +52 -139
  682. package/src/events/index.ts +7 -7
  683. package/src/events/interop.ts +49 -0
  684. package/src/events/listeners.ts +68 -0
  685. package/src/feature-libraries/chunked-forest/chunkTree.ts +63 -18
  686. package/src/feature-libraries/chunked-forest/chunkedForest.ts +18 -4
  687. package/src/feature-libraries/chunked-forest/uniformChunk.ts +33 -0
  688. package/src/feature-libraries/default-schema/defaultEditBuilder.ts +5 -3
  689. package/src/feature-libraries/flex-map-tree/index.ts +1 -0
  690. package/src/feature-libraries/flex-map-tree/mapTreeNode.ts +135 -210
  691. package/src/feature-libraries/flex-tree/README.md +4 -75
  692. package/src/feature-libraries/flex-tree/context.ts +37 -16
  693. package/src/feature-libraries/flex-tree/flexTreeTypes.ts +69 -291
  694. package/src/feature-libraries/flex-tree/index.ts +7 -13
  695. package/src/feature-libraries/flex-tree/lazyEntity.ts +2 -11
  696. package/src/feature-libraries/flex-tree/lazyField.ts +49 -73
  697. package/src/feature-libraries/flex-tree/lazyNode.ts +25 -154
  698. package/src/feature-libraries/flex-tree/unboxed.ts +9 -68
  699. package/src/feature-libraries/flex-tree/utilities.ts +4 -8
  700. package/src/feature-libraries/forest-summary/forestSummarizer.ts +4 -1
  701. package/src/feature-libraries/index.ts +2 -27
  702. package/src/feature-libraries/modular-schema/comparison.ts +4 -6
  703. package/src/feature-libraries/modular-schema/discrepancies.ts +7 -16
  704. package/src/feature-libraries/modular-schema/modularChangeCodecs.ts +4 -1
  705. package/src/feature-libraries/modular-schema/modularChangeFamily.ts +111 -14
  706. package/src/feature-libraries/sequence-field/compose.ts +3 -0
  707. package/src/feature-libraries/sequence-field/utils.ts +2 -4
  708. package/src/feature-libraries/storedToViewSchema.ts +5 -6
  709. package/src/feature-libraries/typed-schema/flexList.ts +3 -3
  710. package/src/feature-libraries/typed-schema/index.ts +1 -3
  711. package/src/feature-libraries/typed-schema/schemaCollection.ts +15 -17
  712. package/src/feature-libraries/typed-schema/typedTreeSchema.ts +35 -127
  713. package/src/feature-libraries/typed-schema/view.ts +4 -13
  714. package/src/index.ts +5 -8
  715. package/src/packageVersion.ts +1 -1
  716. package/src/shared-tree/checkoutFlexTreeView.ts +89 -0
  717. package/src/shared-tree/index.ts +2 -7
  718. package/src/shared-tree/schematizeTree.ts +23 -12
  719. package/src/shared-tree/schematizingTreeView.ts +38 -24
  720. package/src/shared-tree/sharedTree.ts +6 -1
  721. package/src/shared-tree/sharedTreeChangeEnricher.ts +6 -1
  722. package/src/shared-tree/sharedTreeChangeFamily.ts +7 -1
  723. package/src/shared-tree/sharedTreeEditBuilder.ts +9 -4
  724. package/src/shared-tree/treeApi.ts +10 -10
  725. package/src/shared-tree/treeCheckout.ts +26 -15
  726. package/src/shared-tree-core/branch.ts +1 -1
  727. package/src/simple-tree/ProxyBinding.md +23 -23
  728. package/src/simple-tree/api/create.ts +8 -3
  729. package/src/simple-tree/{getJsonSchema.ts → api/getJsonSchema.ts} +3 -3
  730. package/src/simple-tree/{getSimpleSchema.ts → api/getSimpleSchema.ts} +3 -3
  731. package/src/simple-tree/api/index.ts +20 -0
  732. package/src/simple-tree/{jsonSchema.ts → api/jsonSchema.ts} +20 -18
  733. package/src/simple-tree/api/schemaFactory.ts +56 -19
  734. package/src/simple-tree/{simpleSchema.ts → api/simpleSchema.ts} +9 -4
  735. package/src/simple-tree/{simpleSchemaToJsonSchema.ts → api/simpleSchemaToJsonSchema.ts} +43 -22
  736. package/src/simple-tree/api/tree.ts +7 -71
  737. package/src/simple-tree/api/treeApiBeta.ts +101 -0
  738. package/src/simple-tree/api/treeNodeApi.ts +32 -23
  739. package/src/simple-tree/api/verboseTree.ts +1 -1
  740. package/src/simple-tree/{viewSchemaToSimpleSchema.ts → api/viewSchemaToSimpleSchema.ts} +11 -6
  741. package/src/simple-tree/arrayNode.ts +37 -31
  742. package/src/simple-tree/core/index.ts +4 -1
  743. package/src/simple-tree/core/schemaCaching.ts +10 -0
  744. package/src/simple-tree/core/treeNodeKernel.ts +198 -5
  745. package/src/simple-tree/core/treeNodeSchema.ts +1 -1
  746. package/src/simple-tree/core/types.ts +16 -27
  747. package/src/simple-tree/core/withType.ts +3 -1
  748. package/src/simple-tree/index.ts +30 -21
  749. package/src/simple-tree/leafNodeSchema.ts +24 -28
  750. package/src/simple-tree/mapNode.ts +47 -29
  751. package/src/simple-tree/objectNode.ts +51 -46
  752. package/src/simple-tree/proxies.ts +22 -51
  753. package/src/simple-tree/proxyBinding.ts +3 -254
  754. package/src/simple-tree/schemaTypes.ts +63 -13
  755. package/src/simple-tree/toFlexSchema.ts +40 -7
  756. package/src/simple-tree/toMapTree.ts +113 -79
  757. package/src/simple-tree/treeNodeValid.ts +10 -13
  758. package/src/simple-tree/typesUnsafe.ts +13 -13
  759. package/src/simple-tree/walkSchema.ts +81 -0
  760. package/src/treeFactory.ts +2 -1
  761. package/src/util/typeUtils.ts +2 -2
  762. package/dist/core/revertible/index.d.ts.map +0 -1
  763. package/dist/core/revertible/index.js +0 -10
  764. package/dist/core/revertible/index.js.map +0 -1
  765. package/dist/core/revertible/revertible.d.ts.map +0 -1
  766. package/dist/core/revertible/revertible.js.map +0 -1
  767. package/dist/domains/index.d.ts +0 -8
  768. package/dist/domains/index.d.ts.map +0 -1
  769. package/dist/domains/index.js +0 -20
  770. package/dist/domains/index.js.map +0 -1
  771. package/dist/domains/json/index.d.ts +0 -7
  772. package/dist/domains/json/index.d.ts.map +0 -1
  773. package/dist/domains/json/index.js +0 -17
  774. package/dist/domains/json/index.js.map +0 -1
  775. package/dist/domains/json/jsonCursor.d.ts +0 -52
  776. package/dist/domains/json/jsonCursor.d.ts.map +0 -1
  777. package/dist/domains/json/jsonCursor.js +0 -197
  778. package/dist/domains/json/jsonCursor.js.map +0 -1
  779. package/dist/domains/json/jsonDomainSchema.d.ts +0 -24
  780. package/dist/domains/json/jsonDomainSchema.d.ts.map +0 -1
  781. package/dist/domains/json/jsonDomainSchema.js +0 -32
  782. package/dist/domains/json/jsonDomainSchema.js.map +0 -1
  783. package/dist/domains/leafDomain.d.ts +0 -72
  784. package/dist/domains/leafDomain.d.ts.map +0 -1
  785. package/dist/domains/leafDomain.js +0 -88
  786. package/dist/domains/leafDomain.js.map +0 -1
  787. package/dist/domains/schemaBuilder.d.ts +0 -103
  788. package/dist/domains/schemaBuilder.d.ts.map +0 -1
  789. package/dist/domains/schemaBuilder.js +0 -121
  790. package/dist/domains/schemaBuilder.js.map +0 -1
  791. package/dist/domains/testRecursiveDomain.d.ts +0 -17
  792. package/dist/domains/testRecursiveDomain.d.ts.map +0 -1
  793. package/dist/domains/testRecursiveDomain.js +0 -35
  794. package/dist/domains/testRecursiveDomain.js.map +0 -1
  795. package/dist/events/events.d.ts +0 -207
  796. package/dist/events/events.d.ts.map +0 -1
  797. package/dist/events/events.js.map +0 -1
  798. package/dist/feature-libraries/schemaBuilder.d.ts +0 -31
  799. package/dist/feature-libraries/schemaBuilder.d.ts.map +0 -1
  800. package/dist/feature-libraries/schemaBuilder.js +0 -40
  801. package/dist/feature-libraries/schemaBuilder.js.map +0 -1
  802. package/dist/feature-libraries/schemaBuilderBase.d.ts +0 -191
  803. package/dist/feature-libraries/schemaBuilderBase.d.ts.map +0 -1
  804. package/dist/feature-libraries/schemaBuilderBase.js +0 -201
  805. package/dist/feature-libraries/schemaBuilderBase.js.map +0 -1
  806. package/dist/shared-tree/treeView.d.ts +0 -73
  807. package/dist/shared-tree/treeView.d.ts.map +0 -1
  808. package/dist/shared-tree/treeView.js.map +0 -1
  809. package/dist/simple-tree/getJsonSchema.d.ts.map +0 -1
  810. package/dist/simple-tree/getJsonSchema.js.map +0 -1
  811. package/dist/simple-tree/getSimpleSchema.d.ts.map +0 -1
  812. package/dist/simple-tree/getSimpleSchema.js.map +0 -1
  813. package/dist/simple-tree/jsonSchema.d.ts.map +0 -1
  814. package/dist/simple-tree/jsonSchema.js.map +0 -1
  815. package/dist/simple-tree/simpleSchema.d.ts.map +0 -1
  816. package/dist/simple-tree/simpleSchema.js.map +0 -1
  817. package/dist/simple-tree/simpleSchemaToJsonSchema.d.ts.map +0 -1
  818. package/dist/simple-tree/simpleSchemaToJsonSchema.js.map +0 -1
  819. package/dist/simple-tree/viewSchemaToSimpleSchema.d.ts.map +0 -1
  820. package/dist/simple-tree/viewSchemaToSimpleSchema.js.map +0 -1
  821. package/lib/core/revertible/index.d.ts.map +0 -1
  822. package/lib/core/revertible/index.js.map +0 -1
  823. package/lib/core/revertible/revertible.d.ts.map +0 -1
  824. package/lib/core/revertible/revertible.js.map +0 -1
  825. package/lib/domains/index.d.ts +0 -8
  826. package/lib/domains/index.d.ts.map +0 -1
  827. package/lib/domains/index.js +0 -8
  828. package/lib/domains/index.js.map +0 -1
  829. package/lib/domains/json/index.d.ts +0 -7
  830. package/lib/domains/json/index.d.ts.map +0 -1
  831. package/lib/domains/json/index.js +0 -7
  832. package/lib/domains/json/index.js.map +0 -1
  833. package/lib/domains/json/jsonCursor.d.ts +0 -52
  834. package/lib/domains/json/jsonCursor.d.ts.map +0 -1
  835. package/lib/domains/json/jsonCursor.js +0 -192
  836. package/lib/domains/json/jsonCursor.js.map +0 -1
  837. package/lib/domains/json/jsonDomainSchema.d.ts +0 -24
  838. package/lib/domains/json/jsonDomainSchema.d.ts.map +0 -1
  839. package/lib/domains/json/jsonDomainSchema.js +0 -29
  840. package/lib/domains/json/jsonDomainSchema.js.map +0 -1
  841. package/lib/domains/leafDomain.d.ts +0 -72
  842. package/lib/domains/leafDomain.d.ts.map +0 -1
  843. package/lib/domains/leafDomain.js +0 -85
  844. package/lib/domains/leafDomain.js.map +0 -1
  845. package/lib/domains/schemaBuilder.d.ts +0 -103
  846. package/lib/domains/schemaBuilder.d.ts.map +0 -1
  847. package/lib/domains/schemaBuilder.js +0 -117
  848. package/lib/domains/schemaBuilder.js.map +0 -1
  849. package/lib/domains/testRecursiveDomain.d.ts +0 -17
  850. package/lib/domains/testRecursiveDomain.d.ts.map +0 -1
  851. package/lib/domains/testRecursiveDomain.js +0 -32
  852. package/lib/domains/testRecursiveDomain.js.map +0 -1
  853. package/lib/events/events.d.ts +0 -207
  854. package/lib/events/events.d.ts.map +0 -1
  855. package/lib/events/events.js.map +0 -1
  856. package/lib/feature-libraries/schemaBuilder.d.ts +0 -31
  857. package/lib/feature-libraries/schemaBuilder.d.ts.map +0 -1
  858. package/lib/feature-libraries/schemaBuilder.js +0 -36
  859. package/lib/feature-libraries/schemaBuilder.js.map +0 -1
  860. package/lib/feature-libraries/schemaBuilderBase.d.ts +0 -191
  861. package/lib/feature-libraries/schemaBuilderBase.d.ts.map +0 -1
  862. package/lib/feature-libraries/schemaBuilderBase.js +0 -195
  863. package/lib/feature-libraries/schemaBuilderBase.js.map +0 -1
  864. package/lib/shared-tree/treeView.d.ts +0 -73
  865. package/lib/shared-tree/treeView.d.ts.map +0 -1
  866. package/lib/shared-tree/treeView.js.map +0 -1
  867. package/lib/simple-tree/getJsonSchema.d.ts.map +0 -1
  868. package/lib/simple-tree/getJsonSchema.js.map +0 -1
  869. package/lib/simple-tree/getSimpleSchema.d.ts.map +0 -1
  870. package/lib/simple-tree/getSimpleSchema.js.map +0 -1
  871. package/lib/simple-tree/jsonSchema.d.ts.map +0 -1
  872. package/lib/simple-tree/jsonSchema.js.map +0 -1
  873. package/lib/simple-tree/simpleSchema.d.ts.map +0 -1
  874. package/lib/simple-tree/simpleSchema.js.map +0 -1
  875. package/lib/simple-tree/simpleSchemaToJsonSchema.d.ts.map +0 -1
  876. package/lib/simple-tree/simpleSchemaToJsonSchema.js.map +0 -1
  877. package/lib/simple-tree/viewSchemaToSimpleSchema.d.ts.map +0 -1
  878. package/lib/simple-tree/viewSchemaToSimpleSchema.js.map +0 -1
  879. package/src/domains/README.md +0 -6
  880. package/src/domains/fence.json +0 -5
  881. package/src/domains/index.ts +0 -19
  882. package/src/domains/json/fence.json +0 -5
  883. package/src/domains/json/index.ts +0 -13
  884. package/src/domains/json/jsonCursor.ts +0 -247
  885. package/src/domains/json/jsonDomainSchema.ts +0 -47
  886. package/src/domains/leafDomain.ts +0 -97
  887. package/src/domains/schemaBuilder.ts +0 -153
  888. package/src/domains/testRecursiveDomain.ts +0 -38
  889. package/src/events/fence.json +0 -5
  890. package/src/feature-libraries/schemaBuilder.ts +0 -45
  891. package/src/feature-libraries/schemaBuilderBase.ts +0 -393
  892. package/src/shared-tree/treeView.ts +0 -113
  893. /package/dist/core/{revertible/revertible.js → revertible.js} +0 -0
  894. /package/dist/simple-tree/{jsonSchema.js → api/jsonSchema.js} +0 -0
  895. /package/dist/simple-tree/{simpleSchema.js → api/simpleSchema.js} +0 -0
  896. /package/dist/simple-tree/{simpleSchemaToJsonSchema.d.ts → api/simpleSchemaToJsonSchema.d.ts} +0 -0
  897. /package/lib/core/{revertible/revertible.js → revertible.js} +0 -0
  898. /package/lib/simple-tree/{jsonSchema.js → api/jsonSchema.js} +0 -0
  899. /package/lib/simple-tree/{simpleSchema.js → api/simpleSchema.js} +0 -0
  900. /package/lib/simple-tree/{simpleSchemaToJsonSchema.d.ts → api/simpleSchemaToJsonSchema.d.ts} +0 -0
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/events/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,yCAaqB;AAZpB,0GAAA,aAAa,OAAA;AACb,yGAAA,YAAY,OAAA;AACZ,mHAAA,sBAAsB,OAAA","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport {\n\tcreateEmitter,\n\tEventEmitter,\n\tComposableEventEmitter,\n\ttype Listeners,\n\ttype Listenable,\n\ttype Off,\n\ttype IsListener,\n\ttype TransformListeners,\n\ttype UnionToIntersection,\n\ttype IEmitter,\n\ttype NoListenersCallback,\n\ttype HasListeners,\n} from \"./events.js\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/events/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,2CAMsB;AALrB,2GAAA,aAAa,OAAA;AACb,0GAAA,YAAY,OAAA","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport {\n\tcreateEmitter,\n\tEventEmitter,\n\ttype IEmitter,\n\ttype NoListenersCallback,\n\ttype HasListeners,\n} from \"./emitter.js\";\n\nexport {\n\ttype Listeners,\n\ttype Listenable,\n\ttype Off,\n\ttype IsListener,\n} from \"./listeners.js\";\n"]}
@@ -0,0 +1,36 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ import type { IEvent } from "@fluidframework/core-interfaces";
6
+ import type { Listeners } from "./listeners.js";
7
+ /**
8
+ * Convert a union of types to an intersection of those types. Useful for `TransformEvents`.
9
+ * @privateRemarks
10
+ * First an always true extends clause is used (T extends T) to distribute T into to a union of types contravariant over each member of the T union.
11
+ * Then the constraint on the type parameter in this new context is inferred, giving the intersection.
12
+ */
13
+ export type UnionToIntersection<T> = (T extends T ? (k: T) => unknown : never) extends (k: infer U) => unknown ? U : never;
14
+ /**
15
+ * Converts a {@link Listeners} type (i.e. the event registry for a {@link Listenable}) into a type consumable
16
+ * by an IEventProvider from `@fluidframework/core-interfaces`.
17
+ * @param E - the `Events` type to transform
18
+ * @param Target - an optional `IEvent` type that will be merged into the result along with the transformed `E`
19
+ *
20
+ * @example
21
+ *
22
+ * ```typescript
23
+ * interface MyEvents {
24
+ * load: (user: string, data: IUserData) => void;
25
+ * error: (errorCode: number) => void;
26
+ * }
27
+ *
28
+ * class MySharedObject extends SharedObject<TransformEvents<MyEvents, ISharedObjectEvents>> {
29
+ * // ...
30
+ * }
31
+ * ```
32
+ */
33
+ export type TransformListeners<TListeners extends Listeners<TListeners>, TTarget extends IEvent = IEvent> = {
34
+ [P in keyof Listeners<TListeners>]: (event: P, listener: TListeners[P]) => void;
35
+ } extends Record<string | number | symbol, infer Z> ? UnionToIntersection<Z> & TTarget : never;
36
+ //# sourceMappingURL=interop.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"interop.d.ts","sourceRoot":"","sources":["../../src/events/interop.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,iCAAiC,CAAC;AAC9D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAIhD;;;;;GAKG;AACH,MAAM,MAAM,mBAAmB,CAAC,CAAC,IAAI,CAAC,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,KAAK,OAAO,GAAG,KAAK,CAAC,SAAS,CACtF,CAAC,EAAE,MAAM,CAAC,KACN,OAAO,GACT,CAAC,GACD,KAAK,CAAC;AAET;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,MAAM,kBAAkB,CAC7B,UAAU,SAAS,SAAS,CAAC,UAAU,CAAC,EACxC,OAAO,SAAS,MAAM,GAAG,MAAM,IAC5B;KACF,CAAC,IAAI,MAAM,SAAS,CAAC,UAAU,CAAC,GAAG,CAAC,KAAK,EAAE,CAAC,EAAE,QAAQ,EAAE,UAAU,CAAC,CAAC,CAAC,KAAK,IAAI;CAC/E,SAAS,MAAM,CAAC,MAAM,GAAG,MAAM,GAAG,MAAM,EAAE,MAAM,CAAC,CAAC,GAChD,mBAAmB,CAAC,CAAC,CAAC,GAAG,OAAO,GAChC,KAAK,CAAC"}
@@ -1,6 +1,7 @@
1
+ "use strict";
1
2
  /*!
2
3
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
4
  * Licensed under the MIT License.
4
5
  */
5
- export { type Revertible, RevertibleStatus } from "./revertible.js";
6
- //# sourceMappingURL=index.d.ts.map
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ //# sourceMappingURL=interop.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"interop.js","sourceRoot":"","sources":["../../src/events/interop.ts"],"names":[],"mappings":";AAAA;;;GAGG","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { IEvent } from \"@fluidframework/core-interfaces\";\nimport type { Listeners } from \"./listeners.js\";\n\n// TODO: this file is currently unused. Use it or remove it.\n\n/**\n * Convert a union of types to an intersection of those types. Useful for `TransformEvents`.\n * @privateRemarks\n * First an always true extends clause is used (T extends T) to distribute T into to a union of types contravariant over each member of the T union.\n * Then the constraint on the type parameter in this new context is inferred, giving the intersection.\n */\nexport type UnionToIntersection<T> = (T extends T ? (k: T) => unknown : never) extends (\n\tk: infer U,\n) => unknown\n\t? U\n\t: never;\n\n/**\n * Converts a {@link Listeners} type (i.e. the event registry for a {@link Listenable}) into a type consumable\n * by an IEventProvider from `@fluidframework/core-interfaces`.\n * @param E - the `Events` type to transform\n * @param Target - an optional `IEvent` type that will be merged into the result along with the transformed `E`\n *\n * @example\n *\n * ```typescript\n * interface MyEvents {\n * load: (user: string, data: IUserData) => void;\n * error: (errorCode: number) => void;\n * }\n *\n * class MySharedObject extends SharedObject<TransformEvents<MyEvents, ISharedObjectEvents>> {\n * // ...\n * }\n * ```\n */\nexport type TransformListeners<\n\tTListeners extends Listeners<TListeners>,\n\tTTarget extends IEvent = IEvent,\n> = {\n\t[P in keyof Listeners<TListeners>]: (event: P, listener: TListeners[P]) => void;\n} extends Record<string | number | symbol, infer Z>\n\t? UnionToIntersection<Z> & TTarget\n\t: never;\n"]}
@@ -0,0 +1,65 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ /**
6
+ * `true` iff the given type is an acceptable shape for a {@link Listeners | event} listener
7
+ * @public
8
+ */
9
+ export type IsListener<TListener> = TListener extends (...args: any[]) => void ? true : false;
10
+ /**
11
+ * Used to specify the kinds of events emitted by a {@link Listenable}.
12
+ *
13
+ * @remarks
14
+ * Any object type is a valid {@link Listeners}, but only the {@link IsListener | event-like} properties of that
15
+ * type will be included.
16
+ *
17
+ * @example
18
+ * ```typescript
19
+ * interface MyEvents {
20
+ * load: (user: string, data: IUserData) => void;
21
+ * error: (errorCode: number) => void;
22
+ * }
23
+ * ```
24
+ *
25
+ * @public
26
+ */
27
+ export type Listeners<T extends object> = {
28
+ [P in (string | symbol) & keyof T as IsListener<T[P]> extends true ? P : never]: T[P];
29
+ };
30
+ /**
31
+ * An object which allows the registration of listeners so that subscribers can be notified when an event happens.
32
+ * @param TListeners - All the {@link Listeners | events} that this subscribable supports
33
+ *
34
+ * @privateRemarks
35
+ * `EventEmitter` can be used as a base class to implement this via extension.
36
+ * ```ts
37
+ * type MyEventEmitter = IEventEmitter<{
38
+ * load: (user: string, data: IUserData) => void;
39
+ * error: (errorCode: number) => void;
40
+ * }>
41
+ * ```
42
+ * {@link createEmitter} can help implement this interface via delegation.
43
+ *
44
+ * @sealed @public
45
+ */
46
+ export interface Listenable<TListeners extends object> {
47
+ /**
48
+ * Register an event listener.
49
+ * @param eventName - The name of the event.
50
+ * @param listener - the handler to run when the event is fired by the emitter
51
+ * @returns a {@link Off | function} which will deregister the listener when called.
52
+ * This deregistration function is idempotent and therefore may be safely called more than once with no effect.
53
+ * @remarks Do not register the exact same `listener` object for the same event more than once.
54
+ * Doing so will result in undefined behavior, and is not guaranteed to behave the same in future versions of this library.
55
+ */
56
+ on<K extends keyof Listeners<TListeners>>(eventName: K, listener: TListeners[K]): Off;
57
+ }
58
+ /**
59
+ * A function that, when called, will deregister an event listener subscription that was previously registered.
60
+ * @remarks
61
+ * It is returned by the {@link Listenable.on | event registration function} when event registration occurs.
62
+ * @public
63
+ */
64
+ export type Off = () => void;
65
+ //# sourceMappingURL=listeners.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"listeners.d.ts","sourceRoot":"","sources":["../../src/events/listeners.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;GAGG;AACH,MAAM,MAAM,UAAU,CAAC,SAAS,IAAI,SAAS,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,GAAG,IAAI,GAAG,KAAK,CAAC;AAE9F;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,MAAM,SAAS,CAAC,CAAC,SAAS,MAAM,IAAI;KACxC,CAAC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,GAAG,MAAM,CAAC,IAAI,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,IAAI,GAAG,CAAC,GAAG,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC;CACrF,CAAC;AAEF;;;;;;;;;;;;;;;GAeG;AACH,MAAM,WAAW,UAAU,CAAC,UAAU,SAAS,MAAM;IACpD;;;;;;;;OAQG;IACH,EAAE,CAAC,CAAC,SAAS,MAAM,SAAS,CAAC,UAAU,CAAC,EAAE,SAAS,EAAE,CAAC,EAAE,QAAQ,EAAE,UAAU,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC;CACtF;AAED;;;;;GAKG;AACH,MAAM,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC"}
@@ -1,6 +1,7 @@
1
+ "use strict";
1
2
  /*!
2
3
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
4
  * Licensed under the MIT License.
4
5
  */
5
- export { type Revertible, RevertibleStatus } from "./revertible.js";
6
- //# sourceMappingURL=index.d.ts.map
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ //# sourceMappingURL=listeners.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"listeners.js","sourceRoot":"","sources":["../../src/events/listeners.ts"],"names":[],"mappings":";AAAA;;;GAGG","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/**\n * `true` iff the given type is an acceptable shape for a {@link Listeners | event} listener\n * @public\n */\nexport type IsListener<TListener> = TListener extends (...args: any[]) => void ? true : false;\n\n/**\n * Used to specify the kinds of events emitted by a {@link Listenable}.\n *\n * @remarks\n * Any object type is a valid {@link Listeners}, but only the {@link IsListener | event-like} properties of that\n * type will be included.\n *\n * @example\n * ```typescript\n * interface MyEvents {\n * load: (user: string, data: IUserData) => void;\n * error: (errorCode: number) => void;\n * }\n * ```\n *\n * @public\n */\nexport type Listeners<T extends object> = {\n\t[P in (string | symbol) & keyof T as IsListener<T[P]> extends true ? P : never]: T[P];\n};\n\n/**\n * An object which allows the registration of listeners so that subscribers can be notified when an event happens.\n * @param TListeners - All the {@link Listeners | events} that this subscribable supports\n *\n * @privateRemarks\n * `EventEmitter` can be used as a base class to implement this via extension.\n * ```ts\n * type MyEventEmitter = IEventEmitter<{\n * load: (user: string, data: IUserData) => void;\n * error: (errorCode: number) => void;\n * }>\n * ```\n * {@link createEmitter} can help implement this interface via delegation.\n *\n * @sealed @public\n */\nexport interface Listenable<TListeners extends object> {\n\t/**\n\t * Register an event listener.\n\t * @param eventName - The name of the event.\n\t * @param listener - the handler to run when the event is fired by the emitter\n\t * @returns a {@link Off | function} which will deregister the listener when called.\n\t * This deregistration function is idempotent and therefore may be safely called more than once with no effect.\n\t * @remarks Do not register the exact same `listener` object for the same event more than once.\n\t * Doing so will result in undefined behavior, and is not guaranteed to behave the same in future versions of this library.\n\t */\n\ton<K extends keyof Listeners<TListeners>>(eventName: K, listener: TListeners[K]): Off;\n}\n\n/**\n * A function that, when called, will deregister an event listener subscription that was previously registered.\n * @remarks\n * It is returned by the {@link Listenable.on | event registration function} when event registration occurs.\n * @public\n */\nexport type Off = () => void;\n"]}
@@ -7,6 +7,7 @@ import type { FullSchemaPolicy } from "../modular-schema/index.js";
7
7
  import { BasicChunk } from "./basicChunk.js";
8
8
  import { type TreeChunk } from "./chunk.js";
9
9
  import { type FieldShape, TreeShape, UniformChunk } from "./uniformChunk.js";
10
+ import type { IIdCompressor } from "@fluidframework/id-compressor";
10
11
  export interface Disposable {
11
12
  /**
12
13
  * Cleans up resources used by this, such as inbound event registrations.
@@ -74,22 +75,22 @@ export declare class Chunker implements IChunker {
74
75
  *
75
76
  * @param cursor - cursor in nodes mode
76
77
  */
77
- export declare function chunkTree(cursor: ITreeCursorSynchronous, policy: ChunkPolicy): TreeChunk;
78
+ export declare function chunkTree(cursor: ITreeCursorSynchronous, policy: ChunkCompressor): TreeChunk;
78
79
  /**
79
80
  * Get a TreeChunk[] for the current field (and its children) of cursor.
80
81
  * This will copy if needed, but add refs to existing chunks which hold the data.
81
82
  */
82
- export declare function chunkField(cursor: ITreeCursorSynchronous, policy: ChunkPolicy): TreeChunk[];
83
+ export declare function chunkField(cursor: ITreeCursorSynchronous, policy: ChunkCompressor): TreeChunk[];
83
84
  /**
84
85
  * Get a TreeChunk for the current field (and its children) of cursor.
85
86
  * Like {@link chunkField}, but forces the results into a single TreeChunk.
86
87
  */
87
- export declare function chunkFieldSingle(cursor: ITreeCursorSynchronous, policy: ChunkPolicy): TreeChunk;
88
+ export declare function chunkFieldSingle(cursor: ITreeCursorSynchronous, policy: ChunkCompressor): TreeChunk;
88
89
  /**
89
90
  * Get a BasicChunk for the current node (and its children) of cursor.
90
91
  * This will copy if needed, and add refs to existing chunks which hold the data.
91
92
  */
92
- export declare function basicChunkTree(cursor: ITreeCursorSynchronous, policy: ChunkPolicy): BasicChunk;
93
+ export declare function basicChunkTree(cursor: ITreeCursorSynchronous, policy: ChunkCompressor): BasicChunk;
93
94
  export declare function makePolicy(policy?: Partial<ChunkPolicy>): ChunkPolicy;
94
95
  export declare function shapesFromSchema(schema: StoredSchemaCollection, policy: FullSchemaPolicy): Map<TreeNodeSchemaIdentifier, ShapeInfo>;
95
96
  /**
@@ -134,14 +135,28 @@ export interface ChunkPolicy {
134
135
  */
135
136
  shapeFromSchema(schema: TreeNodeSchemaIdentifier): ShapeInfo;
136
137
  }
138
+ export interface ChunkCompressor {
139
+ readonly policy: ChunkPolicy;
140
+ /**
141
+ * If the idCompressor is provided, {@link UniformChunk}s with identifiers will be encoded for its in-memory representation.
142
+ * @remarks
143
+ * This compression applies to {@link UniformChunk}s when {@link TreeShape.maybeDecompressedStringAsNumber} is set.
144
+ * If the `policy` does not use UniformChunks or does not set `maybeDecompressedStringAsNumber`, then no compression will be applied even when providing `idCompressor`.
145
+ */
146
+ readonly idCompressor: IIdCompressor | undefined;
147
+ }
137
148
  /**
138
149
  * @param cursor - cursor in nodes mode
139
150
  * @param policy - heuristics to impact chunking
140
151
  * @param length - how many nodes to process (at the top level)
141
152
  * @param skipLastNavigation - if true, leaves the cursor at the last node instead of moving off of it.
142
153
  */
143
- export declare function chunkRange(cursor: ITreeCursorSynchronous, policy: ChunkPolicy, length: number, skipLastNavigation: boolean): TreeChunk[];
144
- export declare function insertValues(cursor: ITreeCursorSynchronous, shape: TreeShape, values: Value[]): void;
154
+ export declare function chunkRange(cursor: ITreeCursorSynchronous, chunkCompressor: ChunkCompressor, length: number, skipLastNavigation: boolean): TreeChunk[];
155
+ /**
156
+ * @param idCompressor - compressor used to encoded string values that are compressible by the idCompressor for in-memory representation.
157
+ * If the idCompressor is not provided, the values will be the original uncompressed values.
158
+ */
159
+ export declare function insertValues(cursor: ITreeCursorSynchronous, shape: TreeShape, values: Value[], idCompressor?: IIdCompressor): void;
145
160
  /**
146
161
  * Read up to `maxTopLevelLength` nodes from `cursor`, stopping when limit is hit or type of node changes.
147
162
  *
@@ -151,6 +166,9 @@ export declare function insertValues(cursor: ITreeCursorSynchronous, shape: Tree
151
166
  * If this stops early due to the type changing, `skipLastNavigation` is not involved:
152
167
  * `skipLastNavigation` only determines if the cursor will be left on the node after the last one (possibly exiting the field)
153
168
  * if the full length is used.
169
+ *
170
+ * @param idCompressor - compressor used to encoded string values that are compressible by the idCompressor for in-memory representation.
171
+ * If the idCompressor is not provided, the values will be the original uncompressed values.
154
172
  */
155
- export declare function uniformChunkFromCursor(cursor: ITreeCursorSynchronous, shape: TreeShape, maxTopLevelLength: number, skipLastNavigation: boolean): UniformChunk;
173
+ export declare function uniformChunkFromCursor(cursor: ITreeCursorSynchronous, shape: TreeShape, maxTopLevelLength: number, skipLastNavigation: boolean, idCompressor?: IIdCompressor): UniformChunk;
156
174
  //# sourceMappingURL=chunkTree.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"chunkTree.d.ts","sourceRoot":"","sources":["../../../src/feature-libraries/chunked-forest/chunkTree.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAEN,KAAK,QAAQ,EACb,KAAK,sBAAsB,EAG3B,KAAK,sBAAsB,EAC3B,KAAK,qBAAqB,EAC1B,KAAK,wBAAwB,EAC7B,KAAK,gBAAgB,EACrB,KAAK,4BAA4B,EAEjC,KAAK,KAAK,EAGV,MAAM,qBAAqB,CAAC;AAE7B,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAEnE,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,KAAK,SAAS,EAAe,MAAM,YAAY,CAAC;AAEzD,OAAO,EAAE,KAAK,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAE7E,MAAM,WAAW,UAAU;IAC1B;;OAEG;IACH,OAAO,IAAI,IAAI,CAAC;CAChB;AAED;;GAEG;AACH,wBAAgB,eAAe,CAC9B,MAAM,EAAE,4BAA4B,EACpC,MAAM,EAAE,gBAAgB,GACtB,QAAQ,CASV;AAED;;;;;GAKG;AACH,MAAM,WAAW,QAAS,SAAQ,WAAW,EAAE,UAAU;IACxD,QAAQ,CAAC,MAAM,EAAE,4BAA4B,CAAC;IAC9C,KAAK,CAAC,MAAM,EAAE,4BAA4B,GAAG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EvC;;OAEG;IACH,eAAe,CAAC,MAAM,EAAE,wBAAwB,GAAG,SAAS,CAAC;CAC7D;AAED,MAAM,WAAW,eAAe;IAC/B,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC;IAC7B;;;;;OAKG;IACH,QAAQ,CAAC,YAAY,EAAE,aAAa,GAAG,SAAS,CAAC;CACjD;AAaD;;;;;GAKG;AACH,wBAAgB,UAAU,CACzB,MAAM,EAAE,sBAAsB,EAC9B,eAAe,EAAE,eAAe,EAChC,MAAM,EAAE,MAAM,EACd,kBAAkB,EAAE,OAAO,GACzB,SAAS,EAAE,CA8Fb;AACD;;;GAGG;AACH,wBAAgB,YAAY,CAC3B,MAAM,EAAE,sBAAsB,EAC9B,KAAK,EAAE,SAAS,EAChB,MAAM,EAAE,KAAK,EAAE,EACf,YAAY,CAAC,EAAE,aAAa,GAC1B,IAAI,CA4BN;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,sBAAsB,CACrC,MAAM,EAAE,sBAAsB,EAC9B,KAAK,EAAE,SAAS,EAChB,iBAAiB,EAAE,MAAM,EACzB,kBAAkB,EAAE,OAAO,EAC3B,YAAY,CAAC,EAAE,aAAa,GAC1B,YAAY,CAqBd"}
@@ -12,6 +12,7 @@ const basicChunk_js_1 = require("./basicChunk.js");
12
12
  const chunk_js_1 = require("./chunk.js");
13
13
  const sequenceChunk_js_1 = require("./sequenceChunk.js");
14
14
  const uniformChunk_js_1 = require("./uniformChunk.js");
15
+ const index_js_3 = require("../node-key/index.js");
15
16
  /**
16
17
  * Creates a ChunkPolicy which responds to schema changes.
17
18
  */
@@ -152,7 +153,13 @@ function tryShapeFromSchema(schema, policy, type, shapes) {
152
153
  return (0, index_js_2.getOrCreate)(shapes, type, () => {
153
154
  const treeSchema = schema.nodeSchema.get(type) ?? (0, index_js_2.fail)("missing schema");
154
155
  if (treeSchema instanceof index_js_1.LeafNodeStoredSchema) {
155
- return new uniformChunk_js_1.TreeShape(type, true, []);
156
+ // Allow all string values (but only string values) to be compressed by the id compressor.
157
+ // This allows compressing all compressible identifiers without requiring additional context to know which values could be identifiers.
158
+ // Attempting to compress other string shouldn't have significant overhead,
159
+ // and if any of them do end up compressing, that's a benefit not a bug.
160
+ return treeSchema.leafValue === index_js_1.ValueSchema.String
161
+ ? new uniformChunk_js_1.TreeShape(type, true, [], true)
162
+ : new uniformChunk_js_1.TreeShape(type, true, [], false);
156
163
  }
157
164
  if (treeSchema instanceof index_js_1.ObjectNodeStoredSchema) {
158
165
  const fieldsArray = [];
@@ -220,7 +227,7 @@ function newBasicChunkTree(cursor, policy) {
220
227
  * @param length - how many nodes to process (at the top level)
221
228
  * @param skipLastNavigation - if true, leaves the cursor at the last node instead of moving off of it.
222
229
  */
223
- function chunkRange(cursor, policy, length, skipLastNavigation) {
230
+ function chunkRange(cursor, chunkCompressor, length, skipLastNavigation) {
224
231
  (0, internal_1.assert)(cursor.mode === 0 /* CursorLocationType.Nodes */, 0x57e /* should be in nodes */);
225
232
  let output = [];
226
233
  let remaining = length;
@@ -236,7 +243,7 @@ function chunkRange(cursor, policy, length, skipLastNavigation) {
236
243
  const chunk = (0, chunk_js_1.tryGetChunk)(cursor);
237
244
  if (chunk !== undefined) {
238
245
  if (chunk instanceof sequenceChunk_js_1.SequenceChunk &&
239
- chunk.subChunks.length <= policy.sequenceChunkInlineThreshold) {
246
+ chunk.subChunks.length <= chunkCompressor.policy.sequenceChunkInlineThreshold) {
240
247
  // If sequence chunk, and its very short, inline it.
241
248
  // Note that this is not recursive: there may be short sequences nested below this which are not inlined.
242
249
  for (const subChunk of chunk.subChunks) {
@@ -260,18 +267,18 @@ function chunkRange(cursor, policy, length, skipLastNavigation) {
260
267
  (0, internal_1.assert)(cursor.mode === 0 /* CursorLocationType.Nodes */, 0x580 /* should be in nodes */);
261
268
  // TODO: if provided, use schema to consider using UniformChunks
262
269
  const type = cursor.type;
263
- const shape = policy.shapeFromSchema(type);
270
+ const shape = chunkCompressor.policy.shapeFromSchema(type);
264
271
  if (shape instanceof uniformChunk_js_1.TreeShape) {
265
272
  const nodesPerTopLevelNode = shape.positions.length;
266
- const maxTopLevelLength = Math.ceil(nodesPerTopLevelNode / policy.uniformChunkNodeCount);
273
+ const maxTopLevelLength = Math.ceil(nodesPerTopLevelNode / chunkCompressor.policy.uniformChunkNodeCount);
267
274
  const maxLength = Math.min(maxTopLevelLength, remaining);
268
- const newChunk = uniformChunkFromCursor(cursor, shape, maxLength, maxLength === remaining && skipLastNavigation);
275
+ const newChunk = uniformChunkFromCursor(cursor, shape, maxLength, maxLength === remaining && skipLastNavigation, chunkCompressor.idCompressor);
269
276
  remaining -= newChunk.topLevelLength;
270
277
  output.push(newChunk);
271
278
  }
272
279
  else {
273
280
  // Slow path: copy tree into new basic chunk
274
- output.push(newBasicChunkTree(cursor, policy));
281
+ output.push(newBasicChunkTree(cursor, chunkCompressor));
275
282
  remaining -= 1;
276
283
  if (!skipLastNavigation || remaining !== 0) {
277
284
  cursor.nextNode();
@@ -281,8 +288,8 @@ function chunkRange(cursor, policy, length, skipLastNavigation) {
281
288
  }
282
289
  // TODO: maybe make a pass over output to coalesce UniformChunks and/or convert other formats to UniformChunks where possible.
283
290
  // If output is large, group it into a tree of sequence chunks.
284
- while (output.length > policy.sequenceChunkSplitThreshold) {
285
- const chunkCount = Math.ceil(output.length / policy.sequenceChunkSplitThreshold);
291
+ while (output.length > chunkCompressor.policy.sequenceChunkSplitThreshold) {
292
+ const chunkCount = Math.ceil(output.length / chunkCompressor.policy.sequenceChunkSplitThreshold);
286
293
  const newOutput = [];
287
294
  // Rounding down, and add an extra item to some of the chunks.
288
295
  const chunkSize = Math.floor(output.length / chunkCount);
@@ -301,19 +308,30 @@ function chunkRange(cursor, policy, length, skipLastNavigation) {
301
308
  return output;
302
309
  }
303
310
  exports.chunkRange = chunkRange;
304
- function insertValues(cursor, shape, values) {
311
+ /**
312
+ * @param idCompressor - compressor used to encoded string values that are compressible by the idCompressor for in-memory representation.
313
+ * If the idCompressor is not provided, the values will be the original uncompressed values.
314
+ */
315
+ function insertValues(cursor, shape, values, idCompressor) {
305
316
  (0, internal_1.assert)(shape.type === cursor.type, 0x582 /* shape and type must match */);
306
317
  // TODO:Perf:
307
318
  // Fast path for already part of a uniform chunk with matching shape
308
319
  // Slow path: walk shape and cursor together, inserting values.
309
320
  if (shape.hasValue) {
310
- values.push(cursor.value);
321
+ if (typeof cursor.value === "string" &&
322
+ idCompressor !== undefined &&
323
+ (0, index_js_3.isStableNodeKey)(cursor.value)) {
324
+ values.push(idCompressor.tryRecompress(cursor.value) ?? cursor.value);
325
+ }
326
+ else {
327
+ values.push(cursor.value);
328
+ }
311
329
  }
312
330
  for (const [key, childShape, length] of shape.fieldsArray) {
313
331
  cursor.enterField(key);
314
332
  let count = 0;
315
333
  for (let inNodes = cursor.firstNode(); inNodes; inNodes = cursor.nextNode()) {
316
- insertValues(cursor, childShape, values);
334
+ insertValues(cursor, childShape, values, idCompressor);
317
335
  count++;
318
336
  }
319
337
  cursor.exitField();
@@ -330,14 +348,17 @@ exports.insertValues = insertValues;
330
348
  * If this stops early due to the type changing, `skipLastNavigation` is not involved:
331
349
  * `skipLastNavigation` only determines if the cursor will be left on the node after the last one (possibly exiting the field)
332
350
  * if the full length is used.
351
+ *
352
+ * @param idCompressor - compressor used to encoded string values that are compressible by the idCompressor for in-memory representation.
353
+ * If the idCompressor is not provided, the values will be the original uncompressed values.
333
354
  */
334
- function uniformChunkFromCursor(cursor, shape, maxTopLevelLength, skipLastNavigation) {
355
+ function uniformChunkFromCursor(cursor, shape, maxTopLevelLength, skipLastNavigation, idCompressor) {
335
356
  // TODO:
336
357
  // This could have a fast path for consuming already uniformly chunked data with matching shape.
337
358
  const values = [];
338
359
  let topLevelLength = 1;
339
360
  while (topLevelLength <= maxTopLevelLength) {
340
- insertValues(cursor, shape, values);
361
+ insertValues(cursor, shape, values, idCompressor);
341
362
  if (topLevelLength === maxTopLevelLength) {
342
363
  if (!skipLastNavigation) {
343
364
  cursor.nextNode();
@@ -350,7 +371,7 @@ function uniformChunkFromCursor(cursor, shape, maxTopLevelLength, skipLastNaviga
350
371
  }
351
372
  topLevelLength += 1;
352
373
  }
353
- return new uniformChunk_js_1.UniformChunk(shape.withTopLevelLength(topLevelLength), values);
374
+ return new uniformChunk_js_1.UniformChunk(shape.withTopLevelLength(topLevelLength), values, idCompressor);
354
375
  }
355
376
  exports.uniformChunkFromCursor = uniformChunkFromCursor;
356
377
  //# sourceMappingURL=chunkTree.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"chunkTree.js","sourceRoot":"","sources":["../../../src/feature-libraries/chunked-forest/chunkTree.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAAkE;AAElE,kDAe6B;AAC7B,kDAAwD;AAGxD,mDAA6C;AAC7C,yCAAyD;AACzD,yDAAmD;AACnD,uDAA6E;AAS7E;;GAEG;AACH,SAAgB,eAAe,CAC9B,MAAoC,EACpC,MAAwB;IAExB,OAAO,IAAI,OAAO,CACjB,MAAM,EACN,MAAM,EACN,0BAAkB,CAAC,4BAA4B,EAC/C,0BAAkB,CAAC,4BAA4B,EAC/C,0BAAkB,CAAC,qBAAqB,EACxC,kBAAkB,CAClB,CAAC;AACH,CAAC;AAZD,0CAYC;AAaD;;;;;;;;GAQG;AACH,kEAAkE;AAClE,MAAa,WAAW;CAAG;AAA3B,kCAA2B;AAE3B;;;GAGG;AACU,QAAA,WAAW,GAAG,IAAI,WAAW,EAAE,CAAC;AAQ7C,MAAa,OAAO;IAUnB,YACiB,MAAoC,EACpC,MAAwB,EACxB,2BAAmC,EACnC,4BAAoC,EACpC,qBAA6B;IAC7C,wDAAwD;IACvC,kBAKH;QAXE,WAAM,GAAN,MAAM,CAA8B;QACpC,WAAM,GAAN,MAAM,CAAkB;QACxB,gCAA2B,GAA3B,2BAA2B,CAAQ;QACnC,iCAA4B,GAA5B,4BAA4B,CAAQ;QACpC,0BAAqB,GAArB,qBAAqB,CAAQ;QAE5B,uBAAkB,GAAlB,kBAAkB,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C;AAxBD,oCAwBC;AAED;;;;;;;;;GASG;AACH,SAAgB,sBAAsB,CACrC,MAA8B,EAC9B,KAAgB,EAChB,iBAAyB,EACzB,kBAA2B;IAE3B,QAAQ;IACR,gGAAgG;IAEhG,MAAM,MAAM,GAAgB,EAAE,CAAC;IAC/B,IAAI,cAAc,GAAG,CAAC,CAAC;IACvB,OAAO,cAAc,IAAI,iBAAiB,EAAE,CAAC;QAC5C,YAAY,CAAC,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC;QACpC,IAAI,cAAc,KAAK,iBAAiB,EAAE,CAAC;YAC1C,IAAI,CAAC,kBAAkB,EAAE,CAAC;gBACzB,MAAM,CAAC,QAAQ,EAAE,CAAC;YACnB,CAAC;YACD,MAAM;QACP,CAAC;QACD,MAAM,CAAC,QAAQ,EAAE,CAAC;QAClB,IAAI,MAAM,CAAC,IAAI,KAAK,KAAK,CAAC,IAAI,EAAE,CAAC;YAChC,MAAM;QACP,CAAC;QACD,cAAc,IAAI,CAAC,CAAC;IACrB,CAAC;IACD,OAAO,IAAI,8BAAY,CAAC,KAAK,CAAC,kBAAkB,CAAC,cAAc,CAAC,EAAE,MAAM,CAAC,CAAC;AAC3E,CAAC;AA1BD,wDA0BC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, oob } from \"@fluidframework/core-utils/internal\";\n\nimport {\n\tCursorLocationType,\n\ttype FieldKey,\n\ttype ITreeCursorSynchronous,\n\tLeafNodeStoredSchema,\n\tObjectNodeStoredSchema,\n\ttype StoredSchemaCollection,\n\ttype TreeFieldStoredSchema,\n\ttype TreeNodeSchemaIdentifier,\n\ttype TreeStoredSchema,\n\ttype TreeStoredSchemaSubscription,\n\ttype TreeValue,\n\ttype Value,\n\tmapCursorFields,\n\tMultiplicity,\n} from \"../../core/index.js\";\nimport { fail, getOrCreate } from \"../../util/index.js\";\nimport type { FullSchemaPolicy } from \"../modular-schema/index.js\";\n\nimport { BasicChunk } from \"./basicChunk.js\";\nimport { type TreeChunk, tryGetChunk } from \"./chunk.js\";\nimport { SequenceChunk } from \"./sequenceChunk.js\";\nimport { type FieldShape, TreeShape, UniformChunk } from \"./uniformChunk.js\";\n\nexport interface Disposable {\n\t/**\n\t * Cleans up resources used by this, such as inbound event registrations.\n\t */\n\tdispose(): void;\n}\n\n/**\n * Creates a ChunkPolicy which responds to schema changes.\n */\nexport function makeTreeChunker(\n\tschema: TreeStoredSchemaSubscription,\n\tpolicy: FullSchemaPolicy,\n): IChunker {\n\treturn new Chunker(\n\t\tschema,\n\t\tpolicy,\n\t\tdefaultChunkPolicy.sequenceChunkInlineThreshold,\n\t\tdefaultChunkPolicy.sequenceChunkInlineThreshold,\n\t\tdefaultChunkPolicy.uniformChunkNodeCount,\n\t\ttryShapeFromSchema,\n\t);\n}\n\n/**\n * Extends ChunkPolicy to include stateful details required by ChunkedForest.\n *\n * This extra complexity is mostly due to the fact that schema can change over time,\n * and that chunk policy uses caching which thus needs invalidation.\n */\nexport interface IChunker extends ChunkPolicy, Disposable {\n\treadonly schema: TreeStoredSchemaSubscription;\n\tclone(schema: TreeStoredSchemaSubscription): IChunker;\n}\n\n/**\n * Indicates that there are multiple possible `TreeShape` trees with a given type can have.\n *\n * @remarks\n * For example, a schema transitively containing a sequence field, optional field, or allowing multiple child types will be Polymorphic.\n * See `tryShapeFromSchema` for how to tell if a type is Polymorphic.\n *\n * TODO: cache some of the possible shapes here.\n */\n// eslint-disable-next-line @typescript-eslint/no-extraneous-class\nexport class Polymorphic {}\n\n/**\n * See `Polymorphic`.\n * For now Polymorphic is stateless, so just use a singleton.\n */\nexport const polymorphic = new Polymorphic();\n\n/**\n * Information about the possible shapes a tree could take based on its type.\n * Note that this information is for a specific version of the schema.\n */\nexport type ShapeInfo = TreeShape | Polymorphic;\n\nexport class Chunker implements IChunker {\n\t/**\n\t * Cache for information about possible shapes for types.\n\t * Corresponds to the version of the schema in `schema`.\n\t * Cleared when `schema` changes.\n\t */\n\tprivate readonly typeShapes: Map<TreeNodeSchemaIdentifier, ShapeInfo> = new Map();\n\n\tprivate unregisterSchemaCallback: (() => void) | undefined;\n\n\tpublic constructor(\n\t\tpublic readonly schema: TreeStoredSchemaSubscription,\n\t\tpublic readonly policy: FullSchemaPolicy,\n\t\tpublic readonly sequenceChunkSplitThreshold: number,\n\t\tpublic readonly sequenceChunkInlineThreshold: number,\n\t\tpublic readonly uniformChunkNodeCount: number,\n\t\t// eslint-disable-next-line @typescript-eslint/no-shadow\n\t\tprivate readonly tryShapeFromSchema: (\n\t\t\tschema: TreeStoredSchema,\n\t\t\tpolicy: FullSchemaPolicy,\n\t\t\ttype: TreeNodeSchemaIdentifier,\n\t\t\tshapes: Map<TreeNodeSchemaIdentifier, ShapeInfo>,\n\t\t) => ShapeInfo,\n\t) {}\n\n\tpublic clone(schema: TreeStoredSchemaSubscription): IChunker {\n\t\t// This does not preserve the cache.\n\t\t// This is probably fine, but is a potential way it could be optimized in the future (with care to ensure invalidation work properly).\n\t\treturn new Chunker(\n\t\t\tschema,\n\t\t\tthis.policy,\n\t\t\tthis.sequenceChunkSplitThreshold,\n\t\t\tthis.sequenceChunkInlineThreshold,\n\t\t\tthis.uniformChunkNodeCount,\n\t\t\tthis.tryShapeFromSchema,\n\t\t);\n\t}\n\n\tpublic shapeFromSchema(schema: TreeNodeSchemaIdentifier): ShapeInfo {\n\t\tconst cached = this.typeShapes.get(schema);\n\t\tif (cached !== undefined) {\n\t\t\treturn cached;\n\t\t}\n\t\tthis.unregisterSchemaCallback = this.schema.on(\"afterSchemaChange\", () =>\n\t\t\tthis.schemaChanged(),\n\t\t);\n\t\treturn this.tryShapeFromSchema(this.schema, this.policy, schema, this.typeShapes);\n\t}\n\n\tpublic dispose(): void {\n\t\t// Remove subscription for changes via dependent.\n\t\tthis.schemaChanged();\n\t}\n\n\tprivate schemaChanged(): void {\n\t\tthis.typeShapes.clear();\n\t\tif (this.unregisterSchemaCallback) {\n\t\t\tthis.unregisterSchemaCallback();\n\t\t\tthis.unregisterSchemaCallback = undefined;\n\t\t}\n\t}\n}\n\n/**\n * Get a TreeChunk for the current node (and its children) of cursor.\n * This will copy if needed, but add refs to existing chunks which hold the data.\n *\n * @param cursor - cursor in nodes mode\n */\nexport function chunkTree(cursor: ITreeCursorSynchronous, policy: ChunkPolicy): TreeChunk {\n\treturn chunkRange(cursor, policy, 1, true)[0] ?? oob();\n}\n\n/**\n * Get a TreeChunk[] for the current field (and its children) of cursor.\n * This will copy if needed, but add refs to existing chunks which hold the data.\n */\nexport function chunkField(cursor: ITreeCursorSynchronous, policy: ChunkPolicy): TreeChunk[] {\n\tconst length = cursor.getFieldLength();\n\tconst started = cursor.firstNode();\n\tassert(started, 0x57c /* field to chunk should have at least one node */);\n\treturn chunkRange(cursor, policy, length, false);\n}\n\n/**\n * Get a TreeChunk for the current field (and its children) of cursor.\n * Like {@link chunkField}, but forces the results into a single TreeChunk.\n */\nexport function chunkFieldSingle(\n\tcursor: ITreeCursorSynchronous,\n\tpolicy: ChunkPolicy,\n): TreeChunk {\n\tconst chunks = chunkField(cursor, policy);\n\tif (chunks.length === 1) {\n\t\treturn chunks[0] ?? oob();\n\t}\n\treturn new SequenceChunk(chunks);\n}\n\n/**\n * Get a BasicChunk for the current node (and its children) of cursor.\n * This will copy if needed, and add refs to existing chunks which hold the data.\n */\nexport function basicChunkTree(\n\tcursor: ITreeCursorSynchronous,\n\tpolicy: ChunkPolicy,\n): BasicChunk {\n\t// symbol based fast path to check for BasicChunk:\n\t// return existing chunk with a increased ref count if possible.\n\tconst chunk = tryGetChunk(cursor);\n\tif (chunk instanceof BasicChunk) {\n\t\tchunk.referenceAdded();\n\t\treturn chunk;\n\t}\n\n\treturn newBasicChunkTree(cursor, policy);\n}\n\nexport function makePolicy(policy?: Partial<ChunkPolicy>): ChunkPolicy {\n\tconst withDefaults = { ...defaultChunkPolicy, ...policy };\n\t// TODO: move this to a top level policy validation\n\tassert(\n\t\twithDefaults.sequenceChunkSplitThreshold >= 2,\n\t\t0x57d /* sequenceChunkThreshold must be at least 2 */,\n\t);\n\n\treturn withDefaults;\n}\n\nexport function shapesFromSchema(\n\tschema: StoredSchemaCollection,\n\tpolicy: FullSchemaPolicy,\n): Map<TreeNodeSchemaIdentifier, ShapeInfo> {\n\tconst shapes: Map<TreeNodeSchemaIdentifier, ShapeInfo> = new Map();\n\tfor (const identifier of schema.nodeSchema.keys()) {\n\t\ttryShapeFromSchema(schema, policy, identifier, shapes);\n\t}\n\treturn shapes;\n}\n\n/**\n * If `schema` has only one shape, return it.\n *\n * Note that this does not tolerate optional or sequence fields, nor does it optimize for patterns of specific values.\n */\nexport function tryShapeFromSchema(\n\tschema: StoredSchemaCollection,\n\tpolicy: FullSchemaPolicy,\n\ttype: TreeNodeSchemaIdentifier,\n\tshapes: Map<TreeNodeSchemaIdentifier, ShapeInfo>,\n): ShapeInfo {\n\treturn getOrCreate(shapes, type, () => {\n\t\tconst treeSchema = schema.nodeSchema.get(type) ?? fail(\"missing schema\");\n\t\tif (treeSchema instanceof LeafNodeStoredSchema) {\n\t\t\treturn new TreeShape(type, true, []);\n\t\t}\n\t\tif (treeSchema instanceof ObjectNodeStoredSchema) {\n\t\t\tconst fieldsArray: FieldShape[] = [];\n\t\t\tfor (const [key, field] of treeSchema.objectNodeFields) {\n\t\t\t\tconst fieldShape = tryShapeFromFieldSchema(schema, policy, field, key, shapes);\n\t\t\t\tif (fieldShape === undefined) {\n\t\t\t\t\treturn polymorphic;\n\t\t\t\t}\n\t\t\t\tfieldsArray.push(fieldShape);\n\t\t\t}\n\t\t\treturn new TreeShape(type, false, fieldsArray);\n\t\t}\n\t\treturn polymorphic;\n\t});\n}\n\n/**\n * If `schema` has only one shape, return it.\n *\n * Note that this does not tolerate optional or sequence fields, nor does it optimize for patterns of specific values.\n */\nexport function tryShapeFromFieldSchema(\n\tschema: StoredSchemaCollection,\n\tpolicy: FullSchemaPolicy,\n\ttype: TreeFieldStoredSchema,\n\tkey: FieldKey,\n\tshapes: Map<TreeNodeSchemaIdentifier, ShapeInfo>,\n): FieldShape | undefined {\n\tconst kind = policy.fieldKinds.get(type.kind) ?? fail(\"missing FieldKind\");\n\tif (kind.multiplicity !== Multiplicity.Single) {\n\t\treturn undefined;\n\t}\n\tif (type.types?.size !== 1) {\n\t\treturn undefined;\n\t}\n\tconst childType = [...type.types][0] ?? oob();\n\tconst childShape = tryShapeFromSchema(schema, policy, childType, shapes);\n\tif (childShape instanceof Polymorphic) {\n\t\treturn undefined;\n\t}\n\treturn [key, childShape, 1];\n}\n\n/**\n * Default settings for use for {@link ChunkPolicy}.\n * Use `makeTreeChunker` to create a policy with the defaults, but leverages to schema.\n */\nexport const defaultChunkPolicy: ChunkPolicy = {\n\t// Currently ChunkedForest and BasicTreeCursor don't handle SequenceChunks very efficiently:\n\t// they likely add more overhead than they save for now, so don't create them.\n\tsequenceChunkSplitThreshold: Number.POSITIVE_INFINITY,\n\tsequenceChunkInlineThreshold: Number.POSITIVE_INFINITY,\n\t// Current UniformChunk handling doesn't scale well to large chunks, so set a modest size limit:\n\tuniformChunkNodeCount: 400,\n\t// Without knowing what the schema is, all shapes are possible.\n\t// Use `makeTreeChunker` to do better.\n\tshapeFromSchema: () => polymorphic,\n};\n\nexport const basicOnlyChunkPolicy: ChunkPolicy = {\n\tsequenceChunkSplitThreshold: Number.POSITIVE_INFINITY,\n\tsequenceChunkInlineThreshold: Number.POSITIVE_INFINITY,\n\tuniformChunkNodeCount: 0,\n\tshapeFromSchema: () => polymorphic,\n};\n\n/**\n * Policy for how to chunk a tree.\n */\nexport interface ChunkPolicy {\n\t/**\n\t * Group sequences longer than this into into sequence chunks of this length or less.\n\t *\n\t * Must be at least 2.\n\t * Can be set to `Number.POSITIVE_INFINITY` to never introduce extra sequence chunks.\n\t */\n\treadonly sequenceChunkSplitThreshold: number;\n\n\t/**\n\t * SequenceChunks this long or shorter may get inlined into their parent chunk.\n\t */\n\treadonly sequenceChunkInlineThreshold: number;\n\n\t/**\n\t * Maximum total nodes to put in a UniformChunk.\n\t */\n\treadonly uniformChunkNodeCount: number;\n\n\t/**\n\t * Returns information about the shapes trees of type `schema` can take.\n\t */\n\tshapeFromSchema(schema: TreeNodeSchemaIdentifier): ShapeInfo;\n}\n\nfunction newBasicChunkTree(cursor: ITreeCursorSynchronous, policy: ChunkPolicy): BasicChunk {\n\treturn new BasicChunk(\n\t\tcursor.type,\n\t\tnew Map(mapCursorFields(cursor, () => [cursor.getFieldKey(), chunkField(cursor, policy)])),\n\t\tcursor.value,\n\t);\n}\n\n/**\n * @param cursor - cursor in nodes mode\n * @param policy - heuristics to impact chunking\n * @param length - how many nodes to process (at the top level)\n * @param skipLastNavigation - if true, leaves the cursor at the last node instead of moving off of it.\n */\nexport function chunkRange(\n\tcursor: ITreeCursorSynchronous,\n\tpolicy: ChunkPolicy,\n\tlength: number,\n\tskipLastNavigation: boolean,\n): TreeChunk[] {\n\tassert(cursor.mode === CursorLocationType.Nodes, 0x57e /* should be in nodes */);\n\tlet output: TreeChunk[] = [];\n\tlet remaining = length;\n\twhile (remaining > 0) {\n\t\tassert(cursor.mode === CursorLocationType.Nodes, 0x57f /* should be in nodes */);\n\t\tconst start = cursor.chunkStart;\n\t\tlet reusedChunk = false;\n\t\t// symbol based fast path to check for chunk:\n\t\t// return existing chunk with a increased ref count if possible.\n\t\tif (start === cursor.fieldIndex) {\n\t\t\tconst chunkLength = cursor.chunkLength;\n\t\t\tif (chunkLength <= remaining) {\n\t\t\t\tconst chunk = tryGetChunk(cursor);\n\t\t\t\tif (chunk !== undefined) {\n\t\t\t\t\tif (\n\t\t\t\t\t\tchunk instanceof SequenceChunk &&\n\t\t\t\t\t\tchunk.subChunks.length <= policy.sequenceChunkInlineThreshold\n\t\t\t\t\t) {\n\t\t\t\t\t\t// If sequence chunk, and its very short, inline it.\n\t\t\t\t\t\t// Note that this is not recursive: there may be short sequences nested below this which are not inlined.\n\t\t\t\t\t\tfor (const subChunk of chunk.subChunks) {\n\t\t\t\t\t\t\tsubChunk.referenceAdded();\n\t\t\t\t\t\t\toutput.push(subChunk);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tchunk.referenceAdded();\n\t\t\t\t\toutput.push(chunk);\n\t\t\t\t\tremaining -= chunkLength;\n\t\t\t\t\treusedChunk = true;\n\t\t\t\t\tlet seek = chunkLength;\n\t\t\t\t\tif (skipLastNavigation && remaining === 0) {\n\t\t\t\t\t\tseek -= 1;\n\t\t\t\t\t}\n\t\t\t\t\tcursor.seekNodes(seek);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (!reusedChunk) {\n\t\t\tassert(cursor.mode === CursorLocationType.Nodes, 0x580 /* should be in nodes */);\n\t\t\t// TODO: if provided, use schema to consider using UniformChunks\n\t\t\tconst type = cursor.type;\n\t\t\tconst shape = policy.shapeFromSchema(type);\n\t\t\tif (shape instanceof TreeShape) {\n\t\t\t\tconst nodesPerTopLevelNode = shape.positions.length;\n\t\t\t\tconst maxTopLevelLength = Math.ceil(\n\t\t\t\t\tnodesPerTopLevelNode / policy.uniformChunkNodeCount,\n\t\t\t\t);\n\t\t\t\tconst maxLength = Math.min(maxTopLevelLength, remaining);\n\t\t\t\tconst newChunk = uniformChunkFromCursor(\n\t\t\t\t\tcursor,\n\t\t\t\t\tshape,\n\t\t\t\t\tmaxLength,\n\t\t\t\t\tmaxLength === remaining && skipLastNavigation,\n\t\t\t\t);\n\t\t\t\tremaining -= newChunk.topLevelLength;\n\t\t\t\toutput.push(newChunk);\n\t\t\t} else {\n\t\t\t\t// Slow path: copy tree into new basic chunk\n\t\t\t\toutput.push(newBasicChunkTree(cursor, policy));\n\t\t\t\tremaining -= 1;\n\t\t\t\tif (!skipLastNavigation || remaining !== 0) {\n\t\t\t\t\tcursor.nextNode();\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t// TODO: maybe make a pass over output to coalesce UniformChunks and/or convert other formats to UniformChunks where possible.\n\n\t// If output is large, group it into a tree of sequence chunks.\n\twhile (output.length > policy.sequenceChunkSplitThreshold) {\n\t\tconst chunkCount = Math.ceil(output.length / policy.sequenceChunkSplitThreshold);\n\t\tconst newOutput: TreeChunk[] = [];\n\t\t// Rounding down, and add an extra item to some of the chunks.\n\t\tconst chunkSize = Math.floor(output.length / chunkCount);\n\t\t// number of chunks to add an extra item to to make total line up.\n\t\tconst extra = output.length % chunkCount;\n\t\tlet previousEnd = 0;\n\t\tfor (let index = 0; index < chunkCount; index++) {\n\t\t\t// If we are in the first `extra` items, add an extra to this chunk.\n\t\t\tconst end = previousEnd + chunkSize + (index < extra ? 1 : 0);\n\t\t\tnewOutput.push(new SequenceChunk(output.slice(previousEnd, end)));\n\t\t\tpreviousEnd = end;\n\t\t}\n\t\tassert(previousEnd === output.length, 0x581 /* chunks should add up to total */);\n\t\toutput = newOutput;\n\t}\n\n\treturn output;\n}\n\nexport function insertValues(\n\tcursor: ITreeCursorSynchronous,\n\tshape: TreeShape,\n\tvalues: Value[],\n): void {\n\tassert(shape.type === cursor.type, 0x582 /* shape and type must match */);\n\n\t// TODO:Perf:\n\t// Fast path for already part of a uniform chunk with matching shape\n\n\t// Slow path: walk shape and cursor together, inserting values.\n\tif (shape.hasValue) {\n\t\tvalues.push(cursor.value);\n\t}\n\tfor (const [key, childShape, length] of shape.fieldsArray) {\n\t\tcursor.enterField(key);\n\t\tlet count = 0;\n\t\tfor (let inNodes = cursor.firstNode(); inNodes; inNodes = cursor.nextNode()) {\n\t\t\tinsertValues(cursor, childShape, values);\n\t\t\tcount++;\n\t\t}\n\t\tcursor.exitField();\n\t\tassert(length === count, 0x583 /* unexpected field length */);\n\t}\n}\n\n/**\n * Read up to `maxTopLevelLength` nodes from `cursor`, stopping when limit is hit or type of node changes.\n *\n * This requires that the all trees with matching type match the provided shape.\n * This cannot be used if other shapes are possible for this type.\n *\n * If this stops early due to the type changing, `skipLastNavigation` is not involved:\n * `skipLastNavigation` only determines if the cursor will be left on the node after the last one (possibly exiting the field)\n * if the full length is used.\n */\nexport function uniformChunkFromCursor(\n\tcursor: ITreeCursorSynchronous,\n\tshape: TreeShape,\n\tmaxTopLevelLength: number,\n\tskipLastNavigation: boolean,\n): UniformChunk {\n\t// TODO:\n\t// This could have a fast path for consuming already uniformly chunked data with matching shape.\n\n\tconst values: TreeValue[] = [];\n\tlet topLevelLength = 1;\n\twhile (topLevelLength <= maxTopLevelLength) {\n\t\tinsertValues(cursor, shape, values);\n\t\tif (topLevelLength === maxTopLevelLength) {\n\t\t\tif (!skipLastNavigation) {\n\t\t\t\tcursor.nextNode();\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t\tcursor.nextNode();\n\t\tif (cursor.type !== shape.type) {\n\t\t\tbreak;\n\t\t}\n\t\ttopLevelLength += 1;\n\t}\n\treturn new UniformChunk(shape.withTopLevelLength(topLevelLength), values);\n}\n"]}
1
+ {"version":3,"file":"chunkTree.js","sourceRoot":"","sources":["../../../src/feature-libraries/chunked-forest/chunkTree.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAAkE;AAElE,kDAgB6B;AAC7B,kDAAwD;AAGxD,mDAA6C;AAC7C,yCAAyD;AACzD,yDAAmD;AACnD,uDAA6E;AAC7E,mDAAuD;AAUvD;;GAEG;AACH,SAAgB,eAAe,CAC9B,MAAoC,EACpC,MAAwB;IAExB,OAAO,IAAI,OAAO,CACjB,MAAM,EACN,MAAM,EACN,0BAAkB,CAAC,4BAA4B,EAC/C,0BAAkB,CAAC,4BAA4B,EAC/C,0BAAkB,CAAC,qBAAqB,EACxC,kBAAkB,CAClB,CAAC;AACH,CAAC;AAZD,0CAYC;AAaD;;;;;;;;GAQG;AACH,kEAAkE;AAClE,MAAa,WAAW;CAAG;AAA3B,kCAA2B;AAE3B;;;GAGG;AACU,QAAA,WAAW,GAAG,IAAI,WAAW,EAAE,CAAC;AAQ7C,MAAa,OAAO;IAUnB,YACiB,MAAoC,EACpC,MAAwB,EACxB,2BAAmC,EACnC,4BAAoC,EACpC,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AAI,cAAc,KAAK,iBAAiB,EAAE,CAAC;YAC1C,IAAI,CAAC,kBAAkB,EAAE,CAAC;gBACzB,MAAM,CAAC,QAAQ,EAAE,CAAC;YACnB,CAAC;YACD,MAAM;QACP,CAAC;QACD,MAAM,CAAC,QAAQ,EAAE,CAAC;QAClB,IAAI,MAAM,CAAC,IAAI,KAAK,KAAK,CAAC,IAAI,EAAE,CAAC;YAChC,MAAM;QACP,CAAC;QACD,cAAc,IAAI,CAAC,CAAC;IACrB,CAAC;IACD,OAAO,IAAI,8BAAY,CAAC,KAAK,CAAC,kBAAkB,CAAC,cAAc,CAAC,EAAE,MAAM,EAAE,YAAY,CAAC,CAAC;AACzF,CAAC;AA3BD,wDA2BC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, oob } from \"@fluidframework/core-utils/internal\";\n\nimport {\n\tCursorLocationType,\n\ttype FieldKey,\n\ttype ITreeCursorSynchronous,\n\tLeafNodeStoredSchema,\n\tObjectNodeStoredSchema,\n\ttype StoredSchemaCollection,\n\ttype TreeFieldStoredSchema,\n\ttype TreeNodeSchemaIdentifier,\n\ttype TreeStoredSchema,\n\ttype TreeStoredSchemaSubscription,\n\ttype TreeValue,\n\ttype Value,\n\tmapCursorFields,\n\tMultiplicity,\n\tValueSchema,\n} from \"../../core/index.js\";\nimport { fail, getOrCreate } from \"../../util/index.js\";\nimport type { FullSchemaPolicy } from \"../modular-schema/index.js\";\n\nimport { BasicChunk } from \"./basicChunk.js\";\nimport { type TreeChunk, tryGetChunk } from \"./chunk.js\";\nimport { SequenceChunk } from \"./sequenceChunk.js\";\nimport { type FieldShape, TreeShape, UniformChunk } from \"./uniformChunk.js\";\nimport { isStableNodeKey } from \"../node-key/index.js\";\nimport type { IIdCompressor } from \"@fluidframework/id-compressor\";\n\nexport interface Disposable {\n\t/**\n\t * Cleans up resources used by this, such as inbound event registrations.\n\t */\n\tdispose(): void;\n}\n\n/**\n * Creates a ChunkPolicy which responds to schema changes.\n */\nexport function makeTreeChunker(\n\tschema: TreeStoredSchemaSubscription,\n\tpolicy: FullSchemaPolicy,\n): IChunker {\n\treturn new Chunker(\n\t\tschema,\n\t\tpolicy,\n\t\tdefaultChunkPolicy.sequenceChunkInlineThreshold,\n\t\tdefaultChunkPolicy.sequenceChunkInlineThreshold,\n\t\tdefaultChunkPolicy.uniformChunkNodeCount,\n\t\ttryShapeFromSchema,\n\t);\n}\n\n/**\n * Extends ChunkPolicy to include stateful details required by ChunkedForest.\n *\n * This extra complexity is mostly due to the fact that schema can change over time,\n * and that chunk policy uses caching which thus needs invalidation.\n */\nexport interface IChunker extends ChunkPolicy, Disposable {\n\treadonly schema: TreeStoredSchemaSubscription;\n\tclone(schema: TreeStoredSchemaSubscription): IChunker;\n}\n\n/**\n * Indicates that there are multiple possible `TreeShape` trees with a given type can have.\n *\n * @remarks\n * For example, a schema transitively containing a sequence field, optional field, or allowing multiple child types will be Polymorphic.\n * See `tryShapeFromSchema` for how to tell if a type is Polymorphic.\n *\n * TODO: cache some of the possible shapes here.\n */\n// eslint-disable-next-line @typescript-eslint/no-extraneous-class\nexport class Polymorphic {}\n\n/**\n * See `Polymorphic`.\n * For now Polymorphic is stateless, so just use a singleton.\n */\nexport const polymorphic = new Polymorphic();\n\n/**\n * Information about the possible shapes a tree could take based on its type.\n * Note that this information is for a specific version of the schema.\n */\nexport type ShapeInfo = TreeShape | Polymorphic;\n\nexport class Chunker implements IChunker {\n\t/**\n\t * Cache for information about possible shapes for types.\n\t * Corresponds to the version of the schema in `schema`.\n\t * Cleared when `schema` changes.\n\t */\n\tprivate readonly typeShapes: Map<TreeNodeSchemaIdentifier, ShapeInfo> = new Map();\n\n\tprivate unregisterSchemaCallback: (() => void) | undefined;\n\n\tpublic constructor(\n\t\tpublic readonly schema: TreeStoredSchemaSubscription,\n\t\tpublic readonly policy: FullSchemaPolicy,\n\t\tpublic readonly sequenceChunkSplitThreshold: number,\n\t\tpublic readonly sequenceChunkInlineThreshold: number,\n\t\tpublic readonly uniformChunkNodeCount: number,\n\t\t// eslint-disable-next-line @typescript-eslint/no-shadow\n\t\tprivate readonly tryShapeFromSchema: (\n\t\t\tschema: TreeStoredSchema,\n\t\t\tpolicy: FullSchemaPolicy,\n\t\t\ttype: TreeNodeSchemaIdentifier,\n\t\t\tshapes: Map<TreeNodeSchemaIdentifier, ShapeInfo>,\n\t\t) => ShapeInfo,\n\t) {}\n\n\tpublic clone(schema: TreeStoredSchemaSubscription): IChunker {\n\t\t// This does not preserve the cache.\n\t\t// This is probably fine, but is a potential way it could be optimized in the future (with care to ensure invalidation work properly).\n\t\treturn new Chunker(\n\t\t\tschema,\n\t\t\tthis.policy,\n\t\t\tthis.sequenceChunkSplitThreshold,\n\t\t\tthis.sequenceChunkInlineThreshold,\n\t\t\tthis.uniformChunkNodeCount,\n\t\t\tthis.tryShapeFromSchema,\n\t\t);\n\t}\n\n\tpublic shapeFromSchema(schema: TreeNodeSchemaIdentifier): ShapeInfo {\n\t\tconst cached = this.typeShapes.get(schema);\n\t\tif (cached !== undefined) {\n\t\t\treturn cached;\n\t\t}\n\t\tthis.unregisterSchemaCallback = this.schema.on(\"afterSchemaChange\", () =>\n\t\t\tthis.schemaChanged(),\n\t\t);\n\t\treturn this.tryShapeFromSchema(this.schema, this.policy, schema, this.typeShapes);\n\t}\n\n\tpublic dispose(): void {\n\t\t// Remove subscription for changes via dependent.\n\t\tthis.schemaChanged();\n\t}\n\n\tprivate schemaChanged(): void {\n\t\tthis.typeShapes.clear();\n\t\tif (this.unregisterSchemaCallback) {\n\t\t\tthis.unregisterSchemaCallback();\n\t\t\tthis.unregisterSchemaCallback = undefined;\n\t\t}\n\t}\n}\n\n/**\n * Get a TreeChunk for the current node (and its children) of cursor.\n * This will copy if needed, but add refs to existing chunks which hold the data.\n *\n * @param cursor - cursor in nodes mode\n */\nexport function chunkTree(cursor: ITreeCursorSynchronous, policy: ChunkCompressor): TreeChunk {\n\treturn chunkRange(cursor, policy, 1, true)[0] ?? oob();\n}\n\n/**\n * Get a TreeChunk[] for the current field (and its children) of cursor.\n * This will copy if needed, but add refs to existing chunks which hold the data.\n */\nexport function chunkField(\n\tcursor: ITreeCursorSynchronous,\n\tpolicy: ChunkCompressor,\n): TreeChunk[] {\n\tconst length = cursor.getFieldLength();\n\tconst started = cursor.firstNode();\n\tassert(started, 0x57c /* field to chunk should have at least one node */);\n\treturn chunkRange(cursor, policy, length, false);\n}\n\n/**\n * Get a TreeChunk for the current field (and its children) of cursor.\n * Like {@link chunkField}, but forces the results into a single TreeChunk.\n */\nexport function chunkFieldSingle(\n\tcursor: ITreeCursorSynchronous,\n\tpolicy: ChunkCompressor,\n): TreeChunk {\n\tconst chunks = chunkField(cursor, policy);\n\tif (chunks.length === 1) {\n\t\treturn chunks[0] ?? oob();\n\t}\n\treturn new SequenceChunk(chunks);\n}\n\n/**\n * Get a BasicChunk for the current node (and its children) of cursor.\n * This will copy if needed, and add refs to existing chunks which hold the data.\n */\nexport function basicChunkTree(\n\tcursor: ITreeCursorSynchronous,\n\tpolicy: ChunkCompressor,\n): BasicChunk {\n\t// symbol based fast path to check for BasicChunk:\n\t// return existing chunk with a increased ref count if possible.\n\tconst chunk = tryGetChunk(cursor);\n\tif (chunk instanceof BasicChunk) {\n\t\tchunk.referenceAdded();\n\t\treturn chunk;\n\t}\n\n\treturn newBasicChunkTree(cursor, policy);\n}\n\nexport function makePolicy(policy?: Partial<ChunkPolicy>): ChunkPolicy {\n\tconst withDefaults = { ...defaultChunkPolicy, ...policy };\n\t// TODO: move this to a top level policy validation\n\tassert(\n\t\twithDefaults.sequenceChunkSplitThreshold >= 2,\n\t\t0x57d /* sequenceChunkThreshold must be at least 2 */,\n\t);\n\n\treturn withDefaults;\n}\n\nexport function shapesFromSchema(\n\tschema: StoredSchemaCollection,\n\tpolicy: FullSchemaPolicy,\n): Map<TreeNodeSchemaIdentifier, ShapeInfo> {\n\tconst shapes: Map<TreeNodeSchemaIdentifier, ShapeInfo> = new Map();\n\tfor (const identifier of schema.nodeSchema.keys()) {\n\t\ttryShapeFromSchema(schema, policy, identifier, shapes);\n\t}\n\treturn shapes;\n}\n\n/**\n * If `schema` has only one shape, return it.\n *\n * Note that this does not tolerate optional or sequence fields, nor does it optimize for patterns of specific values.\n */\nexport function tryShapeFromSchema(\n\tschema: StoredSchemaCollection,\n\tpolicy: FullSchemaPolicy,\n\ttype: TreeNodeSchemaIdentifier,\n\tshapes: Map<TreeNodeSchemaIdentifier, ShapeInfo>,\n): ShapeInfo {\n\treturn getOrCreate(shapes, type, () => {\n\t\tconst treeSchema = schema.nodeSchema.get(type) ?? fail(\"missing schema\");\n\t\tif (treeSchema instanceof LeafNodeStoredSchema) {\n\t\t\t// Allow all string values (but only string values) to be compressed by the id compressor.\n\t\t\t// This allows compressing all compressible identifiers without requiring additional context to know which values could be identifiers.\n\t\t\t// Attempting to compress other string shouldn't have significant overhead,\n\t\t\t// and if any of them do end up compressing, that's a benefit not a bug.\n\t\t\treturn treeSchema.leafValue === ValueSchema.String\n\t\t\t\t? new TreeShape(type, true, [], true)\n\t\t\t\t: new TreeShape(type, true, [], false);\n\t\t}\n\t\tif (treeSchema instanceof ObjectNodeStoredSchema) {\n\t\t\tconst fieldsArray: FieldShape[] = [];\n\t\t\tfor (const [key, field] of treeSchema.objectNodeFields) {\n\t\t\t\tconst fieldShape = tryShapeFromFieldSchema(schema, policy, field, key, shapes);\n\t\t\t\tif (fieldShape === undefined) {\n\t\t\t\t\treturn polymorphic;\n\t\t\t\t}\n\t\t\t\tfieldsArray.push(fieldShape);\n\t\t\t}\n\t\t\treturn new TreeShape(type, false, fieldsArray);\n\t\t}\n\t\treturn polymorphic;\n\t});\n}\n\n/**\n * If `schema` has only one shape, return it.\n *\n * Note that this does not tolerate optional or sequence fields, nor does it optimize for patterns of specific values.\n */\nexport function tryShapeFromFieldSchema(\n\tschema: StoredSchemaCollection,\n\tpolicy: FullSchemaPolicy,\n\ttype: TreeFieldStoredSchema,\n\tkey: FieldKey,\n\tshapes: Map<TreeNodeSchemaIdentifier, ShapeInfo>,\n): FieldShape | undefined {\n\tconst kind = policy.fieldKinds.get(type.kind) ?? fail(\"missing FieldKind\");\n\tif (kind.multiplicity !== Multiplicity.Single) {\n\t\treturn undefined;\n\t}\n\tif (type.types?.size !== 1) {\n\t\treturn undefined;\n\t}\n\tconst childType = [...type.types][0] ?? oob();\n\tconst childShape = tryShapeFromSchema(schema, policy, childType, shapes);\n\tif (childShape instanceof Polymorphic) {\n\t\treturn undefined;\n\t}\n\treturn [key, childShape, 1];\n}\n\n/**\n * Default settings for use for {@link ChunkPolicy}.\n * Use `makeTreeChunker` to create a policy with the defaults, but leverages to schema.\n */\nexport const defaultChunkPolicy: ChunkPolicy = {\n\t// Currently ChunkedForest and BasicTreeCursor don't handle SequenceChunks very efficiently:\n\t// they likely add more overhead than they save for now, so don't create them.\n\tsequenceChunkSplitThreshold: Number.POSITIVE_INFINITY,\n\tsequenceChunkInlineThreshold: Number.POSITIVE_INFINITY,\n\t// Current UniformChunk handling doesn't scale well to large chunks, so set a modest size limit:\n\tuniformChunkNodeCount: 400,\n\t// Without knowing what the schema is, all shapes are possible.\n\t// Use `makeTreeChunker` to do better.\n\tshapeFromSchema: () => polymorphic,\n};\n\nexport const basicOnlyChunkPolicy: ChunkPolicy = {\n\tsequenceChunkSplitThreshold: Number.POSITIVE_INFINITY,\n\tsequenceChunkInlineThreshold: Number.POSITIVE_INFINITY,\n\tuniformChunkNodeCount: 0,\n\tshapeFromSchema: () => polymorphic,\n};\n\n/**\n * Policy for how to chunk a tree.\n */\nexport interface ChunkPolicy {\n\t/**\n\t * Group sequences longer than this into into sequence chunks of this length or less.\n\t *\n\t * Must be at least 2.\n\t * Can be set to `Number.POSITIVE_INFINITY` to never introduce extra sequence chunks.\n\t */\n\treadonly sequenceChunkSplitThreshold: number;\n\n\t/**\n\t * SequenceChunks this long or shorter may get inlined into their parent chunk.\n\t */\n\treadonly sequenceChunkInlineThreshold: number;\n\n\t/**\n\t * Maximum total nodes to put in a UniformChunk.\n\t */\n\treadonly uniformChunkNodeCount: number;\n\n\t/**\n\t * Returns information about the shapes trees of type `schema` can take.\n\t */\n\tshapeFromSchema(schema: TreeNodeSchemaIdentifier): ShapeInfo;\n}\n\nexport interface ChunkCompressor {\n\treadonly policy: ChunkPolicy;\n\t/**\n\t * If the idCompressor is provided, {@link UniformChunk}s with identifiers will be encoded for its in-memory representation.\n\t * @remarks\n\t * This compression applies to {@link UniformChunk}s when {@link TreeShape.maybeDecompressedStringAsNumber} is set.\n\t * If the `policy` does not use UniformChunks or does not set `maybeDecompressedStringAsNumber`, then no compression will be applied even when providing `idCompressor`.\n\t */\n\treadonly idCompressor: IIdCompressor | undefined;\n}\n\nfunction newBasicChunkTree(\n\tcursor: ITreeCursorSynchronous,\n\tpolicy: ChunkCompressor,\n): BasicChunk {\n\treturn new BasicChunk(\n\t\tcursor.type,\n\t\tnew Map(mapCursorFields(cursor, () => [cursor.getFieldKey(), chunkField(cursor, policy)])),\n\t\tcursor.value,\n\t);\n}\n\n/**\n * @param cursor - cursor in nodes mode\n * @param policy - heuristics to impact chunking\n * @param length - how many nodes to process (at the top level)\n * @param skipLastNavigation - if true, leaves the cursor at the last node instead of moving off of it.\n */\nexport function chunkRange(\n\tcursor: ITreeCursorSynchronous,\n\tchunkCompressor: ChunkCompressor,\n\tlength: number,\n\tskipLastNavigation: boolean,\n): TreeChunk[] {\n\tassert(cursor.mode === CursorLocationType.Nodes, 0x57e /* should be in nodes */);\n\tlet output: TreeChunk[] = [];\n\tlet remaining = length;\n\twhile (remaining > 0) {\n\t\tassert(cursor.mode === CursorLocationType.Nodes, 0x57f /* should be in nodes */);\n\t\tconst start = cursor.chunkStart;\n\t\tlet reusedChunk = false;\n\t\t// symbol based fast path to check for chunk:\n\t\t// return existing chunk with a increased ref count if possible.\n\t\tif (start === cursor.fieldIndex) {\n\t\t\tconst chunkLength = cursor.chunkLength;\n\t\t\tif (chunkLength <= remaining) {\n\t\t\t\tconst chunk = tryGetChunk(cursor);\n\t\t\t\tif (chunk !== undefined) {\n\t\t\t\t\tif (\n\t\t\t\t\t\tchunk instanceof SequenceChunk &&\n\t\t\t\t\t\tchunk.subChunks.length <= chunkCompressor.policy.sequenceChunkInlineThreshold\n\t\t\t\t\t) {\n\t\t\t\t\t\t// If sequence chunk, and its very short, inline it.\n\t\t\t\t\t\t// Note that this is not recursive: there may be short sequences nested below this which are not inlined.\n\t\t\t\t\t\tfor (const subChunk of chunk.subChunks) {\n\t\t\t\t\t\t\tsubChunk.referenceAdded();\n\t\t\t\t\t\t\toutput.push(subChunk);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tchunk.referenceAdded();\n\t\t\t\t\toutput.push(chunk);\n\t\t\t\t\tremaining -= chunkLength;\n\t\t\t\t\treusedChunk = true;\n\t\t\t\t\tlet seek = chunkLength;\n\t\t\t\t\tif (skipLastNavigation && remaining === 0) {\n\t\t\t\t\t\tseek -= 1;\n\t\t\t\t\t}\n\t\t\t\t\tcursor.seekNodes(seek);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (!reusedChunk) {\n\t\t\tassert(cursor.mode === CursorLocationType.Nodes, 0x580 /* should be in nodes */);\n\t\t\t// TODO: if provided, use schema to consider using UniformChunks\n\t\t\tconst type = cursor.type;\n\t\t\tconst shape = chunkCompressor.policy.shapeFromSchema(type);\n\t\t\tif (shape instanceof TreeShape) {\n\t\t\t\tconst nodesPerTopLevelNode = shape.positions.length;\n\t\t\t\tconst maxTopLevelLength = Math.ceil(\n\t\t\t\t\tnodesPerTopLevelNode / chunkCompressor.policy.uniformChunkNodeCount,\n\t\t\t\t);\n\t\t\t\tconst maxLength = Math.min(maxTopLevelLength, remaining);\n\t\t\t\tconst newChunk = uniformChunkFromCursor(\n\t\t\t\t\tcursor,\n\t\t\t\t\tshape,\n\t\t\t\t\tmaxLength,\n\t\t\t\t\tmaxLength === remaining && skipLastNavigation,\n\t\t\t\t\tchunkCompressor.idCompressor,\n\t\t\t\t);\n\t\t\t\tremaining -= newChunk.topLevelLength;\n\t\t\t\toutput.push(newChunk);\n\t\t\t} else {\n\t\t\t\t// Slow path: copy tree into new basic chunk\n\t\t\t\toutput.push(newBasicChunkTree(cursor, chunkCompressor));\n\t\t\t\tremaining -= 1;\n\t\t\t\tif (!skipLastNavigation || remaining !== 0) {\n\t\t\t\t\tcursor.nextNode();\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t// TODO: maybe make a pass over output to coalesce UniformChunks and/or convert other formats to UniformChunks where possible.\n\n\t// If output is large, group it into a tree of sequence chunks.\n\twhile (output.length > chunkCompressor.policy.sequenceChunkSplitThreshold) {\n\t\tconst chunkCount = Math.ceil(\n\t\t\toutput.length / chunkCompressor.policy.sequenceChunkSplitThreshold,\n\t\t);\n\t\tconst newOutput: TreeChunk[] = [];\n\t\t// Rounding down, and add an extra item to some of the chunks.\n\t\tconst chunkSize = Math.floor(output.length / chunkCount);\n\t\t// number of chunks to add an extra item to to make total line up.\n\t\tconst extra = output.length % chunkCount;\n\t\tlet previousEnd = 0;\n\t\tfor (let index = 0; index < chunkCount; index++) {\n\t\t\t// If we are in the first `extra` items, add an extra to this chunk.\n\t\t\tconst end = previousEnd + chunkSize + (index < extra ? 1 : 0);\n\t\t\tnewOutput.push(new SequenceChunk(output.slice(previousEnd, end)));\n\t\t\tpreviousEnd = end;\n\t\t}\n\t\tassert(previousEnd === output.length, 0x581 /* chunks should add up to total */);\n\t\toutput = newOutput;\n\t}\n\n\treturn output;\n}\n/**\n * @param idCompressor - compressor used to encoded string values that are compressible by the idCompressor for in-memory representation.\n * If the idCompressor is not provided, the values will be the original uncompressed values.\n */\nexport function insertValues(\n\tcursor: ITreeCursorSynchronous,\n\tshape: TreeShape,\n\tvalues: Value[],\n\tidCompressor?: IIdCompressor,\n): void {\n\tassert(shape.type === cursor.type, 0x582 /* shape and type must match */);\n\n\t// TODO:Perf:\n\t// Fast path for already part of a uniform chunk with matching shape\n\n\t// Slow path: walk shape and cursor together, inserting values.\n\tif (shape.hasValue) {\n\t\tif (\n\t\t\ttypeof cursor.value === \"string\" &&\n\t\t\tidCompressor !== undefined &&\n\t\t\tisStableNodeKey(cursor.value)\n\t\t) {\n\t\t\tvalues.push(idCompressor.tryRecompress(cursor.value) ?? cursor.value);\n\t\t} else {\n\t\t\tvalues.push(cursor.value);\n\t\t}\n\t}\n\tfor (const [key, childShape, length] of shape.fieldsArray) {\n\t\tcursor.enterField(key);\n\t\tlet count = 0;\n\t\tfor (let inNodes = cursor.firstNode(); inNodes; inNodes = cursor.nextNode()) {\n\t\t\tinsertValues(cursor, childShape, values, idCompressor);\n\t\t\tcount++;\n\t\t}\n\t\tcursor.exitField();\n\t\tassert(length === count, 0x583 /* unexpected field length */);\n\t}\n}\n\n/**\n * Read up to `maxTopLevelLength` nodes from `cursor`, stopping when limit is hit or type of node changes.\n *\n * This requires that the all trees with matching type match the provided shape.\n * This cannot be used if other shapes are possible for this type.\n *\n * If this stops early due to the type changing, `skipLastNavigation` is not involved:\n * `skipLastNavigation` only determines if the cursor will be left on the node after the last one (possibly exiting the field)\n * if the full length is used.\n *\n * @param idCompressor - compressor used to encoded string values that are compressible by the idCompressor for in-memory representation.\n * If the idCompressor is not provided, the values will be the original uncompressed values.\n */\nexport function uniformChunkFromCursor(\n\tcursor: ITreeCursorSynchronous,\n\tshape: TreeShape,\n\tmaxTopLevelLength: number,\n\tskipLastNavigation: boolean,\n\tidCompressor?: IIdCompressor,\n): UniformChunk {\n\t// TODO:\n\t// This could have a fast path for consuming already uniformly chunked data with matching shape.\n\n\tconst values: TreeValue[] = [];\n\tlet topLevelLength = 1;\n\twhile (topLevelLength <= maxTopLevelLength) {\n\t\tinsertValues(cursor, shape, values, idCompressor);\n\t\tif (topLevelLength === maxTopLevelLength) {\n\t\t\tif (!skipLastNavigation) {\n\t\t\t\tcursor.nextNode();\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t\tcursor.nextNode();\n\t\tif (cursor.type !== shape.type) {\n\t\t\tbreak;\n\t\t}\n\t\ttopLevelLength += 1;\n\t}\n\treturn new UniformChunk(shape.withTopLevelLength(topLevelLength), values, idCompressor);\n}\n"]}
@@ -6,6 +6,7 @@ import { type Anchor, AnchorSet, type DeltaVisitor, type DetachedField, type Fie
6
6
  import { BasicChunk, BasicChunkCursor, type SiblingsOrKey } from "./basicChunk.js";
7
7
  import type { ChunkedCursor, TreeChunk } from "./chunk.js";
8
8
  import { type IChunker } from "./chunkTree.js";
9
+ import type { IIdCompressor } from "@fluidframework/id-compressor";
9
10
  /**
10
11
  * Implementation of IEditableForest based on copy on write chunks.
11
12
  *
@@ -16,6 +17,7 @@ export declare class ChunkedForest implements IEditableForest {
16
17
  readonly schema: TreeStoredSchemaSubscription;
17
18
  readonly chunker: IChunker;
18
19
  readonly anchors: AnchorSet;
20
+ readonly idCompressor?: IIdCompressor | undefined;
19
21
  private activeVisitor?;
20
22
  private readonly events;
21
23
  /**
@@ -24,7 +26,7 @@ export declare class ChunkedForest implements IEditableForest {
24
26
  * @param chunker - Chunking policy. TODO: dispose of this when forest is disposed.
25
27
  * @param anchors - anchorSet used to track location in this forest across changes. Callers of applyDelta must ensure this is updated accordingly.
26
28
  */
27
- constructor(roots: BasicChunk, schema: TreeStoredSchemaSubscription, chunker: IChunker, anchors?: AnchorSet);
29
+ constructor(roots: BasicChunk, schema: TreeStoredSchemaSubscription, chunker: IChunker, anchors?: AnchorSet, idCompressor?: IIdCompressor | undefined);
28
30
  get isEmpty(): boolean;
29
31
  on<K extends keyof ForestEvents>(eventName: K, listener: ForestEvents[K]): () => void;
30
32
  clone(schema: TreeStoredSchemaSubscription, anchors: AnchorSet): ChunkedForest;
@@ -52,6 +54,6 @@ declare class Cursor extends BasicChunkCursor implements ITreeSubscriptionCursor
52
54
  /**
53
55
  * @returns an implementation of {@link IEditableForest} with no data or schema.
54
56
  */
55
- export declare function buildChunkedForest(chunker: IChunker, anchors?: AnchorSet): ChunkedForest;
57
+ export declare function buildChunkedForest(chunker: IChunker, anchors?: AnchorSet, idCompressor?: IIdCompressor): ChunkedForest;
56
58
  export {};
57
59
  //# sourceMappingURL=chunkedForest.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"chunkedForest.d.ts","sourceRoot":"","sources":["../../../src/feature-libraries/chunked-forest/chunkedForest.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EACN,KAAK,MAAM,EACX,SAAS,EACT,KAAK,YAAY,EACjB,KAAK,aAAa,EAClB,KAAK,WAAW,EAChB,KAAK,QAAQ,EACb,KAAK,YAAY,EACjB,KAAK,eAAe,EACpB,KAAK,sBAAsB,EAC3B,KAAK,uBAAuB,EAC5B,4BAA4B,EAI5B,oBAAoB,EACpB,KAAK,4BAA4B,EACjC,KAAK,MAAM,EAKX,MAAM,qBAAqB,CAAC;AAI7B,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,KAAK,aAAa,EAAE,MAAM,iBAAiB,CAAC;AACnF,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAC3D,OAAO,EAAE,KAAK,QAAQ,EAA6B,MAAM,gBAAgB,CAAC;AAW1E;;;;GAIG;AACH,qBAAa,aAAc,YAAW,eAAe;IAY5C,KAAK,EAAE,UAAU;aACR,MAAM,EAAE,4BAA4B;aACpC,OAAO,EAAE,QAAQ;aACjB,OAAO,EAAE,SAAS;IAdnC,OAAO,CAAC,aAAa,CAAC,CAAe;IAErC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAiC;IAExD;;;;;OAKG;gBAEK,KAAK,EAAE,UAAU,EACR,MAAM,EAAE,4BAA4B,EACpC,OAAO,EAAE,QAAQ,EACjB,OAAO,GAAE,SAA2B;IAGrD,IAAW,OAAO,IAAI,OAAO,CAE5B;IAEM,EAAE,CAAC,CAAC,SAAS,MAAM,YAAY,EACrC,SAAS,EAAE,CAAC,EACZ,QAAQ,EAAE,YAAY,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