@fluidframework/tree 2.53.1 → 2.61.0-355054

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 (452) hide show
  1. package/.eslintrc.cjs +0 -19
  2. package/.mocharc.cjs +2 -3
  3. package/.mocharc.customBenchmarks.cjs +1 -9
  4. package/CHANGELOG.md +56 -0
  5. package/alpha.d.ts +1 -1
  6. package/api-report/tree.alpha.api.md +51 -37
  7. package/api-report/tree.beta.api.md +16 -2
  8. package/api-report/{tree.legacy.alpha.api.md → tree.legacy.beta.api.md} +72 -6
  9. package/api-report/tree.legacy.public.api.md +2 -2
  10. package/api-report/tree.public.api.md +2 -2
  11. package/beta.d.ts +1 -1
  12. package/dist/alpha.d.ts +17 -7
  13. package/dist/beta.d.ts +10 -4
  14. package/dist/codec/codec.d.ts +43 -6
  15. package/dist/codec/codec.d.ts.map +1 -1
  16. package/dist/codec/codec.js +22 -2
  17. package/dist/codec/codec.js.map +1 -1
  18. package/dist/codec/index.d.ts +1 -1
  19. package/dist/codec/index.d.ts.map +1 -1
  20. package/dist/codec/index.js +4 -1
  21. package/dist/codec/index.js.map +1 -1
  22. package/dist/external-utilities/index.d.ts +1 -1
  23. package/dist/external-utilities/index.d.ts.map +1 -1
  24. package/dist/external-utilities/index.js +2 -1
  25. package/dist/external-utilities/index.js.map +1 -1
  26. package/dist/external-utilities/typeboxValidator.d.ts +6 -1
  27. package/dist/external-utilities/typeboxValidator.d.ts.map +1 -1
  28. package/dist/external-utilities/typeboxValidator.js +7 -1
  29. package/dist/external-utilities/typeboxValidator.js.map +1 -1
  30. package/dist/feature-libraries/chunked-forest/codec/chunkDecoding.d.ts +10 -1
  31. package/dist/feature-libraries/chunked-forest/codec/chunkDecoding.d.ts.map +1 -1
  32. package/dist/feature-libraries/chunked-forest/codec/chunkDecoding.js +28 -5
  33. package/dist/feature-libraries/chunked-forest/codec/chunkDecoding.js.map +1 -1
  34. package/dist/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.d.ts +19 -2
  35. package/dist/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.d.ts.map +1 -1
  36. package/dist/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.js +10 -2
  37. package/dist/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.js.map +1 -1
  38. package/dist/feature-libraries/chunked-forest/codec/codecs.d.ts +59 -4
  39. package/dist/feature-libraries/chunked-forest/codec/codecs.d.ts.map +1 -1
  40. package/dist/feature-libraries/chunked-forest/codec/codecs.js +9 -2
  41. package/dist/feature-libraries/chunked-forest/codec/codecs.js.map +1 -1
  42. package/dist/feature-libraries/chunked-forest/codec/compressedEncode.d.ts +46 -8
  43. package/dist/feature-libraries/chunked-forest/codec/compressedEncode.d.ts.map +1 -1
  44. package/dist/feature-libraries/chunked-forest/codec/compressedEncode.js +91 -16
  45. package/dist/feature-libraries/chunked-forest/codec/compressedEncode.js.map +1 -1
  46. package/dist/feature-libraries/chunked-forest/codec/format.d.ts +14 -0
  47. package/dist/feature-libraries/chunked-forest/codec/format.d.ts.map +1 -1
  48. package/dist/feature-libraries/chunked-forest/codec/format.js +10 -1
  49. package/dist/feature-libraries/chunked-forest/codec/format.js.map +1 -1
  50. package/dist/feature-libraries/chunked-forest/codec/index.d.ts +1 -1
  51. package/dist/feature-libraries/chunked-forest/codec/index.d.ts.map +1 -1
  52. package/dist/feature-libraries/chunked-forest/codec/index.js.map +1 -1
  53. package/dist/feature-libraries/chunked-forest/codec/schemaBasedEncode.d.ts +8 -3
  54. package/dist/feature-libraries/chunked-forest/codec/schemaBasedEncode.d.ts.map +1 -1
  55. package/dist/feature-libraries/chunked-forest/codec/schemaBasedEncode.js +17 -6
  56. package/dist/feature-libraries/chunked-forest/codec/schemaBasedEncode.js.map +1 -1
  57. package/dist/feature-libraries/chunked-forest/index.d.ts +1 -1
  58. package/dist/feature-libraries/chunked-forest/index.d.ts.map +1 -1
  59. package/dist/feature-libraries/chunked-forest/index.js.map +1 -1
  60. package/dist/feature-libraries/forest-summary/codec.d.ts.map +1 -1
  61. package/dist/feature-libraries/forest-summary/codec.js +3 -0
  62. package/dist/feature-libraries/forest-summary/codec.js.map +1 -1
  63. package/dist/feature-libraries/forest-summary/forestSummarizer.d.ts +13 -8
  64. package/dist/feature-libraries/forest-summary/forestSummarizer.d.ts.map +1 -1
  65. package/dist/feature-libraries/forest-summary/forestSummarizer.js +76 -38
  66. package/dist/feature-libraries/forest-summary/forestSummarizer.js.map +1 -1
  67. package/dist/feature-libraries/forest-summary/incrementalSummaryBuilder.d.ts +178 -0
  68. package/dist/feature-libraries/forest-summary/incrementalSummaryBuilder.d.ts.map +1 -0
  69. package/dist/feature-libraries/forest-summary/incrementalSummaryBuilder.js +322 -0
  70. package/dist/feature-libraries/forest-summary/incrementalSummaryBuilder.js.map +1 -0
  71. package/dist/feature-libraries/forest-summary/index.d.ts +1 -1
  72. package/dist/feature-libraries/forest-summary/index.d.ts.map +1 -1
  73. package/dist/feature-libraries/forest-summary/index.js +2 -1
  74. package/dist/feature-libraries/forest-summary/index.js.map +1 -1
  75. package/dist/feature-libraries/index.d.ts +1 -1
  76. package/dist/feature-libraries/index.d.ts.map +1 -1
  77. package/dist/feature-libraries/index.js +2 -1
  78. package/dist/feature-libraries/index.js.map +1 -1
  79. package/dist/feature-libraries/modular-schema/modularChangeCodecs.d.ts +2 -2
  80. package/dist/feature-libraries/modular-schema/modularChangeCodecs.d.ts.map +1 -1
  81. package/dist/feature-libraries/modular-schema/modularChangeCodecs.js +1 -1
  82. package/dist/feature-libraries/modular-schema/modularChangeCodecs.js.map +1 -1
  83. package/dist/feature-libraries/modular-schema/modularChangeFormat.d.ts +6 -9
  84. package/dist/feature-libraries/modular-schema/modularChangeFormat.d.ts.map +1 -1
  85. package/dist/feature-libraries/treeCompressionUtils.d.ts +15 -0
  86. package/dist/feature-libraries/treeCompressionUtils.d.ts.map +1 -1
  87. package/dist/feature-libraries/treeCompressionUtils.js +16 -1
  88. package/dist/feature-libraries/treeCompressionUtils.js.map +1 -1
  89. package/dist/index.d.ts +3 -3
  90. package/dist/index.d.ts.map +1 -1
  91. package/dist/index.js +6 -2
  92. package/dist/index.js.map +1 -1
  93. package/dist/jsonDomainSchema.d.ts +1 -1
  94. package/dist/jsonDomainSchema.d.ts.map +1 -1
  95. package/dist/legacy.d.ts +21 -4
  96. package/dist/packageVersion.d.ts +1 -1
  97. package/dist/packageVersion.d.ts.map +1 -1
  98. package/dist/packageVersion.js +1 -1
  99. package/dist/packageVersion.js.map +1 -1
  100. package/dist/public.d.ts +5 -3
  101. package/dist/shared-tree/schematizingTreeView.d.ts +1 -1
  102. package/dist/shared-tree/schematizingTreeView.d.ts.map +1 -1
  103. package/dist/shared-tree/schematizingTreeView.js.map +1 -1
  104. package/dist/shared-tree/sharedTree.d.ts +23 -6
  105. package/dist/shared-tree/sharedTree.d.ts.map +1 -1
  106. package/dist/shared-tree/sharedTree.js +4 -1
  107. package/dist/shared-tree/sharedTree.js.map +1 -1
  108. package/dist/shared-tree/sharedTreeChangeFamily.d.ts +2 -2
  109. package/dist/shared-tree/sharedTreeChangeFamily.d.ts.map +1 -1
  110. package/dist/shared-tree/sharedTreeChangeFamily.js.map +1 -1
  111. package/dist/shared-tree/tree.d.ts.map +1 -1
  112. package/dist/shared-tree/tree.js +3 -0
  113. package/dist/shared-tree/tree.js.map +1 -1
  114. package/dist/shared-tree/treeAlpha.d.ts +9 -11
  115. package/dist/shared-tree/treeAlpha.d.ts.map +1 -1
  116. package/dist/shared-tree/treeAlpha.js.map +1 -1
  117. package/dist/shared-tree/treeCheckout.d.ts +2 -2
  118. package/dist/shared-tree/treeCheckout.d.ts.map +1 -1
  119. package/dist/shared-tree/treeCheckout.js +1 -0
  120. package/dist/shared-tree/treeCheckout.js.map +1 -1
  121. package/dist/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
  122. package/dist/shared-tree-core/sharedTreeCore.js +13 -0
  123. package/dist/shared-tree-core/sharedTreeCore.js.map +1 -1
  124. package/dist/sharedTreeAttributes.d.ts +2 -2
  125. package/dist/sharedTreeAttributes.js +2 -2
  126. package/dist/sharedTreeAttributes.js.map +1 -1
  127. package/dist/simple-tree/api/conciseTree.d.ts.map +1 -1
  128. package/dist/simple-tree/api/conciseTree.js +1 -1
  129. package/dist/simple-tree/api/conciseTree.js.map +1 -1
  130. package/dist/simple-tree/api/customTree.d.ts +39 -11
  131. package/dist/simple-tree/api/customTree.d.ts.map +1 -1
  132. package/dist/simple-tree/api/customTree.js +79 -19
  133. package/dist/simple-tree/api/customTree.js.map +1 -1
  134. package/dist/simple-tree/api/getJsonSchema.d.ts +7 -2
  135. package/dist/simple-tree/api/getJsonSchema.d.ts.map +1 -1
  136. package/dist/simple-tree/api/getJsonSchema.js +1 -0
  137. package/dist/simple-tree/api/getJsonSchema.js.map +1 -1
  138. package/dist/simple-tree/api/index.d.ts +2 -1
  139. package/dist/simple-tree/api/index.d.ts.map +1 -1
  140. package/dist/simple-tree/api/index.js +4 -1
  141. package/dist/simple-tree/api/index.js.map +1 -1
  142. package/dist/simple-tree/api/schemaCreationUtilities.d.ts +1 -1
  143. package/dist/simple-tree/api/schemaCreationUtilities.js +1 -1
  144. package/dist/simple-tree/api/schemaCreationUtilities.js.map +1 -1
  145. package/dist/simple-tree/api/schemaFactory.d.ts +9 -6
  146. package/dist/simple-tree/api/schemaFactory.d.ts.map +1 -1
  147. package/dist/simple-tree/api/schemaFactory.js +8 -7
  148. package/dist/simple-tree/api/schemaFactory.js.map +1 -1
  149. package/dist/simple-tree/api/schemaFactoryAlpha.d.ts +13 -17
  150. package/dist/simple-tree/api/schemaFactoryAlpha.d.ts.map +1 -1
  151. package/dist/simple-tree/api/schemaFactoryAlpha.js +21 -25
  152. package/dist/simple-tree/api/schemaFactoryAlpha.js.map +1 -1
  153. package/dist/simple-tree/api/schemaFactoryBeta.d.ts +20 -0
  154. package/dist/simple-tree/api/schemaFactoryBeta.d.ts.map +1 -0
  155. package/dist/simple-tree/api/schemaFactoryBeta.js +26 -0
  156. package/dist/simple-tree/api/schemaFactoryBeta.js.map +1 -0
  157. package/dist/simple-tree/api/schemaFactoryRecursive.d.ts +5 -3
  158. package/dist/simple-tree/api/schemaFactoryRecursive.d.ts.map +1 -1
  159. package/dist/simple-tree/api/schemaFactoryRecursive.js.map +1 -1
  160. package/dist/simple-tree/api/simpleSchemaToJsonSchema.d.ts +0 -2
  161. package/dist/simple-tree/api/simpleSchemaToJsonSchema.d.ts.map +1 -1
  162. package/dist/simple-tree/api/simpleSchemaToJsonSchema.js +6 -3
  163. package/dist/simple-tree/api/simpleSchemaToJsonSchema.js.map +1 -1
  164. package/dist/simple-tree/api/transactionTypes.d.ts +1 -0
  165. package/dist/simple-tree/api/transactionTypes.d.ts.map +1 -1
  166. package/dist/simple-tree/api/transactionTypes.js.map +1 -1
  167. package/dist/simple-tree/api/tree.d.ts +68 -74
  168. package/dist/simple-tree/api/tree.d.ts.map +1 -1
  169. package/dist/simple-tree/api/tree.js.map +1 -1
  170. package/dist/simple-tree/api/verboseTree.d.ts.map +1 -1
  171. package/dist/simple-tree/api/verboseTree.js +3 -3
  172. package/dist/simple-tree/api/verboseTree.js.map +1 -1
  173. package/dist/simple-tree/core/simpleNodeSchemaBase.d.ts +6 -0
  174. package/dist/simple-tree/core/simpleNodeSchemaBase.d.ts.map +1 -1
  175. package/dist/simple-tree/core/simpleNodeSchemaBase.js.map +1 -1
  176. package/dist/simple-tree/fieldSchema.d.ts +3 -4
  177. package/dist/simple-tree/fieldSchema.d.ts.map +1 -1
  178. package/dist/simple-tree/fieldSchema.js +0 -3
  179. package/dist/simple-tree/fieldSchema.js.map +1 -1
  180. package/dist/simple-tree/index.d.ts +1 -1
  181. package/dist/simple-tree/index.d.ts.map +1 -1
  182. package/dist/simple-tree/index.js +4 -2
  183. package/dist/simple-tree/index.js.map +1 -1
  184. package/dist/simple-tree/node-kinds/record/recordNode.d.ts.map +1 -1
  185. package/dist/simple-tree/node-kinds/record/recordNode.js +2 -3
  186. package/dist/simple-tree/node-kinds/record/recordNode.js.map +1 -1
  187. package/dist/simple-tree/simpleSchema.d.ts +12 -0
  188. package/dist/simple-tree/simpleSchema.d.ts.map +1 -1
  189. package/dist/simple-tree/simpleSchema.js.map +1 -1
  190. package/dist/simple-tree/toStoredSchema.d.ts +0 -3
  191. package/dist/simple-tree/toStoredSchema.d.ts.map +1 -1
  192. package/dist/simple-tree/toStoredSchema.js +0 -3
  193. package/dist/simple-tree/toStoredSchema.js.map +1 -1
  194. package/dist/tableSchema.d.ts +11 -80
  195. package/dist/tableSchema.d.ts.map +1 -1
  196. package/dist/tableSchema.js +200 -117
  197. package/dist/tableSchema.js.map +1 -1
  198. package/dist/treeFactory.d.ts +1 -2
  199. package/dist/treeFactory.d.ts.map +1 -1
  200. package/dist/treeFactory.js +1 -2
  201. package/dist/treeFactory.js.map +1 -1
  202. package/dist/util/breakable.d.ts.map +1 -1
  203. package/dist/util/breakable.js +7 -1
  204. package/dist/util/breakable.js.map +1 -1
  205. package/internal.d.ts +1 -1
  206. package/legacy.d.ts +1 -1
  207. package/lib/alpha.d.ts +17 -7
  208. package/lib/beta.d.ts +10 -4
  209. package/lib/codec/codec.d.ts +43 -6
  210. package/lib/codec/codec.d.ts.map +1 -1
  211. package/lib/codec/codec.js +19 -1
  212. package/lib/codec/codec.js.map +1 -1
  213. package/lib/codec/index.d.ts +1 -1
  214. package/lib/codec/index.d.ts.map +1 -1
  215. package/lib/codec/index.js +1 -1
  216. package/lib/codec/index.js.map +1 -1
  217. package/lib/external-utilities/index.d.ts +1 -1
  218. package/lib/external-utilities/index.d.ts.map +1 -1
  219. package/lib/external-utilities/index.js +1 -1
  220. package/lib/external-utilities/index.js.map +1 -1
  221. package/lib/external-utilities/typeboxValidator.d.ts +6 -1
  222. package/lib/external-utilities/typeboxValidator.d.ts.map +1 -1
  223. package/lib/external-utilities/typeboxValidator.js +6 -0
  224. package/lib/external-utilities/typeboxValidator.js.map +1 -1
  225. package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.d.ts +10 -1
  226. package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.d.ts.map +1 -1
  227. package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.js +27 -5
  228. package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.js.map +1 -1
  229. package/lib/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.d.ts +19 -2
  230. package/lib/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.d.ts.map +1 -1
  231. package/lib/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.js +10 -2
  232. package/lib/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.js.map +1 -1
  233. package/lib/feature-libraries/chunked-forest/codec/codecs.d.ts +59 -4
  234. package/lib/feature-libraries/chunked-forest/codec/codecs.d.ts.map +1 -1
  235. package/lib/feature-libraries/chunked-forest/codec/codecs.js +10 -3
  236. package/lib/feature-libraries/chunked-forest/codec/codecs.js.map +1 -1
  237. package/lib/feature-libraries/chunked-forest/codec/compressedEncode.d.ts +46 -8
  238. package/lib/feature-libraries/chunked-forest/codec/compressedEncode.d.ts.map +1 -1
  239. package/lib/feature-libraries/chunked-forest/codec/compressedEncode.js +87 -14
  240. package/lib/feature-libraries/chunked-forest/codec/compressedEncode.js.map +1 -1
  241. package/lib/feature-libraries/chunked-forest/codec/format.d.ts +14 -0
  242. package/lib/feature-libraries/chunked-forest/codec/format.d.ts.map +1 -1
  243. package/lib/feature-libraries/chunked-forest/codec/format.js +9 -0
  244. package/lib/feature-libraries/chunked-forest/codec/format.js.map +1 -1
  245. package/lib/feature-libraries/chunked-forest/codec/index.d.ts +1 -1
  246. package/lib/feature-libraries/chunked-forest/codec/index.d.ts.map +1 -1
  247. package/lib/feature-libraries/chunked-forest/codec/index.js.map +1 -1
  248. package/lib/feature-libraries/chunked-forest/codec/schemaBasedEncode.d.ts +8 -3
  249. package/lib/feature-libraries/chunked-forest/codec/schemaBasedEncode.d.ts.map +1 -1
  250. package/lib/feature-libraries/chunked-forest/codec/schemaBasedEncode.js +18 -7
  251. package/lib/feature-libraries/chunked-forest/codec/schemaBasedEncode.js.map +1 -1
  252. package/lib/feature-libraries/chunked-forest/index.d.ts +1 -1
  253. package/lib/feature-libraries/chunked-forest/index.d.ts.map +1 -1
  254. package/lib/feature-libraries/chunked-forest/index.js.map +1 -1
  255. package/lib/feature-libraries/forest-summary/codec.d.ts.map +1 -1
  256. package/lib/feature-libraries/forest-summary/codec.js +3 -0
  257. package/lib/feature-libraries/forest-summary/codec.js.map +1 -1
  258. package/lib/feature-libraries/forest-summary/forestSummarizer.d.ts +13 -8
  259. package/lib/feature-libraries/forest-summary/forestSummarizer.d.ts.map +1 -1
  260. package/lib/feature-libraries/forest-summary/forestSummarizer.js +75 -37
  261. package/lib/feature-libraries/forest-summary/forestSummarizer.js.map +1 -1
  262. package/lib/feature-libraries/forest-summary/incrementalSummaryBuilder.d.ts +178 -0
  263. package/lib/feature-libraries/forest-summary/incrementalSummaryBuilder.d.ts.map +1 -0
  264. package/lib/feature-libraries/forest-summary/incrementalSummaryBuilder.js +318 -0
  265. package/lib/feature-libraries/forest-summary/incrementalSummaryBuilder.js.map +1 -0
  266. package/lib/feature-libraries/forest-summary/index.d.ts +1 -1
  267. package/lib/feature-libraries/forest-summary/index.d.ts.map +1 -1
  268. package/lib/feature-libraries/forest-summary/index.js +1 -1
  269. package/lib/feature-libraries/forest-summary/index.js.map +1 -1
  270. package/lib/feature-libraries/index.d.ts +1 -1
  271. package/lib/feature-libraries/index.d.ts.map +1 -1
  272. package/lib/feature-libraries/index.js +1 -1
  273. package/lib/feature-libraries/index.js.map +1 -1
  274. package/lib/feature-libraries/modular-schema/modularChangeCodecs.d.ts +2 -2
  275. package/lib/feature-libraries/modular-schema/modularChangeCodecs.d.ts.map +1 -1
  276. package/lib/feature-libraries/modular-schema/modularChangeCodecs.js +3 -3
  277. package/lib/feature-libraries/modular-schema/modularChangeCodecs.js.map +1 -1
  278. package/lib/feature-libraries/modular-schema/modularChangeFormat.d.ts +6 -9
  279. package/lib/feature-libraries/modular-schema/modularChangeFormat.d.ts.map +1 -1
  280. package/lib/feature-libraries/treeCompressionUtils.d.ts +15 -0
  281. package/lib/feature-libraries/treeCompressionUtils.d.ts.map +1 -1
  282. package/lib/feature-libraries/treeCompressionUtils.js +15 -0
  283. package/lib/feature-libraries/treeCompressionUtils.js.map +1 -1
  284. package/lib/index.d.ts +3 -3
  285. package/lib/index.d.ts.map +1 -1
  286. package/lib/index.js +4 -4
  287. package/lib/index.js.map +1 -1
  288. package/lib/jsonDomainSchema.d.ts +1 -1
  289. package/lib/jsonDomainSchema.d.ts.map +1 -1
  290. package/lib/legacy.d.ts +21 -4
  291. package/lib/packageVersion.d.ts +1 -1
  292. package/lib/packageVersion.d.ts.map +1 -1
  293. package/lib/packageVersion.js +1 -1
  294. package/lib/packageVersion.js.map +1 -1
  295. package/lib/public.d.ts +5 -3
  296. package/lib/shared-tree/schematizingTreeView.d.ts +1 -1
  297. package/lib/shared-tree/schematizingTreeView.d.ts.map +1 -1
  298. package/lib/shared-tree/schematizingTreeView.js.map +1 -1
  299. package/lib/shared-tree/sharedTree.d.ts +23 -6
  300. package/lib/shared-tree/sharedTree.d.ts.map +1 -1
  301. package/lib/shared-tree/sharedTree.js +4 -1
  302. package/lib/shared-tree/sharedTree.js.map +1 -1
  303. package/lib/shared-tree/sharedTreeChangeFamily.d.ts +2 -2
  304. package/lib/shared-tree/sharedTreeChangeFamily.d.ts.map +1 -1
  305. package/lib/shared-tree/sharedTreeChangeFamily.js.map +1 -1
  306. package/lib/shared-tree/tree.d.ts.map +1 -1
  307. package/lib/shared-tree/tree.js +3 -0
  308. package/lib/shared-tree/tree.js.map +1 -1
  309. package/lib/shared-tree/treeAlpha.d.ts +9 -11
  310. package/lib/shared-tree/treeAlpha.d.ts.map +1 -1
  311. package/lib/shared-tree/treeAlpha.js.map +1 -1
  312. package/lib/shared-tree/treeCheckout.d.ts +2 -2
  313. package/lib/shared-tree/treeCheckout.d.ts.map +1 -1
  314. package/lib/shared-tree/treeCheckout.js +1 -0
  315. package/lib/shared-tree/treeCheckout.js.map +1 -1
  316. package/lib/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
  317. package/lib/shared-tree-core/sharedTreeCore.js +13 -0
  318. package/lib/shared-tree-core/sharedTreeCore.js.map +1 -1
  319. package/lib/sharedTreeAttributes.d.ts +2 -2
  320. package/lib/sharedTreeAttributes.js +2 -2
  321. package/lib/sharedTreeAttributes.js.map +1 -1
  322. package/lib/simple-tree/api/conciseTree.d.ts.map +1 -1
  323. package/lib/simple-tree/api/conciseTree.js +2 -2
  324. package/lib/simple-tree/api/conciseTree.js.map +1 -1
  325. package/lib/simple-tree/api/customTree.d.ts +39 -11
  326. package/lib/simple-tree/api/customTree.d.ts.map +1 -1
  327. package/lib/simple-tree/api/customTree.js +79 -19
  328. package/lib/simple-tree/api/customTree.js.map +1 -1
  329. package/lib/simple-tree/api/getJsonSchema.d.ts +7 -2
  330. package/lib/simple-tree/api/getJsonSchema.d.ts.map +1 -1
  331. package/lib/simple-tree/api/getJsonSchema.js +1 -0
  332. package/lib/simple-tree/api/getJsonSchema.js.map +1 -1
  333. package/lib/simple-tree/api/index.d.ts +2 -1
  334. package/lib/simple-tree/api/index.d.ts.map +1 -1
  335. package/lib/simple-tree/api/index.js +2 -1
  336. package/lib/simple-tree/api/index.js.map +1 -1
  337. package/lib/simple-tree/api/schemaCreationUtilities.d.ts +1 -1
  338. package/lib/simple-tree/api/schemaCreationUtilities.js +1 -1
  339. package/lib/simple-tree/api/schemaCreationUtilities.js.map +1 -1
  340. package/lib/simple-tree/api/schemaFactory.d.ts +9 -6
  341. package/lib/simple-tree/api/schemaFactory.d.ts.map +1 -1
  342. package/lib/simple-tree/api/schemaFactory.js +6 -6
  343. package/lib/simple-tree/api/schemaFactory.js.map +1 -1
  344. package/lib/simple-tree/api/schemaFactoryAlpha.d.ts +13 -17
  345. package/lib/simple-tree/api/schemaFactoryAlpha.d.ts.map +1 -1
  346. package/lib/simple-tree/api/schemaFactoryAlpha.js +22 -26
  347. package/lib/simple-tree/api/schemaFactoryAlpha.js.map +1 -1
  348. package/lib/simple-tree/api/schemaFactoryBeta.d.ts +20 -0
  349. package/lib/simple-tree/api/schemaFactoryBeta.d.ts.map +1 -0
  350. package/lib/simple-tree/api/schemaFactoryBeta.js +22 -0
  351. package/lib/simple-tree/api/schemaFactoryBeta.js.map +1 -0
  352. package/lib/simple-tree/api/schemaFactoryRecursive.d.ts +5 -3
  353. package/lib/simple-tree/api/schemaFactoryRecursive.d.ts.map +1 -1
  354. package/lib/simple-tree/api/schemaFactoryRecursive.js.map +1 -1
  355. package/lib/simple-tree/api/simpleSchemaToJsonSchema.d.ts +0 -2
  356. package/lib/simple-tree/api/simpleSchemaToJsonSchema.d.ts.map +1 -1
  357. package/lib/simple-tree/api/simpleSchemaToJsonSchema.js +6 -3
  358. package/lib/simple-tree/api/simpleSchemaToJsonSchema.js.map +1 -1
  359. package/lib/simple-tree/api/transactionTypes.d.ts +1 -0
  360. package/lib/simple-tree/api/transactionTypes.d.ts.map +1 -1
  361. package/lib/simple-tree/api/transactionTypes.js.map +1 -1
  362. package/lib/simple-tree/api/tree.d.ts +68 -74
  363. package/lib/simple-tree/api/tree.d.ts.map +1 -1
  364. package/lib/simple-tree/api/tree.js.map +1 -1
  365. package/lib/simple-tree/api/verboseTree.d.ts.map +1 -1
  366. package/lib/simple-tree/api/verboseTree.js +4 -4
  367. package/lib/simple-tree/api/verboseTree.js.map +1 -1
  368. package/lib/simple-tree/core/simpleNodeSchemaBase.d.ts +6 -0
  369. package/lib/simple-tree/core/simpleNodeSchemaBase.d.ts.map +1 -1
  370. package/lib/simple-tree/core/simpleNodeSchemaBase.js.map +1 -1
  371. package/lib/simple-tree/fieldSchema.d.ts +3 -4
  372. package/lib/simple-tree/fieldSchema.d.ts.map +1 -1
  373. package/lib/simple-tree/fieldSchema.js +0 -3
  374. package/lib/simple-tree/fieldSchema.js.map +1 -1
  375. package/lib/simple-tree/index.d.ts +1 -1
  376. package/lib/simple-tree/index.d.ts.map +1 -1
  377. package/lib/simple-tree/index.js +1 -1
  378. package/lib/simple-tree/index.js.map +1 -1
  379. package/lib/simple-tree/node-kinds/record/recordNode.d.ts.map +1 -1
  380. package/lib/simple-tree/node-kinds/record/recordNode.js +2 -3
  381. package/lib/simple-tree/node-kinds/record/recordNode.js.map +1 -1
  382. package/lib/simple-tree/simpleSchema.d.ts +12 -0
  383. package/lib/simple-tree/simpleSchema.d.ts.map +1 -1
  384. package/lib/simple-tree/simpleSchema.js.map +1 -1
  385. package/lib/simple-tree/toStoredSchema.d.ts +0 -3
  386. package/lib/simple-tree/toStoredSchema.d.ts.map +1 -1
  387. package/lib/simple-tree/toStoredSchema.js +0 -3
  388. package/lib/simple-tree/toStoredSchema.js.map +1 -1
  389. package/lib/tableSchema.d.ts +11 -80
  390. package/lib/tableSchema.d.ts.map +1 -1
  391. package/lib/tableSchema.js +201 -118
  392. package/lib/tableSchema.js.map +1 -1
  393. package/lib/treeFactory.d.ts +1 -2
  394. package/lib/treeFactory.d.ts.map +1 -1
  395. package/lib/treeFactory.js +1 -2
  396. package/lib/treeFactory.js.map +1 -1
  397. package/lib/tsdoc-metadata.json +1 -1
  398. package/lib/util/breakable.d.ts.map +1 -1
  399. package/lib/util/breakable.js +7 -1
  400. package/lib/util/breakable.js.map +1 -1
  401. package/package.json +28 -28
  402. package/src/codec/codec.ts +52 -7
  403. package/src/codec/index.ts +4 -0
  404. package/src/external-utilities/index.ts +1 -1
  405. package/src/external-utilities/typeboxValidator.ts +7 -1
  406. package/src/feature-libraries/chunked-forest/codec/chunkDecoding.ts +38 -4
  407. package/src/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.ts +10 -3
  408. package/src/feature-libraries/chunked-forest/codec/codecs.ts +96 -8
  409. package/src/feature-libraries/chunked-forest/codec/compressedEncode.ts +123 -19
  410. package/src/feature-libraries/chunked-forest/codec/format.ts +11 -0
  411. package/src/feature-libraries/chunked-forest/codec/index.ts +4 -0
  412. package/src/feature-libraries/chunked-forest/codec/schemaBasedEncode.ts +28 -3
  413. package/src/feature-libraries/chunked-forest/index.ts +2 -0
  414. package/src/feature-libraries/forest-summary/codec.ts +3 -0
  415. package/src/feature-libraries/forest-summary/forestSummarizer.ts +118 -50
  416. package/src/feature-libraries/forest-summary/incrementalSummaryBuilder.ts +511 -0
  417. package/src/feature-libraries/forest-summary/index.ts +1 -1
  418. package/src/feature-libraries/index.ts +5 -1
  419. package/src/feature-libraries/modular-schema/modularChangeCodecs.ts +8 -4
  420. package/src/feature-libraries/treeCompressionUtils.ts +19 -0
  421. package/src/index.ts +6 -1
  422. package/src/packageVersion.ts +1 -1
  423. package/src/shared-tree/schematizingTreeView.ts +1 -1
  424. package/src/shared-tree/sharedTree.ts +37 -4
  425. package/src/shared-tree/sharedTreeChangeFamily.ts +2 -2
  426. package/src/shared-tree/tree.ts +3 -0
  427. package/src/shared-tree/treeAlpha.ts +10 -11
  428. package/src/shared-tree/treeCheckout.ts +3 -2
  429. package/src/shared-tree-core/sharedTreeCore.ts +17 -0
  430. package/src/sharedTreeAttributes.ts +2 -2
  431. package/src/simple-tree/api/conciseTree.ts +2 -1
  432. package/src/simple-tree/api/customTree.ts +102 -32
  433. package/src/simple-tree/api/getJsonSchema.ts +7 -2
  434. package/src/simple-tree/api/index.ts +3 -0
  435. package/src/simple-tree/api/schemaCreationUtilities.ts +1 -1
  436. package/src/simple-tree/api/schemaFactory.ts +21 -14
  437. package/src/simple-tree/api/schemaFactoryAlpha.ts +29 -30
  438. package/src/simple-tree/api/schemaFactoryBeta.ts +28 -0
  439. package/src/simple-tree/api/schemaFactoryRecursive.ts +41 -40
  440. package/src/simple-tree/api/simpleSchemaToJsonSchema.ts +7 -3
  441. package/src/simple-tree/api/transactionTypes.ts +1 -0
  442. package/src/simple-tree/api/tree.ts +75 -81
  443. package/src/simple-tree/api/verboseTree.ts +42 -39
  444. package/src/simple-tree/core/simpleNodeSchemaBase.ts +6 -0
  445. package/src/simple-tree/fieldSchema.ts +3 -4
  446. package/src/simple-tree/index.ts +3 -0
  447. package/src/simple-tree/node-kinds/record/recordNode.ts +2 -3
  448. package/src/simple-tree/simpleSchema.ts +12 -0
  449. package/src/simple-tree/toStoredSchema.ts +0 -3
  450. package/src/tableSchema.ts +261 -243
  451. package/src/treeFactory.ts +1 -2
  452. package/src/util/breakable.ts +9 -1
@@ -4,7 +4,7 @@
4
4
  * Licensed under the MIT License.
5
5
  */
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.NodeDecoder = exports.anyDecoder = exports.InlineArrayDecoder = exports.NestedArrayDecoder = exports.aggregateChunks = exports.deaggregateChunks = exports.readValue = exports.decode = void 0;
7
+ exports.NodeDecoder = exports.anyDecoder = exports.IncrementalChunkDecoder = exports.InlineArrayDecoder = exports.NestedArrayDecoder = exports.aggregateChunks = exports.deaggregateChunks = exports.readValue = exports.decode = void 0;
8
8
  const internal_1 = require("@fluidframework/core-utils/internal");
9
9
  const index_js_1 = require("../../../codec/index.js");
10
10
  const index_js_2 = require("../../../util/index.js");
@@ -17,8 +17,8 @@ const format_js_1 = require("./format.js");
17
17
  /**
18
18
  * Decode `chunk` into a TreeChunk.
19
19
  */
20
- function decode(chunk, idDecodingContext) {
21
- return (0, chunkDecodingGeneric_js_1.decode)(decoderLibrary, new chunkDecodingGeneric_js_1.DecoderContext(chunk.identifiers, chunk.shapes, idDecodingContext), chunk, exports.anyDecoder);
20
+ function decode(chunk, idDecodingContext, incrementalDecoder) {
21
+ return (0, chunkDecodingGeneric_js_1.decode)(decoderLibrary, new chunkDecodingGeneric_js_1.DecoderContext(chunk.identifiers, chunk.shapes, idDecodingContext, incrementalDecoder), chunk, exports.anyDecoder);
22
22
  }
23
23
  exports.decode = decode;
24
24
  const decoderLibrary = new index_js_1.DiscriminatedUnionDispatcher({
@@ -34,6 +34,9 @@ const decoderLibrary = new index_js_1.DiscriminatedUnionDispatcher({
34
34
  d(shape) {
35
35
  return exports.anyDecoder;
36
36
  },
37
+ e(shape, cache) {
38
+ return new IncrementalChunkDecoder(cache);
39
+ },
37
40
  });
38
41
  /**
39
42
  * Decode a node's value from `stream` using its shape.
@@ -164,6 +167,26 @@ class InlineArrayDecoder {
164
167
  }
165
168
  }
166
169
  exports.InlineArrayDecoder = InlineArrayDecoder;
170
+ /**
171
+ * Decoder for {@link EncodedIncrementalChunkShape}s.
172
+ */
173
+ class IncrementalChunkDecoder {
174
+ constructor(cache) {
175
+ this.cache = cache;
176
+ }
177
+ decode(_, stream) {
178
+ (0, internal_1.assert)(this.cache.incrementalDecoder !== undefined, 0xc27 /* incremental decoder not available for incremental field decoding */);
179
+ const chunkReferenceId = (0, chunkCodecUtilities_js_1.readStreamNumber)(stream);
180
+ const batch = this.cache.incrementalDecoder.getEncodedIncrementalChunk((0, index_js_2.brand)(chunkReferenceId));
181
+ (0, internal_1.assert)(batch !== undefined, 0xc28 /* Incremental chunk data missing */);
182
+ // The incremental chunk data is self-describing, i.e., it contain its own shapes list and identifier table.
183
+ // Use these to create a new decoder context to be used to decode the incremental chunk's data.
184
+ const context = new chunkDecodingGeneric_js_1.DecoderContext(batch.identifiers, batch.shapes, this.cache.idDecodingContext, this.cache.incrementalDecoder);
185
+ const chunks = (0, chunkDecodingGeneric_js_1.decode)(decoderLibrary, context, batch, exports.anyDecoder);
186
+ return aggregateChunks(chunks);
187
+ }
188
+ }
189
+ exports.IncrementalChunkDecoder = IncrementalChunkDecoder;
167
190
  /**
168
191
  * Decoder for {@link EncodedAnyShape}s.
169
192
  */
@@ -213,8 +236,8 @@ class NodeDecoder {
213
236
  fields.set(key, chunks);
214
237
  }
215
238
  }
216
- for (const field of this.fieldDecoders) {
217
- const [key, content] = field(decoders, stream);
239
+ for (const decoder of this.fieldDecoders) {
240
+ const [key, content] = decoder(decoders, stream);
218
241
  addField(key, content);
219
242
  }
220
243
  if (this.shape.extraFields !== undefined) {
@@ -1 +1 @@
1
- {"version":3,"file":"chunkDecoding.js","sourceRoot":"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,CAAC;QAED,IAAI,IAAI,CAAC,KAAK,CAAC,WAAW,KAAK,SAAS,EAAE,CAAC;YAC1C,MAAM,OAAO,GAAG,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,IAAI,IAAA,cAAG,GAAE,CAAC;YAC1D,MAAM,KAAK,GAAG,IAAA,yCAAgB,EAAC,MAAM,CAAC,CAAC;YACvC,OAAO,KAAK,CAAC,MAAM,KAAK,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;gBAC3C,MAAM,GAAG,GAAa,IAAA,8CAAoB,EAAC,KAAK,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;gBAChE,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\";\nimport type {\n\tIIdCompressor,\n\tOpSpaceCompressedId,\n\tSessionId,\n} from \"@fluidframework/id-compressor\";\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 EncodedInlineArrayShape,\n\ttype EncodedNestedArrayShape,\n\ttype EncodedNodeShape,\n\ttype EncodedValueShape,\n\tSpecialField,\n} from \"./format.js\";\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[context: DecoderContext<EncodedChunkShape>],\n\tChunkDecoder\n>({\n\ta(shape: EncodedNestedArrayShape, context): ChunkDecoder {\n\t\treturn new NestedArrayDecoder(shape);\n\t},\n\tb(shape: EncodedInlineArrayShape, context): ChunkDecoder {\n\t\treturn new InlineArrayDecoder(shape);\n\t},\n\tc(shape: EncodedNodeShape, context): ChunkDecoder {\n\t\treturn new NodeDecoder(shape, context);\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 EncodedNestedArrayShape}s.\n */\nexport class NestedArrayDecoder implements ChunkDecoder {\n\tpublic constructor(private readonly shape: EncodedNestedArrayShape) {}\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 EncodedInlineArrayShape}s.\n */\nexport class InlineArrayDecoder implements ChunkDecoder {\n\tpublic constructor(private readonly shape: EncodedInlineArrayShape) {}\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 `context`) {@link EncodedChunkShape}.\n */\nfunction fieldDecoder(\n\tcontext: DecoderContext<EncodedChunkShape>,\n\tkey: FieldKey,\n\tshape: number,\n): BasicFieldDecoder {\n\tassertValidIndex(shape, context.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 EncodedNodeShape}s.\n */\nexport class NodeDecoder implements ChunkDecoder {\n\tprivate readonly type?: TreeNodeSchemaIdentifier;\n\tprivate readonly fieldDecoders: readonly BasicFieldDecoder[];\n\tpublic constructor(\n\t\tprivate readonly shape: EncodedNodeShape,\n\t\tprivate readonly context: DecoderContext<EncodedChunkShape>,\n\t) {\n\t\tthis.type = shape.type === undefined ? undefined : context.identifier(shape.type);\n\n\t\tconst fieldDecoders: BasicFieldDecoder[] = [];\n\t\tfor (const [fieldKey, fieldShape] of shape.fields ?? []) {\n\t\t\tconst key: FieldKey = context.identifier(fieldKey);\n\t\t\tfieldDecoders.push(fieldDecoder(context, 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.context);\n\t\t// TODO: Consider typechecking against stored schema in here somewhere.\n\n\t\tconst value = readValue(stream, this.shape.value, this.context.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.context);\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;AAOnF,sDAAuE;AAOvE,qDAAiE;AACjE,oDAA8C;AAC9C,oDAA8C;AAC9C,0DAAoD;AAEpD,q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CAAC,OAAO,CAAC,CAAC;gBAChE,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\";\nimport type {\n\tIIdCompressor,\n\tOpSpaceCompressedId,\n\tSessionId,\n} from \"@fluidframework/id-compressor\";\n\nimport { DiscriminatedUnionDispatcher } from \"../../../codec/index.js\";\nimport type {\n\tFieldKey,\n\tTreeNodeSchemaIdentifier,\n\tValue,\n\tTreeChunk,\n} from \"../../../core/index.js\";\nimport { assertValidIndex, brand } 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 EncodedIncrementalChunkShape,\n\ttype EncodedInlineArrayShape,\n\ttype EncodedNestedArrayShape,\n\ttype EncodedNodeShape,\n\ttype EncodedValueShape,\n\tSpecialField,\n} from \"./format.js\";\nimport type { IncrementalDecoder } from \"./codecs.js\";\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\tincrementalDecoder?: IncrementalDecoder,\n): TreeChunk[] {\n\treturn genericDecode(\n\t\tdecoderLibrary,\n\t\tnew DecoderContext(chunk.identifiers, chunk.shapes, idDecodingContext, incrementalDecoder),\n\t\tchunk,\n\t\tanyDecoder,\n\t);\n}\n\nconst decoderLibrary = new DiscriminatedUnionDispatcher<\n\tEncodedChunkShape,\n\t[context: DecoderContext<EncodedChunkShape>],\n\tChunkDecoder\n>({\n\ta(shape: EncodedNestedArrayShape, context): ChunkDecoder {\n\t\treturn new NestedArrayDecoder(shape);\n\t},\n\tb(shape: EncodedInlineArrayShape, context): ChunkDecoder {\n\t\treturn new InlineArrayDecoder(shape);\n\t},\n\tc(shape: EncodedNodeShape, context): ChunkDecoder {\n\t\treturn new NodeDecoder(shape, context);\n\t},\n\td(shape: EncodedAnyShape): ChunkDecoder {\n\t\treturn anyDecoder;\n\t},\n\te(shape: EncodedIncrementalChunkShape, cache): ChunkDecoder {\n\t\treturn new IncrementalChunkDecoder(cache);\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 EncodedNestedArrayShape}s.\n */\nexport class NestedArrayDecoder implements ChunkDecoder {\n\tpublic constructor(private readonly shape: EncodedNestedArrayShape) {}\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 EncodedInlineArrayShape}s.\n */\nexport class InlineArrayDecoder implements ChunkDecoder {\n\tpublic constructor(private readonly shape: EncodedInlineArrayShape) {}\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 EncodedIncrementalChunkShape}s.\n */\nexport class IncrementalChunkDecoder implements ChunkDecoder {\n\tpublic constructor(private readonly cache: DecoderContext<EncodedChunkShape>) {}\n\tpublic decode(_: readonly ChunkDecoder[], stream: StreamCursor): TreeChunk {\n\t\tassert(\n\t\t\tthis.cache.incrementalDecoder !== undefined,\n\t\t\t0xc27 /* incremental decoder not available for incremental field decoding */,\n\t\t);\n\t\tconst chunkReferenceId = readStreamNumber(stream);\n\t\tconst batch = this.cache.incrementalDecoder.getEncodedIncrementalChunk(\n\t\t\tbrand(chunkReferenceId),\n\t\t);\n\t\tassert(batch !== undefined, 0xc28 /* Incremental chunk data missing */);\n\t\t// The incremental chunk data is self-describing, i.e., it contain its own shapes list and identifier table.\n\t\t// Use these to create a new decoder context to be used to decode the incremental chunk's data.\n\t\tconst context = new DecoderContext(\n\t\t\tbatch.identifiers,\n\t\t\tbatch.shapes,\n\t\t\tthis.cache.idDecodingContext,\n\t\t\tthis.cache.incrementalDecoder,\n\t\t);\n\t\tconst chunks = genericDecode(decoderLibrary, context, batch, anyDecoder);\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 `context`) {@link EncodedChunkShape}.\n */\nfunction fieldDecoder(\n\tcontext: DecoderContext<EncodedChunkShape>,\n\tkey: FieldKey,\n\tshape: number,\n): BasicFieldDecoder {\n\tassertValidIndex(shape, context.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 EncodedNodeShape}s.\n */\nexport class NodeDecoder implements ChunkDecoder {\n\tprivate readonly type?: TreeNodeSchemaIdentifier;\n\tprivate readonly fieldDecoders: readonly BasicFieldDecoder[];\n\tpublic constructor(\n\t\tprivate readonly shape: EncodedNodeShape,\n\t\tprivate readonly context: DecoderContext<EncodedChunkShape>,\n\t) {\n\t\tthis.type = shape.type === undefined ? undefined : context.identifier(shape.type);\n\n\t\tconst fieldDecoders: BasicFieldDecoder[] = [];\n\t\tfor (const [fieldKey, fieldShape] of shape.fields ?? []) {\n\t\t\tconst key: FieldKey = context.identifier(fieldKey);\n\t\t\tfieldDecoders.push(fieldDecoder(context, 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.context);\n\t\t// TODO: Consider typechecking against stored schema in here somewhere.\n\n\t\tconst value = readValue(stream, this.shape.value, this.context.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 decoder of this.fieldDecoders) {\n\t\t\tconst [key, content] = decoder(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.context);\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"]}
@@ -8,6 +8,7 @@ import type { BrandedType } from "../../../util/index.js";
8
8
  import { type ChunkDecoder, type StreamCursor } from "./chunkCodecUtilities.js";
9
9
  import type { IdDecodingContext } from "./chunkDecoding.js";
10
10
  import type { EncodedFieldBatchGeneric, IdentifierOrIndex } from "./formatGeneric.js";
11
+ import type { IncrementalDecoder } from "./codecs.js";
11
12
  /**
12
13
  * General purpose shape based tree decoder which gets its support for specific shapes from the caller.
13
14
  */
@@ -18,13 +19,29 @@ export declare function decode<TEncodedShape extends object, TContext>(decoderLi
18
19
  * Shared data for use in constructing decoders.
19
20
  */
20
21
  export declare class DecoderContext<TEncodedShape = unknown> {
22
+ /**
23
+ * Identifier substitution table (use to replace numeric identifier indexes with the actual identifiers from this table).
24
+ */
21
25
  readonly identifiers: readonly string[];
22
26
  readonly shapes: readonly TEncodedShape[];
23
27
  readonly idDecodingContext: IdDecodingContext;
24
28
  /**
25
- * @param identifiers - identifier substitution table (use to replace numeric identifier indexes with the actual identifiers from this table).
29
+ * To be used to decode incremental chunks, if any.
30
+ * @remarks
31
+ * See {@link IncrementalDecoder} for more information.
32
+ */
33
+ readonly incrementalDecoder: IncrementalDecoder | undefined;
34
+ constructor(
35
+ /**
36
+ * Identifier substitution table (use to replace numeric identifier indexes with the actual identifiers from this table).
37
+ */
38
+ identifiers: readonly string[], shapes: readonly TEncodedShape[], idDecodingContext: IdDecodingContext,
39
+ /**
40
+ * To be used to decode incremental chunks, if any.
41
+ * @remarks
42
+ * See {@link IncrementalDecoder} for more information.
26
43
  */
27
- constructor(identifiers: readonly string[], shapes: readonly TEncodedShape[], idDecodingContext: IdDecodingContext);
44
+ incrementalDecoder: IncrementalDecoder | undefined);
28
45
  identifier<T extends string & BrandedType<string, string>>(encoded: IdentifierOrIndex): T;
29
46
  }
30
47
  /**
@@ -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,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAE1D,OAAO,EACN,KAAK,YAAY,EACjB,KAAK,YAAY,EAGjB,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAC5D,OAAO,KAAK,EAAE,wBAAwB,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAEtF;;GAEG;AACH,wBAAgB,MAAM,CAAC,aAAa,SAAS,MAAM,EAAE,QAAQ,EAC5D,cAAc,EAAE,4BAA4B,CAC3C,aAAa,EACb;IAAC,OAAO,EAAE,QAAQ;CAAC,EACnB,YAAY,CACZ,EACD,OAAO,EAAE,QAAQ,EACjB,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,OAAO,EAAE,cAAc,GACrB,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,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAE1D,OAAO,EACN,KAAK,YAAY,EACjB,KAAK,YAAY,EAGjB,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAC5D,OAAO,KAAK,EAAE,wBAAwB,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACtF,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAEtD;;GAEG;AACH,wBAAgB,MAAM,CAAC,aAAa,SAAS,MAAM,EAAE,QAAQ,EAC5D,cAAc,EAAE,4BAA4B,CAC3C,aAAa,EACb;IAAC,OAAO,EAAE,QAAQ;CAAC,EACnB,YAAY,CACZ,EACD,OAAO,EAAE,QAAQ,EACjB,KAAK,EAAE,wBAAwB,CAAC,aAAa,CAAC,EAC9C,WAAW,EAAE,YAAY,GACvB,SAAS,EAAE,CAcb;AAED;;GAEG;AACH,qBAAa,cAAc,CAAC,aAAa,GAAG,OAAO;IAEjD;;OAEG;aACa,WAAW,EAAE,SAAS,MAAM,EAAE;aAC9B,MAAM,EAAE,SAAS,aAAa,EAAE;aAChC,iBAAiB,EAAE,iBAAiB;IACpD;;;;OAIG;aACa,kBAAkB,EAAE,kBAAkB,GAAG,SAAS;;IAXlE;;OAEG;IACa,WAAW,EAAE,SAAS,MAAM,EAAE,EAC9B,MAAM,EAAE,SAAS,aAAa,EAAE,EAChC,iBAAiB,EAAE,iBAAiB;IACpD;;;;OAIG;IACa,kBAAkB,EAAE,kBAAkB,GAAG,SAAS;IAG5D,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,OAAO,EAAE,cAAc,GACrB,CAAC,CAOH"}
@@ -26,13 +26,21 @@ exports.decode = decode;
26
26
  * Shared data for use in constructing decoders.
27
27
  */
28
28
  class DecoderContext {
29
+ constructor(
29
30
  /**
30
- * @param identifiers - identifier substitution table (use to replace numeric identifier indexes with the actual identifiers from this table).
31
+ * Identifier substitution table (use to replace numeric identifier indexes with the actual identifiers from this table).
31
32
  */
32
- constructor(identifiers, shapes, idDecodingContext) {
33
+ identifiers, shapes, idDecodingContext,
34
+ /**
35
+ * To be used to decode incremental chunks, if any.
36
+ * @remarks
37
+ * See {@link IncrementalDecoder} for more information.
38
+ */
39
+ incrementalDecoder) {
33
40
  this.identifiers = identifiers;
34
41
  this.shapes = shapes;
35
42
  this.idDecodingContext = idDecodingContext;
43
+ this.incrementalDecoder = incrementalDecoder;
36
44
  }
37
45
  identifier(encoded) {
38
46
  if (typeof encoded === "string") {
@@ -1 +1 @@
1
- {"version":3,"file":"chunkDecodingGeneric.js","sourceRoot":"","sources":["../../../../src/fe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AAlBD,wCAkBC;AAED;;GAEG;AACH,SAAgB,oBAAoB,CACnC,MAAoB,EACpB,OAAuB;IAEvB,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,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;AACpC,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 { TreeChunk } from \"../../../core/index.js\";\nimport type { BrandedType } from \"../../../util/index.js\";\n\nimport {\n\ttype ChunkDecoder,\n\ttype StreamCursor,\n\tgetChecked,\n\treadStream,\n} from \"./chunkCodecUtilities.js\";\nimport type { IdDecodingContext } from \"./chunkDecoding.js\";\nimport type { EncodedFieldBatchGeneric, IdentifierOrIndex } from \"./formatGeneric.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, TContext>(\n\tdecoderLibrary: DiscriminatedUnionDispatcher<\n\t\tTEncodedShape,\n\t\t[context: TContext],\n\t\tChunkDecoder\n\t>,\n\tcontext: TContext,\n\tbatch: EncodedFieldBatchGeneric<TEncodedShape>,\n\trootDecoder: ChunkDecoder,\n): TreeChunk[] {\n\tconst decoders = batch.shapes.map((shape) => decoderLibrary.dispatch(shape, context));\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\tcontext: 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 context.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;AAKlC;;GAEG;AACH,SAAgB,MAAM,CACrB,cAIC,EACD,OAAiB,EACjB,KAA8C,EAC9C,WAAyB;IAEzB,MAAM,QAAQ,GAAG,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,cAAc,CAAC,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC,CAAC;IACtF,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;AAvBD,wBAuBC;AAED;;GAEG;AACH,MAAa,cAAc;IAC1B;IACC;;OAEG;IACa,WAA8B,EAC9B,MAAgC,EAChC,iBAAoC;IACpD;;;;OAIG;IACa,kBAAkD;QARlD,gBAAW,GAAX,WAAW,CAAmB;QAC9B,WAAM,GAAN,MAAM,CAA0B;QAChC,sBAAiB,GAAjB,iBAAiB,CAAmB;QAMpC,uBAAkB,GAAlB,kBAAkB,CAAgC;IAChE,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;AAxBD,wCAwBC;AAED;;GAEG;AACH,SAAgB,oBAAoB,CACnC,MAAoB,EACpB,OAAuB;IAEvB,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,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;AACpC,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 { TreeChunk } from \"../../../core/index.js\";\nimport type { BrandedType } from \"../../../util/index.js\";\n\nimport {\n\ttype ChunkDecoder,\n\ttype StreamCursor,\n\tgetChecked,\n\treadStream,\n} from \"./chunkCodecUtilities.js\";\nimport type { IdDecodingContext } from \"./chunkDecoding.js\";\nimport type { EncodedFieldBatchGeneric, IdentifierOrIndex } from \"./formatGeneric.js\";\nimport type { IncrementalDecoder } from \"./codecs.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, TContext>(\n\tdecoderLibrary: DiscriminatedUnionDispatcher<\n\t\tTEncodedShape,\n\t\t[context: TContext],\n\t\tChunkDecoder\n\t>,\n\tcontext: TContext,\n\tbatch: EncodedFieldBatchGeneric<TEncodedShape>,\n\trootDecoder: ChunkDecoder,\n): TreeChunk[] {\n\tconst decoders = batch.shapes.map((shape) => decoderLibrary.dispatch(shape, context));\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\tpublic constructor(\n\t\t/**\n\t\t * Identifier substitution table (use to replace numeric identifier indexes with the actual identifiers from this table).\n\t\t */\n\t\tpublic readonly identifiers: readonly string[],\n\t\tpublic readonly shapes: readonly TEncodedShape[],\n\t\tpublic readonly idDecodingContext: IdDecodingContext,\n\t\t/**\n\t\t * To be used to decode incremental chunks, if any.\n\t\t * @remarks\n\t\t * See {@link IncrementalDecoder} for more information.\n\t\t */\n\t\tpublic readonly incrementalDecoder: IncrementalDecoder | undefined,\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\tcontext: 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 context.identifier(content);\n}\n"]}
@@ -4,16 +4,71 @@
4
4
  */
5
5
  import type { IIdCompressor, SessionId } from "@fluidframework/id-compressor";
6
6
  import { type FluidClientVersion, type ICodecOptions, type IJsonCodec } from "../../../codec/index.js";
7
- import { type SchemaAndPolicy } from "../../../core/index.js";
8
- import type { JsonCompatibleReadOnly } from "../../../util/index.js";
9
- import { TreeCompressionStrategy } from "../../treeCompressionUtils.js";
7
+ import { type FieldKey, type ITreeCursorSynchronous, type SchemaAndPolicy, type TreeChunk, type TreeNodeSchemaIdentifier } from "../../../core/index.js";
8
+ import { type Brand, type JsonCompatibleReadOnly } from "../../../util/index.js";
9
+ import { type TreeCompressionStrategyPrivate } from "../../treeCompressionUtils.js";
10
10
  import type { FieldBatch } from "./fieldBatch.js";
11
11
  import { EncodedFieldBatch } from "./format.js";
12
+ /**
13
+ * Reference ID for a chunk that is incrementally encoded.
14
+ */
15
+ export type ChunkReferenceId = Brand<number, "forest.ChunkReferenceId">;
16
+ /**
17
+ * Properties for incremental encoding.
18
+ * Fields that support incremental encoding will encode their chunks separately by calling `encodeIncrementalField`.
19
+ * @remarks
20
+ * This supports features like incremental summarization where the summary from these fields can be re-used if
21
+ * unchanged between summaries.
22
+ * Note that each of these chunks that are incrementally encoded is fully self-describing (contain its own shapes
23
+ * list and identifier table) and does not rely on context from its parent.
24
+ */
25
+ export interface IncrementalEncoder {
26
+ /**
27
+ * Returns whether a field should be incrementally encoded.
28
+ * @param nodeIdentifier - The identifier of the node containing the field.
29
+ * @param fieldKey - The key of the field to check.
30
+ */
31
+ shouldEncodeFieldIncrementally(nodeIdentifier: TreeNodeSchemaIdentifier, fieldKey: FieldKey): boolean;
32
+ /**
33
+ * Called to encode an incremental field at the cursor.
34
+ * The chunks for this field are encoded separately from the main buffer.
35
+ * @param cursor - The cursor pointing to the field to encode.
36
+ * @param chunkEncoder - A function that encodes the contents of the passed chunk in the field.
37
+ * @returns The reference IDs of the encoded chunks in the field.
38
+ * This is used to retrieve the encoded chunks later.
39
+ */
40
+ encodeIncrementalField(cursor: ITreeCursorSynchronous, chunkEncoder: (chunk: TreeChunk) => EncodedFieldBatch): ChunkReferenceId[];
41
+ }
42
+ /**
43
+ * Properties for incremental decoding.
44
+ *
45
+ * Fields that had their chunks incrementally encoded will retrieve them by calling `getEncodedIncrementalChunk`.
46
+ * @remarks
47
+ * See {@link IncrementalEncoder} for more details.
48
+ */
49
+ export interface IncrementalDecoder {
50
+ /**
51
+ * Called to get the encoded contents of an chunk in an incremental field with the given reference ID.
52
+ * @param referenceId - The reference ID of the chunk to retrieve.
53
+ * @returns The encoded contents of the chunk.
54
+ */
55
+ getEncodedIncrementalChunk: (referenceId: ChunkReferenceId) => EncodedFieldBatch;
56
+ }
57
+ /**
58
+ * Combines the properties of {@link IncrementalEncoder} and {@link IncrementalDecoder}.
59
+ */
60
+ export interface IncrementalEncoderDecoder extends IncrementalEncoder, IncrementalDecoder {
61
+ }
12
62
  export interface FieldBatchEncodingContext {
13
- readonly encodeType: TreeCompressionStrategy;
63
+ readonly encodeType: TreeCompressionStrategyPrivate;
14
64
  readonly idCompressor: IIdCompressor;
15
65
  readonly originatorId: SessionId;
16
66
  readonly schema?: SchemaAndPolicy;
67
+ /**
68
+ * An encoder / decoder for encoding and decoding of incremental fields.
69
+ * This will be defined if incremental encoding is supported and enabled.
70
+ */
71
+ readonly incrementalEncoderDecoder?: IncrementalEncoderDecoder;
17
72
  }
18
73
  /**
19
74
  * @remarks
@@ -1 +1 @@
1
- {"version":3,"file":"codecs.d.ts","sourceRoot":"","sources":["../../../../src/feature-libraries/chunked-forest/codec/codecs.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAE9E,OAAO,EACN,KAAK,kBAAkB,EACvB,KAAK,aAAa,EAClB,KAAK,UAAU,EAEf,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAsB,KAAK,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAClF,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AACrE,OAAO,EAAE,uBAAuB,EAAE,MAAM,+BAA+B,CAAC;AAGxE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAE,iBAAiB,EAAiB,MAAM,aAAa,CAAC;AAI/D,MAAM,WAAW,yBAAyB;IACzC,QAAQ,CAAC,UAAU,EAAE,uBAAuB,CAAC;IAC7C,QAAQ,CAAC,YAAY,EAAE,aAAa,CAAC;IACrC,QAAQ,CAAC,YAAY,EAAE,SAAS,CAAC;IACjC,QAAQ,CAAC,MAAM,CAAC,EAAE,eAAe,CAAC;CAClC;AACD;;;GAGG;AACH,MAAM,MAAM,eAAe,GAAG,UAAU,CACvC,UAAU,EACV,iBAAiB,EACjB,sBAAsB,EACtB,yBAAyB,CACzB,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,yCAAyC,CACxD,sBAAsB,EAAE,kBAAkB,GACxC,MAAM,CAGR;AAED,wBAAgB,mBAAmB,CAClC,OAAO,EAAE,aAAa,EACtB,YAAY,EAAE,MAAM,GAClB,eAAe,CAsDjB"}
1
+ {"version":3,"file":"codecs.d.ts","sourceRoot":"","sources":["../../../../src/feature-libraries/chunked-forest/codec/codecs.ts"],"names":[],"mappings":"AAAA;;;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YAAY,EAAE,aAAa,CAAC;IACrC,QAAQ,CAAC,YAAY,EAAE,SAAS,CAAC;IACjC,QAAQ,CAAC,MAAM,CAAC,EAAE,eAAe,CAAC;IAClC;;;OAGG;IACH,QAAQ,CAAC,yBAAyB,CAAC,EAAE,yBAAyB,CAAC;CAC/D;AACD;;;GAGG;AACH,MAAM,MAAM,eAAe,GAAG,UAAU,CACvC,UAAU,EACV,iBAAiB,EACjB,sBAAsB,EACtB,yBAAyB,CACzB,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,yCAAyC,CACxD,sBAAsB,EAAE,kBAAkB,GACxC,MAAM,CAGR;AAED,wBAAgB,mBAAmB,CAClC,OAAO,EAAE,aAAa,EACtB,YAAY,EAAE,MAAM,GAClB,eAAe,CA+DjB"}
@@ -7,11 +7,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
7
7
  exports.makeFieldBatchCodec = exports.fluidVersionToFieldBatchCodecWriteVersion = void 0;
8
8
  const internal_1 = require("@fluidframework/core-utils/internal");
9
9
  const index_js_1 = require("../../../codec/index.js");
10
+ const index_js_2 = require("../../../util/index.js");
10
11
  const treeCompressionUtils_js_1 = require("../../treeCompressionUtils.js");
11
12
  const chunkDecoding_js_1 = require("./chunkDecoding.js");
12
13
  const format_js_1 = require("./format.js");
13
14
  const schemaBasedEncode_js_1 = require("./schemaBasedEncode.js");
14
15
  const uncompressedEncode_js_1 = require("./uncompressedEncode.js");
16
+ const ChunkReferenceId = (0, index_js_2.brandedNumberType)({ multipleOf: 1, minimum: 0 });
15
17
  /**
16
18
  * Get the write version for {@link makeFieldBatchCodec} based on the `oldestCompatibleClient` version.
17
19
  * @privateRemarks
@@ -39,10 +41,15 @@ function makeFieldBatchCodec(options, writeVersion) {
39
41
  case treeCompressionUtils_js_1.TreeCompressionStrategy.Uncompressed:
40
42
  encoded = (0, uncompressedEncode_js_1.uncompressedEncode)(data);
41
43
  break;
44
+ case treeCompressionUtils_js_1.TreeCompressionStrategyExtended.CompressedIncremental:
42
45
  case treeCompressionUtils_js_1.TreeCompressionStrategy.Compressed:
43
46
  // eslint-disable-next-line unicorn/prefer-ternary
44
47
  if (context.schema !== undefined) {
45
- encoded = (0, schemaBasedEncode_js_1.schemaCompressedEncode)(context.schema.schema, context.schema.policy, data, context.idCompressor);
48
+ encoded = (0, schemaBasedEncode_js_1.schemaCompressedEncode)(context.schema.schema, context.schema.policy, data, context.idCompressor,
49
+ // Incremental encoding is only supported for CompressedIncremental.
50
+ context.encodeType === treeCompressionUtils_js_1.TreeCompressionStrategyExtended.CompressedIncremental
51
+ ? context.incrementalEncoderDecoder
52
+ : undefined);
46
53
  }
47
54
  else {
48
55
  // TODO: consider enabling a somewhat compressed but not schema accelerated encode.
@@ -60,7 +67,7 @@ function makeFieldBatchCodec(options, writeVersion) {
60
67
  return (0, chunkDecoding_js_1.decode)(data, {
61
68
  idCompressor: context.idCompressor,
62
69
  originatorId: context.originatorId,
63
- }).map((chunk) => chunk.cursor());
70
+ }, context.incrementalEncoderDecoder).map((chunk) => chunk.cursor());
64
71
  },
65
72
  });
66
73
  }
@@ -1 +1 @@
1
- {"version":3,"file":"codecs.js","sourceRoot":"","sources":["../../../../src/feature-libraries/chunked-forest/codec/codecs.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAA8E;AAG9E,sDAKiC;AAGjC,2EAAwE;AAExE,yDAA4C;AAE5C,2CAA+D;AAC/D,iEAAgE;AAChE,mEAA6D;AAmB7D;;;;GAIG;AACH,SAAgB,yCAAyC,CACxD,sBAA0C;IAE1C,wCAAwC;IACxC,OAAO,CAAC,CAAC;AACV,CAAC;AALD,8FAKC;AAED,SAAgB,mBAAmB,CAClC,OAAsB,EACtB,YAAoB;IAEpB,6GAA6G;IAC7G,8GAA8G;IAC9G,iHAAiH;IACjH,+BAA+B;IAC/B,IAAA,iBAAM,EACL,yBAAa,CAAC,GAAG,CAAC,YAAY,CAAC,EAC/B,KAAK,CAAC,gDAAgD,CACtD,CAAC;IAEF,uFAAu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AAE,CAAC,CAAC;QACnC,CAAC;KACD,CAAC,CAAC;AACJ,CAAC;AAzDD,kDAyDC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, unreachableCase } from \"@fluidframework/core-utils/internal\";\nimport type { IIdCompressor, SessionId } from \"@fluidframework/id-compressor\";\n\nimport {\n\ttype FluidClientVersion,\n\ttype ICodecOptions,\n\ttype IJsonCodec,\n\tmakeVersionedValidatedCodec,\n} from \"../../../codec/index.js\";\nimport { CursorLocationType, type SchemaAndPolicy } from \"../../../core/index.js\";\nimport type { JsonCompatibleReadOnly } from \"../../../util/index.js\";\nimport { TreeCompressionStrategy } from \"../../treeCompressionUtils.js\";\n\nimport { decode } from \"./chunkDecoding.js\";\nimport type { FieldBatch } from \"./fieldBatch.js\";\nimport { EncodedFieldBatch, validVersions } from \"./format.js\";\nimport { schemaCompressedEncode } from \"./schemaBasedEncode.js\";\nimport { uncompressedEncode } from \"./uncompressedEncode.js\";\n\nexport interface FieldBatchEncodingContext {\n\treadonly encodeType: TreeCompressionStrategy;\n\treadonly idCompressor: IIdCompressor;\n\treadonly originatorId: SessionId;\n\treadonly schema?: SchemaAndPolicy;\n}\n/**\n * @remarks\n * Fields in this batch currently don't have field schema for the root, which limits optimizations.\n */\nexport type FieldBatchCodec = IJsonCodec<\n\tFieldBatch,\n\tEncodedFieldBatch,\n\tJsonCompatibleReadOnly,\n\tFieldBatchEncodingContext\n>;\n\n/**\n * Get the write version for {@link makeFieldBatchCodec} based on the `oldestCompatibleClient` version.\n * @privateRemarks\n * TODO: makeFieldBatchCodec (and makeVersionDispatchingCodec transitively) should bake in this versionToFormat logic and the resulting codec can then support use with FluidClientVersion directly.\n */\nexport function fluidVersionToFieldBatchCodecWriteVersion(\n\toldestCompatibleClient: FluidClientVersion,\n): number {\n\t// There is currently on only 1 version.\n\treturn 1;\n}\n\nexport function makeFieldBatchCodec(\n\toptions: ICodecOptions,\n\twriteVersion: number,\n): FieldBatchCodec {\n\t// Note: it's important that the decode function is schema-agnostic for this strategy/layering to work, since\n\t// the schema that an op was encoded in doesn't necessarily match the current schema for the document (e.g. if\n\t// decode is being run on a client that just submitted a schema change, but the op is from another client who has\n\t// yet to receive that change).\n\tassert(\n\t\tvalidVersions.has(writeVersion),\n\t\t0x935 /* Invalid write version for FieldBatch codec */,\n\t);\n\n\t// TODO: use makeVersionDispatchingCodec to support adding more versions in the future.\n\treturn makeVersionedValidatedCodec(options, validVersions, EncodedFieldBatch, {\n\t\tencode: (data: FieldBatch, context: FieldBatchEncodingContext): EncodedFieldBatch => {\n\t\t\tfor (const cursor of data) {\n\t\t\t\tassert(\n\t\t\t\t\tcursor.mode === CursorLocationType.Fields,\n\t\t\t\t\t0x8a3 /* FieldBatch expects fields cursors */,\n\t\t\t\t);\n\t\t\t}\n\t\t\tlet encoded: EncodedFieldBatch;\n\t\t\tswitch (context.encodeType) {\n\t\t\t\tcase TreeCompressionStrategy.Uncompressed:\n\t\t\t\t\tencoded = uncompressedEncode(data);\n\t\t\t\t\tbreak;\n\t\t\t\tcase TreeCompressionStrategy.Compressed:\n\t\t\t\t\t// eslint-disable-next-line unicorn/prefer-ternary\n\t\t\t\t\tif (context.schema !== undefined) {\n\t\t\t\t\t\tencoded = schemaCompressedEncode(\n\t\t\t\t\t\t\tcontext.schema.schema,\n\t\t\t\t\t\t\tcontext.schema.policy,\n\t\t\t\t\t\t\tdata,\n\t\t\t\t\t\t\tcontext.idCompressor,\n\t\t\t\t\t\t);\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// TODO: consider enabling a somewhat compressed but not schema accelerated encode.\n\t\t\t\t\t\tencoded = uncompressedEncode(data);\n\t\t\t\t\t}\n\n\t\t\t\t\tbreak;\n\t\t\t\tdefault:\n\t\t\t\t\tunreachableCase(context.encodeType);\n\t\t\t}\n\n\t\t\t// TODO: consider checking input data was in schema.\n\t\t\treturn encoded;\n\t\t},\n\t\tdecode: (data: EncodedFieldBatch, context: FieldBatchEncodingContext): FieldBatch => {\n\t\t\t// TODO: consider checking data is in schema.\n\t\t\treturn decode(data, {\n\t\t\t\tidCompressor: context.idCompressor,\n\t\t\t\toriginatorId: context.originatorId,\n\t\t\t}).map((chunk) => chunk.cursor());\n\t\t},\n\t});\n}\n"]}
1
+ {"version":3,"file":"codecs.js","sourceRoot":"","sources":["../../../../src/feature-libraries/chunked-forest/codec/codecs.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAA8E;AAG9E,sDAKiC;AASjC,qDAIgC;AAChC,2EAIuC;AAEvC,yDAA4C;AAE5C,2CAA+D;AAC/D,iEAAgE;AAChE,mEAA6D;AAM7D,MAAM,gBAAgB,GAAG,IAAA,4BAAiB,EAAmB,EAAE,UAAU,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC,CAAC;AA6E5F;;;;GAIG;AACH,SAAgB,yCAAyC,CACxD,sBAA0C;IAE1C,wCAAwC;IACxC,OAAO,CAAC,CAAC;AACV,CAAC;AALD,8FAKC;AAED,SAAgB,mBAAmB,CAClC,OAAsB,EACtB,YAAoB;IAEpB,6GAA6G;IAC7G,8GAA8G;IAC9G,iHAAiH;IACjH,+BAA+B;IAC/B,IAAA,iBAAM,EACL,yBAAa,CAAC,GAAG,CAAC,YAAY,CAAC,EAC/B,KAAK,CAAC,gDAAgD,CACtD,CAAC;IAEF,uFAAuF;IACvF,OAAO,IAAA,sCAA2B,EAAC,OAAO,EAAE,yBAAa,EAAE,6BAAiB,EAAE;QAC7E,MAAM,EAAE,CAAC,IAAgB,EAAE,OAAkC,EAAqB,EAAE;YACnF,KAAK,MAAM,MAAM,IAAI,IAAI,EAAE,CAAC;gBAC3B,IAAA,iBAAM,EACL,MAAM,CAAC,IAAI,sCAA8B,EACzC,KAAK,CAAC,uCAAuC,CAC7C,CAAC;YACH,CAAC;YACD,IAAI,OAA0B,CAAC;YAC/B,QAAQ,OAAO,CAAC,UAAU,EAAE,CAAC;gBAC5B,KAAK,iDAAuB,CAAC,YAAY;oBACxC,OAAO,GAAG,IAAA,0CAAkB,EAAC,IAAI,CAAC,CAAC;oBACnC,MAAM;gBACP,KAAK,yDAA+B,CAAC,qBAAqB,CAAC;gBAC3D,KAAK,iDAAuB,CAAC,UAAU;oBACtC,kDAAkD;oBAClD,IAAI,OAAO,CAAC,MAAM,KAAK,SAAS,EAAE,CAAC;wBAClC,OAAO,GAAG,IAAA,6CAAsB,EAC/B,OAAO,CAAC,MAAM,CAAC,MAAM,EACrB,OAAO,CAAC,MAAM,CAAC,MAAM,EACrB,IAAI,EACJ,OAAO,CAAC,YAAY;wBACpB,oEAAoE;wBACpE,OAAO,CAAC,UAAU,KAAK,yDAA+B,CAAC,qBAAqB;4BAC3E,CAAC,CAAC,OAAO,CAAC,yBAAyB;4BACnC,CAAC,CAAC,SAAS,CACZ,CAAC;oBACH,CAAC;yBAAM,CAAC;wBACP,mFAAmF;wBACnF,OAAO,GAAG,IAAA,0CAAkB,EAAC,IAAI,CAAC,CAAC;oBACpC,CAAC;oBAED,MAAM;gBACP;oBACC,IAAA,0BAAe,EAAC,OAAO,CAAC,UAAU,CAAC,CAAC;YACtC,CAAC;YAED,oDAAoD;YACpD,OAAO,OAAO,CAAC;QAChB,CAAC;QACD,MAAM,EAAE,CAAC,IAAuB,EAAE,OAAkC,EAAc,EAAE;YACnF,6CAA6C;YAC7C,OAAO,IAAA,yBAAM,EACZ,IAAI,EACJ;gBACC,YAAY,EAAE,OAAO,CAAC,YAAY;gBAClC,YAAY,EAAE,OAAO,CAAC,YAAY;aAClC,EACD,OAAO,CAAC,yBAAyB,CACjC,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC;QAClC,CAAC;KACD,CAAC,CAAC;AACJ,CAAC;AAlED,kDAkEC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, unreachableCase } from \"@fluidframework/core-utils/internal\";\nimport type { IIdCompressor, SessionId } from \"@fluidframework/id-compressor\";\n\nimport {\n\ttype FluidClientVersion,\n\ttype ICodecOptions,\n\ttype IJsonCodec,\n\tmakeVersionedValidatedCodec,\n} from \"../../../codec/index.js\";\nimport {\n\tCursorLocationType,\n\ttype FieldKey,\n\ttype ITreeCursorSynchronous,\n\ttype SchemaAndPolicy,\n\ttype TreeChunk,\n\ttype TreeNodeSchemaIdentifier,\n} from \"../../../core/index.js\";\nimport {\n\tbrandedNumberType,\n\ttype Brand,\n\ttype JsonCompatibleReadOnly,\n} from \"../../../util/index.js\";\nimport {\n\tTreeCompressionStrategy,\n\tTreeCompressionStrategyExtended,\n\ttype TreeCompressionStrategyPrivate,\n} from \"../../treeCompressionUtils.js\";\n\nimport { decode } from \"./chunkDecoding.js\";\nimport type { FieldBatch } from \"./fieldBatch.js\";\nimport { EncodedFieldBatch, validVersions } from \"./format.js\";\nimport { schemaCompressedEncode } from \"./schemaBasedEncode.js\";\nimport { uncompressedEncode } from \"./uncompressedEncode.js\";\n\n/**\n * Reference ID for a chunk that is incrementally encoded.\n */\nexport type ChunkReferenceId = Brand<number, \"forest.ChunkReferenceId\">;\nconst ChunkReferenceId = brandedNumberType<ChunkReferenceId>({ multipleOf: 1, minimum: 0 });\n\n/**\n * Properties for incremental encoding.\n * Fields that support incremental encoding will encode their chunks separately by calling `encodeIncrementalField`.\n * @remarks\n * This supports features like incremental summarization where the summary from these fields can be re-used if\n * unchanged between summaries.\n * Note that each of these chunks that are incrementally encoded is fully self-describing (contain its own shapes\n * list and identifier table) and does not rely on context from its parent.\n */\nexport interface IncrementalEncoder {\n\t/**\n\t * Returns whether a field should be incrementally encoded.\n\t * @param nodeIdentifier - The identifier of the node containing the field.\n\t * @param fieldKey - The key of the field to check.\n\t */\n\tshouldEncodeFieldIncrementally(\n\t\tnodeIdentifier: TreeNodeSchemaIdentifier,\n\t\tfieldKey: FieldKey,\n\t): boolean;\n\t/**\n\t * Called to encode an incremental field at the cursor.\n\t * The chunks for this field are encoded separately from the main buffer.\n\t * @param cursor - The cursor pointing to the field to encode.\n\t * @param chunkEncoder - A function that encodes the contents of the passed chunk in the field.\n\t * @returns The reference IDs of the encoded chunks in the field.\n\t * This is used to retrieve the encoded chunks later.\n\t */\n\tencodeIncrementalField(\n\t\tcursor: ITreeCursorSynchronous,\n\t\tchunkEncoder: (chunk: TreeChunk) => EncodedFieldBatch,\n\t): ChunkReferenceId[];\n}\n\n/**\n * Properties for incremental decoding.\n *\n * Fields that had their chunks incrementally encoded will retrieve them by calling `getEncodedIncrementalChunk`.\n * @remarks\n * See {@link IncrementalEncoder} for more details.\n */\nexport interface IncrementalDecoder {\n\t/**\n\t * Called to get the encoded contents of an chunk in an incremental field with the given reference ID.\n\t * @param referenceId - The reference ID of the chunk to retrieve.\n\t * @returns The encoded contents of the chunk.\n\t */\n\tgetEncodedIncrementalChunk: (referenceId: ChunkReferenceId) => EncodedFieldBatch;\n}\n/**\n * Combines the properties of {@link IncrementalEncoder} and {@link IncrementalDecoder}.\n */\nexport interface IncrementalEncoderDecoder extends IncrementalEncoder, IncrementalDecoder {}\n\nexport interface FieldBatchEncodingContext {\n\treadonly encodeType: TreeCompressionStrategyPrivate;\n\treadonly idCompressor: IIdCompressor;\n\treadonly originatorId: SessionId;\n\treadonly schema?: SchemaAndPolicy;\n\t/**\n\t * An encoder / decoder for encoding and decoding of incremental fields.\n\t * This will be defined if incremental encoding is supported and enabled.\n\t */\n\treadonly incrementalEncoderDecoder?: IncrementalEncoderDecoder;\n}\n/**\n * @remarks\n * Fields in this batch currently don't have field schema for the root, which limits optimizations.\n */\nexport type FieldBatchCodec = IJsonCodec<\n\tFieldBatch,\n\tEncodedFieldBatch,\n\tJsonCompatibleReadOnly,\n\tFieldBatchEncodingContext\n>;\n\n/**\n * Get the write version for {@link makeFieldBatchCodec} based on the `oldestCompatibleClient` version.\n * @privateRemarks\n * TODO: makeFieldBatchCodec (and makeVersionDispatchingCodec transitively) should bake in this versionToFormat logic and the resulting codec can then support use with FluidClientVersion directly.\n */\nexport function fluidVersionToFieldBatchCodecWriteVersion(\n\toldestCompatibleClient: FluidClientVersion,\n): number {\n\t// There is currently on only 1 version.\n\treturn 1;\n}\n\nexport function makeFieldBatchCodec(\n\toptions: ICodecOptions,\n\twriteVersion: number,\n): FieldBatchCodec {\n\t// Note: it's important that the decode function is schema-agnostic for this strategy/layering to work, since\n\t// the schema that an op was encoded in doesn't necessarily match the current schema for the document (e.g. if\n\t// decode is being run on a client that just submitted a schema change, but the op is from another client who has\n\t// yet to receive that change).\n\tassert(\n\t\tvalidVersions.has(writeVersion),\n\t\t0x935 /* Invalid write version for FieldBatch codec */,\n\t);\n\n\t// TODO: use makeVersionDispatchingCodec to support adding more versions in the future.\n\treturn makeVersionedValidatedCodec(options, validVersions, EncodedFieldBatch, {\n\t\tencode: (data: FieldBatch, context: FieldBatchEncodingContext): EncodedFieldBatch => {\n\t\t\tfor (const cursor of data) {\n\t\t\t\tassert(\n\t\t\t\t\tcursor.mode === CursorLocationType.Fields,\n\t\t\t\t\t0x8a3 /* FieldBatch expects fields cursors */,\n\t\t\t\t);\n\t\t\t}\n\t\t\tlet encoded: EncodedFieldBatch;\n\t\t\tswitch (context.encodeType) {\n\t\t\t\tcase TreeCompressionStrategy.Uncompressed:\n\t\t\t\t\tencoded = uncompressedEncode(data);\n\t\t\t\t\tbreak;\n\t\t\t\tcase TreeCompressionStrategyExtended.CompressedIncremental:\n\t\t\t\tcase TreeCompressionStrategy.Compressed:\n\t\t\t\t\t// eslint-disable-next-line unicorn/prefer-ternary\n\t\t\t\t\tif (context.schema !== undefined) {\n\t\t\t\t\t\tencoded = schemaCompressedEncode(\n\t\t\t\t\t\t\tcontext.schema.schema,\n\t\t\t\t\t\t\tcontext.schema.policy,\n\t\t\t\t\t\t\tdata,\n\t\t\t\t\t\t\tcontext.idCompressor,\n\t\t\t\t\t\t\t// Incremental encoding is only supported for CompressedIncremental.\n\t\t\t\t\t\t\tcontext.encodeType === TreeCompressionStrategyExtended.CompressedIncremental\n\t\t\t\t\t\t\t\t? context.incrementalEncoderDecoder\n\t\t\t\t\t\t\t\t: undefined,\n\t\t\t\t\t\t);\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// TODO: consider enabling a somewhat compressed but not schema accelerated encode.\n\t\t\t\t\t\tencoded = uncompressedEncode(data);\n\t\t\t\t\t}\n\n\t\t\t\t\tbreak;\n\t\t\t\tdefault:\n\t\t\t\t\tunreachableCase(context.encodeType);\n\t\t\t}\n\n\t\t\t// TODO: consider checking input data was in schema.\n\t\t\treturn encoded;\n\t\t},\n\t\tdecode: (data: EncodedFieldBatch, context: FieldBatchEncodingContext): FieldBatch => {\n\t\t\t// TODO: consider checking data is in schema.\n\t\t\treturn decode(\n\t\t\t\tdata,\n\t\t\t\t{\n\t\t\t\t\tidCompressor: context.idCompressor,\n\t\t\t\t\toriginatorId: context.originatorId,\n\t\t\t\t},\n\t\t\t\tcontext.incrementalEncoderDecoder,\n\t\t\t).map((chunk) => chunk.cursor());\n\t\t},\n\t});\n}\n"]}
@@ -3,14 +3,15 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
  import type { IIdCompressor } from "@fluidframework/id-compressor";
6
- import { type FieldKey, type FieldKindIdentifier, type ITreeCursorSynchronous, type TreeFieldStoredSchema, type TreeNodeSchemaIdentifier, type Value } from "../../../core/index.js";
6
+ import { type FieldKey, type FieldKindIdentifier, type ITreeCursorSynchronous, type TreeChunk, type TreeFieldStoredSchema, type TreeNodeSchemaIdentifier, type Value } from "../../../core/index.js";
7
7
  import type { FlexFieldKind } from "../../modular-schema/index.js";
8
8
  import type { Counter, DeduplicationTable } from "./chunkCodecUtilities.js";
9
9
  import { type BufferFormat as BufferFormatGeneric, Shape as ShapeGeneric } from "./chunkEncodingGeneric.js";
10
10
  import type { FieldBatch } from "./fieldBatch.js";
11
11
  import { type EncodedChunkShape, type EncodedFieldBatch, type EncodedValueShape } from "./format.js";
12
+ import type { ChunkReferenceId, IncrementalEncoder } from "./codecs.js";
12
13
  /**
13
- * Encode data from `FieldBatch` into an `EncodedChunk`.
14
+ * Encode data from `FieldBatch` into an `EncodedFieldBatch`.
14
15
  *
15
16
  * Optimized for encoded size and encoding performance.
16
17
  *
@@ -114,20 +115,50 @@ export declare class InlineArrayEncoder extends ShapeGeneric<EncodedChunkShape>
114
115
  countReferencedShapesAndIdentifiers(identifiers: Counter<string>, shapeDiscovered: (shape: Shape) => void): void;
115
116
  get shape(): this;
116
117
  }
118
+ /**
119
+ * Encodes the shape for a nested array as {@link EncodedNestedArray} shape.
120
+ */
121
+ export declare class NestedArrayShape extends ShapeGeneric<EncodedChunkShape> {
122
+ readonly innerShape: Shape;
123
+ /**
124
+ * @param innerShape - The shape of each item in this nested array.
125
+ */
126
+ constructor(innerShape: Shape);
127
+ encodeShape(identifiers: DeduplicationTable<string>, shapes: DeduplicationTable<Shape>): EncodedChunkShape;
128
+ countReferencedShapesAndIdentifiers(identifiers: Counter<string>, shapeDiscovered: (shape: Shape) => void): void;
129
+ }
117
130
  /**
118
131
  * Encodes a field as a nested array with the {@link EncodedNestedArrayShape} shape.
119
132
  * @remarks
120
- * The fact this is also a Shape is an implementation detail of the encoder: that allows the shape it uses to be itself,
133
+ * The fact this is also exposes a Shape is an implementation detail: it allows the shape it uses to be itself
121
134
  * which is an easy way to keep all the related code together without extra objects.
122
135
  */
123
- export declare class NestedArrayEncoder extends ShapeGeneric<EncodedChunkShape> implements FieldEncoder {
124
- readonly inner: NodeEncoder;
125
- readonly shape: Shape;
126
- constructor(inner: NodeEncoder);
136
+ export declare class NestedArrayEncoder implements FieldEncoder {
137
+ readonly innerEncoder: NodeEncoder;
138
+ readonly shape: NestedArrayShape;
139
+ constructor(innerEncoder: NodeEncoder, shape?: NestedArrayShape);
127
140
  encodeField(cursor: ITreeCursorSynchronous, context: EncoderContext, outputBuffer: BufferFormat): void;
141
+ }
142
+ /**
143
+ * Encodes a chunk with the {@link EncodedIncrementalChunkShape} shape.
144
+ * This chunks will be encoded separately, i.e., the contents of the chunk will not be part of the main buffer.
145
+ * A reference to the chunk will be stored in the main buffer as an {@link ChunkReferenceId}.
146
+ */
147
+ export declare class IncrementalChunkShape extends ShapeGeneric<EncodedChunkShape> {
148
+ /**
149
+ * Encodes all the nodes in the chunk at the cursor position using `InlineArrayShape`.
150
+ */
151
+ static encodeChunk(chunk: TreeChunk, context: EncoderContext): BufferFormat;
128
152
  encodeShape(identifiers: DeduplicationTable<string>, shapes: DeduplicationTable<Shape>): EncodedChunkShape;
129
153
  countReferencedShapesAndIdentifiers(identifiers: Counter<string>, shapeDiscovered: (shape: Shape) => void): void;
154
+ get shape(): this;
130
155
  }
156
+ /**
157
+ * Encodes an incremental field whose chunks are encoded separately and referenced by their {@link ChunkReferenceId}.
158
+ * The shape of the content of this field is {@link NestedShape} where the items in the array are
159
+ * the {@link ChunkReferenceId}s of the encoded chunks.
160
+ */
161
+ export declare const incrementalFieldEncoder: FieldEncoder;
131
162
  /**
132
163
  * Encode `value` with `shape` into `outputBuffer`.
133
164
  *
@@ -137,6 +168,7 @@ export declare function encodeValue(value: Value, shape: EncodedValueShape, outp
137
168
  /**
138
169
  * Provides common contextual information during encoding, like schema and policy settings.
139
170
  * Also, provides a cache to avoid duplicating equivalent shapes during a batch of encode operations.
171
+ * @remarks
140
172
  * To avoid Shape duplication, any Shapes used in the encoding should either be:
141
173
  * - Singletons defined in a static scope.
142
174
  * - Cached in this object for future reuse such that all equivalent Shapes are deduplicated.
@@ -146,12 +178,18 @@ export declare class EncoderContext implements NodeEncodeBuilder, FieldEncodeBui
146
178
  private readonly fieldEncoderFromPolicy;
147
179
  readonly fieldShapes: ReadonlyMap<FieldKindIdentifier, FlexFieldKind>;
148
180
  readonly idCompressor: IIdCompressor;
181
+ private readonly incrementalEncoder;
149
182
  private readonly nodeEncodersFromSchema;
150
183
  private readonly nestedArrayEncoders;
151
- constructor(nodeEncoderFromPolicy: NodeEncoderPolicy, fieldEncoderFromPolicy: FieldEncoderPolicy, fieldShapes: ReadonlyMap<FieldKindIdentifier, FlexFieldKind>, idCompressor: IIdCompressor);
184
+ constructor(nodeEncoderFromPolicy: NodeEncoderPolicy, fieldEncoderFromPolicy: FieldEncoderPolicy, fieldShapes: ReadonlyMap<FieldKindIdentifier, FlexFieldKind>, idCompressor: IIdCompressor, incrementalEncoder: IncrementalEncoder | undefined);
152
185
  nodeEncoderFromSchema(schemaName: TreeNodeSchemaIdentifier): NodeEncoder;
153
186
  fieldEncoderFromSchema(fieldSchema: TreeFieldStoredSchema): FieldEncoder;
154
187
  nestedArrayEncoder(inner: NodeEncoder): NestedArrayEncoder;
188
+ get shouldEncodeIncrementally(): boolean;
189
+ /**
190
+ * {@link IncrementalEncoder.encodeIncrementalField}
191
+ */
192
+ encodeIncrementalField(cursor: ITreeCursorSynchronous, encoder: (chunk: TreeChunk) => BufferFormat): ChunkReferenceId[];
155
193
  }
156
194
  export interface NodeEncodeBuilder {
157
195
  nodeEncoderFromSchema(schemaName: TreeNodeSchemaIdentifier): NodeEncoder;
@@ -1 +1 @@
1
- {"version":3,"file":"compressedEncode.d.ts","sourceRoot":"","sources":["../../../../src/feature-libraries/chunked-forest/codec/compressedEncode.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAEnE,OAAO,EAEN,KAAK,QAAQ,EACb,KAAK,mBAAmB,EACxB,KAAK,sBAAsB,EAC3B,KAAK,qBAAqB,EAC1B,KAAK,wBAAwB,EAC7B,KAAK,KAAK,EAEV,MAAM,wBAAwB,CAAC;AAEhC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAEnE,OAAO,KAAK,EAAE,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAC5E,OAAO,EACN,KAAK,YAAY,IAAI,mBAAmB,EACxC,KAAK,IAAI,YAAY,EAErB,MAAM,2BAA2B,CA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AE,aAAa,CAAC;aAC5D,YAAY,EAAE,aAAa;IAP5C,OAAO,CAAC,QAAQ,CAAC,sBAAsB,CAC5B;IACX,OAAO,CAAC,QAAQ,CAAC,mBAAmB,CAAmD;gBAErE,qBAAqB,EAAE,iBAAiB,EACxC,sBAAsB,EAAE,kBAAkB,EAC3C,WAAW,EAAE,WAAW,CAAC,mBAAmB,EAAE,aAAa,CAAC,EAC5D,YAAY,EAAE,aAAa;IAGrC,qBAAqB,CAAC,UAAU,EAAE,wBAAwB,GAAG,WAAW;IAMxE,sBAAsB,CAAC,WAAW,EAAE,qBAAqB,GAAG,YAAY;IAIxE,kBAAkB,CAAC,KAAK,EAAE,WAAW,GAAG,kBAAkB;CAGjE;AAED,MAAM,WAAW,iBAAiB;IACjC,qBAAqB,CAAC,UAAU,EAAE,wBAAwB,GAAG,WAAW,CAAC;CACzE;AAED,MAAM,WAAW,kBAAkB;IAClC,sBAAsB,CAAC,MAAM,EAAE,qBAAqB,GAAG,YAAY,CAAC;CACpE;AAED;;GAEG;AACH,MAAM,MAAM,kBAAkB,GAAG,CAChC,WAAW,EAAE,iBAAiB,EAC9B,MAAM,EAAE,qBAAqB,KACzB,YAAY,CAAC;AAElB;;GAEG;AACH,MAAM,MAAM,iBAAiB,GAAG,CAC/B,YAAY,EAAE,kBAAkB,EAChC,UAAU,EAAE,wBAAwB,KAChC,WAAW,CAAC"}
1
+ {"version":3,"file":"compressedEncode.d.ts","sourceRoot":"","sources":["../../../../src/feature-libraries/chunked-forest/codec/compressedEncode.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAEnE,OAAO,EAEN,KAAK,QAAQ,EACb,KAAK,mBAAmB,EACxB,KAAK,sBAAsB,EAC3B,KAAK,SAAS,EACd,KAAK,qBAAqB,EAC1B,KAAK,wBAAwB,EAC7B,KAAK,KAAK,EAEV,MAAM,wBAAwB,CAAC;AAEhC,OAAO,KAAK,E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