@fluidframework/tree 2.11.0 → 2.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (704) hide show
  1. package/CHANGELOG.md +140 -0
  2. package/api-report/tree.alpha.api.md +88 -12
  3. package/api-report/tree.beta.api.md +23 -11
  4. package/api-report/tree.legacy.alpha.api.md +23 -11
  5. package/api-report/tree.legacy.public.api.md +23 -11
  6. package/api-report/tree.public.api.md +23 -11
  7. package/dist/alpha.d.ts +11 -0
  8. package/dist/beta.d.ts +2 -0
  9. package/dist/core/index.d.ts +2 -2
  10. package/dist/core/index.d.ts.map +1 -1
  11. package/dist/core/index.js +5 -3
  12. package/dist/core/index.js.map +1 -1
  13. package/dist/core/rebase/utils.d.ts.map +1 -1
  14. package/dist/core/rebase/utils.js +2 -9
  15. package/dist/core/rebase/utils.js.map +1 -1
  16. package/dist/core/schema-stored/format.d.ts +0 -3
  17. package/dist/core/schema-stored/format.d.ts.map +1 -1
  18. package/dist/core/schema-stored/format.js.map +1 -1
  19. package/dist/core/schema-stored/schema.d.ts +12 -10
  20. package/dist/core/schema-stored/schema.d.ts.map +1 -1
  21. package/dist/core/schema-stored/schema.js +3 -5
  22. package/dist/core/schema-stored/schema.js.map +1 -1
  23. package/dist/core/schema-view/index.d.ts +1 -1
  24. package/dist/core/schema-view/index.d.ts.map +1 -1
  25. package/dist/core/schema-view/index.js +1 -2
  26. package/dist/core/schema-view/index.js.map +1 -1
  27. package/dist/core/schema-view/view.d.ts +0 -7
  28. package/dist/core/schema-view/view.d.ts.map +1 -1
  29. package/dist/core/schema-view/view.js +1 -12
  30. package/dist/core/schema-view/view.js.map +1 -1
  31. package/dist/{feature-libraries/chunked-forest → core/tree}/chunk.d.ts +2 -1
  32. package/dist/core/tree/chunk.d.ts.map +1 -0
  33. package/dist/{feature-libraries/chunked-forest → core/tree}/chunk.js +2 -2
  34. package/dist/core/tree/chunk.js.map +1 -0
  35. package/dist/core/tree/index.d.ts +1 -0
  36. package/dist/core/tree/index.d.ts.map +1 -1
  37. package/dist/core/tree/index.js +5 -1
  38. package/dist/core/tree/index.js.map +1 -1
  39. package/dist/core/tree/treeTextFormat.d.ts +0 -5
  40. package/dist/core/tree/treeTextFormat.d.ts.map +1 -1
  41. package/dist/core/tree/treeTextFormat.js.map +1 -1
  42. package/dist/core/tree/types.d.ts +0 -5
  43. package/dist/core/tree/types.d.ts.map +1 -1
  44. package/dist/core/tree/types.js +0 -1
  45. package/dist/core/tree/types.js.map +1 -1
  46. package/dist/feature-libraries/chunked-forest/basicChunk.d.ts +1 -2
  47. package/dist/feature-libraries/chunked-forest/basicChunk.d.ts.map +1 -1
  48. package/dist/feature-libraries/chunked-forest/basicChunk.js +14 -14
  49. package/dist/feature-libraries/chunked-forest/basicChunk.js.map +1 -1
  50. package/dist/feature-libraries/chunked-forest/chunkTree.d.ts +1 -2
  51. package/dist/feature-libraries/chunked-forest/chunkTree.d.ts.map +1 -1
  52. package/dist/feature-libraries/chunked-forest/chunkTree.js +2 -3
  53. package/dist/feature-libraries/chunked-forest/chunkTree.js.map +1 -1
  54. package/dist/feature-libraries/chunked-forest/chunkedForest.d.ts +1 -2
  55. package/dist/feature-libraries/chunked-forest/chunkedForest.d.ts.map +1 -1
  56. package/dist/feature-libraries/chunked-forest/chunkedForest.js.map +1 -1
  57. package/dist/feature-libraries/chunked-forest/codec/chunkCodecUtilities.d.ts +1 -2
  58. package/dist/feature-libraries/chunked-forest/codec/chunkCodecUtilities.d.ts.map +1 -1
  59. package/dist/feature-libraries/chunked-forest/codec/chunkCodecUtilities.js.map +1 -1
  60. package/dist/feature-libraries/chunked-forest/codec/chunkDecoding.d.ts +1 -2
  61. package/dist/feature-libraries/chunked-forest/codec/chunkDecoding.d.ts.map +1 -1
  62. package/dist/feature-libraries/chunked-forest/codec/chunkDecoding.js.map +1 -1
  63. package/dist/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.d.ts +1 -1
  64. package/dist/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.d.ts.map +1 -1
  65. package/dist/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.js.map +1 -1
  66. package/dist/feature-libraries/chunked-forest/emptyChunk.d.ts +1 -1
  67. package/dist/feature-libraries/chunked-forest/emptyChunk.d.ts.map +1 -1
  68. package/dist/feature-libraries/chunked-forest/emptyChunk.js +2 -3
  69. package/dist/feature-libraries/chunked-forest/emptyChunk.js.map +1 -1
  70. package/dist/feature-libraries/chunked-forest/index.d.ts +1 -1
  71. package/dist/feature-libraries/chunked-forest/index.d.ts.map +1 -1
  72. package/dist/feature-libraries/chunked-forest/index.js +5 -5
  73. package/dist/feature-libraries/chunked-forest/index.js.map +1 -1
  74. package/dist/feature-libraries/chunked-forest/sequenceChunk.d.ts +1 -1
  75. package/dist/feature-libraries/chunked-forest/sequenceChunk.d.ts.map +1 -1
  76. package/dist/feature-libraries/chunked-forest/sequenceChunk.js +2 -2
  77. package/dist/feature-libraries/chunked-forest/sequenceChunk.js.map +1 -1
  78. package/dist/feature-libraries/chunked-forest/uniformChunk.d.ts +1 -2
  79. package/dist/feature-libraries/chunked-forest/uniformChunk.d.ts.map +1 -1
  80. package/dist/feature-libraries/chunked-forest/uniformChunk.js +13 -13
  81. package/dist/feature-libraries/chunked-forest/uniformChunk.js.map +1 -1
  82. package/dist/feature-libraries/default-schema/defaultEditBuilder.d.ts +10 -0
  83. package/dist/feature-libraries/default-schema/defaultEditBuilder.d.ts.map +1 -1
  84. package/dist/feature-libraries/default-schema/defaultEditBuilder.js +3 -0
  85. package/dist/feature-libraries/default-schema/defaultEditBuilder.js.map +1 -1
  86. package/dist/feature-libraries/default-schema/defaultSchema.d.ts.map +1 -1
  87. package/dist/feature-libraries/default-schema/defaultSchema.js +1 -0
  88. package/dist/feature-libraries/default-schema/defaultSchema.js.map +1 -1
  89. package/dist/feature-libraries/default-schema/schemaChecker.d.ts.map +1 -1
  90. package/dist/feature-libraries/default-schema/schemaChecker.js +2 -1
  91. package/dist/feature-libraries/default-schema/schemaChecker.js.map +1 -1
  92. package/dist/feature-libraries/index.d.ts +1 -2
  93. package/dist/feature-libraries/index.d.ts.map +1 -1
  94. package/dist/feature-libraries/index.js +6 -4
  95. package/dist/feature-libraries/index.js.map +1 -1
  96. package/dist/feature-libraries/indexing/anchorTreeIndex.d.ts +8 -1
  97. package/dist/feature-libraries/indexing/anchorTreeIndex.d.ts.map +1 -1
  98. package/dist/feature-libraries/indexing/anchorTreeIndex.js +31 -5
  99. package/dist/feature-libraries/indexing/anchorTreeIndex.js.map +1 -1
  100. package/dist/feature-libraries/modular-schema/crossFieldQueries.d.ts +1 -1
  101. package/dist/feature-libraries/modular-schema/crossFieldQueries.d.ts.map +1 -1
  102. package/dist/feature-libraries/modular-schema/crossFieldQueries.js +8 -2
  103. package/dist/feature-libraries/modular-schema/crossFieldQueries.js.map +1 -1
  104. package/dist/feature-libraries/modular-schema/discrepancies.d.ts +84 -24
  105. package/dist/feature-libraries/modular-schema/discrepancies.d.ts.map +1 -1
  106. package/dist/feature-libraries/modular-schema/discrepancies.js +32 -33
  107. package/dist/feature-libraries/modular-schema/discrepancies.js.map +1 -1
  108. package/dist/feature-libraries/modular-schema/fieldChangeHandler.d.ts +12 -5
  109. package/dist/feature-libraries/modular-schema/fieldChangeHandler.d.ts.map +1 -1
  110. package/dist/feature-libraries/modular-schema/fieldChangeHandler.js.map +1 -1
  111. package/dist/feature-libraries/modular-schema/genericFieldKind.d.ts.map +1 -1
  112. package/dist/feature-libraries/modular-schema/genericFieldKind.js +2 -1
  113. package/dist/feature-libraries/modular-schema/genericFieldKind.js.map +1 -1
  114. package/dist/feature-libraries/modular-schema/index.d.ts +2 -2
  115. package/dist/feature-libraries/modular-schema/index.d.ts.map +1 -1
  116. package/dist/feature-libraries/modular-schema/index.js +5 -1
  117. package/dist/feature-libraries/modular-schema/index.js.map +1 -1
  118. package/dist/feature-libraries/modular-schema/isNeverTree.d.ts +0 -1
  119. package/dist/feature-libraries/modular-schema/isNeverTree.d.ts.map +1 -1
  120. package/dist/feature-libraries/modular-schema/isNeverTree.js +0 -1
  121. package/dist/feature-libraries/modular-schema/isNeverTree.js.map +1 -1
  122. package/dist/feature-libraries/modular-schema/modularChangeFamily.d.ts +1 -0
  123. package/dist/feature-libraries/modular-schema/modularChangeFamily.d.ts.map +1 -1
  124. package/dist/feature-libraries/modular-schema/modularChangeFamily.js +89 -25
  125. package/dist/feature-libraries/modular-schema/modularChangeFamily.js.map +1 -1
  126. package/dist/feature-libraries/modular-schema/modularChangeTypes.d.ts +12 -0
  127. package/dist/feature-libraries/modular-schema/modularChangeTypes.d.ts.map +1 -1
  128. package/dist/feature-libraries/modular-schema/modularChangeTypes.js.map +1 -1
  129. package/dist/feature-libraries/optional-field/optionalField.d.ts.map +1 -1
  130. package/dist/feature-libraries/optional-field/optionalField.js +24 -4
  131. package/dist/feature-libraries/optional-field/optionalField.js.map +1 -1
  132. package/dist/feature-libraries/optional-field/optionalFieldChangeFormatV1.d.ts +6 -6
  133. package/dist/feature-libraries/optional-field/optionalFieldChangeFormatV1.d.ts.map +1 -1
  134. package/dist/feature-libraries/optional-field/optionalFieldChangeFormatV2.d.ts +7 -7
  135. package/dist/feature-libraries/optional-field/optionalFieldChangeFormatV2.d.ts.map +1 -1
  136. package/dist/feature-libraries/schema-edits/schemaChangeFormat.d.ts +12 -12
  137. package/dist/feature-libraries/sequence-field/formatV1.d.ts +99 -99
  138. package/dist/feature-libraries/sequence-field/formatV1.d.ts.map +1 -1
  139. package/dist/feature-libraries/sequence-field/formatV2.d.ts +76 -76
  140. package/dist/feature-libraries/sequence-field/formatV2.d.ts.map +1 -1
  141. package/dist/feature-libraries/sequence-field/formatV3.d.ts +54 -54
  142. package/dist/feature-libraries/sequence-field/types.d.ts +0 -1
  143. package/dist/feature-libraries/sequence-field/types.d.ts.map +1 -1
  144. package/dist/feature-libraries/sequence-field/types.js.map +1 -1
  145. package/dist/feature-libraries/sequence-field/utils.d.ts +2 -2
  146. package/dist/feature-libraries/sequence-field/utils.d.ts.map +1 -1
  147. package/dist/feature-libraries/sequence-field/utils.js +14 -5
  148. package/dist/feature-libraries/sequence-field/utils.js.map +1 -1
  149. package/dist/index.d.ts +4 -5
  150. package/dist/index.d.ts.map +1 -1
  151. package/dist/index.js +2 -14
  152. package/dist/index.js.map +1 -1
  153. package/dist/legacy.d.ts +2 -0
  154. package/dist/packageVersion.d.ts +1 -1
  155. package/dist/packageVersion.js +1 -1
  156. package/dist/packageVersion.js.map +1 -1
  157. package/dist/public.d.ts +2 -0
  158. package/dist/shared-tree/index.d.ts +3 -2
  159. package/dist/shared-tree/index.d.ts.map +1 -1
  160. package/dist/shared-tree/index.js +2 -1
  161. package/dist/shared-tree/index.js.map +1 -1
  162. package/dist/shared-tree/schematizeTree.d.ts +1 -1
  163. package/dist/shared-tree/schematizeTree.d.ts.map +1 -1
  164. package/dist/shared-tree/schematizeTree.js +6 -6
  165. package/dist/shared-tree/schematizeTree.js.map +1 -1
  166. package/dist/shared-tree/schematizingTreeView.d.ts +10 -1
  167. package/dist/shared-tree/schematizingTreeView.d.ts.map +1 -1
  168. package/dist/shared-tree/schematizingTreeView.js +51 -12
  169. package/dist/shared-tree/schematizingTreeView.js.map +1 -1
  170. package/dist/shared-tree/sharedTree.d.ts +31 -10
  171. package/dist/shared-tree/sharedTree.d.ts.map +1 -1
  172. package/dist/shared-tree/sharedTree.js +106 -15
  173. package/dist/shared-tree/sharedTree.js.map +1 -1
  174. package/dist/shared-tree/transactionTypes.d.ts +105 -0
  175. package/dist/shared-tree/transactionTypes.d.ts.map +1 -0
  176. package/dist/shared-tree/transactionTypes.js +13 -0
  177. package/dist/shared-tree/transactionTypes.js.map +1 -0
  178. package/dist/shared-tree/treeApi.d.ts +1 -25
  179. package/dist/shared-tree/treeApi.d.ts.map +1 -1
  180. package/dist/shared-tree/treeApi.js +4 -8
  181. package/dist/shared-tree/treeApi.js.map +1 -1
  182. package/dist/shared-tree/treeCheckout.d.ts +39 -13
  183. package/dist/shared-tree/treeCheckout.d.ts.map +1 -1
  184. package/dist/shared-tree/treeCheckout.js +275 -128
  185. package/dist/shared-tree/treeCheckout.js.map +1 -1
  186. package/dist/shared-tree-core/branch.d.ts +13 -35
  187. package/dist/shared-tree-core/branch.d.ts.map +1 -1
  188. package/dist/shared-tree-core/branch.js +12 -77
  189. package/dist/shared-tree-core/branch.js.map +1 -1
  190. package/dist/shared-tree-core/branchCommitEnricher.d.ts +7 -1
  191. package/dist/shared-tree-core/branchCommitEnricher.d.ts.map +1 -1
  192. package/dist/shared-tree-core/branchCommitEnricher.js +16 -18
  193. package/dist/shared-tree-core/branchCommitEnricher.js.map +1 -1
  194. package/dist/shared-tree-core/editManager.d.ts.map +1 -1
  195. package/dist/shared-tree-core/editManager.js +2 -2
  196. package/dist/shared-tree-core/editManager.js.map +1 -1
  197. package/dist/shared-tree-core/index.d.ts +3 -3
  198. package/dist/shared-tree-core/index.d.ts.map +1 -1
  199. package/dist/shared-tree-core/index.js +2 -2
  200. package/dist/shared-tree-core/index.js.map +1 -1
  201. package/dist/shared-tree-core/sharedTreeCore.d.ts +2 -9
  202. package/dist/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
  203. package/dist/shared-tree-core/sharedTreeCore.js +4 -16
  204. package/dist/shared-tree-core/sharedTreeCore.js.map +1 -1
  205. package/dist/shared-tree-core/transaction.d.ts +38 -0
  206. package/dist/shared-tree-core/transaction.d.ts.map +1 -1
  207. package/dist/shared-tree-core/transaction.js +118 -6
  208. package/dist/shared-tree-core/transaction.js.map +1 -1
  209. package/dist/simple-tree/api/conciseTree.d.ts.map +1 -1
  210. package/dist/simple-tree/api/conciseTree.js +1 -1
  211. package/dist/simple-tree/api/conciseTree.js.map +1 -1
  212. package/dist/simple-tree/api/create.d.ts.map +1 -1
  213. package/dist/simple-tree/api/create.js +5 -1
  214. package/dist/simple-tree/api/create.js.map +1 -1
  215. package/dist/simple-tree/api/customTree.d.ts +14 -2
  216. package/dist/simple-tree/api/customTree.d.ts.map +1 -1
  217. package/dist/simple-tree/api/customTree.js +53 -3
  218. package/dist/simple-tree/api/customTree.js.map +1 -1
  219. package/dist/simple-tree/api/index.d.ts +3 -2
  220. package/dist/simple-tree/api/index.d.ts.map +1 -1
  221. package/dist/simple-tree/api/index.js +6 -1
  222. package/dist/simple-tree/api/index.js.map +1 -1
  223. package/dist/simple-tree/api/jsonSchema.d.ts +6 -0
  224. package/dist/simple-tree/api/jsonSchema.d.ts.map +1 -1
  225. package/dist/simple-tree/api/jsonSchema.js.map +1 -1
  226. package/dist/simple-tree/api/schemaFactory.d.ts +65 -8
  227. package/dist/simple-tree/api/schemaFactory.d.ts.map +1 -1
  228. package/dist/simple-tree/api/schemaFactory.js +10 -4
  229. package/dist/simple-tree/api/schemaFactory.js.map +1 -1
  230. package/dist/simple-tree/api/schemaFactoryAlpha.d.ts +83 -0
  231. package/dist/simple-tree/api/schemaFactoryAlpha.d.ts.map +1 -0
  232. package/dist/simple-tree/api/schemaFactoryAlpha.js +90 -0
  233. package/dist/simple-tree/api/schemaFactoryAlpha.js.map +1 -0
  234. package/dist/simple-tree/api/simpleSchema.d.ts +8 -2
  235. package/dist/simple-tree/api/simpleSchema.d.ts.map +1 -1
  236. package/dist/simple-tree/api/simpleSchema.js.map +1 -1
  237. package/dist/simple-tree/api/simpleSchemaToJsonSchema.js +13 -10
  238. package/dist/simple-tree/api/simpleSchemaToJsonSchema.js.map +1 -1
  239. package/dist/simple-tree/api/simpleTreeIndex.js +3 -1
  240. package/dist/simple-tree/api/simpleTreeIndex.js.map +1 -1
  241. package/dist/simple-tree/api/storedSchema.d.ts +4 -4
  242. package/dist/simple-tree/api/storedSchema.d.ts.map +1 -1
  243. package/dist/simple-tree/api/storedSchema.js +8 -21
  244. package/dist/simple-tree/api/storedSchema.js.map +1 -1
  245. package/dist/simple-tree/api/testRecursiveDomain.d.ts +5 -5
  246. package/dist/simple-tree/api/tree.d.ts +61 -0
  247. package/dist/simple-tree/api/tree.d.ts.map +1 -1
  248. package/dist/simple-tree/api/tree.js.map +1 -1
  249. package/dist/simple-tree/api/verboseTree.js +1 -1
  250. package/dist/simple-tree/api/verboseTree.js.map +1 -1
  251. package/dist/simple-tree/api/view.d.ts +14 -9
  252. package/dist/simple-tree/api/view.d.ts.map +1 -1
  253. package/dist/simple-tree/api/view.js +129 -40
  254. package/dist/simple-tree/api/view.js.map +1 -1
  255. package/dist/simple-tree/api/viewSchemaToSimpleSchema.d.ts.map +1 -1
  256. package/dist/simple-tree/api/viewSchemaToSimpleSchema.js +11 -11
  257. package/dist/simple-tree/api/viewSchemaToSimpleSchema.js.map +1 -1
  258. package/dist/simple-tree/arrayNode.d.ts +2 -2
  259. package/dist/simple-tree/arrayNode.d.ts.map +1 -1
  260. package/dist/simple-tree/arrayNode.js +2 -1
  261. package/dist/simple-tree/arrayNode.js.map +1 -1
  262. package/dist/simple-tree/core/treeNodeSchema.d.ts +10 -6
  263. package/dist/simple-tree/core/treeNodeSchema.d.ts.map +1 -1
  264. package/dist/simple-tree/core/treeNodeSchema.js.map +1 -1
  265. package/dist/simple-tree/index.d.ts +3 -3
  266. package/dist/simple-tree/index.d.ts.map +1 -1
  267. package/dist/simple-tree/index.js +6 -2
  268. package/dist/simple-tree/index.js.map +1 -1
  269. package/dist/simple-tree/leafNodeSchema.d.ts +5 -20
  270. package/dist/simple-tree/leafNodeSchema.d.ts.map +1 -1
  271. package/dist/simple-tree/leafNodeSchema.js +0 -15
  272. package/dist/simple-tree/leafNodeSchema.js.map +1 -1
  273. package/dist/simple-tree/mapNode.d.ts +2 -2
  274. package/dist/simple-tree/mapNode.d.ts.map +1 -1
  275. package/dist/simple-tree/mapNode.js +2 -1
  276. package/dist/simple-tree/mapNode.js.map +1 -1
  277. package/dist/simple-tree/objectNode.d.ts +9 -4
  278. package/dist/simple-tree/objectNode.d.ts.map +1 -1
  279. package/dist/simple-tree/objectNode.js +19 -2
  280. package/dist/simple-tree/objectNode.js.map +1 -1
  281. package/dist/simple-tree/objectNodeTypes.d.ts +6 -2
  282. package/dist/simple-tree/objectNodeTypes.d.ts.map +1 -1
  283. package/dist/simple-tree/objectNodeTypes.js.map +1 -1
  284. package/dist/simple-tree/schemaTypes.d.ts +51 -3
  285. package/dist/simple-tree/schemaTypes.d.ts.map +1 -1
  286. package/dist/simple-tree/schemaTypes.js.map +1 -1
  287. package/dist/simple-tree/toStoredSchema.d.ts.map +1 -1
  288. package/dist/simple-tree/toStoredSchema.js +18 -13
  289. package/dist/simple-tree/toStoredSchema.js.map +1 -1
  290. package/dist/util/brand.d.ts +0 -2
  291. package/dist/util/brand.d.ts.map +1 -1
  292. package/dist/util/brand.js +0 -1
  293. package/dist/util/brand.js.map +1 -1
  294. package/dist/util/index.d.ts +2 -2
  295. package/dist/util/index.d.ts.map +1 -1
  296. package/dist/util/index.js +4 -5
  297. package/dist/util/index.js.map +1 -1
  298. package/dist/util/rangeMap.d.ts +72 -42
  299. package/dist/util/rangeMap.d.ts.map +1 -1
  300. package/dist/util/rangeMap.js +161 -151
  301. package/dist/util/rangeMap.js.map +1 -1
  302. package/dist/util/typeCheck.d.ts +0 -2
  303. package/dist/util/typeCheck.d.ts.map +1 -1
  304. package/dist/util/typeCheck.js.map +1 -1
  305. package/dist/util/utils.d.ts +35 -1
  306. package/dist/util/utils.d.ts.map +1 -1
  307. package/dist/util/utils.js +32 -1
  308. package/dist/util/utils.js.map +1 -1
  309. package/lib/alpha.d.ts +11 -0
  310. package/lib/beta.d.ts +2 -0
  311. package/lib/core/index.d.ts +2 -2
  312. package/lib/core/index.d.ts.map +1 -1
  313. package/lib/core/index.js +2 -2
  314. package/lib/core/index.js.map +1 -1
  315. package/lib/core/rebase/utils.d.ts.map +1 -1
  316. package/lib/core/rebase/utils.js +3 -10
  317. package/lib/core/rebase/utils.js.map +1 -1
  318. package/lib/core/schema-stored/format.d.ts +0 -3
  319. package/lib/core/schema-stored/format.d.ts.map +1 -1
  320. package/lib/core/schema-stored/format.js.map +1 -1
  321. package/lib/core/schema-stored/schema.d.ts +12 -10
  322. package/lib/core/schema-stored/schema.d.ts.map +1 -1
  323. package/lib/core/schema-stored/schema.js +3 -5
  324. package/lib/core/schema-stored/schema.js.map +1 -1
  325. package/lib/core/schema-view/index.d.ts +1 -1
  326. package/lib/core/schema-view/index.d.ts.map +1 -1
  327. package/lib/core/schema-view/index.js +1 -1
  328. package/lib/core/schema-view/index.js.map +1 -1
  329. package/lib/core/schema-view/view.d.ts +0 -7
  330. package/lib/core/schema-view/view.d.ts.map +1 -1
  331. package/lib/core/schema-view/view.js +0 -11
  332. package/lib/core/schema-view/view.js.map +1 -1
  333. package/lib/{feature-libraries/chunked-forest → core/tree}/chunk.d.ts +2 -1
  334. package/lib/core/tree/chunk.d.ts.map +1 -0
  335. package/lib/{feature-libraries/chunked-forest → core/tree}/chunk.js +1 -1
  336. package/lib/core/tree/chunk.js.map +1 -0
  337. package/lib/core/tree/index.d.ts +1 -0
  338. package/lib/core/tree/index.d.ts.map +1 -1
  339. package/lib/core/tree/index.js +1 -0
  340. package/lib/core/tree/index.js.map +1 -1
  341. package/lib/core/tree/treeTextFormat.d.ts +0 -5
  342. package/lib/core/tree/treeTextFormat.d.ts.map +1 -1
  343. package/lib/core/tree/treeTextFormat.js.map +1 -1
  344. package/lib/core/tree/types.d.ts +0 -5
  345. package/lib/core/tree/types.d.ts.map +1 -1
  346. package/lib/core/tree/types.js +0 -1
  347. package/lib/core/tree/types.js.map +1 -1
  348. package/lib/feature-libraries/chunked-forest/basicChunk.d.ts +1 -2
  349. package/lib/feature-libraries/chunked-forest/basicChunk.d.ts.map +1 -1
  350. package/lib/feature-libraries/chunked-forest/basicChunk.js +1 -1
  351. package/lib/feature-libraries/chunked-forest/basicChunk.js.map +1 -1
  352. package/lib/feature-libraries/chunked-forest/chunkTree.d.ts +1 -2
  353. package/lib/feature-libraries/chunked-forest/chunkTree.d.ts.map +1 -1
  354. package/lib/feature-libraries/chunked-forest/chunkTree.js +1 -2
  355. package/lib/feature-libraries/chunked-forest/chunkTree.js.map +1 -1
  356. package/lib/feature-libraries/chunked-forest/chunkedForest.d.ts +1 -2
  357. package/lib/feature-libraries/chunked-forest/chunkedForest.d.ts.map +1 -1
  358. package/lib/feature-libraries/chunked-forest/chunkedForest.js.map +1 -1
  359. package/lib/feature-libraries/chunked-forest/codec/chunkCodecUtilities.d.ts +1 -2
  360. package/lib/feature-libraries/chunked-forest/codec/chunkCodecUtilities.d.ts.map +1 -1
  361. package/lib/feature-libraries/chunked-forest/codec/chunkCodecUtilities.js.map +1 -1
  362. package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.d.ts +1 -2
  363. package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.d.ts.map +1 -1
  364. package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.js.map +1 -1
  365. package/lib/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.d.ts +1 -1
  366. package/lib/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.d.ts.map +1 -1
  367. package/lib/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.js.map +1 -1
  368. package/lib/feature-libraries/chunked-forest/emptyChunk.d.ts +1 -1
  369. package/lib/feature-libraries/chunked-forest/emptyChunk.d.ts.map +1 -1
  370. package/lib/feature-libraries/chunked-forest/emptyChunk.js +1 -2
  371. package/lib/feature-libraries/chunked-forest/emptyChunk.js.map +1 -1
  372. package/lib/feature-libraries/chunked-forest/index.d.ts +1 -1
  373. package/lib/feature-libraries/chunked-forest/index.d.ts.map +1 -1
  374. package/lib/feature-libraries/chunked-forest/index.js +1 -1
  375. package/lib/feature-libraries/chunked-forest/index.js.map +1 -1
  376. package/lib/feature-libraries/chunked-forest/sequenceChunk.d.ts +1 -1
  377. package/lib/feature-libraries/chunked-forest/sequenceChunk.d.ts.map +1 -1
  378. package/lib/feature-libraries/chunked-forest/sequenceChunk.js +1 -1
  379. package/lib/feature-libraries/chunked-forest/sequenceChunk.js.map +1 -1
  380. package/lib/feature-libraries/chunked-forest/uniformChunk.d.ts +1 -2
  381. package/lib/feature-libraries/chunked-forest/uniformChunk.d.ts.map +1 -1
  382. package/lib/feature-libraries/chunked-forest/uniformChunk.js +1 -1
  383. package/lib/feature-libraries/chunked-forest/uniformChunk.js.map +1 -1
  384. package/lib/feature-libraries/default-schema/defaultEditBuilder.d.ts +10 -0
  385. package/lib/feature-libraries/default-schema/defaultEditBuilder.d.ts.map +1 -1
  386. package/lib/feature-libraries/default-schema/defaultEditBuilder.js +3 -0
  387. package/lib/feature-libraries/default-schema/defaultEditBuilder.js.map +1 -1
  388. package/lib/feature-libraries/default-schema/defaultSchema.d.ts.map +1 -1
  389. package/lib/feature-libraries/default-schema/defaultSchema.js +1 -0
  390. package/lib/feature-libraries/default-schema/defaultSchema.js.map +1 -1
  391. package/lib/feature-libraries/default-schema/schemaChecker.d.ts.map +1 -1
  392. package/lib/feature-libraries/default-schema/schemaChecker.js +2 -1
  393. package/lib/feature-libraries/default-schema/schemaChecker.js.map +1 -1
  394. package/lib/feature-libraries/index.d.ts +1 -2
  395. package/lib/feature-libraries/index.d.ts.map +1 -1
  396. package/lib/feature-libraries/index.js +1 -2
  397. package/lib/feature-libraries/index.js.map +1 -1
  398. package/lib/feature-libraries/indexing/anchorTreeIndex.d.ts +8 -1
  399. package/lib/feature-libraries/indexing/anchorTreeIndex.d.ts.map +1 -1
  400. package/lib/feature-libraries/indexing/anchorTreeIndex.js +31 -5
  401. package/lib/feature-libraries/indexing/anchorTreeIndex.js.map +1 -1
  402. package/lib/feature-libraries/modular-schema/crossFieldQueries.d.ts +1 -1
  403. package/lib/feature-libraries/modular-schema/crossFieldQueries.d.ts.map +1 -1
  404. package/lib/feature-libraries/modular-schema/crossFieldQueries.js +9 -3
  405. package/lib/feature-libraries/modular-schema/crossFieldQueries.js.map +1 -1
  406. package/lib/feature-libraries/modular-schema/discrepancies.d.ts +84 -24
  407. package/lib/feature-libraries/modular-schema/discrepancies.d.ts.map +1 -1
  408. package/lib/feature-libraries/modular-schema/discrepancies.js +25 -28
  409. package/lib/feature-libraries/modular-schema/discrepancies.js.map +1 -1
  410. package/lib/feature-libraries/modular-schema/fieldChangeHandler.d.ts +12 -5
  411. package/lib/feature-libraries/modular-schema/fieldChangeHandler.d.ts.map +1 -1
  412. package/lib/feature-libraries/modular-schema/fieldChangeHandler.js.map +1 -1
  413. package/lib/feature-libraries/modular-schema/genericFieldKind.d.ts.map +1 -1
  414. package/lib/feature-libraries/modular-schema/genericFieldKind.js +2 -1
  415. package/lib/feature-libraries/modular-schema/genericFieldKind.js.map +1 -1
  416. package/lib/feature-libraries/modular-schema/index.d.ts +2 -2
  417. package/lib/feature-libraries/modular-schema/index.d.ts.map +1 -1
  418. package/lib/feature-libraries/modular-schema/index.js +1 -1
  419. package/lib/feature-libraries/modular-schema/index.js.map +1 -1
  420. package/lib/feature-libraries/modular-schema/isNeverTree.d.ts +0 -1
  421. package/lib/feature-libraries/modular-schema/isNeverTree.d.ts.map +1 -1
  422. package/lib/feature-libraries/modular-schema/isNeverTree.js +0 -1
  423. package/lib/feature-libraries/modular-schema/isNeverTree.js.map +1 -1
  424. package/lib/feature-libraries/modular-schema/modularChangeFamily.d.ts +1 -0
  425. package/lib/feature-libraries/modular-schema/modularChangeFamily.d.ts.map +1 -1
  426. package/lib/feature-libraries/modular-schema/modularChangeFamily.js +89 -25
  427. package/lib/feature-libraries/modular-schema/modularChangeFamily.js.map +1 -1
  428. package/lib/feature-libraries/modular-schema/modularChangeTypes.d.ts +12 -0
  429. package/lib/feature-libraries/modular-schema/modularChangeTypes.d.ts.map +1 -1
  430. package/lib/feature-libraries/modular-schema/modularChangeTypes.js.map +1 -1
  431. package/lib/feature-libraries/optional-field/optionalField.d.ts.map +1 -1
  432. package/lib/feature-libraries/optional-field/optionalField.js +24 -4
  433. package/lib/feature-libraries/optional-field/optionalField.js.map +1 -1
  434. package/lib/feature-libraries/optional-field/optionalFieldChangeFormatV1.d.ts +6 -6
  435. package/lib/feature-libraries/optional-field/optionalFieldChangeFormatV1.d.ts.map +1 -1
  436. package/lib/feature-libraries/optional-field/optionalFieldChangeFormatV2.d.ts +7 -7
  437. package/lib/feature-libraries/optional-field/optionalFieldChangeFormatV2.d.ts.map +1 -1
  438. package/lib/feature-libraries/schema-edits/schemaChangeFormat.d.ts +12 -12
  439. package/lib/feature-libraries/sequence-field/formatV1.d.ts +99 -99
  440. package/lib/feature-libraries/sequence-field/formatV1.d.ts.map +1 -1
  441. package/lib/feature-libraries/sequence-field/formatV2.d.ts +76 -76
  442. package/lib/feature-libraries/sequence-field/formatV2.d.ts.map +1 -1
  443. package/lib/feature-libraries/sequence-field/formatV3.d.ts +54 -54
  444. package/lib/feature-libraries/sequence-field/types.d.ts +0 -1
  445. package/lib/feature-libraries/sequence-field/types.d.ts.map +1 -1
  446. package/lib/feature-libraries/sequence-field/types.js.map +1 -1
  447. package/lib/feature-libraries/sequence-field/utils.d.ts +2 -2
  448. package/lib/feature-libraries/sequence-field/utils.d.ts.map +1 -1
  449. package/lib/feature-libraries/sequence-field/utils.js +14 -5
  450. package/lib/feature-libraries/sequence-field/utils.js.map +1 -1
  451. package/lib/index.d.ts +4 -5
  452. package/lib/index.d.ts.map +1 -1
  453. package/lib/index.js +3 -4
  454. package/lib/index.js.map +1 -1
  455. package/lib/legacy.d.ts +2 -0
  456. package/lib/packageVersion.d.ts +1 -1
  457. package/lib/packageVersion.js +1 -1
  458. package/lib/packageVersion.js.map +1 -1
  459. package/lib/public.d.ts +2 -0
  460. package/lib/shared-tree/index.d.ts +3 -2
  461. package/lib/shared-tree/index.d.ts.map +1 -1
  462. package/lib/shared-tree/index.js +2 -1
  463. package/lib/shared-tree/index.js.map +1 -1
  464. package/lib/shared-tree/schematizeTree.d.ts +1 -1
  465. package/lib/shared-tree/schematizeTree.d.ts.map +1 -1
  466. package/lib/shared-tree/schematizeTree.js +7 -7
  467. package/lib/shared-tree/schematizeTree.js.map +1 -1
  468. package/lib/shared-tree/schematizingTreeView.d.ts +10 -1
  469. package/lib/shared-tree/schematizingTreeView.d.ts.map +1 -1
  470. package/lib/shared-tree/schematizingTreeView.js +56 -17
  471. package/lib/shared-tree/schematizingTreeView.js.map +1 -1
  472. package/lib/shared-tree/sharedTree.d.ts +31 -10
  473. package/lib/shared-tree/sharedTree.d.ts.map +1 -1
  474. package/lib/shared-tree/sharedTree.js +107 -16
  475. package/lib/shared-tree/sharedTree.js.map +1 -1
  476. package/lib/shared-tree/transactionTypes.d.ts +105 -0
  477. package/lib/shared-tree/transactionTypes.d.ts.map +1 -0
  478. package/lib/shared-tree/transactionTypes.js +10 -0
  479. package/lib/shared-tree/transactionTypes.js.map +1 -0
  480. package/lib/shared-tree/treeApi.d.ts +1 -25
  481. package/lib/shared-tree/treeApi.d.ts.map +1 -1
  482. package/lib/shared-tree/treeApi.js +1 -5
  483. package/lib/shared-tree/treeApi.js.map +1 -1
  484. package/lib/shared-tree/treeCheckout.d.ts +39 -13
  485. package/lib/shared-tree/treeCheckout.d.ts.map +1 -1
  486. package/lib/shared-tree/treeCheckout.js +277 -130
  487. package/lib/shared-tree/treeCheckout.js.map +1 -1
  488. package/lib/shared-tree-core/branch.d.ts +13 -35
  489. package/lib/shared-tree-core/branch.d.ts.map +1 -1
  490. package/lib/shared-tree-core/branch.js +12 -76
  491. package/lib/shared-tree-core/branch.js.map +1 -1
  492. package/lib/shared-tree-core/branchCommitEnricher.d.ts +7 -1
  493. package/lib/shared-tree-core/branchCommitEnricher.d.ts.map +1 -1
  494. package/lib/shared-tree-core/branchCommitEnricher.js +16 -18
  495. package/lib/shared-tree-core/branchCommitEnricher.js.map +1 -1
  496. package/lib/shared-tree-core/editManager.d.ts.map +1 -1
  497. package/lib/shared-tree-core/editManager.js +3 -3
  498. package/lib/shared-tree-core/editManager.js.map +1 -1
  499. package/lib/shared-tree-core/index.d.ts +3 -3
  500. package/lib/shared-tree-core/index.d.ts.map +1 -1
  501. package/lib/shared-tree-core/index.js +2 -2
  502. package/lib/shared-tree-core/index.js.map +1 -1
  503. package/lib/shared-tree-core/sharedTreeCore.d.ts +2 -9
  504. package/lib/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
  505. package/lib/shared-tree-core/sharedTreeCore.js +4 -16
  506. package/lib/shared-tree-core/sharedTreeCore.js.map +1 -1
  507. package/lib/shared-tree-core/transaction.d.ts +38 -0
  508. package/lib/shared-tree-core/transaction.d.ts.map +1 -1
  509. package/lib/shared-tree-core/transaction.js +112 -1
  510. package/lib/shared-tree-core/transaction.js.map +1 -1
  511. package/lib/simple-tree/api/conciseTree.d.ts.map +1 -1
  512. package/lib/simple-tree/api/conciseTree.js +2 -2
  513. package/lib/simple-tree/api/conciseTree.js.map +1 -1
  514. package/lib/simple-tree/api/create.d.ts.map +1 -1
  515. package/lib/simple-tree/api/create.js +5 -1
  516. package/lib/simple-tree/api/create.js.map +1 -1
  517. package/lib/simple-tree/api/customTree.d.ts +14 -2
  518. package/lib/simple-tree/api/customTree.d.ts.map +1 -1
  519. package/lib/simple-tree/api/customTree.js +50 -2
  520. package/lib/simple-tree/api/customTree.js.map +1 -1
  521. package/lib/simple-tree/api/index.d.ts +3 -2
  522. package/lib/simple-tree/api/index.d.ts.map +1 -1
  523. package/lib/simple-tree/api/index.js +3 -1
  524. package/lib/simple-tree/api/index.js.map +1 -1
  525. package/lib/simple-tree/api/jsonSchema.d.ts +6 -0
  526. package/lib/simple-tree/api/jsonSchema.d.ts.map +1 -1
  527. package/lib/simple-tree/api/jsonSchema.js.map +1 -1
  528. package/lib/simple-tree/api/schemaFactory.d.ts +65 -8
  529. package/lib/simple-tree/api/schemaFactory.d.ts.map +1 -1
  530. package/lib/simple-tree/api/schemaFactory.js +9 -3
  531. package/lib/simple-tree/api/schemaFactory.js.map +1 -1
  532. package/lib/simple-tree/api/schemaFactoryAlpha.d.ts +83 -0
  533. package/lib/simple-tree/api/schemaFactoryAlpha.d.ts.map +1 -0
  534. package/lib/simple-tree/api/schemaFactoryAlpha.js +86 -0
  535. package/lib/simple-tree/api/schemaFactoryAlpha.js.map +1 -0
  536. package/lib/simple-tree/api/simpleSchema.d.ts +8 -2
  537. package/lib/simple-tree/api/simpleSchema.d.ts.map +1 -1
  538. package/lib/simple-tree/api/simpleSchema.js.map +1 -1
  539. package/lib/simple-tree/api/simpleSchemaToJsonSchema.js +14 -11
  540. package/lib/simple-tree/api/simpleSchemaToJsonSchema.js.map +1 -1
  541. package/lib/simple-tree/api/simpleTreeIndex.js +3 -1
  542. package/lib/simple-tree/api/simpleTreeIndex.js.map +1 -1
  543. package/lib/simple-tree/api/storedSchema.d.ts +4 -4
  544. package/lib/simple-tree/api/storedSchema.d.ts.map +1 -1
  545. package/lib/simple-tree/api/storedSchema.js +5 -18
  546. package/lib/simple-tree/api/storedSchema.js.map +1 -1
  547. package/lib/simple-tree/api/testRecursiveDomain.d.ts +5 -5
  548. package/lib/simple-tree/api/tree.d.ts +61 -0
  549. package/lib/simple-tree/api/tree.d.ts.map +1 -1
  550. package/lib/simple-tree/api/tree.js.map +1 -1
  551. package/lib/simple-tree/api/verboseTree.js +2 -2
  552. package/lib/simple-tree/api/verboseTree.js.map +1 -1
  553. package/lib/simple-tree/api/view.d.ts +14 -9
  554. package/lib/simple-tree/api/view.d.ts.map +1 -1
  555. package/lib/simple-tree/api/view.js +131 -42
  556. package/lib/simple-tree/api/view.js.map +1 -1
  557. package/lib/simple-tree/api/viewSchemaToSimpleSchema.d.ts.map +1 -1
  558. package/lib/simple-tree/api/viewSchemaToSimpleSchema.js +12 -12
  559. package/lib/simple-tree/api/viewSchemaToSimpleSchema.js.map +1 -1
  560. package/lib/simple-tree/arrayNode.d.ts +2 -2
  561. package/lib/simple-tree/arrayNode.d.ts.map +1 -1
  562. package/lib/simple-tree/arrayNode.js +2 -1
  563. package/lib/simple-tree/arrayNode.js.map +1 -1
  564. package/lib/simple-tree/core/treeNodeSchema.d.ts +10 -6
  565. package/lib/simple-tree/core/treeNodeSchema.d.ts.map +1 -1
  566. package/lib/simple-tree/core/treeNodeSchema.js.map +1 -1
  567. package/lib/simple-tree/index.d.ts +3 -3
  568. package/lib/simple-tree/index.d.ts.map +1 -1
  569. package/lib/simple-tree/index.js +2 -2
  570. package/lib/simple-tree/index.js.map +1 -1
  571. package/lib/simple-tree/leafNodeSchema.d.ts +5 -20
  572. package/lib/simple-tree/leafNodeSchema.d.ts.map +1 -1
  573. package/lib/simple-tree/leafNodeSchema.js +0 -15
  574. package/lib/simple-tree/leafNodeSchema.js.map +1 -1
  575. package/lib/simple-tree/mapNode.d.ts +2 -2
  576. package/lib/simple-tree/mapNode.d.ts.map +1 -1
  577. package/lib/simple-tree/mapNode.js +2 -1
  578. package/lib/simple-tree/mapNode.js.map +1 -1
  579. package/lib/simple-tree/objectNode.d.ts +9 -4
  580. package/lib/simple-tree/objectNode.d.ts.map +1 -1
  581. package/lib/simple-tree/objectNode.js +17 -1
  582. package/lib/simple-tree/objectNode.js.map +1 -1
  583. package/lib/simple-tree/objectNodeTypes.d.ts +6 -2
  584. package/lib/simple-tree/objectNodeTypes.d.ts.map +1 -1
  585. package/lib/simple-tree/objectNodeTypes.js.map +1 -1
  586. package/lib/simple-tree/schemaTypes.d.ts +51 -3
  587. package/lib/simple-tree/schemaTypes.d.ts.map +1 -1
  588. package/lib/simple-tree/schemaTypes.js.map +1 -1
  589. package/lib/simple-tree/toStoredSchema.d.ts.map +1 -1
  590. package/lib/simple-tree/toStoredSchema.js +19 -14
  591. package/lib/simple-tree/toStoredSchema.js.map +1 -1
  592. package/lib/util/brand.d.ts +0 -2
  593. package/lib/util/brand.d.ts.map +1 -1
  594. package/lib/util/brand.js +0 -1
  595. package/lib/util/brand.js.map +1 -1
  596. package/lib/util/index.d.ts +2 -2
  597. package/lib/util/index.d.ts.map +1 -1
  598. package/lib/util/index.js +2 -2
  599. package/lib/util/index.js.map +1 -1
  600. package/lib/util/rangeMap.d.ts +72 -42
  601. package/lib/util/rangeMap.d.ts.map +1 -1
  602. package/lib/util/rangeMap.js +159 -146
  603. package/lib/util/rangeMap.js.map +1 -1
  604. package/lib/util/typeCheck.d.ts +0 -2
  605. package/lib/util/typeCheck.d.ts.map +1 -1
  606. package/lib/util/typeCheck.js.map +1 -1
  607. package/lib/util/utils.d.ts +35 -1
  608. package/lib/util/utils.d.ts.map +1 -1
  609. package/lib/util/utils.js +29 -0
  610. package/lib/util/utils.js.map +1 -1
  611. package/package.json +23 -23
  612. package/src/core/index.ts +5 -1
  613. package/src/core/rebase/utils.ts +17 -20
  614. package/src/core/schema-stored/format.ts +0 -3
  615. package/src/core/schema-stored/schema.ts +13 -10
  616. package/src/core/schema-view/index.ts +0 -1
  617. package/src/core/schema-view/view.ts +0 -11
  618. package/src/{feature-libraries/chunked-forest → core/tree}/chunk.ts +4 -4
  619. package/src/core/tree/index.ts +8 -0
  620. package/src/core/tree/treeTextFormat.ts +0 -5
  621. package/src/core/tree/types.ts +0 -5
  622. package/src/feature-libraries/chunked-forest/basicChunk.ts +4 -2
  623. package/src/feature-libraries/chunked-forest/chunkTree.ts +2 -1
  624. package/src/feature-libraries/chunked-forest/chunkedForest.ts +2 -1
  625. package/src/feature-libraries/chunked-forest/codec/chunkCodecUtilities.ts +1 -2
  626. package/src/feature-libraries/chunked-forest/codec/chunkDecoding.ts +6 -2
  627. package/src/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.ts +1 -1
  628. package/src/feature-libraries/chunked-forest/emptyChunk.ts +4 -2
  629. package/src/feature-libraries/chunked-forest/index.ts +1 -1
  630. package/src/feature-libraries/chunked-forest/sequenceChunk.ts +1 -1
  631. package/src/feature-libraries/chunked-forest/uniformChunk.ts +4 -1
  632. package/src/feature-libraries/default-schema/defaultEditBuilder.ts +14 -1
  633. package/src/feature-libraries/default-schema/defaultSchema.ts +1 -0
  634. package/src/feature-libraries/default-schema/schemaChecker.ts +4 -1
  635. package/src/feature-libraries/index.ts +13 -1
  636. package/src/feature-libraries/indexing/anchorTreeIndex.ts +34 -5
  637. package/src/feature-libraries/modular-schema/crossFieldQueries.ts +9 -9
  638. package/src/feature-libraries/modular-schema/discrepancies.ts +76 -38
  639. package/src/feature-libraries/modular-schema/fieldChangeHandler.ts +13 -9
  640. package/src/feature-libraries/modular-schema/genericFieldKind.ts +4 -2
  641. package/src/feature-libraries/modular-schema/index.ts +14 -0
  642. package/src/feature-libraries/modular-schema/isNeverTree.ts +0 -2
  643. package/src/feature-libraries/modular-schema/modularChangeFamily.ts +124 -31
  644. package/src/feature-libraries/modular-schema/modularChangeTypes.ts +12 -0
  645. package/src/feature-libraries/optional-field/optionalField.ts +34 -5
  646. package/src/feature-libraries/sequence-field/types.ts +0 -1
  647. package/src/feature-libraries/sequence-field/utils.ts +18 -7
  648. package/src/index.ts +12 -29
  649. package/src/packageVersion.ts +1 -1
  650. package/src/shared-tree/index.ts +13 -2
  651. package/src/shared-tree/schematizeTree.ts +6 -10
  652. package/src/shared-tree/schematizingTreeView.ts +102 -23
  653. package/src/shared-tree/sharedTree.ts +181 -44
  654. package/src/shared-tree/transactionTypes.ts +125 -0
  655. package/src/shared-tree/treeApi.ts +1 -28
  656. package/src/shared-tree/treeCheckout.ts +358 -175
  657. package/src/shared-tree-core/branch.ts +29 -122
  658. package/src/shared-tree-core/branchCommitEnricher.ts +19 -20
  659. package/src/shared-tree-core/editManager.ts +3 -8
  660. package/src/shared-tree-core/index.ts +2 -1
  661. package/src/shared-tree-core/sharedTreeCore.ts +8 -19
  662. package/src/shared-tree-core/transaction.ts +145 -0
  663. package/src/simple-tree/api/conciseTree.ts +2 -2
  664. package/src/simple-tree/api/create.ts +5 -1
  665. package/src/simple-tree/api/customTree.ts +69 -1
  666. package/src/simple-tree/api/index.ts +13 -2
  667. package/src/simple-tree/api/jsonSchema.ts +7 -0
  668. package/src/simple-tree/api/schemaFactory.ts +91 -3
  669. package/src/simple-tree/api/schemaFactoryAlpha.ts +253 -0
  670. package/src/simple-tree/api/simpleSchema.ts +9 -2
  671. package/src/simple-tree/api/simpleSchemaToJsonSchema.ts +22 -12
  672. package/src/simple-tree/api/simpleTreeIndex.ts +2 -0
  673. package/src/simple-tree/api/storedSchema.ts +7 -22
  674. package/src/simple-tree/api/tree.ts +78 -0
  675. package/src/simple-tree/api/verboseTree.ts +2 -2
  676. package/src/simple-tree/api/view.ts +197 -51
  677. package/src/simple-tree/api/viewSchemaToSimpleSchema.ts +19 -13
  678. package/src/simple-tree/arrayNode.ts +7 -1
  679. package/src/simple-tree/core/treeNodeSchema.ts +51 -7
  680. package/src/simple-tree/index.ts +9 -0
  681. package/src/simple-tree/leafNodeSchema.ts +0 -19
  682. package/src/simple-tree/mapNode.ts +7 -1
  683. package/src/simple-tree/objectNode.ts +33 -3
  684. package/src/simple-tree/objectNodeTypes.ts +9 -1
  685. package/src/simple-tree/schemaTypes.ts +57 -3
  686. package/src/simple-tree/toStoredSchema.ts +25 -19
  687. package/src/util/brand.ts +0 -2
  688. package/src/util/index.ts +3 -6
  689. package/src/util/rangeMap.ts +199 -189
  690. package/src/util/typeCheck.ts +0 -2
  691. package/src/util/utils.ts +73 -1
  692. package/dist/feature-libraries/chunked-forest/chunk.d.ts.map +0 -1
  693. package/dist/feature-libraries/chunked-forest/chunk.js.map +0 -1
  694. package/dist/feature-libraries/memoizedIdRangeAllocator.d.ts +0 -38
  695. package/dist/feature-libraries/memoizedIdRangeAllocator.d.ts.map +0 -1
  696. package/dist/feature-libraries/memoizedIdRangeAllocator.js +0 -74
  697. package/dist/feature-libraries/memoizedIdRangeAllocator.js.map +0 -1
  698. package/lib/feature-libraries/chunked-forest/chunk.d.ts.map +0 -1
  699. package/lib/feature-libraries/chunked-forest/chunk.js.map +0 -1
  700. package/lib/feature-libraries/memoizedIdRangeAllocator.d.ts +0 -38
  701. package/lib/feature-libraries/memoizedIdRangeAllocator.d.ts.map +0 -1
  702. package/lib/feature-libraries/memoizedIdRangeAllocator.js +0 -71
  703. package/lib/feature-libraries/memoizedIdRangeAllocator.js.map +0 -1
  704. package/src/feature-libraries/memoizedIdRangeAllocator.ts +0 -112
@@ -1 +1 @@
1
- {"version":3,"file":"chunkedForest.d.ts","sourceRoot":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;CAIpB;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CACjC,OAAO,EAAE,QAAQ,EACjB,OAAO,CAAC,EAAE,SAAS,EACnB,YAAY,CAAC,EAAE,aAAa,GAC1B,aAAa,CAEf"}
1
+ {"version":3,"file":"chunkedForest.d.ts","sourceRoot":"","sources":["../../../src/feature-libraries/chunked-forest/chunkedForest.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAGlE,OAAO,EACN,KAAK,MAAM,EACX,SAAS,EACT,KAAK,gBAAgB,EACrB,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,EAMX,KAAK,aAAa,EAClB,KAAK,SAAS,EACd,MAAM,qBAAqB,CAAC;AAU7B,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,KAAK,aAAa,EAAE,MAAM,iBAAiB,CAAC;AACnF,OAAO,EAAE,KAAK,QAAQ,EAA6B,MAAM,gBAAgB,CAAC;AAC1E,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAWnE;;;;GAIG;AACH,qBAAa,aAAc,YAAW,eAAe;;IAc5C,KAAK,EAAE,UAAU;aACR,MAAM,EAAE,4BAA4B;aACpC,OAAO,EAAE,QAAQ;aACjB,OAAO,EAAE,SAAS;aAClB,YAAY,CAAC;IAjB9B,OAAO,CAAC,aAAa,CAAC,CAAe;IAErC,OAAO,CAAC,QAAQ,CAAC,aAAa,CAA0C;IAExE,SAAgB,MAAM,EAAE,UAAU,CAAC,YAAY,CAAC,CAAgB;IAEhE;;;;;OAKG;gBAEK,KAAK,EAAE,UAAU,EACR,MAAM,EAAE,4BAA4B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jB,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC;IAClD,CAAC;IAEM,KAAK;QACX,IAAI,CAAC,KAAK,GAAG,uCAA4B,CAAC,OAAO,CAAC;QAClD,IAAI,CAAC,qBAAqB,CAAC,uBAAY,CAAC,CAAC;IAC1C,CAAC;CACD;AAED;;GAEG;AACH,SAAgB,kBAAkB,CACjC,OAAiB,EACjB,OAAmB,EACnB,YAA4B;IAE5B,OAAO,IAAI,aAAa,CAAC,QAAQ,EAAE,EAAE,OAAO,CAAC,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,YAAY,CAAC,CAAC;AACtF,CAAC;AAND,gDAMC","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\";\nimport type { Listenable } from \"@fluidframework/core-interfaces\";\nimport { createEmitter } from \"@fluid-internal/client-utils\";\n\nimport {\n\ttype Anchor,\n\tAnchorSet,\n\ttype AnnouncedVisitor,\n\ttype DeltaVisitor,\n\ttype DetachedField,\n\ttype FieldAnchor,\n\ttype FieldKey,\n\ttype ForestEvents,\n\ttype IEditableForest,\n\ttype ITreeCursorSynchronous,\n\ttype ITreeSubscriptionCursor,\n\tITreeSubscriptionCursorState,\n\ttype PlaceIndex,\n\ttype ProtoNodes,\n\ttype Range,\n\tTreeNavigationResult,\n\ttype TreeStoredSchemaSubscription,\n\ttype UpPath,\n\taboveRootPlaceholder,\n\tcombineVisitors,\n\tdetachedFieldAsKey,\n\tmapCursorField,\n\trootFieldKey,\n} from \"../../core/index.js\";\nimport {\n\tassertValidRange,\n\tbrand,\n\tfail,\n\tgetLast,\n\tgetOrAddEmptyToMap,\n\thasSome,\n} from \"../../util/index.js\";\n\nimport { BasicChunk, BasicChunkCursor, type SiblingsOrKey } from \"./basicChunk.js\";\nimport type { ChunkedCursor, TreeChunk } from \"./chunk.js\";\nimport { type IChunker, basicChunkTree, chunkTree } from \"./chunkTree.js\";\nimport type { IIdCompressor } from \"@fluidframework/id-compressor\";\n\nfunction makeRoot(): BasicChunk {\n\treturn new BasicChunk(aboveRootPlaceholder, new Map());\n}\n\ninterface StackNode {\n\tmutableChunk: BasicChunk;\n\tkey: FieldKey;\n}\n\n/**\n * Implementation of IEditableForest based on copy on write chunks.\n *\n * This implementation focuses on performance.\n */\nexport class ChunkedForest implements IEditableForest {\n\tprivate activeVisitor?: DeltaVisitor;\n\n\tprivate readonly deltaVisitors: Set<() => AnnouncedVisitor> = new Set();\n\treadonly #events = createEmitter<ForestEvents>();\n\tpublic readonly events: Listenable<ForestEvents> = this.#events;\n\n\t/**\n\t * @param roots - dummy node above the root under which detached fields are stored. All content of the forest is reachable from this.\n\t * @param schema - schema which all content in this forest is assumed to comply with.\n\t * @param chunker - Chunking policy. TODO: dispose of this when forest is disposed.\n\t * @param anchors - anchorSet used to track location in this forest across changes. Callers of applyDelta must ensure this is updated accordingly.\n\t */\n\tpublic constructor(\n\t\tpublic roots: BasicChunk,\n\t\tpublic readonly schema: TreeStoredSchemaSubscription,\n\t\tpublic readonly chunker: IChunker,\n\t\tpublic readonly anchors: AnchorSet = new AnchorSet(),\n\t\tpublic readonly idCompressor?: IIdCompressor,\n\t) {}\n\n\tpublic get isEmpty(): boolean {\n\t\treturn this.roots.fields.size === 0;\n\t}\n\n\tpublic clone(schema: TreeStoredSchemaSubscription, anchors: AnchorSet): ChunkedForest {\n\t\tthis.roots.referenceAdded();\n\t\treturn new ChunkedForest(this.roots, schema, this.chunker.clone(schema), anchors);\n\t}\n\n\tpublic forgetAnchor(anchor: Anchor): void {\n\t\tthis.anchors.forget(anchor);\n\t}\n\n\tpublic registerAnnouncedVisitor(visitor: () => AnnouncedVisitor): void {\n\t\tthis.deltaVisitors.add(visitor);\n\t}\n\n\tpublic deregisterAnnouncedVisitor(visitor: () => AnnouncedVisitor): void {\n\t\tthis.deltaVisitors.delete(visitor);\n\t}\n\n\tpublic acquireVisitor(): DeltaVisitor {\n\t\tassert(\n\t\t\tthis.activeVisitor === undefined,\n\t\t\t0x76a /* Must release existing visitor before acquiring another */,\n\t\t);\n\n\t\tif (this.roots.isShared()) {\n\t\t\tthis.roots = this.roots.clone();\n\t\t}\n\n\t\tconst forestVisitor = {\n\t\t\tforest: this,\n\t\t\t// Current location in the tree, as a non-shared BasicChunk (TODO: support in-place modification of other chunk formats when possible).\n\t\t\t// Start above root detached sequences.\n\t\t\tmutableChunkStack: [] as StackNode[],\n\t\t\tmutableChunk: this.roots as BasicChunk | undefined,\n\t\t\tgetParent(): StackNode {\n\t\t\t\tassert(hasSome(this.mutableChunkStack), 0x532 /* invalid access to root's parent */);\n\t\t\t\treturn getLast(this.mutableChunkStack);\n\t\t\t},\n\t\t\tfree(): void {\n\t\t\t\tthis.mutableChunk = undefined;\n\t\t\t\tthis.mutableChunkStack.length = 0;\n\t\t\t\tassert(\n\t\t\t\t\tthis.forest.activeVisitor !== undefined,\n\t\t\t\t\t0x76b /* Multiple free calls for same visitor */,\n\t\t\t\t);\n\t\t\t\tthis.forest.activeVisitor = undefined;\n\t\t\t},\n\t\t\tdestroy(detachedField: FieldKey, count: number): void {\n\t\t\t\tthis.forest.#events.emit(\"beforeChange\");\n\t\t\t\tthis.forest.roots.fields.delete(detachedField);\n\t\t\t},\n\t\t\tcreate(content: ProtoNodes, destination: FieldKey): void {\n\t\t\t\tthis.forest.#events.emit(\"beforeChange\");\n\t\t\t\tconst chunks: TreeChunk[] = content.map((c) =>\n\t\t\t\t\tchunkTree(c, {\n\t\t\t\t\t\tpolicy: this.forest.chunker,\n\t\t\t\t\t\tidCompressor: this.forest.idCompressor,\n\t\t\t\t\t}),\n\t\t\t\t);\n\t\t\t\tthis.forest.roots.fields.set(destination, chunks);\n\t\t\t\tthis.forest.#events.emit(\"afterRootFieldCreated\", destination);\n\t\t\t},\n\t\t\tattach(source: FieldKey, count: number, destination: PlaceIndex): void {\n\t\t\t\tthis.attachEdit(source, count, destination);\n\t\t\t},\n\t\t\tdetach(source: Range, destination: FieldKey): void {\n\t\t\t\tthis.detachEdit(source, destination);\n\t\t\t},\n\t\t\t/**\n\t\t\t * Attaches the range into the current field by transferring it from the given source path.\n\t\t\t * Does not invalidate dependents.\n\t\t\t * @param source - The the range to be attached.\n\t\t\t * @param destination - The index in the current field at which to attach the content.\n\t\t\t */\n\t\t\tattachEdit(source: FieldKey, count: number, destination: PlaceIndex): void {\n\t\t\t\tthis.forest.#events.emit(\"beforeChange\");\n\t\t\t\tconst sourceField = this.forest.roots.fields.get(source) ?? [];\n\t\t\t\tthis.forest.roots.fields.delete(source);\n\t\t\t\tif (sourceField.length === 0) {\n\t\t\t\t\treturn; // Prevent creating 0 sized fields when inserting empty into empty.\n\t\t\t\t}\n\n\t\t\t\tconst parent = this.getParent();\n\t\t\t\tconst destinationField = getOrAddEmptyToMap(parent.mutableChunk.fields, parent.key);\n\t\t\t\t// TODO: this will fail for very large moves due to argument limits.\n\t\t\t\tdestinationField.splice(destination, 0, ...sourceField);\n\t\t\t},\n\t\t\t/**\n\t\t\t * Detaches the range from the current field and transfers it to the given destination if any.\n\t\t\t * Does not invalidate dependents.\n\t\t\t * @param source - The bounds of the range to be detached from the current field.\n\t\t\t * @param destination - If specified, the destination to transfer the detached range to.\n\t\t\t * If not specified, the detached range is destroyed.\n\t\t\t */\n\t\t\tdetachEdit(source: Range, destination: FieldKey | undefined): void {\n\t\t\t\tthis.forest.#events.emit(\"beforeChange\");\n\t\t\t\tconst parent = this.getParent();\n\t\t\t\tconst sourceField = parent.mutableChunk.fields.get(parent.key) ?? [];\n\n\t\t\t\tassertValidRange(source, sourceField);\n\t\t\t\tconst newField = sourceField.splice(source.start, source.end - source.start);\n\n\t\t\t\tif (destination !== undefined) {\n\t\t\t\t\tassert(\n\t\t\t\t\t\t!this.forest.roots.fields.has(destination),\n\t\t\t\t\t\t0x7af /* Destination must be a new empty detached field */,\n\t\t\t\t\t);\n\t\t\t\t\tif (newField.length > 0) {\n\t\t\t\t\t\tthis.forest.roots.fields.set(destination, newField);\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tfor (const child of newField) {\n\t\t\t\t\t\tchild.referenceRemoved();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t// This check is performed after the transfer to ensure that the field is not removed in scenarios\n\t\t\t\t// where the source and destination are the same.\n\t\t\t\tif (sourceField.length === 0) {\n\t\t\t\t\tparent.mutableChunk.fields.delete(parent.key);\n\t\t\t\t}\n\t\t\t},\n\t\t\treplace(\n\t\t\t\tnewContentSource: FieldKey,\n\t\t\t\trange: Range,\n\t\t\t\toldContentDestination: FieldKey,\n\t\t\t): void {\n\t\t\t\tassert(\n\t\t\t\t\tnewContentSource !== oldContentDestination,\n\t\t\t\t\t0x7b0 /* Replace detached source field and detached destination field must be different */,\n\t\t\t\t);\n\t\t\t\t// TODO: optimize this to: perform in-place replace in uniform chunks when possible.\n\t\t\t\t// This should result in 3 cases:\n\t\t\t\t// 1. In-place update of uniform chunk. No allocations, no ref count changes, no new TreeChunks.\n\t\t\t\t// 2. Uniform chunk is shared: copy it (and parent path as needed), and update the copy.\n\t\t\t\t// 3. Fallback to detach then attach (Which will copy parents and convert to basic chunks as needed).\n\t\t\t\tthis.detachEdit(range, oldContentDestination);\n\t\t\t\tthis.attachEdit(newContentSource, range.end - range.start, range.start);\n\t\t\t},\n\t\t\tenterNode(index: number): void {\n\t\t\t\tassert(this.mutableChunk === undefined, 0x535 /* should be in field */);\n\t\t\t\tconst parent = this.getParent();\n\t\t\t\tconst chunks =\n\t\t\t\t\tparent.mutableChunk.fields.get(parent.key) ?? fail(\"missing edited field\");\n\t\t\t\tlet indexWithinChunk = index;\n\t\t\t\tlet indexOfChunk = 0;\n\t\t\t\tlet chunk = chunks[indexOfChunk] ?? oob();\n\t\t\t\twhile (indexWithinChunk >= chunk.topLevelLength) {\n\t\t\t\t\tchunk = chunks[indexOfChunk] ?? oob();\n\t\t\t\t\tindexWithinChunk -= chunk.topLevelLength;\n\t\t\t\t\tindexOfChunk++;\n\t\t\t\t\tif (indexOfChunk === chunks.length) {\n\t\t\t\t\t\tfail(\"missing edited node\");\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tlet found = chunks[indexOfChunk] ?? oob();\n\t\t\t\tif (!(found instanceof BasicChunk)) {\n\t\t\t\t\t// TODO:Perf: support in place editing of other chunk formats when possible:\n\t\t\t\t\t// 1. Support updating values in uniform chunks.\n\t\t\t\t\t// 2. Support traversing sequence chunks.\n\t\t\t\t\t//\n\t\t\t\t\t// Maybe build path when visitor navigates then lazily sync to chunk tree when editing?\n\t\t\t\t\tconst newChunks = mapCursorField(found.cursor(), (cursor) =>\n\t\t\t\t\t\tbasicChunkTree(cursor, {\n\t\t\t\t\t\t\tpolicy: this.forest.chunker,\n\t\t\t\t\t\t\tidCompressor: this.forest.idCompressor,\n\t\t\t\t\t\t}),\n\t\t\t\t\t);\n\t\t\t\t\t// TODO: this could fail for really long chunks being split (due to argument count limits).\n\t\t\t\t\t// Current implementations of chunks shouldn't ever be that long, but it could be an issue if they get bigger.\n\t\t\t\t\tchunks.splice(indexOfChunk, 1, ...newChunks);\n\t\t\t\t\tfound.referenceRemoved();\n\n\t\t\t\t\tfound = newChunks[indexWithinChunk] ?? oob();\n\t\t\t\t}\n\t\t\t\tassert(found instanceof BasicChunk, 0x536 /* chunk should have been normalized */);\n\t\t\t\tif (found.isShared()) {\n\t\t\t\t\tthis.mutableChunk = chunks[indexOfChunk] = found.clone();\n\t\t\t\t\tfound.referenceRemoved();\n\t\t\t\t} else {\n\t\t\t\t\tthis.mutableChunk = found;\n\t\t\t\t}\n\t\t\t},\n\t\t\texitNode(index: number): void {\n\t\t\t\tassert(this.mutableChunk !== undefined, 0x537 /* should be in node */);\n\t\t\t\tthis.mutableChunk = undefined;\n\t\t\t},\n\t\t\tenterField(key: FieldKey): void {\n\t\t\t\tassert(this.mutableChunk !== undefined, 0x538 /* should be in node */);\n\t\t\t\tthis.mutableChunkStack.push({ key, mutableChunk: this.mutableChunk });\n\t\t\t\tthis.mutableChunk = undefined;\n\t\t\t},\n\t\t\texitField(key: FieldKey): void {\n\t\t\t\tconst top = this.mutableChunkStack.pop() ?? fail(\"should not be at root\");\n\t\t\t\tassert(this.mutableChunk === undefined, 0x539 /* should be in field */);\n\t\t\t\tthis.mutableChunk = top.mutableChunk;\n\t\t\t},\n\t\t};\n\n\t\tconst announcedVisitors: AnnouncedVisitor[] = [];\n\t\tthis.deltaVisitors.forEach((getVisitor) => announcedVisitors.push(getVisitor()));\n\t\tconst combinedVisitor = combineVisitors(\n\t\t\t[forestVisitor, ...announcedVisitors],\n\t\t\tannouncedVisitors,\n\t\t);\n\t\tthis.activeVisitor = combinedVisitor;\n\t\treturn combinedVisitor;\n\t}\n\n\tprivate nextDetachedFieldIdentifier = 0;\n\tpublic newDetachedField(): DetachedField {\n\t\tconst field: DetachedField = brand(String(this.nextDetachedFieldIdentifier));\n\t\tassert(\n\t\t\t!this.roots.fields.has(detachedFieldAsKey(field)),\n\t\t\t0x53a /* new field must not already exist */,\n\t\t);\n\t\tthis.nextDetachedFieldIdentifier += 1;\n\t\treturn field;\n\t}\n\n\tpublic allocateCursor(): Cursor {\n\t\treturn new Cursor(\n\t\t\tthis,\n\t\t\tITreeSubscriptionCursorState.Cleared,\n\t\t\t[],\n\t\t\t[],\n\t\t\t[],\n\t\t\t[],\n\t\t\t[],\n\t\t\t[],\n\t\t\t0,\n\t\t\t0,\n\t\t\t0,\n\t\t\tundefined,\n\t\t);\n\t}\n\n\tpublic tryMoveCursorToNode(\n\t\tdestination: Anchor,\n\t\tcursorToMove: ITreeSubscriptionCursor,\n\t): TreeNavigationResult {\n\t\tconst path = this.anchors.locate(destination);\n\t\tif (path === undefined) {\n\t\t\treturn TreeNavigationResult.NotFound;\n\t\t}\n\t\tthis.moveCursorToPath(path, cursorToMove);\n\t\treturn TreeNavigationResult.Ok;\n\t}\n\n\tpublic tryMoveCursorToField(\n\t\tdestination: FieldAnchor,\n\t\tcursorToMove: ITreeSubscriptionCursor,\n\t): TreeNavigationResult {\n\t\tassert(\n\t\t\tcursorToMove instanceof Cursor,\n\t\t\t0x53b /* ChunkedForest must only be given its own Cursor type */,\n\t\t);\n\t\tif (destination.parent === undefined) {\n\t\t\tcursorToMove.setToDetachedSequence(destination.fieldKey);\n\t\t\treturn TreeNavigationResult.Ok;\n\t\t}\n\t\tconst result = this.tryMoveCursorToNode(destination.parent, cursorToMove);\n\t\tif (result !== TreeNavigationResult.Ok) {\n\t\t\treturn result;\n\t\t}\n\n\t\tcursorToMove.enterField(destination.fieldKey);\n\t\treturn TreeNavigationResult.Ok;\n\t}\n\n\tpublic moveCursorToPath(destination: UpPath, cursorToMove: ITreeSubscriptionCursor): void {\n\t\tassert(\n\t\t\tcursorToMove instanceof Cursor,\n\t\t\t0x53c /* ChunkedForest must only be given its own Cursor type */,\n\t\t);\n\t\tassert(\n\t\t\tcursorToMove.forest === this,\n\t\t\t0x53d /* ChunkedForest must only be given its own Cursor */,\n\t\t);\n\n\t\tconst indexStack: number[] = [];\n\t\tconst keyStack: FieldKey[] = [];\n\n\t\tlet path: UpPath | undefined = destination;\n\t\twhile (path !== undefined) {\n\t\t\tindexStack.push(path.parentIndex);\n\t\t\tkeyStack.push(path.parentField);\n\t\t\tpath = path.parent;\n\t\t}\n\t\tcursorToMove.clear();\n\t\twhile (keyStack.length > 0) {\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\tconst key = keyStack.pop()!;\n\t\t\tif (cursorToMove.state === ITreeSubscriptionCursorState.Cleared) {\n\t\t\t\tcursorToMove.setToDetachedSequence(key);\n\t\t\t\tcursorToMove.state = ITreeSubscriptionCursorState.Current;\n\t\t\t} else {\n\t\t\t\tcursorToMove.enterField(key);\n\t\t\t}\n\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\tcursorToMove.enterNode(indexStack.pop()!);\n\t\t}\n\t}\n\n\tpublic getCursorAboveDetachedFields(): ITreeCursorSynchronous {\n\t\tconst rootCursor = this.roots.cursor();\n\t\trootCursor.enterNode(0);\n\t\treturn rootCursor;\n\t}\n}\n\nclass Cursor extends BasicChunkCursor implements ITreeSubscriptionCursor {\n\tpublic constructor(\n\t\tpublic readonly forest: ChunkedForest,\n\t\tpublic state: ITreeSubscriptionCursorState,\n\t\troot: readonly TreeChunk[],\n\t\tsiblingStack: SiblingsOrKey[],\n\t\tindexStack: number[],\n\t\tindexOfChunkStack: number[],\n\t\tindexWithinChunkStack: number[],\n\t\tsiblings: SiblingsOrKey,\n\t\tindex: number,\n\t\tindexOfChunk: number,\n\t\tindexWithinChunk: number,\n\t\tnestedCursor: ChunkedCursor | undefined,\n\t) {\n\t\tsuper(\n\t\t\troot,\n\t\t\tsiblingStack,\n\t\t\tindexStack,\n\t\t\tindexOfChunkStack,\n\t\t\tindexWithinChunkStack,\n\t\t\tsiblings,\n\t\t\tindex,\n\t\t\tindexOfChunk,\n\t\t\tindexWithinChunk,\n\t\t\tnestedCursor,\n\t\t);\n\t}\n\n\tpublic setToDetachedSequence(key: FieldKey): void {\n\t\tthis.root = (this.forest.roots.fields.get(key) ?? []) as BasicChunk[];\n\t\tthis.siblingStack.length = 0;\n\t\tthis.indexStack.length = 0;\n\t\tthis.indexOfChunkStack.length = 0;\n\t\tthis.indexWithinChunkStack.length = 0;\n\t\tthis.siblings = [key];\n\t\tthis.index = 0;\n\t\tthis.indexOfChunk = 0;\n\t\tthis.indexWithinChunk = 0;\n\t\tthis.nestedCursor = undefined;\n\t}\n\n\tpublic override fork(): Cursor {\n\t\t// Siblings arrays are not modified during navigation and do not need be be copied.\n\t\t// This allows this copy to be shallow, and `this.siblings` below to not be copied as all.\n\t\treturn new Cursor(\n\t\t\tthis.forest,\n\t\t\tthis.state,\n\t\t\tthis.root,\n\t\t\t[...this.siblingStack],\n\t\t\t[...this.indexStack],\n\t\t\t[...this.indexOfChunkStack],\n\t\t\t[...this.indexWithinChunkStack],\n\t\t\tthis.siblings,\n\t\t\tthis.index,\n\t\t\tthis.indexOfChunk,\n\t\t\tthis.indexWithinChunk,\n\t\t\tthis.nestedCursor?.fork(),\n\t\t);\n\t}\n\n\tpublic buildFieldAnchor(): FieldAnchor {\n\t\tconst path = this.getFieldPath();\n\t\tconst anchor =\n\t\t\tpath.parent === undefined ? undefined : this.forest.anchors.track(path.parent);\n\t\treturn { parent: anchor, fieldKey: path.field };\n\t}\n\n\tpublic free(): void {\n\t\tthis.state = ITreeSubscriptionCursorState.Freed;\n\t}\n\n\tpublic buildAnchor(): Anchor {\n\t\treturn this.forest.anchors.track(this.getPath());\n\t}\n\n\tpublic clear(): void {\n\t\tthis.state = ITreeSubscriptionCursorState.Cleared;\n\t\tthis.setToDetachedSequence(rootFieldKey);\n\t}\n}\n\n/**\n * @returns an implementation of {@link IEditableForest} with no data or schema.\n */\nexport function buildChunkedForest(\n\tchunker: IChunker,\n\tanchors?: AnchorSet,\n\tidCompressor?: IIdCompressor,\n): ChunkedForest {\n\treturn new ChunkedForest(makeRoot(), chunker.schema, chunker, anchors, idCompressor);\n}\n"]}
1
+ {"version":3,"file":"chunkedForest.js","sourceRoot":"","sources":["../../../src/feature-libraries/chunked-forest/chunkedForest.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;AAEH,kEAAkE;AAElE,+DAA6D;AAE7D,kDA0B6B;AAC7B,kDAO6B;AAE7B,mDAAmF;AACnF,iDAA0E;AAG1E,SAAS,QAAQ;IAChB,OAAO,IAAI,0BAAU,CAAC,+BAAoB,EAAE,IAAI,GAAG,EAAE,CAAC,CAAC;AACxD,CAAC;AAOD;;;;GAIG;AACH,MAAa,aAAa;IAOzB;;;;;OAKG;IACH,YACQ,KAAiB,EACR,MAAoC,EACpC,OAAiB,EACjB,UAAqB,IAAI,oBAAS,EAAE,EACpC,YAA4B;QAJrC,UAAK,GAAL,KAAK,CAAY;QACR,WAAM,GAAN,MAAM,CAA8B;QAC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AI,CAAC,YAAY,EAAE,CAAC;QACjC,MAAM,MAAM,GACX,IAAI,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAChF,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,CAAC,KAAK,EAAE,CAAC;IACjD,CAAC;IAEM,IAAI;QACV,IAAI,CAAC,KAAK,GAAG,uCAA4B,CAAC,KAAK,CAAC;IACjD,CAAC;IAEM,WAAW;QACjB,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC;IAClD,CAAC;IAEM,KAAK;QACX,IAAI,CAAC,KAAK,GAAG,uCAA4B,CAAC,OAAO,CAAC;QAClD,IAAI,CAAC,qBAAqB,CAAC,uBAAY,CAAC,CAAC;IAC1C,CAAC;CACD;AAED;;GAEG;AACH,SAAgB,kBAAkB,CACjC,OAAiB,EACjB,OAAmB,EACnB,YAA4B;IAE5B,OAAO,IAAI,aAAa,CAAC,QAAQ,EAAE,EAAE,OAAO,CAAC,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,YAAY,CAAC,CAAC;AACtF,CAAC;AAND,gDAMC","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\";\nimport type { Listenable } from \"@fluidframework/core-interfaces\";\nimport { createEmitter } from \"@fluid-internal/client-utils\";\n\nimport {\n\ttype Anchor,\n\tAnchorSet,\n\ttype AnnouncedVisitor,\n\ttype DeltaVisitor,\n\ttype DetachedField,\n\ttype FieldAnchor,\n\ttype FieldKey,\n\ttype ForestEvents,\n\ttype IEditableForest,\n\ttype ITreeCursorSynchronous,\n\ttype ITreeSubscriptionCursor,\n\tITreeSubscriptionCursorState,\n\ttype PlaceIndex,\n\ttype ProtoNodes,\n\ttype Range,\n\tTreeNavigationResult,\n\ttype TreeStoredSchemaSubscription,\n\ttype UpPath,\n\taboveRootPlaceholder,\n\tcombineVisitors,\n\tdetachedFieldAsKey,\n\tmapCursorField,\n\trootFieldKey,\n\ttype ChunkedCursor,\n\ttype TreeChunk,\n} from \"../../core/index.js\";\nimport {\n\tassertValidRange,\n\tbrand,\n\tfail,\n\tgetLast,\n\tgetOrAddEmptyToMap,\n\thasSome,\n} from \"../../util/index.js\";\n\nimport { BasicChunk, BasicChunkCursor, type SiblingsOrKey } from \"./basicChunk.js\";\nimport { type IChunker, basicChunkTree, chunkTree } from \"./chunkTree.js\";\nimport type { IIdCompressor } from \"@fluidframework/id-compressor\";\n\nfunction makeRoot(): BasicChunk {\n\treturn new BasicChunk(aboveRootPlaceholder, new Map());\n}\n\ninterface StackNode {\n\tmutableChunk: BasicChunk;\n\tkey: FieldKey;\n}\n\n/**\n * Implementation of IEditableForest based on copy on write chunks.\n *\n * This implementation focuses on performance.\n */\nexport class ChunkedForest implements IEditableForest {\n\tprivate activeVisitor?: DeltaVisitor;\n\n\tprivate readonly deltaVisitors: Set<() => AnnouncedVisitor> = new Set();\n\treadonly #events = createEmitter<ForestEvents>();\n\tpublic readonly events: Listenable<ForestEvents> = this.#events;\n\n\t/**\n\t * @param roots - dummy node above the root under which detached fields are stored. All content of the forest is reachable from this.\n\t * @param schema - schema which all content in this forest is assumed to comply with.\n\t * @param chunker - Chunking policy. TODO: dispose of this when forest is disposed.\n\t * @param anchors - anchorSet used to track location in this forest across changes. Callers of applyDelta must ensure this is updated accordingly.\n\t */\n\tpublic constructor(\n\t\tpublic roots: BasicChunk,\n\t\tpublic readonly schema: TreeStoredSchemaSubscription,\n\t\tpublic readonly chunker: IChunker,\n\t\tpublic readonly anchors: AnchorSet = new AnchorSet(),\n\t\tpublic readonly idCompressor?: IIdCompressor,\n\t) {}\n\n\tpublic get isEmpty(): boolean {\n\t\treturn this.roots.fields.size === 0;\n\t}\n\n\tpublic clone(schema: TreeStoredSchemaSubscription, anchors: AnchorSet): ChunkedForest {\n\t\tthis.roots.referenceAdded();\n\t\treturn new ChunkedForest(this.roots, schema, this.chunker.clone(schema), anchors);\n\t}\n\n\tpublic forgetAnchor(anchor: Anchor): void {\n\t\tthis.anchors.forget(anchor);\n\t}\n\n\tpublic registerAnnouncedVisitor(visitor: () => AnnouncedVisitor): void {\n\t\tthis.deltaVisitors.add(visitor);\n\t}\n\n\tpublic deregisterAnnouncedVisitor(visitor: () => AnnouncedVisitor): void {\n\t\tthis.deltaVisitors.delete(visitor);\n\t}\n\n\tpublic acquireVisitor(): DeltaVisitor {\n\t\tassert(\n\t\t\tthis.activeVisitor === undefined,\n\t\t\t0x76a /* Must release existing visitor before acquiring another */,\n\t\t);\n\n\t\tif (this.roots.isShared()) {\n\t\t\tthis.roots = this.roots.clone();\n\t\t}\n\n\t\tconst forestVisitor = {\n\t\t\tforest: this,\n\t\t\t// Current location in the tree, as a non-shared BasicChunk (TODO: support in-place modification of other chunk formats when possible).\n\t\t\t// Start above root detached sequences.\n\t\t\tmutableChunkStack: [] as StackNode[],\n\t\t\tmutableChunk: this.roots as BasicChunk | undefined,\n\t\t\tgetParent(): StackNode {\n\t\t\t\tassert(hasSome(this.mutableChunkStack), 0x532 /* invalid access to root's parent */);\n\t\t\t\treturn getLast(this.mutableChunkStack);\n\t\t\t},\n\t\t\tfree(): void {\n\t\t\t\tthis.mutableChunk = undefined;\n\t\t\t\tthis.mutableChunkStack.length = 0;\n\t\t\t\tassert(\n\t\t\t\t\tthis.forest.activeVisitor !== undefined,\n\t\t\t\t\t0x76b /* Multiple free calls for same visitor */,\n\t\t\t\t);\n\t\t\t\tthis.forest.activeVisitor = undefined;\n\t\t\t},\n\t\t\tdestroy(detachedField: FieldKey, count: number): void {\n\t\t\t\tthis.forest.#events.emit(\"beforeChange\");\n\t\t\t\tthis.forest.roots.fields.delete(detachedField);\n\t\t\t},\n\t\t\tcreate(content: ProtoNodes, destination: FieldKey): void {\n\t\t\t\tthis.forest.#events.emit(\"beforeChange\");\n\t\t\t\tconst chunks: TreeChunk[] = content.map((c) =>\n\t\t\t\t\tchunkTree(c, {\n\t\t\t\t\t\tpolicy: this.forest.chunker,\n\t\t\t\t\t\tidCompressor: this.forest.idCompressor,\n\t\t\t\t\t}),\n\t\t\t\t);\n\t\t\t\tthis.forest.roots.fields.set(destination, chunks);\n\t\t\t\tthis.forest.#events.emit(\"afterRootFieldCreated\", destination);\n\t\t\t},\n\t\t\tattach(source: FieldKey, count: number, destination: PlaceIndex): void {\n\t\t\t\tthis.attachEdit(source, count, destination);\n\t\t\t},\n\t\t\tdetach(source: Range, destination: FieldKey): void {\n\t\t\t\tthis.detachEdit(source, destination);\n\t\t\t},\n\t\t\t/**\n\t\t\t * Attaches the range into the current field by transferring it from the given source path.\n\t\t\t * Does not invalidate dependents.\n\t\t\t * @param source - The the range to be attached.\n\t\t\t * @param destination - The index in the current field at which to attach the content.\n\t\t\t */\n\t\t\tattachEdit(source: FieldKey, count: number, destination: PlaceIndex): void {\n\t\t\t\tthis.forest.#events.emit(\"beforeChange\");\n\t\t\t\tconst sourceField = this.forest.roots.fields.get(source) ?? [];\n\t\t\t\tthis.forest.roots.fields.delete(source);\n\t\t\t\tif (sourceField.length === 0) {\n\t\t\t\t\treturn; // Prevent creating 0 sized fields when inserting empty into empty.\n\t\t\t\t}\n\n\t\t\t\tconst parent = this.getParent();\n\t\t\t\tconst destinationField = getOrAddEmptyToMap(parent.mutableChunk.fields, parent.key);\n\t\t\t\t// TODO: this will fail for very large moves due to argument limits.\n\t\t\t\tdestinationField.splice(destination, 0, ...sourceField);\n\t\t\t},\n\t\t\t/**\n\t\t\t * Detaches the range from the current field and transfers it to the given destination if any.\n\t\t\t * Does not invalidate dependents.\n\t\t\t * @param source - The bounds of the range to be detached from the current field.\n\t\t\t * @param destination - If specified, the destination to transfer the detached range to.\n\t\t\t * If not specified, the detached range is destroyed.\n\t\t\t */\n\t\t\tdetachEdit(source: Range, destination: FieldKey | undefined): void {\n\t\t\t\tthis.forest.#events.emit(\"beforeChange\");\n\t\t\t\tconst parent = this.getParent();\n\t\t\t\tconst sourceField = parent.mutableChunk.fields.get(parent.key) ?? [];\n\n\t\t\t\tassertValidRange(source, sourceField);\n\t\t\t\tconst newField = sourceField.splice(source.start, source.end - source.start);\n\n\t\t\t\tif (destination !== undefined) {\n\t\t\t\t\tassert(\n\t\t\t\t\t\t!this.forest.roots.fields.has(destination),\n\t\t\t\t\t\t0x7af /* Destination must be a new empty detached field */,\n\t\t\t\t\t);\n\t\t\t\t\tif (newField.length > 0) {\n\t\t\t\t\t\tthis.forest.roots.fields.set(destination, newField);\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tfor (const child of newField) {\n\t\t\t\t\t\tchild.referenceRemoved();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t// This check is performed after the transfer to ensure that the field is not removed in scenarios\n\t\t\t\t// where the source and destination are the same.\n\t\t\t\tif (sourceField.length === 0) {\n\t\t\t\t\tparent.mutableChunk.fields.delete(parent.key);\n\t\t\t\t}\n\t\t\t},\n\t\t\treplace(\n\t\t\t\tnewContentSource: FieldKey,\n\t\t\t\trange: Range,\n\t\t\t\toldContentDestination: FieldKey,\n\t\t\t): void {\n\t\t\t\tassert(\n\t\t\t\t\tnewContentSource !== oldContentDestination,\n\t\t\t\t\t0x7b0 /* Replace detached source field and detached destination field must be different */,\n\t\t\t\t);\n\t\t\t\t// TODO: optimize this to: perform in-place replace in uniform chunks when possible.\n\t\t\t\t// This should result in 3 cases:\n\t\t\t\t// 1. In-place update of uniform chunk. No allocations, no ref count changes, no new TreeChunks.\n\t\t\t\t// 2. Uniform chunk is shared: copy it (and parent path as needed), and update the copy.\n\t\t\t\t// 3. Fallback to detach then attach (Which will copy parents and convert to basic chunks as needed).\n\t\t\t\tthis.detachEdit(range, oldContentDestination);\n\t\t\t\tthis.attachEdit(newContentSource, range.end - range.start, range.start);\n\t\t\t},\n\t\t\tenterNode(index: number): void {\n\t\t\t\tassert(this.mutableChunk === undefined, 0x535 /* should be in field */);\n\t\t\t\tconst parent = this.getParent();\n\t\t\t\tconst chunks =\n\t\t\t\t\tparent.mutableChunk.fields.get(parent.key) ?? fail(\"missing edited field\");\n\t\t\t\tlet indexWithinChunk = index;\n\t\t\t\tlet indexOfChunk = 0;\n\t\t\t\tlet chunk = chunks[indexOfChunk] ?? oob();\n\t\t\t\twhile (indexWithinChunk >= chunk.topLevelLength) {\n\t\t\t\t\tchunk = chunks[indexOfChunk] ?? oob();\n\t\t\t\t\tindexWithinChunk -= chunk.topLevelLength;\n\t\t\t\t\tindexOfChunk++;\n\t\t\t\t\tif (indexOfChunk === chunks.length) {\n\t\t\t\t\t\tfail(\"missing edited node\");\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tlet found = chunks[indexOfChunk] ?? oob();\n\t\t\t\tif (!(found instanceof BasicChunk)) {\n\t\t\t\t\t// TODO:Perf: support in place editing of other chunk formats when possible:\n\t\t\t\t\t// 1. Support updating values in uniform chunks.\n\t\t\t\t\t// 2. Support traversing sequence chunks.\n\t\t\t\t\t//\n\t\t\t\t\t// Maybe build path when visitor navigates then lazily sync to chunk tree when editing?\n\t\t\t\t\tconst newChunks = mapCursorField(found.cursor(), (cursor) =>\n\t\t\t\t\t\tbasicChunkTree(cursor, {\n\t\t\t\t\t\t\tpolicy: this.forest.chunker,\n\t\t\t\t\t\t\tidCompressor: this.forest.idCompressor,\n\t\t\t\t\t\t}),\n\t\t\t\t\t);\n\t\t\t\t\t// TODO: this could fail for really long chunks being split (due to argument count limits).\n\t\t\t\t\t// Current implementations of chunks shouldn't ever be that long, but it could be an issue if they get bigger.\n\t\t\t\t\tchunks.splice(indexOfChunk, 1, ...newChunks);\n\t\t\t\t\tfound.referenceRemoved();\n\n\t\t\t\t\tfound = newChunks[indexWithinChunk] ?? oob();\n\t\t\t\t}\n\t\t\t\tassert(found instanceof BasicChunk, 0x536 /* chunk should have been normalized */);\n\t\t\t\tif (found.isShared()) {\n\t\t\t\t\tthis.mutableChunk = chunks[indexOfChunk] = found.clone();\n\t\t\t\t\tfound.referenceRemoved();\n\t\t\t\t} else {\n\t\t\t\t\tthis.mutableChunk = found;\n\t\t\t\t}\n\t\t\t},\n\t\t\texitNode(index: number): void {\n\t\t\t\tassert(this.mutableChunk !== undefined, 0x537 /* should be in node */);\n\t\t\t\tthis.mutableChunk = undefined;\n\t\t\t},\n\t\t\tenterField(key: FieldKey): void {\n\t\t\t\tassert(this.mutableChunk !== undefined, 0x538 /* should be in node */);\n\t\t\t\tthis.mutableChunkStack.push({ key, mutableChunk: this.mutableChunk });\n\t\t\t\tthis.mutableChunk = undefined;\n\t\t\t},\n\t\t\texitField(key: FieldKey): void {\n\t\t\t\tconst top = this.mutableChunkStack.pop() ?? fail(\"should not be at root\");\n\t\t\t\tassert(this.mutableChunk === undefined, 0x539 /* should be in field */);\n\t\t\t\tthis.mutableChunk = top.mutableChunk;\n\t\t\t},\n\t\t};\n\n\t\tconst announcedVisitors: AnnouncedVisitor[] = [];\n\t\tthis.deltaVisitors.forEach((getVisitor) => announcedVisitors.push(getVisitor()));\n\t\tconst combinedVisitor = combineVisitors(\n\t\t\t[forestVisitor, ...announcedVisitors],\n\t\t\tannouncedVisitors,\n\t\t);\n\t\tthis.activeVisitor = combinedVisitor;\n\t\treturn combinedVisitor;\n\t}\n\n\tprivate nextDetachedFieldIdentifier = 0;\n\tpublic newDetachedField(): DetachedField {\n\t\tconst field: DetachedField = brand(String(this.nextDetachedFieldIdentifier));\n\t\tassert(\n\t\t\t!this.roots.fields.has(detachedFieldAsKey(field)),\n\t\t\t0x53a /* new field must not already exist */,\n\t\t);\n\t\tthis.nextDetachedFieldIdentifier += 1;\n\t\treturn field;\n\t}\n\n\tpublic allocateCursor(): Cursor {\n\t\treturn new Cursor(\n\t\t\tthis,\n\t\t\tITreeSubscriptionCursorState.Cleared,\n\t\t\t[],\n\t\t\t[],\n\t\t\t[],\n\t\t\t[],\n\t\t\t[],\n\t\t\t[],\n\t\t\t0,\n\t\t\t0,\n\t\t\t0,\n\t\t\tundefined,\n\t\t);\n\t}\n\n\tpublic tryMoveCursorToNode(\n\t\tdestination: Anchor,\n\t\tcursorToMove: ITreeSubscriptionCursor,\n\t): TreeNavigationResult {\n\t\tconst path = this.anchors.locate(destination);\n\t\tif (path === undefined) {\n\t\t\treturn TreeNavigationResult.NotFound;\n\t\t}\n\t\tthis.moveCursorToPath(path, cursorToMove);\n\t\treturn TreeNavigationResult.Ok;\n\t}\n\n\tpublic tryMoveCursorToField(\n\t\tdestination: FieldAnchor,\n\t\tcursorToMove: ITreeSubscriptionCursor,\n\t): TreeNavigationResult {\n\t\tassert(\n\t\t\tcursorToMove instanceof Cursor,\n\t\t\t0x53b /* ChunkedForest must only be given its own Cursor type */,\n\t\t);\n\t\tif (destination.parent === undefined) {\n\t\t\tcursorToMove.setToDetachedSequence(destination.fieldKey);\n\t\t\treturn TreeNavigationResult.Ok;\n\t\t}\n\t\tconst result = this.tryMoveCursorToNode(destination.parent, cursorToMove);\n\t\tif (result !== TreeNavigationResult.Ok) {\n\t\t\treturn result;\n\t\t}\n\n\t\tcursorToMove.enterField(destination.fieldKey);\n\t\treturn TreeNavigationResult.Ok;\n\t}\n\n\tpublic moveCursorToPath(destination: UpPath, cursorToMove: ITreeSubscriptionCursor): void {\n\t\tassert(\n\t\t\tcursorToMove instanceof Cursor,\n\t\t\t0x53c /* ChunkedForest must only be given its own Cursor type */,\n\t\t);\n\t\tassert(\n\t\t\tcursorToMove.forest === this,\n\t\t\t0x53d /* ChunkedForest must only be given its own Cursor */,\n\t\t);\n\n\t\tconst indexStack: number[] = [];\n\t\tconst keyStack: FieldKey[] = [];\n\n\t\tlet path: UpPath | undefined = destination;\n\t\twhile (path !== undefined) {\n\t\t\tindexStack.push(path.parentIndex);\n\t\t\tkeyStack.push(path.parentField);\n\t\t\tpath = path.parent;\n\t\t}\n\t\tcursorToMove.clear();\n\t\twhile (keyStack.length > 0) {\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\tconst key = keyStack.pop()!;\n\t\t\tif (cursorToMove.state === ITreeSubscriptionCursorState.Cleared) {\n\t\t\t\tcursorToMove.setToDetachedSequence(key);\n\t\t\t\tcursorToMove.state = ITreeSubscriptionCursorState.Current;\n\t\t\t} else {\n\t\t\t\tcursorToMove.enterField(key);\n\t\t\t}\n\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\tcursorToMove.enterNode(indexStack.pop()!);\n\t\t}\n\t}\n\n\tpublic getCursorAboveDetachedFields(): ITreeCursorSynchronous {\n\t\tconst rootCursor = this.roots.cursor();\n\t\trootCursor.enterNode(0);\n\t\treturn rootCursor;\n\t}\n}\n\nclass Cursor extends BasicChunkCursor implements ITreeSubscriptionCursor {\n\tpublic constructor(\n\t\tpublic readonly forest: ChunkedForest,\n\t\tpublic state: ITreeSubscriptionCursorState,\n\t\troot: readonly TreeChunk[],\n\t\tsiblingStack: SiblingsOrKey[],\n\t\tindexStack: number[],\n\t\tindexOfChunkStack: number[],\n\t\tindexWithinChunkStack: number[],\n\t\tsiblings: SiblingsOrKey,\n\t\tindex: number,\n\t\tindexOfChunk: number,\n\t\tindexWithinChunk: number,\n\t\tnestedCursor: ChunkedCursor | undefined,\n\t) {\n\t\tsuper(\n\t\t\troot,\n\t\t\tsiblingStack,\n\t\t\tindexStack,\n\t\t\tindexOfChunkStack,\n\t\t\tindexWithinChunkStack,\n\t\t\tsiblings,\n\t\t\tindex,\n\t\t\tindexOfChunk,\n\t\t\tindexWithinChunk,\n\t\t\tnestedCursor,\n\t\t);\n\t}\n\n\tpublic setToDetachedSequence(key: FieldKey): void {\n\t\tthis.root = (this.forest.roots.fields.get(key) ?? []) as BasicChunk[];\n\t\tthis.siblingStack.length = 0;\n\t\tthis.indexStack.length = 0;\n\t\tthis.indexOfChunkStack.length = 0;\n\t\tthis.indexWithinChunkStack.length = 0;\n\t\tthis.siblings = [key];\n\t\tthis.index = 0;\n\t\tthis.indexOfChunk = 0;\n\t\tthis.indexWithinChunk = 0;\n\t\tthis.nestedCursor = undefined;\n\t}\n\n\tpublic override fork(): Cursor {\n\t\t// Siblings arrays are not modified during navigation and do not need be be copied.\n\t\t// This allows this copy to be shallow, and `this.siblings` below to not be copied as all.\n\t\treturn new Cursor(\n\t\t\tthis.forest,\n\t\t\tthis.state,\n\t\t\tthis.root,\n\t\t\t[...this.siblingStack],\n\t\t\t[...this.indexStack],\n\t\t\t[...this.indexOfChunkStack],\n\t\t\t[...this.indexWithinChunkStack],\n\t\t\tthis.siblings,\n\t\t\tthis.index,\n\t\t\tthis.indexOfChunk,\n\t\t\tthis.indexWithinChunk,\n\t\t\tthis.nestedCursor?.fork(),\n\t\t);\n\t}\n\n\tpublic buildFieldAnchor(): FieldAnchor {\n\t\tconst path = this.getFieldPath();\n\t\tconst anchor =\n\t\t\tpath.parent === undefined ? undefined : this.forest.anchors.track(path.parent);\n\t\treturn { parent: anchor, fieldKey: path.field };\n\t}\n\n\tpublic free(): void {\n\t\tthis.state = ITreeSubscriptionCursorState.Freed;\n\t}\n\n\tpublic buildAnchor(): Anchor {\n\t\treturn this.forest.anchors.track(this.getPath());\n\t}\n\n\tpublic clear(): void {\n\t\tthis.state = ITreeSubscriptionCursorState.Cleared;\n\t\tthis.setToDetachedSequence(rootFieldKey);\n\t}\n}\n\n/**\n * @returns an implementation of {@link IEditableForest} with no data or schema.\n */\nexport function buildChunkedForest(\n\tchunker: IChunker,\n\tanchors?: AnchorSet,\n\tidCompressor?: IIdCompressor,\n): ChunkedForest {\n\treturn new ChunkedForest(makeRoot(), chunker.schema, chunker, anchors, idCompressor);\n}\n"]}
@@ -2,9 +2,8 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
- import type { TreeValue } from "../../../core/index.js";
5
+ import type { TreeValue, TreeChunk } from "../../../core/index.js";
6
6
  import { type FluidSerializableReadOnly } from "../../valueUtilities.js";
7
- import type { TreeChunk } from "../chunk.js";
8
7
  /**
9
8
  * Utilities related to chunk encoding and decoding that do not depend on specific chunk types or formats.
10
9
  */
@@ -1 +1 @@
1
- {"version":3,"file":"chunkCodecUtilities.d.ts","sourceRoot":"","sources":["../../../../src/feature-libraries/chunked-forest/codec/chunkCodecUtilities.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAExD,OAAO,EAAE,KAAK,yBAAyB,EAAsB,MAAM,yBAAyB,CAAC;AAC7F,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAE7C;;GAEG;AAEH;;;;GAIG;AACH,qBAAa,OAAO,CAAC,CAAC;IACrB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAA6B;IAC7C,GAAG,CAAC,CAAC,EAAE,CAAC,EAAE,KAAK,SAAI,GAAG,IAAI;IAKjC;;;;;OAKG;IACI,UAAU,CAAC,MAAM,GAAE,aAAa,CAAC,CAAC,CAAuB,GAAG,kBAAkB,CAAC,CAAC,CAAC;CAiBxF;AAED;;GAEG;AACH,MAAM,MAAM,aAAa,CAAC,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC;AAE/E;;;GAGG;AACH,MAAM,WAAW,kBAAkB,CAAC,CAAC;IACpC;;OAEG;IACH,QAAQ,CAAC,YAAY,EAAE,WAAW,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;IAC9C;;;;OAIG;IACH,QAAQ,CAAC,YAAY,EAAE,SAAS,CAAC,EAAE,CAAC;CACpC;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,oBAAoB,CAAC,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAWrF;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,CAAC,EAAE,IAAI,EAAE,SAAS,CAAC,EAAE,EAAE,KAAK,EAAE,MAAM,GAAG,CAAC,CAGlE;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IAC5B;;OAEG;IACH,QAAQ,CAAC,IAAI,EAAE,SAAS,yBAAyB,EAAE,CAAC;IACpD;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;CACf;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,MAAM,EAAE,YAAY,GAAG,yBAAyB,CAI1E;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,YAAY,GAAG,MAAM,CAI7D;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,YAAY,GAAG,OAAO,CAI/D;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,YAAY,GAAG,SAAS,CAI/D;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,YAAY,GAAG,YAAY,CAInE;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IAC5B;;;;;OAKG;IACH,MAAM,CAAC,QAAQ,EAAE,SAAS,YAAY,EAAE,EAAE,MAAM,EAAE,YAAY,GAAG,SAAS,CAAC;CAC3E"}
1
+ {"version":3,"file":"chunkCodecUtilities.d.ts","sourceRoot":"","sources":["../../../../src/feature-libraries/chunked-forest/codec/chunkCodecUtilities.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAEnE,OAAO,EAAE,KAAK,yBAAyB,EAAsB,MAAM,yBAAyB,CAAC;AAE7F;;GAEG;AAEH;;;;GAIG;AACH,qBAAa,OAAO,CAAC,CAAC;IACrB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAA6B;IAC7C,GAAG,CAAC,CAAC,EAAE,CAAC,E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IG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,YAAY,GAAG,YAAY,CAInE;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IAC5B;;;;;OAKG;IACH,MAAM,CAAC,QAAQ,EAAE,SAAS,YAAY,EAAE,EAAE,MAAM,EAAE,YAAY,GAAG,SAAS,CAAC;CAC3E"}
@@ -1 +1 @@
1
- {"version":3,"file":"chunkCodecUtilities.js","sourceRoot":"","sources":["../../../../src/feature-libraries/chunked-forest/codec/chunkCodecUtilities.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAAkE;AAGlE,qDAA0D;AAC1D,+DAA6F;AAG7F;;GAEG;AAEH;;;;GAIG;AACH,MAAa,OAAO;IAApB;QACkB,WAAM,GAAmB,IAAI,GAAG,EAAE,CAAC;IA6BrD,CAAC;IA5BO,GAAG,CAAC,CAAI,EAAE,KAAK,GAAG,CAAC;QACzB,MAAM,GAAG,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;QACpC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,EAAE,GAAG,GAAG,KAAK,CAAC,CAAC;IACjC,CAAC;IAED;;;;;OAKG;IACI,UAAU,CAAC,SAA2B,GAAY,EAAE,CAAC,IAAI;QAC/D,MAAM,IAAI,GAAQ,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC;QAC1C,qGAAqG;QACrG,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAC3E,qGAAqG;QACrG,MAAM,QAAQ,GAAQ,EAAE,CAAC;QACzB,KAAK,MAAM,CAAC,IAA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AAC,MAAoB;IAC9C,MAAM,OAAO,GAAG,UAAU,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;IACvD,MAAM,CAAC,MAAM,EAAE,CAAC;IAChB,OAAO,OAAO,CAAC;AAChB,CAAC;AAJD,gCAIC;AAED;;GAEG;AACH,SAAgB,gBAAgB,CAAC,MAAoB;IACpD,MAAM,OAAO,GAAG,UAAU,CAAC,MAAM,CAAC,CAAC;IACnC,IAAA,iBAAM,EAAC,OAAO,OAAO,KAAK,QAAQ,EAAE,KAAK,CAAC,+BAA+B,CAAC,CAAC;IAC3E,OAAO,OAAO,CAAC;AAChB,CAAC;AAJD,4CAIC;AAED;;GAEG;AACH,SAAgB,iBAAiB,CAAC,MAAoB;IACrD,MAAM,OAAO,GAAG,UAAU,CAAC,MAAM,CAAC,CAAC;IACnC,IAAA,iBAAM,EAAC,OAAO,OAAO,KAAK,SAAS,EAAE,KAAK,CAAC,gCAAgC,CAAC,CAAC;IAC7E,OAAO,OAAO,CAAC;AAChB,CAAC;AAJD,8CAIC;AAED;;GAEG;AACH,SAAgB,eAAe,CAAC,MAAoB;IACnD,MAAM,OAAO,GAAG,UAAU,CAAC,MAAM,CAAC,CAAC;IACnC,IAAA,sCAAkB,EAAC,OAAO,CAAC,CAAC;IAC5B,OAAO,OAAO,CAAC;AAChB,CAAC;AAJD,0CAIC;AAED;;;;GAIG;AACH,SAAgB,gBAAgB,CAAC,MAAoB;IACpD,MAAM,OAAO,GAAG,UAAU,CAAC,MAAM,CAAC,CAAC;IACnC,IAAA,iBAAM,EAAC,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,KAAK,CAAC,8BAA8B,CAAC,CAAC;IACrE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC;AACrC,CAAC;AAJD,4CAIC","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 type { TreeValue } from \"../../../core/index.js\";\nimport { assertValidIndex } from \"../../../util/index.js\";\nimport { type FluidSerializableReadOnly, assertAllowedValue } from \"../../valueUtilities.js\";\nimport type { TreeChunk } from \"../chunk.js\";\n\n/**\n * Utilities related to chunk encoding and decoding that do not depend on specific chunk types or formats.\n */\n\n/**\n * Counts usages of some `T`, then generates tables for replacing those `T` values with small numbers.\n *\n * Can be used to deduplicate objects when encoding via {@link https://go-compression.github.io/algorithms/dictionary/ | Dictionary Coding}.\n */\nexport class Counter<T> {\n\tprivate readonly counts: Map<T, number> = new Map();\n\tpublic add(t: T, count = 1): void {\n\t\tconst old = this.counts.get(t) ?? 0;\n\t\tthis.counts.set(t, old + count);\n\t}\n\n\t/**\n\t * Generate a table which can be used to deduplicate the items added via `add`.\n\t * Table is sorted from most used to least used so that more commonly added items will get smaller indexes.\n\t *\n\t * @param filter - determines which items should be included in the table.\n\t */\n\tpublic buildTable(filter: CounterFilter<T> = (): boolean => true): DeduplicationTable<T> {\n\t\tconst data: T[] = [...this.counts.keys()];\n\t\t// Sort in descending order by count, giving priority (smaller indexes) to more commonly used values.\n\t\tdata.sort((a, b) => (this.counts.get(b) ?? 0) - (this.counts.get(a) ?? 0));\n\t\t// Since the index needed is the output index not the input one, data.filter doesn't quite work here.\n\t\tconst filtered: T[] = [];\n\t\tfor (const t of data) {\n\t\t\tconst include = filter(t, filtered.length, this.counts.get(t) ?? 0);\n\t\t\tif (include) {\n\t\t\t\tfiltered.push(t);\n\t\t\t}\n\t\t}\n\t\treturn {\n\t\t\tindexToValue: filtered,\n\t\t\tvalueToIndex: new Map(filtered.map((t, index) => [t, index])),\n\t\t};\n\t}\n}\n\n/**\n * Returns true iff a given item `t` (of which there are `count` usages) is worth substituting with the number `value`.\n */\nexport type CounterFilter<T> = (t: T, value: number, count: number) => boolean;\n\n/**\n * Table for dictionary compression.\n * See {@link Counter}.\n */\nexport interface DeduplicationTable<T> {\n\t/**\n\t * Lookup table derived from indexToValue,\n\t */\n\treadonly valueToIndex: ReadonlyMap<T, number>;\n\t/**\n\t * Deduplication table: lookup values by their index.\n\t *\n\t * This is the portion of the table that should be included in persisted data.\n\t */\n\treadonly indexToValue: readonly T[];\n}\n\n/**\n * Filter for use with Counter.buildTable that minimizes the size of the produced JSON.\n *\n * @remarks\n * This minimizes the number of UTF-16 code units in the produced JSON.\n * This is not ideal: minimizing UTF-8 bytes would be better.\n * For ascii text these are the same, and in worst cases they correlate pretty well (accurate to within a small constant factor).\n * This is thus good enough for a heuristic.\n *\n * Also the use of this filter doesn't take into account the length cost of keeping a value in the table possibly\n * making some of the entries at higher indexes in the table get a larger number.\n * For example, if keeping an entry at index 9 saves one character this will keep it,\n * even if that means the next entry (at index 10) loses more than one character due to 10 being two digits instead of the one digit it would have been at index 9.\n * This means that this filter is not guaranteed to be optimal, but it should always be quite close.\n */\nexport function jsonMinimizingFilter(s: string, value: number, count: number): boolean {\n\t// The most practical way to compute how long s will be with quoting and escaping\n\t// is to actually quote and escape it with JSON.stringify:\n\tconst quotedAndEscaped = JSON.stringify(s);\n\t// Account for count instances of value, and one instance of a `,s` which would go in the table.\n\tconst lengthUsingTable = String(value).length * count + quotedAndEscaped.length + 1;\n\t// Account for count instances of s.\n\tconst lengthWithoutTable = quotedAndEscaped.length * count;\n\t// Break ties to not use the table to avoid needing a lookup,\n\t// and save table entries for other uses.\n\treturn lengthUsingTable < lengthWithoutTable;\n}\n\n/**\n * Read from an array, but error if index is not valid.\n */\nexport function getChecked<T>(data: readonly T[], index: number): T {\n\tassertValidIndex(index, data);\n\treturn data[index] ?? oob();\n}\n\n/**\n * A readable stream.\n */\nexport interface StreamCursor {\n\t/**\n\t * The data to read.\n\t */\n\treadonly data: readonly FluidSerializableReadOnly[];\n\t/**\n\t * Location in the data.\n\t */\n\toffset: number;\n}\n\n/**\n * Read one item from the stream, advancing the stream offset.\n */\nexport function readStream(stream: StreamCursor): FluidSerializableReadOnly {\n\tconst content = getChecked(stream.data, stream.offset);\n\tstream.offset++;\n\treturn content;\n}\n\n/**\n * Read one number from the stream, advancing the stream offset.\n */\nexport function readStreamNumber(stream: StreamCursor): number {\n\tconst content = readStream(stream);\n\tassert(typeof content === \"number\", 0x730 /* expected number in stream */);\n\treturn content;\n}\n\n/**\n * Read one boolean from the stream, advancing the stream offset.\n */\nexport function readStreamBoolean(stream: StreamCursor): boolean {\n\tconst content = readStream(stream);\n\tassert(typeof content === \"boolean\", 0x731 /* expected boolean in stream */);\n\treturn content;\n}\n\n/**\n * Read one TreeValue from the stream, advancing the stream offset.\n */\nexport function readStreamValue(stream: StreamCursor): TreeValue {\n\tconst content = readStream(stream);\n\tassertAllowedValue(content);\n\treturn content;\n}\n\n/**\n * Read one nested array from the stream, advancing the stream offset.\n *\n * @returns the nested array as a stream.\n */\nexport function readStreamStream(stream: StreamCursor): StreamCursor {\n\tconst content = readStream(stream);\n\tassert(Array.isArray(content), 0x732 /* expected Array in stream */);\n\treturn { data: content, offset: 0 };\n}\n\n/**\n * Decodes a chunk within a FieldBatch.\n */\nexport interface ChunkDecoder {\n\t/**\n\t * Read from stream, updating the offset.\n\t *\n\t * @returns a TreeChunk made from the data from `stream`.\n\t * This chunk is allowed to reference/take ownership of content it reads from the stream.\n\t */\n\tdecode(decoders: readonly ChunkDecoder[], stream: StreamCursor): TreeChunk;\n}\n"]}
1
+ {"version":3,"file":"chunkCodecUtilities.js","sourceRoot":"","sources":["../../../../src/feature-libraries/chunked-forest/codec/chunkCodecUtilities.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAAkE;AAGlE,qDAA0D;AAC1D,+DAA6F;AAE7F;;GAEG;AAEH;;;;GAIG;AACH,MAAa,OAAO;IAApB;QACkB,WAAM,GAAmB,IAAI,GAAG,EAAE,CAAC;IA6BrD,CAAC;IA5BO,GAAG,CAAC,CAAI,EAAE,KAAK,GAAG,CAAC;QACzB,MAAM,GAAG,GAAG,IAAI,CAAC,MAAM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CAAC,CAAC;IAC7E,OAAO,OAAO,CAAC;AAChB,CAAC;AAJD,8CAIC;AAED;;GAEG;AACH,SAAgB,eAAe,CAAC,MAAoB;IACnD,MAAM,OAAO,GAAG,UAAU,CAAC,MAAM,CAAC,CAAC;IACnC,IAAA,sCAAkB,EAAC,OAAO,CAAC,CAAC;IAC5B,OAAO,OAAO,CAAC;AAChB,CAAC;AAJD,0CAIC;AAED;;;;GAIG;AACH,SAAgB,gBAAgB,CAAC,MAAoB;IACpD,MAAM,OAAO,GAAG,UAAU,CAAC,MAAM,CAAC,CAAC;IACnC,IAAA,iBAAM,EAAC,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,KAAK,CAAC,8BAA8B,CAAC,CAAC;IACrE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC;AACrC,CAAC;AAJD,4CAIC","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 type { TreeValue, TreeChunk } from \"../../../core/index.js\";\nimport { assertValidIndex } from \"../../../util/index.js\";\nimport { type FluidSerializableReadOnly, assertAllowedValue } from \"../../valueUtilities.js\";\n\n/**\n * Utilities related to chunk encoding and decoding that do not depend on specific chunk types or formats.\n */\n\n/**\n * Counts usages of some `T`, then generates tables for replacing those `T` values with small numbers.\n *\n * Can be used to deduplicate objects when encoding via {@link https://go-compression.github.io/algorithms/dictionary/ | Dictionary Coding}.\n */\nexport class Counter<T> {\n\tprivate readonly counts: Map<T, number> = new Map();\n\tpublic add(t: T, count = 1): void {\n\t\tconst old = this.counts.get(t) ?? 0;\n\t\tthis.counts.set(t, old + count);\n\t}\n\n\t/**\n\t * Generate a table which can be used to deduplicate the items added via `add`.\n\t * Table is sorted from most used to least used so that more commonly added items will get smaller indexes.\n\t *\n\t * @param filter - determines which items should be included in the table.\n\t */\n\tpublic buildTable(filter: CounterFilter<T> = (): boolean => true): DeduplicationTable<T> {\n\t\tconst data: T[] = [...this.counts.keys()];\n\t\t// Sort in descending order by count, giving priority (smaller indexes) to more commonly used values.\n\t\tdata.sort((a, b) => (this.counts.get(b) ?? 0) - (this.counts.get(a) ?? 0));\n\t\t// Since the index needed is the output index not the input one, data.filter doesn't quite work here.\n\t\tconst filtered: T[] = [];\n\t\tfor (const t of data) {\n\t\t\tconst include = filter(t, filtered.length, this.counts.get(t) ?? 0);\n\t\t\tif (include) {\n\t\t\t\tfiltered.push(t);\n\t\t\t}\n\t\t}\n\t\treturn {\n\t\t\tindexToValue: filtered,\n\t\t\tvalueToIndex: new Map(filtered.map((t, index) => [t, index])),\n\t\t};\n\t}\n}\n\n/**\n * Returns true iff a given item `t` (of which there are `count` usages) is worth substituting with the number `value`.\n */\nexport type CounterFilter<T> = (t: T, value: number, count: number) => boolean;\n\n/**\n * Table for dictionary compression.\n * See {@link Counter}.\n */\nexport interface DeduplicationTable<T> {\n\t/**\n\t * Lookup table derived from indexToValue,\n\t */\n\treadonly valueToIndex: ReadonlyMap<T, number>;\n\t/**\n\t * Deduplication table: lookup values by their index.\n\t *\n\t * This is the portion of the table that should be included in persisted data.\n\t */\n\treadonly indexToValue: readonly T[];\n}\n\n/**\n * Filter for use with Counter.buildTable that minimizes the size of the produced JSON.\n *\n * @remarks\n * This minimizes the number of UTF-16 code units in the produced JSON.\n * This is not ideal: minimizing UTF-8 bytes would be better.\n * For ascii text these are the same, and in worst cases they correlate pretty well (accurate to within a small constant factor).\n * This is thus good enough for a heuristic.\n *\n * Also the use of this filter doesn't take into account the length cost of keeping a value in the table possibly\n * making some of the entries at higher indexes in the table get a larger number.\n * For example, if keeping an entry at index 9 saves one character this will keep it,\n * even if that means the next entry (at index 10) loses more than one character due to 10 being two digits instead of the one digit it would have been at index 9.\n * This means that this filter is not guaranteed to be optimal, but it should always be quite close.\n */\nexport function jsonMinimizingFilter(s: string, value: number, count: number): boolean {\n\t// The most practical way to compute how long s will be with quoting and escaping\n\t// is to actually quote and escape it with JSON.stringify:\n\tconst quotedAndEscaped = JSON.stringify(s);\n\t// Account for count instances of value, and one instance of a `,s` which would go in the table.\n\tconst lengthUsingTable = String(value).length * count + quotedAndEscaped.length + 1;\n\t// Account for count instances of s.\n\tconst lengthWithoutTable = quotedAndEscaped.length * count;\n\t// Break ties to not use the table to avoid needing a lookup,\n\t// and save table entries for other uses.\n\treturn lengthUsingTable < lengthWithoutTable;\n}\n\n/**\n * Read from an array, but error if index is not valid.\n */\nexport function getChecked<T>(data: readonly T[], index: number): T {\n\tassertValidIndex(index, data);\n\treturn data[index] ?? oob();\n}\n\n/**\n * A readable stream.\n */\nexport interface StreamCursor {\n\t/**\n\t * The data to read.\n\t */\n\treadonly data: readonly FluidSerializableReadOnly[];\n\t/**\n\t * Location in the data.\n\t */\n\toffset: number;\n}\n\n/**\n * Read one item from the stream, advancing the stream offset.\n */\nexport function readStream(stream: StreamCursor): FluidSerializableReadOnly {\n\tconst content = getChecked(stream.data, stream.offset);\n\tstream.offset++;\n\treturn content;\n}\n\n/**\n * Read one number from the stream, advancing the stream offset.\n */\nexport function readStreamNumber(stream: StreamCursor): number {\n\tconst content = readStream(stream);\n\tassert(typeof content === \"number\", 0x730 /* expected number in stream */);\n\treturn content;\n}\n\n/**\n * Read one boolean from the stream, advancing the stream offset.\n */\nexport function readStreamBoolean(stream: StreamCursor): boolean {\n\tconst content = readStream(stream);\n\tassert(typeof content === \"boolean\", 0x731 /* expected boolean in stream */);\n\treturn content;\n}\n\n/**\n * Read one TreeValue from the stream, advancing the stream offset.\n */\nexport function readStreamValue(stream: StreamCursor): TreeValue {\n\tconst content = readStream(stream);\n\tassertAllowedValue(content);\n\treturn content;\n}\n\n/**\n * Read one nested array from the stream, advancing the stream offset.\n *\n * @returns the nested array as a stream.\n */\nexport function readStreamStream(stream: StreamCursor): StreamCursor {\n\tconst content = readStream(stream);\n\tassert(Array.isArray(content), 0x732 /* expected Array in stream */);\n\treturn { data: content, offset: 0 };\n}\n\n/**\n * Decodes a chunk within a FieldBatch.\n */\nexport interface ChunkDecoder {\n\t/**\n\t * Read from stream, updating the offset.\n\t *\n\t * @returns a TreeChunk made from the data from `stream`.\n\t * This chunk is allowed to reference/take ownership of content it reads from the stream.\n\t */\n\tdecode(decoders: readonly ChunkDecoder[], stream: StreamCursor): TreeChunk;\n}\n"]}
@@ -2,8 +2,7 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
- import type { Value } from "../../../core/index.js";
6
- import type { TreeChunk } from "../chunk.js";
5
+ import type { Value, TreeChunk } from "../../../core/index.js";
7
6
  import { type ChunkDecoder, type StreamCursor } from "./chunkCodecUtilities.js";
8
7
  import { DecoderContext } from "./chunkDecodingGeneric.js";
9
8
  import { type EncodedChunkShape, type EncodedFieldBatch, type EncodedInlineArray, type EncodedNestedArray, type EncodedTreeShape, type EncodedValueShape } from "./format.js";
@@ -1 +1 @@
1
- {"version":3,"file":"chunkDecoding.d.ts","sourceRoot":"","sources":["../../../../src/feature-libraries/chunked-forest/codec/chunkDecoding.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,KAAK,EAAsC,KAAK,EAAE,MAAM,wBAAwB,CAAC;AAGxF,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAI7C,OAAO,EACN,KAAK,YAAY,EACjB,KAAK,YAAY,EAOjB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACN,cAAc,EAGd,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAEN,KAAK,iBAAiB,EACtB,KAAK,iBAAiB,EACtB,KAAK,kBAAkB,EACvB,KAAK,kBAAkB,EACvB,KAAK,gBAAgB,EACrB,KAAK,iBAAiB,EAEtB,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EACX,aAAa,EAEb,SAAS,EACT,MAAM,+BAA+B,CAAC;AAEvC,MAAM,WAAW,iBAAiB;IACjC,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,EAAE,gBAAgB,EACvB,KAAK,EAAE,cAAc,CAAC,iBAAiB,CAAC;IAWnD,MAAM,CAAC,QAAQ,EAAE,SAAS,YAAY,EAAE,EAAE,MAAM,EAAE,YAAY,GAAG,SAAS;CAmCjF"}
1
+ {"version":3,"file":"chunkDecoding.d.ts","sourceRoot":"","sources":["../../../../src/feature-libraries/chunked-forest/codec/chunkDecoding.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,KAAK,EAGX,KAAK,EACL,SAAS,EACT,MAAM,wBAAwB,CAAC;AAMhC,OAAO,EACN,KAAK,YAAY,EACjB,KAAK,YAAY,EAOjB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACN,cAAc,EAGd,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAEN,KAAK,iBAAiB,EACtB,KAAK,iBAAiB,EACtB,KAAK,kBAAkB,EACvB,KAAK,kBAAkB,EACvB,KAAK,gBAAgB,EACrB,KAAK,iBAAiB,EAEtB,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EACX,aAAa,EAEb,SAAS,EACT,MAAM,+BAA+B,CAAC;AAEvC,MAAM,WAAW,iBAAiB;IACjC,YAAY,EAAE,aAAa,CAAC;IAC5B;;OAEG;IACH,YAAY,EAAE,SAAS,CAAC;CACxB;AACD;;GAEG;AACH,wBAAgB,MAAM,CACrB,KAAK,EAAE,iBAAiB,EACxB,iBAAiB,EAAE;IAAE,YAAY,EAAE,aAAa,CAAC;IAAC,YAAY,EAAE,SAAS,CAAA;CAAE,GACzE,SAAS,EAAE,CAOb;AAqBD;;GAEG;AACH,wBAAgB,SAAS,CACxB,MAAM,EAAE,YAAY,EACpB,KAAK,EAAE,iBAAiB,EACxB,iBAAiB,EAAE,iBAAiB,GAClC,KAAK,CAgCP;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,SAAS,GAAG,SAAS,EAAE,CAyB/D;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,KAAK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CAAC,MAAM,EAAE,CAAC;gBAC3C,MAAM,GAAG,GAAa,IAAA,8CAAoB,EAAC,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC;gBAC9D,QAAQ,CAAC,GAAG,EAAE,OAAO,CAAC,MAAM,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC,CAAC;YAChD,CAAC;QACF,CAAC;QAED,OAAO,IAAI,0BAAU,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC;IAC5C,CAAC;CACD;AAnDD,kCAmDC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, unreachableCase, oob } from \"@fluidframework/core-utils/internal\";\n\nimport { DiscriminatedUnionDispatcher } from \"../../../codec/index.js\";\nimport type { FieldKey, TreeNodeSchemaIdentifier, Value } from \"../../../core/index.js\";\nimport { assertValidIndex } from \"../../../util/index.js\";\nimport { BasicChunk } from \"../basicChunk.js\";\nimport type { TreeChunk } from \"../chunk.js\";\nimport { emptyChunk } from \"../emptyChunk.js\";\nimport { SequenceChunk } from \"../sequenceChunk.js\";\n\nimport {\n\ttype ChunkDecoder,\n\ttype StreamCursor,\n\tgetChecked,\n\treadStream,\n\treadStreamBoolean,\n\treadStreamNumber,\n\treadStreamStream,\n\treadStreamValue,\n} from \"./chunkCodecUtilities.js\";\nimport {\n\tDecoderContext,\n\tdecode as genericDecode,\n\treadStreamIdentifier,\n} from \"./chunkDecodingGeneric.js\";\nimport {\n\ttype EncodedAnyShape,\n\ttype EncodedChunkShape,\n\ttype EncodedFieldBatch,\n\ttype EncodedInlineArray,\n\ttype EncodedNestedArray,\n\ttype EncodedTreeShape,\n\ttype EncodedValueShape,\n\tSpecialField,\n} from \"./format.js\";\nimport type {\n\tIIdCompressor,\n\tOpSpaceCompressedId,\n\tSessionId,\n} from \"@fluidframework/id-compressor\";\n\nexport interface IdDecodingContext {\n\tidCompressor: IIdCompressor;\n\t/**\n\t * The creator of any local Ids to be decoded.\n\t */\n\toriginatorId: SessionId;\n}\n/**\n * Decode `chunk` into a TreeChunk.\n */\nexport function decode(\n\tchunk: EncodedFieldBatch,\n\tidDecodingContext: { idCompressor: IIdCompressor; originatorId: SessionId },\n): TreeChunk[] {\n\treturn genericDecode(\n\t\tdecoderLibrary,\n\t\tnew DecoderContext(chunk.identifiers, chunk.shapes, idDecodingContext),\n\t\tchunk,\n\t\tanyDecoder,\n\t);\n}\n\nconst decoderLibrary = new DiscriminatedUnionDispatcher<\n\tEncodedChunkShape,\n\t[cache: DecoderContext<EncodedChunkShape>],\n\tChunkDecoder\n>({\n\ta(shape: EncodedNestedArray, cache): ChunkDecoder {\n\t\treturn new NestedArrayDecoder(shape);\n\t},\n\tb(shape: EncodedInlineArray, cache): ChunkDecoder {\n\t\treturn new InlineArrayDecoder(shape);\n\t},\n\tc(shape: EncodedTreeShape, cache): ChunkDecoder {\n\t\treturn new TreeDecoder(shape, cache);\n\t},\n\td(shape: EncodedAnyShape): ChunkDecoder {\n\t\treturn anyDecoder;\n\t},\n});\n\n/**\n * Decode a node's value from `stream` using its shape.\n */\nexport function readValue(\n\tstream: StreamCursor,\n\tshape: EncodedValueShape,\n\tidDecodingContext: IdDecodingContext,\n): Value {\n\tif (shape === undefined) {\n\t\treturn readStreamBoolean(stream) ? readStreamValue(stream) : undefined;\n\t} else {\n\t\tif (shape === true) {\n\t\t\treturn readStreamValue(stream);\n\t\t} else if (shape === false) {\n\t\t\treturn undefined;\n\t\t} else if (Array.isArray(shape)) {\n\t\t\tassert(shape.length === 1, 0x734 /* expected a single constant for value */);\n\t\t\treturn shape[0] as Value;\n\t\t} else if (shape === SpecialField.Identifier) {\n\t\t\t// This case is a special case handling the decoding of identifier fields.\n\t\t\tconst streamValue = readStream(stream);\n\t\t\tassert(\n\t\t\t\ttypeof streamValue === \"number\" || typeof streamValue === \"string\",\n\t\t\t\t0x997 /* identifier must be string or number. */,\n\t\t\t);\n\t\t\tconst idCompressor = idDecodingContext.idCompressor;\n\t\t\treturn typeof streamValue === \"number\"\n\t\t\t\t? idCompressor.decompress(\n\t\t\t\t\t\tidCompressor.normalizeToSessionSpace(\n\t\t\t\t\t\t\tstreamValue as OpSpaceCompressedId,\n\t\t\t\t\t\t\tidDecodingContext.originatorId,\n\t\t\t\t\t\t),\n\t\t\t\t\t)\n\t\t\t\t: streamValue;\n\t\t} else {\n\t\t\t// EncodedCounter case:\n\t\t\tunreachableCase(shape, \"decoding values as deltas is not yet supported\");\n\t\t}\n\t}\n}\n\n/**\n * Normalize a {@link TreeChunk} into an array.\n *\n * Unwraps {@link SequenceChunk}s, and wraps other chunks.\n */\nexport function deaggregateChunks(chunk: TreeChunk): TreeChunk[] {\n\tif (chunk === emptyChunk) {\n\t\treturn [];\n\t}\n\t// TODO: when handling of SequenceChunks has better performance (for example in cursors),\n\t// consider keeping SequenceChunks here if they are longer than some threshold.\n\tif (chunk instanceof SequenceChunk) {\n\t\t// Could return [] here, however the logic in this file is designed to never produce an empty SequenceChunk, so its better to throw an error here to detect bugs.\n\t\tassert(chunk.subChunks.length > 0, 0x735 /* Unexpected empty sequence */);\n\t\t// Logic in this file is designed to never produce an unneeded (single item) SequenceChunks, so its better to throw an error here to detect bugs.\n\t\tassert(chunk.subChunks.length > 1, 0x736 /* Unexpected single item sequence */);\n\n\t\tfor (const sub of chunk.subChunks) {\n\t\t\t// The logic in this file is designed to never produce an nested SequenceChunks or emptyChunk, so its better to throw an error here to detect bugs.\n\t\t\tassert(!(sub instanceof SequenceChunk), 0x737 /* unexpected nested sequence */);\n\t\t\tassert(sub !== emptyChunk, 0x738 /* unexpected empty chunk */);\n\n\t\t\tsub.referenceAdded();\n\t\t}\n\n\t\tchunk.referenceRemoved();\n\t\treturn chunk.subChunks;\n\t} else {\n\t\treturn [chunk];\n\t}\n}\n\n/**\n * Normalize a {@link TreeChunk}[] into a single TreeChunk.\n *\n * Avoids creating nested or less than 2 child {@link SequenceChunk}s.\n */\nexport function aggregateChunks(input: TreeChunk[]): TreeChunk {\n\tconst chunks = input.flatMap(deaggregateChunks);\n\tswitch (chunks.length) {\n\t\tcase 0:\n\t\t\treturn emptyChunk;\n\t\tcase 1:\n\t\t\treturn chunks[0] ?? oob();\n\t\tdefault:\n\t\t\treturn new SequenceChunk(chunks);\n\t}\n}\n\n/**\n * Decoder for {@link EncodedNestedArray}s.\n */\nexport class NestedArrayDecoder implements ChunkDecoder {\n\tpublic constructor(private readonly shape: EncodedNestedArray) {}\n\tpublic decode(decoders: readonly ChunkDecoder[], stream: StreamCursor): TreeChunk {\n\t\tconst decoder = decoders[this.shape] ?? oob();\n\n\t\t// TODO: uniform chunk fast path\n\t\tconst chunks: TreeChunk[] = [];\n\n\t\tconst data = readStream(stream);\n\t\tif (typeof data === \"number\") {\n\t\t\t// This case means that the array contained only 0-sized items, and was thus encoded as the length of the array.\n\t\t\tconst inner = { data: [], offset: 0 };\n\t\t\tfor (let index = 0; index < data; index++) {\n\t\t\t\tchunks.push(decoder.decode(decoders, inner));\n\t\t\t}\n\t\t} else {\n\t\t\tassert(\n\t\t\t\tArray.isArray(data),\n\t\t\t\t0x739 /* expected number of array for encoding of nested array */,\n\t\t\t);\n\t\t\tconst inner = { data, offset: 0 };\n\t\t\twhile (inner.offset !== inner.data.length) {\n\t\t\t\tchunks.push(decoder.decode(decoders, inner));\n\t\t\t}\n\t\t}\n\n\t\treturn aggregateChunks(chunks);\n\t}\n}\n\n/**\n * Decoder for {@link EncodedInlineArray}s.\n */\nexport class InlineArrayDecoder implements ChunkDecoder {\n\tpublic constructor(private readonly shape: EncodedInlineArray) {}\n\tpublic decode(decoders: readonly ChunkDecoder[], stream: StreamCursor): TreeChunk {\n\t\tconst length = this.shape.length;\n\t\tconst decoder = decoders[this.shape.shape] ?? oob();\n\t\tconst chunks: TreeChunk[] = [];\n\t\tfor (let index = 0; index < length; index++) {\n\t\t\tchunks.push(decoder.decode(decoders, stream));\n\t\t}\n\t\treturn aggregateChunks(chunks);\n\t}\n}\n\n/**\n * Decoder for {@link EncodedAnyShape}s.\n */\nexport const anyDecoder: ChunkDecoder = {\n\tdecode(decoders: readonly ChunkDecoder[], stream: StreamCursor): TreeChunk {\n\t\tconst shapeIndex = readStreamNumber(stream);\n\t\tconst decoder = getChecked(decoders, shapeIndex);\n\t\treturn decoder.decode(decoders, stream);\n\t},\n};\n\n/**\n * Decoder for field.\n */\ntype BasicFieldDecoder = (\n\tdecoders: readonly ChunkDecoder[],\n\tstream: StreamCursor,\n) => [FieldKey, TreeChunk];\n\n/**\n * Get a decoder for fields of a provided (via `shape` and `cache`) {@link EncodedChunkShape}.\n */\nfunction fieldDecoder(\n\tcache: DecoderContext<EncodedChunkShape>,\n\tkey: FieldKey,\n\tshape: number,\n): BasicFieldDecoder {\n\tassertValidIndex(shape, cache.shapes);\n\treturn (decoders, stream) => {\n\t\tconst decoder = decoders[shape] ?? oob();\n\t\treturn [key, decoder.decode(decoders, stream)];\n\t};\n}\n\n/**\n * Decoder for {@link EncodedTreeShape}s.\n */\nexport class TreeDecoder implements ChunkDecoder {\n\tprivate readonly type?: TreeNodeSchemaIdentifier;\n\tprivate readonly fieldDecoders: readonly BasicFieldDecoder[];\n\tpublic constructor(\n\t\tprivate readonly shape: EncodedTreeShape,\n\t\tprivate readonly cache: DecoderContext<EncodedChunkShape>,\n\t) {\n\t\tthis.type = shape.type === undefined ? undefined : cache.identifier(shape.type);\n\n\t\tconst fieldDecoders: BasicFieldDecoder[] = [];\n\t\tfor (const [fieldKey, fieldShape] of shape.fields ?? []) {\n\t\t\tconst key: FieldKey = cache.identifier(fieldKey);\n\t\t\tfieldDecoders.push(fieldDecoder(cache, key, fieldShape));\n\t\t}\n\t\tthis.fieldDecoders = fieldDecoders;\n\t}\n\tpublic decode(decoders: readonly ChunkDecoder[], stream: StreamCursor): TreeChunk {\n\t\tconst type: TreeNodeSchemaIdentifier =\n\t\t\tthis.type ?? readStreamIdentifier(stream, this.cache);\n\t\t// TODO: Consider typechecking against stored schema in here somewhere.\n\n\t\tconst value = readValue(stream, this.shape.value, this.cache.idDecodingContext);\n\t\tconst fields: Map<FieldKey, TreeChunk[]> = new Map();\n\n\t\t// Helper to add fields, but with unneeded array chunks removed.\n\t\tfunction addField(key: FieldKey, data: TreeChunk): void {\n\t\t\t// TODO: when handling of ArrayChunks has better performance (for example in cursors),\n\t\t\t// consider keeping array chunks here if they are longer than some threshold.\n\t\t\tconst chunks = deaggregateChunks(data);\n\n\t\t\tif (chunks.length !== 0) {\n\t\t\t\tfields.set(key, chunks);\n\t\t\t}\n\t\t}\n\n\t\tfor (const field of this.fieldDecoders) {\n\t\t\tconst [key, content] = field(decoders, stream);\n\t\t\taddField(key, content);\n\t\t}\n\n\t\tif (this.shape.extraFields !== undefined) {\n\t\t\tconst decoder = decoders[this.shape.extraFields] ?? oob();\n\t\t\tconst inner = readStreamStream(stream);\n\t\t\twhile (inner.offset !== inner.data.length) {\n\t\t\t\tconst key: FieldKey = readStreamIdentifier(inner, this.cache);\n\t\t\t\taddField(key, decoder.decode(decoders, inner));\n\t\t\t}\n\t\t}\n\n\t\treturn new BasicChunk(type, fields, value);\n\t}\n}\n"]}
1
+ {"version":3,"file":"chunkDecoding.js","sourceRoot":"","sources":["../../../../src/feature-libraries/chunked-forest/codec/chunkDecoding.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAAmF;AAEnF,sDAAuE;AAOvE,qDAA0D;AAC1D,oDAA8C;AAC9C,oDAA8C;AAC9C,0DAAoD;AAEpD,qEASkC;AAClC,uEAImC;AACnC,2CASqB;AAcrB;;GAEG;AACH,SAAgB,MAAM,CACrB,KAAwB,EACxB,iBAA2E;IAE3E,OAAO,IAAA,gCAAa,EACnB,cAAc,EACd,IAAI,wCAAc,CAAC,KAAK,CAAC,WAAW,EAAE,KAAK,CAAC,MAAM,EAAE,iBAAiB,CAAC,EACtE,KAAK,EACL,kBAAU,CACV,CAAC;AACH,CAAC;AAVD,wBAUC;AAED,MAAM,cAAc,GAAG,IAAI,uC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AAC,CAAC,CAAC;YAChD,CAAC;QACF,CAAC;QAED,OAAO,IAAI,0BAAU,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC;IAC5C,CAAC;CACD;AAnDD,kCAmDC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, unreachableCase, oob } from \"@fluidframework/core-utils/internal\";\n\nimport { DiscriminatedUnionDispatcher } from \"../../../codec/index.js\";\nimport type {\n\tFieldKey,\n\tTreeNodeSchemaIdentifier,\n\tValue,\n\tTreeChunk,\n} from \"../../../core/index.js\";\nimport { assertValidIndex } from \"../../../util/index.js\";\nimport { BasicChunk } from \"../basicChunk.js\";\nimport { emptyChunk } from \"../emptyChunk.js\";\nimport { SequenceChunk } from \"../sequenceChunk.js\";\n\nimport {\n\ttype ChunkDecoder,\n\ttype StreamCursor,\n\tgetChecked,\n\treadStream,\n\treadStreamBoolean,\n\treadStreamNumber,\n\treadStreamStream,\n\treadStreamValue,\n} from \"./chunkCodecUtilities.js\";\nimport {\n\tDecoderContext,\n\tdecode as genericDecode,\n\treadStreamIdentifier,\n} from \"./chunkDecodingGeneric.js\";\nimport {\n\ttype EncodedAnyShape,\n\ttype EncodedChunkShape,\n\ttype EncodedFieldBatch,\n\ttype EncodedInlineArray,\n\ttype EncodedNestedArray,\n\ttype EncodedTreeShape,\n\ttype EncodedValueShape,\n\tSpecialField,\n} from \"./format.js\";\nimport type {\n\tIIdCompressor,\n\tOpSpaceCompressedId,\n\tSessionId,\n} from \"@fluidframework/id-compressor\";\n\nexport interface IdDecodingContext {\n\tidCompressor: IIdCompressor;\n\t/**\n\t * The creator of any local Ids to be decoded.\n\t */\n\toriginatorId: SessionId;\n}\n/**\n * Decode `chunk` into a TreeChunk.\n */\nexport function decode(\n\tchunk: EncodedFieldBatch,\n\tidDecodingContext: { idCompressor: IIdCompressor; originatorId: SessionId },\n): TreeChunk[] {\n\treturn genericDecode(\n\t\tdecoderLibrary,\n\t\tnew DecoderContext(chunk.identifiers, chunk.shapes, idDecodingContext),\n\t\tchunk,\n\t\tanyDecoder,\n\t);\n}\n\nconst decoderLibrary = new DiscriminatedUnionDispatcher<\n\tEncodedChunkShape,\n\t[cache: DecoderContext<EncodedChunkShape>],\n\tChunkDecoder\n>({\n\ta(shape: EncodedNestedArray, cache): ChunkDecoder {\n\t\treturn new NestedArrayDecoder(shape);\n\t},\n\tb(shape: EncodedInlineArray, cache): ChunkDecoder {\n\t\treturn new InlineArrayDecoder(shape);\n\t},\n\tc(shape: EncodedTreeShape, cache): ChunkDecoder {\n\t\treturn new TreeDecoder(shape, cache);\n\t},\n\td(shape: EncodedAnyShape): ChunkDecoder {\n\t\treturn anyDecoder;\n\t},\n});\n\n/**\n * Decode a node's value from `stream` using its shape.\n */\nexport function readValue(\n\tstream: StreamCursor,\n\tshape: EncodedValueShape,\n\tidDecodingContext: IdDecodingContext,\n): Value {\n\tif (shape === undefined) {\n\t\treturn readStreamBoolean(stream) ? readStreamValue(stream) : undefined;\n\t} else {\n\t\tif (shape === true) {\n\t\t\treturn readStreamValue(stream);\n\t\t} else if (shape === false) {\n\t\t\treturn undefined;\n\t\t} else if (Array.isArray(shape)) {\n\t\t\tassert(shape.length === 1, 0x734 /* expected a single constant for value */);\n\t\t\treturn shape[0] as Value;\n\t\t} else if (shape === SpecialField.Identifier) {\n\t\t\t// This case is a special case handling the decoding of identifier fields.\n\t\t\tconst streamValue = readStream(stream);\n\t\t\tassert(\n\t\t\t\ttypeof streamValue === \"number\" || typeof streamValue === \"string\",\n\t\t\t\t0x997 /* identifier must be string or number. */,\n\t\t\t);\n\t\t\tconst idCompressor = idDecodingContext.idCompressor;\n\t\t\treturn typeof streamValue === \"number\"\n\t\t\t\t? idCompressor.decompress(\n\t\t\t\t\t\tidCompressor.normalizeToSessionSpace(\n\t\t\t\t\t\t\tstreamValue as OpSpaceCompressedId,\n\t\t\t\t\t\t\tidDecodingContext.originatorId,\n\t\t\t\t\t\t),\n\t\t\t\t\t)\n\t\t\t\t: streamValue;\n\t\t} else {\n\t\t\t// EncodedCounter case:\n\t\t\tunreachableCase(shape, \"decoding values as deltas is not yet supported\");\n\t\t}\n\t}\n}\n\n/**\n * Normalize a {@link TreeChunk} into an array.\n *\n * Unwraps {@link SequenceChunk}s, and wraps other chunks.\n */\nexport function deaggregateChunks(chunk: TreeChunk): TreeChunk[] {\n\tif (chunk === emptyChunk) {\n\t\treturn [];\n\t}\n\t// TODO: when handling of SequenceChunks has better performance (for example in cursors),\n\t// consider keeping SequenceChunks here if they are longer than some threshold.\n\tif (chunk instanceof SequenceChunk) {\n\t\t// Could return [] here, however the logic in this file is designed to never produce an empty SequenceChunk, so its better to throw an error here to detect bugs.\n\t\tassert(chunk.subChunks.length > 0, 0x735 /* Unexpected empty sequence */);\n\t\t// Logic in this file is designed to never produce an unneeded (single item) SequenceChunks, so its better to throw an error here to detect bugs.\n\t\tassert(chunk.subChunks.length > 1, 0x736 /* Unexpected single item sequence */);\n\n\t\tfor (const sub of chunk.subChunks) {\n\t\t\t// The logic in this file is designed to never produce an nested SequenceChunks or emptyChunk, so its better to throw an error here to detect bugs.\n\t\t\tassert(!(sub instanceof SequenceChunk), 0x737 /* unexpected nested sequence */);\n\t\t\tassert(sub !== emptyChunk, 0x738 /* unexpected empty chunk */);\n\n\t\t\tsub.referenceAdded();\n\t\t}\n\n\t\tchunk.referenceRemoved();\n\t\treturn chunk.subChunks;\n\t} else {\n\t\treturn [chunk];\n\t}\n}\n\n/**\n * Normalize a {@link TreeChunk}[] into a single TreeChunk.\n *\n * Avoids creating nested or less than 2 child {@link SequenceChunk}s.\n */\nexport function aggregateChunks(input: TreeChunk[]): TreeChunk {\n\tconst chunks = input.flatMap(deaggregateChunks);\n\tswitch (chunks.length) {\n\t\tcase 0:\n\t\t\treturn emptyChunk;\n\t\tcase 1:\n\t\t\treturn chunks[0] ?? oob();\n\t\tdefault:\n\t\t\treturn new SequenceChunk(chunks);\n\t}\n}\n\n/**\n * Decoder for {@link EncodedNestedArray}s.\n */\nexport class NestedArrayDecoder implements ChunkDecoder {\n\tpublic constructor(private readonly shape: EncodedNestedArray) {}\n\tpublic decode(decoders: readonly ChunkDecoder[], stream: StreamCursor): TreeChunk {\n\t\tconst decoder = decoders[this.shape] ?? oob();\n\n\t\t// TODO: uniform chunk fast path\n\t\tconst chunks: TreeChunk[] = [];\n\n\t\tconst data = readStream(stream);\n\t\tif (typeof data === \"number\") {\n\t\t\t// This case means that the array contained only 0-sized items, and was thus encoded as the length of the array.\n\t\t\tconst inner = { data: [], offset: 0 };\n\t\t\tfor (let index = 0; index < data; index++) {\n\t\t\t\tchunks.push(decoder.decode(decoders, inner));\n\t\t\t}\n\t\t} else {\n\t\t\tassert(\n\t\t\t\tArray.isArray(data),\n\t\t\t\t0x739 /* expected number of array for encoding of nested array */,\n\t\t\t);\n\t\t\tconst inner = { data, offset: 0 };\n\t\t\twhile (inner.offset !== inner.data.length) {\n\t\t\t\tchunks.push(decoder.decode(decoders, inner));\n\t\t\t}\n\t\t}\n\n\t\treturn aggregateChunks(chunks);\n\t}\n}\n\n/**\n * Decoder for {@link EncodedInlineArray}s.\n */\nexport class InlineArrayDecoder implements ChunkDecoder {\n\tpublic constructor(private readonly shape: EncodedInlineArray) {}\n\tpublic decode(decoders: readonly ChunkDecoder[], stream: StreamCursor): TreeChunk {\n\t\tconst length = this.shape.length;\n\t\tconst decoder = decoders[this.shape.shape] ?? oob();\n\t\tconst chunks: TreeChunk[] = [];\n\t\tfor (let index = 0; index < length; index++) {\n\t\t\tchunks.push(decoder.decode(decoders, stream));\n\t\t}\n\t\treturn aggregateChunks(chunks);\n\t}\n}\n\n/**\n * Decoder for {@link EncodedAnyShape}s.\n */\nexport const anyDecoder: ChunkDecoder = {\n\tdecode(decoders: readonly ChunkDecoder[], stream: StreamCursor): TreeChunk {\n\t\tconst shapeIndex = readStreamNumber(stream);\n\t\tconst decoder = getChecked(decoders, shapeIndex);\n\t\treturn decoder.decode(decoders, stream);\n\t},\n};\n\n/**\n * Decoder for field.\n */\ntype BasicFieldDecoder = (\n\tdecoders: readonly ChunkDecoder[],\n\tstream: StreamCursor,\n) => [FieldKey, TreeChunk];\n\n/**\n * Get a decoder for fields of a provided (via `shape` and `cache`) {@link EncodedChunkShape}.\n */\nfunction fieldDecoder(\n\tcache: DecoderContext<EncodedChunkShape>,\n\tkey: FieldKey,\n\tshape: number,\n): BasicFieldDecoder {\n\tassertValidIndex(shape, cache.shapes);\n\treturn (decoders, stream) => {\n\t\tconst decoder = decoders[shape] ?? oob();\n\t\treturn [key, decoder.decode(decoders, stream)];\n\t};\n}\n\n/**\n * Decoder for {@link EncodedTreeShape}s.\n */\nexport class TreeDecoder implements ChunkDecoder {\n\tprivate readonly type?: TreeNodeSchemaIdentifier;\n\tprivate readonly fieldDecoders: readonly BasicFieldDecoder[];\n\tpublic constructor(\n\t\tprivate readonly shape: EncodedTreeShape,\n\t\tprivate readonly cache: DecoderContext<EncodedChunkShape>,\n\t) {\n\t\tthis.type = shape.type === undefined ? undefined : cache.identifier(shape.type);\n\n\t\tconst fieldDecoders: BasicFieldDecoder[] = [];\n\t\tfor (const [fieldKey, fieldShape] of shape.fields ?? []) {\n\t\t\tconst key: FieldKey = cache.identifier(fieldKey);\n\t\t\tfieldDecoders.push(fieldDecoder(cache, key, fieldShape));\n\t\t}\n\t\tthis.fieldDecoders = fieldDecoders;\n\t}\n\tpublic decode(decoders: readonly ChunkDecoder[], stream: StreamCursor): TreeChunk {\n\t\tconst type: TreeNodeSchemaIdentifier =\n\t\t\tthis.type ?? readStreamIdentifier(stream, this.cache);\n\t\t// TODO: Consider typechecking against stored schema in here somewhere.\n\n\t\tconst value = readValue(stream, this.shape.value, this.cache.idDecodingContext);\n\t\tconst fields: Map<FieldKey, TreeChunk[]> = new Map();\n\n\t\t// Helper to add fields, but with unneeded array chunks removed.\n\t\tfunction addField(key: FieldKey, data: TreeChunk): void {\n\t\t\t// TODO: when handling of ArrayChunks has better performance (for example in cursors),\n\t\t\t// consider keeping array chunks here if they are longer than some threshold.\n\t\t\tconst chunks = deaggregateChunks(data);\n\n\t\t\tif (chunks.length !== 0) {\n\t\t\t\tfields.set(key, chunks);\n\t\t\t}\n\t\t}\n\n\t\tfor (const field of this.fieldDecoders) {\n\t\t\tconst [key, content] = field(decoders, stream);\n\t\t\taddField(key, content);\n\t\t}\n\n\t\tif (this.shape.extraFields !== undefined) {\n\t\t\tconst decoder = decoders[this.shape.extraFields] ?? oob();\n\t\t\tconst inner = readStreamStream(stream);\n\t\t\twhile (inner.offset !== inner.data.length) {\n\t\t\t\tconst key: FieldKey = readStreamIdentifier(inner, this.cache);\n\t\t\t\taddField(key, decoder.decode(decoders, inner));\n\t\t\t}\n\t\t}\n\n\t\treturn new BasicChunk(type, fields, value);\n\t}\n}\n"]}
@@ -4,7 +4,7 @@
4
4
  */
5
5
  import type { DiscriminatedUnionDispatcher } from "../../../codec/index.js";
6
6
  import type { BrandedType } from "../../../util/index.js";
7
- import type { TreeChunk } from "../chunk.js";
7
+ import type { TreeChunk } from "../../../core/index.js";
8
8
  import { type ChunkDecoder, type StreamCursor } from "./chunkCodecUtilities.js";
9
9
  import type { EncodedFieldBatchGeneric, IdentifierOrIndex } from "./formatGeneric.js";
10
10
  import type { IdDecodingContext } from "./chunkDecoding.js";
@@ -1 +1 @@
1
- {"version":3,"file":"chunkDecodingGeneric.d.ts","sourceRoot":"","sources":["../../../../src/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,yBAAyB,CAAC;AAC5E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAE7C,OAAO,EACN,KAAK,YAAY,EACjB,KAAK,YAAY,EAGjB,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EAAE,wBAAwB,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACtF,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAE5D;;GAEG;AACH,wBAAgB,MAAM,CAAC,aAAa,SAAS,MAAM,EAAE,MAAM,EAC1D,cAAc,EAAE,4BAA4B,CAAC,aAAa,EAAE,CAAC,KAAK,EAAE,MAAM,CAAC,EAAE,YAAY,CAAC,EAC1F,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,wBAAwB,CAAC,aAAa,CAAC,EAC9C,WAAW,EAAE,YAAY,GACvB,SAAS,EAAE,CAcb;AAED;;GAEG;AACH,qBAAa,cAAc,CAAC,aAAa,GAAG,OAAO;aAKjC,WAAW,EAAE,SAAS,MAAM,EAAE;aAC9B,MAAM,EAAE,SAAS,aAAa,EAAE;aAChC,iBAAiB,EAAE,iBAAiB;IANrD;;OAEG;gBAEc,WAAW,EAAE,SAAS,MAAM,EAAE,EAC9B,MAAM,EAAE,SAAS,aAAa,EAAE,EAChC,iBAAiB,EAAE,iBAAiB;IAG9C,UAAU,CAAC,CAAC,SAAS,MAAM,GAAG,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,EAC/D,OAAO,EAAE,iBAAiB,GACxB,CAAC;CAMJ;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,CAAC,SAAS,MAAM,GAAG,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,EAClF,MAAM,EAAE,YAAY,EACpB,KAAK,EAAE,cAAc,GACnB,CAAC,CAOH"}
1
+ {"version":3,"file":"chunkDecodingGeneric.d.ts","sourceRoot":"","sources":["../../../../src/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,yBAAyB,CAAC;AAC5E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAExD,OAAO,EACN,KAAK,YAAY,EACjB,KAAK,YAAY,EAGjB,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EAAE,wBAAwB,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACtF,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAE5D;;GAEG;AACH,wBAAgB,MAAM,CAAC,aAAa,SAAS,MAAM,EAAE,MAAM,EAC1D,cAAc,EAAE,4BAA4B,CAAC,aAAa,EAAE,CAAC,KAAK,EAAE,MAAM,CAAC,EAAE,YAAY,CAAC,EAC1F,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,wBAAwB,CAAC,aAAa,CAAC,EAC9C,WAAW,EAAE,YAAY,GACvB,SAAS,EAAE,CAcb;AAED;;GAEG;AACH,qBAAa,cAAc,CAAC,aAAa,GAAG,OAAO;aAKjC,WAAW,EAAE,SAAS,MAAM,EAAE;aAC9B,MAAM,EAAE,SAAS,aAAa,EAAE;aAChC,iBAAiB,EAAE,iBAAiB;IANrD;;OAEG;gBAEc,WAAW,EAAE,SAAS,MAAM,EAAE,EAC9B,MAAM,EAAE,SAAS,aAAa,EAAE,EAChC,iBAAiB,EAAE,iBAAiB;IAG9C,UAAU,CAAC,CAAC,SAAS,MAAM,GAAG,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,EAC/D,OAAO,EAAE,iBAAiB,GACxB,CAAC;CAMJ;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,CAAC,SAAS,MAAM,GAAG,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,EAClF,MAAM,EAAE,YAAY,EACpB,KAAK,EAAE,cAAc,GACnB,CAAC,CAOH"}
@@ -1 +1 @@
1
- {"version":3,"file":"chunkDecodingGeneric.js","sourceRoot":"","sources":["../../../../src/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;A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AAqB;IAErB,MAAM,OAAO,GAAG,IAAA,mCAAU,EAAC,MAAM,CAAC,CAAC;IACnC,IAAA,iBAAM,EACL,OAAO,OAAO,KAAK,QAAQ,IAAI,OAAO,OAAO,KAAK,QAAQ,EAC1D,KAAK,CAAC,sCAAsC,CAC5C,CAAC;IACF,OAAO,KAAK,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;AAClC,CAAC;AAVD,oDAUC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\n\nimport type { DiscriminatedUnionDispatcher } from \"../../../codec/index.js\";\nimport type { BrandedType } from \"../../../util/index.js\";\nimport type { TreeChunk } from \"../chunk.js\";\n\nimport {\n\ttype ChunkDecoder,\n\ttype StreamCursor,\n\tgetChecked,\n\treadStream,\n} from \"./chunkCodecUtilities.js\";\nimport type { EncodedFieldBatchGeneric, IdentifierOrIndex } from \"./formatGeneric.js\";\nimport type { IdDecodingContext } from \"./chunkDecoding.js\";\n\n/**\n * General purpose shape based tree decoder which gets its support for specific shapes from the caller.\n */\nexport function decode<TEncodedShape extends object, TCache>(\n\tdecoderLibrary: DiscriminatedUnionDispatcher<TEncodedShape, [cache: TCache], ChunkDecoder>,\n\tcache: TCache,\n\tbatch: EncodedFieldBatchGeneric<TEncodedShape>,\n\trootDecoder: ChunkDecoder,\n): TreeChunk[] {\n\tconst decoders = batch.shapes.map((shape) => decoderLibrary.dispatch(shape, cache));\n\tconst chunks: TreeChunk[] = [];\n\tfor (const field of batch.data) {\n\t\tconst stream = { data: field, offset: 0 };\n\t\tconst result = rootDecoder.decode(decoders, stream);\n\t\tassert(\n\t\t\tstream.offset === stream.data.length,\n\t\t\t0x73a /* expected decode to consume full stream */,\n\t\t);\n\t\tchunks.push(result);\n\t}\n\n\treturn chunks;\n}\n\n/**\n * Shared data for use in constructing decoders.\n */\nexport class DecoderContext<TEncodedShape = unknown> {\n\t/**\n\t * @param identifiers - identifier substitution table (use to replace numeric identifier indexes with the actual identifiers from this table).\n\t */\n\tpublic constructor(\n\t\tpublic readonly identifiers: readonly string[],\n\t\tpublic readonly shapes: readonly TEncodedShape[],\n\t\tpublic readonly idDecodingContext: IdDecodingContext,\n\t) {}\n\n\tpublic identifier<T extends string & BrandedType<string, string>>(\n\t\tencoded: IdentifierOrIndex,\n\t): T {\n\t\tif (typeof encoded === \"string\") {\n\t\t\treturn encoded as T;\n\t\t}\n\t\treturn getChecked(this.identifiers, encoded) as T;\n\t}\n}\n\n/**\n * Read one identifier from the stream, advancing the stream offset.\n */\nexport function readStreamIdentifier<T extends string & BrandedType<string, string>>(\n\tstream: StreamCursor,\n\tcache: DecoderContext,\n): T {\n\tconst content = readStream(stream);\n\tassert(\n\t\ttypeof content === \"number\" || typeof content === \"string\",\n\t\t0x73b /* content to be a number or string */,\n\t);\n\treturn cache.identifier(content);\n}\n"]}
1
+ {"version":3,"file":"chunkDecodingGeneric.js","sourceRoot":"","sources":["../../../../src/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAA6D;AAM7D,qEAKkC;AAIlC;;GAEG;AACH,SAAgB,MAAM,CACrB,cAA0F,EAC1F,KAAa,EACb,KAA8C,EAC9C,WAAyB;IAEzB,MAAM,QAAQ,GAAG,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,cAAc,CAAC,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC;IACpF,MAAM,MAAM,GAAgB,EAAE,CAAC;IAC/B,KAAK,MAAM,KAAK,IAAI,KAAK,CAAC,IAAI,EAAE,CAAC;QAChC,MAAM,MAAM,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC;QAC1C,MAAM,MAAM,GAAG,WAAW,CAAC,MAAM,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;QACpD,IAAA,iBAAM,EACL,MAAM,CAAC,MAAM,KAAK,MAAM,CAAC,IAAI,CAAC,MAAM,EACpC,KAAK,CAAC,4CAA4C,CAClD,CAAC;QACF,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACrB,CAAC;IAED,OAAO,MAAM,CAAC;AACf,CAAC;AAnBD,wBAmBC;AAED;;GAEG;AACH,MAAa,cAAc;IAC1B;;OAEG;IACH,YACiB,WAA8B,EAC9B,MAAgC,EAChC,iBAAoC;QAFpC,gBAAW,GAAX,WAAW,CAAmB;QAC9B,WAAM,GAAN,MAAM,CAA0B;QAChC,sBAAiB,GAAjB,iBAAiB,CAAmB;IAClD,CAAC;IAEG,UAAU,CAChB,OAA0B;QAE1B,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE,CAAC;YACjC,OAAO,OAAY,CAAC;QACrB,CAAC;QACD,OAAO,IAAA,mCAAU,EAAC,IAAI,CAAC,WAAW,EAAE,OAAO,CAAM,CAAC;IACnD,CAAC;CACD;AAlBD,wCAkBC;AAED;;GAEG;AACH,SAAgB,oBAAoB,CACnC,MAAoB,EACpB,KAAqB;IAErB,MAAM,OAAO,GAAG,IAAA,mCAAU,EAAC,MAAM,CAAC,CAAC;IACnC,IAAA,iBAAM,EACL,OAAO,OAAO,KAAK,QAAQ,IAAI,OAAO,OAAO,KAAK,QAAQ,EAC1D,KAAK,CAAC,sCAAsC,CAC5C,CAAC;IACF,OAAO,KAAK,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;AAClC,CAAC;AAVD,oDAUC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\n\nimport type { DiscriminatedUnionDispatcher } from \"../../../codec/index.js\";\nimport type { BrandedType } from \"../../../util/index.js\";\nimport type { TreeChunk } from \"../../../core/index.js\";\n\nimport {\n\ttype ChunkDecoder,\n\ttype StreamCursor,\n\tgetChecked,\n\treadStream,\n} from \"./chunkCodecUtilities.js\";\nimport type { EncodedFieldBatchGeneric, IdentifierOrIndex } from \"./formatGeneric.js\";\nimport type { IdDecodingContext } from \"./chunkDecoding.js\";\n\n/**\n * General purpose shape based tree decoder which gets its support for specific shapes from the caller.\n */\nexport function decode<TEncodedShape extends object, TCache>(\n\tdecoderLibrary: DiscriminatedUnionDispatcher<TEncodedShape, [cache: TCache], ChunkDecoder>,\n\tcache: TCache,\n\tbatch: EncodedFieldBatchGeneric<TEncodedShape>,\n\trootDecoder: ChunkDecoder,\n): TreeChunk[] {\n\tconst decoders = batch.shapes.map((shape) => decoderLibrary.dispatch(shape, cache));\n\tconst chunks: TreeChunk[] = [];\n\tfor (const field of batch.data) {\n\t\tconst stream = { data: field, offset: 0 };\n\t\tconst result = rootDecoder.decode(decoders, stream);\n\t\tassert(\n\t\t\tstream.offset === stream.data.length,\n\t\t\t0x73a /* expected decode to consume full stream */,\n\t\t);\n\t\tchunks.push(result);\n\t}\n\n\treturn chunks;\n}\n\n/**\n * Shared data for use in constructing decoders.\n */\nexport class DecoderContext<TEncodedShape = unknown> {\n\t/**\n\t * @param identifiers - identifier substitution table (use to replace numeric identifier indexes with the actual identifiers from this table).\n\t */\n\tpublic constructor(\n\t\tpublic readonly identifiers: readonly string[],\n\t\tpublic readonly shapes: readonly TEncodedShape[],\n\t\tpublic readonly idDecodingContext: IdDecodingContext,\n\t) {}\n\n\tpublic identifier<T extends string & BrandedType<string, string>>(\n\t\tencoded: IdentifierOrIndex,\n\t): T {\n\t\tif (typeof encoded === \"string\") {\n\t\t\treturn encoded as T;\n\t\t}\n\t\treturn getChecked(this.identifiers, encoded) as T;\n\t}\n}\n\n/**\n * Read one identifier from the stream, advancing the stream offset.\n */\nexport function readStreamIdentifier<T extends string & BrandedType<string, string>>(\n\tstream: StreamCursor,\n\tcache: DecoderContext,\n): T {\n\tconst content = readStream(stream);\n\tassert(\n\t\ttypeof content === \"number\" || typeof content === \"string\",\n\t\t0x73b /* content to be a number or string */,\n\t);\n\treturn cache.identifier(content);\n}\n"]}
@@ -2,7 +2,7 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
- import { type ChunkedCursor, type TreeChunk } from "./chunk.js";
5
+ import { type ChunkedCursor, type TreeChunk } from "../../core/index.js";
6
6
  /**
7
7
  * Chunk that is empty.
8
8
  *
@@ -1 +1 @@
1
- {"version":3,"file":"emptyChunk.d.ts","sourceRoot":"","sources":["../../../src/feature-libraries/chunked-forest/emptyChunk.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAaH,OAAO,EAAE,KAAK,aAAa,EAAE,KAAK,SAAS,EAA0B,MAAM,YAAY,CAAC;AAExF;;;;;;GAMG;AACH,eAAO,MAAM,UAAU,EAAE,SAUxB,CAAC;AAOF;;;GAGG;AACH,eAAO,MAAM,WAAW,EAAE,aAoEzB,CAAC"}
1
+ {"version":3,"file":"emptyChunk.d.ts","sourceRoot":"","sources":["../../../src/feature-libraries/chunked-forest/emptyChunk.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAON,KAAK,aAAa,EAClB,KAAK,SAAS,EAGd,MAAM,qBAAqB,CAAC;AAI7B;;;;;;GAMG;AACH,eAAO,MAAM,UAAU,EAAE,SAUxB,CAAC;AAOF;;;GAGG;AACH,eAAO,MAAM,WAAW,EAAE,aAoEzB,CAAC"}
@@ -8,7 +8,6 @@ exports.emptyCursor = exports.emptyChunk = void 0;
8
8
  const index_js_1 = require("../../core/index.js");
9
9
  const index_js_2 = require("../../util/index.js");
10
10
  const treeCursorUtils_js_1 = require("../treeCursorUtils.js");
11
- const chunk_js_1 = require("./chunk.js");
12
11
  /**
13
12
  * Chunk that is empty.
14
13
  *
@@ -29,7 +28,7 @@ exports.emptyChunk = {
29
28
  };
30
29
  const emptyPath = {
31
30
  parent: undefined,
32
- field: chunk_js_1.dummyRoot,
31
+ field: index_js_1.dummyRoot,
33
32
  };
34
33
  /**
35
34
  * Cursor over an empty field.
@@ -39,7 +38,7 @@ exports.emptyCursor = {
39
38
  [index_js_1.CursorMarker]: true,
40
39
  pending: false,
41
40
  mode: 1 /* CursorLocationType.Fields */,
42
- [chunk_js_1.cursorChunk]: exports.emptyChunk,
41
+ [index_js_1.cursorChunk]: exports.emptyChunk,
43
42
  nextField() {
44
43
  (0, index_js_2.fail)("cannot navigate above root");
45
44
  },
@@ -1 +1 @@
1
- {"version":3,"file":"emptyChunk.js","sourceRoot":"","sources":["../../../src/feature-libraries/chunked-forest/emptyChunk.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kDAO6B;AAC7B,kDAA2C;AAC3C,8DAAwD;AAExD,yCAAwF;AAExF;;;;;;GAMG;AACU,QAAA,UAAU,GAAc;IACpC,cAAc,EAAE,CAAC;IACjB,MAAM;QACL,OAAO,mBAAW,CAAC;IACpB,CAAC;IACD,cAAc,KAAU,CAAC;IACzB,gBAAgB,KAAU,CAAC;IAC3B,QAAQ;QACP,OAAO,KAAK,CAAC,CAAC,yCAAyC;IACxD,CAAC;CACD,CAAC;AAEF,MAAM,SAAS,GAAgB;IAC9B,MAAM,EAAE,SAAS;IACjB,KAAK,EAAE,oBAAS;CAChB,CAAC;AAEF;;;GAGG;AACU,QAAA,WAAW,GAAkB;IACzC,CAAC,uBAAY,CAAC,EAAE,IAAI;IACpB,OAAO,EAAE,KAAK;IACd,IAAI,mCAA2B;IAC/B,CAAC,sBAAW,CAAC,EAAE,kBAAU;IACzB,SAAS;QACR,IAAA,eAAI,EAAC,4BAA4B,CAAC,CAAC;IACpC,CAAC;IACD,SAAS;QACR,IAAA,eAAI,EAAC,4BAA4B,CAAC,CAAC;IACpC,CAAC;IACD,iBAAiB;QAChB,OAAO,IAAI,CAAC;IACb,CAAC;IACD,WAAW;QACV,OAAO,SAAS,CAAC,KAAK,CAAC;IACxB,CAAC;IACD,cAAc;QACb,OAAO,CAAC,CAAC;IACV,CAAC;IACD,SAAS;QACR,OAAO,KAAK,CAAC;IACd,CAAC;IACD,SAAS,CAAC,UAAkB;QAC3B,IAAA,eAAI,EAAC,2BAA2B,CAAC,CAAC;IACnC,CAAC;IACD,YAAY,CAAC,MAAuB;QACnC,OAAO,IAAA,oCAAe,EAAC,MAAM,EAAE,SAAS,CAAC,CAAC;IAC3C,CAAC;IACD,OAAO;QACN,IAAA,eAAI,EAAC,2BAA2B,CAAC,CAAC;IACnC,CAAC;IACD,IAAI,UAAU;QACb,OAAO,IAAA,eAAI,EAAC,2BAA2B,CAAC,CAAC;IAC1C,CAAC;IACD,IAAI,UAAU;QACb,OAAO,IAAA,eAAI,EAAC,2BAA2B,CAAC,CAAC;IAC1C,CAAC;IACD,IAAI,WAAW;QACd,OAAO,IAAA,eAAI,EAAC,2BAA2B,CAAC,CAAC;IAC1C,CAAC;IACD,SAAS,CAAC,MAAc;QACvB,IAAA,eAAI,EAAC,2BAA2B,CAAC,CAAC;IACnC,CAAC;IACD,QAAQ;QACP,IAAA,eAAI,EAAC,2BAA2B,CAAC,CAAC;IACnC,CAAC;IACD,QAAQ;QACP,IAAA,eAAI,EAAC,2BAA2B,CAAC,CAAC;IACnC,CAAC;IACD,UAAU;QACT,IAAA,eAAI,EAAC,2BAA2B,CAAC,CAAC;IACnC,CAAC;IACD,UAAU,CAAC,GAAa;QACvB,IAAA,eAAI,EAAC,2BAA2B,CAAC,CAAC;IACnC,CAAC;IACD,IAAI,IAAI;QACP,OAAO,IAAA,eAAI,EAAC,2BAA2B,CAAC,CAAC;IAC1C,CAAC;IACD,IAAI,KAAK;QACR,OAAO,IAAA,eAAI,EAAC,2BAA2B,CAAC,CAAC;IAC1C,CAAC;IACD,WAAW;QACV,OAAO,IAAI,CAAC;IACb,CAAC;IACD,IAAI;QACH,OAAO,mBAAW,CAAC;IACpB,CAAC;CACD,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\tCursorLocationType,\n\tCursorMarker,\n\ttype FieldKey,\n\ttype FieldUpPath,\n\ttype PathRootPrefix,\n\ttype UpPath,\n} from \"../../core/index.js\";\nimport { fail } from \"../../util/index.js\";\nimport { prefixFieldPath } from \"../treeCursorUtils.js\";\n\nimport { type ChunkedCursor, type TreeChunk, cursorChunk, dummyRoot } from \"./chunk.js\";\n\n/**\n * Chunk that is empty.\n *\n * Since all emptiness is the same, this is a singleton.\n *\n * Useful for when a chunk or cursor is needed for an empty field or detached sequence.\n */\nexport const emptyChunk: TreeChunk = {\n\ttopLevelLength: 0,\n\tcursor(): ChunkedCursor {\n\t\treturn emptyCursor;\n\t},\n\treferenceAdded(): void {},\n\treferenceRemoved(): void {},\n\tisShared(): boolean {\n\t\treturn false; // Immutable, so sharing does not matter.\n\t},\n};\n\nconst emptyPath: FieldUpPath = {\n\tparent: undefined,\n\tfield: dummyRoot,\n};\n\n/**\n * Cursor over an empty field.\n * Contains no nodes and is stateless.\n */\nexport const emptyCursor: ChunkedCursor = {\n\t[CursorMarker]: true,\n\tpending: false,\n\tmode: CursorLocationType.Fields,\n\t[cursorChunk]: emptyChunk,\n\tnextField(): boolean {\n\t\tfail(\"cannot navigate above root\");\n\t},\n\texitField(): void {\n\t\tfail(\"cannot navigate above root\");\n\t},\n\tskipPendingFields(): boolean {\n\t\treturn true;\n\t},\n\tgetFieldKey(): FieldKey {\n\t\treturn emptyPath.field;\n\t},\n\tgetFieldLength(): number {\n\t\treturn 0;\n\t},\n\tfirstNode(): boolean {\n\t\treturn false;\n\t},\n\tenterNode(childIndex: number): void {\n\t\tfail(\"empty cursor has no nodes\");\n\t},\n\tgetFieldPath(prefix?: PathRootPrefix): FieldUpPath {\n\t\treturn prefixFieldPath(prefix, emptyPath);\n\t},\n\tgetPath(): UpPath | undefined {\n\t\tfail(\"empty cursor has no nodes\");\n\t},\n\tget fieldIndex(): never {\n\t\treturn fail(\"empty cursor has no nodes\");\n\t},\n\tget chunkStart(): never {\n\t\treturn fail(\"empty cursor has no nodes\");\n\t},\n\tget chunkLength(): never {\n\t\treturn fail(\"empty cursor has no nodes\");\n\t},\n\tseekNodes(offset: number): boolean {\n\t\tfail(\"empty cursor has no nodes\");\n\t},\n\tnextNode(): boolean {\n\t\tfail(\"empty cursor has no nodes\");\n\t},\n\texitNode(): void {\n\t\tfail(\"empty cursor has no nodes\");\n\t},\n\tfirstField(): boolean {\n\t\tfail(\"empty cursor has no nodes\");\n\t},\n\tenterField(key: FieldKey): void {\n\t\tfail(\"empty cursor has no nodes\");\n\t},\n\tget type(): never {\n\t\treturn fail(\"empty cursor has no nodes\");\n\t},\n\tget value(): never {\n\t\treturn fail(\"empty cursor has no nodes\");\n\t},\n\tatChunkRoot(): boolean {\n\t\treturn true;\n\t},\n\tfork(): ChunkedCursor {\n\t\treturn emptyCursor;\n\t},\n};\n"]}
1
+ {"version":3,"file":"emptyChunk.js","sourceRoot":"","sources":["../../../src/feature-libraries/chunked-forest/emptyChunk.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kDAW6B;AAC7B,kDAA2C;AAC3C,8DAAwD;AAExD;;;;;;GAMG;AACU,QAAA,UAAU,GAAc;IACpC,cAAc,EAAE,CAAC;IACjB,MAAM;QACL,OAAO,mBAAW,CAAC;IACpB,CAAC;IACD,cAAc,KAAU,CAAC;IACzB,gBAAgB,KAAU,CAAC;IAC3B,QAAQ;QACP,OAAO,KAAK,CAAC,CAAC,yCAAyC;IACxD,CAAC;CACD,CAAC;AAEF,MAAM,SAAS,GAAgB;IAC9B,MAAM,EAAE,SAAS;IACjB,KAAK,EAAE,oBAAS;CAChB,CAAC;AAEF;;;GAGG;AACU,QAAA,WAAW,GAAkB;IACzC,CAAC,uBAAY,CAAC,EAAE,IAAI;IACpB,OAAO,EAAE,KAAK;IACd,IAAI,mCAA2B;IAC/B,CAAC,sBAAW,CAAC,EAAE,kBAAU;IACzB,SAAS;QACR,IAAA,eAAI,EAAC,4BAA4B,CAAC,CAAC;IACpC,CAAC;IACD,SAAS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AC,CAAC;IAC1C,CAAC;IACD,WAAW;QACV,OAAO,IAAI,CAAC;IACb,CAAC;IACD,IAAI;QACH,OAAO,mBAAW,CAAC;IACpB,CAAC;CACD,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\tCursorLocationType,\n\tCursorMarker,\n\ttype FieldKey,\n\ttype FieldUpPath,\n\ttype PathRootPrefix,\n\ttype UpPath,\n\ttype ChunkedCursor,\n\ttype TreeChunk,\n\tcursorChunk,\n\tdummyRoot,\n} from \"../../core/index.js\";\nimport { fail } from \"../../util/index.js\";\nimport { prefixFieldPath } from \"../treeCursorUtils.js\";\n\n/**\n * Chunk that is empty.\n *\n * Since all emptiness is the same, this is a singleton.\n *\n * Useful for when a chunk or cursor is needed for an empty field or detached sequence.\n */\nexport const emptyChunk: TreeChunk = {\n\ttopLevelLength: 0,\n\tcursor(): ChunkedCursor {\n\t\treturn emptyCursor;\n\t},\n\treferenceAdded(): void {},\n\treferenceRemoved(): void {},\n\tisShared(): boolean {\n\t\treturn false; // Immutable, so sharing does not matter.\n\t},\n};\n\nconst emptyPath: FieldUpPath = {\n\tparent: undefined,\n\tfield: dummyRoot,\n};\n\n/**\n * Cursor over an empty field.\n * Contains no nodes and is stateless.\n */\nexport const emptyCursor: ChunkedCursor = {\n\t[CursorMarker]: true,\n\tpending: false,\n\tmode: CursorLocationType.Fields,\n\t[cursorChunk]: emptyChunk,\n\tnextField(): boolean {\n\t\tfail(\"cannot navigate above root\");\n\t},\n\texitField(): void {\n\t\tfail(\"cannot navigate above root\");\n\t},\n\tskipPendingFields(): boolean {\n\t\treturn true;\n\t},\n\tgetFieldKey(): FieldKey {\n\t\treturn emptyPath.field;\n\t},\n\tgetFieldLength(): number {\n\t\treturn 0;\n\t},\n\tfirstNode(): boolean {\n\t\treturn false;\n\t},\n\tenterNode(childIndex: number): void {\n\t\tfail(\"empty cursor has no nodes\");\n\t},\n\tgetFieldPath(prefix?: PathRootPrefix): FieldUpPath {\n\t\treturn prefixFieldPath(prefix, emptyPath);\n\t},\n\tgetPath(): UpPath | undefined {\n\t\tfail(\"empty cursor has no nodes\");\n\t},\n\tget fieldIndex(): never {\n\t\treturn fail(\"empty cursor has no nodes\");\n\t},\n\tget chunkStart(): never {\n\t\treturn fail(\"empty cursor has no nodes\");\n\t},\n\tget chunkLength(): never {\n\t\treturn fail(\"empty cursor has no nodes\");\n\t},\n\tseekNodes(offset: number): boolean {\n\t\tfail(\"empty cursor has no nodes\");\n\t},\n\tnextNode(): boolean {\n\t\tfail(\"empty cursor has no nodes\");\n\t},\n\texitNode(): void {\n\t\tfail(\"empty cursor has no nodes\");\n\t},\n\tfirstField(): boolean {\n\t\tfail(\"empty cursor has no nodes\");\n\t},\n\tenterField(key: FieldKey): void {\n\t\tfail(\"empty cursor has no nodes\");\n\t},\n\tget type(): never {\n\t\treturn fail(\"empty cursor has no nodes\");\n\t},\n\tget value(): never {\n\t\treturn fail(\"empty cursor has no nodes\");\n\t},\n\tatChunkRoot(): boolean {\n\t\treturn true;\n\t},\n\tfork(): ChunkedCursor {\n\t\treturn emptyCursor;\n\t},\n};\n"]}
@@ -3,7 +3,7 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
  export { uniformChunk, ChunkShape } from "./uniformChunk.js";
6
- export { type TreeChunk, dummyRoot } from "./chunk.js";
6
+ export { type TreeChunk, dummyRoot } from "../../core/index.js";
7
7
  export { chunkTree, defaultChunkPolicy, makeTreeChunker, type IChunker, chunkFieldSingle, chunkField, } from "./chunkTree.js";
8
8
  export { buildChunkedForest } from "./chunkedForest.js";
9
9
  export { EncodedFieldBatch, type FieldBatch, type FieldBatchCodec, makeFieldBatchCodec, type FieldBatchEncodingContext, } from "./codec/index.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/feature-libraries/chunked-forest/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC7D,OAAO,EAAE,KAAK,SAAS,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvD,OAAO,EACN,SAAS,EACT,kBAAkB,EAClB,eAAe,EACf,KAAK,QAAQ,EACb,gBAAgB,EAChB,UAAU,GACV,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,EACN,iBAAiB,EACjB,KAAK,UAAU,EACf,KAAK,eAAe,EACpB,mBAAmB,EACnB,KAAK,yBAAyB,GAC9B,MAAM,kBAAkB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/feature-libraries/chunked-forest/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC7D,OAAO,EAAE,KAAK,SAAS,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAChE,OAAO,EACN,SAAS,EACT,kBAAkB,EAClB,eAAe,EACf,KAAK,QAAQ,EACb,gBAAgB,EAChB,UAAU,GACV,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,EACN,iBAAiB,EACjB,KAAK,UAAU,EACf,KAAK,eAAe,EACpB,mBAAmB,EACnB,KAAK,yBAAyB,GAC9B,MAAM,kBAAkB,CAAC"}
@@ -8,8 +8,8 @@ exports.makeFieldBatchCodec = exports.EncodedFieldBatch = exports.buildChunkedFo
8
8
  var uniformChunk_js_1 = require("./uniformChunk.js");
9
9
  Object.defineProperty(exports, "uniformChunk", { enumerable: true, get: function () { return uniformChunk_js_1.uniformChunk; } });
10
10
  Object.defineProperty(exports, "ChunkShape", { enumerable: true, get: function () { return uniformChunk_js_1.ChunkShape; } });
11
- var chunk_js_1 = require("./chunk.js");
12
- Object.defineProperty(exports, "dummyRoot", { enumerable: true, get: function () { return chunk_js_1.dummyRoot; } });
11
+ var index_js_1 = require("../../core/index.js");
12
+ Object.defineProperty(exports, "dummyRoot", { enumerable: true, get: function () { return index_js_1.dummyRoot; } });
13
13
  var chunkTree_js_1 = require("./chunkTree.js");
14
14
  Object.defineProperty(exports, "chunkTree", { enumerable: true, get: function () { return chunkTree_js_1.chunkTree; } });
15
15
  Object.defineProperty(exports, "defaultChunkPolicy", { enumerable: true, get: function () { return chunkTree_js_1.defaultChunkPolicy; } });
@@ -18,7 +18,7 @@ Object.defineProperty(exports, "chunkFieldSingle", { enumerable: true, get: func
18
18
  Object.defineProperty(exports, "chunkField", { enumerable: true, get: function () { return chunkTree_js_1.chunkField; } });
19
19
  var chunkedForest_js_1 = require("./chunkedForest.js");
20
20
  Object.defineProperty(exports, "buildChunkedForest", { enumerable: true, get: function () { return chunkedForest_js_1.buildChunkedForest; } });
21
- var index_js_1 = require("./codec/index.js");
22
- Object.defineProperty(exports, "EncodedFieldBatch", { enumerable: true, get: function () { return index_js_1.EncodedFieldBatch; } });
23
- Object.defineProperty(exports, "makeFieldBatchCodec", { enumerable: true, get: function () { return index_js_1.makeFieldBatchCodec; } });
21
+ var index_js_2 = require("./codec/index.js");
22
+ Object.defineProperty(exports, "EncodedFieldBatch", { enumerable: true, get: function () { return index_js_2.EncodedFieldBatch; } });
23
+ Object.defineProperty(exports, "makeFieldBatchCodec", { enumerable: true, get: function () { return index_js_2.makeFieldBatchCodec; } });
24
24
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/feature-libraries/chunked-forest/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,qDAA6D;AAApD,+GAAA,YAAY,OAAA;AAAE,6GAAA,UAAU,OAAA;AACjC,uCAAuD;AAA9B,qGAAA,SAAS,OAAA;AAClC,+CAOwB;AANvB,yGAAA,SAAS,OAAA;AACT,kHAAA,kBAAkB,OAAA;AAClB,+GAAA,eAAe,OAAA;AAEf,gHAAA,gBAAgB,OAAA;AAChB,0GAAA,UAAU,OAAA;AAEX,uDAAwD;AAA/C,sHAAA,kBAAkB,OAAA;AAC3B,6CAM0B;AALzB,6GAAA,iBAAiB,OAAA;AAGjB,+GAAA,mBAAmB,OAAA","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport { uniformChunk, ChunkShape } from \"./uniformChunk.js\";\nexport { type TreeChunk, dummyRoot } from \"./chunk.js\";\nexport {\n\tchunkTree,\n\tdefaultChunkPolicy,\n\tmakeTreeChunker,\n\ttype IChunker,\n\tchunkFieldSingle,\n\tchunkField,\n} from \"./chunkTree.js\";\nexport { buildChunkedForest } from \"./chunkedForest.js\";\nexport {\n\tEncodedFieldBatch,\n\ttype FieldBatch,\n\ttype FieldBatchCodec,\n\tmakeFieldBatchCodec,\n\ttype FieldBatchEncodingContext,\n} from \"./codec/index.js\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/feature-libraries/chunked-forest/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,qDAA6D;AAApD,+GAAA,YAAY,OAAA;AAAE,6GAAA,UAAU,OAAA;AACjC,gDAAgE;AAAvC,qGAAA,SAAS,OAAA;AAClC,+CAOwB;AANvB,yGAAA,SAAS,OAAA;AACT,kHAAA,kBAAkB,OAAA;AAClB,+GAAA,eAAe,OAAA;AAEf,gHAAA,gBAAgB,OAAA;AAChB,0GAAA,UAAU,OAAA;AAEX,uDAAwD;AAA/C,sHAAA,kBAAkB,OAAA;AAC3B,6CAM0B;AALzB,6GAAA,iBAAiB,OAAA;AAGjB,+GAAA,mBAAmB,OAAA","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport { uniformChunk, ChunkShape } from \"./uniformChunk.js\";\nexport { type TreeChunk, dummyRoot } from \"../../core/index.js\";\nexport {\n\tchunkTree,\n\tdefaultChunkPolicy,\n\tmakeTreeChunker,\n\ttype IChunker,\n\tchunkFieldSingle,\n\tchunkField,\n} from \"./chunkTree.js\";\nexport { buildChunkedForest } from \"./chunkedForest.js\";\nexport {\n\tEncodedFieldBatch,\n\ttype FieldBatch,\n\ttype FieldBatchCodec,\n\tmakeFieldBatchCodec,\n\ttype FieldBatchEncodingContext,\n} from \"./codec/index.js\";\n"]}
@@ -3,7 +3,7 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
  import { ReferenceCountedBase } from "../../util/index.js";
6
- import { type ChunkedCursor, type TreeChunk } from "./chunk.js";
6
+ import { type ChunkedCursor, type TreeChunk } from "../../core/index.js";
7
7
  /**
8
8
  * General purpose multi-node sequence chunk.
9
9
  */
@@ -1 +1 @@
1
- {"version":3,"file":"sequenceChunk.d.ts","sourceRoot":"","sources":["../../../src/feature-libraries/chunked-forest/sequenceChunk.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAG3D,OAAO,EAAE,KAAK,aAAa,EAAE,KAAK,SAAS,EAAa,MAAM,YAAY,CAAC;AAE3E;;GAEG;AACH,qBAAa,aAAc,SAAQ,oBAAqB,YAAW,SAAS;aAiBxC,SAAS,EAAE,SAAS,EAAE;IAhBzD,IAAW,cAAc,IAAI,MAAM,CAMlC;IAED;;;;;;;OAOG;gBACgC,SAAS,EAAE,SAAS,EAAE;IAIlD,KAAK,IAAI,aAAa;IAQtB,MAAM,IAAI,aAAa;IAe9B,SAAS,CAAC,cAAc,IAAI,IAAI;CAKhC"}
1
+ {"version":3,"file":"sequenceChunk.d.ts","sourceRoot":"","sources":["../../../src/feature-libraries/chunked-forest/sequenceChunk.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAG3D,OAAO,EAAE,KAAK,aAAa,EAAE,KAAK,SAAS,EAAa,MAAM,qBAAqB,CAAC;AAEpF;;GAEG;AACH,qBAAa,aAAc,SAAQ,oBAAqB,YAAW,SAAS;aAiBxC,SAAS,EAAE,SAAS,EAAE;IAhBzD,IAAW,cAAc,IAAI,MAAM,CAMlC;IAED;;;;;;;OAOG;gBACgC,SAAS,EAAE,SAAS,EAAE;IAIlD,KAAK,IAAI,aAAa;IAQtB,MAAM,IAAI,aAAa;IAe9B,SAAS,CAAC,cAAc,IAAI,IAAI;CAKhC"}
@@ -7,7 +7,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
7
7
  exports.SequenceChunk = void 0;
8
8
  const index_js_1 = require("../../util/index.js");
9
9
  const basicChunk_js_1 = require("./basicChunk.js");
10
- const chunk_js_1 = require("./chunk.js");
10
+ const index_js_2 = require("../../core/index.js");
11
11
  /**
12
12
  * General purpose multi-node sequence chunk.
13
13
  */
@@ -39,7 +39,7 @@ class SequenceChunk extends index_js_1.ReferenceCountedBase {
39
39
  return new SequenceChunk(subChunks);
40
40
  }
41
41
  cursor() {
42
- return new basicChunk_js_1.BasicChunkCursor(this.subChunks, [], [], [], [], [chunk_js_1.dummyRoot], 0, 0, 0, undefined);
42
+ return new basicChunk_js_1.BasicChunkCursor(this.subChunks, [], [], [], [], [index_js_2.dummyRoot], 0, 0, 0, undefined);
43
43
  }
44
44
  onUnreferenced() {
45
45
  for (const child of this.subChunks) {
@@ -1 +1 @@
1
- {"version":3,"file":"sequenceChunk.js","sourceRoot":"","sources":["../../../src/feature-libraries/chunked-forest/sequenceChunk.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kDAA2D;AAE3D,mDAAmD;AACnD,yCAA2E;AAE3E;;GAEG;AACH,MAAa,aAAc,SAAQ,+BAAoB;IACtD,IAAW,cAAc;QACxB,IAAI,KAAK,GAAG,CAAC,CAAC;QACd,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;YACpC,KAAK,IAAI,KAAK,CAAC,cAAc,CAAC;QAC/B,CAAC;QACD,OAAO,KAAK,CAAC;IACd,CAAC;IAED;;;;;;;OAOG;IACH,YAAmC,SAAsB;QACxD,KAAK,EAAE,CAAC;QAD0B,cAAS,GAAT,SAAS,CAAa;IAEzD,CAAC;IAEM,KAAK;QACX,MAAM,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE;YAC9C,KAAK,CAAC,cAAc,EAAE,CAAC;YACvB,OAAO,KAAK,CAAC;QACd,CAAC,CAAC,CAAC;QACH,OAAO,IAAI,aAAa,CAAC,SAAS,CAAC,CAAC;IACrC,CAAC;IAEM,MAAM;QACZ,OAAO,IAAI,gCAAgB,CAC1B,IAAI,CAAC,SAAS,EACd,EAAE,EACF,EAAE,EACF,EAAE,EACF,EAAE,EACF,CAAC,oBAAS,CAAC,EACX,CAAC,EACD,CAAC,EACD,CAAC,EACD,SAAS,CACT,CAAC;IACH,CAAC;IAES,cAAc;QACvB,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;YACpC,KAAK,CAAC,gBAAgB,EAAE,CAAC;QAC1B,CAAC;IACF,CAAC;CACD;AAjDD,sCAiDC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ReferenceCountedBase } from \"../../util/index.js\";\n\nimport { BasicChunkCursor } from \"./basicChunk.js\";\nimport { type ChunkedCursor, type TreeChunk, dummyRoot } from \"./chunk.js\";\n\n/**\n * General purpose multi-node sequence chunk.\n */\nexport class SequenceChunk extends ReferenceCountedBase implements TreeChunk {\n\tpublic get topLevelLength(): number {\n\t\tlet total = 0;\n\t\tfor (const child of this.subChunks) {\n\t\t\ttotal += child.topLevelLength;\n\t\t}\n\t\treturn total;\n\t}\n\n\t/**\n\t * Create a tree chunk with ref count 1.\n\t *\n\t * @param fields - provides exclusive deep ownership of this map to this object (which might mutate it in the future).\n\t * The caller must have already accounted for this reference to the children in this map (via `referenceAdded`),\n\t * and any edits to this must update child reference counts.\n\t * @param value - the value on this node, if any.\n\t */\n\tpublic constructor(public readonly subChunks: TreeChunk[]) {\n\t\tsuper();\n\t}\n\n\tpublic clone(): SequenceChunk {\n\t\tconst subChunks = this.subChunks.map((child) => {\n\t\t\tchild.referenceAdded();\n\t\t\treturn child;\n\t\t});\n\t\treturn new SequenceChunk(subChunks);\n\t}\n\n\tpublic cursor(): ChunkedCursor {\n\t\treturn new BasicChunkCursor(\n\t\t\tthis.subChunks,\n\t\t\t[],\n\t\t\t[],\n\t\t\t[],\n\t\t\t[],\n\t\t\t[dummyRoot],\n\t\t\t0,\n\t\t\t0,\n\t\t\t0,\n\t\t\tundefined,\n\t\t);\n\t}\n\n\tprotected onUnreferenced(): void {\n\t\tfor (const child of this.subChunks) {\n\t\t\tchild.referenceRemoved();\n\t\t}\n\t}\n}\n"]}
1
+ {"version":3,"file":"sequenceChunk.js","sourceRoot":"","sources":["../../../src/feature-libraries/chunked-forest/sequenceChunk.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kDAA2D;AAE3D,mDAAmD;AACnD,kDAAoF;AAEpF;;GAEG;AACH,MAAa,aAAc,SAAQ,+BAAoB;IACtD,IAAW,cAAc;QACxB,IAAI,KAAK,GAAG,CAAC,CAAC;QACd,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;YACpC,KAAK,IAAI,KAAK,CAAC,cAAc,CAAC;QAC/B,CAAC;QACD,OAAO,KAAK,CAAC;IACd,CAAC;IAED;;;;;;;OAOG;IACH,YAAmC,SAAsB;QACxD,KAAK,EAAE,CAAC;QAD0B,cAAS,GAAT,SAAS,CAAa;IAEzD,CAAC;IAEM,KAAK;QACX,MAAM,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE;YAC9C,KAAK,CAAC,cAAc,EAAE,CAAC;YACvB,OAAO,KAAK,CAAC;QACd,CAAC,CAAC,CAAC;QACH,OAAO,IAAI,aAAa,CAAC,SAAS,CAAC,CAAC;IACrC,CAAC;IAEM,MAAM;QACZ,OAAO,IAAI,gCAAgB,CAC1B,IAAI,CAAC,SAAS,EACd,EAAE,EACF,EAAE,EACF,EAAE,EACF,EAAE,EACF,CAAC,oBAAS,CAAC,EACX,CAAC,EACD,CAAC,EACD,CAAC,EACD,SAAS,CACT,CAAC;IACH,CAAC;IAES,cAAc;QACvB,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;YACpC,KAAK,CAAC,gBAAgB,EAAE,CAAC;QAC1B,CAAC;IACF,CAAC;CACD;AAjDD,sCAiDC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ReferenceCountedBase } from \"../../util/index.js\";\n\nimport { BasicChunkCursor } from \"./basicChunk.js\";\nimport { type ChunkedCursor, type TreeChunk, dummyRoot } from \"../../core/index.js\";\n\n/**\n * General purpose multi-node sequence chunk.\n */\nexport class SequenceChunk extends ReferenceCountedBase implements TreeChunk {\n\tpublic get topLevelLength(): number {\n\t\tlet total = 0;\n\t\tfor (const child of this.subChunks) {\n\t\t\ttotal += child.topLevelLength;\n\t\t}\n\t\treturn total;\n\t}\n\n\t/**\n\t * Create a tree chunk with ref count 1.\n\t *\n\t * @param fields - provides exclusive deep ownership of this map to this object (which might mutate it in the future).\n\t * The caller must have already accounted for this reference to the children in this map (via `referenceAdded`),\n\t * and any edits to this must update child reference counts.\n\t * @param value - the value on this node, if any.\n\t */\n\tpublic constructor(public readonly subChunks: TreeChunk[]) {\n\t\tsuper();\n\t}\n\n\tpublic clone(): SequenceChunk {\n\t\tconst subChunks = this.subChunks.map((child) => {\n\t\t\tchild.referenceAdded();\n\t\t\treturn child;\n\t\t});\n\t\treturn new SequenceChunk(subChunks);\n\t}\n\n\tpublic cursor(): ChunkedCursor {\n\t\treturn new BasicChunkCursor(\n\t\t\tthis.subChunks,\n\t\t\t[],\n\t\t\t[],\n\t\t\t[],\n\t\t\t[],\n\t\t\t[dummyRoot],\n\t\t\t0,\n\t\t\t0,\n\t\t\t0,\n\t\t\tundefined,\n\t\t);\n\t}\n\n\tprotected onUnreferenced(): void {\n\t\tfor (const child of this.subChunks) {\n\t\t\tchild.referenceRemoved();\n\t\t}\n\t}\n}\n"]}
@@ -2,10 +2,9 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
- import { CursorLocationType, type FieldKey, type FieldUpPath, type PathRootPrefix, type TreeNodeSchemaIdentifier, type TreeValue, type UpPath, type Value } from "../../core/index.js";
5
+ import { CursorLocationType, type FieldKey, type FieldUpPath, type PathRootPrefix, type TreeNodeSchemaIdentifier, type TreeValue, type UpPath, type Value, type ChunkedCursor, type TreeChunk, cursorChunk } from "../../core/index.js";
6
6
  import { ReferenceCountedBase } from "../../util/index.js";
7
7
  import { SynchronousCursor } from "../treeCursorUtils.js";
8
- import { type ChunkedCursor, type TreeChunk, cursorChunk } from "./chunk.js";
9
8
  import type { IIdCompressor } from "@fluidframework/id-compressor";
10
9
  /**
11
10
  * Create a tree chunk with ref count 1.