@fluidframework/tree 2.51.0 → 2.53.0-350190

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 (730) hide show
  1. package/.vscode/settings.json +0 -1
  2. package/CHANGELOG.md +43 -0
  3. package/api-report/tree.alpha.api.md +40 -30
  4. package/dist/alpha.d.ts +2 -1
  5. package/dist/codec/codec.d.ts +2 -1
  6. package/dist/codec/codec.d.ts.map +1 -1
  7. package/dist/codec/codec.js +4 -3
  8. package/dist/codec/codec.js.map +1 -1
  9. package/dist/core/index.d.ts +1 -1
  10. package/dist/core/index.d.ts.map +1 -1
  11. package/dist/core/index.js +3 -2
  12. package/dist/core/index.js.map +1 -1
  13. package/dist/core/rebase/index.d.ts +1 -1
  14. package/dist/core/rebase/index.d.ts.map +1 -1
  15. package/dist/core/rebase/index.js +2 -1
  16. package/dist/core/rebase/index.js.map +1 -1
  17. package/dist/core/rebase/types.d.ts +3 -1
  18. package/dist/core/rebase/types.d.ts.map +1 -1
  19. package/dist/core/rebase/types.js +2 -1
  20. package/dist/core/rebase/types.js.map +1 -1
  21. package/dist/core/schema-stored/schema.d.ts +1 -23
  22. package/dist/core/schema-stored/schema.d.ts.map +1 -1
  23. package/dist/core/schema-stored/schema.js +2 -2
  24. package/dist/core/schema-stored/schema.js.map +1 -1
  25. package/dist/core/tree/detachedFieldIndex.d.ts.map +1 -1
  26. package/dist/core/tree/detachedFieldIndex.js +2 -3
  27. package/dist/core/tree/detachedFieldIndex.js.map +1 -1
  28. package/dist/core/tree/detachedFieldIndexCodecCommon.d.ts +17 -0
  29. package/dist/core/tree/detachedFieldIndexCodecCommon.d.ts.map +1 -0
  30. package/dist/core/tree/detachedFieldIndexCodecCommon.js +68 -0
  31. package/dist/core/tree/detachedFieldIndexCodecCommon.js.map +1 -0
  32. package/dist/core/tree/detachedFieldIndexCodecV1.d.ts +11 -0
  33. package/dist/core/tree/detachedFieldIndexCodecV1.d.ts.map +1 -0
  34. package/dist/core/tree/detachedFieldIndexCodecV1.js +55 -0
  35. package/dist/core/tree/detachedFieldIndexCodecV1.js.map +1 -0
  36. package/dist/core/tree/detachedFieldIndexCodecV2.d.ts +11 -0
  37. package/dist/core/tree/detachedFieldIndexCodecV2.d.ts.map +1 -0
  38. package/dist/core/tree/detachedFieldIndexCodecV2.js +49 -0
  39. package/dist/core/tree/detachedFieldIndexCodecV2.js.map +1 -0
  40. package/dist/core/tree/detachedFieldIndexCodecs.d.ts +11 -0
  41. package/dist/core/tree/detachedFieldIndexCodecs.d.ts.map +1 -0
  42. package/dist/core/tree/detachedFieldIndexCodecs.js +26 -0
  43. package/dist/core/tree/detachedFieldIndexCodecs.js.map +1 -0
  44. package/dist/core/tree/detachedFieldIndexFormatCommon.d.ts +37 -0
  45. package/dist/core/tree/detachedFieldIndexFormatCommon.d.ts.map +1 -0
  46. package/dist/core/tree/{detachedFieldIndexFormat.js → detachedFieldIndexFormatCommon.js} +18 -13
  47. package/dist/core/tree/detachedFieldIndexFormatCommon.js.map +1 -0
  48. package/dist/core/tree/detachedFieldIndexFormatV1.d.ts +13 -0
  49. package/dist/core/tree/detachedFieldIndexFormatV1.d.ts.map +1 -0
  50. package/dist/core/tree/detachedFieldIndexFormatV1.js +12 -0
  51. package/dist/core/tree/detachedFieldIndexFormatV1.js.map +1 -0
  52. package/dist/core/tree/detachedFieldIndexFormatV2.d.ts +14 -0
  53. package/dist/core/tree/detachedFieldIndexFormatV2.d.ts.map +1 -0
  54. package/dist/core/tree/detachedFieldIndexFormatV2.js +14 -0
  55. package/dist/core/tree/detachedFieldIndexFormatV2.js.map +1 -0
  56. package/dist/feature-libraries/chunked-forest/codec/chunkDecoding.d.ts +9 -9
  57. package/dist/feature-libraries/chunked-forest/codec/chunkDecoding.d.ts.map +1 -1
  58. package/dist/feature-libraries/chunked-forest/codec/chunkDecoding.js +21 -21
  59. package/dist/feature-libraries/chunked-forest/codec/chunkDecoding.js.map +1 -1
  60. package/dist/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.d.ts +4 -2
  61. package/dist/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.d.ts.map +1 -1
  62. package/dist/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.js +4 -4
  63. package/dist/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.js.map +1 -1
  64. package/dist/feature-libraries/chunked-forest/codec/compressedEncode.d.ts +50 -31
  65. package/dist/feature-libraries/chunked-forest/codec/compressedEncode.d.ts.map +1 -1
  66. package/dist/feature-libraries/chunked-forest/codec/compressedEncode.js +74 -61
  67. package/dist/feature-libraries/chunked-forest/codec/compressedEncode.js.map +1 -1
  68. package/dist/feature-libraries/chunked-forest/codec/format.d.ts +20 -14
  69. package/dist/feature-libraries/chunked-forest/codec/format.d.ts.map +1 -1
  70. package/dist/feature-libraries/chunked-forest/codec/format.js +18 -12
  71. package/dist/feature-libraries/chunked-forest/codec/format.js.map +1 -1
  72. package/{lib/feature-libraries/chunked-forest/codec/nodeShape.d.ts → dist/feature-libraries/chunked-forest/codec/nodeEncoder.d.ts} +20 -14
  73. package/dist/feature-libraries/chunked-forest/codec/nodeEncoder.d.ts.map +1 -0
  74. package/dist/feature-libraries/chunked-forest/codec/{nodeShape.js → nodeEncoder.js} +23 -17
  75. package/dist/feature-libraries/chunked-forest/codec/nodeEncoder.js.map +1 -0
  76. package/dist/feature-libraries/chunked-forest/codec/schemaBasedEncode.d.ts +7 -7
  77. package/dist/feature-libraries/chunked-forest/codec/schemaBasedEncode.d.ts.map +1 -1
  78. package/dist/feature-libraries/chunked-forest/codec/schemaBasedEncode.js +22 -22
  79. package/dist/feature-libraries/chunked-forest/codec/schemaBasedEncode.js.map +1 -1
  80. package/dist/feature-libraries/chunked-forest/codec/uncompressedEncode.js +2 -2
  81. package/dist/feature-libraries/chunked-forest/codec/uncompressedEncode.js.map +1 -1
  82. package/dist/feature-libraries/default-schema/defaultFieldKinds.d.ts +5 -1
  83. package/dist/feature-libraries/default-schema/defaultFieldKinds.d.ts.map +1 -1
  84. package/dist/feature-libraries/default-schema/defaultFieldKinds.js +15 -2
  85. package/dist/feature-libraries/default-schema/defaultFieldKinds.js.map +1 -1
  86. package/dist/feature-libraries/default-schema/defaultSchema.d.ts.map +1 -1
  87. package/dist/feature-libraries/default-schema/defaultSchema.js +0 -2
  88. package/dist/feature-libraries/default-schema/defaultSchema.js.map +1 -1
  89. package/dist/feature-libraries/default-schema/index.d.ts +1 -1
  90. package/dist/feature-libraries/default-schema/index.d.ts.map +1 -1
  91. package/dist/feature-libraries/default-schema/index.js +2 -2
  92. package/dist/feature-libraries/default-schema/index.js.map +1 -1
  93. package/dist/feature-libraries/default-schema/schemaChecker.d.ts +14 -4
  94. package/dist/feature-libraries/default-schema/schemaChecker.d.ts.map +1 -1
  95. package/dist/feature-libraries/default-schema/schemaChecker.js +31 -26
  96. package/dist/feature-libraries/default-schema/schemaChecker.js.map +1 -1
  97. package/dist/feature-libraries/index.d.ts +1 -2
  98. package/dist/feature-libraries/index.d.ts.map +1 -1
  99. package/dist/feature-libraries/index.js +2 -4
  100. package/dist/feature-libraries/index.js.map +1 -1
  101. package/dist/feature-libraries/modular-schema/comparison.d.ts +5 -6
  102. package/dist/feature-libraries/modular-schema/comparison.d.ts.map +1 -1
  103. package/dist/feature-libraries/modular-schema/comparison.js +15 -16
  104. package/dist/feature-libraries/modular-schema/comparison.js.map +1 -1
  105. package/dist/feature-libraries/modular-schema/fieldChangeHandler.d.ts +7 -0
  106. package/dist/feature-libraries/modular-schema/fieldChangeHandler.d.ts.map +1 -1
  107. package/dist/feature-libraries/modular-schema/fieldChangeHandler.js +1 -0
  108. package/dist/feature-libraries/modular-schema/fieldChangeHandler.js.map +1 -1
  109. package/dist/feature-libraries/modular-schema/genericFieldKind.d.ts.map +1 -1
  110. package/dist/feature-libraries/modular-schema/genericFieldKind.js +1 -0
  111. package/dist/feature-libraries/modular-schema/genericFieldKind.js.map +1 -1
  112. package/dist/feature-libraries/modular-schema/modularChangeFamily.d.ts +9 -1
  113. package/dist/feature-libraries/modular-schema/modularChangeFamily.d.ts.map +1 -1
  114. package/dist/feature-libraries/modular-schema/modularChangeFamily.js +49 -20
  115. package/dist/feature-libraries/modular-schema/modularChangeFamily.js.map +1 -1
  116. package/dist/feature-libraries/modular-schema/modularChangeFormat.d.ts +9 -3
  117. package/dist/feature-libraries/modular-schema/modularChangeFormat.d.ts.map +1 -1
  118. package/dist/feature-libraries/object-forest/objectForest.d.ts.map +1 -1
  119. package/dist/feature-libraries/object-forest/objectForest.js +2 -3
  120. package/dist/feature-libraries/object-forest/objectForest.js.map +1 -1
  121. package/dist/feature-libraries/optional-field/optionalField.d.ts.map +1 -1
  122. package/dist/feature-libraries/optional-field/optionalField.js +3 -0
  123. package/dist/feature-libraries/optional-field/optionalField.js.map +1 -1
  124. package/dist/feature-libraries/sequence-field/sequenceFieldChangeRebaser.d.ts +1 -0
  125. package/dist/feature-libraries/sequence-field/sequenceFieldChangeRebaser.d.ts.map +1 -1
  126. package/dist/feature-libraries/sequence-field/sequenceFieldChangeRebaser.js +4 -0
  127. package/dist/feature-libraries/sequence-field/sequenceFieldChangeRebaser.js.map +1 -1
  128. package/dist/index.d.ts +1 -1
  129. package/dist/index.d.ts.map +1 -1
  130. package/dist/index.js +6 -2
  131. package/dist/index.js.map +1 -1
  132. package/dist/jsonDomainSchema.d.ts +5 -3
  133. package/dist/jsonDomainSchema.d.ts.map +1 -1
  134. package/dist/jsonDomainSchema.js.map +1 -1
  135. package/dist/packageVersion.d.ts +1 -1
  136. package/dist/packageVersion.d.ts.map +1 -1
  137. package/dist/packageVersion.js +1 -1
  138. package/dist/packageVersion.js.map +1 -1
  139. package/dist/shared-tree/independentView.d.ts +8 -0
  140. package/dist/shared-tree/independentView.d.ts.map +1 -1
  141. package/dist/shared-tree/independentView.js +23 -11
  142. package/dist/shared-tree/independentView.js.map +1 -1
  143. package/dist/shared-tree/schematizeTree.d.ts.map +1 -1
  144. package/dist/shared-tree/schematizeTree.js +1 -1
  145. package/dist/shared-tree/schematizeTree.js.map +1 -1
  146. package/dist/shared-tree/schematizingTreeView.d.ts +0 -1
  147. package/dist/shared-tree/schematizingTreeView.d.ts.map +1 -1
  148. package/dist/shared-tree/schematizingTreeView.js +9 -12
  149. package/dist/shared-tree/schematizingTreeView.js.map +1 -1
  150. package/dist/shared-tree/sharedTree.d.ts.map +1 -1
  151. package/dist/shared-tree/sharedTree.js +1 -29
  152. package/dist/shared-tree/sharedTree.js.map +1 -1
  153. package/dist/shared-tree/treeAlpha.d.ts +20 -6
  154. package/dist/shared-tree/treeAlpha.d.ts.map +1 -1
  155. package/dist/shared-tree/treeAlpha.js +18 -7
  156. package/dist/shared-tree/treeAlpha.js.map +1 -1
  157. package/dist/shared-tree/treeCheckout.d.ts +2 -1
  158. package/dist/shared-tree/treeCheckout.d.ts.map +1 -1
  159. package/dist/shared-tree/treeCheckout.js +32 -0
  160. package/dist/shared-tree/treeCheckout.js.map +1 -1
  161. package/dist/shared-tree-core/branch.d.ts.map +1 -1
  162. package/dist/shared-tree-core/branch.js +1 -1
  163. package/dist/shared-tree-core/branch.js.map +1 -1
  164. package/dist/simple-tree/api/conciseTree.d.ts +2 -2
  165. package/dist/simple-tree/api/conciseTree.d.ts.map +1 -1
  166. package/dist/simple-tree/api/conciseTree.js +6 -6
  167. package/dist/simple-tree/api/conciseTree.js.map +1 -1
  168. package/dist/simple-tree/api/configuration.d.ts +11 -2
  169. package/dist/simple-tree/api/configuration.d.ts.map +1 -1
  170. package/dist/simple-tree/api/configuration.js +5 -1
  171. package/dist/simple-tree/api/configuration.js.map +1 -1
  172. package/dist/simple-tree/api/create.d.ts +8 -7
  173. package/dist/simple-tree/api/create.d.ts.map +1 -1
  174. package/dist/simple-tree/api/create.js +33 -23
  175. package/dist/simple-tree/api/create.js.map +1 -1
  176. package/dist/simple-tree/api/customTree.d.ts +25 -4
  177. package/dist/simple-tree/api/customTree.d.ts.map +1 -1
  178. package/dist/simple-tree/api/customTree.js +42 -16
  179. package/dist/simple-tree/api/customTree.js.map +1 -1
  180. package/dist/simple-tree/api/discrepancies.d.ts +94 -0
  181. package/dist/simple-tree/api/discrepancies.d.ts.map +1 -0
  182. package/dist/simple-tree/api/discrepancies.js +256 -0
  183. package/dist/simple-tree/api/discrepancies.js.map +1 -0
  184. package/dist/simple-tree/api/index.d.ts +3 -2
  185. package/dist/simple-tree/api/index.d.ts.map +1 -1
  186. package/dist/simple-tree/api/index.js +3 -2
  187. package/dist/simple-tree/api/index.js.map +1 -1
  188. package/dist/simple-tree/api/schemaCompatibilityTester.d.ts +9 -7
  189. package/dist/simple-tree/api/schemaCompatibilityTester.d.ts.map +1 -1
  190. package/dist/simple-tree/api/schemaCompatibilityTester.js +17 -117
  191. package/dist/simple-tree/api/schemaCompatibilityTester.js.map +1 -1
  192. package/dist/simple-tree/api/schemaFactory.d.ts +16 -159
  193. package/dist/simple-tree/api/schemaFactory.d.ts.map +1 -1
  194. package/dist/simple-tree/api/schemaFactory.js +4 -47
  195. package/dist/simple-tree/api/schemaFactory.js.map +1 -1
  196. package/dist/simple-tree/api/schemaFactoryAlpha.d.ts +157 -16
  197. package/dist/simple-tree/api/schemaFactoryAlpha.d.ts.map +1 -1
  198. package/dist/simple-tree/api/schemaFactoryAlpha.js +33 -11
  199. package/dist/simple-tree/api/schemaFactoryAlpha.js.map +1 -1
  200. package/dist/simple-tree/api/schemaFactoryRecursive.d.ts +1 -3
  201. package/dist/simple-tree/api/schemaFactoryRecursive.d.ts.map +1 -1
  202. package/dist/simple-tree/api/schemaFactoryRecursive.js +1 -7
  203. package/dist/simple-tree/api/schemaFactoryRecursive.js.map +1 -1
  204. package/dist/simple-tree/api/schemaStatics.d.ts +158 -0
  205. package/dist/simple-tree/api/schemaStatics.d.ts.map +1 -0
  206. package/dist/simple-tree/api/schemaStatics.js +59 -0
  207. package/dist/simple-tree/api/schemaStatics.js.map +1 -0
  208. package/dist/simple-tree/api/storedSchema.d.ts +5 -3
  209. package/dist/simple-tree/api/storedSchema.d.ts.map +1 -1
  210. package/dist/simple-tree/api/storedSchema.js +9 -3
  211. package/dist/simple-tree/api/storedSchema.js.map +1 -1
  212. package/dist/simple-tree/api/treeBeta.d.ts +2 -2
  213. package/dist/simple-tree/api/treeBeta.d.ts.map +1 -1
  214. package/dist/simple-tree/api/treeBeta.js +16 -4
  215. package/dist/simple-tree/api/treeBeta.js.map +1 -1
  216. package/dist/simple-tree/api/verboseTree.d.ts +2 -2
  217. package/dist/simple-tree/api/verboseTree.d.ts.map +1 -1
  218. package/dist/simple-tree/api/verboseTree.js +15 -15
  219. package/dist/simple-tree/api/verboseTree.js.map +1 -1
  220. package/dist/simple-tree/core/allowedTypes.d.ts +43 -11
  221. package/dist/simple-tree/core/allowedTypes.d.ts.map +1 -1
  222. package/dist/simple-tree/core/allowedTypes.js +51 -11
  223. package/dist/simple-tree/core/allowedTypes.js.map +1 -1
  224. package/dist/simple-tree/core/context.d.ts +13 -2
  225. package/dist/simple-tree/core/context.d.ts.map +1 -1
  226. package/dist/simple-tree/core/context.js +22 -9
  227. package/dist/simple-tree/core/context.js.map +1 -1
  228. package/dist/simple-tree/core/index.d.ts +6 -4
  229. package/dist/simple-tree/core/index.d.ts.map +1 -1
  230. package/dist/simple-tree/core/index.js +8 -1
  231. package/dist/simple-tree/core/index.js.map +1 -1
  232. package/dist/simple-tree/core/simpleNodeSchemaBase.d.ts +25 -0
  233. package/dist/simple-tree/core/simpleNodeSchemaBase.d.ts.map +1 -0
  234. package/dist/simple-tree/core/simpleNodeSchemaBase.js +7 -0
  235. package/dist/simple-tree/core/simpleNodeSchemaBase.js.map +1 -0
  236. package/dist/simple-tree/core/toStored.d.ts +32 -0
  237. package/dist/simple-tree/core/toStored.d.ts.map +1 -0
  238. package/dist/simple-tree/core/toStored.js +37 -0
  239. package/dist/simple-tree/core/toStored.js.map +1 -0
  240. package/dist/simple-tree/core/treeNodeKernel.d.ts +1 -1
  241. package/dist/simple-tree/core/treeNodeKernel.js +1 -1
  242. package/dist/simple-tree/core/treeNodeKernel.js.map +1 -1
  243. package/dist/simple-tree/core/treeNodeSchema.d.ts +7 -2
  244. package/dist/simple-tree/core/treeNodeSchema.d.ts.map +1 -1
  245. package/dist/simple-tree/core/treeNodeSchema.js.map +1 -1
  246. package/dist/simple-tree/core/treeNodeValid.d.ts +7 -2
  247. package/dist/simple-tree/core/treeNodeValid.d.ts.map +1 -1
  248. package/dist/simple-tree/core/treeNodeValid.js +19 -4
  249. package/dist/simple-tree/core/treeNodeValid.js.map +1 -1
  250. package/dist/simple-tree/core/walkSchema.d.ts +22 -5
  251. package/dist/simple-tree/core/walkSchema.d.ts.map +1 -1
  252. package/dist/simple-tree/core/walkSchema.js +6 -2
  253. package/dist/simple-tree/core/walkSchema.js.map +1 -1
  254. package/dist/simple-tree/createContext.d.ts +2 -0
  255. package/dist/simple-tree/createContext.d.ts.map +1 -1
  256. package/dist/simple-tree/createContext.js +4 -2
  257. package/dist/simple-tree/createContext.js.map +1 -1
  258. package/dist/simple-tree/fieldSchema.d.ts +1 -0
  259. package/dist/simple-tree/fieldSchema.d.ts.map +1 -1
  260. package/dist/simple-tree/fieldSchema.js +2 -1
  261. package/dist/simple-tree/fieldSchema.js.map +1 -1
  262. package/dist/simple-tree/index.d.ts +7 -7
  263. package/dist/simple-tree/index.d.ts.map +1 -1
  264. package/dist/simple-tree/index.js +13 -8
  265. package/dist/simple-tree/index.js.map +1 -1
  266. package/dist/simple-tree/leafNodeSchema.d.ts.map +1 -1
  267. package/dist/simple-tree/leafNodeSchema.js +1 -0
  268. package/dist/simple-tree/leafNodeSchema.js.map +1 -1
  269. package/dist/simple-tree/node-kinds/array/arrayNode.d.ts.map +1 -1
  270. package/dist/simple-tree/node-kinds/array/arrayNode.js +18 -4
  271. package/dist/simple-tree/node-kinds/array/arrayNode.js.map +1 -1
  272. package/dist/simple-tree/node-kinds/index.d.ts +1 -1
  273. package/dist/simple-tree/node-kinds/index.d.ts.map +1 -1
  274. package/dist/simple-tree/node-kinds/index.js +1 -2
  275. package/dist/simple-tree/node-kinds/index.js.map +1 -1
  276. package/dist/simple-tree/node-kinds/map/mapNode.d.ts.map +1 -1
  277. package/dist/simple-tree/node-kinds/map/mapNode.js +9 -2
  278. package/dist/simple-tree/node-kinds/map/mapNode.js.map +1 -1
  279. package/dist/simple-tree/node-kinds/object/index.d.ts +1 -1
  280. package/dist/simple-tree/node-kinds/object/index.d.ts.map +1 -1
  281. package/dist/simple-tree/node-kinds/object/index.js +1 -2
  282. package/dist/simple-tree/node-kinds/object/index.js.map +1 -1
  283. package/dist/simple-tree/node-kinds/object/objectNode.d.ts +3 -8
  284. package/dist/simple-tree/node-kinds/object/objectNode.d.ts.map +1 -1
  285. package/dist/simple-tree/node-kinds/object/objectNode.js +41 -44
  286. package/dist/simple-tree/node-kinds/object/objectNode.js.map +1 -1
  287. package/dist/simple-tree/node-kinds/record/recordNode.d.ts.map +1 -1
  288. package/dist/simple-tree/node-kinds/record/recordNode.js +9 -2
  289. package/dist/simple-tree/node-kinds/record/recordNode.js.map +1 -1
  290. package/dist/simple-tree/prepareForInsertion.d.ts +6 -6
  291. package/dist/simple-tree/prepareForInsertion.d.ts.map +1 -1
  292. package/dist/simple-tree/prepareForInsertion.js +19 -13
  293. package/dist/simple-tree/prepareForInsertion.js.map +1 -1
  294. package/dist/simple-tree/simpleSchema.d.ts +6 -21
  295. package/dist/simple-tree/simpleSchema.d.ts.map +1 -1
  296. package/dist/simple-tree/simpleSchema.js.map +1 -1
  297. package/dist/simple-tree/toStoredSchema.d.ts +38 -11
  298. package/dist/simple-tree/toStoredSchema.d.ts.map +1 -1
  299. package/dist/simple-tree/toStoredSchema.js +71 -33
  300. package/dist/simple-tree/toStoredSchema.js.map +1 -1
  301. package/dist/simple-tree/unhydratedFlexTreeFromInsertable.d.ts +2 -2
  302. package/dist/simple-tree/unhydratedFlexTreeFromInsertable.d.ts.map +1 -1
  303. package/dist/simple-tree/unhydratedFlexTreeFromInsertable.js.map +1 -1
  304. package/dist/simple-tree/walkFieldSchema.d.ts +1 -0
  305. package/dist/simple-tree/walkFieldSchema.d.ts.map +1 -1
  306. package/dist/simple-tree/walkFieldSchema.js +1 -0
  307. package/dist/simple-tree/walkFieldSchema.js.map +1 -1
  308. package/lib/alpha.d.ts +2 -1
  309. package/lib/codec/codec.d.ts +2 -1
  310. package/lib/codec/codec.d.ts.map +1 -1
  311. package/lib/codec/codec.js +4 -3
  312. package/lib/codec/codec.js.map +1 -1
  313. package/lib/core/index.d.ts +1 -1
  314. package/lib/core/index.d.ts.map +1 -1
  315. package/lib/core/index.js +1 -1
  316. package/lib/core/index.js.map +1 -1
  317. package/lib/core/rebase/index.d.ts +1 -1
  318. package/lib/core/rebase/index.d.ts.map +1 -1
  319. package/lib/core/rebase/index.js +1 -1
  320. package/lib/core/rebase/index.js.map +1 -1
  321. package/lib/core/rebase/types.d.ts +3 -1
  322. package/lib/core/rebase/types.d.ts.map +1 -1
  323. package/lib/core/rebase/types.js +1 -0
  324. package/lib/core/rebase/types.js.map +1 -1
  325. package/lib/core/schema-stored/schema.d.ts +1 -23
  326. package/lib/core/schema-stored/schema.d.ts.map +1 -1
  327. package/lib/core/schema-stored/schema.js +2 -2
  328. package/lib/core/schema-stored/schema.js.map +1 -1
  329. package/lib/core/tree/detachedFieldIndex.d.ts.map +1 -1
  330. package/lib/core/tree/detachedFieldIndex.js +2 -3
  331. package/lib/core/tree/detachedFieldIndex.js.map +1 -1
  332. package/lib/core/tree/detachedFieldIndexCodecCommon.d.ts +17 -0
  333. package/lib/core/tree/detachedFieldIndexCodecCommon.d.ts.map +1 -0
  334. package/lib/core/tree/detachedFieldIndexCodecCommon.js +64 -0
  335. package/lib/core/tree/detachedFieldIndexCodecCommon.js.map +1 -0
  336. package/lib/core/tree/detachedFieldIndexCodecV1.d.ts +11 -0
  337. package/lib/core/tree/detachedFieldIndexCodecV1.d.ts.map +1 -0
  338. package/lib/core/tree/detachedFieldIndexCodecV1.js +51 -0
  339. package/lib/core/tree/detachedFieldIndexCodecV1.js.map +1 -0
  340. package/lib/core/tree/detachedFieldIndexCodecV2.d.ts +11 -0
  341. package/lib/core/tree/detachedFieldIndexCodecV2.d.ts.map +1 -0
  342. package/lib/core/tree/detachedFieldIndexCodecV2.js +45 -0
  343. package/lib/core/tree/detachedFieldIndexCodecV2.js.map +1 -0
  344. package/lib/core/tree/detachedFieldIndexCodecs.d.ts +11 -0
  345. package/lib/core/tree/detachedFieldIndexCodecs.d.ts.map +1 -0
  346. package/lib/core/tree/detachedFieldIndexCodecs.js +21 -0
  347. package/lib/core/tree/detachedFieldIndexCodecs.js.map +1 -0
  348. package/lib/core/tree/detachedFieldIndexFormatCommon.d.ts +37 -0
  349. package/lib/core/tree/detachedFieldIndexFormatCommon.d.ts.map +1 -0
  350. package/lib/core/tree/{detachedFieldIndexFormat.js → detachedFieldIndexFormatCommon.js} +13 -10
  351. package/lib/core/tree/detachedFieldIndexFormatCommon.js.map +1 -0
  352. package/lib/core/tree/detachedFieldIndexFormatV1.d.ts +13 -0
  353. package/lib/core/tree/detachedFieldIndexFormatV1.d.ts.map +1 -0
  354. package/lib/core/tree/detachedFieldIndexFormatV1.js +9 -0
  355. package/lib/core/tree/detachedFieldIndexFormatV1.js.map +1 -0
  356. package/lib/core/tree/detachedFieldIndexFormatV2.d.ts +14 -0
  357. package/lib/core/tree/detachedFieldIndexFormatV2.d.ts.map +1 -0
  358. package/lib/core/tree/detachedFieldIndexFormatV2.js +11 -0
  359. package/lib/core/tree/detachedFieldIndexFormatV2.js.map +1 -0
  360. package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.d.ts +9 -9
  361. package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.d.ts.map +1 -1
  362. package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.js +19 -19
  363. package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.js.map +1 -1
  364. package/lib/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.d.ts +4 -2
  365. package/lib/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.d.ts.map +1 -1
  366. package/lib/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.js +4 -4
  367. package/lib/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.js.map +1 -1
  368. package/lib/feature-libraries/chunked-forest/codec/compressedEncode.d.ts +50 -31
  369. package/lib/feature-libraries/chunked-forest/codec/compressedEncode.d.ts.map +1 -1
  370. package/lib/feature-libraries/chunked-forest/codec/compressedEncode.js +70 -57
  371. package/lib/feature-libraries/chunked-forest/codec/compressedEncode.js.map +1 -1
  372. package/lib/feature-libraries/chunked-forest/codec/format.d.ts +20 -14
  373. package/lib/feature-libraries/chunked-forest/codec/format.d.ts.map +1 -1
  374. package/lib/feature-libraries/chunked-forest/codec/format.js +17 -11
  375. package/lib/feature-libraries/chunked-forest/codec/format.js.map +1 -1
  376. package/{dist/feature-libraries/chunked-forest/codec/nodeShape.d.ts → lib/feature-libraries/chunked-forest/codec/nodeEncoder.d.ts} +20 -14
  377. package/lib/feature-libraries/chunked-forest/codec/nodeEncoder.d.ts.map +1 -0
  378. package/lib/feature-libraries/chunked-forest/codec/{nodeShape.js → nodeEncoder.js} +21 -15
  379. package/lib/feature-libraries/chunked-forest/codec/nodeEncoder.js.map +1 -0
  380. package/lib/feature-libraries/chunked-forest/codec/schemaBasedEncode.d.ts +7 -7
  381. package/lib/feature-libraries/chunked-forest/codec/schemaBasedEncode.d.ts.map +1 -1
  382. package/lib/feature-libraries/chunked-forest/codec/schemaBasedEncode.js +19 -19
  383. package/lib/feature-libraries/chunked-forest/codec/schemaBasedEncode.js.map +1 -1
  384. package/lib/feature-libraries/chunked-forest/codec/uncompressedEncode.js +2 -2
  385. package/lib/feature-libraries/chunked-forest/codec/uncompressedEncode.js.map +1 -1
  386. package/lib/feature-libraries/default-schema/defaultFieldKinds.d.ts +5 -1
  387. package/lib/feature-libraries/default-schema/defaultFieldKinds.d.ts.map +1 -1
  388. package/lib/feature-libraries/default-schema/defaultFieldKinds.js +15 -2
  389. package/lib/feature-libraries/default-schema/defaultFieldKinds.js.map +1 -1
  390. package/lib/feature-libraries/default-schema/defaultSchema.d.ts.map +1 -1
  391. package/lib/feature-libraries/default-schema/defaultSchema.js +0 -2
  392. package/lib/feature-libraries/default-schema/defaultSchema.js.map +1 -1
  393. package/lib/feature-libraries/default-schema/index.d.ts +1 -1
  394. package/lib/feature-libraries/default-schema/index.d.ts.map +1 -1
  395. package/lib/feature-libraries/default-schema/index.js +1 -1
  396. package/lib/feature-libraries/default-schema/index.js.map +1 -1
  397. package/lib/feature-libraries/default-schema/schemaChecker.d.ts +14 -4
  398. package/lib/feature-libraries/default-schema/schemaChecker.d.ts.map +1 -1
  399. package/lib/feature-libraries/default-schema/schemaChecker.js +29 -24
  400. package/lib/feature-libraries/default-schema/schemaChecker.js.map +1 -1
  401. package/lib/feature-libraries/index.d.ts +1 -2
  402. package/lib/feature-libraries/index.d.ts.map +1 -1
  403. package/lib/feature-libraries/index.js +1 -2
  404. package/lib/feature-libraries/index.js.map +1 -1
  405. package/lib/feature-libraries/modular-schema/comparison.d.ts +5 -6
  406. package/lib/feature-libraries/modular-schema/comparison.d.ts.map +1 -1
  407. package/lib/feature-libraries/modular-schema/comparison.js +14 -14
  408. package/lib/feature-libraries/modular-schema/comparison.js.map +1 -1
  409. package/lib/feature-libraries/modular-schema/fieldChangeHandler.d.ts +7 -0
  410. package/lib/feature-libraries/modular-schema/fieldChangeHandler.d.ts.map +1 -1
  411. package/lib/feature-libraries/modular-schema/fieldChangeHandler.js +1 -0
  412. package/lib/feature-libraries/modular-schema/fieldChangeHandler.js.map +1 -1
  413. package/lib/feature-libraries/modular-schema/genericFieldKind.d.ts.map +1 -1
  414. package/lib/feature-libraries/modular-schema/genericFieldKind.js +1 -0
  415. package/lib/feature-libraries/modular-schema/genericFieldKind.js.map +1 -1
  416. package/lib/feature-libraries/modular-schema/modularChangeFamily.d.ts +9 -1
  417. package/lib/feature-libraries/modular-schema/modularChangeFamily.d.ts.map +1 -1
  418. package/lib/feature-libraries/modular-schema/modularChangeFamily.js +50 -21
  419. package/lib/feature-libraries/modular-schema/modularChangeFamily.js.map +1 -1
  420. package/lib/feature-libraries/modular-schema/modularChangeFormat.d.ts +9 -3
  421. package/lib/feature-libraries/modular-schema/modularChangeFormat.d.ts.map +1 -1
  422. package/lib/feature-libraries/object-forest/objectForest.d.ts.map +1 -1
  423. package/lib/feature-libraries/object-forest/objectForest.js +3 -4
  424. package/lib/feature-libraries/object-forest/objectForest.js.map +1 -1
  425. package/lib/feature-libraries/optional-field/optionalField.d.ts.map +1 -1
  426. package/lib/feature-libraries/optional-field/optionalField.js +3 -0
  427. package/lib/feature-libraries/optional-field/optionalField.js.map +1 -1
  428. package/lib/feature-libraries/sequence-field/sequenceFieldChangeRebaser.d.ts +1 -0
  429. package/lib/feature-libraries/sequence-field/sequenceFieldChangeRebaser.d.ts.map +1 -1
  430. package/lib/feature-libraries/sequence-field/sequenceFieldChangeRebaser.js +4 -0
  431. package/lib/feature-libraries/sequence-field/sequenceFieldChangeRebaser.js.map +1 -1
  432. package/lib/index.d.ts +1 -1
  433. package/lib/index.d.ts.map +1 -1
  434. package/lib/index.js +2 -2
  435. package/lib/index.js.map +1 -1
  436. package/lib/jsonDomainSchema.d.ts +5 -3
  437. package/lib/jsonDomainSchema.d.ts.map +1 -1
  438. package/lib/jsonDomainSchema.js.map +1 -1
  439. package/lib/packageVersion.d.ts +1 -1
  440. package/lib/packageVersion.d.ts.map +1 -1
  441. package/lib/packageVersion.js +1 -1
  442. package/lib/packageVersion.js.map +1 -1
  443. package/lib/shared-tree/independentView.d.ts +8 -0
  444. package/lib/shared-tree/independentView.d.ts.map +1 -1
  445. package/lib/shared-tree/independentView.js +21 -10
  446. package/lib/shared-tree/independentView.js.map +1 -1
  447. package/lib/shared-tree/schematizeTree.d.ts.map +1 -1
  448. package/lib/shared-tree/schematizeTree.js +2 -2
  449. package/lib/shared-tree/schematizeTree.js.map +1 -1
  450. package/lib/shared-tree/schematizingTreeView.d.ts +0 -1
  451. package/lib/shared-tree/schematizingTreeView.d.ts.map +1 -1
  452. package/lib/shared-tree/schematizingTreeView.js +10 -13
  453. package/lib/shared-tree/schematizingTreeView.js.map +1 -1
  454. package/lib/shared-tree/sharedTree.d.ts.map +1 -1
  455. package/lib/shared-tree/sharedTree.js +2 -30
  456. package/lib/shared-tree/sharedTree.js.map +1 -1
  457. package/lib/shared-tree/treeAlpha.d.ts +20 -6
  458. package/lib/shared-tree/treeAlpha.d.ts.map +1 -1
  459. package/lib/shared-tree/treeAlpha.js +19 -8
  460. package/lib/shared-tree/treeAlpha.js.map +1 -1
  461. package/lib/shared-tree/treeCheckout.d.ts +2 -1
  462. package/lib/shared-tree/treeCheckout.d.ts.map +1 -1
  463. package/lib/shared-tree/treeCheckout.js +33 -1
  464. package/lib/shared-tree/treeCheckout.js.map +1 -1
  465. package/lib/shared-tree-core/branch.d.ts.map +1 -1
  466. package/lib/shared-tree-core/branch.js +1 -1
  467. package/lib/shared-tree-core/branch.js.map +1 -1
  468. package/lib/simple-tree/api/conciseTree.d.ts +2 -2
  469. package/lib/simple-tree/api/conciseTree.d.ts.map +1 -1
  470. package/lib/simple-tree/api/conciseTree.js +6 -6
  471. package/lib/simple-tree/api/conciseTree.js.map +1 -1
  472. package/lib/simple-tree/api/configuration.d.ts +11 -2
  473. package/lib/simple-tree/api/configuration.d.ts.map +1 -1
  474. package/lib/simple-tree/api/configuration.js +6 -2
  475. package/lib/simple-tree/api/configuration.js.map +1 -1
  476. package/lib/simple-tree/api/create.d.ts +8 -7
  477. package/lib/simple-tree/api/create.d.ts.map +1 -1
  478. package/lib/simple-tree/api/create.js +35 -25
  479. package/lib/simple-tree/api/create.js.map +1 -1
  480. package/lib/simple-tree/api/customTree.d.ts +25 -4
  481. package/lib/simple-tree/api/customTree.d.ts.map +1 -1
  482. package/lib/simple-tree/api/customTree.js +43 -17
  483. package/lib/simple-tree/api/customTree.js.map +1 -1
  484. package/lib/simple-tree/api/discrepancies.d.ts +94 -0
  485. package/lib/simple-tree/api/discrepancies.d.ts.map +1 -0
  486. package/lib/simple-tree/api/discrepancies.js +251 -0
  487. package/lib/simple-tree/api/discrepancies.js.map +1 -0
  488. package/lib/simple-tree/api/index.d.ts +3 -2
  489. package/lib/simple-tree/api/index.d.ts.map +1 -1
  490. package/lib/simple-tree/api/index.js +2 -1
  491. package/lib/simple-tree/api/index.js.map +1 -1
  492. package/lib/simple-tree/api/schemaCompatibilityTester.d.ts +9 -7
  493. package/lib/simple-tree/api/schemaCompatibilityTester.d.ts.map +1 -1
  494. package/lib/simple-tree/api/schemaCompatibilityTester.js +19 -119
  495. package/lib/simple-tree/api/schemaCompatibilityTester.js.map +1 -1
  496. package/lib/simple-tree/api/schemaFactory.d.ts +16 -159
  497. package/lib/simple-tree/api/schemaFactory.d.ts.map +1 -1
  498. package/lib/simple-tree/api/schemaFactory.js +2 -45
  499. package/lib/simple-tree/api/schemaFactory.js.map +1 -1
  500. package/lib/simple-tree/api/schemaFactoryAlpha.d.ts +157 -16
  501. package/lib/simple-tree/api/schemaFactoryAlpha.d.ts.map +1 -1
  502. package/lib/simple-tree/api/schemaFactoryAlpha.js +23 -1
  503. package/lib/simple-tree/api/schemaFactoryAlpha.js.map +1 -1
  504. package/lib/simple-tree/api/schemaFactoryRecursive.d.ts +1 -3
  505. package/lib/simple-tree/api/schemaFactoryRecursive.d.ts.map +1 -1
  506. package/lib/simple-tree/api/schemaFactoryRecursive.js +0 -5
  507. package/lib/simple-tree/api/schemaFactoryRecursive.js.map +1 -1
  508. package/lib/simple-tree/api/schemaStatics.d.ts +158 -0
  509. package/lib/simple-tree/api/schemaStatics.d.ts.map +1 -0
  510. package/lib/simple-tree/api/schemaStatics.js +56 -0
  511. package/lib/simple-tree/api/schemaStatics.js.map +1 -0
  512. package/lib/simple-tree/api/storedSchema.d.ts +5 -3
  513. package/lib/simple-tree/api/storedSchema.d.ts.map +1 -1
  514. package/lib/simple-tree/api/storedSchema.js +12 -6
  515. package/lib/simple-tree/api/storedSchema.js.map +1 -1
  516. package/lib/simple-tree/api/treeBeta.d.ts +2 -2
  517. package/lib/simple-tree/api/treeBeta.d.ts.map +1 -1
  518. package/lib/simple-tree/api/treeBeta.js +14 -2
  519. package/lib/simple-tree/api/treeBeta.js.map +1 -1
  520. package/lib/simple-tree/api/verboseTree.d.ts +2 -2
  521. package/lib/simple-tree/api/verboseTree.d.ts.map +1 -1
  522. package/lib/simple-tree/api/verboseTree.js +9 -9
  523. package/lib/simple-tree/api/verboseTree.js.map +1 -1
  524. package/lib/simple-tree/core/allowedTypes.d.ts +43 -11
  525. package/lib/simple-tree/core/allowedTypes.d.ts.map +1 -1
  526. package/lib/simple-tree/core/allowedTypes.js +52 -11
  527. package/lib/simple-tree/core/allowedTypes.js.map +1 -1
  528. package/lib/simple-tree/core/context.d.ts +13 -2
  529. package/lib/simple-tree/core/context.d.ts.map +1 -1
  530. package/lib/simple-tree/core/context.js +22 -9
  531. package/lib/simple-tree/core/context.js.map +1 -1
  532. package/lib/simple-tree/core/index.d.ts +6 -4
  533. package/lib/simple-tree/core/index.d.ts.map +1 -1
  534. package/lib/simple-tree/core/index.js +4 -3
  535. package/lib/simple-tree/core/index.js.map +1 -1
  536. package/lib/simple-tree/core/simpleNodeSchemaBase.d.ts +25 -0
  537. package/lib/simple-tree/core/simpleNodeSchemaBase.d.ts.map +1 -0
  538. package/lib/simple-tree/core/simpleNodeSchemaBase.js +6 -0
  539. package/lib/simple-tree/core/simpleNodeSchemaBase.js.map +1 -0
  540. package/lib/simple-tree/core/toStored.d.ts +32 -0
  541. package/lib/simple-tree/core/toStored.d.ts.map +1 -0
  542. package/lib/simple-tree/core/toStored.js +32 -0
  543. package/lib/simple-tree/core/toStored.js.map +1 -0
  544. package/lib/simple-tree/core/treeNodeKernel.d.ts +1 -1
  545. package/lib/simple-tree/core/treeNodeKernel.js +1 -1
  546. package/lib/simple-tree/core/treeNodeKernel.js.map +1 -1
  547. package/lib/simple-tree/core/treeNodeSchema.d.ts +7 -2
  548. package/lib/simple-tree/core/treeNodeSchema.d.ts.map +1 -1
  549. package/lib/simple-tree/core/treeNodeSchema.js.map +1 -1
  550. package/lib/simple-tree/core/treeNodeValid.d.ts +7 -2
  551. package/lib/simple-tree/core/treeNodeValid.d.ts.map +1 -1
  552. package/lib/simple-tree/core/treeNodeValid.js +17 -3
  553. package/lib/simple-tree/core/treeNodeValid.js.map +1 -1
  554. package/lib/simple-tree/core/walkSchema.d.ts +22 -5
  555. package/lib/simple-tree/core/walkSchema.d.ts.map +1 -1
  556. package/lib/simple-tree/core/walkSchema.js +6 -2
  557. package/lib/simple-tree/core/walkSchema.js.map +1 -1
  558. package/lib/simple-tree/createContext.d.ts +2 -0
  559. package/lib/simple-tree/createContext.d.ts.map +1 -1
  560. package/lib/simple-tree/createContext.js +5 -3
  561. package/lib/simple-tree/createContext.js.map +1 -1
  562. package/lib/simple-tree/fieldSchema.d.ts +1 -0
  563. package/lib/simple-tree/fieldSchema.d.ts.map +1 -1
  564. package/lib/simple-tree/fieldSchema.js +2 -1
  565. package/lib/simple-tree/fieldSchema.js.map +1 -1
  566. package/lib/simple-tree/index.d.ts +7 -7
  567. package/lib/simple-tree/index.d.ts.map +1 -1
  568. package/lib/simple-tree/index.js +5 -5
  569. package/lib/simple-tree/index.js.map +1 -1
  570. package/lib/simple-tree/leafNodeSchema.d.ts.map +1 -1
  571. package/lib/simple-tree/leafNodeSchema.js +2 -1
  572. package/lib/simple-tree/leafNodeSchema.js.map +1 -1
  573. package/lib/simple-tree/node-kinds/array/arrayNode.d.ts.map +1 -1
  574. package/lib/simple-tree/node-kinds/array/arrayNode.js +21 -7
  575. package/lib/simple-tree/node-kinds/array/arrayNode.js.map +1 -1
  576. package/lib/simple-tree/node-kinds/index.d.ts +1 -1
  577. package/lib/simple-tree/node-kinds/index.d.ts.map +1 -1
  578. package/lib/simple-tree/node-kinds/index.js +1 -1
  579. package/lib/simple-tree/node-kinds/index.js.map +1 -1
  580. package/lib/simple-tree/node-kinds/map/mapNode.d.ts.map +1 -1
  581. package/lib/simple-tree/node-kinds/map/mapNode.js +12 -5
  582. package/lib/simple-tree/node-kinds/map/mapNode.js.map +1 -1
  583. package/lib/simple-tree/node-kinds/object/index.d.ts +1 -1
  584. package/lib/simple-tree/node-kinds/object/index.d.ts.map +1 -1
  585. package/lib/simple-tree/node-kinds/object/index.js +1 -1
  586. package/lib/simple-tree/node-kinds/object/index.js.map +1 -1
  587. package/lib/simple-tree/node-kinds/object/objectNode.d.ts +3 -8
  588. package/lib/simple-tree/node-kinds/object/objectNode.d.ts.map +1 -1
  589. package/lib/simple-tree/node-kinds/object/objectNode.js +19 -21
  590. package/lib/simple-tree/node-kinds/object/objectNode.js.map +1 -1
  591. package/lib/simple-tree/node-kinds/record/recordNode.d.ts.map +1 -1
  592. package/lib/simple-tree/node-kinds/record/recordNode.js +12 -5
  593. package/lib/simple-tree/node-kinds/record/recordNode.js.map +1 -1
  594. package/lib/simple-tree/prepareForInsertion.d.ts +6 -6
  595. package/lib/simple-tree/prepareForInsertion.d.ts.map +1 -1
  596. package/lib/simple-tree/prepareForInsertion.js +21 -15
  597. package/lib/simple-tree/prepareForInsertion.js.map +1 -1
  598. package/lib/simple-tree/simpleSchema.d.ts +6 -21
  599. package/lib/simple-tree/simpleSchema.d.ts.map +1 -1
  600. package/lib/simple-tree/simpleSchema.js.map +1 -1
  601. package/lib/simple-tree/toStoredSchema.d.ts +38 -11
  602. package/lib/simple-tree/toStoredSchema.d.ts.map +1 -1
  603. package/lib/simple-tree/toStoredSchema.js +70 -34
  604. package/lib/simple-tree/toStoredSchema.js.map +1 -1
  605. package/lib/simple-tree/unhydratedFlexTreeFromInsertable.d.ts +2 -2
  606. package/lib/simple-tree/unhydratedFlexTreeFromInsertable.d.ts.map +1 -1
  607. package/lib/simple-tree/unhydratedFlexTreeFromInsertable.js +1 -1
  608. package/lib/simple-tree/unhydratedFlexTreeFromInsertable.js.map +1 -1
  609. package/lib/simple-tree/walkFieldSchema.d.ts +1 -0
  610. package/lib/simple-tree/walkFieldSchema.d.ts.map +1 -1
  611. package/lib/simple-tree/walkFieldSchema.js +1 -0
  612. package/lib/simple-tree/walkFieldSchema.js.map +1 -1
  613. package/package.json +23 -23
  614. package/src/codec/codec.ts +4 -3
  615. package/src/core/index.ts +2 -0
  616. package/src/core/rebase/index.ts +2 -0
  617. package/src/core/rebase/types.ts +4 -0
  618. package/src/core/schema-stored/schema.ts +2 -26
  619. package/src/core/tree/detachedFieldIndex.ts +4 -6
  620. package/src/core/tree/detachedFieldIndexCodecCommon.ts +87 -0
  621. package/src/core/tree/{detachedFieldIndexCodec.ts → detachedFieldIndexCodecV1.ts} +22 -68
  622. package/src/core/tree/detachedFieldIndexCodecV2.ts +72 -0
  623. package/src/core/tree/detachedFieldIndexCodecs.ts +44 -0
  624. package/src/core/tree/{detachedFieldIndexFormat.ts → detachedFieldIndexFormatCommon.ts} +32 -23
  625. package/src/core/tree/detachedFieldIndexFormatV1.ts +15 -0
  626. package/src/core/tree/detachedFieldIndexFormatV2.ts +17 -0
  627. package/src/feature-libraries/chunked-forest/codec/README.md +1 -1
  628. package/src/feature-libraries/chunked-forest/codec/chunkDecoding.ts +25 -25
  629. package/src/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.ts +10 -6
  630. package/src/feature-libraries/chunked-forest/codec/compressedEncode.ts +96 -73
  631. package/src/feature-libraries/chunked-forest/codec/format.ts +20 -14
  632. package/src/feature-libraries/chunked-forest/codec/{nodeShape.ts → nodeEncoder.ts} +23 -17
  633. package/src/feature-libraries/chunked-forest/codec/schemaBasedEncode.ts +34 -34
  634. package/src/feature-libraries/chunked-forest/codec/uncompressedEncode.ts +5 -5
  635. package/src/feature-libraries/default-schema/defaultFieldKinds.ts +11 -0
  636. package/src/feature-libraries/default-schema/defaultSchema.ts +0 -2
  637. package/src/feature-libraries/default-schema/index.ts +1 -1
  638. package/src/feature-libraries/default-schema/schemaChecker.ts +47 -30
  639. package/src/feature-libraries/index.ts +1 -3
  640. package/src/feature-libraries/modular-schema/comparison.ts +14 -29
  641. package/src/feature-libraries/modular-schema/fieldChangeHandler.ts +9 -0
  642. package/src/feature-libraries/modular-schema/genericFieldKind.ts +1 -0
  643. package/src/feature-libraries/modular-schema/modularChangeFamily.ts +61 -19
  644. package/src/feature-libraries/object-forest/objectForest.ts +10 -6
  645. package/src/feature-libraries/optional-field/optionalField.ts +4 -0
  646. package/src/feature-libraries/sequence-field/sequenceFieldChangeRebaser.ts +4 -0
  647. package/src/index.ts +7 -1
  648. package/src/jsonDomainSchema.ts +4 -0
  649. package/src/packageVersion.ts +1 -1
  650. package/src/shared-tree/independentView.ts +45 -19
  651. package/src/shared-tree/schematizeTree.ts +2 -2
  652. package/src/shared-tree/schematizingTreeView.ts +24 -15
  653. package/src/shared-tree/sharedTree.ts +2 -42
  654. package/src/shared-tree/treeAlpha.ts +48 -22
  655. package/src/shared-tree/treeCheckout.ts +54 -10
  656. package/src/shared-tree-core/branch.ts +1 -6
  657. package/src/simple-tree/api/conciseTree.ts +9 -7
  658. package/src/simple-tree/api/configuration.ts +18 -4
  659. package/src/simple-tree/api/create.ts +44 -36
  660. package/src/simple-tree/api/customTree.ts +59 -20
  661. package/src/simple-tree/api/discrepancies.ts +474 -0
  662. package/src/simple-tree/api/index.ts +2 -3
  663. package/src/simple-tree/api/schemaCompatibilityTester.ts +23 -151
  664. package/src/simple-tree/api/schemaFactory.ts +13 -254
  665. package/src/simple-tree/api/schemaFactoryAlpha.ts +174 -1
  666. package/src/simple-tree/api/schemaFactoryRecursive.ts +1 -25
  667. package/src/simple-tree/api/schemaStatics.ts +291 -0
  668. package/src/simple-tree/api/storedSchema.ts +18 -14
  669. package/src/simple-tree/api/treeBeta.ts +24 -4
  670. package/src/simple-tree/api/verboseTree.ts +17 -8
  671. package/src/simple-tree/core/allowedTypes.ts +87 -34
  672. package/src/simple-tree/core/context.ts +24 -22
  673. package/src/simple-tree/core/index.ts +11 -2
  674. package/src/simple-tree/core/simpleNodeSchemaBase.ts +30 -0
  675. package/src/simple-tree/core/toStored.ts +58 -0
  676. package/src/simple-tree/core/treeNodeKernel.ts +1 -1
  677. package/src/simple-tree/core/treeNodeSchema.ts +8 -2
  678. package/src/simple-tree/core/treeNodeValid.ts +23 -4
  679. package/src/simple-tree/core/walkSchema.ts +26 -6
  680. package/src/simple-tree/createContext.ts +11 -3
  681. package/src/simple-tree/fieldSchema.ts +3 -1
  682. package/src/simple-tree/index.ts +19 -13
  683. package/src/simple-tree/leafNodeSchema.ts +2 -1
  684. package/src/simple-tree/node-kinds/array/arrayNode.ts +64 -23
  685. package/src/simple-tree/node-kinds/index.ts +0 -1
  686. package/src/simple-tree/node-kinds/map/mapNode.ts +23 -2
  687. package/src/simple-tree/node-kinds/object/index.ts +0 -1
  688. package/src/simple-tree/node-kinds/object/objectNode.ts +42 -30
  689. package/src/simple-tree/node-kinds/record/recordNode.ts +20 -2
  690. package/src/simple-tree/prepareForInsertion.ts +28 -15
  691. package/src/simple-tree/simpleSchema.ts +6 -26
  692. package/src/simple-tree/toStoredSchema.ts +110 -44
  693. package/src/simple-tree/unhydratedFlexTreeFromInsertable.ts +6 -2
  694. package/src/simple-tree/walkFieldSchema.ts +1 -0
  695. package/dist/core/tree/detachedFieldIndexCodec.d.ts +0 -11
  696. package/dist/core/tree/detachedFieldIndexCodec.d.ts.map +0 -1
  697. package/dist/core/tree/detachedFieldIndexCodec.js +0 -100
  698. package/dist/core/tree/detachedFieldIndexCodec.js.map +0 -1
  699. package/dist/core/tree/detachedFieldIndexFormat.d.ts +0 -33
  700. package/dist/core/tree/detachedFieldIndexFormat.d.ts.map +0 -1
  701. package/dist/core/tree/detachedFieldIndexFormat.js.map +0 -1
  702. package/dist/feature-libraries/chunked-forest/codec/nodeShape.d.ts.map +0 -1
  703. package/dist/feature-libraries/chunked-forest/codec/nodeShape.js.map +0 -1
  704. package/dist/feature-libraries/initializeForest.d.ts +0 -18
  705. package/dist/feature-libraries/initializeForest.d.ts.map +0 -1
  706. package/dist/feature-libraries/initializeForest.js +0 -35
  707. package/dist/feature-libraries/initializeForest.js.map +0 -1
  708. package/dist/simple-tree/discrepancies.d.ts +0 -167
  709. package/dist/simple-tree/discrepancies.d.ts.map +0 -1
  710. package/dist/simple-tree/discrepancies.js +0 -382
  711. package/dist/simple-tree/discrepancies.js.map +0 -1
  712. package/lib/core/tree/detachedFieldIndexCodec.d.ts +0 -11
  713. package/lib/core/tree/detachedFieldIndexCodec.d.ts.map +0 -1
  714. package/lib/core/tree/detachedFieldIndexCodec.js +0 -96
  715. package/lib/core/tree/detachedFieldIndexCodec.js.map +0 -1
  716. package/lib/core/tree/detachedFieldIndexFormat.d.ts +0 -33
  717. package/lib/core/tree/detachedFieldIndexFormat.d.ts.map +0 -1
  718. package/lib/core/tree/detachedFieldIndexFormat.js.map +0 -1
  719. package/lib/feature-libraries/chunked-forest/codec/nodeShape.d.ts.map +0 -1
  720. package/lib/feature-libraries/chunked-forest/codec/nodeShape.js.map +0 -1
  721. package/lib/feature-libraries/initializeForest.d.ts +0 -18
  722. package/lib/feature-libraries/initializeForest.d.ts.map +0 -1
  723. package/lib/feature-libraries/initializeForest.js +0 -31
  724. package/lib/feature-libraries/initializeForest.js.map +0 -1
  725. package/lib/simple-tree/discrepancies.d.ts +0 -167
  726. package/lib/simple-tree/discrepancies.d.ts.map +0 -1
  727. package/lib/simple-tree/discrepancies.js +0 -376
  728. package/lib/simple-tree/discrepancies.js.map +0 -1
  729. package/src/feature-libraries/initializeForest.ts +0 -55
  730. package/src/simple-tree/discrepancies.ts +0 -648
@@ -0,0 +1 @@
1
+ {"version":3,"file":"detachedFieldIndexCodecV1.js","sourceRoot":"","sources":["../../../src/core/tree/detachedFieldIndexCodecV1.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAA6D;AAI7D,iDAK4B;AAE5B,mFAA0E;AAE1E,yFAA+F;AAE/F,MAAM,UAAU;IACf,YACkB,gBAAkC,EAClC,OAAsB,EACtB,YAA2B;QAF3B,qBAAgB,GAAhB,gBAAgB,CAAkB;QAClC,YAAO,GAAP,OAAO,CAAe;QACtB,iBAAY,GAAZ,YAAY,CAAe;IAC1C,CAAC;IAEG,MAAM,CAAC,KAAY;QACzB,IAAA,iBAAM,EAAC,KAAK,KAAK,SAAS,EAAE,KAAK,CAAC,mCAAmC,CAAC,CAAC;QACvE,MAAM,EAAE,GAAG,IAAI,CAAC,gBAAgB,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QAC/C;;;;;;;;;;;;;;;;WAgBG;QACH,IAAA,iBAAM,EACL,EAAE,KAAK,MAAM,IAAI,EAAE,IAAI,CAAC,EACxB,KAAK,CAAC,kEAAkE,CACxE,CAAC;QACF,OAAO,EAAE,CAAC;IACX,CAAC;IAEM,MAAM,CAAC,KAAyB;QACtC,IAAA,iBAAM,EACL,KAAK,KAAK,MAAM,IAAI,KAAK,IAAI,CAAC,EAC9B,KAAK,CAAC,kEAAkE,CACxE,CAAC;QACF,OAAO,IAAI,CAAC,gBAAgB,CAAC,MAAM,CAAC,KAAK,EAAE;YAC1C,YAAY,EAAE,IAAI,CAAC,gBAAgB,CAAC,cAAc;YAClD,YAAY,EAAE,IAAI,CAAC,YAAY;YAC/B,QAAQ,EAAE,SAAS;SACnB,CAAC,CAAC;IACJ,CAAC;CACD;AAED,SAAgB,8BAA8B,CAC7C,gBAAkC,EAClC,OAAsB,EACtB,YAA2B;IAE3B,MAAM,UAAU,GAAG,IAAI,UAAU,CAAC,gBAAgB,EAAE,OAAO,EAAE,YAAY,CAAC,CAAC;IAC3E,OAAO,IAAA,4EAAyC,EAC/C,OAAO,EACP,UAAU,EACV,wCAAQ,EACR,4BAAiB,CACjB,CAAC;AACH,CAAC;AAZD,wEAYC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport type { IIdCompressor } from \"@fluidframework/id-compressor\";\n\nimport type { ICodecOptions, IJsonCodec } from \"../../codec/index.js\";\nimport {\n\ttype EncodedRevisionTag,\n\ttype RevisionTagCodec,\n\ttype RevisionTag,\n\tRevisionTagSchema,\n} from \"../rebase/index.js\";\n\nimport { type FormatV1, version1 } from \"./detachedFieldIndexFormatV1.js\";\nimport type { DetachedFieldSummaryData, Major } from \"./detachedFieldIndexTypes.js\";\nimport { makeDetachedFieldIndexCodecFromMajorCodec } from \"./detachedFieldIndexCodecCommon.js\";\n\nclass MajorCodec implements IJsonCodec<Major, EncodedRevisionTag> {\n\tpublic constructor(\n\t\tprivate readonly revisionTagCodec: RevisionTagCodec,\n\t\tprivate readonly options: ICodecOptions,\n\t\tprivate readonly idCompressor: IIdCompressor,\n\t) {}\n\n\tpublic encode(major: Major): EncodedRevisionTag {\n\t\tassert(major !== undefined, 0x88e /* Unexpected undefined revision */);\n\t\tconst id = this.revisionTagCodec.encode(major);\n\t\t/**\n\t\t * Preface: this codec is only used at summarization time (not for ops).\n\t\t * Note that the decode path must provide a session id in which to interpret the revision tag.\n\t\t * The revision associated with a detached root generally comes from the session which detaches that subtree,\n\t\t * which isn't generally the local session (nor is it available at decode time with the layering of the tree\n\t\t * package), despite decode using the local session id.\n\t\t *\n\t\t * This is made OK by enforcing that all ids on encode/decode are non-local, since local ids won't be interpretable\n\t\t * at decode time.\n\t\t * This assert is valid because the revision for an acked edit will have already been finalized, and a revision\n\t\t * for a local-only edit will be finalizable at summarization time (local edits can only occur on a summarizing client\n\t\t * if they're created while detached, and local ids made while detached are finalized before generating the attach summary).\n\t\t *\n\t\t * WARNING: the above is true when the whole container transitions from detached to attached,\n\t\t * but not when the container is already attached and it's just the shared-tree that is attaching.\n\t\t * The assert below will fail in such a scenario. This is addressed in the v2 codec.\n\t\t */\n\t\tassert(\n\t\t\tid === \"root\" || id >= 0,\n\t\t\t0x88f /* Expected final id on encode of detached field index revision */,\n\t\t);\n\t\treturn id;\n\t}\n\n\tpublic decode(major: EncodedRevisionTag): RevisionTag {\n\t\tassert(\n\t\t\tmajor === \"root\" || major >= 0,\n\t\t\t0x890 /* Expected final id on decode of detached field index revision */,\n\t\t);\n\t\treturn this.revisionTagCodec.decode(major, {\n\t\t\toriginatorId: this.revisionTagCodec.localSessionId,\n\t\t\tidCompressor: this.idCompressor,\n\t\t\trevision: undefined,\n\t\t});\n\t}\n}\n\nexport function makeDetachedNodeToFieldCodecV1(\n\trevisionTagCodec: RevisionTagCodec,\n\toptions: ICodecOptions,\n\tidCompressor: IIdCompressor,\n): IJsonCodec<DetachedFieldSummaryData, FormatV1> {\n\tconst majorCodec = new MajorCodec(revisionTagCodec, options, idCompressor);\n\treturn makeDetachedFieldIndexCodecFromMajorCodec(\n\t\toptions,\n\t\tmajorCodec,\n\t\tversion1,\n\t\tRevisionTagSchema,\n\t);\n}\n"]}
@@ -0,0 +1,11 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ import type { IIdCompressor } from "@fluidframework/id-compressor";
6
+ import type { ICodecOptions, IJsonCodec } from "../../codec/index.js";
7
+ import type { RevisionTagCodec } from "../rebase/index.js";
8
+ import { type FormatV2 } from "./detachedFieldIndexFormatV2.js";
9
+ import type { DetachedFieldSummaryData } from "./detachedFieldIndexTypes.js";
10
+ export declare function makeDetachedNodeToFieldCodecV2(revisionTagCodec: RevisionTagCodec, options: ICodecOptions, idCompressor: IIdCompressor): IJsonCodec<DetachedFieldSummaryData, FormatV2>;
11
+ //# sourceMappingURL=detachedFieldIndexCodecV2.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"detachedFieldIndexCodecV2.d.ts","sourceRoot":"","sources":["../../../src/core/tree/detachedFieldIndexCodecV2.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,aAAa,EAAY,MAAM,+BAA+B,CAAC;AAE7E,OAAO,KAAK,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AACtE,OAAO,KAAK,EAAsB,gBAAgB,EAAe,MAAM,oBAAoB,CAAC;AAE5F,OAAO,EACN,KAAK,QAAQ,EAGb,MAAM,iCAAiC,CAAC;AACzC,OAAO,KAAK,EAAE,wBAAwB,EAAS,MAAM,8BAA8B,CAAC;AA2CpF,wBAAgB,8BAA8B,CAC7C,gBAAgB,EAAE,gBAAgB,EAClC,OAAO,EAAE,aAAa,EACtB,YAAY,EAAE,aAAa,GACzB,UAAU,CAAC,wBAAwB,EAAE,QAAQ,CAAC,CAQhD"}
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+ /*!
3
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
4
+ * Licensed under the MIT License.
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.makeDetachedNodeToFieldCodecV2 = void 0;
8
+ const internal_1 = require("@fluidframework/core-utils/internal");
9
+ const detachedFieldIndexFormatV2_js_1 = require("./detachedFieldIndexFormatV2.js");
10
+ const detachedFieldIndexCodecCommon_js_1 = require("./detachedFieldIndexCodecCommon.js");
11
+ const internal_2 = require("@fluidframework/id-compressor/internal");
12
+ class MajorCodec {
13
+ constructor(revisionTagCodec, options, idCompressor) {
14
+ this.revisionTagCodec = revisionTagCodec;
15
+ this.options = options;
16
+ this.idCompressor = idCompressor;
17
+ }
18
+ encode(major) {
19
+ (0, internal_1.assert)(major !== undefined, 0xbfb /* Unexpected undefined revision */);
20
+ const id = this.revisionTagCodec.encode(major);
21
+ if (id !== "root" && id < 0) {
22
+ /**
23
+ * This code path handles the case where the major revision is not finalized.
24
+ * This can happen the SharedTree is being attached to an already attached container.
25
+ */
26
+ (0, internal_1.assert)(major !== "root", 0xbfc /* Major revision cannot be 'root' */);
27
+ const long = this.idCompressor.decompress(major);
28
+ return long;
29
+ }
30
+ return id;
31
+ }
32
+ decode(major) {
33
+ (0, internal_1.assert)(major === "root" || (typeof major === "string" && (0, internal_2.isStableId)(major)) || major >= 0, 0xbfd /* Expected root, stable, or final compressed id */);
34
+ if (typeof major === "string" && (0, internal_2.isStableId)(major)) {
35
+ return this.idCompressor.recompress(major);
36
+ }
37
+ return this.revisionTagCodec.decode(major, {
38
+ originatorId: this.revisionTagCodec.localSessionId,
39
+ idCompressor: this.idCompressor,
40
+ revision: undefined,
41
+ });
42
+ }
43
+ }
44
+ function makeDetachedNodeToFieldCodecV2(revisionTagCodec, options, idCompressor) {
45
+ const majorCodec = new MajorCodec(revisionTagCodec, options, idCompressor);
46
+ return (0, detachedFieldIndexCodecCommon_js_1.makeDetachedFieldIndexCodecFromMajorCodec)(options, majorCodec, detachedFieldIndexFormatV2_js_1.version2, detachedFieldIndexFormatV2_js_1.StableOrFinalRevisionTag);
47
+ }
48
+ exports.makeDetachedNodeToFieldCodecV2 = makeDetachedNodeToFieldCodecV2;
49
+ //# sourceMappingURL=detachedFieldIndexCodecV2.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"detachedFieldIndexCodecV2.js","sourceRoot":"","sources":["../../../src/core/tree/detachedFieldIndexCodecV2.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAA6D;AAM7D,mFAIyC;AAEzC,yFAA+F;AAC/F,qEAAoE;AAEpE,MAAM,UAAU;IACf,YACkB,gBAAkC,EAClC,OAAsB,EACtB,YAA2B;QAF3B,qBAAgB,GAAhB,gBAAgB,CAAkB;QAClC,YAAO,GAAP,OAAO,CAAe;QACtB,iBAAY,GAAZ,YAAY,CAAe;IAC1C,CAAC;IAEG,MAAM,CAAC,KAAY;QACzB,IAAA,iBAAM,EAAC,KAAK,KAAK,SAAS,EAAE,KAAK,CAAC,mCAAmC,CAAC,CAAC;QACvE,MAAM,EAAE,GAAG,IAAI,CAAC,gBAAgB,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QAE/C,IAAI,EAAE,KAAK,MAAM,IAAI,EAAE,GAAG,CAAC,EAAE,CAAC;YAC7B;;;eAGG;YACH,IAAA,iBAAM,EAAC,KAAK,KAAK,MAAM,EAAE,KAAK,CAAC,qCAAqC,CAAC,CAAC;YACtE,MAAM,IAAI,GAAG,IAAI,CAAC,YAAY,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;YACjD,OAAO,IAAI,CAAC;QACb,CAAC;QACD,OAAO,EAAE,CAAC;IACX,CAAC;IAEM,MAAM,CAAC,KAAoC;QACjD,IAAA,iBAAM,EACL,KAAK,KAAK,MAAM,IAAI,CAAC,OAAO,KAAK,KAAK,QAAQ,IAAI,IAAA,qBAAU,EAAC,KAAK,CAAC,CAAC,IAAI,KAAK,IAAI,CAAC,EAClF,KAAK,CAAC,mDAAmD,CACzD,CAAC;QACF,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,IAAA,qBAAU,EAAC,KAAK,CAAC,EAAE,CAAC;YACpD,OAAO,IAAI,CAAC,YAAY,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;QAC5C,CAAC;QACD,OAAO,IAAI,CAAC,gBAAgB,CAAC,MAAM,CAAC,KAAK,EAAE;YAC1C,YAAY,EAAE,IAAI,CAAC,gBAAgB,CAAC,cAAc;YAClD,YAAY,EAAE,IAAI,CAAC,YAAY;YAC/B,QAAQ,EAAE,SAAS;SACnB,CAAC,CAAC;IACJ,CAAC;CACD;AAED,SAAgB,8BAA8B,CAC7C,gBAAkC,EAClC,OAAsB,EACtB,YAA2B;IAE3B,MAAM,UAAU,GAAG,IAAI,UAAU,CAAC,gBAAgB,EAAE,OAAO,EAAE,YAAY,CAAC,CAAC;IAC3E,OAAO,IAAA,4EAAyC,EAC/C,OAAO,EACP,UAAU,EACV,wCAAQ,EACR,wDAAwB,CACxB,CAAC;AACH,CAAC;AAZD,wEAYC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport type { IIdCompressor, StableId } from \"@fluidframework/id-compressor\";\n\nimport type { ICodecOptions, IJsonCodec } from \"../../codec/index.js\";\nimport type { EncodedRevisionTag, RevisionTagCodec, RevisionTag } from \"../rebase/index.js\";\n\nimport {\n\ttype FormatV2,\n\tStableOrFinalRevisionTag,\n\tversion2,\n} from \"./detachedFieldIndexFormatV2.js\";\nimport type { DetachedFieldSummaryData, Major } from \"./detachedFieldIndexTypes.js\";\nimport { makeDetachedFieldIndexCodecFromMajorCodec } from \"./detachedFieldIndexCodecCommon.js\";\nimport { isStableId } from \"@fluidframework/id-compressor/internal\";\n\nclass MajorCodec implements IJsonCodec<Major> {\n\tpublic constructor(\n\t\tprivate readonly revisionTagCodec: RevisionTagCodec,\n\t\tprivate readonly options: ICodecOptions,\n\t\tprivate readonly idCompressor: IIdCompressor,\n\t) {}\n\n\tpublic encode(major: Major): EncodedRevisionTag | StableId {\n\t\tassert(major !== undefined, 0xbfb /* Unexpected undefined revision */);\n\t\tconst id = this.revisionTagCodec.encode(major);\n\n\t\tif (id !== \"root\" && id < 0) {\n\t\t\t/**\n\t\t\t * This code path handles the case where the major revision is not finalized.\n\t\t\t * This can happen the SharedTree is being attached to an already attached container.\n\t\t\t */\n\t\t\tassert(major !== \"root\", 0xbfc /* Major revision cannot be 'root' */);\n\t\t\tconst long = this.idCompressor.decompress(major);\n\t\t\treturn long;\n\t\t}\n\t\treturn id;\n\t}\n\n\tpublic decode(major: EncodedRevisionTag | StableId): RevisionTag {\n\t\tassert(\n\t\t\tmajor === \"root\" || (typeof major === \"string\" && isStableId(major)) || major >= 0,\n\t\t\t0xbfd /* Expected root, stable, or final compressed id */,\n\t\t);\n\t\tif (typeof major === \"string\" && isStableId(major)) {\n\t\t\treturn this.idCompressor.recompress(major);\n\t\t}\n\t\treturn this.revisionTagCodec.decode(major, {\n\t\t\toriginatorId: this.revisionTagCodec.localSessionId,\n\t\t\tidCompressor: this.idCompressor,\n\t\t\trevision: undefined,\n\t\t});\n\t}\n}\n\nexport function makeDetachedNodeToFieldCodecV2(\n\trevisionTagCodec: RevisionTagCodec,\n\toptions: ICodecOptions,\n\tidCompressor: IIdCompressor,\n): IJsonCodec<DetachedFieldSummaryData, FormatV2> {\n\tconst majorCodec = new MajorCodec(revisionTagCodec, options, idCompressor);\n\treturn makeDetachedFieldIndexCodecFromMajorCodec(\n\t\toptions,\n\t\tmajorCodec,\n\t\tversion2,\n\t\tStableOrFinalRevisionTag,\n\t);\n}\n"]}
@@ -0,0 +1,11 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ import type { IIdCompressor } from "@fluidframework/id-compressor";
6
+ import { type CodecWriteOptions, type ICodecFamily, type IJsonCodec } from "../../codec/index.js";
7
+ import type { RevisionTagCodec } from "../rebase/index.js";
8
+ import type { DetachedFieldSummaryData } from "./detachedFieldIndexTypes.js";
9
+ export declare function makeDetachedFieldIndexCodec(revisionTagCodec: RevisionTagCodec, options: CodecWriteOptions, idCompressor: IIdCompressor): IJsonCodec<DetachedFieldSummaryData>;
10
+ export declare function makeDetachedFieldIndexCodecFamily(revisionTagCodec: RevisionTagCodec, options: CodecWriteOptions, idCompressor: IIdCompressor): ICodecFamily<DetachedFieldSummaryData>;
11
+ //# sourceMappingURL=detachedFieldIndexCodecs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"detachedFieldIndexCodecs.d.ts","sourceRoot":"","sources":["../../../src/core/tree/detachedFieldIndexCodecs.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAEnE,OAAO,EACN,KAAK,iBAAiB,EAEtB,KAAK,YAAY,EACjB,KAAK,UAAU,EAGf,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAM3D,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,8BAA8B,CAAC;AAE7E,wBAAgB,2BAA2B,CAC1C,gBAAgB,EAAE,gBAAgB,EAClC,OAAO,EAAE,iBAAiB,EAC1B,YAAY,EAAE,aAAa,GACzB,UAAU,CAAC,wBAAwB,CAAC,CAKtC;AAED,wBAAgB,iCAAiC,CAChD,gBAAgB,EAAE,gBAAgB,EAClC,OAAO,EAAE,iBAAiB,EAC1B,YAAY,EAAE,aAAa,GACzB,YAAY,CAAC,wBAAwB,CAAC,CAKxC"}
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ /*!
3
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
4
+ * Licensed under the MIT License.
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.makeDetachedFieldIndexCodecFamily = exports.makeDetachedFieldIndexCodec = void 0;
8
+ const index_js_1 = require("../../codec/index.js");
9
+ const detachedFieldIndexFormatV1_js_1 = require("./detachedFieldIndexFormatV1.js");
10
+ const detachedFieldIndexFormatV2_js_1 = require("./detachedFieldIndexFormatV2.js");
11
+ const detachedFieldIndexCodecV1_js_1 = require("./detachedFieldIndexCodecV1.js");
12
+ const detachedFieldIndexCodecV2_js_1 = require("./detachedFieldIndexCodecV2.js");
13
+ function makeDetachedFieldIndexCodec(revisionTagCodec, options, idCompressor) {
14
+ const family = makeDetachedFieldIndexCodecFamily(revisionTagCodec, options, idCompressor);
15
+ const writeVersion = options.oldestCompatibleClient < index_js_1.FluidClientVersion.v2_52 ? detachedFieldIndexFormatV1_js_1.version1 : detachedFieldIndexFormatV2_js_1.version2;
16
+ return (0, index_js_1.makeVersionDispatchingCodec)(family, { ...options, writeVersion });
17
+ }
18
+ exports.makeDetachedFieldIndexCodec = makeDetachedFieldIndexCodec;
19
+ function makeDetachedFieldIndexCodecFamily(revisionTagCodec, options, idCompressor) {
20
+ return (0, index_js_1.makeCodecFamily)([
21
+ [detachedFieldIndexFormatV1_js_1.version1, (0, detachedFieldIndexCodecV1_js_1.makeDetachedNodeToFieldCodecV1)(revisionTagCodec, options, idCompressor)],
22
+ [detachedFieldIndexFormatV2_js_1.version2, (0, detachedFieldIndexCodecV2_js_1.makeDetachedNodeToFieldCodecV2)(revisionTagCodec, options, idCompressor)],
23
+ ]);
24
+ }
25
+ exports.makeDetachedFieldIndexCodecFamily = makeDetachedFieldIndexCodecFamily;
26
+ //# sourceMappingURL=detachedFieldIndexCodecs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"detachedFieldIndexCodecs.js","sourceRoot":"","sources":["../../../src/core/tree/detachedFieldIndexCodecs.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAIH,mDAO8B;AAG9B,mFAA2D;AAC3D,mFAA2D;AAC3D,iFAAgF;AAChF,iFAAgF;AAGhF,SAAgB,2BAA2B,CAC1C,gBAAkC,EAClC,OAA0B,EAC1B,YAA2B;IAE3B,MAAM,MAAM,GAAG,iCAAiC,CAAC,gBAAgB,EAAE,OAAO,EAAE,YAAY,CAAC,CAAC;IAC1F,MAAM,YAAY,GACjB,OAAO,CAAC,sBAAsB,GAAG,6BAAkB,CAAC,KAAK,CAAC,CAAC,CAAC,wCAAQ,CAAC,CAAC,CAAC,wCAAQ,CAAC;IACjF,OAAO,IAAA,sCAA2B,EAAC,MAAM,EAAE,EAAE,GAAG,OAAO,EAAE,YAAY,EAAE,CAAC,CAAC;AAC1E,CAAC;AATD,kEASC;AAED,SAAgB,iCAAiC,CAChD,gBAAkC,EAClC,OAA0B,EAC1B,YAA2B;IAE3B,OAAO,IAAA,0BAAe,EAAC;QACtB,CAAC,wCAAQ,EAAE,IAAA,6DAA8B,EAAC,gBAAgB,EAAE,OAAO,EAAE,YAAY,CAAC,CAAC;QACnF,CAAC,wCAAQ,EAAE,IAAA,6DAA8B,EAAC,gBAAgB,EAAE,OAAO,EAAE,YAAY,CAAC,CAAC;KACnF,CAAC,CAAC;AACJ,CAAC;AATD,8EASC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { IIdCompressor } from \"@fluidframework/id-compressor\";\n\nimport {\n\ttype CodecWriteOptions,\n\tFluidClientVersion,\n\ttype ICodecFamily,\n\ttype IJsonCodec,\n\tmakeCodecFamily,\n\tmakeVersionDispatchingCodec,\n} from \"../../codec/index.js\";\nimport type { RevisionTagCodec } from \"../rebase/index.js\";\n\nimport { version1 } from \"./detachedFieldIndexFormatV1.js\";\nimport { version2 } from \"./detachedFieldIndexFormatV2.js\";\nimport { makeDetachedNodeToFieldCodecV1 } from \"./detachedFieldIndexCodecV1.js\";\nimport { makeDetachedNodeToFieldCodecV2 } from \"./detachedFieldIndexCodecV2.js\";\nimport type { DetachedFieldSummaryData } from \"./detachedFieldIndexTypes.js\";\n\nexport function makeDetachedFieldIndexCodec(\n\trevisionTagCodec: RevisionTagCodec,\n\toptions: CodecWriteOptions,\n\tidCompressor: IIdCompressor,\n): IJsonCodec<DetachedFieldSummaryData> {\n\tconst family = makeDetachedFieldIndexCodecFamily(revisionTagCodec, options, idCompressor);\n\tconst writeVersion =\n\t\toptions.oldestCompatibleClient < FluidClientVersion.v2_52 ? version1 : version2;\n\treturn makeVersionDispatchingCodec(family, { ...options, writeVersion });\n}\n\nexport function makeDetachedFieldIndexCodecFamily(\n\trevisionTagCodec: RevisionTagCodec,\n\toptions: CodecWriteOptions,\n\tidCompressor: IIdCompressor,\n): ICodecFamily<DetachedFieldSummaryData> {\n\treturn makeCodecFamily([\n\t\t[version1, makeDetachedNodeToFieldCodecV1(revisionTagCodec, options, idCompressor)],\n\t\t[version2, makeDetachedNodeToFieldCodecV2(revisionTagCodec, options, idCompressor)],\n\t]);\n}\n"]}
@@ -0,0 +1,37 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ import { type Static, type TSchema } from "@sinclair/typebox";
6
+ import type { ForestRootId } from "./detachedFieldIndexTypes.js";
7
+ /**
8
+ * The ID of a detached node. Is not globally unique on.
9
+ * A `RevisionTag` + `DetachId` pair is globally unique and eventually consistent across clients.
10
+ */
11
+ export declare const DetachId: import("@sinclair/typebox").TNumber;
12
+ /**
13
+ * The ID of a root node in the forest associated with the owning checkout. Is unique for that forest.
14
+ * Is not consistent across clients.
15
+ */
16
+ export declare const ForestRootIdSchema: import("@sinclair/typebox").TUnsafe<ForestRootId>;
17
+ /**
18
+ * A mapping from a range of the detached node IDs the corresponding range root IDs.
19
+ * The detached node IDs need to be qualified with a revision (stored in the containing `EncodedRootsForRevision`).
20
+ * Note: the length of the range (currently always 1) can be looked up in the forest.
21
+ */
22
+ export declare const RootRange: import("@sinclair/typebox").TTuple<[import("@sinclair/typebox").TNumber, import("@sinclair/typebox").TUnsafe<ForestRootId>]>;
23
+ export type RootRange = Static<typeof RootRange>;
24
+ export declare const RootRanges: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TTuple<[import("@sinclair/typebox").TNumber, import("@sinclair/typebox").TUnsafe<ForestRootId>]>>;
25
+ export type RootRanges = Static<typeof RootRanges>;
26
+ /**
27
+ * For all the roots detached in a revision, represents a mapping from the detached node ID to corresponding root ID.
28
+ */
29
+ export declare const EncodedRootsForRevision: <Schema extends TSchema>(tRevisionTag: Schema) => import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TTuple<[Schema, import("@sinclair/typebox").TArray<import("@sinclair/typebox").TTuple<[import("@sinclair/typebox").TNumber, import("@sinclair/typebox").TUnsafe<ForestRootId>]>>]>, import("@sinclair/typebox").TTuple<[Schema, import("@sinclair/typebox").TNumber, import("@sinclair/typebox").TUnsafe<ForestRootId>]>]>;
30
+ export type EncodedRootsForRevision = Static<ReturnType<typeof EncodedRootsForRevision>>;
31
+ export declare const Format: <TVersion extends number, TRevisionTagSchema extends TSchema>(tVersion: TVersion, tRevisionTag: TRevisionTagSchema) => import("@sinclair/typebox").TObject<{
32
+ version: import("@sinclair/typebox").TLiteral<TVersion>;
33
+ data: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TTuple<[TRevisionTagSchema, import("@sinclair/typebox").TArray<import("@sinclair/typebox").TTuple<[import("@sinclair/typebox").TNumber, import("@sinclair/typebox").TUnsafe<ForestRootId>]>>]>, import("@sinclair/typebox").TTuple<[TRevisionTagSchema, import("@sinclair/typebox").TNumber, import("@sinclair/typebox").TUnsafe<ForestRootId>]>]>>;
34
+ maxId: import("@sinclair/typebox").TUnsafe<ForestRootId>;
35
+ }>;
36
+ export type Format = Static<ReturnType<typeof Format>>;
37
+ //# sourceMappingURL=detachedFieldIndexFormatCommon.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"detachedFieldIndexFormatCommon.d.ts","sourceRoot":"","sources":["../../../src/core/tree/detachedFieldIndexFormatCommon.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,KAAK,MAAM,EAAE,KAAK,OAAO,EAAQ,MAAM,mBAAmB,CAAC;AAIpE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAEjE;;;GAGG;AACH,eAAO,MAAM,QAAQ,qCAAiC,CAAC;AAEvD;;;GAGG;AACH,eAAO,MAAM,kBAAkB,mDAG7B,CAAC;AAEH;;;;GAIG;AACH,eAAO,MAAM,SAAS,8HAKpB,CAAC;AACH,MAAM,MAAM,SAAS,GAAG,MAAM,CAAC,OAAO,SAAS,CAAC,CAAC;AAEjD,eAAO,MAAM,UAAU,kKAAwB,CAAC;AAChD,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC,OAAO,UAAU,CAAC,CAAC;AAEnD;;GAEG;AAGH,eAAO,MAAM,uBAAuB,yCAA0C,MAAM,+XAMjF,CAAC;AACJ,MAAM,MAAM,uBAAuB,GAAG,MAAM,CAAC,UAAU,CAAC,OAAO,uBAAuB,CAAC,CAAC,CAAC;AAEzF,eAAO,MAAM,MAAM,0EACR,QAAQ,gBACJ,kBAAkB;;;;EAW/B,CAAC;AAEH,MAAM,MAAM,MAAM,GAAG,MAAM,CAAC,UAAU,CAAC,OAAO,MAAM,CAAC,CAAC,CAAC"}
@@ -4,11 +4,9 @@
4
4
  * Licensed under the MIT License.
5
5
  */
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.Format = exports.EncodedRootsForRevision = exports.RootRanges = exports.RootRange = exports.DetachId = exports.version = void 0;
7
+ exports.Format = exports.EncodedRootsForRevision = exports.RootRanges = exports.RootRange = exports.ForestRootIdSchema = exports.DetachId = void 0;
8
8
  const typebox_1 = require("@sinclair/typebox");
9
9
  const index_js_1 = require("../../util/index.js");
10
- const index_js_2 = require("../rebase/index.js");
11
- exports.version = 1.0;
12
10
  /**
13
11
  * The ID of a detached node. Is not globally unique on.
14
12
  * A `RevisionTag` + `DetachId` pair is globally unique and eventually consistent across clients.
@@ -18,7 +16,10 @@ exports.DetachId = typebox_1.Type.Number({ multipleOf: 1 });
18
16
  * The ID of a root node in the forest associated with the owning checkout. Is unique for that forest.
19
17
  * Is not consistent across clients.
20
18
  */
21
- const ForestRootIdSchema = (0, index_js_1.brandedNumberType)({ minimum: -1, multipleOf: 1 });
19
+ exports.ForestRootIdSchema = (0, index_js_1.brandedNumberType)({
20
+ minimum: -1,
21
+ multipleOf: 1,
22
+ });
22
23
  /**
23
24
  * A mapping from a range of the detached node IDs the corresponding range root IDs.
24
25
  * The detached node IDs need to be qualified with a revision (stored in the containing `EncodedRootsForRevision`).
@@ -28,21 +29,25 @@ exports.RootRange = typebox_1.Type.Tuple([
28
29
  // ID for the first detached node
29
30
  exports.DetachId,
30
31
  // ID for the first root node
31
- ForestRootIdSchema,
32
+ exports.ForestRootIdSchema,
32
33
  ]);
33
34
  exports.RootRanges = typebox_1.Type.Array(exports.RootRange);
34
35
  /**
35
36
  * For all the roots detached in a revision, represents a mapping from the detached node ID to corresponding root ID.
36
37
  */
37
- exports.EncodedRootsForRevision = typebox_1.Type.Union([
38
+ // Return type is intentionally derived.
39
+ // eslint-disable-next-line @typescript-eslint/explicit-function-return-type
40
+ const EncodedRootsForRevision = (tRevisionTag) => typebox_1.Type.Union([
38
41
  // Used to represent a revision in which more than one node were detached
39
- typebox_1.Type.Tuple([index_js_2.RevisionTagSchema, exports.RootRanges]),
42
+ typebox_1.Type.Tuple([tRevisionTag, exports.RootRanges]),
40
43
  // Used to represent a revision in which a single node was detached
41
- typebox_1.Type.Tuple([index_js_2.RevisionTagSchema, exports.DetachId, ForestRootIdSchema]),
44
+ typebox_1.Type.Tuple([tRevisionTag, exports.DetachId, exports.ForestRootIdSchema]),
42
45
  ]);
43
- exports.Format = typebox_1.Type.Object({
44
- version: typebox_1.Type.Literal(exports.version),
45
- data: typebox_1.Type.Array(exports.EncodedRootsForRevision),
46
- maxId: ForestRootIdSchema,
46
+ exports.EncodedRootsForRevision = EncodedRootsForRevision;
47
+ const Format = (tVersion, tRevisionTag) => typebox_1.Type.Object({
48
+ version: typebox_1.Type.Literal(tVersion),
49
+ data: typebox_1.Type.Array((0, exports.EncodedRootsForRevision)(tRevisionTag)),
50
+ maxId: exports.ForestRootIdSchema,
47
51
  }, { additionalProperties: false });
48
- //# sourceMappingURL=detachedFieldIndexFormat.js.map
52
+ exports.Format = Format;
53
+ //# sourceMappingURL=detachedFieldIndexFormatCommon.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"detachedFieldIndexFormatCommon.js","sourceRoot":"","sources":["../../../src/core/tree/detachedFieldIndexFormatCommon.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+CAAoE;AAEpE,kDAAwD;AAIxD;;;GAGG;AACU,QAAA,QAAQ,GAAG,cAAI,CAAC,MAAM,CAAC,EAAE,UAAU,EAAE,CAAC,EAAE,CAAC,CAAC;AAEvD;;;GAGG;AACU,QAAA,kBAAkB,GAAG,IAAA,4BAAiB,EAAe;IACjE,OAAO,EAAE,CAAC,CAAC;IACX,UAAU,EAAE,CAAC;CACb,CAAC,CAAC;AAEH;;;;GAIG;AACU,QAAA,SAAS,GAAG,cAAI,CAAC,KAAK,CAAC;IACnC,iCAAiC;IACjC,gBAAQ;IACR,6BAA6B;IAC7B,0BAAkB;CAClB,CAAC,CAAC;AAGU,QAAA,UAAU,GAAG,cAAI,CAAC,KAAK,CAAC,iBAAS,CAAC,CAAC;AAGhD;;GAEG;AACH,wCAAwC;AACxC,4EAA4E;AACrE,MAAM,uBAAuB,GAAG,CAAyB,YAAoB,EAAE,EAAE,CACvF,cAAI,CAAC,KAAK,CAAC;IACV,yEAAyE;IACzE,cAAI,CAAC,KAAK,CAAC,CAAC,YAAY,EAAE,kBAAU,CAAC,CAAC;IACtC,mEAAmE;IACnE,cAAI,CAAC,KAAK,CAAC,CAAC,YAAY,EAAE,gBAAQ,EAAE,0BAAkB,CAAC,CAAC;CACxD,CAAC,CAAC;AANS,QAAA,uBAAuB,2BAMhC;AAGG,MAAM,MAAM,GAAG,CACrB,QAAkB,EAClB,YAAgC,EAG/B,EAAE,CACH,cAAI,CAAC,MAAM,CACV;IACC,OAAO,EAAE,cAAI,CAAC,OAAO,CAAC,QAAQ,CAAC;IAC/B,IAAI,EAAE,cAAI,CAAC,KAAK,CAAC,IAAA,+BAAuB,EAAC,YAAY,CAAC,CAAC;IACvD,KAAK,EAAE,0BAAkB;CACzB,EACD,EAAE,oBAAoB,EAAE,KAAK,EAAE,CAC/B,CAAC;AAbU,QAAA,MAAM,UAahB","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { type Static, type TSchema, Type } from \"@sinclair/typebox\";\n\nimport { brandedNumberType } from \"../../util/index.js\";\n\nimport type { ForestRootId } from \"./detachedFieldIndexTypes.js\";\n\n/**\n * The ID of a detached node. Is not globally unique on.\n * A `RevisionTag` + `DetachId` pair is globally unique and eventually consistent across clients.\n */\nexport const DetachId = Type.Number({ multipleOf: 1 });\n\n/**\n * The ID of a root node in the forest associated with the owning checkout. Is unique for that forest.\n * Is not consistent across clients.\n */\nexport const ForestRootIdSchema = brandedNumberType<ForestRootId>({\n\tminimum: -1,\n\tmultipleOf: 1,\n});\n\n/**\n * A mapping from a range of the detached node IDs the corresponding range root IDs.\n * The detached node IDs need to be qualified with a revision (stored in the containing `EncodedRootsForRevision`).\n * Note: the length of the range (currently always 1) can be looked up in the forest.\n */\nexport const RootRange = Type.Tuple([\n\t// ID for the first detached node\n\tDetachId,\n\t// ID for the first root node\n\tForestRootIdSchema,\n]);\nexport type RootRange = Static<typeof RootRange>;\n\nexport const RootRanges = Type.Array(RootRange);\nexport type RootRanges = Static<typeof RootRanges>;\n\n/**\n * For all the roots detached in a revision, represents a mapping from the detached node ID to corresponding root ID.\n */\n// Return type is intentionally derived.\n// eslint-disable-next-line @typescript-eslint/explicit-function-return-type\nexport const EncodedRootsForRevision = <Schema extends TSchema>(tRevisionTag: Schema) =>\n\tType.Union([\n\t\t// Used to represent a revision in which more than one node were detached\n\t\tType.Tuple([tRevisionTag, RootRanges]),\n\t\t// Used to represent a revision in which a single node was detached\n\t\tType.Tuple([tRevisionTag, DetachId, ForestRootIdSchema]),\n\t]);\nexport type EncodedRootsForRevision = Static<ReturnType<typeof EncodedRootsForRevision>>;\n\nexport const Format = <TVersion extends number, TRevisionTagSchema extends TSchema>(\n\ttVersion: TVersion,\n\ttRevisionTag: TRevisionTagSchema,\n\t// Return type is intentionally derived.\n\t// eslint-disable-next-line @typescript-eslint/explicit-function-return-type\n) =>\n\tType.Object(\n\t\t{\n\t\t\tversion: Type.Literal(tVersion),\n\t\t\tdata: Type.Array(EncodedRootsForRevision(tRevisionTag)),\n\t\t\tmaxId: ForestRootIdSchema,\n\t\t},\n\t\t{ additionalProperties: false },\n\t);\n\nexport type Format = Static<ReturnType<typeof Format>>;\n"]}
@@ -0,0 +1,13 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ import type { Static } from "@sinclair/typebox";
6
+ export declare const version1 = 1;
7
+ export declare const FormatV1: import("@sinclair/typebox").TObject<{
8
+ version: import("@sinclair/typebox").TLiteral<1>;
9
+ data: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TTuple<[import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"root">, import("@sinclair/typebox").TUnsafe<import("../../util/brand.js").Brand<import("@fluidframework/id-compressor").OpSpaceCompressedId, "EncodedRevisionTag">>]>, import("@sinclair/typebox").TArray<import("@sinclair/typebox").TTuple<[import("@sinclair/typebox").TNumber, import("@sinclair/typebox").TUnsafe<import("./detachedFieldIndexTypes.js").ForestRootId>]>>]>, import("@sinclair/typebox").TTuple<[import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"root">, import("@sinclair/typebox").TUnsafe<import("../../util/brand.js").Brand<import("@fluidframework/id-compressor").OpSpaceCompressedId, "EncodedRevisionTag">>]>, import("@sinclair/typebox").TNumber, import("@sinclair/typebox").TUnsafe<import("./detachedFieldIndexTypes.js").ForestRootId>]>]>>;
10
+ maxId: import("@sinclair/typebox").TUnsafe<import("./detachedFieldIndexTypes.js").ForestRootId>;
11
+ }>;
12
+ export type FormatV1 = Static<typeof FormatV1>;
13
+ //# sourceMappingURL=detachedFieldIndexFormatV1.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"detachedFieldIndexFormatV1.d.ts","sourceRoot":"","sources":["../../../src/core/tree/detachedFieldIndexFormatV1.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAKhD,eAAO,MAAM,QAAQ,IAAM,CAAC;AAE5B,eAAO,MAAM,QAAQ;;;;EAAsC,CAAC;AAE5D,MAAM,MAAM,QAAQ,GAAG,MAAM,CAAC,OAAO,QAAQ,CAAC,CAAC"}
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ /*!
3
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
4
+ * Licensed under the MIT License.
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.FormatV1 = exports.version1 = void 0;
8
+ const detachedFieldIndexFormatCommon_js_1 = require("./detachedFieldIndexFormatCommon.js");
9
+ const index_js_1 = require("../rebase/index.js");
10
+ exports.version1 = 1.0;
11
+ exports.FormatV1 = (0, detachedFieldIndexFormatCommon_js_1.Format)(exports.version1, index_js_1.RevisionTagSchema);
12
+ //# sourceMappingURL=detachedFieldIndexFormatV1.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"detachedFieldIndexFormatV1.js","sourceRoot":"","sources":["../../../src/core/tree/detachedFieldIndexFormatV1.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAIH,2FAA6D;AAC7D,iDAAuD;AAE1C,QAAA,QAAQ,GAAG,GAAG,CAAC;AAEf,QAAA,QAAQ,GAAG,IAAA,0CAAM,EAAC,gBAAQ,EAAE,4BAAiB,CAAC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { Static } from \"@sinclair/typebox\";\n\nimport { Format } from \"./detachedFieldIndexFormatCommon.js\";\nimport { RevisionTagSchema } from \"../rebase/index.js\";\n\nexport const version1 = 1.0;\n\nexport const FormatV1 = Format(version1, RevisionTagSchema);\n\nexport type FormatV1 = Static<typeof FormatV1>;\n"]}
@@ -0,0 +1,14 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ import { type Static } from "@sinclair/typebox";
6
+ export declare const version2 = 2;
7
+ export declare const StableOrFinalRevisionTag: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"root">, import("@sinclair/typebox").TUnsafe<import("../../util/brand.js").Brand<import("@fluidframework/id-compressor").OpSpaceCompressedId, "EncodedRevisionTag">>]>, import("@sinclair/typebox").TString]>;
8
+ export declare const FormatV2: import("@sinclair/typebox").TObject<{
9
+ version: import("@sinclair/typebox").TLiteral<2>;
10
+ data: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TTuple<[import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"root">, import("@sinclair/typebox").TUnsafe<import("../../util/brand.js").Brand<import("@fluidframework/id-compressor").OpSpaceCompressedId, "EncodedRevisionTag">>]>, import("@sinclair/typebox").TString]>, import("@sinclair/typebox").TArray<import("@sinclair/typebox").TTuple<[import("@sinclair/typebox").TNumber, import("@sinclair/typebox").TUnsafe<import("./detachedFieldIndexTypes.js").ForestRootId>]>>]>, import("@sinclair/typebox").TTuple<[import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"root">, import("@sinclair/typebox").TUnsafe<import("../../util/brand.js").Brand<import("@fluidframework/id-compressor").OpSpaceCompressedId, "EncodedRevisionTag">>]>, import("@sinclair/typebox").TString]>, import("@sinclair/typebox").TNumber, import("@sinclair/typebox").TUnsafe<import("./detachedFieldIndexTypes.js").ForestRootId>]>]>>;
11
+ maxId: import("@sinclair/typebox").TUnsafe<import("./detachedFieldIndexTypes.js").ForestRootId>;
12
+ }>;
13
+ export type FormatV2 = Static<typeof FormatV2>;
14
+ //# sourceMappingURL=detachedFieldIndexFormatV2.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"detachedFieldIndexFormatV2.d.ts","sourceRoot":"","sources":["../../../src/core/tree/detachedFieldIndexFormatV2.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAQ,KAAK,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAKtD,eAAO,MAAM,QAAQ,IAAM,CAAC;AAE5B,eAAO,MAAM,wBAAwB,4TAAkD,CAAC;AAExF,eAAO,MAAM,QAAQ;;;;EAA6C,CAAC;AAEnE,MAAM,MAAM,QAAQ,GAAG,MAAM,CAAC,OAAO,QAAQ,CAAC,CAAC"}
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ /*!
3
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
4
+ * Licensed under the MIT License.
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.FormatV2 = exports.StableOrFinalRevisionTag = exports.version2 = void 0;
8
+ const typebox_1 = require("@sinclair/typebox");
9
+ const detachedFieldIndexFormatCommon_js_1 = require("./detachedFieldIndexFormatCommon.js");
10
+ const index_js_1 = require("../rebase/index.js");
11
+ exports.version2 = 2.0;
12
+ exports.StableOrFinalRevisionTag = typebox_1.Type.Union([index_js_1.RevisionTagSchema, index_js_1.StableIdSchema]);
13
+ exports.FormatV2 = (0, detachedFieldIndexFormatCommon_js_1.Format)(exports.version2, exports.StableOrFinalRevisionTag);
14
+ //# sourceMappingURL=detachedFieldIndexFormatV2.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"detachedFieldIndexFormatV2.js","sourceRoot":"","sources":["../../../src/core/tree/detachedFieldIndexFormatV2.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+CAAsD;AAEtD,2FAA6D;AAC7D,iDAAuE;AAE1D,QAAA,QAAQ,GAAG,GAAG,CAAC;AAEf,QAAA,wBAAwB,GAAG,cAAI,CAAC,KAAK,CAAC,CAAC,4BAAiB,EAAE,yBAAc,CAAC,CAAC,CAAC;AAE3E,QAAA,QAAQ,GAAG,IAAA,0CAAM,EAAC,gBAAQ,EAAE,gCAAwB,CAAC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { Type, type Static } from \"@sinclair/typebox\";\n\nimport { Format } from \"./detachedFieldIndexFormatCommon.js\";\nimport { RevisionTagSchema, StableIdSchema } from \"../rebase/index.js\";\n\nexport const version2 = 2.0;\n\nexport const StableOrFinalRevisionTag = Type.Union([RevisionTagSchema, StableIdSchema]);\n\nexport const FormatV2 = Format(version2, StableOrFinalRevisionTag);\n\nexport type FormatV2 = Static<typeof FormatV2>;\n"]}
@@ -6,7 +6,7 @@ import type { IIdCompressor, SessionId } from "@fluidframework/id-compressor";
6
6
  import type { Value, TreeChunk } from "../../../core/index.js";
7
7
  import { type ChunkDecoder, type StreamCursor } from "./chunkCodecUtilities.js";
8
8
  import { DecoderContext } from "./chunkDecodingGeneric.js";
9
- import { type EncodedChunkShape, type EncodedFieldBatch, type EncodedInlineArray, type EncodedNestedArray, type EncodedTreeShape, type EncodedValueShape } from "./format.js";
9
+ import { type EncodedChunkShape, type EncodedFieldBatch, type EncodedInlineArrayShape, type EncodedNestedArrayShape, type EncodedNodeShape, type EncodedValueShape } from "./format.js";
10
10
  export interface IdDecodingContext {
11
11
  idCompressor: IIdCompressor;
12
12
  /**
@@ -38,19 +38,19 @@ export declare function deaggregateChunks(chunk: TreeChunk): TreeChunk[];
38
38
  */
39
39
  export declare function aggregateChunks(input: TreeChunk[]): TreeChunk;
40
40
  /**
41
- * Decoder for {@link EncodedNestedArray}s.
41
+ * Decoder for {@link EncodedNestedArrayShape}s.
42
42
  */
43
43
  export declare class NestedArrayDecoder implements ChunkDecoder {
44
44
  private readonly shape;
45
- constructor(shape: EncodedNestedArray);
45
+ constructor(shape: EncodedNestedArrayShape);
46
46
  decode(decoders: readonly ChunkDecoder[], stream: StreamCursor): TreeChunk;
47
47
  }
48
48
  /**
49
- * Decoder for {@link EncodedInlineArray}s.
49
+ * Decoder for {@link EncodedInlineArrayShape}s.
50
50
  */
51
51
  export declare class InlineArrayDecoder implements ChunkDecoder {
52
52
  private readonly shape;
53
- constructor(shape: EncodedInlineArray);
53
+ constructor(shape: EncodedInlineArrayShape);
54
54
  decode(decoders: readonly ChunkDecoder[], stream: StreamCursor): TreeChunk;
55
55
  }
56
56
  /**
@@ -58,14 +58,14 @@ export declare class InlineArrayDecoder implements ChunkDecoder {
58
58
  */
59
59
  export declare const anyDecoder: ChunkDecoder;
60
60
  /**
61
- * Decoder for {@link EncodedTreeShape}s.
61
+ * Decoder for {@link EncodedNodeShape}s.
62
62
  */
63
- export declare class TreeDecoder implements ChunkDecoder {
63
+ export declare class NodeDecoder implements ChunkDecoder {
64
64
  private readonly shape;
65
- private readonly cache;
65
+ private readonly context;
66
66
  private readonly type?;
67
67
  private readonly fieldDecoders;
68
- constructor(shape: EncodedTreeShape, cache: DecoderContext<EncodedChunkShape>);
68
+ constructor(shape: EncodedNodeShape, context: DecoderContext<EncodedChunkShape>);
69
69
  decode(decoders: readonly ChunkDecoder[], stream: StreamCursor): TreeChunk;
70
70
  }
71
71
  //# sourceMappingURL=chunkDecoding.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"chunkDecoding.d.ts","sourceRoot":"","sources":["../../../../src/feature-libraries/chunked-forest/codec/chunkDecoding.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EACX,aAAa,EAEb,SAAS,EACT,MAAM,+BAA+B,CAAC;AAGvC,OAAO,KAAK,EAGX,KAAK,EACL,SAAS,EACT,MAAM,wBAAwB,CAAC;AAMhC,OAAO,EACN,KAAK,YAAY,EACjB,KAAK,YAAY,EAOjB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACN,cAAc,EAGd,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAEN,KAAK,iBAAiB,EACtB,KAAK,iBAAiB,EACtB,KAAK,kBAAkB,EACvB,KAAK,kBAAkB,EACvB,KAAK,gBAAgB,EACrB,KAAK,iBAAiB,EAEtB,MAAM,aAAa,CAAC;AAErB,MAAM,WAAW,iBAAiB;IACjC,YAAY,EAAE,aAAa,CAAC;IAC5B;;OAEG;IACH,YAAY,EAAE,SAAS,CAAC;CACxB;AACD;;GAEG;AACH,wBAAgB,MAAM,CACrB,KAAK,EAAE,iBAAiB,EACxB,iBAAiB,EAAE;IAAE,YAAY,EAAE,aAAa,CAAC;IAAC,YAAY,EAAE,SAAS,CAAA;CAAE,GACzE,SAAS,EAAE,CAOb;AAqBD;;GAEG;AACH,wBAAgB,SAAS,CACxB,MAAM,EAAE,YAAY,EACpB,KAAK,EAAE,iBAAiB,EACxB,iBAAiB,EAAE,iBAAiB,GAClC,KAAK,CAgCP;AAED;;;;GAIG;A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AS,YAAY,EAAE,EAAE,MAAM,EAAE,YAAY,GAAG,SAAS;CASjF;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"}
@@ -4,7 +4,7 @@
4
4
  * Licensed under the MIT License.
5
5
  */
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.TreeDecoder = exports.anyDecoder = exports.InlineArrayDecoder = exports.NestedArrayDecoder = exports.aggregateChunks = exports.deaggregateChunks = exports.readValue = exports.decode = void 0;
7
+ exports.NodeDecoder = exports.anyDecoder = exports.InlineArrayDecoder = exports.NestedArrayDecoder = exports.aggregateChunks = exports.deaggregateChunks = exports.readValue = exports.decode = void 0;
8
8
  const internal_1 = require("@fluidframework/core-utils/internal");
9
9
  const index_js_1 = require("../../../codec/index.js");
10
10
  const index_js_2 = require("../../../util/index.js");
@@ -22,14 +22,14 @@ function decode(chunk, idDecodingContext) {
22
22
  }
23
23
  exports.decode = decode;
24
24
  const decoderLibrary = new index_js_1.DiscriminatedUnionDispatcher({
25
- a(shape, cache) {
25
+ a(shape, context) {
26
26
  return new NestedArrayDecoder(shape);
27
27
  },
28
- b(shape, cache) {
28
+ b(shape, context) {
29
29
  return new InlineArrayDecoder(shape);
30
30
  },
31
- c(shape, cache) {
32
- return new TreeDecoder(shape, cache);
31
+ c(shape, context) {
32
+ return new NodeDecoder(shape, context);
33
33
  },
34
34
  d(shape) {
35
35
  return exports.anyDecoder;
@@ -117,7 +117,7 @@ function aggregateChunks(input) {
117
117
  }
118
118
  exports.aggregateChunks = aggregateChunks;
119
119
  /**
120
- * Decoder for {@link EncodedNestedArray}s.
120
+ * Decoder for {@link EncodedNestedArrayShape}s.
121
121
  */
122
122
  class NestedArrayDecoder {
123
123
  constructor(shape) {
@@ -147,7 +147,7 @@ class NestedArrayDecoder {
147
147
  }
148
148
  exports.NestedArrayDecoder = NestedArrayDecoder;
149
149
  /**
150
- * Decoder for {@link EncodedInlineArray}s.
150
+ * Decoder for {@link EncodedInlineArrayShape}s.
151
151
  */
152
152
  class InlineArrayDecoder {
153
153
  constructor(shape) {
@@ -175,34 +175,34 @@ exports.anyDecoder = {
175
175
  },
176
176
  };
177
177
  /**
178
- * Get a decoder for fields of a provided (via `shape` and `cache`) {@link EncodedChunkShape}.
178
+ * Get a decoder for fields of a provided (via `shape` and `context`) {@link EncodedChunkShape}.
179
179
  */
180
- function fieldDecoder(cache, key, shape) {
181
- (0, index_js_2.assertValidIndex)(shape, cache.shapes);
180
+ function fieldDecoder(context, key, shape) {
181
+ (0, index_js_2.assertValidIndex)(shape, context.shapes);
182
182
  return (decoders, stream) => {
183
183
  const decoder = decoders[shape] ?? (0, internal_1.oob)();
184
184
  return [key, decoder.decode(decoders, stream)];
185
185
  };
186
186
  }
187
187
  /**
188
- * Decoder for {@link EncodedTreeShape}s.
188
+ * Decoder for {@link EncodedNodeShape}s.
189
189
  */
190
- class TreeDecoder {
191
- constructor(shape, cache) {
190
+ class NodeDecoder {
191
+ constructor(shape, context) {
192
192
  this.shape = shape;
193
- this.cache = cache;
194
- this.type = shape.type === undefined ? undefined : cache.identifier(shape.type);
193
+ this.context = context;
194
+ this.type = shape.type === undefined ? undefined : context.identifier(shape.type);
195
195
  const fieldDecoders = [];
196
196
  for (const [fieldKey, fieldShape] of shape.fields ?? []) {
197
- const key = cache.identifier(fieldKey);
198
- fieldDecoders.push(fieldDecoder(cache, key, fieldShape));
197
+ const key = context.identifier(fieldKey);
198
+ fieldDecoders.push(fieldDecoder(context, key, fieldShape));
199
199
  }
200
200
  this.fieldDecoders = fieldDecoders;
201
201
  }
202
202
  decode(decoders, stream) {
203
- const type = this.type ?? (0, chunkDecodingGeneric_js_1.readStreamIdentifier)(stream, this.cache);
203
+ const type = this.type ?? (0, chunkDecodingGeneric_js_1.readStreamIdentifier)(stream, this.context);
204
204
  // TODO: Consider typechecking against stored schema in here somewhere.
205
- const value = readValue(stream, this.shape.value, this.cache.idDecodingContext);
205
+ const value = readValue(stream, this.shape.value, this.context.idDecodingContext);
206
206
  const fields = new Map();
207
207
  // Helper to add fields, but with unneeded array chunks removed.
208
208
  function addField(key, data) {
@@ -221,12 +221,12 @@ class TreeDecoder {
221
221
  const decoder = decoders[this.shape.extraFields] ?? (0, internal_1.oob)();
222
222
  const inner = (0, chunkCodecUtilities_js_1.readStreamStream)(stream);
223
223
  while (inner.offset !== inner.data.length) {
224
- const key = (0, chunkDecodingGeneric_js_1.readStreamIdentifier)(inner, this.cache);
224
+ const key = (0, chunkDecodingGeneric_js_1.readStreamIdentifier)(inner, this.context);
225
225
  addField(key, decoder.decode(decoders, inner));
226
226
  }
227
227
  }
228
228
  return new basicChunk_js_1.BasicChunk(type, fields, value);
229
229
  }
230
230
  }
231
- exports.TreeDecoder = TreeDecoder;
231
+ exports.NodeDecoder = NodeDecoder;
232
232
  //# sourceMappingURL=chunkDecoding.js.map
@@ -1 +1 @@
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,qDAA0D;AAC1D,oDAA8C;AAC9C,oDAA8C;AAC9C,0DAAoD;AAEpD,qEASkC;AAClC,uEAImC;AACnC,2CASqB;AASrB;;GAEG;AACH,SAAgB,MAAM,CACrB,KAAwB,EACxB,iBAA2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M,KAAK,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;gBAC3C,MAAM,GAAG,GAAa,IAAA,8CAAoB,EAAC,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC;gBAC9D,QAAQ,CAAC,GAAG,EAAE,OAAO,CAAC,MAAM,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC,CAAC;YAChD,CAAC;QACF,CAAC;QAED,OAAO,IAAI,0BAAU,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC;IAC5C,CAAC;CACD;AAnDD,kCAmDC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, unreachableCase, oob } from \"@fluidframework/core-utils/internal\";\nimport type {\n\tIIdCompressor,\n\tOpSpaceCompressedId,\n\tSessionId,\n} from \"@fluidframework/id-compressor\";\n\nimport { DiscriminatedUnionDispatcher } from \"../../../codec/index.js\";\nimport type {\n\tFieldKey,\n\tTreeNodeSchemaIdentifier,\n\tValue,\n\tTreeChunk,\n} from \"../../../core/index.js\";\nimport { assertValidIndex } from \"../../../util/index.js\";\nimport { BasicChunk } from \"../basicChunk.js\";\nimport { emptyChunk } from \"../emptyChunk.js\";\nimport { SequenceChunk } from \"../sequenceChunk.js\";\n\nimport {\n\ttype ChunkDecoder,\n\ttype StreamCursor,\n\tgetChecked,\n\treadStream,\n\treadStreamBoolean,\n\treadStreamNumber,\n\treadStreamStream,\n\treadStreamValue,\n} from \"./chunkCodecUtilities.js\";\nimport {\n\tDecoderContext,\n\tdecode as genericDecode,\n\treadStreamIdentifier,\n} from \"./chunkDecodingGeneric.js\";\nimport {\n\ttype EncodedAnyShape,\n\ttype EncodedChunkShape,\n\ttype EncodedFieldBatch,\n\ttype EncodedInlineArray,\n\ttype EncodedNestedArray,\n\ttype EncodedTreeShape,\n\ttype EncodedValueShape,\n\tSpecialField,\n} from \"./format.js\";\n\nexport interface IdDecodingContext {\n\tidCompressor: IIdCompressor;\n\t/**\n\t * The creator of any local Ids to be decoded.\n\t */\n\toriginatorId: SessionId;\n}\n/**\n * Decode `chunk` into a TreeChunk.\n */\nexport function decode(\n\tchunk: EncodedFieldBatch,\n\tidDecodingContext: { idCompressor: IIdCompressor; originatorId: SessionId },\n): TreeChunk[] {\n\treturn genericDecode(\n\t\tdecoderLibrary,\n\t\tnew DecoderContext(chunk.identifiers, chunk.shapes, idDecodingContext),\n\t\tchunk,\n\t\tanyDecoder,\n\t);\n}\n\nconst decoderLibrary = new DiscriminatedUnionDispatcher<\n\tEncodedChunkShape,\n\t[cache: DecoderContext<EncodedChunkShape>],\n\tChunkDecoder\n>({\n\ta(shape: EncodedNestedArray, cache): ChunkDecoder {\n\t\treturn new NestedArrayDecoder(shape);\n\t},\n\tb(shape: EncodedInlineArray, cache): ChunkDecoder {\n\t\treturn new InlineArrayDecoder(shape);\n\t},\n\tc(shape: EncodedTreeShape, cache): ChunkDecoder {\n\t\treturn new TreeDecoder(shape, cache);\n\t},\n\td(shape: EncodedAnyShape): ChunkDecoder {\n\t\treturn anyDecoder;\n\t},\n});\n\n/**\n * Decode a node's value from `stream` using its shape.\n */\nexport function readValue(\n\tstream: StreamCursor,\n\tshape: EncodedValueShape,\n\tidDecodingContext: IdDecodingContext,\n): Value {\n\tif (shape === undefined) {\n\t\treturn readStreamBoolean(stream) ? readStreamValue(stream) : undefined;\n\t} else {\n\t\tif (shape === true) {\n\t\t\treturn readStreamValue(stream);\n\t\t} else if (shape === false) {\n\t\t\treturn undefined;\n\t\t} else if (Array.isArray(shape)) {\n\t\t\tassert(shape.length === 1, 0x734 /* expected a single constant for value */);\n\t\t\treturn shape[0] as Value;\n\t\t} else if (shape === SpecialField.Identifier) {\n\t\t\t// This case is a special case handling the decoding of identifier fields.\n\t\t\tconst streamValue = readStream(stream);\n\t\t\tassert(\n\t\t\t\ttypeof streamValue === \"number\" || typeof streamValue === \"string\",\n\t\t\t\t0x997 /* identifier must be string or number. */,\n\t\t\t);\n\t\t\tconst idCompressor = idDecodingContext.idCompressor;\n\t\t\treturn typeof streamValue === \"number\"\n\t\t\t\t? idCompressor.decompress(\n\t\t\t\t\t\tidCompressor.normalizeToSessionSpace(\n\t\t\t\t\t\t\tstreamValue as OpSpaceCompressedId,\n\t\t\t\t\t\t\tidDecodingContext.originatorId,\n\t\t\t\t\t\t),\n\t\t\t\t\t)\n\t\t\t\t: streamValue;\n\t\t} else {\n\t\t\t// EncodedCounter case:\n\t\t\tunreachableCase(shape, \"decoding values as deltas is not yet supported\");\n\t\t}\n\t}\n}\n\n/**\n * Normalize a {@link TreeChunk} into an array.\n *\n * Unwraps {@link SequenceChunk}s, and wraps other chunks.\n */\nexport function deaggregateChunks(chunk: TreeChunk): TreeChunk[] {\n\tif (chunk === emptyChunk) {\n\t\treturn [];\n\t}\n\t// TODO: when handling of SequenceChunks has better performance (for example in cursors),\n\t// consider keeping SequenceChunks here if they are longer than some threshold.\n\tif (chunk instanceof SequenceChunk) {\n\t\t// Could return [] here, however the logic in this file is designed to never produce an empty SequenceChunk, so its better to throw an error here to detect bugs.\n\t\tassert(chunk.subChunks.length > 0, 0x735 /* Unexpected empty sequence */);\n\t\t// Logic in this file is designed to never produce an unneeded (single item) SequenceChunks, so its better to throw an error here to detect bugs.\n\t\tassert(chunk.subChunks.length > 1, 0x736 /* Unexpected single item sequence */);\n\n\t\tfor (const sub of chunk.subChunks) {\n\t\t\t// The logic in this file is designed to never produce an nested SequenceChunks or emptyChunk, so its better to throw an error here to detect bugs.\n\t\t\tassert(!(sub instanceof SequenceChunk), 0x737 /* unexpected nested sequence */);\n\t\t\tassert(sub !== emptyChunk, 0x738 /* unexpected empty chunk */);\n\n\t\t\tsub.referenceAdded();\n\t\t}\n\n\t\tchunk.referenceRemoved();\n\t\treturn chunk.subChunks;\n\t} else {\n\t\treturn [chunk];\n\t}\n}\n\n/**\n * Normalize a {@link TreeChunk}[] into a single TreeChunk.\n *\n * Avoids creating nested or less than 2 child {@link SequenceChunk}s.\n */\nexport function aggregateChunks(input: TreeChunk[]): TreeChunk {\n\tconst chunks = input.flatMap(deaggregateChunks);\n\tswitch (chunks.length) {\n\t\tcase 0:\n\t\t\treturn emptyChunk;\n\t\tcase 1:\n\t\t\treturn chunks[0] ?? oob();\n\t\tdefault:\n\t\t\treturn new SequenceChunk(chunks);\n\t}\n}\n\n/**\n * Decoder for {@link EncodedNestedArray}s.\n */\nexport class NestedArrayDecoder implements ChunkDecoder {\n\tpublic constructor(private readonly shape: EncodedNestedArray) {}\n\tpublic decode(decoders: readonly ChunkDecoder[], stream: StreamCursor): TreeChunk {\n\t\tconst decoder = decoders[this.shape] ?? oob();\n\n\t\t// TODO: uniform chunk fast path\n\t\tconst chunks: TreeChunk[] = [];\n\n\t\tconst data = readStream(stream);\n\t\tif (typeof data === \"number\") {\n\t\t\t// This case means that the array contained only 0-sized items, and was thus encoded as the length of the array.\n\t\t\tconst inner = { data: [], offset: 0 };\n\t\t\tfor (let index = 0; index < data; index++) {\n\t\t\t\tchunks.push(decoder.decode(decoders, inner));\n\t\t\t}\n\t\t} else {\n\t\t\tassert(\n\t\t\t\tArray.isArray(data),\n\t\t\t\t0x739 /* expected number of array for encoding of nested array */,\n\t\t\t);\n\t\t\tconst inner = { data, offset: 0 };\n\t\t\twhile (inner.offset !== inner.data.length) {\n\t\t\t\tchunks.push(decoder.decode(decoders, inner));\n\t\t\t}\n\t\t}\n\n\t\treturn aggregateChunks(chunks);\n\t}\n}\n\n/**\n * Decoder for {@link EncodedInlineArray}s.\n */\nexport class InlineArrayDecoder implements ChunkDecoder {\n\tpublic constructor(private readonly shape: EncodedInlineArray) {}\n\tpublic decode(decoders: readonly ChunkDecoder[], stream: StreamCursor): TreeChunk {\n\t\tconst length = this.shape.length;\n\t\tconst decoder = decoders[this.shape.shape] ?? oob();\n\t\tconst chunks: TreeChunk[] = [];\n\t\tfor (let index = 0; index < length; index++) {\n\t\t\tchunks.push(decoder.decode(decoders, stream));\n\t\t}\n\t\treturn aggregateChunks(chunks);\n\t}\n}\n\n/**\n * Decoder for {@link EncodedAnyShape}s.\n */\nexport const anyDecoder: ChunkDecoder = {\n\tdecode(decoders: readonly ChunkDecoder[], stream: StreamCursor): TreeChunk {\n\t\tconst shapeIndex = readStreamNumber(stream);\n\t\tconst decoder = getChecked(decoders, shapeIndex);\n\t\treturn decoder.decode(decoders, stream);\n\t},\n};\n\n/**\n * Decoder for field.\n */\ntype BasicFieldDecoder = (\n\tdecoders: readonly ChunkDecoder[],\n\tstream: StreamCursor,\n) => [FieldKey, TreeChunk];\n\n/**\n * Get a decoder for fields of a provided (via `shape` and `cache`) {@link EncodedChunkShape}.\n */\nfunction fieldDecoder(\n\tcache: DecoderContext<EncodedChunkShape>,\n\tkey: FieldKey,\n\tshape: number,\n): BasicFieldDecoder {\n\tassertValidIndex(shape, cache.shapes);\n\treturn (decoders, stream) => {\n\t\tconst decoder = decoders[shape] ?? oob();\n\t\treturn [key, decoder.decode(decoders, stream)];\n\t};\n}\n\n/**\n * Decoder for {@link EncodedTreeShape}s.\n */\nexport class TreeDecoder implements ChunkDecoder {\n\tprivate readonly type?: TreeNodeSchemaIdentifier;\n\tprivate readonly fieldDecoders: readonly BasicFieldDecoder[];\n\tpublic constructor(\n\t\tprivate readonly shape: EncodedTreeShape,\n\t\tprivate readonly cache: DecoderContext<EncodedChunkShape>,\n\t) {\n\t\tthis.type = shape.type === undefined ? undefined : cache.identifier(shape.type);\n\n\t\tconst fieldDecoders: BasicFieldDecoder[] = [];\n\t\tfor (const [fieldKey, fieldShape] of shape.fields ?? []) {\n\t\t\tconst key: FieldKey = cache.identifier(fieldKey);\n\t\t\tfieldDecoders.push(fieldDecoder(cache, key, fieldShape));\n\t\t}\n\t\tthis.fieldDecoders = fieldDecoders;\n\t}\n\tpublic decode(decoders: readonly ChunkDecoder[], stream: StreamCursor): TreeChunk {\n\t\tconst type: TreeNodeSchemaIdentifier =\n\t\t\tthis.type ?? readStreamIdentifier(stream, this.cache);\n\t\t// TODO: Consider typechecking against stored schema in here somewhere.\n\n\t\tconst value = readValue(stream, this.shape.value, this.cache.idDecodingContext);\n\t\tconst fields: Map<FieldKey, TreeChunk[]> = new Map();\n\n\t\t// Helper to add fields, but with unneeded array chunks removed.\n\t\tfunction addField(key: FieldKey, data: TreeChunk): void {\n\t\t\t// TODO: when handling of ArrayChunks has better performance (for example in cursors),\n\t\t\t// consider keeping array chunks here if they are longer than some threshold.\n\t\t\tconst chunks = deaggregateChunks(data);\n\n\t\t\tif (chunks.length !== 0) {\n\t\t\t\tfields.set(key, chunks);\n\t\t\t}\n\t\t}\n\n\t\tfor (const field of this.fieldDecoders) {\n\t\t\tconst [key, content] = field(decoders, stream);\n\t\t\taddField(key, content);\n\t\t}\n\n\t\tif (this.shape.extraFields !== undefined) {\n\t\t\tconst decoder = decoders[this.shape.extraFields] ?? oob();\n\t\t\tconst inner = readStreamStream(stream);\n\t\t\twhile (inner.offset !== inner.data.length) {\n\t\t\t\tconst key: FieldKey = readStreamIdentifier(inner, this.cache);\n\t\t\t\taddField(key, decoder.decode(decoders, inner));\n\t\t\t}\n\t\t}\n\n\t\treturn new BasicChunk(type, fields, value);\n\t}\n}\n"]}
1
+ {"version":3,"file":"chunkDecoding.js","sourceRoot":"","sources":["../../../../src/feature-libraries/chunked-forest/codec/chunkDecoding.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAAmF;AAOnF,sDAAuE;AAOvE,qDAA0D;AAC1D,oDAA8C;AAC9C,oDAA8C;AAC9C,0DAAoD;AAEpD,qEASkC;AAClC,uEAImC;AACnC,2CASqB;AASrB;;GAEG;AACH,SAAgB,MAAM,CACrB,KAAwB,EACxB,iBAA2E;IAE3E,OAAO,IAAA,gCAAa,EACnB,cAAc,EACd,IAAI,wCAAc,CAAC,KAAK,CAAC,WAAW,EAAE,KAAK,CAAC,MAAM,EAAE,iBAAiB,CAAC,EACtE,KAAK,EACL,kBAAU,CACV,CAAC;AACH,CAAC;AAVD,wBAUC;AAED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CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC,CAAC;YAChD,CAAC;QACF,CAAC;QAED,OAAO,IAAI,0BAAU,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC;IAC5C,CAAC;CACD;AAnDD,kCAmDC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, unreachableCase, oob } from \"@fluidframework/core-utils/internal\";\nimport type {\n\tIIdCompressor,\n\tOpSpaceCompressedId,\n\tSessionId,\n} from \"@fluidframework/id-compressor\";\n\nimport { DiscriminatedUnionDispatcher } from \"../../../codec/index.js\";\nimport type {\n\tFieldKey,\n\tTreeNodeSchemaIdentifier,\n\tValue,\n\tTreeChunk,\n} from \"../../../core/index.js\";\nimport { assertValidIndex } from \"../../../util/index.js\";\nimport { BasicChunk } from \"../basicChunk.js\";\nimport { emptyChunk } from \"../emptyChunk.js\";\nimport { SequenceChunk } from \"../sequenceChunk.js\";\n\nimport {\n\ttype ChunkDecoder,\n\ttype StreamCursor,\n\tgetChecked,\n\treadStream,\n\treadStreamBoolean,\n\treadStreamNumber,\n\treadStreamStream,\n\treadStreamValue,\n} from \"./chunkCodecUtilities.js\";\nimport {\n\tDecoderContext,\n\tdecode as genericDecode,\n\treadStreamIdentifier,\n} from \"./chunkDecodingGeneric.js\";\nimport {\n\ttype EncodedAnyShape,\n\ttype EncodedChunkShape,\n\ttype EncodedFieldBatch,\n\ttype EncodedInlineArrayShape,\n\ttype EncodedNestedArrayShape,\n\ttype EncodedNodeShape,\n\ttype EncodedValueShape,\n\tSpecialField,\n} from \"./format.js\";\n\nexport interface IdDecodingContext {\n\tidCompressor: IIdCompressor;\n\t/**\n\t * The creator of any local Ids to be decoded.\n\t */\n\toriginatorId: SessionId;\n}\n/**\n * Decode `chunk` into a TreeChunk.\n */\nexport function decode(\n\tchunk: EncodedFieldBatch,\n\tidDecodingContext: { idCompressor: IIdCompressor; originatorId: SessionId },\n): TreeChunk[] {\n\treturn genericDecode(\n\t\tdecoderLibrary,\n\t\tnew DecoderContext(chunk.identifiers, chunk.shapes, idDecodingContext),\n\t\tchunk,\n\t\tanyDecoder,\n\t);\n}\n\nconst decoderLibrary = new DiscriminatedUnionDispatcher<\n\tEncodedChunkShape,\n\t[context: DecoderContext<EncodedChunkShape>],\n\tChunkDecoder\n>({\n\ta(shape: EncodedNestedArrayShape, context): ChunkDecoder {\n\t\treturn new NestedArrayDecoder(shape);\n\t},\n\tb(shape: EncodedInlineArrayShape, context): ChunkDecoder {\n\t\treturn new InlineArrayDecoder(shape);\n\t},\n\tc(shape: EncodedNodeShape, context): ChunkDecoder {\n\t\treturn new NodeDecoder(shape, context);\n\t},\n\td(shape: EncodedAnyShape): ChunkDecoder {\n\t\treturn anyDecoder;\n\t},\n});\n\n/**\n * Decode a node's value from `stream` using its shape.\n */\nexport function readValue(\n\tstream: StreamCursor,\n\tshape: EncodedValueShape,\n\tidDecodingContext: IdDecodingContext,\n): Value {\n\tif (shape === undefined) {\n\t\treturn readStreamBoolean(stream) ? readStreamValue(stream) : undefined;\n\t} else {\n\t\tif (shape === true) {\n\t\t\treturn readStreamValue(stream);\n\t\t} else if (shape === false) {\n\t\t\treturn undefined;\n\t\t} else if (Array.isArray(shape)) {\n\t\t\tassert(shape.length === 1, 0x734 /* expected a single constant for value */);\n\t\t\treturn shape[0] as Value;\n\t\t} else if (shape === SpecialField.Identifier) {\n\t\t\t// This case is a special case handling the decoding of identifier fields.\n\t\t\tconst streamValue = readStream(stream);\n\t\t\tassert(\n\t\t\t\ttypeof streamValue === \"number\" || typeof streamValue === \"string\",\n\t\t\t\t0x997 /* identifier must be string or number. */,\n\t\t\t);\n\t\t\tconst idCompressor = idDecodingContext.idCompressor;\n\t\t\treturn typeof streamValue === \"number\"\n\t\t\t\t? idCompressor.decompress(\n\t\t\t\t\t\tidCompressor.normalizeToSessionSpace(\n\t\t\t\t\t\t\tstreamValue as OpSpaceCompressedId,\n\t\t\t\t\t\t\tidDecodingContext.originatorId,\n\t\t\t\t\t\t),\n\t\t\t\t\t)\n\t\t\t\t: streamValue;\n\t\t} else {\n\t\t\t// EncodedCounter case:\n\t\t\tunreachableCase(shape, \"decoding values as deltas is not yet supported\");\n\t\t}\n\t}\n}\n\n/**\n * Normalize a {@link TreeChunk} into an array.\n *\n * Unwraps {@link SequenceChunk}s, and wraps other chunks.\n */\nexport function deaggregateChunks(chunk: TreeChunk): TreeChunk[] {\n\tif (chunk === emptyChunk) {\n\t\treturn [];\n\t}\n\t// TODO: when handling of SequenceChunks has better performance (for example in cursors),\n\t// consider keeping SequenceChunks here if they are longer than some threshold.\n\tif (chunk instanceof SequenceChunk) {\n\t\t// Could return [] here, however the logic in this file is designed to never produce an empty SequenceChunk, so its better to throw an error here to detect bugs.\n\t\tassert(chunk.subChunks.length > 0, 0x735 /* Unexpected empty sequence */);\n\t\t// Logic in this file is designed to never produce an unneeded (single item) SequenceChunks, so its better to throw an error here to detect bugs.\n\t\tassert(chunk.subChunks.length > 1, 0x736 /* Unexpected single item sequence */);\n\n\t\tfor (const sub of chunk.subChunks) {\n\t\t\t// The logic in this file is designed to never produce an nested SequenceChunks or emptyChunk, so its better to throw an error here to detect bugs.\n\t\t\tassert(!(sub instanceof SequenceChunk), 0x737 /* unexpected nested sequence */);\n\t\t\tassert(sub !== emptyChunk, 0x738 /* unexpected empty chunk */);\n\n\t\t\tsub.referenceAdded();\n\t\t}\n\n\t\tchunk.referenceRemoved();\n\t\treturn chunk.subChunks;\n\t} else {\n\t\treturn [chunk];\n\t}\n}\n\n/**\n * Normalize a {@link TreeChunk}[] into a single TreeChunk.\n *\n * Avoids creating nested or less than 2 child {@link SequenceChunk}s.\n */\nexport function aggregateChunks(input: TreeChunk[]): TreeChunk {\n\tconst chunks = input.flatMap(deaggregateChunks);\n\tswitch (chunks.length) {\n\t\tcase 0:\n\t\t\treturn emptyChunk;\n\t\tcase 1:\n\t\t\treturn chunks[0] ?? oob();\n\t\tdefault:\n\t\t\treturn new SequenceChunk(chunks);\n\t}\n}\n\n/**\n * Decoder for {@link EncodedNestedArrayShape}s.\n */\nexport class NestedArrayDecoder implements ChunkDecoder {\n\tpublic constructor(private readonly shape: EncodedNestedArrayShape) {}\n\tpublic decode(decoders: readonly ChunkDecoder[], stream: StreamCursor): TreeChunk {\n\t\tconst decoder = decoders[this.shape] ?? oob();\n\n\t\t// TODO: uniform chunk fast path\n\t\tconst chunks: TreeChunk[] = [];\n\n\t\tconst data = readStream(stream);\n\t\tif (typeof data === \"number\") {\n\t\t\t// This case means that the array contained only 0-sized items, and was thus encoded as the length of the array.\n\t\t\tconst inner = { data: [], offset: 0 };\n\t\t\tfor (let index = 0; index < data; index++) {\n\t\t\t\tchunks.push(decoder.decode(decoders, inner));\n\t\t\t}\n\t\t} else {\n\t\t\tassert(\n\t\t\t\tArray.isArray(data),\n\t\t\t\t0x739 /* expected number of array for encoding of nested array */,\n\t\t\t);\n\t\t\tconst inner = { data, offset: 0 };\n\t\t\twhile (inner.offset !== inner.data.length) {\n\t\t\t\tchunks.push(decoder.decode(decoders, inner));\n\t\t\t}\n\t\t}\n\n\t\treturn aggregateChunks(chunks);\n\t}\n}\n\n/**\n * Decoder for {@link EncodedInlineArrayShape}s.\n */\nexport class InlineArrayDecoder implements ChunkDecoder {\n\tpublic constructor(private readonly shape: EncodedInlineArrayShape) {}\n\tpublic decode(decoders: readonly ChunkDecoder[], stream: StreamCursor): TreeChunk {\n\t\tconst length = this.shape.length;\n\t\tconst decoder = decoders[this.shape.shape] ?? oob();\n\t\tconst chunks: TreeChunk[] = [];\n\t\tfor (let index = 0; index < length; index++) {\n\t\t\tchunks.push(decoder.decode(decoders, stream));\n\t\t}\n\t\treturn aggregateChunks(chunks);\n\t}\n}\n\n/**\n * Decoder for {@link EncodedAnyShape}s.\n */\nexport const anyDecoder: ChunkDecoder = {\n\tdecode(decoders: readonly ChunkDecoder[], stream: StreamCursor): TreeChunk {\n\t\tconst shapeIndex = readStreamNumber(stream);\n\t\tconst decoder = getChecked(decoders, shapeIndex);\n\t\treturn decoder.decode(decoders, stream);\n\t},\n};\n\n/**\n * Decoder for field.\n */\ntype BasicFieldDecoder = (\n\tdecoders: readonly ChunkDecoder[],\n\tstream: StreamCursor,\n) => [FieldKey, TreeChunk];\n\n/**\n * Get a decoder for fields of a provided (via `shape` and `context`) {@link EncodedChunkShape}.\n */\nfunction fieldDecoder(\n\tcontext: DecoderContext<EncodedChunkShape>,\n\tkey: FieldKey,\n\tshape: number,\n): BasicFieldDecoder {\n\tassertValidIndex(shape, context.shapes);\n\treturn (decoders, stream) => {\n\t\tconst decoder = decoders[shape] ?? oob();\n\t\treturn [key, decoder.decode(decoders, stream)];\n\t};\n}\n\n/**\n * Decoder for {@link EncodedNodeShape}s.\n */\nexport class NodeDecoder implements ChunkDecoder {\n\tprivate readonly type?: TreeNodeSchemaIdentifier;\n\tprivate readonly fieldDecoders: readonly BasicFieldDecoder[];\n\tpublic constructor(\n\t\tprivate readonly shape: EncodedNodeShape,\n\t\tprivate readonly context: DecoderContext<EncodedChunkShape>,\n\t) {\n\t\tthis.type = shape.type === undefined ? undefined : context.identifier(shape.type);\n\n\t\tconst fieldDecoders: BasicFieldDecoder[] = [];\n\t\tfor (const [fieldKey, fieldShape] of shape.fields ?? []) {\n\t\t\tconst key: FieldKey = context.identifier(fieldKey);\n\t\t\tfieldDecoders.push(fieldDecoder(context, key, fieldShape));\n\t\t}\n\t\tthis.fieldDecoders = fieldDecoders;\n\t}\n\tpublic decode(decoders: readonly ChunkDecoder[], stream: StreamCursor): TreeChunk {\n\t\tconst type: TreeNodeSchemaIdentifier =\n\t\t\tthis.type ?? readStreamIdentifier(stream, this.context);\n\t\t// TODO: Consider typechecking against stored schema in here somewhere.\n\n\t\tconst value = readValue(stream, this.shape.value, this.context.idDecodingContext);\n\t\tconst fields: Map<FieldKey, TreeChunk[]> = new Map();\n\n\t\t// Helper to add fields, but with unneeded array chunks removed.\n\t\tfunction addField(key: FieldKey, data: TreeChunk): void {\n\t\t\t// TODO: when handling of ArrayChunks has better performance (for example in cursors),\n\t\t\t// consider keeping array chunks here if they are longer than some threshold.\n\t\t\tconst chunks = deaggregateChunks(data);\n\n\t\t\tif (chunks.length !== 0) {\n\t\t\t\tfields.set(key, chunks);\n\t\t\t}\n\t\t}\n\n\t\tfor (const field of this.fieldDecoders) {\n\t\t\tconst [key, content] = field(decoders, stream);\n\t\t\taddField(key, content);\n\t\t}\n\n\t\tif (this.shape.extraFields !== undefined) {\n\t\t\tconst decoder = decoders[this.shape.extraFields] ?? oob();\n\t\t\tconst inner = readStreamStream(stream);\n\t\t\twhile (inner.offset !== inner.data.length) {\n\t\t\t\tconst key: FieldKey = readStreamIdentifier(inner, this.context);\n\t\t\t\taddField(key, decoder.decode(decoders, inner));\n\t\t\t}\n\t\t}\n\n\t\treturn new BasicChunk(type, fields, value);\n\t}\n}\n"]}