@fluidframework/tree 2.72.0 → 2.73.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (609) hide show
  1. package/CHANGELOG.md +99 -0
  2. package/api-report/tree.alpha.api.md +17 -30
  3. package/dist/alpha.d.ts +3 -1
  4. package/dist/api.d.ts +6 -2
  5. package/dist/api.d.ts.map +1 -1
  6. package/dist/api.js +2 -11
  7. package/dist/api.js.map +1 -1
  8. package/dist/codec/codec.d.ts +9 -2
  9. package/dist/codec/codec.d.ts.map +1 -1
  10. package/dist/codec/codec.js +9 -2
  11. package/dist/codec/codec.js.map +1 -1
  12. package/dist/codec/index.d.ts +1 -1
  13. package/dist/codec/index.d.ts.map +1 -1
  14. package/dist/codec/index.js +2 -1
  15. package/dist/codec/index.js.map +1 -1
  16. package/dist/codec/versioned/codec.d.ts +7 -2
  17. package/dist/codec/versioned/codec.d.ts.map +1 -1
  18. package/dist/codec/versioned/codec.js +24 -1
  19. package/dist/codec/versioned/codec.js.map +1 -1
  20. package/dist/codec/versioned/index.d.ts +1 -1
  21. package/dist/codec/versioned/index.d.ts.map +1 -1
  22. package/dist/codec/versioned/index.js +2 -1
  23. package/dist/codec/versioned/index.js.map +1 -1
  24. package/dist/core/schema-stored/schema.d.ts +12 -1
  25. package/dist/core/schema-stored/schema.d.ts.map +1 -1
  26. package/dist/core/schema-stored/schema.js.map +1 -1
  27. package/dist/core/tree/detachedFieldIndexCodecs.d.ts.map +1 -1
  28. package/dist/core/tree/detachedFieldIndexCodecs.js +5 -3
  29. package/dist/core/tree/detachedFieldIndexCodecs.js.map +1 -1
  30. package/dist/feature-libraries/chunked-forest/chunkTree.d.ts +4 -5
  31. package/dist/feature-libraries/chunked-forest/chunkTree.d.ts.map +1 -1
  32. package/dist/feature-libraries/chunked-forest/chunkTree.js.map +1 -1
  33. package/dist/feature-libraries/chunked-forest/codec/chunkDecoding.d.ts.map +1 -1
  34. package/dist/feature-libraries/chunked-forest/codec/chunkDecoding.js +1 -0
  35. package/dist/feature-libraries/chunked-forest/codec/chunkDecoding.js.map +1 -1
  36. package/dist/feature-libraries/chunked-forest/codec/chunkEncodingGeneric.d.ts +2 -1
  37. package/dist/feature-libraries/chunked-forest/codec/chunkEncodingGeneric.d.ts.map +1 -1
  38. package/dist/feature-libraries/chunked-forest/codec/chunkEncodingGeneric.js.map +1 -1
  39. package/dist/feature-libraries/chunked-forest/codec/codecs.d.ts +1 -1
  40. package/dist/feature-libraries/chunked-forest/codec/codecs.d.ts.map +1 -1
  41. package/dist/feature-libraries/chunked-forest/codec/codecs.js +31 -17
  42. package/dist/feature-libraries/chunked-forest/codec/codecs.js.map +1 -1
  43. package/dist/feature-libraries/chunked-forest/codec/compressedEncode.d.ts +6 -6
  44. package/dist/feature-libraries/chunked-forest/codec/compressedEncode.d.ts.map +1 -1
  45. package/dist/feature-libraries/chunked-forest/codec/compressedEncode.js +4 -2
  46. package/dist/feature-libraries/chunked-forest/codec/compressedEncode.js.map +1 -1
  47. package/dist/feature-libraries/chunked-forest/codec/format.d.ts +156 -4
  48. package/dist/feature-libraries/chunked-forest/codec/format.d.ts.map +1 -1
  49. package/dist/feature-libraries/chunked-forest/codec/format.js +7 -3
  50. package/dist/feature-libraries/chunked-forest/codec/format.js.map +1 -1
  51. package/dist/feature-libraries/chunked-forest/codec/formatGeneric.d.ts +8 -3
  52. package/dist/feature-libraries/chunked-forest/codec/formatGeneric.d.ts.map +1 -1
  53. package/dist/feature-libraries/chunked-forest/codec/formatGeneric.js +4 -1
  54. package/dist/feature-libraries/chunked-forest/codec/formatGeneric.js.map +1 -1
  55. package/dist/feature-libraries/chunked-forest/codec/index.d.ts +1 -1
  56. package/dist/feature-libraries/chunked-forest/codec/index.d.ts.map +1 -1
  57. package/dist/feature-libraries/chunked-forest/codec/index.js +2 -1
  58. package/dist/feature-libraries/chunked-forest/codec/index.js.map +1 -1
  59. package/dist/feature-libraries/chunked-forest/codec/schemaBasedEncode.d.ts +13 -13
  60. package/dist/feature-libraries/chunked-forest/codec/schemaBasedEncode.d.ts.map +1 -1
  61. package/dist/feature-libraries/chunked-forest/codec/schemaBasedEncode.js +23 -6
  62. package/dist/feature-libraries/chunked-forest/codec/schemaBasedEncode.js.map +1 -1
  63. package/dist/feature-libraries/chunked-forest/codec/uncompressedEncode.d.ts +9 -8
  64. package/dist/feature-libraries/chunked-forest/codec/uncompressedEncode.d.ts.map +1 -1
  65. package/dist/feature-libraries/chunked-forest/codec/uncompressedEncode.js +20 -4
  66. package/dist/feature-libraries/chunked-forest/codec/uncompressedEncode.js.map +1 -1
  67. package/dist/feature-libraries/chunked-forest/index.d.ts +1 -1
  68. package/dist/feature-libraries/chunked-forest/index.d.ts.map +1 -1
  69. package/dist/feature-libraries/chunked-forest/index.js +2 -1
  70. package/dist/feature-libraries/chunked-forest/index.js.map +1 -1
  71. package/dist/feature-libraries/default-schema/defaultFieldKinds.d.ts +35 -17
  72. package/dist/feature-libraries/default-schema/defaultFieldKinds.d.ts.map +1 -1
  73. package/dist/feature-libraries/default-schema/defaultFieldKinds.js +53 -55
  74. package/dist/feature-libraries/default-schema/defaultFieldKinds.js.map +1 -1
  75. package/dist/feature-libraries/default-schema/index.d.ts +1 -3
  76. package/dist/feature-libraries/default-schema/index.d.ts.map +1 -1
  77. package/dist/feature-libraries/default-schema/index.js +2 -8
  78. package/dist/feature-libraries/default-schema/index.js.map +1 -1
  79. package/dist/feature-libraries/forest-summary/format.d.ts +2 -2
  80. package/dist/feature-libraries/forest-summary/format.d.ts.map +1 -1
  81. package/dist/feature-libraries/forest-summary/format.js +4 -2
  82. package/dist/feature-libraries/forest-summary/format.js.map +1 -1
  83. package/dist/feature-libraries/index.d.ts +4 -3
  84. package/dist/feature-libraries/index.d.ts.map +1 -1
  85. package/dist/feature-libraries/index.js +8 -7
  86. package/dist/feature-libraries/index.js.map +1 -1
  87. package/dist/feature-libraries/modular-schema/comparison.d.ts.map +1 -1
  88. package/dist/feature-libraries/modular-schema/comparison.js +1 -2
  89. package/dist/feature-libraries/modular-schema/comparison.js.map +1 -1
  90. package/dist/feature-libraries/modular-schema/fieldKind.d.ts +38 -12
  91. package/dist/feature-libraries/modular-schema/fieldKind.d.ts.map +1 -1
  92. package/dist/feature-libraries/modular-schema/fieldKind.js +29 -11
  93. package/dist/feature-libraries/modular-schema/fieldKind.js.map +1 -1
  94. package/dist/feature-libraries/modular-schema/fieldKindConfiguration.d.ts +2 -2
  95. package/dist/feature-libraries/modular-schema/fieldKindConfiguration.d.ts.map +1 -1
  96. package/dist/feature-libraries/modular-schema/fieldKindConfiguration.js.map +1 -1
  97. package/dist/feature-libraries/modular-schema/genericFieldKind.d.ts +2 -2
  98. package/dist/feature-libraries/modular-schema/genericFieldKind.d.ts.map +1 -1
  99. package/dist/feature-libraries/modular-schema/genericFieldKind.js +3 -2
  100. package/dist/feature-libraries/modular-schema/genericFieldKind.js.map +1 -1
  101. package/dist/feature-libraries/modular-schema/index.d.ts +0 -1
  102. package/dist/feature-libraries/modular-schema/index.d.ts.map +1 -1
  103. package/dist/feature-libraries/modular-schema/index.js +1 -3
  104. package/dist/feature-libraries/modular-schema/index.js.map +1 -1
  105. package/dist/feature-libraries/modular-schema/isNeverTree.d.ts +5 -6
  106. package/dist/feature-libraries/modular-schema/isNeverTree.d.ts.map +1 -1
  107. package/dist/feature-libraries/modular-schema/isNeverTree.js.map +1 -1
  108. package/dist/feature-libraries/modular-schema/modularChangeFamily.d.ts +8 -8
  109. package/dist/feature-libraries/modular-schema/modularChangeFamily.d.ts.map +1 -1
  110. package/dist/feature-libraries/modular-schema/modularChangeFamily.js +1 -2
  111. package/dist/feature-libraries/modular-schema/modularChangeFamily.js.map +1 -1
  112. package/dist/feature-libraries/modular-schema/modularChangeFormat.d.ts +66 -9
  113. package/dist/feature-libraries/modular-schema/modularChangeFormat.d.ts.map +1 -1
  114. package/dist/feature-libraries/object-forest/objectForest.d.ts.map +1 -1
  115. package/dist/feature-libraries/object-forest/objectForest.js +3 -2
  116. package/dist/feature-libraries/object-forest/objectForest.js.map +1 -1
  117. package/dist/feature-libraries/optional-field/index.d.ts +1 -1
  118. package/dist/feature-libraries/optional-field/index.d.ts.map +1 -1
  119. package/dist/feature-libraries/optional-field/index.js.map +1 -1
  120. package/dist/feature-libraries/optional-field/optionalFieldCodecs.d.ts.map +1 -1
  121. package/dist/feature-libraries/optional-field/optionalFieldCodecs.js +1 -5
  122. package/dist/feature-libraries/optional-field/optionalFieldCodecs.js.map +1 -1
  123. package/dist/feature-libraries/schema-index/codec.d.ts.map +1 -1
  124. package/dist/feature-libraries/schema-index/codec.js +5 -3
  125. package/dist/feature-libraries/schema-index/codec.js.map +1 -1
  126. package/dist/feature-libraries/{default-schema/schemaChecker.d.ts → schemaChecker.d.ts} +2 -2
  127. package/dist/feature-libraries/schemaChecker.d.ts.map +1 -0
  128. package/dist/feature-libraries/{default-schema/schemaChecker.js → schemaChecker.js} +3 -3
  129. package/dist/feature-libraries/schemaChecker.js.map +1 -0
  130. package/dist/feature-libraries/sequence-field/sequenceFieldCodecs.d.ts.map +1 -1
  131. package/dist/feature-libraries/sequence-field/sequenceFieldCodecs.js +0 -2
  132. package/dist/feature-libraries/sequence-field/sequenceFieldCodecs.js.map +1 -1
  133. package/dist/index.d.ts +2 -2
  134. package/dist/index.d.ts.map +1 -1
  135. package/dist/index.js +5 -3
  136. package/dist/index.js.map +1 -1
  137. package/dist/packageVersion.d.ts +1 -1
  138. package/dist/packageVersion.js +1 -1
  139. package/dist/packageVersion.js.map +1 -1
  140. package/dist/shared-tree/index.d.ts +1 -1
  141. package/dist/shared-tree/index.d.ts.map +1 -1
  142. package/dist/shared-tree/index.js +1 -2
  143. package/dist/shared-tree/index.js.map +1 -1
  144. package/dist/shared-tree/sharedTree.d.ts +0 -44
  145. package/dist/shared-tree/sharedTree.d.ts.map +1 -1
  146. package/dist/shared-tree/sharedTree.js +1 -52
  147. package/dist/shared-tree/sharedTree.js.map +1 -1
  148. package/dist/shared-tree/sharedTreeChangeCodecs.d.ts +1 -1
  149. package/dist/shared-tree/sharedTreeChangeCodecs.d.ts.map +1 -1
  150. package/dist/shared-tree/sharedTreeChangeCodecs.js +0 -2
  151. package/dist/shared-tree/sharedTreeChangeCodecs.js.map +1 -1
  152. package/dist/shared-tree-core/editManagerCodecs.d.ts.map +1 -1
  153. package/dist/shared-tree-core/editManagerCodecs.js +12 -6
  154. package/dist/shared-tree-core/editManagerCodecs.js.map +1 -1
  155. package/dist/shared-tree-core/editManagerFormatCommons.d.ts +3 -4
  156. package/dist/shared-tree-core/editManagerFormatCommons.d.ts.map +1 -1
  157. package/dist/shared-tree-core/editManagerFormatCommons.js +5 -8
  158. package/dist/shared-tree-core/editManagerFormatCommons.js.map +1 -1
  159. package/dist/shared-tree-core/index.d.ts +2 -2
  160. package/dist/shared-tree-core/index.d.ts.map +1 -1
  161. package/dist/shared-tree-core/index.js +3 -2
  162. package/dist/shared-tree-core/index.js.map +1 -1
  163. package/dist/shared-tree-core/messageCodecs.d.ts.map +1 -1
  164. package/dist/shared-tree-core/messageCodecs.js +20 -9
  165. package/dist/shared-tree-core/messageCodecs.js.map +1 -1
  166. package/dist/shared-tree-core/messageFormat.d.ts +4 -6
  167. package/dist/shared-tree-core/messageFormat.d.ts.map +1 -1
  168. package/dist/shared-tree-core/messageFormat.js +9 -7
  169. package/dist/shared-tree-core/messageFormat.js.map +1 -1
  170. package/dist/simple-tree/api/configuration.d.ts +2 -0
  171. package/dist/simple-tree/api/configuration.d.ts.map +1 -1
  172. package/dist/simple-tree/api/configuration.js +10 -0
  173. package/dist/simple-tree/api/configuration.js.map +1 -1
  174. package/dist/simple-tree/api/index.d.ts +1 -0
  175. package/dist/simple-tree/api/index.d.ts.map +1 -1
  176. package/dist/simple-tree/api/index.js +5 -1
  177. package/dist/simple-tree/api/index.js.map +1 -1
  178. package/dist/simple-tree/api/schemaFromSimple.d.ts.map +1 -1
  179. package/dist/simple-tree/api/schemaFromSimple.js +7 -1
  180. package/dist/simple-tree/api/schemaFromSimple.js.map +1 -1
  181. package/dist/simple-tree/api/simpleSchemaCodec.js +4 -6
  182. package/dist/simple-tree/api/simpleSchemaCodec.js.map +1 -1
  183. package/dist/simple-tree/api/snapshotCompatibilityChecker.d.ts +103 -0
  184. package/dist/simple-tree/api/snapshotCompatibilityChecker.d.ts.map +1 -0
  185. package/dist/simple-tree/api/snapshotCompatibilityChecker.js +128 -0
  186. package/dist/simple-tree/api/snapshotCompatibilityChecker.js.map +1 -0
  187. package/dist/simple-tree/api/tree.d.ts +1 -1
  188. package/dist/simple-tree/api/tree.js +1 -1
  189. package/dist/simple-tree/api/tree.js.map +1 -1
  190. package/dist/simple-tree/core/allowedTypes.js +1 -1
  191. package/dist/simple-tree/core/allowedTypes.js.map +1 -1
  192. package/dist/simple-tree/core/index.d.ts +3 -3
  193. package/dist/simple-tree/core/index.d.ts.map +1 -1
  194. package/dist/simple-tree/core/index.js +3 -1
  195. package/dist/simple-tree/core/index.js.map +1 -1
  196. package/dist/simple-tree/core/toStored.d.ts +12 -5
  197. package/dist/simple-tree/core/toStored.d.ts.map +1 -1
  198. package/dist/simple-tree/core/toStored.js +26 -10
  199. package/dist/simple-tree/core/toStored.js.map +1 -1
  200. package/dist/simple-tree/core/treeNodeSchema.d.ts +1 -6
  201. package/dist/simple-tree/core/treeNodeSchema.d.ts.map +1 -1
  202. package/dist/simple-tree/core/treeNodeSchema.js.map +1 -1
  203. package/dist/simple-tree/core/treeNodeValid.d.ts +1 -1
  204. package/dist/simple-tree/core/treeNodeValid.d.ts.map +1 -1
  205. package/dist/simple-tree/core/treeNodeValid.js +1 -2
  206. package/dist/simple-tree/core/treeNodeValid.js.map +1 -1
  207. package/dist/simple-tree/fieldSchema.d.ts.map +1 -1
  208. package/dist/simple-tree/fieldSchema.js +1 -8
  209. package/dist/simple-tree/fieldSchema.js.map +1 -1
  210. package/dist/simple-tree/index.d.ts +2 -2
  211. package/dist/simple-tree/index.d.ts.map +1 -1
  212. package/dist/simple-tree/index.js +9 -3
  213. package/dist/simple-tree/index.js.map +1 -1
  214. package/dist/simple-tree/leafNodeSchema.d.ts.map +1 -1
  215. package/dist/simple-tree/leafNodeSchema.js +0 -1
  216. package/dist/simple-tree/leafNodeSchema.js.map +1 -1
  217. package/dist/simple-tree/node-kinds/array/arrayNode.d.ts.map +1 -1
  218. package/dist/simple-tree/node-kinds/array/arrayNode.js +13 -49
  219. package/dist/simple-tree/node-kinds/array/arrayNode.js.map +1 -1
  220. package/dist/simple-tree/node-kinds/map/mapNode.d.ts.map +1 -1
  221. package/dist/simple-tree/node-kinds/map/mapNode.js +1 -5
  222. package/dist/simple-tree/node-kinds/map/mapNode.js.map +1 -1
  223. package/dist/simple-tree/node-kinds/object/objectNode.d.ts.map +1 -1
  224. package/dist/simple-tree/node-kinds/object/objectNode.js +2 -10
  225. package/dist/simple-tree/node-kinds/object/objectNode.js.map +1 -1
  226. package/dist/simple-tree/node-kinds/record/recordNode.d.ts.map +1 -1
  227. package/dist/simple-tree/node-kinds/record/recordNode.js +1 -5
  228. package/dist/simple-tree/node-kinds/record/recordNode.js.map +1 -1
  229. package/dist/simple-tree/simpleSchema.d.ts +15 -3
  230. package/dist/simple-tree/simpleSchema.d.ts.map +1 -1
  231. package/dist/simple-tree/simpleSchema.js.map +1 -1
  232. package/dist/simple-tree/toStoredSchema.d.ts +20 -8
  233. package/dist/simple-tree/toStoredSchema.d.ts.map +1 -1
  234. package/dist/simple-tree/toStoredSchema.js +27 -22
  235. package/dist/simple-tree/toStoredSchema.js.map +1 -1
  236. package/dist/simple-tree/unhydratedFlexTreeFromInsertable.d.ts.map +1 -1
  237. package/dist/simple-tree/unhydratedFlexTreeFromInsertable.js +18 -15
  238. package/dist/simple-tree/unhydratedFlexTreeFromInsertable.js.map +1 -1
  239. package/dist/tableSchema.d.ts +22 -52
  240. package/dist/tableSchema.d.ts.map +1 -1
  241. package/dist/tableSchema.js +141 -277
  242. package/dist/tableSchema.js.map +1 -1
  243. package/dist/util/arrayUtilities.d.ts +45 -0
  244. package/dist/util/arrayUtilities.d.ts.map +1 -0
  245. package/dist/util/arrayUtilities.js +76 -0
  246. package/dist/util/arrayUtilities.js.map +1 -0
  247. package/dist/util/index.d.ts +1 -0
  248. package/dist/util/index.d.ts.map +1 -1
  249. package/dist/util/index.js +7 -2
  250. package/dist/util/index.js.map +1 -1
  251. package/lib/alpha.d.ts +3 -1
  252. package/lib/api.d.ts +6 -2
  253. package/lib/api.d.ts.map +1 -1
  254. package/lib/api.js +2 -13
  255. package/lib/api.js.map +1 -1
  256. package/lib/codec/codec.d.ts +9 -2
  257. package/lib/codec/codec.d.ts.map +1 -1
  258. package/lib/codec/codec.js +9 -2
  259. package/lib/codec/codec.js.map +1 -1
  260. package/lib/codec/index.d.ts +1 -1
  261. package/lib/codec/index.d.ts.map +1 -1
  262. package/lib/codec/index.js +1 -1
  263. package/lib/codec/index.js.map +1 -1
  264. package/lib/codec/versioned/codec.d.ts +7 -2
  265. package/lib/codec/versioned/codec.d.ts.map +1 -1
  266. package/lib/codec/versioned/codec.js +22 -0
  267. package/lib/codec/versioned/codec.js.map +1 -1
  268. package/lib/codec/versioned/index.d.ts +1 -1
  269. package/lib/codec/versioned/index.d.ts.map +1 -1
  270. package/lib/codec/versioned/index.js +1 -1
  271. package/lib/codec/versioned/index.js.map +1 -1
  272. package/lib/core/schema-stored/schema.d.ts +12 -1
  273. package/lib/core/schema-stored/schema.d.ts.map +1 -1
  274. package/lib/core/schema-stored/schema.js.map +1 -1
  275. package/lib/core/tree/detachedFieldIndexCodecs.d.ts.map +1 -1
  276. package/lib/core/tree/detachedFieldIndexCodecs.js +5 -3
  277. package/lib/core/tree/detachedFieldIndexCodecs.js.map +1 -1
  278. package/lib/feature-libraries/chunked-forest/chunkTree.d.ts +4 -5
  279. package/lib/feature-libraries/chunked-forest/chunkTree.d.ts.map +1 -1
  280. package/lib/feature-libraries/chunked-forest/chunkTree.js.map +1 -1
  281. package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.d.ts.map +1 -1
  282. package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.js +2 -1
  283. package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.js.map +1 -1
  284. package/lib/feature-libraries/chunked-forest/codec/chunkEncodingGeneric.d.ts +2 -1
  285. package/lib/feature-libraries/chunked-forest/codec/chunkEncodingGeneric.d.ts.map +1 -1
  286. package/lib/feature-libraries/chunked-forest/codec/chunkEncodingGeneric.js.map +1 -1
  287. package/lib/feature-libraries/chunked-forest/codec/codecs.d.ts +1 -1
  288. package/lib/feature-libraries/chunked-forest/codec/codecs.d.ts.map +1 -1
  289. package/lib/feature-libraries/chunked-forest/codec/codecs.js +34 -20
  290. package/lib/feature-libraries/chunked-forest/codec/codecs.js.map +1 -1
  291. package/lib/feature-libraries/chunked-forest/codec/compressedEncode.d.ts +6 -6
  292. package/lib/feature-libraries/chunked-forest/codec/compressedEncode.d.ts.map +1 -1
  293. package/lib/feature-libraries/chunked-forest/codec/compressedEncode.js +4 -2
  294. package/lib/feature-libraries/chunked-forest/codec/compressedEncode.js.map +1 -1
  295. package/lib/feature-libraries/chunked-forest/codec/format.d.ts +156 -4
  296. package/lib/feature-libraries/chunked-forest/codec/format.d.ts.map +1 -1
  297. package/lib/feature-libraries/chunked-forest/codec/format.js +6 -2
  298. package/lib/feature-libraries/chunked-forest/codec/format.js.map +1 -1
  299. package/lib/feature-libraries/chunked-forest/codec/formatGeneric.d.ts +8 -3
  300. package/lib/feature-libraries/chunked-forest/codec/formatGeneric.d.ts.map +1 -1
  301. package/lib/feature-libraries/chunked-forest/codec/formatGeneric.js +4 -1
  302. package/lib/feature-libraries/chunked-forest/codec/formatGeneric.js.map +1 -1
  303. package/lib/feature-libraries/chunked-forest/codec/index.d.ts +1 -1
  304. package/lib/feature-libraries/chunked-forest/codec/index.d.ts.map +1 -1
  305. package/lib/feature-libraries/chunked-forest/codec/index.js +1 -1
  306. package/lib/feature-libraries/chunked-forest/codec/index.js.map +1 -1
  307. package/lib/feature-libraries/chunked-forest/codec/schemaBasedEncode.d.ts +13 -13
  308. package/lib/feature-libraries/chunked-forest/codec/schemaBasedEncode.d.ts.map +1 -1
  309. package/lib/feature-libraries/chunked-forest/codec/schemaBasedEncode.js +22 -6
  310. package/lib/feature-libraries/chunked-forest/codec/schemaBasedEncode.js.map +1 -1
  311. package/lib/feature-libraries/chunked-forest/codec/uncompressedEncode.d.ts +9 -8
  312. package/lib/feature-libraries/chunked-forest/codec/uncompressedEncode.d.ts.map +1 -1
  313. package/lib/feature-libraries/chunked-forest/codec/uncompressedEncode.js +17 -2
  314. package/lib/feature-libraries/chunked-forest/codec/uncompressedEncode.js.map +1 -1
  315. package/lib/feature-libraries/chunked-forest/index.d.ts +1 -1
  316. package/lib/feature-libraries/chunked-forest/index.d.ts.map +1 -1
  317. package/lib/feature-libraries/chunked-forest/index.js +1 -1
  318. package/lib/feature-libraries/chunked-forest/index.js.map +1 -1
  319. package/lib/feature-libraries/default-schema/defaultFieldKinds.d.ts +35 -17
  320. package/lib/feature-libraries/default-schema/defaultFieldKinds.d.ts.map +1 -1
  321. package/lib/feature-libraries/default-schema/defaultFieldKinds.js +55 -57
  322. package/lib/feature-libraries/default-schema/defaultFieldKinds.js.map +1 -1
  323. package/lib/feature-libraries/default-schema/index.d.ts +1 -3
  324. package/lib/feature-libraries/default-schema/index.d.ts.map +1 -1
  325. package/lib/feature-libraries/default-schema/index.js +1 -3
  326. package/lib/feature-libraries/default-schema/index.js.map +1 -1
  327. package/lib/feature-libraries/forest-summary/format.d.ts +2 -2
  328. package/lib/feature-libraries/forest-summary/format.d.ts.map +1 -1
  329. package/lib/feature-libraries/forest-summary/format.js +4 -2
  330. package/lib/feature-libraries/forest-summary/format.js.map +1 -1
  331. package/lib/feature-libraries/index.d.ts +4 -3
  332. package/lib/feature-libraries/index.d.ts.map +1 -1
  333. package/lib/feature-libraries/index.js +4 -3
  334. package/lib/feature-libraries/index.js.map +1 -1
  335. package/lib/feature-libraries/modular-schema/comparison.d.ts.map +1 -1
  336. package/lib/feature-libraries/modular-schema/comparison.js +1 -2
  337. package/lib/feature-libraries/modular-schema/comparison.js.map +1 -1
  338. package/lib/feature-libraries/modular-schema/fieldKind.d.ts +38 -12
  339. package/lib/feature-libraries/modular-schema/fieldKind.d.ts.map +1 -1
  340. package/lib/feature-libraries/modular-schema/fieldKind.js +29 -11
  341. package/lib/feature-libraries/modular-schema/fieldKind.js.map +1 -1
  342. package/lib/feature-libraries/modular-schema/fieldKindConfiguration.d.ts +2 -2
  343. package/lib/feature-libraries/modular-schema/fieldKindConfiguration.d.ts.map +1 -1
  344. package/lib/feature-libraries/modular-schema/fieldKindConfiguration.js.map +1 -1
  345. package/lib/feature-libraries/modular-schema/genericFieldKind.d.ts +2 -2
  346. package/lib/feature-libraries/modular-schema/genericFieldKind.d.ts.map +1 -1
  347. package/lib/feature-libraries/modular-schema/genericFieldKind.js +3 -2
  348. package/lib/feature-libraries/modular-schema/genericFieldKind.js.map +1 -1
  349. package/lib/feature-libraries/modular-schema/index.d.ts +0 -1
  350. package/lib/feature-libraries/modular-schema/index.d.ts.map +1 -1
  351. package/lib/feature-libraries/modular-schema/index.js +0 -1
  352. package/lib/feature-libraries/modular-schema/index.js.map +1 -1
  353. package/lib/feature-libraries/modular-schema/isNeverTree.d.ts +5 -6
  354. package/lib/feature-libraries/modular-schema/isNeverTree.d.ts.map +1 -1
  355. package/lib/feature-libraries/modular-schema/isNeverTree.js.map +1 -1
  356. package/lib/feature-libraries/modular-schema/modularChangeFamily.d.ts +8 -8
  357. package/lib/feature-libraries/modular-schema/modularChangeFamily.d.ts.map +1 -1
  358. package/lib/feature-libraries/modular-schema/modularChangeFamily.js +1 -2
  359. package/lib/feature-libraries/modular-schema/modularChangeFamily.js.map +1 -1
  360. package/lib/feature-libraries/modular-schema/modularChangeFormat.d.ts +66 -9
  361. package/lib/feature-libraries/modular-schema/modularChangeFormat.d.ts.map +1 -1
  362. package/lib/feature-libraries/object-forest/objectForest.d.ts.map +1 -1
  363. package/lib/feature-libraries/object-forest/objectForest.js +2 -1
  364. package/lib/feature-libraries/object-forest/objectForest.js.map +1 -1
  365. package/lib/feature-libraries/optional-field/index.d.ts +1 -1
  366. package/lib/feature-libraries/optional-field/index.d.ts.map +1 -1
  367. package/lib/feature-libraries/optional-field/index.js.map +1 -1
  368. package/lib/feature-libraries/optional-field/optionalFieldCodecs.d.ts.map +1 -1
  369. package/lib/feature-libraries/optional-field/optionalFieldCodecs.js +1 -5
  370. package/lib/feature-libraries/optional-field/optionalFieldCodecs.js.map +1 -1
  371. package/lib/feature-libraries/schema-index/codec.d.ts.map +1 -1
  372. package/lib/feature-libraries/schema-index/codec.js +5 -3
  373. package/lib/feature-libraries/schema-index/codec.js.map +1 -1
  374. package/lib/feature-libraries/{default-schema/schemaChecker.d.ts → schemaChecker.d.ts} +2 -2
  375. package/lib/feature-libraries/schemaChecker.d.ts.map +1 -0
  376. package/lib/feature-libraries/{default-schema/schemaChecker.js → schemaChecker.js} +3 -3
  377. package/lib/feature-libraries/schemaChecker.js.map +1 -0
  378. package/lib/feature-libraries/sequence-field/sequenceFieldCodecs.d.ts.map +1 -1
  379. package/lib/feature-libraries/sequence-field/sequenceFieldCodecs.js +0 -2
  380. package/lib/feature-libraries/sequence-field/sequenceFieldCodecs.js.map +1 -1
  381. package/lib/index.d.ts +2 -2
  382. package/lib/index.d.ts.map +1 -1
  383. package/lib/index.js +2 -2
  384. package/lib/index.js.map +1 -1
  385. package/lib/packageVersion.d.ts +1 -1
  386. package/lib/packageVersion.js +1 -1
  387. package/lib/packageVersion.js.map +1 -1
  388. package/lib/shared-tree/index.d.ts +1 -1
  389. package/lib/shared-tree/index.d.ts.map +1 -1
  390. package/lib/shared-tree/index.js +1 -1
  391. package/lib/shared-tree/index.js.map +1 -1
  392. package/lib/shared-tree/sharedTree.d.ts +0 -44
  393. package/lib/shared-tree/sharedTree.d.ts.map +1 -1
  394. package/lib/shared-tree/sharedTree.js +0 -51
  395. package/lib/shared-tree/sharedTree.js.map +1 -1
  396. package/lib/shared-tree/sharedTreeChangeCodecs.d.ts +1 -1
  397. package/lib/shared-tree/sharedTreeChangeCodecs.d.ts.map +1 -1
  398. package/lib/shared-tree/sharedTreeChangeCodecs.js +0 -2
  399. package/lib/shared-tree/sharedTreeChangeCodecs.js.map +1 -1
  400. package/lib/shared-tree-core/editManagerCodecs.d.ts.map +1 -1
  401. package/lib/shared-tree-core/editManagerCodecs.js +13 -7
  402. package/lib/shared-tree-core/editManagerCodecs.js.map +1 -1
  403. package/lib/shared-tree-core/editManagerFormatCommons.d.ts +3 -4
  404. package/lib/shared-tree-core/editManagerFormatCommons.d.ts.map +1 -1
  405. package/lib/shared-tree-core/editManagerFormatCommons.js +4 -7
  406. package/lib/shared-tree-core/editManagerFormatCommons.js.map +1 -1
  407. package/lib/shared-tree-core/index.d.ts +2 -2
  408. package/lib/shared-tree-core/index.d.ts.map +1 -1
  409. package/lib/shared-tree-core/index.js +2 -2
  410. package/lib/shared-tree-core/index.js.map +1 -1
  411. package/lib/shared-tree-core/messageCodecs.d.ts.map +1 -1
  412. package/lib/shared-tree-core/messageCodecs.js +21 -10
  413. package/lib/shared-tree-core/messageCodecs.js.map +1 -1
  414. package/lib/shared-tree-core/messageFormat.d.ts +4 -6
  415. package/lib/shared-tree-core/messageFormat.d.ts.map +1 -1
  416. package/lib/shared-tree-core/messageFormat.js +8 -6
  417. package/lib/shared-tree-core/messageFormat.js.map +1 -1
  418. package/lib/simple-tree/api/configuration.d.ts +2 -0
  419. package/lib/simple-tree/api/configuration.d.ts.map +1 -1
  420. package/lib/simple-tree/api/configuration.js +10 -0
  421. package/lib/simple-tree/api/configuration.js.map +1 -1
  422. package/lib/simple-tree/api/index.d.ts +1 -0
  423. package/lib/simple-tree/api/index.d.ts.map +1 -1
  424. package/lib/simple-tree/api/index.js +1 -0
  425. package/lib/simple-tree/api/index.js.map +1 -1
  426. package/lib/simple-tree/api/schemaFromSimple.d.ts.map +1 -1
  427. package/lib/simple-tree/api/schemaFromSimple.js +8 -2
  428. package/lib/simple-tree/api/schemaFromSimple.js.map +1 -1
  429. package/lib/simple-tree/api/simpleSchemaCodec.js +5 -7
  430. package/lib/simple-tree/api/simpleSchemaCodec.js.map +1 -1
  431. package/lib/simple-tree/api/snapshotCompatibilityChecker.d.ts +103 -0
  432. package/lib/simple-tree/api/snapshotCompatibilityChecker.d.ts.map +1 -0
  433. package/lib/simple-tree/api/snapshotCompatibilityChecker.js +122 -0
  434. package/lib/simple-tree/api/snapshotCompatibilityChecker.js.map +1 -0
  435. package/lib/simple-tree/api/tree.d.ts +1 -1
  436. package/lib/simple-tree/api/tree.js +1 -1
  437. package/lib/simple-tree/api/tree.js.map +1 -1
  438. package/lib/simple-tree/core/allowedTypes.js +1 -1
  439. package/lib/simple-tree/core/allowedTypes.js.map +1 -1
  440. package/lib/simple-tree/core/index.d.ts +3 -3
  441. package/lib/simple-tree/core/index.d.ts.map +1 -1
  442. package/lib/simple-tree/core/index.js +2 -2
  443. package/lib/simple-tree/core/index.js.map +1 -1
  444. package/lib/simple-tree/core/toStored.d.ts +12 -5
  445. package/lib/simple-tree/core/toStored.d.ts.map +1 -1
  446. package/lib/simple-tree/core/toStored.js +25 -9
  447. package/lib/simple-tree/core/toStored.js.map +1 -1
  448. package/lib/simple-tree/core/treeNodeSchema.d.ts +1 -6
  449. package/lib/simple-tree/core/treeNodeSchema.d.ts.map +1 -1
  450. package/lib/simple-tree/core/treeNodeSchema.js.map +1 -1
  451. package/lib/simple-tree/core/treeNodeValid.d.ts +1 -1
  452. package/lib/simple-tree/core/treeNodeValid.d.ts.map +1 -1
  453. package/lib/simple-tree/core/treeNodeValid.js +1 -2
  454. package/lib/simple-tree/core/treeNodeValid.js.map +1 -1
  455. package/lib/simple-tree/fieldSchema.d.ts.map +1 -1
  456. package/lib/simple-tree/fieldSchema.js +2 -9
  457. package/lib/simple-tree/fieldSchema.js.map +1 -1
  458. package/lib/simple-tree/index.d.ts +2 -2
  459. package/lib/simple-tree/index.d.ts.map +1 -1
  460. package/lib/simple-tree/index.js +2 -2
  461. package/lib/simple-tree/index.js.map +1 -1
  462. package/lib/simple-tree/leafNodeSchema.d.ts.map +1 -1
  463. package/lib/simple-tree/leafNodeSchema.js +1 -2
  464. package/lib/simple-tree/leafNodeSchema.js.map +1 -1
  465. package/lib/simple-tree/node-kinds/array/arrayNode.d.ts.map +1 -1
  466. package/lib/simple-tree/node-kinds/array/arrayNode.js +15 -51
  467. package/lib/simple-tree/node-kinds/array/arrayNode.js.map +1 -1
  468. package/lib/simple-tree/node-kinds/map/mapNode.d.ts.map +1 -1
  469. package/lib/simple-tree/node-kinds/map/mapNode.js +3 -7
  470. package/lib/simple-tree/node-kinds/map/mapNode.js.map +1 -1
  471. package/lib/simple-tree/node-kinds/object/objectNode.d.ts.map +1 -1
  472. package/lib/simple-tree/node-kinds/object/objectNode.js +3 -11
  473. package/lib/simple-tree/node-kinds/object/objectNode.js.map +1 -1
  474. package/lib/simple-tree/node-kinds/record/recordNode.d.ts.map +1 -1
  475. package/lib/simple-tree/node-kinds/record/recordNode.js +3 -7
  476. package/lib/simple-tree/node-kinds/record/recordNode.js.map +1 -1
  477. package/lib/simple-tree/simpleSchema.d.ts +15 -3
  478. package/lib/simple-tree/simpleSchema.d.ts.map +1 -1
  479. package/lib/simple-tree/simpleSchema.js.map +1 -1
  480. package/lib/simple-tree/toStoredSchema.d.ts +20 -8
  481. package/lib/simple-tree/toStoredSchema.d.ts.map +1 -1
  482. package/lib/simple-tree/toStoredSchema.js +28 -24
  483. package/lib/simple-tree/toStoredSchema.js.map +1 -1
  484. package/lib/simple-tree/unhydratedFlexTreeFromInsertable.d.ts.map +1 -1
  485. package/lib/simple-tree/unhydratedFlexTreeFromInsertable.js +20 -17
  486. package/lib/simple-tree/unhydratedFlexTreeFromInsertable.js.map +1 -1
  487. package/lib/tableSchema.d.ts +22 -52
  488. package/lib/tableSchema.d.ts.map +1 -1
  489. package/lib/tableSchema.js +143 -279
  490. package/lib/tableSchema.js.map +1 -1
  491. package/lib/util/arrayUtilities.d.ts +45 -0
  492. package/lib/util/arrayUtilities.d.ts.map +1 -0
  493. package/lib/util/arrayUtilities.js +69 -0
  494. package/lib/util/arrayUtilities.js.map +1 -0
  495. package/lib/util/index.d.ts +1 -0
  496. package/lib/util/index.d.ts.map +1 -1
  497. package/lib/util/index.js +1 -0
  498. package/lib/util/index.js.map +1 -1
  499. package/package.json +21 -21
  500. package/src/api.ts +22 -11
  501. package/src/codec/codec.ts +10 -2
  502. package/src/codec/index.ts +1 -0
  503. package/src/codec/versioned/codec.ts +40 -2
  504. package/src/codec/versioned/index.ts +1 -0
  505. package/src/core/schema-stored/schema.ts +12 -1
  506. package/src/core/tree/detachedFieldIndexCodecs.ts +10 -3
  507. package/src/feature-libraries/README.md +1 -1
  508. package/src/feature-libraries/chunked-forest/chunkTree.ts +3 -3
  509. package/src/feature-libraries/chunked-forest/codec/chunkDecoding.ts +5 -0
  510. package/src/feature-libraries/chunked-forest/codec/chunkEncodingGeneric.ts +2 -1
  511. package/src/feature-libraries/chunked-forest/codec/codecs.ts +52 -19
  512. package/src/feature-libraries/chunked-forest/codec/compressedEncode.ts +8 -3
  513. package/src/feature-libraries/chunked-forest/codec/format.ts +14 -4
  514. package/src/feature-libraries/chunked-forest/codec/formatGeneric.ts +7 -2
  515. package/src/feature-libraries/chunked-forest/codec/index.ts +1 -4
  516. package/src/feature-libraries/chunked-forest/codec/schemaBasedEncode.ts +62 -9
  517. package/src/feature-libraries/chunked-forest/codec/uncompressedEncode.ts +24 -2
  518. package/src/feature-libraries/chunked-forest/index.ts +1 -1
  519. package/src/feature-libraries/default-schema/defaultFieldKinds.ts +86 -74
  520. package/src/feature-libraries/default-schema/index.ts +1 -9
  521. package/src/feature-libraries/forest-summary/format.ts +15 -9
  522. package/src/feature-libraries/index.ts +7 -5
  523. package/src/feature-libraries/modular-schema/comparison.ts +2 -3
  524. package/src/feature-libraries/modular-schema/fieldKind.ts +90 -13
  525. package/src/feature-libraries/modular-schema/fieldKindConfiguration.ts +2 -3
  526. package/src/feature-libraries/modular-schema/genericFieldKind.ts +6 -6
  527. package/src/feature-libraries/modular-schema/index.ts +0 -1
  528. package/src/feature-libraries/modular-schema/isNeverTree.ts +7 -8
  529. package/src/feature-libraries/modular-schema/modularChangeFamily.ts +13 -13
  530. package/src/feature-libraries/object-forest/objectForest.ts +2 -6
  531. package/src/feature-libraries/optional-field/index.ts +1 -0
  532. package/src/feature-libraries/optional-field/optionalFieldCodecs.ts +1 -5
  533. package/src/feature-libraries/schema-index/codec.ts +10 -3
  534. package/src/feature-libraries/{default-schema/schemaChecker.ts → schemaChecker.ts} +4 -4
  535. package/src/feature-libraries/sequence-field/sequenceFieldCodecs.ts +0 -2
  536. package/src/index.ts +3 -1
  537. package/src/packageVersion.ts +1 -1
  538. package/src/shared-tree/index.ts +0 -1
  539. package/src/shared-tree/sharedTree.ts +0 -70
  540. package/src/shared-tree/sharedTreeChangeCodecs.ts +1 -6
  541. package/src/shared-tree-core/editManagerCodecs.ts +19 -7
  542. package/src/shared-tree-core/editManagerFormatCommons.ts +11 -12
  543. package/src/shared-tree-core/index.ts +6 -2
  544. package/src/shared-tree-core/messageCodecs.ts +32 -17
  545. package/src/shared-tree-core/messageFormat.ts +8 -6
  546. package/src/simple-tree/api/configuration.ts +17 -4
  547. package/src/simple-tree/api/index.ts +5 -0
  548. package/src/simple-tree/api/schemaFromSimple.ts +14 -6
  549. package/src/simple-tree/api/simpleSchemaCodec.ts +10 -9
  550. package/src/simple-tree/api/snapshotCompatibilityChecker.ts +135 -0
  551. package/src/simple-tree/api/tree.ts +1 -1
  552. package/src/simple-tree/core/allowedTypes.ts +1 -1
  553. package/src/simple-tree/core/index.ts +3 -1
  554. package/src/simple-tree/core/toStored.ts +42 -18
  555. package/src/simple-tree/core/treeNodeSchema.ts +1 -7
  556. package/src/simple-tree/core/treeNodeValid.ts +0 -2
  557. package/src/simple-tree/fieldSchema.ts +2 -11
  558. package/src/simple-tree/index.ts +6 -1
  559. package/src/simple-tree/leafNodeSchema.ts +1 -2
  560. package/src/simple-tree/node-kinds/array/arrayNode.ts +26 -75
  561. package/src/simple-tree/node-kinds/map/mapNode.ts +1 -15
  562. package/src/simple-tree/node-kinds/object/objectNode.ts +2 -17
  563. package/src/simple-tree/node-kinds/record/recordNode.ts +1 -15
  564. package/src/simple-tree/simpleSchema.ts +16 -3
  565. package/src/simple-tree/toStoredSchema.ts +54 -38
  566. package/src/simple-tree/unhydratedFlexTreeFromInsertable.ts +22 -17
  567. package/src/tableSchema.ts +110 -334
  568. package/src/util/arrayUtilities.ts +88 -0
  569. package/src/util/index.ts +6 -0
  570. package/dist/feature-libraries/default-schema/defaultSchema.d.ts +0 -10
  571. package/dist/feature-libraries/default-schema/defaultSchema.d.ts.map +0 -1
  572. package/dist/feature-libraries/default-schema/defaultSchema.js +0 -15
  573. package/dist/feature-libraries/default-schema/defaultSchema.js.map +0 -1
  574. package/dist/feature-libraries/default-schema/schemaChecker.d.ts.map +0 -1
  575. package/dist/feature-libraries/default-schema/schemaChecker.js.map +0 -1
  576. package/dist/feature-libraries/modular-schema/fieldKindWithEditor.d.ts +0 -50
  577. package/dist/feature-libraries/modular-schema/fieldKindWithEditor.d.ts.map +0 -1
  578. package/dist/feature-libraries/modular-schema/fieldKindWithEditor.js +0 -76
  579. package/dist/feature-libraries/modular-schema/fieldKindWithEditor.js.map +0 -1
  580. package/dist/feature-libraries/optional-field/optionalFieldCodecV1.d.ts +0 -12
  581. package/dist/feature-libraries/optional-field/optionalFieldCodecV1.d.ts.map +0 -1
  582. package/dist/feature-libraries/optional-field/optionalFieldCodecV1.js +0 -158
  583. package/dist/feature-libraries/optional-field/optionalFieldCodecV1.js.map +0 -1
  584. package/dist/feature-libraries/sequence-field/sequenceFieldCodecV1.d.ts +0 -11
  585. package/dist/feature-libraries/sequence-field/sequenceFieldCodecV1.d.ts.map +0 -1
  586. package/dist/feature-libraries/sequence-field/sequenceFieldCodecV1.js +0 -245
  587. package/dist/feature-libraries/sequence-field/sequenceFieldCodecV1.js.map +0 -1
  588. package/lib/feature-libraries/default-schema/defaultSchema.d.ts +0 -10
  589. package/lib/feature-libraries/default-schema/defaultSchema.d.ts.map +0 -1
  590. package/lib/feature-libraries/default-schema/defaultSchema.js +0 -12
  591. package/lib/feature-libraries/default-schema/defaultSchema.js.map +0 -1
  592. package/lib/feature-libraries/default-schema/schemaChecker.d.ts.map +0 -1
  593. package/lib/feature-libraries/default-schema/schemaChecker.js.map +0 -1
  594. package/lib/feature-libraries/modular-schema/fieldKindWithEditor.d.ts +0 -50
  595. package/lib/feature-libraries/modular-schema/fieldKindWithEditor.d.ts.map +0 -1
  596. package/lib/feature-libraries/modular-schema/fieldKindWithEditor.js +0 -71
  597. package/lib/feature-libraries/modular-schema/fieldKindWithEditor.js.map +0 -1
  598. package/lib/feature-libraries/optional-field/optionalFieldCodecV1.d.ts +0 -12
  599. package/lib/feature-libraries/optional-field/optionalFieldCodecV1.d.ts.map +0 -1
  600. package/lib/feature-libraries/optional-field/optionalFieldCodecV1.js +0 -154
  601. package/lib/feature-libraries/optional-field/optionalFieldCodecV1.js.map +0 -1
  602. package/lib/feature-libraries/sequence-field/sequenceFieldCodecV1.d.ts +0 -11
  603. package/lib/feature-libraries/sequence-field/sequenceFieldCodecV1.d.ts.map +0 -1
  604. package/lib/feature-libraries/sequence-field/sequenceFieldCodecV1.js +0 -241
  605. package/lib/feature-libraries/sequence-field/sequenceFieldCodecV1.js.map +0 -1
  606. package/src/feature-libraries/default-schema/defaultSchema.ts +0 -15
  607. package/src/feature-libraries/modular-schema/fieldKindWithEditor.ts +0 -108
  608. package/src/feature-libraries/optional-field/optionalFieldCodecV1.ts +0 -208
  609. package/src/feature-libraries/sequence-field/sequenceFieldCodecV1.ts +0 -344
@@ -1 +1 @@
1
- {"version":3,"file":"chunkDecoding.d.ts","sourceRoot":"","sources":["../../../../src/feature-libraries/chunked-forest/codec/chunkDecoding.ts"],"names":[],"mappings":"AAAA;;;GAGG;AA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CAAC,QAAQ,EAAE,SAAS,YAAY,EAAE,EAAE,MAAM,EAAE,YAAY,GAAG,SAAS;CASjF;AAED;;GAEG;AACH,qBAAa,uBAAwB,YAAW,YAAY;IACxC,OAAO,CAAC,QAAQ,CAAC,OAAO;gBAAP,OAAO,EAAE,cAAc,CAAC,iBAAiB,CAAC;IACvE,MAAM,CAAC,CAAC,EAAE,SAAS,YAAY,EAAE,EAAE,MAAM,EAAE,YAAY,GAAG,SAAS;CA2B1E;AAED;;GAEG;AACH,eAAO,MAAM,UAAU,EAAE,YAMxB,CAAC;AAyBF;;GAEG;AACH,qBAAa,WAAY,YAAW,YAAY;IAI9C,OAAO,CAAC,QAAQ,CAAC,KAAK;IACtB,OAAO,CAAC,QAAQ,CAAC,OAAO;IAJzB,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,CAA2B;IACjD,OAAO,CAAC,QAAQ,CAAC,aAAa,CAA+B;gBAE3C,KAAK,EAAE,gBAAgB,EACvB,OAAO,EAAE,cAAc,CAAC,iBAAiB,CAAC;IAWrD,MAAM,CAAC,QAAQ,EAAE,SAAS,YAAY,EAAE,EAAE,MAAM,EAAE,YAAY,GAAG,SAAS;CAmCjF"}
@@ -177,6 +177,7 @@ class IncrementalChunkDecoder {
177
177
  decode(_, stream) {
178
178
  (0, internal_1.assert)(this.context.incrementalDecoder !== undefined, 0xc27 /* incremental decoder not available for incremental field decoding */);
179
179
  const chunkDecoder = (batch) => {
180
+ (0, internal_1.assert)(batch.version >= format_js_1.FieldBatchFormatVersion.v2, 0xc9f /* Unsupported FieldBatchFormatVersion for incremental chunks; must be v2 or higher */);
180
181
  const context = new chunkDecodingGeneric_js_1.DecoderContext(batch.identifiers, batch.shapes, this.context.idDecodingContext, this.context.incrementalDecoder);
181
182
  const chunks = (0, chunkDecodingGeneric_js_1.decode)(decoderLibrary, context, batch, exports.anyDecoder);
182
183
  return aggregateChunks(chunks);
@@ -1 +1 @@
1
- {"version":3,"file":"chunkDecoding.js","sourceRoot":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,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, 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 context: DecoderContext<EncodedChunkShape>) {}\n\tpublic decode(_: readonly ChunkDecoder[], stream: StreamCursor): TreeChunk {\n\t\tassert(\n\t\t\tthis.context.incrementalDecoder !== undefined,\n\t\t\t0xc27 /* incremental decoder not available for incremental field decoding */,\n\t\t);\n\n\t\tconst chunkDecoder = (batch: EncodedFieldBatch): TreeChunk => {\n\t\t\tconst context = new DecoderContext(\n\t\t\t\tbatch.identifiers,\n\t\t\t\tbatch.shapes,\n\t\t\t\tthis.context.idDecodingContext,\n\t\t\t\tthis.context.incrementalDecoder,\n\t\t\t);\n\t\t\tconst chunks = genericDecode(decoderLibrary, context, batch, anyDecoder);\n\t\t\treturn aggregateChunks(chunks);\n\t\t};\n\n\t\tconst chunkReferenceId = readStreamNumber(stream);\n\t\treturn this.context.incrementalDecoder.decodeIncrementalChunk(\n\t\t\tbrand(chunkReferenceId),\n\t\t\tchunkDecoder,\n\t\t);\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"]}
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,qEASkC;AAClC,uEAImC;AACnC,2CAWqB;AAUrB;;GAEG;AACH,SAAgB,MAAM,CACrB,KAAwB,EACxB,iBAA2E,EAC3E,kBAAuC;IAEvC,OAAO,IAAA,gCAAa,EACnB,cAAc,EACd,IAAI,wCAAc,CAAC,KAAK,CAAC,WAAW,EAAE,KAAK,CAAC,MAAM,EAAE,iBAAiB,EAAE,kBAAkB,CAAC,EAC1F,KAAK,EACL,kBAAU,CACV,CAAC;AACH,CAAC;AAXD,wBAWC;AAED,MAAM,cAAc,GAAG,IAAI,uCAA4B,CAIrD;IACD,CAAC,CAAC,KAA8B,EAAE,OAAO;QACxC,OAAO,IAAI,kBAAkB,CAAC,KAAK,CAAC,CAAC;IACtC,CAAC;IACD,CAAC,CAAC,KAA8B,EAAE,OAAO;QACxC,OAAO,IAAI,kBAAkB,CAAC,KAAK,CAAC,CAAC;IACtC,CAAC;IACD,CAAC,CAAC,KAAuB,EAAE,OAAO;QACjC,OAAO,IAAI,WAAW,CAAC,KAAK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AC;gBACzB,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;YACzB,CAAC;QACF,CAAC;QAED,KAAK,MAAM,OAAO,IAAI,IAAI,CAAC,aAAa,EAAE,CAAC;YAC1C,MAAM,CAAC,GAAG,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;YACjD,QAAQ,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;QACxB,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, 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\tFieldBatchFormatVersion,\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 context: DecoderContext<EncodedChunkShape>) {}\n\tpublic decode(_: readonly ChunkDecoder[], stream: StreamCursor): TreeChunk {\n\t\tassert(\n\t\t\tthis.context.incrementalDecoder !== undefined,\n\t\t\t0xc27 /* incremental decoder not available for incremental field decoding */,\n\t\t);\n\n\t\tconst chunkDecoder = (batch: EncodedFieldBatch): TreeChunk => {\n\t\t\tassert(\n\t\t\t\tbatch.version >= FieldBatchFormatVersion.v2,\n\t\t\t\t0xc9f /* Unsupported FieldBatchFormatVersion for incremental chunks; must be v2 or higher */,\n\t\t\t);\n\t\t\tconst context = new DecoderContext(\n\t\t\t\tbatch.identifiers,\n\t\t\t\tbatch.shapes,\n\t\t\t\tthis.context.idDecodingContext,\n\t\t\t\tthis.context.incrementalDecoder,\n\t\t\t);\n\t\t\tconst chunks = genericDecode(decoderLibrary, context, batch, anyDecoder);\n\t\t\treturn aggregateChunks(chunks);\n\t\t};\n\n\t\tconst chunkReferenceId = readStreamNumber(stream);\n\t\treturn this.context.incrementalDecoder.decodeIncrementalChunk(\n\t\t\tbrand(chunkReferenceId),\n\t\t\tchunkDecoder,\n\t\t);\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"]}
@@ -5,6 +5,7 @@
5
5
  import type { FluidSerializableReadOnly } from "../../valueUtilities.js";
6
6
  import { Counter, type CounterFilter, type DeduplicationTable } from "./chunkCodecUtilities.js";
7
7
  import type { EncodedFieldBatchGeneric } from "./formatGeneric.js";
8
+ import type { FieldBatchFormatVersion } from "./format.js";
8
9
  /**
9
10
  * An identifier which can be compressed using {@link Counter}.
10
11
  *
@@ -33,7 +34,7 @@ export type BufferFormat<TEncodedShape> = (FluidSerializableReadOnly | Shape<TEn
33
34
  *
34
35
  * Note that this modifies `buffer` to avoid having to copy it.
35
36
  */
36
- export declare function updateShapesAndIdentifiersEncoding<TEncodedShape>(version: number, buffer: BufferFormat<TEncodedShape>[], identifierFilter?: CounterFilter<string>): EncodedFieldBatchGeneric<TEncodedShape>;
37
+ export declare function updateShapesAndIdentifiersEncoding<TEncodedShape>(version: FieldBatchFormatVersion, buffer: BufferFormat<TEncodedShape>[], identifierFilter?: CounterFilter<string>): EncodedFieldBatchGeneric<TEncodedShape>;
37
38
  /**
38
39
  * A tree shape.
39
40
  * This similar to a schema for a tree, though it may be more or less specific than the actual schema system used.
@@ -1 +1 @@
1
- {"version":3,"file":"chunkEncodingGeneric.d.ts","sourceRoot":"","sources":["../../../../src/feature-libraries/chunked-forest/codec/chunkEncodingGeneric.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,yBAAyB,CAAC;AAEzE,OAAO,EACN,OAAO,EACP,KAAK,aAAa,EAClB,KAAK,kBAAkB,EAEvB,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,oBAAoB,CAAC;AAEnE;;;;;;;;GAQG;AACH,qBAAa,eAAe;aACQ,UAAU,EAAE,MAAM;gBAAlB,UAAU,EAAE,MAAM;CACrD;AAED;;;;;GAKG;AACH,MAAM,MAAM,YAAY,CAAC,aAAa,IAAI,CACvC,yBAAyB,GACzB,KAAK,CAAC,aAAa,CAAC,GACpB,eAAe,GACf,YAAY,CAAC,aAAa,CAAC,CAC7B,EAAE,CAAC;AAEJ;;;;;;;GAOG;AACH,wBAAgB,kCAAkC,CAAC,aAAa,EAC/D,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,YAAY,CAAC,aAAa,CAAC,EAAE,EACrC,gBAAgB,GAAE,aAAa,CAAC,MAAM,CAAwB,GAC5D,wBAAwB,CAAC,aAAa,CAAC,CA2EzC;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,8BAAsB,KAAK,CAAC,aAAa;IACxC;;;;;;;;;;OAUG;aACa,mCAAmC,CAClD,WAAW,EAAE,OAAO,CAAC,MAAM,CAAC,EAC5B,eAAe,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,aAAa,CAAC,KAAK,IAAI,GACpD,IAAI;IAEP;;;;;;;OAOG;aACa,WAAW,CAC1B,WAAW,EAAE,kBAAkB,CAAC,MAAM,CAAC,EACvC,MAAM,EAAE,kBAAkB,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC,GAC9C,aAAa;CAChB"}
1
+ {"version":3,"file":"chunkEncodingGeneric.d.ts","sourceRoot":"","sources":["../../../../src/feature-libraries/chunked-forest/codec/chunkEncodingGeneric.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,yBAAyB,CAAC;AAEzE,OAAO,EACN,OAAO,EACP,KAAK,aAAa,EAClB,KAAK,kBAAkB,EAEvB,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,oBAAoB,CAAC;AACnE,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AAE3D;;;;;;;;GAQG;AACH,qBAAa,eAAe;aACQ,UAAU,EAAE,MAAM;gBAAlB,UAAU,EAAE,MAAM;CACrD;AAED;;;;;GAKG;AACH,MAAM,MAAM,YAAY,CAAC,aAAa,IAAI,CACvC,yBAAyB,GACzB,KAAK,CAAC,aAAa,CAAC,GACpB,eAAe,GACf,YAAY,CAAC,aAAa,CAAC,CAC7B,EAAE,CAAC;AAEJ;;;;;;;GAOG;AACH,wBAAgB,kCAAkC,CAAC,aAAa,EAC/D,OAAO,EAAE,uBAAuB,EAChC,MAAM,EAAE,YAAY,CAAC,aAAa,CAAC,EAAE,EACrC,gBAAgB,GAAE,aAAa,CAAC,MAAM,CAAwB,GAC5D,wBAAwB,CAAC,aAAa,CAAC,CA2EzC;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,8BAAsB,KAAK,CAAC,aAAa;IACxC;;;;;;;;;;OAUG;aACa,mCAAmC,CAClD,WAAW,EAAE,OAAO,CAAC,MAAM,CAAC,EAC5B,eAAe,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,aAAa,CAAC,KAAK,IAAI,GACpD,IAAI;IAEP;;;;;;;OAOG;aACa,WAAW,CAC1B,WAAW,EAAE,kBAAkB,CAAC,MAAM,CAAC,EACvC,MAAM,EAAE,kBAAkB,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC,GAC9C,aAAa;CAChB"}
@@ -1 +1 @@
1
- {"version":3,"file":"chunkEncodingGeneric.js","sourceRoot":"","sources":["../../../../src/feature-libraries/chunked-forest/codec/chunkEncodingGeneric.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAA2D;AAK3D,qEAKkC;AAGlC;;;;;;;;GAQG;AACH,MAAa,eAAe;IAC3B,YAAmC,UAAkB;QAAlB,eAAU,GAAV,UAAU,CAAQ;IAAG,CAAC;CACzD;AAFD,0CAEC;AAeD;;;;;;;GAOG;AACH,SAAgB,kCAAkC,CACjD,OAAe,EACf,MAAqC,EACrC,mBAA0C,6CAAoB;IAE9D,MAAM,WAAW,GAAG,IAAI,gCAAO,EAAU,CAAC;IAC1C,MAAM,MAAM,GAAG,IAAI,gCAAO,EAAwB,CAAC;IACnD,+FAA+F;IAC/F,iCAAiC;IACjC,MAAM,UAAU,GAAG,IAAI,GAAG,EAAwB,CAAC;IACnD,MAAM,YAAY,GAA2B,EAAE,CAAC;IAChD,MAAM,eAAe,GAAG,CAAC,KAA2B,EAAQ,EAAE;QAC7D,MAAM,CAAC,GAAG,CAAC,KAAK,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tD,MAAM,eAAe,GAAG,WAAW,CAAC,UAAU,CAAC,gBAAgB,CAAC,CAAC;IACjE,MAAM,UAAU,GAAG,MAAM,CAAC,UAAU,EAAE,CAAC;IAEvC,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;QAC5B,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,KAAK,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE,CAAC;YACnD,MAAM,IAAI,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC;YAC1B,IAAI,IAAI,YAAY,eAAe,EAAE,CAAC;gBACrC,KAAK,CAAC,KAAK,CAAC,GAAG,eAAe,CAAC,YAAY,CAAC,GAAG,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,IAAI,CAAC,UAAU,CAAC;YACrF,CAAC;iBAAM,IAAI,IAAI,YAAY,KAAK,EAAE,CAAC;gBAClC,KAAK,CAAC,KAAK,CAAC,GAAG,UAAU,CAAC,YAAY,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,IAAA,eAAI,EAAC,KAAK,CAAC,mBAAmB,CAAC,CAAC;YACrF,CAAC;QACF,CAAC;IACF,CAAC;IAED,MAAM,aAAa,GAAG,UAAU,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAC3D,KAAK,CAAC,WAAW,CAAC,eAAe,EAAE,UAAU,CAAC,CAC9C,CAAC;IAEF,OAAO;QACN,OAAO;QACP,wDAAwD;QACxD,WAAW,EAAE,eAAe,CAAC,YAAwB;QACrD,MAAM,EAAE,aAAa;QACrB,IAAI,EAAE,MAAuB;KAC7B,CAAC;AACH,CAAC;AA/ED,gFA+EC;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAsB,KAAK;CA6B1B;AA7BD,sBA6BC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { fail } from \"@fluidframework/core-utils/internal\";\n\nimport type { TreeValue } from \"../../../core/index.js\";\nimport type { FluidSerializableReadOnly } from \"../../valueUtilities.js\";\n\nimport {\n\tCounter,\n\ttype CounterFilter,\n\ttype DeduplicationTable,\n\tjsonMinimizingFilter,\n} from \"./chunkCodecUtilities.js\";\nimport type { EncodedFieldBatchGeneric } from \"./formatGeneric.js\";\n\n/**\n * An identifier which can be compressed using {@link Counter}.\n *\n * @remarks\n * Compression of Identifiers is done after the output is otherwise generated to enable counting all the usages.\n * To avoid having to decode the decode the data array to determine which data is an identifier and which is some other string,\n * some recognizable representation is required.\n * Using a class and checking its prototype works for this, and is why IdentifierToken is a class.\n */\nexport class IdentifierToken {\n\tpublic constructor(public readonly identifier: string) {}\n}\n\n/**\n * Format for data emitted during encoding, before dictionary compression of identifiers.\n *\n * @remarks\n * These buffers are mutated after construction if they contain identifiers or shapes.\n */\nexport type BufferFormat<TEncodedShape> = (\n\t| FluidSerializableReadOnly\n\t| Shape<TEncodedShape>\n\t| IdentifierToken\n\t| BufferFormat<TEncodedShape>\n)[];\n\n/**\n * Takes already encoded content in `buffer` and deeply searches, replacing each `IdentifierToken` and `Shape`\n * with references to their encodings in the returned `EncodedFieldBatchGeneric`.\n *\n * This looks inside nested arrays (including transitively) but not inside objects.\n *\n * Note that this modifies `buffer` to avoid having to copy it.\n */\nexport function updateShapesAndIdentifiersEncoding<TEncodedShape>(\n\tversion: number,\n\tbuffer: BufferFormat<TEncodedShape>[],\n\tidentifierFilter: CounterFilter<string> = jsonMinimizingFilter,\n): EncodedFieldBatchGeneric<TEncodedShape> {\n\tconst identifiers = new Counter<string>();\n\tconst shapes = new Counter<Shape<TEncodedShape>>();\n\t// Shapes can reference other shapes (and identifiers), so we need to traverse the shape graph.\n\t// These collections enable that.\n\tconst shapesSeen = new Set<Shape<TEncodedShape>>();\n\tconst shapeToCount: Shape<TEncodedShape>[] = [];\n\tconst shapeDiscovered = (shape: Shape<TEncodedShape>): void => {\n\t\tshapes.add(shape);\n\t\tif (!shapesSeen.has(shape)) {\n\t\t\tshapesSeen.add(shape);\n\t\t\tshapeToCount.push(shape);\n\t\t}\n\t};\n\n\t// A collection of all arrays transitively reachable (via arrays) from buffer.\n\t// These are all the arrays whose contents are searched for shapes and identifiers which are then replaced\n\t// with references. This uses a breadth first traversal, but the actual order is not important.\n\tconst arrays: BufferFormat<TEncodedShape>[] = [buffer];\n\tfor (const array of arrays) {\n\t\tfor (const item of array) {\n\t\t\tif (item instanceof IdentifierToken) {\n\t\t\t\tidentifiers.add(item.identifier);\n\t\t\t} else if (item instanceof Shape) {\n\t\t\t\tshapeDiscovered(item);\n\t\t\t} else if (Array.isArray(item)) {\n\t\t\t\t// In JS it is legal to push items to an array which is being iterated,\n\t\t\t\t// and they will be visited in order.\n\t\t\t\tarrays.push(item);\n\t\t\t} else if (\n\t\t\t\titem !== null &&\n\t\t\t\ttypeof item === \"object\" &&\n\t\t\t\t(item as Record<string, unknown>).shape instanceof Shape\n\t\t\t) {\n\t\t\t\t// because \"serializable\" is allowed in buffer and it has type `any`, its very easy to mess up including of shapes in the buffer.\n\t\t\t\t// This catches the easiest way to get it wrong.\n\t\t\t\tfail(0xb4b /* encoder interface instead of shape written to stream */);\n\t\t\t}\n\t\t}\n\t}\n\n\t// Traverse shape graph, discovering and counting all shape to shape and shape to identifier references.\n\t{\n\t\tlet shape: Shape<TEncodedShape> | undefined;\n\t\twhile ((shape = shapeToCount.pop()) !== undefined) {\n\t\t\tshape.countReferencedShapesAndIdentifiers(identifiers, shapeDiscovered);\n\t\t}\n\t}\n\n\t// Determine substitutions for identifiers and shapes:\n\tconst identifierTable = identifiers.buildTable(identifierFilter);\n\tconst shapeTable = shapes.buildTable();\n\n\tfor (const array of arrays) {\n\t\tfor (let index = 0; index < array.length; index++) {\n\t\t\tconst item = array[index];\n\t\t\tif (item instanceof IdentifierToken) {\n\t\t\t\tarray[index] = identifierTable.valueToIndex.get(item.identifier) ?? item.identifier;\n\t\t\t} else if (item instanceof Shape) {\n\t\t\t\tarray[index] = shapeTable.valueToIndex.get(item) ?? fail(0xb4c /* missing shape */);\n\t\t\t}\n\t\t}\n\t}\n\n\tconst encodedShapes = shapeTable.indexToValue.map((shape) =>\n\t\tshape.encodeShape(identifierTable, shapeTable),\n\t);\n\n\treturn {\n\t\tversion,\n\t\t// TODO: fix readonly typing issues to remove this cast.\n\t\tidentifiers: identifierTable.indexToValue as string[],\n\t\tshapes: encodedShapes,\n\t\tdata: buffer as TreeValue[][],\n\t};\n}\n\n/**\n * A tree shape.\n * This similar to a schema for a tree, though it may be more or less specific than the actual schema system used.\n * Can be encoded into a `TEncodedShape`: when doing so encodes references to shapes (if needed) using {@link Counter}:\n * this can include recursive references (direct or indirect).\n *\n * @remarks\n * Deduplication of shapes is done after the output is otherwise generated (including identifier dictionary encoding).\n * To avoid having to decode the data array to determine which data is a shape and which is some other object,\n * some recognizable representation is required.\n * Using a class and checking its prototype works for this, and is why Shape is a class.\n *\n * Note that deduplication compares shapes by object identity not by content, so encoders must ensure shapes are not duplicated to achieve efficient encoding.\n * Comparison by content would be difficult due to shape containing references to other shapes.\n *\n * @privateRemarks\n * Unlike with identifiers, conversion from the initial form (this class / IdentifierToken) is done by the `encodeShape` method, not by general purpose logic in `updateShapesAndIdentifiersEncoding`.\n * For `updateShapesAndIdentifiersEncoding` to do the conversion without help from `encodeShape`,\n * instances of this Shape class would have to either be or output an object that is identical to the `TEncodedShape` format except with all shape references as object references instead of indexes.\n * Those objects would have to be deeply traversed looking for shape objects to replace with reference indexes.\n * This is possible, but making it type safe would involve generating derived types from the `TEncodedShape` deeply replacing any shape references, as well as requiring deep traversal of all objects in the encoded output.\n * Such an approach seemed less maintainable and readable than the design taken here which avoids the need for those derived types.\n */\nexport abstract class Shape<TEncodedShape> {\n\t/**\n\t * Enumerate all contents of this shape that can get replaced with references (for better compression/deduplication) during encoding.\n\t * This currently includes shapes and identifiers.\n\t *\n\t * Used to discover referenced shapes (to ensure they are included in the `shapes` passed to `encodeShape`),\n\t * as well as count usages of shapes and identifiers for more efficient dictionary encoding. See {@link Counter}.\n\t *\n\t * @param shapeDiscovered - must be invoked with each directly referenced shape (which must be provided to `encodeShape`).\n\t * Can be invoked multiple times if a shape is referenced more than once for more efficient dictionary encoding.\n\t * Should not be invoked with `this` unless this shape references itself.\n\t */\n\tpublic abstract countReferencedShapesAndIdentifiers(\n\t\tidentifiers: Counter<string>,\n\t\tshapeDiscovered: (shape: Shape<TEncodedShape>) => void,\n\t): void;\n\n\t/**\n\t * Produce the final encoded format for this shape.\n\t *\n\t * @param identifiers - a subset of identifiers used in this tree, and their corresponding indexes to use for the dictionary encoding.\n\t * Can be used to encode identifiers referenced by this shape.\n\t * @param shapes - includes a superset of shapes reported by count.\n\t * Used to encode references to shapes as numbers.\n\t */\n\tpublic abstract encodeShape(\n\t\tidentifiers: DeduplicationTable<string>,\n\t\tshapes: DeduplicationTable<Shape<TEncodedShape>>,\n\t): TEncodedShape;\n}\n"]}
1
+ {"version":3,"file":"chunkEncodingGeneric.js","sourceRoot":"","sources":["../../../../src/feature-libraries/chunked-forest/codec/chunkEncodingGeneric.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAA2D;AAK3D,qEAKkC;AAIlC;;;;;;;;GAQG;AACH,MAAa,eAAe;IAC3B,YAAmC,UAAkB;QAAlB,eAAU,GAAV,UAAU,CAAQ;IAAG,CAAC;CACzD;AAFD,0CAEC;AAeD;;;;;;;GAOG;AACH,SAAgB,kCAAkC,CACjD,OAAgC,EAChC,MAAqC,EACrC,mBAA0C,6CAAoB;IAE9D,MAAM,WAAW,GAAG,IAAI,gCAAO,EAAU,CAAC;IAC1C,MAAM,MAAM,GAAG,IAAI,gCAAO,EAAwB,CAAC;IACnD,+FAA+F;IAC/F,iCAAiC;IACjC,MAAM,UAAU,GAAG,IAAI,GAAG,EAAwB,CAAC;IACnD,MAAM,YAAY,GAA2B,EAAE,CAAC;IAChD,MAAM,eAAe,GAAG,CAAC,KAA2B,EAAQ,EAAE;QAC7D,MAAM,C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,CAAC;IAED,sDAAsD;IACtD,MAAM,eAAe,GAAG,WAAW,CAAC,UAAU,CAAC,gBAAgB,CAAC,CAAC;IACjE,MAAM,UAAU,GAAG,MAAM,CAAC,UAAU,EAAE,CAAC;IAEvC,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;QAC5B,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,KAAK,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE,CAAC;YACnD,MAAM,IAAI,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC;YAC1B,IAAI,IAAI,YAAY,eAAe,EAAE,CAAC;gBACrC,KAAK,CAAC,KAAK,CAAC,GAAG,eAAe,CAAC,YAAY,CAAC,GAAG,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,IAAI,CAAC,UAAU,CAAC;YACrF,CAAC;iBAAM,IAAI,IAAI,YAAY,KAAK,EAAE,CAAC;gBAClC,KAAK,CAAC,KAAK,CAAC,GAAG,UAAU,CAAC,YAAY,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,IAAA,eAAI,EAAC,KAAK,CAAC,mBAAmB,CAAC,CAAC;YACrF,CAAC;QACF,CAAC;IACF,CAAC;IAED,MAAM,aAAa,GAAG,UAAU,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAC3D,KAAK,CAAC,WAAW,CAAC,eAAe,EAAE,UAAU,CAAC,CAC9C,CAAC;IAEF,OAAO;QACN,OAAO;QACP,wDAAwD;QACxD,WAAW,EAAE,eAAe,CAAC,YAAwB;QACrD,MAAM,EAAE,aAAa;QACrB,IAAI,EAAE,MAAuB;KAC7B,CAAC;AACH,CAAC;AA/ED,gFA+EC;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAsB,KAAK;CA6B1B;AA7BD,sBA6BC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { fail } from \"@fluidframework/core-utils/internal\";\n\nimport type { TreeValue } from \"../../../core/index.js\";\nimport type { FluidSerializableReadOnly } from \"../../valueUtilities.js\";\n\nimport {\n\tCounter,\n\ttype CounterFilter,\n\ttype DeduplicationTable,\n\tjsonMinimizingFilter,\n} from \"./chunkCodecUtilities.js\";\nimport type { EncodedFieldBatchGeneric } from \"./formatGeneric.js\";\nimport type { FieldBatchFormatVersion } from \"./format.js\";\n\n/**\n * An identifier which can be compressed using {@link Counter}.\n *\n * @remarks\n * Compression of Identifiers is done after the output is otherwise generated to enable counting all the usages.\n * To avoid having to decode the decode the data array to determine which data is an identifier and which is some other string,\n * some recognizable representation is required.\n * Using a class and checking its prototype works for this, and is why IdentifierToken is a class.\n */\nexport class IdentifierToken {\n\tpublic constructor(public readonly identifier: string) {}\n}\n\n/**\n * Format for data emitted during encoding, before dictionary compression of identifiers.\n *\n * @remarks\n * These buffers are mutated after construction if they contain identifiers or shapes.\n */\nexport type BufferFormat<TEncodedShape> = (\n\t| FluidSerializableReadOnly\n\t| Shape<TEncodedShape>\n\t| IdentifierToken\n\t| BufferFormat<TEncodedShape>\n)[];\n\n/**\n * Takes already encoded content in `buffer` and deeply searches, replacing each `IdentifierToken` and `Shape`\n * with references to their encodings in the returned `EncodedFieldBatchGeneric`.\n *\n * This looks inside nested arrays (including transitively) but not inside objects.\n *\n * Note that this modifies `buffer` to avoid having to copy it.\n */\nexport function updateShapesAndIdentifiersEncoding<TEncodedShape>(\n\tversion: FieldBatchFormatVersion,\n\tbuffer: BufferFormat<TEncodedShape>[],\n\tidentifierFilter: CounterFilter<string> = jsonMinimizingFilter,\n): EncodedFieldBatchGeneric<TEncodedShape> {\n\tconst identifiers = new Counter<string>();\n\tconst shapes = new Counter<Shape<TEncodedShape>>();\n\t// Shapes can reference other shapes (and identifiers), so we need to traverse the shape graph.\n\t// These collections enable that.\n\tconst shapesSeen = new Set<Shape<TEncodedShape>>();\n\tconst shapeToCount: Shape<TEncodedShape>[] = [];\n\tconst shapeDiscovered = (shape: Shape<TEncodedShape>): void => {\n\t\tshapes.add(shape);\n\t\tif (!shapesSeen.has(shape)) {\n\t\t\tshapesSeen.add(shape);\n\t\t\tshapeToCount.push(shape);\n\t\t}\n\t};\n\n\t// A collection of all arrays transitively reachable (via arrays) from buffer.\n\t// These are all the arrays whose contents are searched for shapes and identifiers which are then replaced\n\t// with references. This uses a breadth first traversal, but the actual order is not important.\n\tconst arrays: BufferFormat<TEncodedShape>[] = [buffer];\n\tfor (const array of arrays) {\n\t\tfor (const item of array) {\n\t\t\tif (item instanceof IdentifierToken) {\n\t\t\t\tidentifiers.add(item.identifier);\n\t\t\t} else if (item instanceof Shape) {\n\t\t\t\tshapeDiscovered(item);\n\t\t\t} else if (Array.isArray(item)) {\n\t\t\t\t// In JS it is legal to push items to an array which is being iterated,\n\t\t\t\t// and they will be visited in order.\n\t\t\t\tarrays.push(item);\n\t\t\t} else if (\n\t\t\t\titem !== null &&\n\t\t\t\ttypeof item === \"object\" &&\n\t\t\t\t(item as Record<string, unknown>).shape instanceof Shape\n\t\t\t) {\n\t\t\t\t// because \"serializable\" is allowed in buffer and it has type `any`, its very easy to mess up including of shapes in the buffer.\n\t\t\t\t// This catches the easiest way to get it wrong.\n\t\t\t\tfail(0xb4b /* encoder interface instead of shape written to stream */);\n\t\t\t}\n\t\t}\n\t}\n\n\t// Traverse shape graph, discovering and counting all shape to shape and shape to identifier references.\n\t{\n\t\tlet shape: Shape<TEncodedShape> | undefined;\n\t\twhile ((shape = shapeToCount.pop()) !== undefined) {\n\t\t\tshape.countReferencedShapesAndIdentifiers(identifiers, shapeDiscovered);\n\t\t}\n\t}\n\n\t// Determine substitutions for identifiers and shapes:\n\tconst identifierTable = identifiers.buildTable(identifierFilter);\n\tconst shapeTable = shapes.buildTable();\n\n\tfor (const array of arrays) {\n\t\tfor (let index = 0; index < array.length; index++) {\n\t\t\tconst item = array[index];\n\t\t\tif (item instanceof IdentifierToken) {\n\t\t\t\tarray[index] = identifierTable.valueToIndex.get(item.identifier) ?? item.identifier;\n\t\t\t} else if (item instanceof Shape) {\n\t\t\t\tarray[index] = shapeTable.valueToIndex.get(item) ?? fail(0xb4c /* missing shape */);\n\t\t\t}\n\t\t}\n\t}\n\n\tconst encodedShapes = shapeTable.indexToValue.map((shape) =>\n\t\tshape.encodeShape(identifierTable, shapeTable),\n\t);\n\n\treturn {\n\t\tversion,\n\t\t// TODO: fix readonly typing issues to remove this cast.\n\t\tidentifiers: identifierTable.indexToValue as string[],\n\t\tshapes: encodedShapes,\n\t\tdata: buffer as TreeValue[][],\n\t};\n}\n\n/**\n * A tree shape.\n * This similar to a schema for a tree, though it may be more or less specific than the actual schema system used.\n * Can be encoded into a `TEncodedShape`: when doing so encodes references to shapes (if needed) using {@link Counter}:\n * this can include recursive references (direct or indirect).\n *\n * @remarks\n * Deduplication of shapes is done after the output is otherwise generated (including identifier dictionary encoding).\n * To avoid having to decode the data array to determine which data is a shape and which is some other object,\n * some recognizable representation is required.\n * Using a class and checking its prototype works for this, and is why Shape is a class.\n *\n * Note that deduplication compares shapes by object identity not by content, so encoders must ensure shapes are not duplicated to achieve efficient encoding.\n * Comparison by content would be difficult due to shape containing references to other shapes.\n *\n * @privateRemarks\n * Unlike with identifiers, conversion from the initial form (this class / IdentifierToken) is done by the `encodeShape` method, not by general purpose logic in `updateShapesAndIdentifiersEncoding`.\n * For `updateShapesAndIdentifiersEncoding` to do the conversion without help from `encodeShape`,\n * instances of this Shape class would have to either be or output an object that is identical to the `TEncodedShape` format except with all shape references as object references instead of indexes.\n * Those objects would have to be deeply traversed looking for shape objects to replace with reference indexes.\n * This is possible, but making it type safe would involve generating derived types from the `TEncodedShape` deeply replacing any shape references, as well as requiring deep traversal of all objects in the encoded output.\n * Such an approach seemed less maintainable and readable than the design taken here which avoids the need for those derived types.\n */\nexport abstract class Shape<TEncodedShape> {\n\t/**\n\t * Enumerate all contents of this shape that can get replaced with references (for better compression/deduplication) during encoding.\n\t * This currently includes shapes and identifiers.\n\t *\n\t * Used to discover referenced shapes (to ensure they are included in the `shapes` passed to `encodeShape`),\n\t * as well as count usages of shapes and identifiers for more efficient dictionary encoding. See {@link Counter}.\n\t *\n\t * @param shapeDiscovered - must be invoked with each directly referenced shape (which must be provided to `encodeShape`).\n\t * Can be invoked multiple times if a shape is referenced more than once for more efficient dictionary encoding.\n\t * Should not be invoked with `this` unless this shape references itself.\n\t */\n\tpublic abstract countReferencedShapesAndIdentifiers(\n\t\tidentifiers: Counter<string>,\n\t\tshapeDiscovered: (shape: Shape<TEncodedShape>) => void,\n\t): void;\n\n\t/**\n\t * Produce the final encoded format for this shape.\n\t *\n\t * @param identifiers - a subset of identifiers used in this tree, and their corresponding indexes to use for the dictionary encoding.\n\t * Can be used to encode identifiers referenced by this shape.\n\t * @param shapes - includes a superset of shapes reported by count.\n\t * Used to encode references to shapes as numbers.\n\t */\n\tpublic abstract encodeShape(\n\t\tidentifiers: DeduplicationTable<string>,\n\t\tshapes: DeduplicationTable<Shape<TEncodedShape>>,\n\t): TEncodedShape;\n}\n"]}
@@ -8,7 +8,7 @@ import { type ITreeCursorSynchronous, type SchemaAndPolicy, type TreeChunk } fro
8
8
  import { type Brand, type JsonCompatibleReadOnly } from "../../../util/index.js";
9
9
  import { type TreeCompressionStrategyPrivate } from "../../treeCompressionUtils.js";
10
10
  import type { FieldBatch } from "./fieldBatch.js";
11
- import { EncodedFieldBatch } from "./format.js";
11
+ import { type EncodedFieldBatch } from "./format.js";
12
12
  import type { MinimumVersionForCollab } from "@fluidframework/runtime-definitions/internal";
13
13
  import type { IncrementalEncodingPolicy } from "./incrementalEncodingPolicy.js";
14
14
  /**
@@ -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,SAAS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B,CAAC,CAAC;AAGxE;;;;;;;;GAQG;AACH,MAAM,WAAW,kBAAkB;IAClC;;;OAGG;IACH,yBAAyB,EAAE,yBAAyB,CAAC;IACrD;;;;;;;OAOG;IACH,sBAAsB,CACrB,MAAM,EAAE,sBAAsB,EAC9B,YAAY,EAAE,CAAC,KAAK,EAAE,SAAS,KAAK,iBAAiB,GACnD,gBAAgB,EAAE,CAAC;CACtB;AAED;;;;;;GAMG;AACH,MAAM,WAAW,kBAAkB;IAClC;;;;;OAKG;IACH,sBAAsB,CACrB,WAAW,EAAE,gBAAgB,EAC7B,YAAY,EAAE,CAAC,OAAO,EAAE,iBAAiB,KAAK,SAAS,GACrD,SAAS,CAAC;CACb;AACD;;GAEG;AACH,MAAM,WAAW,yBAA0B,SAAQ,kBAAkB,EAAE,kBAAkB;CAAG;AAE5F,MAAM,WAAW,yBAAyB;IACzC,QAAQ,CAAC,UAAU,EAAE,8BAA8B,CAAC;IACpD,QAAQ,CAAC,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;AAiBF,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,iBAAiB,GAAG,eAAe,CAuF/E;AAED,wBAAgB,+BAA+B,CAC9C,aAAa,EAAE,uBAAuB,GACpC,SAAS,CAEX"}
@@ -6,26 +6,24 @@
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
7
  exports.getCodecTreeForFieldBatchFormat = exports.makeFieldBatchCodec = void 0;
8
8
  const internal_1 = require("@fluidframework/core-utils/internal");
9
+ const internal_2 = require("@fluidframework/runtime-utils/internal");
9
10
  const index_js_1 = require("../../../codec/index.js");
10
11
  const index_js_2 = require("../../../util/index.js");
11
12
  const treeCompressionUtils_js_1 = require("../../treeCompressionUtils.js");
12
13
  const chunkDecoding_js_1 = require("./chunkDecoding.js");
13
14
  const format_js_1 = require("./format.js");
14
- const schemaBasedEncode_js_1 = require("./schemaBasedEncode.js");
15
15
  const uncompressedEncode_js_1 = require("./uncompressedEncode.js");
16
+ const schemaBasedEncode_js_1 = require("./schemaBasedEncode.js");
16
17
  const ChunkReferenceId = (0, index_js_2.brandedNumberType)({ multipleOf: 1, minimum: 0 });
17
- /**
18
- * Get the write version for {@link makeFieldBatchCodec} based on the `minVersionForCollab` version.
19
- * @privateRemarks
20
- * TODO: makeFieldBatchCodec (and makeVersionDispatchingCodec transitively) should bake in this versionToFormat logic and the resulting codec can then support use with FluidClientVersion directly.
21
- */
22
18
  /**
23
19
  * Convert a MinimumVersionForCollab to write version for {@link FieldBatchCodec}.
24
20
  * @param clientVersion - The MinimumVersionForCollab to convert.
25
21
  */
26
22
  function clientVersionToFieldBatchVersion(clientVersion) {
27
- // Currently, field batch codec only writes in version 1.
28
- return (0, index_js_2.brand)(format_js_1.FieldBatchFormatVersion.v1);
23
+ return (0, index_js_2.brand)((0, internal_2.getConfigForMinVersionForCollab)(clientVersion, {
24
+ [internal_2.lowestMinVersionForCollab]: format_js_1.FieldBatchFormatVersion.v1,
25
+ [index_js_1.FluidClientVersion.v2_73]: format_js_1.FieldBatchFormatVersion.v2,
26
+ }));
29
27
  }
30
28
  function makeFieldBatchCodec(options) {
31
29
  const writeVersion = clientVersionToFieldBatchVersion(options.minVersionForCollab);
@@ -34,30 +32,46 @@ function makeFieldBatchCodec(options) {
34
32
  // decode is being run on a client that just submitted a schema change, but the op is from another client who has
35
33
  // yet to receive that change).
36
34
  (0, internal_1.assert)(format_js_1.validVersions.has(writeVersion), 0x935 /* Invalid write version for FieldBatch codec */);
37
- // TODO: use makeVersionDispatchingCodec to support adding more versions in the future.
38
- return (0, index_js_1.makeVersionedValidatedCodec)(options, format_js_1.validVersions, format_js_1.EncodedFieldBatch, {
35
+ let uncompressedEncodeFn;
36
+ let schemaCompressedEncodeFn;
37
+ let encodedFieldBatchType;
38
+ switch (writeVersion) {
39
+ case format_js_1.FieldBatchFormatVersion.v1:
40
+ uncompressedEncodeFn = uncompressedEncode_js_1.uncompressedEncodeV1;
41
+ schemaCompressedEncodeFn = schemaBasedEncode_js_1.schemaCompressedEncodeV1;
42
+ encodedFieldBatchType = format_js_1.EncodedFieldBatchV1;
43
+ break;
44
+ case format_js_1.FieldBatchFormatVersion.v2:
45
+ uncompressedEncodeFn = uncompressedEncode_js_1.uncompressedEncodeV2;
46
+ schemaCompressedEncodeFn = schemaBasedEncode_js_1.schemaCompressedEncodeV2;
47
+ encodedFieldBatchType = format_js_1.EncodedFieldBatchV2;
48
+ break;
49
+ default:
50
+ (0, internal_1.unreachableCase)(writeVersion);
51
+ }
52
+ return (0, index_js_1.makeVersionedValidatedCodec)(options, format_js_1.validVersions, encodedFieldBatchType, {
39
53
  encode: (data, context) => {
40
54
  for (const cursor of data) {
41
55
  (0, internal_1.assert)(cursor.mode === 1 /* CursorLocationType.Fields */, 0x8a3 /* FieldBatch expects fields cursors */);
42
56
  }
43
57
  let encoded;
58
+ let incrementalEncoder;
44
59
  switch (context.encodeType) {
45
60
  case treeCompressionUtils_js_1.TreeCompressionStrategy.Uncompressed:
46
- encoded = (0, uncompressedEncode_js_1.uncompressedEncode)(data);
61
+ encoded = uncompressedEncodeFn(data);
47
62
  break;
48
63
  case treeCompressionUtils_js_1.TreeCompressionStrategyExtended.CompressedIncremental:
64
+ (0, internal_1.assert)(writeVersion >= format_js_1.FieldBatchFormatVersion.v2, 0xca0 /* Unsupported FieldBatchFormatVersion for incremental encoding; must be v2 or higher */);
65
+ // Incremental encoding is only supported for CompressedIncremental.
66
+ incrementalEncoder = context.incrementalEncoderDecoder;
49
67
  case treeCompressionUtils_js_1.TreeCompressionStrategy.Compressed:
50
68
  // eslint-disable-next-line unicorn/prefer-ternary
51
69
  if (context.schema !== undefined) {
52
- encoded = (0, schemaBasedEncode_js_1.schemaCompressedEncode)(context.schema.schema, context.schema.policy, data, context.idCompressor,
53
- // Incremental encoding is only supported for CompressedIncremental.
54
- context.encodeType === treeCompressionUtils_js_1.TreeCompressionStrategyExtended.CompressedIncremental
55
- ? context.incrementalEncoderDecoder
56
- : undefined);
70
+ encoded = schemaCompressedEncodeFn(context.schema.schema, context.schema.policy, data, context.idCompressor, incrementalEncoder);
57
71
  }
58
72
  else {
59
73
  // TODO: consider enabling a somewhat compressed but not schema accelerated encode.
60
- encoded = (0, uncompressedEncode_js_1.uncompressedEncode)(data);
74
+ encoded = uncompressedEncodeFn(data);
61
75
  }
62
76
  break;
63
77
  default:
@@ -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;AAOjC,qDAKgC;AAChC,2EAIuC;AAEvC,yDAA4C;AAE5C,2CAAwF;AACxF,iEAAgE;AAChE,mEAA6D;AAQ7D,MAAM,gBAAgB,GAAG,IAAA,4BAAiB,EAAmB,EAAE,UAAU,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC,CAAC;AA6E5F;;;;GAIG;AACH;;;GAGG;AACH,SAAS,gCAAgC,CACxC,aAAsC;IAEtC,yDAAyD;IACzD,OAAO,IAAA,gBAAK,EAAC,mCAAuB,CAAC,EAAE,CAAC,CAAC;AAC1C,CAAC;AAED,SAAgB,mBAAmB,CAAC,OAA0B;IAC7D,MAAM,YAAY,GAAG,gCAAgC,CAAC,OAAO,CAAC,mBAAmB,CAAC,CAAC;IACnF,6GAA6G;IAC7G,8GAA8G;IAC9G,iHAAiH;IACjH,+BAA+B;IAC/B,IAAA,iBAAM,EACL,yBAAa,CAAC,GAAG,CAAC,YAAY,CAAC,EAC/B,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AAc,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;AAhED,kDAgEC;AAED,SAAgB,+BAA+B,CAC9C,aAAsC;IAEtC,OAAO,EAAE,IAAI,EAAE,YAAY,EAAE,OAAO,EAAE,gCAAgC,CAAC,aAAa,CAAC,EAAE,CAAC;AACzF,CAAC;AAJD,0EAIC","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 CodecTree,\n\ttype CodecWriteOptions,\n\ttype IJsonCodec,\n\tmakeVersionedValidatedCodec,\n} from \"../../../codec/index.js\";\nimport {\n\tCursorLocationType,\n\ttype ITreeCursorSynchronous,\n\ttype SchemaAndPolicy,\n\ttype TreeChunk,\n} from \"../../../core/index.js\";\nimport {\n\tbrand,\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, FieldBatchFormatVersion } from \"./format.js\";\nimport { schemaCompressedEncode } from \"./schemaBasedEncode.js\";\nimport { uncompressedEncode } from \"./uncompressedEncode.js\";\nimport type { MinimumVersionForCollab } from \"@fluidframework/runtime-definitions/internal\";\nimport type { IncrementalEncodingPolicy } from \"./incrementalEncodingPolicy.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 node / field should be incrementally encoded.\n\t * @remarks See {@link IncrementalEncodingPolicy}.\n\t */\n\tshouldEncodeIncrementally: IncrementalEncodingPolicy;\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 decode an incremental chunk with the given reference ID.\n\t * @param referenceId - The reference ID of the chunk to decode.\n\t * @param chunkDecoder - A function that decodes the chunk.\n\t * @returns The decoded chunk.\n\t */\n\tdecodeIncrementalChunk(\n\t\treferenceId: ChunkReferenceId,\n\t\tchunkDecoder: (encoded: EncodedFieldBatch) => TreeChunk,\n\t): TreeChunk;\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 `minVersionForCollab` 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 */\n/**\n * Convert a MinimumVersionForCollab to write version for {@link FieldBatchCodec}.\n * @param clientVersion - The MinimumVersionForCollab to convert.\n */\nfunction clientVersionToFieldBatchVersion(\n\tclientVersion: MinimumVersionForCollab,\n): FieldBatchFormatVersion {\n\t// Currently, field batch codec only writes in version 1.\n\treturn brand(FieldBatchFormatVersion.v1);\n}\n\nexport function makeFieldBatchCodec(options: CodecWriteOptions): FieldBatchCodec {\n\tconst writeVersion = clientVersionToFieldBatchVersion(options.minVersionForCollab);\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\nexport function getCodecTreeForFieldBatchFormat(\n\tclientVersion: MinimumVersionForCollab,\n): CodecTree {\n\treturn { name: \"FieldBatch\", version: clientVersionToFieldBatchVersion(clientVersion) };\n}\n"]}
1
+ {"version":3,"file":"codecs.js","sourceRoot":"","sources":["../../../../src/feature-libraries/chunked-forest/codec/codecs.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAA8E;AAE9E,qEAGgD;AAEhD,sDAMiC;AAOjC,qDAKgC;AAChC,2EAIuC;AAEvC,yDAA4C;AAE5C,2CAMqB;AAGrB,mEAAqF;AACrF,iEAA4F;AAM5F,MAAM,gBAAgB,GAAG,IAAA,4BAAiB,EAAmB,EAAE,UAAU,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC,CAAC;AA6E5F;;;GAGG;AACH,SAAS,gCAAgC,CACxC,aAAsC;IAEtC,OAAO,IAAA,gBAAK,EACX,IAAA,0CAA+B,EAAC,aAAa,EAAE;QAC9C,CAAC,oCAAyB,CAAC,EAAE,mCAAuB,CAAC,EAAE;QACvD,CAAC,6BAAkB,CAAC,KAAK,CAAC,EAAE,mCAAuB,CAAC,EAAE;KACtD,CAAC,CACF,CAAC;AACH,CAAC;AAED,SAAgB,mBAAmB,CAAC,OAA0B;IAC7D,MAAM,YAAY,GAAG,gCAAgC,CAAC,OAAO,CAAC,mBAAmB,CAAC,CAAC;IACnF,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;IAE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S,EAAE,CAAC;wBAClC,OAAO,GAAG,wBAAwB,CACjC,OAAO,CAAC,MAAM,CAAC,MAAM,EACrB,OAAO,CAAC,MAAM,CAAC,MAAM,EACrB,IAAI,EACJ,OAAO,CAAC,YAAY,EACpB,kBAAkB,CAClB,CAAC;oBACH,CAAC;yBAAM,CAAC;wBACP,mFAAmF;wBACnF,OAAO,GAAG,oBAAoB,CAAC,IAAI,CAAC,CAAC;oBACtC,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;AAvFD,kDAuFC;AAED,SAAgB,+BAA+B,CAC9C,aAAsC;IAEtC,OAAO,EAAE,IAAI,EAAE,YAAY,EAAE,OAAO,EAAE,gCAAgC,CAAC,aAAa,CAAC,EAAE,CAAC;AACzF,CAAC;AAJD,0EAIC","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\";\nimport {\n\tgetConfigForMinVersionForCollab,\n\tlowestMinVersionForCollab,\n} from \"@fluidframework/runtime-utils/internal\";\n\nimport {\n\ttype CodecTree,\n\ttype CodecWriteOptions,\n\tFluidClientVersion,\n\ttype IJsonCodec,\n\tmakeVersionedValidatedCodec,\n} from \"../../../codec/index.js\";\nimport {\n\tCursorLocationType,\n\ttype ITreeCursorSynchronous,\n\ttype SchemaAndPolicy,\n\ttype TreeChunk,\n} from \"../../../core/index.js\";\nimport {\n\tbrand,\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 {\n\ttype EncodedFieldBatch,\n\tvalidVersions,\n\tFieldBatchFormatVersion,\n\tEncodedFieldBatchV1,\n\tEncodedFieldBatchV2,\n} from \"./format.js\";\nimport type { MinimumVersionForCollab } from \"@fluidframework/runtime-definitions/internal\";\nimport type { IncrementalEncodingPolicy } from \"./incrementalEncodingPolicy.js\";\nimport { uncompressedEncodeV1, uncompressedEncodeV2 } from \"./uncompressedEncode.js\";\nimport { schemaCompressedEncodeV1, schemaCompressedEncodeV2 } from \"./schemaBasedEncode.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 node / field should be incrementally encoded.\n\t * @remarks See {@link IncrementalEncodingPolicy}.\n\t */\n\tshouldEncodeIncrementally: IncrementalEncodingPolicy;\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 decode an incremental chunk with the given reference ID.\n\t * @param referenceId - The reference ID of the chunk to decode.\n\t * @param chunkDecoder - A function that decodes the chunk.\n\t * @returns The decoded chunk.\n\t */\n\tdecodeIncrementalChunk(\n\t\treferenceId: ChunkReferenceId,\n\t\tchunkDecoder: (encoded: EncodedFieldBatch) => TreeChunk,\n\t): TreeChunk;\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 * Convert a MinimumVersionForCollab to write version for {@link FieldBatchCodec}.\n * @param clientVersion - The MinimumVersionForCollab to convert.\n */\nfunction clientVersionToFieldBatchVersion(\n\tclientVersion: MinimumVersionForCollab,\n): FieldBatchFormatVersion {\n\treturn brand(\n\t\tgetConfigForMinVersionForCollab(clientVersion, {\n\t\t\t[lowestMinVersionForCollab]: FieldBatchFormatVersion.v1,\n\t\t\t[FluidClientVersion.v2_73]: FieldBatchFormatVersion.v2,\n\t\t}),\n\t);\n}\n\nexport function makeFieldBatchCodec(options: CodecWriteOptions): FieldBatchCodec {\n\tconst writeVersion = clientVersionToFieldBatchVersion(options.minVersionForCollab);\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\tlet uncompressedEncodeFn: typeof uncompressedEncodeV1 | typeof uncompressedEncodeV2;\n\tlet schemaCompressedEncodeFn:\n\t\t| typeof schemaCompressedEncodeV1\n\t\t| typeof schemaCompressedEncodeV2;\n\tlet encodedFieldBatchType: typeof EncodedFieldBatchV1 | typeof EncodedFieldBatchV2;\n\tswitch (writeVersion) {\n\t\tcase FieldBatchFormatVersion.v1:\n\t\t\tuncompressedEncodeFn = uncompressedEncodeV1;\n\t\t\tschemaCompressedEncodeFn = schemaCompressedEncodeV1;\n\t\t\tencodedFieldBatchType = EncodedFieldBatchV1;\n\t\t\tbreak;\n\t\tcase FieldBatchFormatVersion.v2:\n\t\t\tuncompressedEncodeFn = uncompressedEncodeV2;\n\t\t\tschemaCompressedEncodeFn = schemaCompressedEncodeV2;\n\t\t\tencodedFieldBatchType = EncodedFieldBatchV2;\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tunreachableCase(writeVersion);\n\t}\n\n\treturn makeVersionedValidatedCodec(options, validVersions, encodedFieldBatchType, {\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\tlet incrementalEncoder: IncrementalEncoder | undefined;\n\t\t\tswitch (context.encodeType) {\n\t\t\t\tcase TreeCompressionStrategy.Uncompressed:\n\t\t\t\t\tencoded = uncompressedEncodeFn(data);\n\t\t\t\t\tbreak;\n\t\t\t\tcase TreeCompressionStrategyExtended.CompressedIncremental:\n\t\t\t\t\tassert(\n\t\t\t\t\t\twriteVersion >= FieldBatchFormatVersion.v2,\n\t\t\t\t\t\t0xca0 /* Unsupported FieldBatchFormatVersion for incremental encoding; must be v2 or higher */,\n\t\t\t\t\t);\n\t\t\t\t\t// Incremental encoding is only supported for CompressedIncremental.\n\t\t\t\t\tincrementalEncoder = context.incrementalEncoderDecoder;\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 = schemaCompressedEncodeFn(\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\tincrementalEncoder,\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 = uncompressedEncodeFn(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\nexport function getCodecTreeForFieldBatchFormat(\n\tclientVersion: MinimumVersionForCollab,\n): CodecTree {\n\treturn { name: \"FieldBatch\", version: clientVersionToFieldBatchVersion(clientVersion) };\n}\n"]}
@@ -3,12 +3,11 @@
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";
7
- import type { FlexFieldKind } from "../../modular-schema/index.js";
6
+ import { type FieldKey, type FieldKindData, type FieldKindIdentifier, type ITreeCursorSynchronous, type TreeFieldStoredSchema, type TreeNodeSchemaIdentifier, type Value } from "../../../core/index.js";
8
7
  import type { Counter, DeduplicationTable } from "./chunkCodecUtilities.js";
9
8
  import { type BufferFormat as BufferFormatGeneric, Shape as ShapeGeneric } from "./chunkEncodingGeneric.js";
10
9
  import type { FieldBatch } from "./fieldBatch.js";
11
- import { type EncodedChunkShape, type EncodedFieldBatch, type EncodedValueShape } from "./format.js";
10
+ import { type EncodedChunkShape, type EncodedFieldBatch, type EncodedValueShape, FieldBatchFormatVersion } from "./format.js";
12
11
  import type { IncrementalEncoder } from "./codecs.js";
13
12
  /**
14
13
  * Encode data from `FieldBatch` into an `EncodedFieldBatch`.
@@ -171,7 +170,7 @@ export declare function encodeValue(value: Value, shape: EncodedValueShape, outp
171
170
  export declare class EncoderContext implements NodeEncodeBuilder, FieldEncodeBuilder {
172
171
  private readonly nodeEncoderFromPolicy;
173
172
  private readonly fieldEncoderFromPolicy;
174
- readonly fieldShapes: ReadonlyMap<FieldKindIdentifier, FlexFieldKind>;
173
+ readonly fieldShapes: ReadonlyMap<FieldKindIdentifier, FieldKindData>;
175
174
  readonly idCompressor: IIdCompressor;
176
175
  /**
177
176
  * To be used to encode incremental chunks, if any.
@@ -179,15 +178,16 @@ export declare class EncoderContext implements NodeEncodeBuilder, FieldEncodeBui
179
178
  * See {@link IncrementalEncoder} for more information.
180
179
  */
181
180
  readonly incrementalEncoder: IncrementalEncoder | undefined;
181
+ readonly version: FieldBatchFormatVersion;
182
182
  private readonly nodeEncodersFromSchema;
183
183
  private readonly nestedArrayEncoders;
184
- constructor(nodeEncoderFromPolicy: NodeEncoderPolicy, fieldEncoderFromPolicy: FieldEncoderPolicy, fieldShapes: ReadonlyMap<FieldKindIdentifier, FlexFieldKind>, idCompressor: IIdCompressor,
184
+ constructor(nodeEncoderFromPolicy: NodeEncoderPolicy, fieldEncoderFromPolicy: FieldEncoderPolicy, fieldShapes: ReadonlyMap<FieldKindIdentifier, FieldKindData>, idCompressor: IIdCompressor,
185
185
  /**
186
186
  * To be used to encode incremental chunks, if any.
187
187
  * @remarks
188
188
  * See {@link IncrementalEncoder} for more information.
189
189
  */
190
- incrementalEncoder: IncrementalEncoder | undefined);
190
+ incrementalEncoder: IncrementalEncoder | undefined, version: FieldBatchFormatVersion);
191
191
  nodeEncoderFromSchema(schemaName: TreeNodeSchemaIdentifier): NodeEncoder;
192
192
  fieldEncoderFromSchema(fieldSchema: TreeFieldStoredSchema): FieldEncoder;
193
193
  nestedArrayEncoder(inner: NodeEncoder): NestedArrayEncoder;
@@ -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,QAA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B,EAAE,aAAa,CAAC,EAC5D,YAAY,EAAE,aAAa;IAC3C;;;;OAIG;IACa,kBAAkB,EAAE,kBAAkB,GAAG,SAAS;IAG5D,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,aAAa,EAClB,KAAK,mBAAmB,EACxB,KAAK,sBAAsB,EAE3B,KAAK,qBAAqB,EAC1B,KAAK,wBAAwB,EAC7B,KAAK,KAAK,EAEV,MAAM,wBAAwB,CAAC;AAGhC,OAAO,KAAK,EAAE,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAC5E,OAAO,EACN,KAAK,YAAY,IAAI,mBAAmB,EACxC,KAAK,IAAI,YAAY,EAErB,MAAM,2BAA2B,CAAC;AACnC,OAAO,KAAK,EAAE,UA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,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"}
@@ -25,7 +25,7 @@ function compressedEncode(fieldBatch, context) {
25
25
  exports.anyFieldEncoder.encodeField(cursor, context, buffer);
26
26
  batchBuffer.push(buffer);
27
27
  }
28
- return (0, chunkEncodingGeneric_js_1.updateShapesAndIdentifiersEncoding)(format_js_1.FieldBatchFormatVersion.v1, batchBuffer);
28
+ return (0, chunkEncodingGeneric_js_1.updateShapesAndIdentifiersEncoding)(context.version, batchBuffer);
29
29
  }
30
30
  exports.compressedEncode = compressedEncode;
31
31
  /**
@@ -250,6 +250,7 @@ exports.IncrementalChunkShape = IncrementalChunkShape;
250
250
  exports.incrementalFieldEncoder = {
251
251
  encodeField(cursor, context, outputBuffer) {
252
252
  (0, internal_1.assert)(context.incrementalEncoder !== undefined, 0xc88 /* incremental encoder must be defined to use incrementalFieldEncoder */);
253
+ (0, internal_1.assert)(context.version >= format_js_1.FieldBatchFormatVersion.v2, 0xca1 /* Unsupported FieldBatchFormatVersion for incremental encoding; must be v2 or higher */);
253
254
  const chunkReferenceIds = context.incrementalEncoder.encodeIncrementalField(cursor, (chunk) => compressedEncode([chunk.cursor()], context));
254
255
  outputBuffer.push(chunkReferenceIds);
255
256
  },
@@ -307,12 +308,13 @@ class EncoderContext {
307
308
  * @remarks
308
309
  * See {@link IncrementalEncoder} for more information.
309
310
  */
310
- incrementalEncoder) {
311
+ incrementalEncoder, version) {
311
312
  this.nodeEncoderFromPolicy = nodeEncoderFromPolicy;
312
313
  this.fieldEncoderFromPolicy = fieldEncoderFromPolicy;
313
314
  this.fieldShapes = fieldShapes;
314
315
  this.idCompressor = idCompressor;
315
316
  this.incrementalEncoder = incrementalEncoder;
317
+ this.version = version;
316
318
  this.nodeEncodersFromSchema = new Map();
317
319
  this.nestedArrayEncoders = new Map();
318
320
  }