@fluidframework/tree 2.30.0 → 2.31.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (660) hide show
  1. package/CHANGELOG.md +1632 -1500
  2. package/api-extractor/api-extractor.current.json +0 -3
  3. package/api-report/tree.alpha.api.md +233 -88
  4. package/api-report/tree.beta.api.md +86 -61
  5. package/api-report/tree.legacy.alpha.api.md +86 -61
  6. package/api-report/tree.legacy.public.api.md +86 -61
  7. package/api-report/tree.public.api.md +86 -61
  8. package/dist/alpha.d.ts +26 -1
  9. package/dist/beta.d.ts +5 -1
  10. package/dist/codec/codec.d.ts +1 -1
  11. package/dist/codec/codec.d.ts.map +1 -1
  12. package/dist/codec/codec.js +3 -4
  13. package/dist/codec/codec.js.map +1 -1
  14. package/dist/codec/discriminatedUnions.d.ts.map +1 -1
  15. package/dist/codec/discriminatedUnions.js +1 -1
  16. package/dist/codec/discriminatedUnions.js.map +1 -1
  17. package/dist/core/rebase/utils.js +1 -1
  18. package/dist/core/rebase/utils.js.map +1 -1
  19. package/dist/core/schema-stored/schema.d.ts +4 -1
  20. package/dist/core/schema-stored/schema.d.ts.map +1 -1
  21. package/dist/core/schema-stored/schema.js +8 -4
  22. package/dist/core/schema-stored/schema.js.map +1 -1
  23. package/dist/core/tree/anchorSet.d.ts.map +1 -1
  24. package/dist/core/tree/anchorSet.js +4 -4
  25. package/dist/core/tree/anchorSet.js.map +1 -1
  26. package/dist/core/tree/treeTextFormat.js +2 -2
  27. package/dist/core/tree/treeTextFormat.js.map +1 -1
  28. package/dist/feature-libraries/chunked-forest/basicChunk.d.ts.map +1 -1
  29. package/dist/feature-libraries/chunked-forest/basicChunk.js +8 -8
  30. package/dist/feature-libraries/chunked-forest/basicChunk.js.map +1 -1
  31. package/dist/feature-libraries/chunked-forest/chunkTree.js +2 -2
  32. package/dist/feature-libraries/chunked-forest/chunkTree.js.map +1 -1
  33. package/dist/feature-libraries/chunked-forest/chunkedForest.d.ts.map +1 -1
  34. package/dist/feature-libraries/chunked-forest/chunkedForest.js +3 -3
  35. package/dist/feature-libraries/chunked-forest/chunkedForest.js.map +1 -1
  36. package/dist/feature-libraries/chunked-forest/codec/chunkEncodingGeneric.js +3 -3
  37. package/dist/feature-libraries/chunked-forest/codec/chunkEncodingGeneric.js.map +1 -1
  38. package/dist/feature-libraries/chunked-forest/codec/compressedEncode.js +3 -3
  39. package/dist/feature-libraries/chunked-forest/codec/compressedEncode.js.map +1 -1
  40. package/dist/feature-libraries/chunked-forest/codec/nodeShape.js +2 -2
  41. package/dist/feature-libraries/chunked-forest/codec/nodeShape.js.map +1 -1
  42. package/dist/feature-libraries/chunked-forest/codec/schemaBasedEncode.d.ts.map +1 -1
  43. package/dist/feature-libraries/chunked-forest/codec/schemaBasedEncode.js +3 -4
  44. package/dist/feature-libraries/chunked-forest/codec/schemaBasedEncode.js.map +1 -1
  45. package/dist/feature-libraries/chunked-forest/emptyChunk.d.ts.map +1 -1
  46. package/dist/feature-libraries/chunked-forest/emptyChunk.js +15 -15
  47. package/dist/feature-libraries/chunked-forest/emptyChunk.js.map +1 -1
  48. package/dist/feature-libraries/chunked-forest/uniformChunk.d.ts.map +1 -1
  49. package/dist/feature-libraries/chunked-forest/uniformChunk.js +4 -4
  50. package/dist/feature-libraries/chunked-forest/uniformChunk.js.map +1 -1
  51. package/dist/feature-libraries/default-schema/defaultFieldKinds.d.ts.map +1 -1
  52. package/dist/feature-libraries/default-schema/defaultFieldKinds.js +19 -19
  53. package/dist/feature-libraries/default-schema/defaultFieldKinds.js.map +1 -1
  54. package/dist/feature-libraries/default-schema/schemaChecker.d.ts.map +1 -1
  55. package/dist/feature-libraries/default-schema/schemaChecker.js +1 -2
  56. package/dist/feature-libraries/default-schema/schemaChecker.js.map +1 -1
  57. package/dist/feature-libraries/flex-tree/lazyField.js +3 -3
  58. package/dist/feature-libraries/flex-tree/lazyField.js.map +1 -1
  59. package/dist/feature-libraries/flex-tree/lazyNode.js +4 -4
  60. package/dist/feature-libraries/flex-tree/lazyNode.js.map +1 -1
  61. package/dist/feature-libraries/indexing/anchorTreeIndex.d.ts.map +1 -1
  62. package/dist/feature-libraries/indexing/anchorTreeIndex.js +1 -1
  63. package/dist/feature-libraries/indexing/anchorTreeIndex.js.map +1 -1
  64. package/dist/feature-libraries/modular-schema/comparison.js +4 -4
  65. package/dist/feature-libraries/modular-schema/comparison.js.map +1 -1
  66. package/dist/feature-libraries/modular-schema/isNeverTree.d.ts.map +1 -1
  67. package/dist/feature-libraries/modular-schema/isNeverTree.js +2 -3
  68. package/dist/feature-libraries/modular-schema/isNeverTree.js.map +1 -1
  69. package/dist/feature-libraries/modular-schema/modularChangeCodecs.d.ts.map +1 -1
  70. package/dist/feature-libraries/modular-schema/modularChangeCodecs.js +4 -4
  71. package/dist/feature-libraries/modular-schema/modularChangeCodecs.js.map +1 -1
  72. package/dist/feature-libraries/modular-schema/modularChangeFamily.d.ts.map +1 -1
  73. package/dist/feature-libraries/modular-schema/modularChangeFamily.js +4 -4
  74. package/dist/feature-libraries/modular-schema/modularChangeFamily.js.map +1 -1
  75. package/dist/feature-libraries/node-identifier/mockNodeIdentifierManager.js +1 -1
  76. package/dist/feature-libraries/node-identifier/mockNodeIdentifierManager.js.map +1 -1
  77. package/dist/feature-libraries/object-forest/objectForest.d.ts.map +1 -1
  78. package/dist/feature-libraries/object-forest/objectForest.js +1 -1
  79. package/dist/feature-libraries/object-forest/objectForest.js.map +1 -1
  80. package/dist/feature-libraries/schema-index/codec.d.ts.map +1 -1
  81. package/dist/feature-libraries/schema-index/codec.js +2 -1
  82. package/dist/feature-libraries/schema-index/codec.js.map +1 -1
  83. package/dist/feature-libraries/sequence-field/compose.d.ts +1 -1
  84. package/dist/feature-libraries/sequence-field/compose.d.ts.map +1 -1
  85. package/dist/feature-libraries/sequence-field/compose.js +16 -17
  86. package/dist/feature-libraries/sequence-field/compose.js.map +1 -1
  87. package/dist/feature-libraries/sequence-field/invert.d.ts.map +1 -1
  88. package/dist/feature-libraries/sequence-field/invert.js +1 -1
  89. package/dist/feature-libraries/sequence-field/invert.js.map +1 -1
  90. package/dist/feature-libraries/sequence-field/sequenceFieldCodecV1.d.ts.map +1 -1
  91. package/dist/feature-libraries/sequence-field/sequenceFieldCodecV1.js +1 -1
  92. package/dist/feature-libraries/sequence-field/sequenceFieldCodecV1.js.map +1 -1
  93. package/dist/feature-libraries/sequence-field/sequenceFieldCodecV2.d.ts.map +1 -1
  94. package/dist/feature-libraries/sequence-field/sequenceFieldCodecV2.js +1 -1
  95. package/dist/feature-libraries/sequence-field/sequenceFieldCodecV2.js.map +1 -1
  96. package/dist/feature-libraries/sequence-field/utils.js +1 -1
  97. package/dist/feature-libraries/sequence-field/utils.js.map +1 -1
  98. package/dist/feature-libraries/treeCursorUtils.d.ts.map +1 -1
  99. package/dist/feature-libraries/treeCursorUtils.js +4 -5
  100. package/dist/feature-libraries/treeCursorUtils.js.map +1 -1
  101. package/dist/index.d.ts +4 -3
  102. package/dist/index.d.ts.map +1 -1
  103. package/dist/index.js +8 -4
  104. package/dist/index.js.map +1 -1
  105. package/dist/jsonDomainSchema.d.ts +15 -16
  106. package/dist/jsonDomainSchema.d.ts.map +1 -1
  107. package/dist/jsonDomainSchema.js +10 -5
  108. package/dist/jsonDomainSchema.js.map +1 -1
  109. package/dist/legacy.d.ts +5 -1
  110. package/dist/packageVersion.d.ts +1 -1
  111. package/dist/packageVersion.js +1 -1
  112. package/dist/packageVersion.js.map +1 -1
  113. package/dist/public.d.ts +5 -1
  114. package/dist/serializableDomainSchema.d.ts +8 -14
  115. package/dist/serializableDomainSchema.d.ts.map +1 -1
  116. package/dist/shared-tree/schematizeTree.js +1 -1
  117. package/dist/shared-tree/schematizeTree.js.map +1 -1
  118. package/dist/shared-tree/sharedTree.d.ts.map +1 -1
  119. package/dist/shared-tree/sharedTree.js +16 -12
  120. package/dist/shared-tree/sharedTree.js.map +1 -1
  121. package/dist/shared-tree/sharedTreeChangeFamily.d.ts.map +1 -1
  122. package/dist/shared-tree/sharedTreeChangeFamily.js +1 -1
  123. package/dist/shared-tree/sharedTreeChangeFamily.js.map +1 -1
  124. package/dist/shared-tree/treeApiAlpha.d.ts +6 -2
  125. package/dist/shared-tree/treeApiAlpha.d.ts.map +1 -1
  126. package/dist/shared-tree/treeApiAlpha.js +20 -17
  127. package/dist/shared-tree/treeApiAlpha.js.map +1 -1
  128. package/dist/shared-tree/treeCheckout.d.ts.map +1 -1
  129. package/dist/shared-tree/treeCheckout.js +1 -1
  130. package/dist/shared-tree/treeCheckout.js.map +1 -1
  131. package/dist/shared-tree-core/branch.d.ts +4 -3
  132. package/dist/shared-tree-core/branch.d.ts.map +1 -1
  133. package/dist/shared-tree-core/branch.js +2 -2
  134. package/dist/shared-tree-core/branch.js.map +1 -1
  135. package/dist/shared-tree-core/editManager.d.ts.map +1 -1
  136. package/dist/shared-tree-core/editManager.js +37 -31
  137. package/dist/shared-tree-core/editManager.js.map +1 -1
  138. package/dist/sharedTreeAttributes.d.ts +18 -0
  139. package/dist/sharedTreeAttributes.d.ts.map +1 -0
  140. package/dist/sharedTreeAttributes.js +25 -0
  141. package/dist/sharedTreeAttributes.js.map +1 -0
  142. package/dist/simple-tree/api/customTree.js +3 -3
  143. package/dist/simple-tree/api/customTree.js.map +1 -1
  144. package/dist/simple-tree/api/getJsonSchema.d.ts +10 -0
  145. package/dist/simple-tree/api/getJsonSchema.d.ts.map +1 -1
  146. package/dist/simple-tree/api/getJsonSchema.js +10 -0
  147. package/dist/simple-tree/api/getJsonSchema.js.map +1 -1
  148. package/dist/simple-tree/api/getSimpleSchema.d.ts +13 -43
  149. package/dist/simple-tree/api/getSimpleSchema.d.ts.map +1 -1
  150. package/dist/simple-tree/api/getSimpleSchema.js +13 -43
  151. package/dist/simple-tree/api/getSimpleSchema.js.map +1 -1
  152. package/dist/simple-tree/api/index.d.ts +3 -3
  153. package/dist/simple-tree/api/index.d.ts.map +1 -1
  154. package/dist/simple-tree/api/index.js +3 -1
  155. package/dist/simple-tree/api/index.js.map +1 -1
  156. package/dist/simple-tree/api/schemaCreationUtilities.d.ts.map +1 -1
  157. package/dist/simple-tree/api/schemaCreationUtilities.js +2 -2
  158. package/dist/simple-tree/api/schemaCreationUtilities.js.map +1 -1
  159. package/dist/simple-tree/api/schemaFactory.d.ts +100 -58
  160. package/dist/simple-tree/api/schemaFactory.d.ts.map +1 -1
  161. package/dist/simple-tree/api/schemaFactory.js +65 -133
  162. package/dist/simple-tree/api/schemaFactory.js.map +1 -1
  163. package/dist/simple-tree/api/schemaFactoryAlpha.d.ts +31 -23
  164. package/dist/simple-tree/api/schemaFactoryAlpha.d.ts.map +1 -1
  165. package/dist/simple-tree/api/schemaFactoryAlpha.js +17 -1
  166. package/dist/simple-tree/api/schemaFactoryAlpha.js.map +1 -1
  167. package/dist/simple-tree/api/schemaFactoryRecursive.d.ts +40 -5
  168. package/dist/simple-tree/api/schemaFactoryRecursive.d.ts.map +1 -1
  169. package/dist/simple-tree/api/schemaFactoryRecursive.js.map +1 -1
  170. package/dist/simple-tree/api/schemaFromSimple.d.ts +4 -4
  171. package/dist/simple-tree/api/schemaFromSimple.d.ts.map +1 -1
  172. package/dist/simple-tree/api/schemaFromSimple.js +26 -15
  173. package/dist/simple-tree/api/schemaFromSimple.js.map +1 -1
  174. package/dist/simple-tree/api/simpleSchemaToJsonSchema.d.ts +3 -2
  175. package/dist/simple-tree/api/simpleSchemaToJsonSchema.d.ts.map +1 -1
  176. package/dist/simple-tree/api/simpleSchemaToJsonSchema.js +7 -6
  177. package/dist/simple-tree/api/simpleSchemaToJsonSchema.js.map +1 -1
  178. package/dist/simple-tree/api/simpleTreeIndex.d.ts.map +1 -1
  179. package/dist/simple-tree/api/simpleTreeIndex.js +4 -3
  180. package/dist/simple-tree/api/simpleTreeIndex.js.map +1 -1
  181. package/dist/simple-tree/api/testRecursiveDomain.d.ts +10 -10
  182. package/dist/simple-tree/api/tree.d.ts +1 -1
  183. package/dist/simple-tree/api/tree.d.ts.map +1 -1
  184. package/dist/simple-tree/api/tree.js +6 -6
  185. package/dist/simple-tree/api/tree.js.map +1 -1
  186. package/dist/simple-tree/api/treeNodeApi.js +3 -3
  187. package/dist/simple-tree/api/treeNodeApi.js.map +1 -1
  188. package/dist/simple-tree/api/typesUnsafe.d.ts +87 -21
  189. package/dist/simple-tree/api/typesUnsafe.d.ts.map +1 -1
  190. package/dist/simple-tree/api/typesUnsafe.js +0 -1
  191. package/dist/simple-tree/api/typesUnsafe.js.map +1 -1
  192. package/dist/simple-tree/api/verboseTree.js +4 -4
  193. package/dist/simple-tree/api/verboseTree.js.map +1 -1
  194. package/dist/simple-tree/api/view.d.ts.map +1 -1
  195. package/dist/simple-tree/api/view.js +16 -17
  196. package/dist/simple-tree/api/view.js.map +1 -1
  197. package/dist/simple-tree/api/viewSchemaToSimpleSchema.d.ts +16 -3
  198. package/dist/simple-tree/api/viewSchemaToSimpleSchema.d.ts.map +1 -1
  199. package/dist/simple-tree/api/viewSchemaToSimpleSchema.js +70 -147
  200. package/dist/simple-tree/api/viewSchemaToSimpleSchema.js.map +1 -1
  201. package/dist/simple-tree/arrayNode.d.ts +5 -4
  202. package/dist/simple-tree/arrayNode.d.ts.map +1 -1
  203. package/dist/simple-tree/arrayNode.js +13 -9
  204. package/dist/simple-tree/arrayNode.js.map +1 -1
  205. package/dist/simple-tree/arrayNodeTypes.d.ts +46 -0
  206. package/dist/simple-tree/arrayNodeTypes.d.ts.map +1 -0
  207. package/dist/simple-tree/arrayNodeTypes.js +30 -0
  208. package/dist/simple-tree/arrayNodeTypes.js.map +1 -0
  209. package/dist/simple-tree/core/getOrCreateNode.d.ts.map +1 -1
  210. package/dist/simple-tree/core/getOrCreateNode.js +1 -11
  211. package/dist/simple-tree/core/getOrCreateNode.js.map +1 -1
  212. package/dist/simple-tree/core/index.d.ts +1 -2
  213. package/dist/simple-tree/core/index.d.ts.map +1 -1
  214. package/dist/simple-tree/core/index.js +2 -3
  215. package/dist/simple-tree/core/index.js.map +1 -1
  216. package/dist/simple-tree/core/treeNodeKernel.d.ts +12 -5
  217. package/dist/simple-tree/core/treeNodeKernel.d.ts.map +1 -1
  218. package/dist/simple-tree/core/treeNodeKernel.js +36 -20
  219. package/dist/simple-tree/core/treeNodeKernel.js.map +1 -1
  220. package/dist/simple-tree/core/treeNodeSchema.d.ts +14 -7
  221. package/dist/simple-tree/core/treeNodeSchema.d.ts.map +1 -1
  222. package/dist/simple-tree/core/treeNodeSchema.js.map +1 -1
  223. package/dist/simple-tree/core/unhydratedFlexTree.js +5 -5
  224. package/dist/simple-tree/core/unhydratedFlexTree.js.map +1 -1
  225. package/dist/simple-tree/index.d.ts +9 -2
  226. package/dist/simple-tree/index.d.ts.map +1 -1
  227. package/dist/simple-tree/index.js +9 -1
  228. package/dist/simple-tree/index.js.map +1 -1
  229. package/dist/simple-tree/leafNodeSchema.d.ts +22 -5
  230. package/dist/simple-tree/leafNodeSchema.d.ts.map +1 -1
  231. package/dist/simple-tree/leafNodeSchema.js +2 -0
  232. package/dist/simple-tree/leafNodeSchema.js.map +1 -1
  233. package/dist/simple-tree/mapNode.d.ts +3 -2
  234. package/dist/simple-tree/mapNode.d.ts.map +1 -1
  235. package/dist/simple-tree/mapNode.js +5 -1
  236. package/dist/simple-tree/mapNode.js.map +1 -1
  237. package/dist/simple-tree/mapNodeTypes.d.ts +46 -0
  238. package/dist/simple-tree/mapNodeTypes.d.ts.map +1 -0
  239. package/dist/simple-tree/mapNodeTypes.js +30 -0
  240. package/dist/simple-tree/mapNodeTypes.js.map +1 -0
  241. package/dist/simple-tree/objectNode.d.ts +10 -3
  242. package/dist/simple-tree/objectNode.d.ts.map +1 -1
  243. package/dist/simple-tree/objectNode.js +10 -5
  244. package/dist/simple-tree/objectNode.js.map +1 -1
  245. package/dist/simple-tree/objectNodeTypes.d.ts +9 -5
  246. package/dist/simple-tree/objectNodeTypes.d.ts.map +1 -1
  247. package/dist/simple-tree/objectNodeTypes.js +3 -0
  248. package/dist/simple-tree/objectNodeTypes.js.map +1 -1
  249. package/dist/simple-tree/proxies.js +2 -1
  250. package/dist/simple-tree/proxies.js.map +1 -1
  251. package/dist/simple-tree/schemaTypes.d.ts +47 -6
  252. package/dist/simple-tree/schemaTypes.d.ts.map +1 -1
  253. package/dist/simple-tree/schemaTypes.js +40 -4
  254. package/dist/simple-tree/schemaTypes.js.map +1 -1
  255. package/dist/simple-tree/{api/simpleSchema.d.ts → simpleSchema.d.ts} +54 -30
  256. package/dist/simple-tree/simpleSchema.d.ts.map +1 -0
  257. package/dist/simple-tree/simpleSchema.js.map +1 -0
  258. package/dist/simple-tree/toMapTree.js +3 -3
  259. package/dist/simple-tree/toMapTree.js.map +1 -1
  260. package/dist/simple-tree/toStoredSchema.js +1 -1
  261. package/dist/simple-tree/toStoredSchema.js.map +1 -1
  262. package/dist/simple-tree/treeNodeValid.d.ts.map +1 -1
  263. package/dist/simple-tree/treeNodeValid.js +4 -5
  264. package/dist/simple-tree/treeNodeValid.js.map +1 -1
  265. package/dist/treeFactory.d.ts +0 -12
  266. package/dist/treeFactory.d.ts.map +1 -1
  267. package/dist/treeFactory.js +5 -21
  268. package/dist/treeFactory.js.map +1 -1
  269. package/dist/util/idAllocator.d.ts.map +1 -1
  270. package/dist/util/idAllocator.js +1 -2
  271. package/dist/util/idAllocator.js.map +1 -1
  272. package/dist/util/index.d.ts +1 -1
  273. package/dist/util/index.d.ts.map +1 -1
  274. package/dist/util/index.js +2 -3
  275. package/dist/util/index.js.map +1 -1
  276. package/dist/util/typeCheck.d.ts +7 -0
  277. package/dist/util/typeCheck.d.ts.map +1 -1
  278. package/dist/util/typeCheck.js.map +1 -1
  279. package/dist/util/utils.d.ts +0 -1
  280. package/dist/util/utils.d.ts.map +1 -1
  281. package/dist/util/utils.js +1 -4
  282. package/dist/util/utils.js.map +1 -1
  283. package/lib/alpha.d.ts +26 -1
  284. package/lib/beta.d.ts +5 -1
  285. package/lib/codec/codec.d.ts +1 -1
  286. package/lib/codec/codec.d.ts.map +1 -1
  287. package/lib/codec/codec.js +1 -2
  288. package/lib/codec/codec.js.map +1 -1
  289. package/lib/codec/discriminatedUnions.d.ts.map +1 -1
  290. package/lib/codec/discriminatedUnions.js +2 -2
  291. package/lib/codec/discriminatedUnions.js.map +1 -1
  292. package/lib/core/rebase/utils.js +1 -1
  293. package/lib/core/rebase/utils.js.map +1 -1
  294. package/lib/core/schema-stored/schema.d.ts +4 -1
  295. package/lib/core/schema-stored/schema.d.ts.map +1 -1
  296. package/lib/core/schema-stored/schema.js +6 -2
  297. package/lib/core/schema-stored/schema.js.map +1 -1
  298. package/lib/core/tree/anchorSet.d.ts.map +1 -1
  299. package/lib/core/tree/anchorSet.js +2 -2
  300. package/lib/core/tree/anchorSet.js.map +1 -1
  301. package/lib/core/tree/treeTextFormat.js +1 -1
  302. package/lib/core/tree/treeTextFormat.js.map +1 -1
  303. package/lib/feature-libraries/chunked-forest/basicChunk.d.ts.map +1 -1
  304. package/lib/feature-libraries/chunked-forest/basicChunk.js +2 -2
  305. package/lib/feature-libraries/chunked-forest/basicChunk.js.map +1 -1
  306. package/lib/feature-libraries/chunked-forest/chunkTree.js +2 -2
  307. package/lib/feature-libraries/chunked-forest/chunkTree.js.map +1 -1
  308. package/lib/feature-libraries/chunked-forest/chunkedForest.d.ts.map +1 -1
  309. package/lib/feature-libraries/chunked-forest/chunkedForest.js +2 -2
  310. package/lib/feature-libraries/chunked-forest/chunkedForest.js.map +1 -1
  311. package/lib/feature-libraries/chunked-forest/codec/chunkEncodingGeneric.js +1 -1
  312. package/lib/feature-libraries/chunked-forest/codec/chunkEncodingGeneric.js.map +1 -1
  313. package/lib/feature-libraries/chunked-forest/codec/compressedEncode.js +2 -2
  314. package/lib/feature-libraries/chunked-forest/codec/compressedEncode.js.map +1 -1
  315. package/lib/feature-libraries/chunked-forest/codec/nodeShape.js +2 -2
  316. package/lib/feature-libraries/chunked-forest/codec/nodeShape.js.map +1 -1
  317. package/lib/feature-libraries/chunked-forest/codec/schemaBasedEncode.d.ts.map +1 -1
  318. package/lib/feature-libraries/chunked-forest/codec/schemaBasedEncode.js +1 -2
  319. package/lib/feature-libraries/chunked-forest/codec/schemaBasedEncode.js.map +1 -1
  320. package/lib/feature-libraries/chunked-forest/emptyChunk.d.ts.map +1 -1
  321. package/lib/feature-libraries/chunked-forest/emptyChunk.js +1 -1
  322. package/lib/feature-libraries/chunked-forest/emptyChunk.js.map +1 -1
  323. package/lib/feature-libraries/chunked-forest/uniformChunk.d.ts.map +1 -1
  324. package/lib/feature-libraries/chunked-forest/uniformChunk.js +2 -2
  325. package/lib/feature-libraries/chunked-forest/uniformChunk.js.map +1 -1
  326. package/lib/feature-libraries/default-schema/defaultFieldKinds.d.ts.map +1 -1
  327. package/lib/feature-libraries/default-schema/defaultFieldKinds.js +1 -1
  328. package/lib/feature-libraries/default-schema/defaultFieldKinds.js.map +1 -1
  329. package/lib/feature-libraries/default-schema/schemaChecker.d.ts.map +1 -1
  330. package/lib/feature-libraries/default-schema/schemaChecker.js +1 -2
  331. package/lib/feature-libraries/default-schema/schemaChecker.js.map +1 -1
  332. package/lib/feature-libraries/flex-tree/lazyField.js +2 -2
  333. package/lib/feature-libraries/flex-tree/lazyField.js.map +1 -1
  334. package/lib/feature-libraries/flex-tree/lazyNode.js +2 -2
  335. package/lib/feature-libraries/flex-tree/lazyNode.js.map +1 -1
  336. package/lib/feature-libraries/indexing/anchorTreeIndex.d.ts.map +1 -1
  337. package/lib/feature-libraries/indexing/anchorTreeIndex.js +2 -2
  338. package/lib/feature-libraries/indexing/anchorTreeIndex.js.map +1 -1
  339. package/lib/feature-libraries/modular-schema/comparison.js +2 -2
  340. package/lib/feature-libraries/modular-schema/comparison.js.map +1 -1
  341. package/lib/feature-libraries/modular-schema/isNeverTree.d.ts.map +1 -1
  342. package/lib/feature-libraries/modular-schema/isNeverTree.js +1 -2
  343. package/lib/feature-libraries/modular-schema/isNeverTree.js.map +1 -1
  344. package/lib/feature-libraries/modular-schema/modularChangeCodecs.d.ts.map +1 -1
  345. package/lib/feature-libraries/modular-schema/modularChangeCodecs.js +2 -2
  346. package/lib/feature-libraries/modular-schema/modularChangeCodecs.js.map +1 -1
  347. package/lib/feature-libraries/modular-schema/modularChangeFamily.d.ts.map +1 -1
  348. package/lib/feature-libraries/modular-schema/modularChangeFamily.js +2 -2
  349. package/lib/feature-libraries/modular-schema/modularChangeFamily.js.map +1 -1
  350. package/lib/feature-libraries/node-identifier/mockNodeIdentifierManager.js +2 -2
  351. package/lib/feature-libraries/node-identifier/mockNodeIdentifierManager.js.map +1 -1
  352. package/lib/feature-libraries/object-forest/objectForest.d.ts.map +1 -1
  353. package/lib/feature-libraries/object-forest/objectForest.js +2 -2
  354. package/lib/feature-libraries/object-forest/objectForest.js.map +1 -1
  355. package/lib/feature-libraries/schema-index/codec.d.ts.map +1 -1
  356. package/lib/feature-libraries/schema-index/codec.js +2 -1
  357. package/lib/feature-libraries/schema-index/codec.js.map +1 -1
  358. package/lib/feature-libraries/sequence-field/compose.d.ts +1 -1
  359. package/lib/feature-libraries/sequence-field/compose.d.ts.map +1 -1
  360. package/lib/feature-libraries/sequence-field/compose.js +1 -2
  361. package/lib/feature-libraries/sequence-field/compose.js.map +1 -1
  362. package/lib/feature-libraries/sequence-field/invert.d.ts.map +1 -1
  363. package/lib/feature-libraries/sequence-field/invert.js +2 -2
  364. package/lib/feature-libraries/sequence-field/invert.js.map +1 -1
  365. package/lib/feature-libraries/sequence-field/sequenceFieldCodecV1.d.ts.map +1 -1
  366. package/lib/feature-libraries/sequence-field/sequenceFieldCodecV1.js +2 -2
  367. package/lib/feature-libraries/sequence-field/sequenceFieldCodecV1.js.map +1 -1
  368. package/lib/feature-libraries/sequence-field/sequenceFieldCodecV2.d.ts.map +1 -1
  369. package/lib/feature-libraries/sequence-field/sequenceFieldCodecV2.js +2 -2
  370. package/lib/feature-libraries/sequence-field/sequenceFieldCodecV2.js.map +1 -1
  371. package/lib/feature-libraries/sequence-field/utils.js +2 -2
  372. package/lib/feature-libraries/sequence-field/utils.js.map +1 -1
  373. package/lib/feature-libraries/treeCursorUtils.d.ts.map +1 -1
  374. package/lib/feature-libraries/treeCursorUtils.js +1 -2
  375. package/lib/feature-libraries/treeCursorUtils.js.map +1 -1
  376. package/lib/index.d.ts +4 -3
  377. package/lib/index.d.ts.map +1 -1
  378. package/lib/index.js +4 -3
  379. package/lib/index.js.map +1 -1
  380. package/lib/jsonDomainSchema.d.ts +15 -16
  381. package/lib/jsonDomainSchema.d.ts.map +1 -1
  382. package/lib/jsonDomainSchema.js +11 -6
  383. package/lib/jsonDomainSchema.js.map +1 -1
  384. package/lib/legacy.d.ts +5 -1
  385. package/lib/packageVersion.d.ts +1 -1
  386. package/lib/packageVersion.js +1 -1
  387. package/lib/packageVersion.js.map +1 -1
  388. package/lib/public.d.ts +5 -1
  389. package/lib/serializableDomainSchema.d.ts +8 -14
  390. package/lib/serializableDomainSchema.d.ts.map +1 -1
  391. package/lib/shared-tree/schematizeTree.js +2 -2
  392. package/lib/shared-tree/schematizeTree.js.map +1 -1
  393. package/lib/shared-tree/sharedTree.d.ts.map +1 -1
  394. package/lib/shared-tree/sharedTree.js +14 -10
  395. package/lib/shared-tree/sharedTree.js.map +1 -1
  396. package/lib/shared-tree/sharedTreeChangeFamily.d.ts.map +1 -1
  397. package/lib/shared-tree/sharedTreeChangeFamily.js +2 -2
  398. package/lib/shared-tree/sharedTreeChangeFamily.js.map +1 -1
  399. package/lib/shared-tree/treeApiAlpha.d.ts +6 -2
  400. package/lib/shared-tree/treeApiAlpha.d.ts.map +1 -1
  401. package/lib/shared-tree/treeApiAlpha.js +10 -7
  402. package/lib/shared-tree/treeApiAlpha.js.map +1 -1
  403. package/lib/shared-tree/treeCheckout.d.ts.map +1 -1
  404. package/lib/shared-tree/treeCheckout.js +2 -2
  405. package/lib/shared-tree/treeCheckout.js.map +1 -1
  406. package/lib/shared-tree-core/branch.d.ts +4 -3
  407. package/lib/shared-tree-core/branch.d.ts.map +1 -1
  408. package/lib/shared-tree-core/branch.js +2 -2
  409. package/lib/shared-tree-core/branch.js.map +1 -1
  410. package/lib/shared-tree-core/editManager.d.ts.map +1 -1
  411. package/lib/shared-tree-core/editManager.js +35 -29
  412. package/lib/shared-tree-core/editManager.js.map +1 -1
  413. package/lib/sharedTreeAttributes.d.ts +18 -0
  414. package/lib/sharedTreeAttributes.d.ts.map +1 -0
  415. package/lib/sharedTreeAttributes.js +22 -0
  416. package/lib/sharedTreeAttributes.js.map +1 -0
  417. package/lib/simple-tree/api/customTree.js +2 -2
  418. package/lib/simple-tree/api/customTree.js.map +1 -1
  419. package/lib/simple-tree/api/getJsonSchema.d.ts +10 -0
  420. package/lib/simple-tree/api/getJsonSchema.d.ts.map +1 -1
  421. package/lib/simple-tree/api/getJsonSchema.js +10 -0
  422. package/lib/simple-tree/api/getJsonSchema.js.map +1 -1
  423. package/lib/simple-tree/api/getSimpleSchema.d.ts +13 -43
  424. package/lib/simple-tree/api/getSimpleSchema.d.ts.map +1 -1
  425. package/lib/simple-tree/api/getSimpleSchema.js +13 -43
  426. package/lib/simple-tree/api/getSimpleSchema.js.map +1 -1
  427. package/lib/simple-tree/api/index.d.ts +3 -3
  428. package/lib/simple-tree/api/index.d.ts.map +1 -1
  429. package/lib/simple-tree/api/index.js +1 -0
  430. package/lib/simple-tree/api/index.js.map +1 -1
  431. package/lib/simple-tree/api/schemaCreationUtilities.d.ts.map +1 -1
  432. package/lib/simple-tree/api/schemaCreationUtilities.js +1 -1
  433. package/lib/simple-tree/api/schemaCreationUtilities.js.map +1 -1
  434. package/lib/simple-tree/api/schemaFactory.d.ts +100 -58
  435. package/lib/simple-tree/api/schemaFactory.d.ts.map +1 -1
  436. package/lib/simple-tree/api/schemaFactory.js +64 -132
  437. package/lib/simple-tree/api/schemaFactory.js.map +1 -1
  438. package/lib/simple-tree/api/schemaFactoryAlpha.d.ts +31 -23
  439. package/lib/simple-tree/api/schemaFactoryAlpha.d.ts.map +1 -1
  440. package/lib/simple-tree/api/schemaFactoryAlpha.js +18 -2
  441. package/lib/simple-tree/api/schemaFactoryAlpha.js.map +1 -1
  442. package/lib/simple-tree/api/schemaFactoryRecursive.d.ts +40 -5
  443. package/lib/simple-tree/api/schemaFactoryRecursive.d.ts.map +1 -1
  444. package/lib/simple-tree/api/schemaFactoryRecursive.js.map +1 -1
  445. package/lib/simple-tree/api/schemaFromSimple.d.ts +4 -4
  446. package/lib/simple-tree/api/schemaFromSimple.d.ts.map +1 -1
  447. package/lib/simple-tree/api/schemaFromSimple.js +21 -10
  448. package/lib/simple-tree/api/schemaFromSimple.js.map +1 -1
  449. package/lib/simple-tree/api/simpleSchemaToJsonSchema.d.ts +3 -2
  450. package/lib/simple-tree/api/simpleSchemaToJsonSchema.d.ts.map +1 -1
  451. package/lib/simple-tree/api/simpleSchemaToJsonSchema.js +6 -6
  452. package/lib/simple-tree/api/simpleSchemaToJsonSchema.js.map +1 -1
  453. package/lib/simple-tree/api/simpleTreeIndex.d.ts.map +1 -1
  454. package/lib/simple-tree/api/simpleTreeIndex.js +2 -1
  455. package/lib/simple-tree/api/simpleTreeIndex.js.map +1 -1
  456. package/lib/simple-tree/api/testRecursiveDomain.d.ts +10 -10
  457. package/lib/simple-tree/api/tree.d.ts +1 -1
  458. package/lib/simple-tree/api/tree.d.ts.map +1 -1
  459. package/lib/simple-tree/api/tree.js +2 -2
  460. package/lib/simple-tree/api/tree.js.map +1 -1
  461. package/lib/simple-tree/api/treeNodeApi.js +2 -2
  462. package/lib/simple-tree/api/treeNodeApi.js.map +1 -1
  463. package/lib/simple-tree/api/typesUnsafe.d.ts +87 -21
  464. package/lib/simple-tree/api/typesUnsafe.d.ts.map +1 -1
  465. package/lib/simple-tree/api/typesUnsafe.js +0 -1
  466. package/lib/simple-tree/api/typesUnsafe.js.map +1 -1
  467. package/lib/simple-tree/api/verboseTree.js +2 -2
  468. package/lib/simple-tree/api/verboseTree.js.map +1 -1
  469. package/lib/simple-tree/api/view.d.ts.map +1 -1
  470. package/lib/simple-tree/api/view.js +1 -2
  471. package/lib/simple-tree/api/view.js.map +1 -1
  472. package/lib/simple-tree/api/viewSchemaToSimpleSchema.d.ts +16 -3
  473. package/lib/simple-tree/api/viewSchemaToSimpleSchema.d.ts.map +1 -1
  474. package/lib/simple-tree/api/viewSchemaToSimpleSchema.js +69 -146
  475. package/lib/simple-tree/api/viewSchemaToSimpleSchema.js.map +1 -1
  476. package/lib/simple-tree/arrayNode.d.ts +5 -4
  477. package/lib/simple-tree/arrayNode.d.ts.map +1 -1
  478. package/lib/simple-tree/arrayNode.js +7 -3
  479. package/lib/simple-tree/arrayNode.js.map +1 -1
  480. package/lib/simple-tree/arrayNodeTypes.d.ts +46 -0
  481. package/lib/simple-tree/arrayNodeTypes.d.ts.map +1 -0
  482. package/lib/simple-tree/arrayNodeTypes.js +26 -0
  483. package/lib/simple-tree/arrayNodeTypes.js.map +1 -0
  484. package/lib/simple-tree/core/getOrCreateNode.d.ts.map +1 -1
  485. package/lib/simple-tree/core/getOrCreateNode.js +2 -12
  486. package/lib/simple-tree/core/getOrCreateNode.js.map +1 -1
  487. package/lib/simple-tree/core/index.d.ts +1 -2
  488. package/lib/simple-tree/core/index.d.ts.map +1 -1
  489. package/lib/simple-tree/core/index.js +1 -2
  490. package/lib/simple-tree/core/index.js.map +1 -1
  491. package/lib/simple-tree/core/treeNodeKernel.d.ts +12 -5
  492. package/lib/simple-tree/core/treeNodeKernel.d.ts.map +1 -1
  493. package/lib/simple-tree/core/treeNodeKernel.js +28 -14
  494. package/lib/simple-tree/core/treeNodeKernel.js.map +1 -1
  495. package/lib/simple-tree/core/treeNodeSchema.d.ts +14 -7
  496. package/lib/simple-tree/core/treeNodeSchema.d.ts.map +1 -1
  497. package/lib/simple-tree/core/treeNodeSchema.js.map +1 -1
  498. package/lib/simple-tree/core/unhydratedFlexTree.js +2 -2
  499. package/lib/simple-tree/core/unhydratedFlexTree.js.map +1 -1
  500. package/lib/simple-tree/index.d.ts +9 -2
  501. package/lib/simple-tree/index.d.ts.map +1 -1
  502. package/lib/simple-tree/index.js +3 -0
  503. package/lib/simple-tree/index.js.map +1 -1
  504. package/lib/simple-tree/leafNodeSchema.d.ts +22 -5
  505. package/lib/simple-tree/leafNodeSchema.d.ts.map +1 -1
  506. package/lib/simple-tree/leafNodeSchema.js +2 -0
  507. package/lib/simple-tree/leafNodeSchema.js.map +1 -1
  508. package/lib/simple-tree/mapNode.d.ts +3 -2
  509. package/lib/simple-tree/mapNode.d.ts.map +1 -1
  510. package/lib/simple-tree/mapNode.js +5 -1
  511. package/lib/simple-tree/mapNode.js.map +1 -1
  512. package/lib/simple-tree/mapNodeTypes.d.ts +46 -0
  513. package/lib/simple-tree/mapNodeTypes.d.ts.map +1 -0
  514. package/lib/simple-tree/mapNodeTypes.js +26 -0
  515. package/lib/simple-tree/mapNodeTypes.js.map +1 -0
  516. package/lib/simple-tree/objectNode.d.ts +10 -3
  517. package/lib/simple-tree/objectNode.d.ts.map +1 -1
  518. package/lib/simple-tree/objectNode.js +10 -5
  519. package/lib/simple-tree/objectNode.js.map +1 -1
  520. package/lib/simple-tree/objectNodeTypes.d.ts +9 -5
  521. package/lib/simple-tree/objectNodeTypes.d.ts.map +1 -1
  522. package/lib/simple-tree/objectNodeTypes.js +3 -0
  523. package/lib/simple-tree/objectNodeTypes.js.map +1 -1
  524. package/lib/simple-tree/proxies.js +2 -1
  525. package/lib/simple-tree/proxies.js.map +1 -1
  526. package/lib/simple-tree/schemaTypes.d.ts +47 -6
  527. package/lib/simple-tree/schemaTypes.d.ts.map +1 -1
  528. package/lib/simple-tree/schemaTypes.js +37 -3
  529. package/lib/simple-tree/schemaTypes.js.map +1 -1
  530. package/lib/simple-tree/{api/simpleSchema.d.ts → simpleSchema.d.ts} +54 -30
  531. package/lib/simple-tree/simpleSchema.d.ts.map +1 -0
  532. package/lib/simple-tree/simpleSchema.js.map +1 -0
  533. package/lib/simple-tree/toMapTree.js +2 -2
  534. package/lib/simple-tree/toMapTree.js.map +1 -1
  535. package/lib/simple-tree/toStoredSchema.js +2 -2
  536. package/lib/simple-tree/toStoredSchema.js.map +1 -1
  537. package/lib/simple-tree/treeNodeValid.d.ts.map +1 -1
  538. package/lib/simple-tree/treeNodeValid.js +1 -2
  539. package/lib/simple-tree/treeNodeValid.js.map +1 -1
  540. package/lib/treeFactory.d.ts +0 -12
  541. package/lib/treeFactory.d.ts.map +1 -1
  542. package/lib/treeFactory.js +1 -17
  543. package/lib/treeFactory.js.map +1 -1
  544. package/lib/tsdoc-metadata.json +1 -1
  545. package/lib/util/idAllocator.d.ts.map +1 -1
  546. package/lib/util/idAllocator.js +1 -2
  547. package/lib/util/idAllocator.js.map +1 -1
  548. package/lib/util/index.d.ts +1 -1
  549. package/lib/util/index.d.ts.map +1 -1
  550. package/lib/util/index.js +1 -1
  551. package/lib/util/index.js.map +1 -1
  552. package/lib/util/typeCheck.d.ts +7 -0
  553. package/lib/util/typeCheck.d.ts.map +1 -1
  554. package/lib/util/typeCheck.js.map +1 -1
  555. package/lib/util/utils.d.ts +0 -1
  556. package/lib/util/utils.d.ts.map +1 -1
  557. package/lib/util/utils.js +0 -2
  558. package/lib/util/utils.js.map +1 -1
  559. package/package.json +36 -26
  560. package/src/codec/codec.ts +2 -2
  561. package/src/codec/discriminatedUnions.ts +2 -2
  562. package/src/core/rebase/utils.ts +1 -1
  563. package/src/core/schema-stored/schema.ts +6 -2
  564. package/src/core/tree/anchorSet.ts +1 -2
  565. package/src/core/tree/treeTextFormat.ts +1 -1
  566. package/src/feature-libraries/chunked-forest/basicChunk.ts +2 -2
  567. package/src/feature-libraries/chunked-forest/chunkTree.ts +2 -2
  568. package/src/feature-libraries/chunked-forest/chunkedForest.ts +1 -2
  569. package/src/feature-libraries/chunked-forest/codec/chunkEncodingGeneric.ts +1 -1
  570. package/src/feature-libraries/chunked-forest/codec/compressedEncode.ts +2 -2
  571. package/src/feature-libraries/chunked-forest/codec/nodeShape.ts +2 -2
  572. package/src/feature-libraries/chunked-forest/codec/schemaBasedEncode.ts +1 -2
  573. package/src/feature-libraries/chunked-forest/emptyChunk.ts +1 -1
  574. package/src/feature-libraries/chunked-forest/uniformChunk.ts +2 -2
  575. package/src/feature-libraries/default-schema/defaultFieldKinds.ts +1 -1
  576. package/src/feature-libraries/default-schema/schemaChecker.ts +1 -2
  577. package/src/feature-libraries/flex-tree/lazyField.ts +2 -2
  578. package/src/feature-libraries/flex-tree/lazyNode.ts +2 -2
  579. package/src/feature-libraries/indexing/anchorTreeIndex.ts +2 -2
  580. package/src/feature-libraries/modular-schema/comparison.ts +2 -2
  581. package/src/feature-libraries/modular-schema/isNeverTree.ts +1 -2
  582. package/src/feature-libraries/modular-schema/modularChangeCodecs.ts +1 -2
  583. package/src/feature-libraries/modular-schema/modularChangeFamily.ts +1 -2
  584. package/src/feature-libraries/node-identifier/mockNodeIdentifierManager.ts +2 -2
  585. package/src/feature-libraries/object-forest/objectForest.ts +1 -2
  586. package/src/feature-libraries/schema-index/codec.ts +2 -1
  587. package/src/feature-libraries/sequence-field/compose.ts +2 -2
  588. package/src/feature-libraries/sequence-field/invert.ts +2 -2
  589. package/src/feature-libraries/sequence-field/sequenceFieldCodecV1.ts +2 -2
  590. package/src/feature-libraries/sequence-field/sequenceFieldCodecV2.ts +2 -2
  591. package/src/feature-libraries/sequence-field/utils.ts +2 -2
  592. package/src/feature-libraries/treeCursorUtils.ts +1 -2
  593. package/src/index.ts +26 -3
  594. package/src/jsonDomainSchema.ts +30 -11
  595. package/src/packageVersion.ts +1 -1
  596. package/src/shared-tree/schematizeTree.ts +2 -2
  597. package/src/shared-tree/sharedTree.ts +16 -10
  598. package/src/shared-tree/sharedTreeChangeFamily.ts +1 -2
  599. package/src/shared-tree/treeApiAlpha.ts +36 -13
  600. package/src/shared-tree/treeCheckout.ts +2 -8
  601. package/src/shared-tree-core/branch.ts +5 -3
  602. package/src/shared-tree-core/editManager.ts +37 -45
  603. package/src/sharedTreeAttributes.ts +25 -0
  604. package/src/simple-tree/api/customTree.ts +2 -2
  605. package/src/simple-tree/api/getJsonSchema.ts +10 -0
  606. package/src/simple-tree/api/getSimpleSchema.ts +14 -44
  607. package/src/simple-tree/api/index.ts +7 -11
  608. package/src/simple-tree/api/schemaCreationUtilities.ts +1 -2
  609. package/src/simple-tree/api/schemaFactory.ts +161 -86
  610. package/src/simple-tree/api/schemaFactoryAlpha.ts +62 -67
  611. package/src/simple-tree/api/schemaFactoryRecursive.ts +44 -12
  612. package/src/simple-tree/api/schemaFromSimple.ts +41 -13
  613. package/src/simple-tree/api/simpleSchemaToJsonSchema.ts +7 -7
  614. package/src/simple-tree/api/simpleTreeIndex.ts +2 -1
  615. package/src/simple-tree/api/tree.ts +3 -3
  616. package/src/simple-tree/api/treeNodeApi.ts +2 -2
  617. package/src/simple-tree/api/typesUnsafe.ts +151 -33
  618. package/src/simple-tree/api/verboseTree.ts +2 -2
  619. package/src/simple-tree/api/view.ts +1 -2
  620. package/src/simple-tree/api/viewSchemaToSimpleSchema.ts +80 -185
  621. package/src/simple-tree/arrayNode.ts +20 -14
  622. package/src/simple-tree/arrayNodeTypes.ts +93 -0
  623. package/src/simple-tree/core/getOrCreateNode.ts +3 -13
  624. package/src/simple-tree/core/index.ts +1 -1
  625. package/src/simple-tree/core/treeNodeKernel.ts +32 -18
  626. package/src/simple-tree/core/treeNodeSchema.ts +14 -8
  627. package/src/simple-tree/core/unhydratedFlexTree.ts +2 -2
  628. package/src/simple-tree/index.ts +30 -9
  629. package/src/simple-tree/leafNodeSchema.ts +28 -7
  630. package/src/simple-tree/mapNode.ts +13 -11
  631. package/src/simple-tree/mapNodeTypes.ts +90 -0
  632. package/src/simple-tree/objectNode.ts +37 -13
  633. package/src/simple-tree/objectNodeTypes.ts +21 -16
  634. package/src/simple-tree/proxies.ts +2 -2
  635. package/src/simple-tree/schemaTypes.ts +83 -19
  636. package/src/simple-tree/{api/simpleSchema.ts → simpleSchema.ts} +61 -32
  637. package/src/simple-tree/toMapTree.ts +2 -2
  638. package/src/simple-tree/toStoredSchema.ts +2 -2
  639. package/src/simple-tree/treeNodeValid.ts +1 -2
  640. package/src/treeFactory.ts +1 -19
  641. package/src/util/idAllocator.ts +1 -3
  642. package/src/util/index.ts +0 -1
  643. package/src/util/typeCheck.ts +7 -0
  644. package/src/util/utils.ts +0 -3
  645. package/dist/simple-tree/api/simpleSchema.d.ts.map +0 -1
  646. package/dist/simple-tree/api/simpleSchema.js.map +0 -1
  647. package/dist/simple-tree/core/schemaCaching.d.ts +0 -16
  648. package/dist/simple-tree/core/schemaCaching.d.ts.map +0 -1
  649. package/dist/simple-tree/core/schemaCaching.js +0 -32
  650. package/dist/simple-tree/core/schemaCaching.js.map +0 -1
  651. package/lib/simple-tree/api/simpleSchema.d.ts.map +0 -1
  652. package/lib/simple-tree/api/simpleSchema.js.map +0 -1
  653. package/lib/simple-tree/core/schemaCaching.d.ts +0 -16
  654. package/lib/simple-tree/core/schemaCaching.d.ts.map +0 -1
  655. package/lib/simple-tree/core/schemaCaching.js +0 -27
  656. package/lib/simple-tree/core/schemaCaching.js.map +0 -1
  657. package/prettier.config.cjs +0 -8
  658. package/src/simple-tree/core/schemaCaching.ts +0 -35
  659. /package/dist/simple-tree/{api/simpleSchema.js → simpleSchema.js} +0 -0
  660. /package/lib/simple-tree/{api/simpleSchema.js → simpleSchema.js} +0 -0
@@ -1 +1 @@
1
- {"version":3,"file":"chunkEncodingGeneric.js","sourceRoot":"","sources":["../../../../src/feature-libraries/chunked-forest/codec/chunkEncodingGeneric.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,qDAA8C;AAG9C,qEAKkC;AAGlC;;;;;;;;GAQG;AACH,MAAa,eAAe;IAC3B,YAAmC,UAAkB;QAAlB,eAAU,GAAV,UAAU,CAAQ;IAAG,CAAC;CACzD;AAFD,0CAEC;AAeD;;;;;;GAMG;AACH,SAAgB,0BAA0B,CACzC,OAAe,EACf,MAAqC,EACrC,mBAA0C,6CAAoB;IAE9D,MAAM,WAAW,GAAG,IAAI,gCAAO,EAAU,CAAC;IAC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AA5ED,gEA4EC;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAsB,KAAK;CA4B1B;AA5BD,sBA4BC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { TreeValue } from \"../../../core/index.js\";\nimport { fail } from \"../../../util/index.js\";\nimport type { FluidSerializableReadOnly } from \"../../valueUtilities.js\";\n\nimport {\n\tCounter,\n\ttype CounterFilter,\n\ttype DeduplicationTable,\n\tjsonMinimizingFilter,\n} from \"./chunkCodecUtilities.js\";\nimport type { EncodedFieldBatchGeneric } from \"./formatGeneric.js\";\n\n/**\n * An identifier which can be compressed using {@link Counter}.\n *\n * @remarks\n * Compression of Identifiers is done after the output is otherwise generated to enable counting all the usages.\n * To avoid having to decode the decode the data array to determine which data is an identifier and which is some other string,\n * some recognizable representation is required.\n * Using a class and checking its prototype works for this, and is why IdentifierToken is a class.\n */\nexport class IdentifierToken {\n\tpublic constructor(public readonly identifier: string) {}\n}\n\n/**\n * Format for data emitted during encoding, before dictionary compression of identifiers.\n *\n * @remarks\n * These buffers are mutated after construction if they contain identifiers or shapes.\n */\nexport type BufferFormat<TEncodedShape> = (\n\t| FluidSerializableReadOnly\n\t| Shape<TEncodedShape>\n\t| IdentifierToken\n\t| BufferFormat<TEncodedShape>\n)[];\n\n/**\n * Replace shapes and identifiers in buffer and any nested arrays.\n *\n * This looks inside nested arrays (including transitively) but not inside objects.\n *\n * Note that this modifies `buffer` to avoid having to copy it.\n */\nexport function handleShapesAndIdentifiers<TEncodedShape>(\n\tversion: number,\n\tbuffer: BufferFormat<TEncodedShape>[],\n\tidentifierFilter: CounterFilter<string> = jsonMinimizingFilter,\n): EncodedFieldBatchGeneric<TEncodedShape> {\n\tconst identifiers = new Counter<string>();\n\tconst shapes = new Counter<Shape<TEncodedShape>>();\n\t// Shapes can reference other shapes (and identifiers), so we need to traverse the shape graph.\n\t// These collections enable that.\n\tconst shapesSeen = new Set<Shape<TEncodedShape>>();\n\tconst shapeToCount: Shape<TEncodedShape>[] = [];\n\tconst shapeDiscovered = (shape: Shape<TEncodedShape>): void => {\n\t\tshapes.add(shape);\n\t\tif (!shapesSeen.has(shape)) {\n\t\t\tshapesSeen.add(shape);\n\t\t\tshapeToCount.push(shape);\n\t\t}\n\t};\n\n\tconst arrays: BufferFormat<TEncodedShape>[] = [buffer];\n\tfor (const array of arrays) {\n\t\tfor (const item of array) {\n\t\t\tif (item instanceof IdentifierToken) {\n\t\t\t\tidentifiers.add(item.identifier);\n\t\t\t} else if (item instanceof Shape) {\n\t\t\t\tshapeDiscovered(item);\n\t\t\t} else if (Array.isArray(item)) {\n\t\t\t\t// In JS it is legal to push items to an array which is being iterated,\n\t\t\t\t// and they will be visited in order.\n\t\t\t\tarrays.push(item);\n\t\t\t} else if (\n\t\t\t\titem !== null &&\n\t\t\t\ttypeof item === \"object\" &&\n\t\t\t\t(item as Record<string, unknown>).shape instanceof Shape\n\t\t\t) {\n\t\t\t\t// because \"serializable\" is allowed in buffer and it has type `any`, its very easy to mess up including of shapes in the buffer.\n\t\t\t\t// This catches the easiest way to get it wrong.\n\t\t\t\tfail(0xb4b /* encoder interface instead of shape written to stream */);\n\t\t\t}\n\t\t}\n\t}\n\n\t// Traverse shape graph, discovering and counting all shape to shape and shape to identifier references.\n\t{\n\t\tlet item: Shape<TEncodedShape> | undefined;\n\t\twhile ((item = shapeToCount.pop()) !== undefined) {\n\t\t\titem.count(identifiers, shapeDiscovered);\n\t\t}\n\t}\n\n\t// Determine substitutions for identifiers and shapes:\n\tconst identifierTable = identifiers.buildTable(identifierFilter);\n\tconst shapeTable = shapes.buildTable();\n\n\tfor (const array of arrays) {\n\t\tfor (let index = 0; index < array.length; index++) {\n\t\t\tconst item = array[index];\n\t\t\tif (item instanceof IdentifierToken) {\n\t\t\t\tarray[index] = identifierTable.valueToIndex.get(item.identifier) ?? item.identifier;\n\t\t\t} else if (item instanceof Shape) {\n\t\t\t\tarray[index] = shapeTable.valueToIndex.get(item) ?? fail(0xb4c /* missing shape */);\n\t\t\t}\n\t\t}\n\t}\n\n\tconst encodedShapes = shapeTable.indexToValue.map((shape) =>\n\t\tshape.encodeShape(identifierTable, shapeTable),\n\t);\n\n\treturn {\n\t\tversion,\n\t\t// TODO: fix readonly typing issues to remove this cast.\n\t\tidentifiers: identifierTable.indexToValue as string[],\n\t\tshapes: encodedShapes,\n\t\tdata: buffer as TreeValue[][],\n\t};\n}\n\n/**\n * A tree shape.\n * This similar to a schema for a tree, though it may be more or less specific than the actual schema system used.\n * Can be encoded into a `TEncodedShape`: when doing so encodes references to shapes (if needed) using {@link Counter}:\n * this can include recursive references (direct or indirect).\n *\n * @remarks\n * Deduplication of shapes is done after the output is otherwise generated (including identifier dictionary encoding).\n * To avoid having to decode the data array to determine which data is a shape and which is some other object,\n * some recognizable representation is required.\n * Using a class and checking its prototype works for this, and is why Shape is a class.\n *\n * Note that deduplication compares shapes by object identity not by content, so encoders must ensure shapes are not duplicated to achieve efficient encoding.\n * Comparison by content would be difficult due to shape containing references to other shapes.\n *\n * @privateRemarks\n * Unlike with identifiers, conversion from the initial form (this class / IdentifierToken) is done by the `encodeShape` method, not by general purpose logic in `handleShapesAndIdentifiers`.\n * For `handleShapesAndIdentifiers` to do the conversion without help from `encodeShape`,\n * instances of this Shape class would have to either be or output an object that is identical to the `TEncodedShape` format except with all shape references as object references instead of indexes.\n * Those objects would have to be deeply traversed looking for shape objects to replace with reference indexes.\n * This is possible, but making it type safe would involve generating derived types from the `TEncodedShape` deeply replacing any shape references, as well as requiring deep traversal of all objects in the encoded output.\n * Such an approach seemed less maintainable and readable than the design taken here which avoids the need for those derived types.\n */\nexport abstract class Shape<TEncodedShape> {\n\t/**\n\t * Count this shape's contents.\n\t *\n\t * Used to discover referenced shapes (to ensure they are included in the `shapes` passed to `encodeShape`),\n\t * as well as count usages of shapes and identifiers for more efficient dictionary encoding. See {@link Counter}.\n\t *\n\t * @param shapes - must be invoked with each directly referenced shape (which must provided to `encodeShape`).\n\t * Can be invoked multiple times if a shape is referenced more than once for more efficient dictionary encoding.\n\t * Should not be invoked with `this` unless this shape references itself.\n\t */\n\tpublic abstract count(\n\t\tidentifiers: Counter<string>,\n\t\tshapes: (shape: Shape<TEncodedShape>) => void,\n\t): void;\n\n\t/**\n\t * Produce the final encoded format for this shape.\n\t *\n\t * @param identifiers - a subset of identifiers used in this tree, and their corresponding indexes to use for the dictionary encoding.\n\t * Can be used to encode identifiers referenced by this shape.\n\t * @param shapes - includes a superset of shapes reported by count.\n\t * Used to encode references to shapes as numbers.\n\t */\n\tpublic abstract encodeShape(\n\t\tidentifiers: DeduplicationTable<string>,\n\t\tshapes: DeduplicationTable<Shape<TEncodedShape>>,\n\t): TEncodedShape;\n}\n"]}
1
+ {"version":3,"file":"chunkEncodingGeneric.js","sourceRoot":"","sources":["../../../../src/feature-libraries/chunked-forest/codec/chunkEncodingGeneric.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAA2D;AAI3D,qEAKkC;AAGlC;;;;;;;;GAQG;AACH,MAAa,eAAe;IAC3B,YAAmC,UAAkB;QAAlB,eAAU,GAAV,UAAU,CAAQ;IAAG,CAAC;CACzD;AAFD,0CAEC;AAeD;;;;;;GAMG;AACH,SAAgB,0BAA0B,CACzC,OAAe,EACf,MAAqC,EACrC,mBAA0C,6CAAoB;IAE9D,MAAM,WAAW,GAAG,IAAI,gCAAO,EAAU,CAAC;IAC1C,MAAM,MAAM,GAAG,IAAI,gCAAO,EAAwB,CAAC;IACnD,+FAA+F;IAC/F,iCAAiC;IACjC,MAAM,UAAU,GAAG,IAAI,GAAG,EAAwB,CAAC;IACnD,MAAM,YAAY,GAA2B,EAAE,CAAC;IAChD,MAAM,eAAe,GAAG,CAAC,KAA2B,EAAQ,EAAE;QAC7D,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QAClB,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC;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,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;QAC5B,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,KAAK,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE,CAAC;YACnD,MAAM,IAAI,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC;YAC1B,IAAI,IAAI,YAAY,eAAe,EAAE,CAAC;gBACrC,KAAK,CAAC,KAAK,CAAC,GAAG,eAAe,CAAC,YAAY,CAAC,GAAG,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,IAAI,CAAC,UAAU,CAAC;YACrF,CAAC;iBAAM,IAAI,IAAI,YAAY,KAAK,EAAE,CAAC;gBAClC,KAAK,CAAC,KAAK,CAAC,GAAG,UAAU,CAAC,YAAY,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,IAAA,eAAI,EAAC,KAAK,CAAC,mBAAmB,CAAC,CAAC;YACrF,CAAC;QACF,CAAC;IACF,CAAC;IAED,MAAM,aAAa,GAAG,UAAU,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAC3D,KAAK,CAAC,WAAW,CAAC,eAAe,EAAE,UAAU,CAAC,CAC9C,CAAC;IAEF,OAAO;QACN,OAAO;QACP,wDAAwD;QACxD,WAAW,EAAE,eAAe,CAAC,YAAwB;QACrD,MAAM,EAAE,aAAa;QACrB,IAAI,EAAE,MAAuB;KAC7B,CAAC;AACH,CAAC;AA5ED,gEA4EC;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAsB,KAAK;CA4B1B;AA5BD,sBA4BC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { fail } from \"@fluidframework/core-utils/internal\";\nimport type { TreeValue } from \"../../../core/index.js\";\nimport type { FluidSerializableReadOnly } from \"../../valueUtilities.js\";\n\nimport {\n\tCounter,\n\ttype CounterFilter,\n\ttype DeduplicationTable,\n\tjsonMinimizingFilter,\n} from \"./chunkCodecUtilities.js\";\nimport type { EncodedFieldBatchGeneric } from \"./formatGeneric.js\";\n\n/**\n * An identifier which can be compressed using {@link Counter}.\n *\n * @remarks\n * Compression of Identifiers is done after the output is otherwise generated to enable counting all the usages.\n * To avoid having to decode the decode the data array to determine which data is an identifier and which is some other string,\n * some recognizable representation is required.\n * Using a class and checking its prototype works for this, and is why IdentifierToken is a class.\n */\nexport class IdentifierToken {\n\tpublic constructor(public readonly identifier: string) {}\n}\n\n/**\n * Format for data emitted during encoding, before dictionary compression of identifiers.\n *\n * @remarks\n * These buffers are mutated after construction if they contain identifiers or shapes.\n */\nexport type BufferFormat<TEncodedShape> = (\n\t| FluidSerializableReadOnly\n\t| Shape<TEncodedShape>\n\t| IdentifierToken\n\t| BufferFormat<TEncodedShape>\n)[];\n\n/**\n * Replace shapes and identifiers in buffer and any nested arrays.\n *\n * This looks inside nested arrays (including transitively) but not inside objects.\n *\n * Note that this modifies `buffer` to avoid having to copy it.\n */\nexport function handleShapesAndIdentifiers<TEncodedShape>(\n\tversion: number,\n\tbuffer: BufferFormat<TEncodedShape>[],\n\tidentifierFilter: CounterFilter<string> = jsonMinimizingFilter,\n): EncodedFieldBatchGeneric<TEncodedShape> {\n\tconst identifiers = new Counter<string>();\n\tconst shapes = new Counter<Shape<TEncodedShape>>();\n\t// Shapes can reference other shapes (and identifiers), so we need to traverse the shape graph.\n\t// These collections enable that.\n\tconst shapesSeen = new Set<Shape<TEncodedShape>>();\n\tconst shapeToCount: Shape<TEncodedShape>[] = [];\n\tconst shapeDiscovered = (shape: Shape<TEncodedShape>): void => {\n\t\tshapes.add(shape);\n\t\tif (!shapesSeen.has(shape)) {\n\t\t\tshapesSeen.add(shape);\n\t\t\tshapeToCount.push(shape);\n\t\t}\n\t};\n\n\tconst arrays: BufferFormat<TEncodedShape>[] = [buffer];\n\tfor (const array of arrays) {\n\t\tfor (const item of array) {\n\t\t\tif (item instanceof IdentifierToken) {\n\t\t\t\tidentifiers.add(item.identifier);\n\t\t\t} else if (item instanceof Shape) {\n\t\t\t\tshapeDiscovered(item);\n\t\t\t} else if (Array.isArray(item)) {\n\t\t\t\t// In JS it is legal to push items to an array which is being iterated,\n\t\t\t\t// and they will be visited in order.\n\t\t\t\tarrays.push(item);\n\t\t\t} else if (\n\t\t\t\titem !== null &&\n\t\t\t\ttypeof item === \"object\" &&\n\t\t\t\t(item as Record<string, unknown>).shape instanceof Shape\n\t\t\t) {\n\t\t\t\t// because \"serializable\" is allowed in buffer and it has type `any`, its very easy to mess up including of shapes in the buffer.\n\t\t\t\t// This catches the easiest way to get it wrong.\n\t\t\t\tfail(0xb4b /* encoder interface instead of shape written to stream */);\n\t\t\t}\n\t\t}\n\t}\n\n\t// Traverse shape graph, discovering and counting all shape to shape and shape to identifier references.\n\t{\n\t\tlet item: Shape<TEncodedShape> | undefined;\n\t\twhile ((item = shapeToCount.pop()) !== undefined) {\n\t\t\titem.count(identifiers, shapeDiscovered);\n\t\t}\n\t}\n\n\t// Determine substitutions for identifiers and shapes:\n\tconst identifierTable = identifiers.buildTable(identifierFilter);\n\tconst shapeTable = shapes.buildTable();\n\n\tfor (const array of arrays) {\n\t\tfor (let index = 0; index < array.length; index++) {\n\t\t\tconst item = array[index];\n\t\t\tif (item instanceof IdentifierToken) {\n\t\t\t\tarray[index] = identifierTable.valueToIndex.get(item.identifier) ?? item.identifier;\n\t\t\t} else if (item instanceof Shape) {\n\t\t\t\tarray[index] = shapeTable.valueToIndex.get(item) ?? fail(0xb4c /* missing shape */);\n\t\t\t}\n\t\t}\n\t}\n\n\tconst encodedShapes = shapeTable.indexToValue.map((shape) =>\n\t\tshape.encodeShape(identifierTable, shapeTable),\n\t);\n\n\treturn {\n\t\tversion,\n\t\t// TODO: fix readonly typing issues to remove this cast.\n\t\tidentifiers: identifierTable.indexToValue as string[],\n\t\tshapes: encodedShapes,\n\t\tdata: buffer as TreeValue[][],\n\t};\n}\n\n/**\n * A tree shape.\n * This similar to a schema for a tree, though it may be more or less specific than the actual schema system used.\n * Can be encoded into a `TEncodedShape`: when doing so encodes references to shapes (if needed) using {@link Counter}:\n * this can include recursive references (direct or indirect).\n *\n * @remarks\n * Deduplication of shapes is done after the output is otherwise generated (including identifier dictionary encoding).\n * To avoid having to decode the data array to determine which data is a shape and which is some other object,\n * some recognizable representation is required.\n * Using a class and checking its prototype works for this, and is why Shape is a class.\n *\n * Note that deduplication compares shapes by object identity not by content, so encoders must ensure shapes are not duplicated to achieve efficient encoding.\n * Comparison by content would be difficult due to shape containing references to other shapes.\n *\n * @privateRemarks\n * Unlike with identifiers, conversion from the initial form (this class / IdentifierToken) is done by the `encodeShape` method, not by general purpose logic in `handleShapesAndIdentifiers`.\n * For `handleShapesAndIdentifiers` to do the conversion without help from `encodeShape`,\n * instances of this Shape class would have to either be or output an object that is identical to the `TEncodedShape` format except with all shape references as object references instead of indexes.\n * Those objects would have to be deeply traversed looking for shape objects to replace with reference indexes.\n * This is possible, but making it type safe would involve generating derived types from the `TEncodedShape` deeply replacing any shape references, as well as requiring deep traversal of all objects in the encoded output.\n * Such an approach seemed less maintainable and readable than the design taken here which avoids the need for those derived types.\n */\nexport abstract class Shape<TEncodedShape> {\n\t/**\n\t * Count this shape's contents.\n\t *\n\t * Used to discover referenced shapes (to ensure they are included in the `shapes` passed to `encodeShape`),\n\t * as well as count usages of shapes and identifiers for more efficient dictionary encoding. See {@link Counter}.\n\t *\n\t * @param shapes - must be invoked with each directly referenced shape (which must provided to `encodeShape`).\n\t * Can be invoked multiple times if a shape is referenced more than once for more efficient dictionary encoding.\n\t * Should not be invoked with `this` unless this shape references itself.\n\t */\n\tpublic abstract count(\n\t\tidentifiers: Counter<string>,\n\t\tshapes: (shape: Shape<TEncodedShape>) => void,\n\t): void;\n\n\t/**\n\t * Produce the final encoded format for this shape.\n\t *\n\t * @param identifiers - a subset of identifiers used in this tree, and their corresponding indexes to use for the dictionary encoding.\n\t * Can be used to encode identifiers referenced by this shape.\n\t * @param shapes - includes a superset of shapes reported by count.\n\t * Used to encode references to shapes as numbers.\n\t */\n\tpublic abstract encodeShape(\n\t\tidentifiers: DeduplicationTable<string>,\n\t\tshapes: DeduplicationTable<Shape<TEncodedShape>>,\n\t): TEncodedShape;\n}\n"]}
@@ -147,7 +147,7 @@ class InlineArrayShape extends chunkEncodingGeneric_js_1.Shape {
147
147
  return {
148
148
  b: {
149
149
  length: this.length,
150
- shape: shapes.valueToIndex.get(this.inner.shape) ?? (0, index_js_2.fail)(0xb4e /* missing shape */),
150
+ shape: shapes.valueToIndex.get(this.inner.shape) ?? (0, internal_1.fail)(0xb4e /* missing shape */),
151
151
  },
152
152
  };
153
153
  }
@@ -165,7 +165,7 @@ InlineArrayShape.empty = new InlineArrayShape(0, {
165
165
  return InlineArrayShape.empty;
166
166
  },
167
167
  encodeNodes(cursor, shapes, outputBuffer) {
168
- (0, index_js_2.fail)(0xb4d /* Empty array should not encode any nodes */);
168
+ (0, internal_1.fail)(0xb4d /* Empty array should not encode any nodes */);
169
169
  },
170
170
  });
171
171
  /**
@@ -198,7 +198,7 @@ class NestedArrayShape extends chunkEncodingGeneric_js_1.Shape {
198
198
  }
199
199
  encodeShape(identifiers, shapes) {
200
200
  const shape = shapes.valueToIndex.get(this.inner.shape) ??
201
- (0, index_js_2.fail)(0xb4f /* index for shape not found in table */);
201
+ (0, internal_1.fail)(0xb4f /* index for shape not found in table */);
202
202
  return {
203
203
  a: shape,
204
204
  };
@@ -1 +1 @@
1
- {"version":3,"file":"compressedEncode.js","sourceRoot":"","sources":["../../../../src/feature-libraries/chunked-forest/codec/compressedEncode.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAA8E;AAE9E,qDASgC;AAChC,qDAA2D;AAI3D,uEAImC;AAEnC,2CAQqB;AAGrB;;;;;;GAMG;AACH,SAAgB,gBAAgB,CAC/B,UAAsB,EACtB,KAAmB;IAEnB,MAAM,WAAW,GAAmB,EAAE,CAAC;IAEvC,6DAA6D;IAC7D,KAAK,MAA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AK,CAAC;IAC3B,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, unreachableCase } from \"@fluidframework/core-utils/internal\";\n\nimport {\n\tCursorLocationType,\n\ttype FieldKey,\n\ttype FieldKindIdentifier,\n\ttype ITreeCursorSynchronous,\n\ttype TreeFieldStoredSchema,\n\ttype TreeNodeSchemaIdentifier,\n\ttype Value,\n\tforEachNode,\n} from \"../../../core/index.js\";\nimport { fail, getOrCreate } from \"../../../util/index.js\";\nimport type { FlexFieldKind } from \"../../modular-schema/index.js\";\n\nimport type { Counter, DeduplicationTable } from \"./chunkCodecUtilities.js\";\nimport {\n\ttype BufferFormat as BufferFormatGeneric,\n\tShape as ShapeGeneric,\n\thandleShapesAndIdentifiers,\n} from \"./chunkEncodingGeneric.js\";\nimport type { FieldBatch } from \"./fieldBatch.js\";\nimport {\n\ttype EncodedAnyShape,\n\ttype EncodedChunkShape,\n\ttype EncodedFieldBatch,\n\ttype EncodedNestedArray,\n\ttype EncodedValueShape,\n\tSpecialField,\n\tversion,\n} from \"./format.js\";\nimport type { IIdCompressor } from \"@fluidframework/id-compressor\";\n\n/**\n * Encode data from `FieldBatch` into an `EncodedChunk`.\n *\n * Optimized for encoded size and encoding performance.\n *\n * Most of the compression strategy comes from the policy provided via `cache`.\n */\nexport function compressedEncode(\n\tfieldBatch: FieldBatch,\n\tcache: EncoderCache,\n): EncodedFieldBatch {\n\tconst batchBuffer: BufferFormat[] = [];\n\n\t// Populate buffer, including shape and identifier references\n\tfor (const cursor of fieldBatch) {\n\t\tconst buffer: BufferFormat = [];\n\t\tanyFieldEncoder.encodeField(cursor, cache, buffer);\n\t\tbatchBuffer.push(buffer);\n\t}\n\treturn handleShapesAndIdentifiers(version, batchBuffer);\n}\n\nexport type BufferFormat = BufferFormatGeneric<EncodedChunkShape>;\nexport type Shape = ShapeGeneric<EncodedChunkShape>;\n\n/**\n * Like {@link FieldEncoder}, except data will be prefixed with the key.\n */\nexport interface KeyedFieldEncoder {\n\treadonly key: FieldKey;\n\treadonly shape: FieldEncoder;\n}\n\n/**\n * An encoder with an associated shape.\n */\nexport interface Encoder {\n\t/**\n\t * The shape which describes how the encoded data is laid out.\n\t * Used by decoders to interpret the output of `encodeNode`.\n\t */\n\treadonly shape: Shape;\n}\n\n/**\n * An encoder for a specific shape of node.\n *\n * Can only be used with compatible nodes.\n */\nexport interface NodeEncoder extends Encoder {\n\t/**\n\t * @param cursor - in Nodes mode. Does not move cursor.\n\t */\n\tencodeNode(\n\t\tcursor: ITreeCursorSynchronous,\n\t\tcache: EncoderCache,\n\t\toutputBuffer: BufferFormat,\n\t): void;\n}\n\n/**\n * Like {@link NodeEncoder}, except encodes a run of nodes.\n */\nexport interface NodesEncoder extends Encoder {\n\t/**\n\t * @param cursor - in Nodes mode. Moves cursor however many nodes it encodes.\n\t */\n\tencodeNodes(\n\t\tcursor: ITreeCursorSynchronous,\n\t\tcache: EncoderCache,\n\t\toutputBuffer: BufferFormat,\n\t): void;\n}\n\n/**\n * Like {@link NodeEncoder}, except encodes a field.\n */\nexport interface FieldEncoder extends Encoder {\n\t/**\n\t * @param cursor - in Fields mode. Encodes entire field.\n\t */\n\tencodeField(\n\t\tcursor: ITreeCursorSynchronous,\n\t\tcache: EncoderCache,\n\t\toutputBuffer: BufferFormat,\n\t): void;\n}\n\n/**\n * Makes a {@link FieldEncoder} which runs `encoder` on every node in the field.\n * This does not encode the number nodes: the user of this may need to encode that elsewhere.\n */\nexport function asFieldEncoder(encoder: NodeEncoder): FieldEncoder {\n\treturn {\n\t\tencodeField(\n\t\t\tcursor: ITreeCursorSynchronous,\n\t\t\tshapes: EncoderCache,\n\t\t\toutputBuffer: BufferFormat,\n\t\t): void {\n\t\t\tforEachNode(cursor, () => encoder.encodeNode(cursor, shapes, outputBuffer));\n\t\t},\n\t\tshape: encoder.shape,\n\t};\n}\n\n/**\n * Adapt a {@link NodeEncoder} to a {@link NodesEncoder} which invokes `encoder` once.\n */\nexport function asNodesEncoder(encoder: NodeEncoder): NodesEncoder {\n\treturn {\n\t\tencodeNodes(\n\t\t\tcursor: ITreeCursorSynchronous,\n\t\t\tshapes: EncoderCache,\n\t\t\toutputBuffer: BufferFormat,\n\t\t): void {\n\t\t\tencoder.encodeNode(cursor, shapes, outputBuffer);\n\t\t\tcursor.nextNode();\n\t\t},\n\t\tshape: encoder.shape,\n\t};\n}\n\n/**\n * Encodes a chunk with {@link EncodedAnyShape} by prefixing the data with its shape.\n */\nexport class AnyShape extends ShapeGeneric<EncodedChunkShape> {\n\tprivate constructor() {\n\t\tsuper();\n\t}\n\tpublic static readonly instance = new AnyShape();\n\n\tpublic encodeShape(\n\t\tidentifiers: DeduplicationTable<string>,\n\t\tshapes: DeduplicationTable<Shape>,\n\t): EncodedChunkShape {\n\t\tconst encodedAnyShape: EncodedAnyShape = 0;\n\t\treturn { d: encodedAnyShape };\n\t}\n\n\tpublic count(identifiers: Counter<string>, shapes: (shape: Shape) => void): void {}\n\n\tpublic static encodeField(\n\t\tcursor: ITreeCursorSynchronous,\n\t\tcache: EncoderCache,\n\t\toutputBuffer: BufferFormat,\n\t\tshape: FieldEncoder,\n\t): void {\n\t\toutputBuffer.push(shape.shape);\n\t\tshape.encodeField(cursor, cache, outputBuffer);\n\t}\n\n\tpublic static encodeNode(\n\t\tcursor: ITreeCursorSynchronous,\n\t\tcache: EncoderCache,\n\t\toutputBuffer: BufferFormat,\n\t\tshape: NodeEncoder,\n\t): void {\n\t\toutputBuffer.push(shape.shape);\n\t\tshape.encodeNode(cursor, cache, outputBuffer);\n\t}\n\n\tpublic static encodeNodes(\n\t\tcursor: ITreeCursorSynchronous,\n\t\tcache: EncoderCache,\n\t\toutputBuffer: BufferFormat,\n\t\tshape: NodesEncoder,\n\t): void {\n\t\toutputBuffer.push(shape.shape);\n\t\tshape.encodeNodes(cursor, cache, outputBuffer);\n\t}\n}\n\n/**\n * Encodes a single node polymorphically.\n */\nexport const anyNodeEncoder: NodeEncoder = {\n\tencodeNode(\n\t\tcursor: ITreeCursorSynchronous,\n\t\tcache: EncoderCache,\n\t\toutputBuffer: BufferFormat,\n\t): void {\n\t\t// TODO: Fast path uniform chunk content.\n\t\tconst shape = cache.shapeFromTree(cursor.type);\n\t\tAnyShape.encodeNode(cursor, cache, outputBuffer, shape);\n\t},\n\n\tshape: AnyShape.instance,\n};\n\n/**\n * Encodes a field polymorphically.\n */\nexport const anyFieldEncoder: FieldEncoder = {\n\tencodeField(\n\t\tcursor: ITreeCursorSynchronous,\n\t\tcache: EncoderCache,\n\t\toutputBuffer: BufferFormat,\n\t): void {\n\t\t// TODO: Fast path uniform chunks.\n\n\t\tif (cursor.getFieldLength() === 0) {\n\t\t\tconst shape = InlineArrayShape.empty;\n\t\t\tAnyShape.encodeField(cursor, cache, outputBuffer, shape);\n\t\t} else if (cursor.getFieldLength() === 1) {\n\t\t\t// Fast path chunk of size one size one at least: skip nested array.\n\t\t\tcursor.enterNode(0);\n\t\t\tanyNodeEncoder.encodeNode(cursor, cache, outputBuffer);\n\t\t\tcursor.exitNode();\n\t\t} else {\n\t\t\t// TODO: more efficient encoding for common cases.\n\t\t\t// Could try to find more specific shape compatible with all children than `anyNodeEncoder`.\n\n\t\t\tconst shape = cache.nestedArray(anyNodeEncoder);\n\t\t\tAnyShape.encodeField(cursor, cache, outputBuffer, shape);\n\t\t}\n\t},\n\n\tshape: AnyShape.instance,\n};\n\n/**\n * Encodes a chunk using {@link EncodedInlineArray}.\n */\nexport class InlineArrayShape\n\textends ShapeGeneric<EncodedChunkShape>\n\timplements NodesEncoder, FieldEncoder\n{\n\tpublic static readonly empty: InlineArrayShape = new InlineArrayShape(0, {\n\t\tget shape() {\n\t\t\t// Not actually used, makes count work without adding an additional shape.\n\t\t\treturn InlineArrayShape.empty;\n\t\t},\n\t\tencodeNodes(\n\t\t\tcursor: ITreeCursorSynchronous,\n\t\t\tshapes: EncoderCache,\n\t\t\toutputBuffer: BufferFormat,\n\t\t): void {\n\t\t\tfail(0xb4d /* Empty array should not encode any nodes */);\n\t\t},\n\t});\n\n\t/**\n\t * @param length - number of invocations of `inner`.\n\t */\n\tpublic constructor(\n\t\tpublic readonly length: number,\n\t\tpublic readonly inner: NodesEncoder,\n\t) {\n\t\tsuper();\n\t}\n\n\tpublic encodeNodes(\n\t\tcursor: ITreeCursorSynchronous,\n\t\tshapes: EncoderCache,\n\t\toutputBuffer: BufferFormat,\n\t): void {\n\t\t// Linter is wrong about this loop being for-of compatible.\n\t\t// eslint-disable-next-line @typescript-eslint/prefer-for-of\n\t\tfor (let index = 0; index < this.length; index++) {\n\t\t\tthis.inner.encodeNodes(cursor, shapes, outputBuffer);\n\t\t}\n\t}\n\n\tpublic encodeField(\n\t\tcursor: ITreeCursorSynchronous,\n\t\tshapes: EncoderCache,\n\t\toutputBuffer: BufferFormat,\n\t): void {\n\t\t// Its possible individual items from this array encode multiple nodes, so don't assume === here.\n\t\tassert(\n\t\t\tcursor.getFieldLength() >= this.length,\n\t\t\t0x73c /* unexpected length for fixed length array */,\n\t\t);\n\t\tcursor.firstNode();\n\t\tthis.encodeNodes(cursor, shapes, outputBuffer);\n\t\tassert(\n\t\t\tcursor.mode === CursorLocationType.Fields,\n\t\t\t0x73d /* should return to fields mode when finished encoding */,\n\t\t);\n\t}\n\n\tpublic encodeShape(\n\t\tidentifiers: DeduplicationTable<string>,\n\t\tshapes: DeduplicationTable<Shape>,\n\t): EncodedChunkShape {\n\t\treturn {\n\t\t\tb: {\n\t\t\t\tlength: this.length,\n\t\t\t\tshape: shapes.valueToIndex.get(this.inner.shape) ?? fail(0xb4e /* missing shape */),\n\t\t\t},\n\t\t};\n\t}\n\n\tpublic count(identifiers: Counter<string>, shapes: (shape: Shape) => void): void {\n\t\tshapes(this.inner.shape);\n\t}\n\n\tpublic get shape(): this {\n\t\treturn this;\n\t}\n}\n\n/**\n * Encodes a field as a nested array with the {@link EncodedNestedArray} shape.\n */\nexport class NestedArrayShape extends ShapeGeneric<EncodedChunkShape> implements FieldEncoder {\n\tpublic readonly shape: Shape;\n\n\tpublic constructor(public readonly inner: NodeEncoder) {\n\t\tsuper();\n\t\tthis.shape = this;\n\t}\n\n\tpublic encodeField(\n\t\tcursor: ITreeCursorSynchronous,\n\t\tcache: EncoderCache,\n\t\toutputBuffer: BufferFormat,\n\t): void {\n\t\tconst buffer: BufferFormat = [];\n\t\tlet allNonZeroSize = true;\n\t\tconst length = cursor.getFieldLength();\n\t\tforEachNode(cursor, () => {\n\t\t\tconst before = buffer.length;\n\t\t\tthis.inner.encodeNode(cursor, cache, buffer);\n\t\t\tallNonZeroSize &&= buffer.length - before !== 0;\n\t\t});\n\t\tif (buffer.length === 0) {\n\t\t\t// This relies on the number of inner chunks being the same as the number of nodes.\n\t\t\t// If making inner a `NodesEncoder`, this code will have to be adjusted accordingly.\n\t\t\toutputBuffer.push(length);\n\t\t} else {\n\t\t\tassert(\n\t\t\t\tallNonZeroSize,\n\t\t\t\t0x73e /* either all or none of the members of a nested array must be 0 sized, or there is no way the decoder could process the content correctly. */,\n\t\t\t);\n\t\t\toutputBuffer.push(buffer);\n\t\t}\n\t}\n\n\tpublic encodeShape(\n\t\tidentifiers: DeduplicationTable<string>,\n\t\tshapes: DeduplicationTable<Shape>,\n\t): EncodedChunkShape {\n\t\tconst shape: EncodedNestedArray =\n\t\t\tshapes.valueToIndex.get(this.inner.shape) ??\n\t\t\tfail(0xb4f /* index for shape not found in table */);\n\t\treturn {\n\t\t\ta: shape,\n\t\t};\n\t}\n\n\tpublic count(identifiers: Counter<string>, shapes: (shape: Shape) => void): void {\n\t\tshapes(this.inner.shape);\n\t}\n}\n\n/**\n * Encode `value` with `shape` into `outputBuffer`.\n *\n * Requires that `value` is compatible with `shape`.\n */\nexport function encodeValue(\n\tvalue: Value,\n\tshape: EncodedValueShape,\n\toutputBuffer: BufferFormat,\n): void {\n\tif (shape === undefined) {\n\t\tif (value !== undefined) {\n\t\t\toutputBuffer.push(true, value);\n\t\t} else {\n\t\t\toutputBuffer.push(false);\n\t\t}\n\t} else {\n\t\tif (shape === true) {\n\t\t\tassert(value !== undefined, 0x78d /* required value must not be missing */);\n\t\t\toutputBuffer.push(value);\n\t\t} else if (shape === false) {\n\t\t\tassert(value === undefined, 0x73f /* incompatible value shape: expected no value */);\n\t\t} else if (Array.isArray(shape)) {\n\t\t\tassert(shape.length === 1, 0x740 /* expected a single constant for value */);\n\t\t} else if (shape === SpecialField.Identifier) {\n\t\t\t// This case is a special case handling the encoding of identifier fields.\n\t\t\tassert(value !== undefined, 0x998 /* required value must not be missing */);\n\t\t\toutputBuffer.push(value);\n\t\t} else {\n\t\t\t// EncodedCounter case:\n\t\t\tunreachableCase(shape, \"Encoding values as deltas is not yet supported\");\n\t\t}\n\t}\n}\n\nexport class EncoderCache implements TreeShaper, FieldShaper {\n\tprivate readonly shapesFromSchema: Map<TreeNodeSchemaIdentifier, NodeEncoder> = new Map();\n\tprivate readonly nestedArrays: Map<NodeEncoder, NestedArrayShape> = new Map();\n\tpublic constructor(\n\t\tprivate readonly treeEncoder: TreeShapePolicy,\n\t\tprivate readonly fieldEncoder: FieldShapePolicy,\n\t\tpublic readonly fieldShapes: ReadonlyMap<FieldKindIdentifier, FlexFieldKind>,\n\t\tpublic readonly idCompressor: IIdCompressor,\n\t) {}\n\n\tpublic shapeFromTree(schemaName: TreeNodeSchemaIdentifier): NodeEncoder {\n\t\treturn getOrCreate(this.shapesFromSchema, schemaName, () =>\n\t\t\tthis.treeEncoder(this, schemaName),\n\t\t);\n\t}\n\n\tpublic nestedArray(inner: NodeEncoder): NestedArrayShape {\n\t\treturn getOrCreate(this.nestedArrays, inner, () => new NestedArrayShape(inner));\n\t}\n\n\tpublic shapeFromField(field: TreeFieldStoredSchema): FieldEncoder {\n\t\treturn new LazyFieldEncoder(this, field, this.fieldEncoder);\n\t}\n}\n\nexport interface TreeShaper {\n\tshapeFromTree(schemaName: TreeNodeSchemaIdentifier): NodeEncoder;\n}\n\nexport interface FieldShaper {\n\tshapeFromField(field: TreeFieldStoredSchema): FieldEncoder;\n}\n\nexport type FieldShapePolicy = (\n\ttreeShaper: TreeShaper,\n\tfield: TreeFieldStoredSchema,\n) => FieldEncoder;\n\nexport type TreeShapePolicy = (\n\tfieldShaper: FieldShaper,\n\tschemaName: TreeNodeSchemaIdentifier,\n) => NodeEncoder;\n\nclass LazyFieldEncoder implements FieldEncoder {\n\tprivate encoderLazy: FieldEncoder | undefined;\n\n\tpublic constructor(\n\t\tpublic readonly cache: TreeShaper,\n\t\tpublic readonly field: TreeFieldStoredSchema,\n\t\tprivate readonly fieldEncoder: FieldShapePolicy,\n\t) {}\n\tpublic encodeField(\n\t\tcursor: ITreeCursorSynchronous,\n\t\tcache: EncoderCache,\n\t\toutputBuffer: BufferFormat,\n\t): void {\n\t\tthis.encoder.encodeField(cursor, cache, outputBuffer);\n\t}\n\n\tprivate get encoder(): FieldEncoder {\n\t\tif (this.encoderLazy === undefined) {\n\t\t\tthis.encoderLazy = this.fieldEncoder(this.cache, this.field);\n\t\t}\n\t\treturn this.encoderLazy;\n\t}\n\n\tpublic get shape(): Shape {\n\t\treturn this.encoder.shape;\n\t}\n}\n"]}
1
+ {"version":3,"file":"compressedEncode.js","sourceRoot":"","sources":["../../../../src/feature-libraries/chunked-forest/codec/compressedEncode.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAAoF;AAEpF,qDASgC;AAChC,qDAAqD;AAIrD,uEAImC;AAEnC,2CAQqB;AAGrB;;;;;;GAMG;AACH,SAAgB,gBAAgB,CAC/B,UAAsB,EACtB,KAAmB;IAEnB,MAAM,WAAW,GAAmB,EAAE,CAAC;IAEvC,6DAA6D;IAC7D,KAAK,MAAM,MAAM,IAAI,UAAU,EAAE,CAAC;QACjC,MAAM,MAAM,GAAiB,EAAE,CAAC;QAChC,uBAAe,CAAC,WAAW,CAAC,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC;QACnD,WAAW,CAAC,IAAI,CAAC,MAAM,C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BAAgB,EAAE,UAAU,EAAE,GAAG,EAAE,CAC1D,IAAI,CAAC,WAAW,CAAC,IAAI,EAAE,UAAU,CAAC,CAClC,CAAC;IACH,CAAC;IAEM,WAAW,CAAC,KAAkB;QACpC,OAAO,IAAA,sBAAW,EAAC,IAAI,CAAC,YAAY,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,IAAI,gBAAgB,CAAC,KAAK,CAAC,CAAC,CAAC;IACjF,CAAC;IAEM,cAAc,CAAC,KAA4B;QACjD,OAAO,IAAI,gBAAgB,CAAC,IAAI,EAAE,KAAK,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC;IAC7D,CAAC;CACD;AAvBD,oCAuBC;AAoBD,MAAM,gBAAgB;IAGrB,YACiB,KAAiB,EACjB,KAA4B,EAC3B,YAA8B;QAF/B,UAAK,GAAL,KAAK,CAAY;QACjB,UAAK,GAAL,KAAK,CAAuB;QAC3B,iBAAY,GAAZ,YAAY,CAAkB;IAC7C,CAAC;IACG,WAAW,CACjB,MAA8B,EAC9B,KAAmB,EACnB,YAA0B;QAE1B,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,MAAM,EAAE,KAAK,EAAE,YAAY,CAAC,CAAC;IACvD,CAAC;IAED,IAAY,OAAO;QAClB,IAAI,IAAI,CAAC,WAAW,KAAK,SAAS,EAAE,CAAC;YACpC,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC;QAC9D,CAAC;QACD,OAAO,IAAI,CAAC,WAAW,CAAC;IACzB,CAAC;IAED,IAAW,KAAK;QACf,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC;IAC3B,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, unreachableCase, fail } from \"@fluidframework/core-utils/internal\";\n\nimport {\n\tCursorLocationType,\n\ttype FieldKey,\n\ttype FieldKindIdentifier,\n\ttype ITreeCursorSynchronous,\n\ttype TreeFieldStoredSchema,\n\ttype TreeNodeSchemaIdentifier,\n\ttype Value,\n\tforEachNode,\n} from \"../../../core/index.js\";\nimport { getOrCreate } from \"../../../util/index.js\";\nimport type { FlexFieldKind } from \"../../modular-schema/index.js\";\n\nimport type { Counter, DeduplicationTable } from \"./chunkCodecUtilities.js\";\nimport {\n\ttype BufferFormat as BufferFormatGeneric,\n\tShape as ShapeGeneric,\n\thandleShapesAndIdentifiers,\n} from \"./chunkEncodingGeneric.js\";\nimport type { FieldBatch } from \"./fieldBatch.js\";\nimport {\n\ttype EncodedAnyShape,\n\ttype EncodedChunkShape,\n\ttype EncodedFieldBatch,\n\ttype EncodedNestedArray,\n\ttype EncodedValueShape,\n\tSpecialField,\n\tversion,\n} from \"./format.js\";\nimport type { IIdCompressor } from \"@fluidframework/id-compressor\";\n\n/**\n * Encode data from `FieldBatch` into an `EncodedChunk`.\n *\n * Optimized for encoded size and encoding performance.\n *\n * Most of the compression strategy comes from the policy provided via `cache`.\n */\nexport function compressedEncode(\n\tfieldBatch: FieldBatch,\n\tcache: EncoderCache,\n): EncodedFieldBatch {\n\tconst batchBuffer: BufferFormat[] = [];\n\n\t// Populate buffer, including shape and identifier references\n\tfor (const cursor of fieldBatch) {\n\t\tconst buffer: BufferFormat = [];\n\t\tanyFieldEncoder.encodeField(cursor, cache, buffer);\n\t\tbatchBuffer.push(buffer);\n\t}\n\treturn handleShapesAndIdentifiers(version, batchBuffer);\n}\n\nexport type BufferFormat = BufferFormatGeneric<EncodedChunkShape>;\nexport type Shape = ShapeGeneric<EncodedChunkShape>;\n\n/**\n * Like {@link FieldEncoder}, except data will be prefixed with the key.\n */\nexport interface KeyedFieldEncoder {\n\treadonly key: FieldKey;\n\treadonly shape: FieldEncoder;\n}\n\n/**\n * An encoder with an associated shape.\n */\nexport interface Encoder {\n\t/**\n\t * The shape which describes how the encoded data is laid out.\n\t * Used by decoders to interpret the output of `encodeNode`.\n\t */\n\treadonly shape: Shape;\n}\n\n/**\n * An encoder for a specific shape of node.\n *\n * Can only be used with compatible nodes.\n */\nexport interface NodeEncoder extends Encoder {\n\t/**\n\t * @param cursor - in Nodes mode. Does not move cursor.\n\t */\n\tencodeNode(\n\t\tcursor: ITreeCursorSynchronous,\n\t\tcache: EncoderCache,\n\t\toutputBuffer: BufferFormat,\n\t): void;\n}\n\n/**\n * Like {@link NodeEncoder}, except encodes a run of nodes.\n */\nexport interface NodesEncoder extends Encoder {\n\t/**\n\t * @param cursor - in Nodes mode. Moves cursor however many nodes it encodes.\n\t */\n\tencodeNodes(\n\t\tcursor: ITreeCursorSynchronous,\n\t\tcache: EncoderCache,\n\t\toutputBuffer: BufferFormat,\n\t): void;\n}\n\n/**\n * Like {@link NodeEncoder}, except encodes a field.\n */\nexport interface FieldEncoder extends Encoder {\n\t/**\n\t * @param cursor - in Fields mode. Encodes entire field.\n\t */\n\tencodeField(\n\t\tcursor: ITreeCursorSynchronous,\n\t\tcache: EncoderCache,\n\t\toutputBuffer: BufferFormat,\n\t): void;\n}\n\n/**\n * Makes a {@link FieldEncoder} which runs `encoder` on every node in the field.\n * This does not encode the number nodes: the user of this may need to encode that elsewhere.\n */\nexport function asFieldEncoder(encoder: NodeEncoder): FieldEncoder {\n\treturn {\n\t\tencodeField(\n\t\t\tcursor: ITreeCursorSynchronous,\n\t\t\tshapes: EncoderCache,\n\t\t\toutputBuffer: BufferFormat,\n\t\t): void {\n\t\t\tforEachNode(cursor, () => encoder.encodeNode(cursor, shapes, outputBuffer));\n\t\t},\n\t\tshape: encoder.shape,\n\t};\n}\n\n/**\n * Adapt a {@link NodeEncoder} to a {@link NodesEncoder} which invokes `encoder` once.\n */\nexport function asNodesEncoder(encoder: NodeEncoder): NodesEncoder {\n\treturn {\n\t\tencodeNodes(\n\t\t\tcursor: ITreeCursorSynchronous,\n\t\t\tshapes: EncoderCache,\n\t\t\toutputBuffer: BufferFormat,\n\t\t): void {\n\t\t\tencoder.encodeNode(cursor, shapes, outputBuffer);\n\t\t\tcursor.nextNode();\n\t\t},\n\t\tshape: encoder.shape,\n\t};\n}\n\n/**\n * Encodes a chunk with {@link EncodedAnyShape} by prefixing the data with its shape.\n */\nexport class AnyShape extends ShapeGeneric<EncodedChunkShape> {\n\tprivate constructor() {\n\t\tsuper();\n\t}\n\tpublic static readonly instance = new AnyShape();\n\n\tpublic encodeShape(\n\t\tidentifiers: DeduplicationTable<string>,\n\t\tshapes: DeduplicationTable<Shape>,\n\t): EncodedChunkShape {\n\t\tconst encodedAnyShape: EncodedAnyShape = 0;\n\t\treturn { d: encodedAnyShape };\n\t}\n\n\tpublic count(identifiers: Counter<string>, shapes: (shape: Shape) => void): void {}\n\n\tpublic static encodeField(\n\t\tcursor: ITreeCursorSynchronous,\n\t\tcache: EncoderCache,\n\t\toutputBuffer: BufferFormat,\n\t\tshape: FieldEncoder,\n\t): void {\n\t\toutputBuffer.push(shape.shape);\n\t\tshape.encodeField(cursor, cache, outputBuffer);\n\t}\n\n\tpublic static encodeNode(\n\t\tcursor: ITreeCursorSynchronous,\n\t\tcache: EncoderCache,\n\t\toutputBuffer: BufferFormat,\n\t\tshape: NodeEncoder,\n\t): void {\n\t\toutputBuffer.push(shape.shape);\n\t\tshape.encodeNode(cursor, cache, outputBuffer);\n\t}\n\n\tpublic static encodeNodes(\n\t\tcursor: ITreeCursorSynchronous,\n\t\tcache: EncoderCache,\n\t\toutputBuffer: BufferFormat,\n\t\tshape: NodesEncoder,\n\t): void {\n\t\toutputBuffer.push(shape.shape);\n\t\tshape.encodeNodes(cursor, cache, outputBuffer);\n\t}\n}\n\n/**\n * Encodes a single node polymorphically.\n */\nexport const anyNodeEncoder: NodeEncoder = {\n\tencodeNode(\n\t\tcursor: ITreeCursorSynchronous,\n\t\tcache: EncoderCache,\n\t\toutputBuffer: BufferFormat,\n\t): void {\n\t\t// TODO: Fast path uniform chunk content.\n\t\tconst shape = cache.shapeFromTree(cursor.type);\n\t\tAnyShape.encodeNode(cursor, cache, outputBuffer, shape);\n\t},\n\n\tshape: AnyShape.instance,\n};\n\n/**\n * Encodes a field polymorphically.\n */\nexport const anyFieldEncoder: FieldEncoder = {\n\tencodeField(\n\t\tcursor: ITreeCursorSynchronous,\n\t\tcache: EncoderCache,\n\t\toutputBuffer: BufferFormat,\n\t): void {\n\t\t// TODO: Fast path uniform chunks.\n\n\t\tif (cursor.getFieldLength() === 0) {\n\t\t\tconst shape = InlineArrayShape.empty;\n\t\t\tAnyShape.encodeField(cursor, cache, outputBuffer, shape);\n\t\t} else if (cursor.getFieldLength() === 1) {\n\t\t\t// Fast path chunk of size one size one at least: skip nested array.\n\t\t\tcursor.enterNode(0);\n\t\t\tanyNodeEncoder.encodeNode(cursor, cache, outputBuffer);\n\t\t\tcursor.exitNode();\n\t\t} else {\n\t\t\t// TODO: more efficient encoding for common cases.\n\t\t\t// Could try to find more specific shape compatible with all children than `anyNodeEncoder`.\n\n\t\t\tconst shape = cache.nestedArray(anyNodeEncoder);\n\t\t\tAnyShape.encodeField(cursor, cache, outputBuffer, shape);\n\t\t}\n\t},\n\n\tshape: AnyShape.instance,\n};\n\n/**\n * Encodes a chunk using {@link EncodedInlineArray}.\n */\nexport class InlineArrayShape\n\textends ShapeGeneric<EncodedChunkShape>\n\timplements NodesEncoder, FieldEncoder\n{\n\tpublic static readonly empty: InlineArrayShape = new InlineArrayShape(0, {\n\t\tget shape() {\n\t\t\t// Not actually used, makes count work without adding an additional shape.\n\t\t\treturn InlineArrayShape.empty;\n\t\t},\n\t\tencodeNodes(\n\t\t\tcursor: ITreeCursorSynchronous,\n\t\t\tshapes: EncoderCache,\n\t\t\toutputBuffer: BufferFormat,\n\t\t): void {\n\t\t\tfail(0xb4d /* Empty array should not encode any nodes */);\n\t\t},\n\t});\n\n\t/**\n\t * @param length - number of invocations of `inner`.\n\t */\n\tpublic constructor(\n\t\tpublic readonly length: number,\n\t\tpublic readonly inner: NodesEncoder,\n\t) {\n\t\tsuper();\n\t}\n\n\tpublic encodeNodes(\n\t\tcursor: ITreeCursorSynchronous,\n\t\tshapes: EncoderCache,\n\t\toutputBuffer: BufferFormat,\n\t): void {\n\t\t// Linter is wrong about this loop being for-of compatible.\n\t\t// eslint-disable-next-line @typescript-eslint/prefer-for-of\n\t\tfor (let index = 0; index < this.length; index++) {\n\t\t\tthis.inner.encodeNodes(cursor, shapes, outputBuffer);\n\t\t}\n\t}\n\n\tpublic encodeField(\n\t\tcursor: ITreeCursorSynchronous,\n\t\tshapes: EncoderCache,\n\t\toutputBuffer: BufferFormat,\n\t): void {\n\t\t// Its possible individual items from this array encode multiple nodes, so don't assume === here.\n\t\tassert(\n\t\t\tcursor.getFieldLength() >= this.length,\n\t\t\t0x73c /* unexpected length for fixed length array */,\n\t\t);\n\t\tcursor.firstNode();\n\t\tthis.encodeNodes(cursor, shapes, outputBuffer);\n\t\tassert(\n\t\t\tcursor.mode === CursorLocationType.Fields,\n\t\t\t0x73d /* should return to fields mode when finished encoding */,\n\t\t);\n\t}\n\n\tpublic encodeShape(\n\t\tidentifiers: DeduplicationTable<string>,\n\t\tshapes: DeduplicationTable<Shape>,\n\t): EncodedChunkShape {\n\t\treturn {\n\t\t\tb: {\n\t\t\t\tlength: this.length,\n\t\t\t\tshape: shapes.valueToIndex.get(this.inner.shape) ?? fail(0xb4e /* missing shape */),\n\t\t\t},\n\t\t};\n\t}\n\n\tpublic count(identifiers: Counter<string>, shapes: (shape: Shape) => void): void {\n\t\tshapes(this.inner.shape);\n\t}\n\n\tpublic get shape(): this {\n\t\treturn this;\n\t}\n}\n\n/**\n * Encodes a field as a nested array with the {@link EncodedNestedArray} shape.\n */\nexport class NestedArrayShape extends ShapeGeneric<EncodedChunkShape> implements FieldEncoder {\n\tpublic readonly shape: Shape;\n\n\tpublic constructor(public readonly inner: NodeEncoder) {\n\t\tsuper();\n\t\tthis.shape = this;\n\t}\n\n\tpublic encodeField(\n\t\tcursor: ITreeCursorSynchronous,\n\t\tcache: EncoderCache,\n\t\toutputBuffer: BufferFormat,\n\t): void {\n\t\tconst buffer: BufferFormat = [];\n\t\tlet allNonZeroSize = true;\n\t\tconst length = cursor.getFieldLength();\n\t\tforEachNode(cursor, () => {\n\t\t\tconst before = buffer.length;\n\t\t\tthis.inner.encodeNode(cursor, cache, buffer);\n\t\t\tallNonZeroSize &&= buffer.length - before !== 0;\n\t\t});\n\t\tif (buffer.length === 0) {\n\t\t\t// This relies on the number of inner chunks being the same as the number of nodes.\n\t\t\t// If making inner a `NodesEncoder`, this code will have to be adjusted accordingly.\n\t\t\toutputBuffer.push(length);\n\t\t} else {\n\t\t\tassert(\n\t\t\t\tallNonZeroSize,\n\t\t\t\t0x73e /* either all or none of the members of a nested array must be 0 sized, or there is no way the decoder could process the content correctly. */,\n\t\t\t);\n\t\t\toutputBuffer.push(buffer);\n\t\t}\n\t}\n\n\tpublic encodeShape(\n\t\tidentifiers: DeduplicationTable<string>,\n\t\tshapes: DeduplicationTable<Shape>,\n\t): EncodedChunkShape {\n\t\tconst shape: EncodedNestedArray =\n\t\t\tshapes.valueToIndex.get(this.inner.shape) ??\n\t\t\tfail(0xb4f /* index for shape not found in table */);\n\t\treturn {\n\t\t\ta: shape,\n\t\t};\n\t}\n\n\tpublic count(identifiers: Counter<string>, shapes: (shape: Shape) => void): void {\n\t\tshapes(this.inner.shape);\n\t}\n}\n\n/**\n * Encode `value` with `shape` into `outputBuffer`.\n *\n * Requires that `value` is compatible with `shape`.\n */\nexport function encodeValue(\n\tvalue: Value,\n\tshape: EncodedValueShape,\n\toutputBuffer: BufferFormat,\n): void {\n\tif (shape === undefined) {\n\t\tif (value !== undefined) {\n\t\t\toutputBuffer.push(true, value);\n\t\t} else {\n\t\t\toutputBuffer.push(false);\n\t\t}\n\t} else {\n\t\tif (shape === true) {\n\t\t\tassert(value !== undefined, 0x78d /* required value must not be missing */);\n\t\t\toutputBuffer.push(value);\n\t\t} else if (shape === false) {\n\t\t\tassert(value === undefined, 0x73f /* incompatible value shape: expected no value */);\n\t\t} else if (Array.isArray(shape)) {\n\t\t\tassert(shape.length === 1, 0x740 /* expected a single constant for value */);\n\t\t} else if (shape === SpecialField.Identifier) {\n\t\t\t// This case is a special case handling the encoding of identifier fields.\n\t\t\tassert(value !== undefined, 0x998 /* required value must not be missing */);\n\t\t\toutputBuffer.push(value);\n\t\t} else {\n\t\t\t// EncodedCounter case:\n\t\t\tunreachableCase(shape, \"Encoding values as deltas is not yet supported\");\n\t\t}\n\t}\n}\n\nexport class EncoderCache implements TreeShaper, FieldShaper {\n\tprivate readonly shapesFromSchema: Map<TreeNodeSchemaIdentifier, NodeEncoder> = new Map();\n\tprivate readonly nestedArrays: Map<NodeEncoder, NestedArrayShape> = new Map();\n\tpublic constructor(\n\t\tprivate readonly treeEncoder: TreeShapePolicy,\n\t\tprivate readonly fieldEncoder: FieldShapePolicy,\n\t\tpublic readonly fieldShapes: ReadonlyMap<FieldKindIdentifier, FlexFieldKind>,\n\t\tpublic readonly idCompressor: IIdCompressor,\n\t) {}\n\n\tpublic shapeFromTree(schemaName: TreeNodeSchemaIdentifier): NodeEncoder {\n\t\treturn getOrCreate(this.shapesFromSchema, schemaName, () =>\n\t\t\tthis.treeEncoder(this, schemaName),\n\t\t);\n\t}\n\n\tpublic nestedArray(inner: NodeEncoder): NestedArrayShape {\n\t\treturn getOrCreate(this.nestedArrays, inner, () => new NestedArrayShape(inner));\n\t}\n\n\tpublic shapeFromField(field: TreeFieldStoredSchema): FieldEncoder {\n\t\treturn new LazyFieldEncoder(this, field, this.fieldEncoder);\n\t}\n}\n\nexport interface TreeShaper {\n\tshapeFromTree(schemaName: TreeNodeSchemaIdentifier): NodeEncoder;\n}\n\nexport interface FieldShaper {\n\tshapeFromField(field: TreeFieldStoredSchema): FieldEncoder;\n}\n\nexport type FieldShapePolicy = (\n\ttreeShaper: TreeShaper,\n\tfield: TreeFieldStoredSchema,\n) => FieldEncoder;\n\nexport type TreeShapePolicy = (\n\tfieldShaper: FieldShaper,\n\tschemaName: TreeNodeSchemaIdentifier,\n) => NodeEncoder;\n\nclass LazyFieldEncoder implements FieldEncoder {\n\tprivate encoderLazy: FieldEncoder | undefined;\n\n\tpublic constructor(\n\t\tpublic readonly cache: TreeShaper,\n\t\tpublic readonly field: TreeFieldStoredSchema,\n\t\tprivate readonly fieldEncoder: FieldShapePolicy,\n\t) {}\n\tpublic encodeField(\n\t\tcursor: ITreeCursorSynchronous,\n\t\tcache: EncoderCache,\n\t\toutputBuffer: BufferFormat,\n\t): void {\n\t\tthis.encoder.encodeField(cursor, cache, outputBuffer);\n\t}\n\n\tprivate get encoder(): FieldEncoder {\n\t\tif (this.encoderLazy === undefined) {\n\t\t\tthis.encoderLazy = this.fieldEncoder(this.cache, this.field);\n\t\t}\n\t\treturn this.encoderLazy;\n\t}\n\n\tpublic get shape(): Shape {\n\t\treturn this.encoder.shape;\n\t}\n}\n"]}
@@ -93,7 +93,7 @@ function encodeFieldShapes(fields, identifiers, shapes) {
93
93
  // key
94
94
  encodeIdentifier(field.key, identifiers),
95
95
  // shape
96
- shapes.valueToIndex.get(field.shape.shape) ?? (0, index_js_2.fail)(0xb50 /* missing shape */),
96
+ shapes.valueToIndex.get(field.shape.shape) ?? (0, internal_1.fail)(0xb50 /* missing shape */),
97
97
  ]);
98
98
  }
99
99
  exports.encodeFieldShapes = encodeFieldShapes;
@@ -107,6 +107,6 @@ function encodeOptionalFieldShape(shape, shapes) {
107
107
  return shape === undefined ? undefined : dedupShape(shape.shape, shapes);
108
108
  }
109
109
  function dedupShape(shape, shapes) {
110
- return shapes.valueToIndex.get(shape) ?? (0, index_js_2.fail)(0xb51 /* missing shape */);
110
+ return shapes.valueToIndex.get(shape) ?? (0, internal_1.fail)(0xb51 /* missing shape */);
111
111
  }
112
112
  //# sourceMappingURL=nodeShape.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"nodeShape.js","sourceRoot":"","sources":["../../../../src/feature-libraries/chunked-forest/codec/nodeShape.ts"],"names":[],"mappings":";AAAA;;;GAGG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,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,IAAA,eAAI,EAAC,KAAK,CAAC,mBAAmB,CAAC;KAC7E,CAAC,CAAC;AACJ,CAAC;AAdD,8CAcC;AAED,SAAS,gBAAgB,CACxB,UAAkB,EAClB,WAAuC;IAEvC,OAAO,WAAW,CAAC,YAAY,CAAC,GAAG,CAAC,UAAU,CAAC,IAAI,UAAU,CAAC;AAC/D,CAAC;AAED,SAAS,wBAAwB,CAChC,UAA8B,EAC9B,WAAuC;IAEvC,OAAO,UAAU,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,gBAAgB,CAAC,UAAU,EAAE,WAAW,CAAC,CAAC;AACzF,CAAC;AAED,SAAS,wBAAwB,CAChC,KAA+B,EAC/B,MAAoD;IAEpD,OAAO,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,UAAU,CAAC,KAAK,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;AAC1E,CAAC;AAED,SAAS,UAAU,CAClB,KAA+B,EAC/B,MAAoD;IAEpD,OAAO,MAAM,CAAC,YAAY,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,IAAA,eAAI,EAAC,KAAK,CAAC,mBAAmB,CAAC,CAAC;AAC1E,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\n\nimport {\n\ttype FieldKey,\n\ttype ITreeCursorSynchronous,\n\ttype TreeNodeSchemaIdentifier,\n\tforEachField,\n\ttype Value,\n} from \"../../../core/index.js\";\nimport { brand, fail } from \"../../../util/index.js\";\n\nimport type { Counter, DeduplicationTable } from \"./chunkCodecUtilities.js\";\nimport { type BufferFormat, IdentifierToken, Shape } from \"./chunkEncodingGeneric.js\";\nimport {\n\ttype EncoderCache,\n\ttype FieldEncoder,\n\ttype KeyedFieldEncoder,\n\ttype NodeEncoder,\n\tencodeValue,\n} from \"./compressedEncode.js\";\nimport type { EncodedChunkShape, EncodedFieldShape, EncodedValueShape } from \"./format.js\";\nimport { isStableId } from \"@fluidframework/id-compressor/internal\";\n\nexport class NodeShape extends Shape<EncodedChunkShape> implements NodeEncoder {\n\t// TODO: Ensure uniform chunks, encoding and identifier generation sort fields the same.\n\tprivate readonly explicitKeys: Set<FieldKey>;\n\n\tpublic constructor(\n\t\tpublic readonly type: undefined | TreeNodeSchemaIdentifier,\n\t\tpublic readonly value: EncodedValueShape,\n\t\tpublic readonly fields: readonly KeyedFieldEncoder[],\n\t\tpublic readonly extraLocal: undefined | FieldEncoder,\n\t) {\n\t\tsuper();\n\t\tthis.explicitKeys = new Set(this.fields.map((f) => f.key));\n\t}\n\n\tprivate getValueToEncode(cursor: ITreeCursorSynchronous, cache: EncoderCache): Value {\n\t\tif (this.value === 0) {\n\t\t\tassert(typeof cursor.value === \"string\", 0x9aa /* identifier must be type string */);\n\t\t\tif (isStableId(cursor.value)) {\n\t\t\t\tconst sessionSpaceCompressedId = cache.idCompressor.tryRecompress(cursor.value);\n\t\t\t\tif (sessionSpaceCompressedId !== undefined) {\n\t\t\t\t\treturn cache.idCompressor.normalizeToOpSpace(sessionSpaceCompressedId);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn cursor.value;\n\t}\n\n\tpublic encodeNode(\n\t\tcursor: ITreeCursorSynchronous,\n\t\tcache: EncoderCache,\n\t\toutputBuffer: BufferFormat<EncodedChunkShape>,\n\t): void {\n\t\tif (this.type === undefined) {\n\t\t\toutputBuffer.push(new IdentifierToken(cursor.type));\n\t\t} else {\n\t\t\tassert(cursor.type === this.type, 0x741 /* type must match shape */);\n\t\t}\n\t\tencodeValue(this.getValueToEncode(cursor, cache), this.value, outputBuffer);\n\t\tfor (const field of this.fields) {\n\t\t\tcursor.enterField(brand(field.key));\n\t\t\tfield.shape.encodeField(cursor, cache, outputBuffer);\n\t\t\tcursor.exitField();\n\t\t}\n\n\t\tconst localBuffer: BufferFormat<EncodedChunkShape> = [];\n\n\t\tforEachField(cursor, () => {\n\t\t\tconst key = cursor.getFieldKey();\n\t\t\tif (!this.explicitKeys.has(key)) {\n\t\t\t\tassert(\n\t\t\t\t\tthis.extraLocal !== undefined,\n\t\t\t\t\t0x742 /* had extra local fields when shape does not support them */,\n\t\t\t\t);\n\t\t\t\tlocalBuffer.push(new IdentifierToken(key));\n\t\t\t\tthis.extraLocal.encodeField(cursor, cache, localBuffer);\n\t\t\t}\n\t\t});\n\n\t\tif (this.extraLocal !== undefined) {\n\t\t\toutputBuffer.push(localBuffer);\n\t\t}\n\t}\n\n\tpublic encodeShape(\n\t\tidentifiers: DeduplicationTable<string>,\n\t\tshapes: DeduplicationTable<Shape<EncodedChunkShape>>,\n\t): EncodedChunkShape {\n\t\treturn {\n\t\t\tc: {\n\t\t\t\ttype: encodeOptionalIdentifier(this.type, identifiers),\n\t\t\t\tvalue: this.value,\n\t\t\t\tfields: encodeFieldShapes(this.fields, identifiers, shapes),\n\t\t\t\textraFields: encodeOptionalFieldShape(this.extraLocal, shapes),\n\t\t\t},\n\t\t};\n\t}\n\n\tpublic count(\n\t\tidentifiers: Counter<string>,\n\t\tshapes: (shape: Shape<EncodedChunkShape>) => void,\n\t): void {\n\t\tif (this.type !== undefined) {\n\t\t\tidentifiers.add(this.type);\n\t\t}\n\n\t\tfor (const field of this.fields) {\n\t\t\tidentifiers.add(field.key);\n\t\t\tshapes(field.shape.shape);\n\t\t}\n\n\t\tif (this.extraLocal !== undefined) {\n\t\t\tshapes(this.extraLocal.shape);\n\t\t}\n\t}\n\n\tpublic get shape(): NodeShape {\n\t\treturn this;\n\t}\n}\n\nexport function encodeFieldShapes(\n\tfields: readonly KeyedFieldEncoder[],\n\tidentifiers: DeduplicationTable<string>,\n\tshapes: DeduplicationTable<Shape<EncodedChunkShape>>,\n): EncodedFieldShape[] | undefined {\n\tif (fields.length === 0) {\n\t\treturn undefined;\n\t}\n\treturn fields.map((field) => [\n\t\t// key\n\t\tencodeIdentifier(field.key, identifiers),\n\t\t// shape\n\t\tshapes.valueToIndex.get(field.shape.shape) ?? fail(0xb50 /* missing shape */),\n\t]);\n}\n\nfunction encodeIdentifier(\n\tidentifier: string,\n\tidentifiers: DeduplicationTable<string>,\n): string | number {\n\treturn identifiers.valueToIndex.get(identifier) ?? identifier;\n}\n\nfunction encodeOptionalIdentifier(\n\tidentifier: string | undefined,\n\tidentifiers: DeduplicationTable<string>,\n): string | number | undefined {\n\treturn identifier === undefined ? undefined : encodeIdentifier(identifier, identifiers);\n}\n\nfunction encodeOptionalFieldShape(\n\tshape: FieldEncoder | undefined,\n\tshapes: DeduplicationTable<Shape<EncodedChunkShape>>,\n): number | undefined {\n\treturn shape === undefined ? undefined : dedupShape(shape.shape, shapes);\n}\n\nfunction dedupShape(\n\tshape: Shape<EncodedChunkShape>,\n\tshapes: DeduplicationTable<Shape<EncodedChunkShape>>,\n): number {\n\treturn shapes.valueToIndex.get(shape) ?? fail(0xb51 /* missing shape */);\n}\n"]}
1
+ {"version":3,"file":"nodeShape.js","sourceRoot":"","sources":["../../../../src/feature-libraries/chunked-forest/codec/nodeShape.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAAmE;AAEnE,qDAMgC;AAChC,qDAA+C;AAG/C,uEAAsF;AACtF,+DAM+B;AAE/B,qEAAoE;AAEpE,MAAa,SAAU,SAAQ,+BAAwB;IAItD,YACiB,IAA0C,EAC1C,KAAwB,EACxB,MAAoC,EACpC,UAAoC;QAEpD,KAAK,EAAE,CAAC;QALQ,SAAI,GAAJ,IAAI,CAAsC;QAC1C,UAAK,GAAL,KAAK,CAAmB;QACxB,WAAM,GAAN,MAAM,CAA8B;QACpC,eAAU,GAAV,UAAU,CAA0B;QAGpD,IAAI,CAAC,YAAY,GAAG,IAAI,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG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AChC,KAA+B,EAC/B,MAAoD;IAEpD,OAAO,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,UAAU,CAAC,KAAK,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;AAC1E,CAAC;AAED,SAAS,UAAU,CAClB,KAA+B,EAC/B,MAAoD;IAEpD,OAAO,MAAM,CAAC,YAAY,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,IAAA,eAAI,EAAC,KAAK,CAAC,mBAAmB,CAAC,CAAC;AAC1E,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, fail } from \"@fluidframework/core-utils/internal\";\n\nimport {\n\ttype FieldKey,\n\ttype ITreeCursorSynchronous,\n\ttype TreeNodeSchemaIdentifier,\n\tforEachField,\n\ttype Value,\n} from \"../../../core/index.js\";\nimport { brand } from \"../../../util/index.js\";\n\nimport type { Counter, DeduplicationTable } from \"./chunkCodecUtilities.js\";\nimport { type BufferFormat, IdentifierToken, Shape } from \"./chunkEncodingGeneric.js\";\nimport {\n\ttype EncoderCache,\n\ttype FieldEncoder,\n\ttype KeyedFieldEncoder,\n\ttype NodeEncoder,\n\tencodeValue,\n} from \"./compressedEncode.js\";\nimport type { EncodedChunkShape, EncodedFieldShape, EncodedValueShape } from \"./format.js\";\nimport { isStableId } from \"@fluidframework/id-compressor/internal\";\n\nexport class NodeShape extends Shape<EncodedChunkShape> implements NodeEncoder {\n\t// TODO: Ensure uniform chunks, encoding and identifier generation sort fields the same.\n\tprivate readonly explicitKeys: Set<FieldKey>;\n\n\tpublic constructor(\n\t\tpublic readonly type: undefined | TreeNodeSchemaIdentifier,\n\t\tpublic readonly value: EncodedValueShape,\n\t\tpublic readonly fields: readonly KeyedFieldEncoder[],\n\t\tpublic readonly extraLocal: undefined | FieldEncoder,\n\t) {\n\t\tsuper();\n\t\tthis.explicitKeys = new Set(this.fields.map((f) => f.key));\n\t}\n\n\tprivate getValueToEncode(cursor: ITreeCursorSynchronous, cache: EncoderCache): Value {\n\t\tif (this.value === 0) {\n\t\t\tassert(typeof cursor.value === \"string\", 0x9aa /* identifier must be type string */);\n\t\t\tif (isStableId(cursor.value)) {\n\t\t\t\tconst sessionSpaceCompressedId = cache.idCompressor.tryRecompress(cursor.value);\n\t\t\t\tif (sessionSpaceCompressedId !== undefined) {\n\t\t\t\t\treturn cache.idCompressor.normalizeToOpSpace(sessionSpaceCompressedId);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn cursor.value;\n\t}\n\n\tpublic encodeNode(\n\t\tcursor: ITreeCursorSynchronous,\n\t\tcache: EncoderCache,\n\t\toutputBuffer: BufferFormat<EncodedChunkShape>,\n\t): void {\n\t\tif (this.type === undefined) {\n\t\t\toutputBuffer.push(new IdentifierToken(cursor.type));\n\t\t} else {\n\t\t\tassert(cursor.type === this.type, 0x741 /* type must match shape */);\n\t\t}\n\t\tencodeValue(this.getValueToEncode(cursor, cache), this.value, outputBuffer);\n\t\tfor (const field of this.fields) {\n\t\t\tcursor.enterField(brand(field.key));\n\t\t\tfield.shape.encodeField(cursor, cache, outputBuffer);\n\t\t\tcursor.exitField();\n\t\t}\n\n\t\tconst localBuffer: BufferFormat<EncodedChunkShape> = [];\n\n\t\tforEachField(cursor, () => {\n\t\t\tconst key = cursor.getFieldKey();\n\t\t\tif (!this.explicitKeys.has(key)) {\n\t\t\t\tassert(\n\t\t\t\t\tthis.extraLocal !== undefined,\n\t\t\t\t\t0x742 /* had extra local fields when shape does not support them */,\n\t\t\t\t);\n\t\t\t\tlocalBuffer.push(new IdentifierToken(key));\n\t\t\t\tthis.extraLocal.encodeField(cursor, cache, localBuffer);\n\t\t\t}\n\t\t});\n\n\t\tif (this.extraLocal !== undefined) {\n\t\t\toutputBuffer.push(localBuffer);\n\t\t}\n\t}\n\n\tpublic encodeShape(\n\t\tidentifiers: DeduplicationTable<string>,\n\t\tshapes: DeduplicationTable<Shape<EncodedChunkShape>>,\n\t): EncodedChunkShape {\n\t\treturn {\n\t\t\tc: {\n\t\t\t\ttype: encodeOptionalIdentifier(this.type, identifiers),\n\t\t\t\tvalue: this.value,\n\t\t\t\tfields: encodeFieldShapes(this.fields, identifiers, shapes),\n\t\t\t\textraFields: encodeOptionalFieldShape(this.extraLocal, shapes),\n\t\t\t},\n\t\t};\n\t}\n\n\tpublic count(\n\t\tidentifiers: Counter<string>,\n\t\tshapes: (shape: Shape<EncodedChunkShape>) => void,\n\t): void {\n\t\tif (this.type !== undefined) {\n\t\t\tidentifiers.add(this.type);\n\t\t}\n\n\t\tfor (const field of this.fields) {\n\t\t\tidentifiers.add(field.key);\n\t\t\tshapes(field.shape.shape);\n\t\t}\n\n\t\tif (this.extraLocal !== undefined) {\n\t\t\tshapes(this.extraLocal.shape);\n\t\t}\n\t}\n\n\tpublic get shape(): NodeShape {\n\t\treturn this;\n\t}\n}\n\nexport function encodeFieldShapes(\n\tfields: readonly KeyedFieldEncoder[],\n\tidentifiers: DeduplicationTable<string>,\n\tshapes: DeduplicationTable<Shape<EncodedChunkShape>>,\n): EncodedFieldShape[] | undefined {\n\tif (fields.length === 0) {\n\t\treturn undefined;\n\t}\n\treturn fields.map((field) => [\n\t\t// key\n\t\tencodeIdentifier(field.key, identifiers),\n\t\t// shape\n\t\tshapes.valueToIndex.get(field.shape.shape) ?? fail(0xb50 /* missing shape */),\n\t]);\n}\n\nfunction encodeIdentifier(\n\tidentifier: string,\n\tidentifiers: DeduplicationTable<string>,\n): string | number {\n\treturn identifiers.valueToIndex.get(identifier) ?? identifier;\n}\n\nfunction encodeOptionalIdentifier(\n\tidentifier: string | undefined,\n\tidentifiers: DeduplicationTable<string>,\n): string | number | undefined {\n\treturn identifier === undefined ? undefined : encodeIdentifier(identifier, identifiers);\n}\n\nfunction encodeOptionalFieldShape(\n\tshape: FieldEncoder | undefined,\n\tshapes: DeduplicationTable<Shape<EncodedChunkShape>>,\n): number | undefined {\n\treturn shape === undefined ? undefined : dedupShape(shape.shape, shapes);\n}\n\nfunction dedupShape(\n\tshape: Shape<EncodedChunkShape>,\n\tshapes: DeduplicationTable<Shape<EncodedChunkShape>>,\n): number {\n\treturn shapes.valueToIndex.get(shape) ?? fail(0xb51 /* missing shape */);\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"schemaBasedEncode.d.ts","sourceRoot":"","sources":["../../../../src/feature-libraries/chunked-forest/codec/schemaBasedEncode.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAIN,KAAK,sBAAsB,EAC3B,KAAK,qBAAqB,EAC1B,KAAK,wBAAwB,EAI7B,MAAM,wBAAwB,CAAC;AAEhC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AAEtE,OAAO,EACN,YAAY,EACZ,KAAK,YAAY,EACjB,KAAK,WAAW,EAEhB,KAAK,UAAU,EAIf,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAE,KAAK,iBAAiB,EAAwC,MAAM,aAAa,CAAC;AAC3F,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAEnE;;;;;GAKG;AACH,wBAAgB,sBAAsB,CACrC,MAAM,EAAE,sBAAsB,EAC9B,MAAM,EAAE,gBAAgB,EACxB,UAAU,EAAE,UAAU,EACtB,YAAY,EAAE,aAAa,GACzB,iBAAiB,CAEnB;AAED,wBAAgB,UAAU,CACzB,MAAM,EAAE,sBAAsB,EAC9B,MAAM,EAAE,gBAAgB,EACxB,YAAY,EAAE,aAAa,GACzB,YAAY,CAUd;AAED;;GAEG;AACH,wBAAgB,WAAW,CAC1B,WAAW,EAAE,UAAU,EACvB,KAAK,EAAE,qBAAqB,EAC5B,KAAK,EAAE,YAAY,EACnB,YAAY,EAAE,sBAAsB,GAClC,YAAY,CA6Bd;AAED;;GAEG;AACH,wBAAgB,UAAU,CACzB,UAAU,EAAE,sBAAsB,EAClC,MAAM,EAAE,gBAAgB,EACxB,YAAY,EAAE,WAAW,EACzB,UAAU,EAAE,wBAAwB,GAClC,SAAS,CAoCX;AAED,wBAAgB,UAAU,CAAC,CAAC,EAAE,GAAG,EAAE,WAAW,CAAC,CAAC,CAAC,GAAG,SAAS,GAAG,CAAC,GAAG,SAAS,CAU5E"}
1
+ {"version":3,"file":"schemaBasedEncode.d.ts","sourceRoot":"","sources":["../../../../src/feature-libraries/chunked-forest/codec/schemaBasedEncode.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAIN,KAAK,sBAAsB,EAC3B,KAAK,qBAAqB,EAC1B,KAAK,wBAAwB,EAI7B,MAAM,wBAAwB,CAAC;AAChC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AAEtE,OAAO,EACN,YAAY,EACZ,KAAK,YAAY,EACjB,KAAK,WAAW,EAEhB,KAAK,UAAU,EAIf,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAE,KAAK,iBAAiB,EAAwC,MAAM,aAAa,CAAC;AAC3F,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAEnE;;;;;GAKG;AACH,wBAAgB,sBAAsB,CACrC,MAAM,EAAE,sBAAsB,EAC9B,MAAM,EAAE,gBAAgB,EACxB,UAAU,EAAE,UAAU,EACtB,YAAY,EAAE,aAAa,GACzB,iBAAiB,CAEnB;AAED,wBAAgB,UAAU,CACzB,MAAM,EAAE,sBAAsB,EAC9B,MAAM,EAAE,gBAAgB,EACxB,YAAY,EAAE,aAAa,GACzB,YAAY,CAUd;AAED;;GAEG;AACH,wBAAgB,WAAW,CAC1B,WAAW,EAAE,UAAU,EACvB,KAAK,EAAE,qBAAqB,EAC5B,KAAK,EAAE,YAAY,EACnB,YAAY,EAAE,sBAAsB,GAClC,YAAY,CA6Bd;AAED;;GAEG;AACH,wBAAgB,UAAU,CACzB,UAAU,EAAE,sBAAsB,EAClC,MAAM,EAAE,gBAAgB,EACxB,YAAY,EAAE,WAAW,EACzB,UAAU,EAAE,wBAAwB,GAClC,SAAS,CAoCX;AAED,wBAAgB,UAAU,CAAC,CAAC,EAAE,GAAG,EAAE,WAAW,CAAC,CAAC,CAAC,GAAG,SAAS,GAAG,CAAC,GAAG,SAAS,CAU5E"}
@@ -7,7 +7,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
7
7
  exports.oneFromSet = exports.treeShaper = exports.fieldShaper = exports.buildCache = exports.schemaCompressedEncode = void 0;
8
8
  const internal_1 = require("@fluidframework/core-utils/internal");
9
9
  const index_js_1 = require("../../../core/index.js");
10
- const index_js_2 = require("../../../util/index.js");
11
10
  const compressedEncode_js_1 = require("./compressedEncode.js");
12
11
  const format_js_1 = require("./format.js");
13
12
  const nodeShape_js_1 = require("./nodeShape.js");
@@ -30,7 +29,7 @@ exports.buildCache = buildCache;
30
29
  * Selects shapes to use to encode fields.
31
30
  */
32
31
  function fieldShaper(treeHandler, field, cache, storedSchema) {
33
- const kind = cache.fieldShapes.get(field.kind) ?? (0, index_js_2.fail)(0xb52 /* missing FieldKind */);
32
+ const kind = cache.fieldShapes.get(field.kind) ?? (0, internal_1.fail)(0xb52 /* missing FieldKind */);
34
33
  const type = oneFromSet(field.types);
35
34
  const nodeEncoder = type !== undefined ? treeHandler.shapeFromTree(type) : compressedEncode_js_1.anyNodeEncoder;
36
35
  if (kind.multiplicity === index_js_1.Multiplicity.Single) {
@@ -54,7 +53,7 @@ exports.fieldShaper = fieldShaper;
54
53
  * Selects shapes to use to encode trees.
55
54
  */
56
55
  function treeShaper(fullSchema, policy, fieldHandler, schemaName) {
57
- const schema = fullSchema.nodeSchema.get(schemaName) ?? (0, index_js_2.fail)(0xb53 /* missing node schema */);
56
+ const schema = fullSchema.nodeSchema.get(schemaName) ?? (0, internal_1.fail)(0xb53 /* missing node schema */);
58
57
  if (schema instanceof index_js_1.ObjectNodeStoredSchema) {
59
58
  // TODO:Performance:
60
59
  // consider moving some optional and sequence fields to extra fields if they are commonly empty
@@ -74,7 +73,7 @@ function treeShaper(fullSchema, policy, fieldHandler, schemaName) {
74
73
  const shape = new nodeShape_js_1.NodeShape(schemaName, false, [], fieldHandler.shapeFromField(schema.mapFields));
75
74
  return shape;
76
75
  }
77
- (0, index_js_2.fail)(0xb54 /* unsupported node kind */);
76
+ (0, internal_1.fail)(0xb54 /* unsupported node kind */);
78
77
  }
79
78
  exports.treeShaper = treeShaper;
80
79
  function oneFromSet(set) {
@@ -1 +1 @@
1
- {"version":3,"file":"schemaBasedEncode.js","sourceRoot":"","sources":["../../../../src/feature-libraries/chunked-forest/codec/schemaBasedEncode.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAA8E;AAE9E,qDAUgC;AAChC,qDAA8C;AAG9C,+DAS+B;AAE/B,2CAA2F;AAC3F,iDAA2C;AAG3C;;;;;GAKG;AACH,SAAgB,sBAAsB,CACrC,MAA8B,EAC9B,MAAwB,EACxB,UAAsB,EACtB,YAA2B;IAE3B,OAAO,IAAA,sCAAgB,EAAC,UAAU,EAAE,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,YAAY,CAAC,CAAC,CAAC;AAC/E,CAAC;AAPD,wDAOC;AAED,SAAgB,UAAU,CACzB,MAA8B,EAC9B,MAAwB,EACxB,YAA2B;IAE3B,MAAM,KAAK,GAAiB,IAAI,kCAAY,CAC3C,CAAC,YAAyB,EAAE,UAAoC,EAAE,EAAE,CACnE,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,YAAY,EAAE,UAAU,CAAC,EACrD,CAAC,WAAuB,EAAE,KAA4B,EAAE,EAAE,CACzD,WAAW,CAAC,WAAW,EAAE,KAAK,EAAE,KAAK,EAAE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AAY,CAAC,cAAc,CAAC,MAAM,CAAC,SAAS,CAAC,CAC7C,CAAC;QACF,OAAO,KAAK,CAAC;IACd,CAAC;IACD,IAAA,eAAI,EAAC,KAAK,CAAC,2BAA2B,CAAC,CAAC;AACzC,CAAC;AAzCD,gCAyCC;AAED,SAAgB,UAAU,CAAI,GAA+B;IAC5D,IAAI,GAAG,KAAK,SAAS,EAAE,CAAC;QACvB,OAAO,SAAS,CAAC;IAClB,CAAC;IACD,IAAI,GAAG,CAAC,IAAI,KAAK,CAAC,EAAE,CAAC;QACpB,OAAO,SAAS,CAAC;IAClB,CAAC;IACD,KAAK,MAAM,IAAI,IAAI,GAAG,EAAE,CAAC;QACxB,OAAO,IAAI,CAAC;IACb,CAAC;AACF,CAAC;AAVD,gCAUC;AAED,SAAS,oBAAoB,CAAC,MAA+B;IAC5D,QAAQ,MAAM,EAAE,CAAC;QAChB,KAAK,SAAS;YACb,OAAO,KAAK,CAAC;QACd,KAAK,sBAAW,CAAC,MAAM,CAAC;QACxB,KAAK,sBAAW,CAAC,MAAM,CAAC;QACxB,KAAK,sBAAW,CAAC,OAAO,CAAC;QACzB,KAAK,sBAAW,CAAC,WAAW;YAC3B,OAAO,IAAI,CAAC;QACb,KAAK,sBAAW,CAAC,IAAI;YACpB,OAAO,CAAC,IAAI,CAAC,CAAC;QACf;YACC,IAAA,0BAAe,EAAC,MAAM,CAAC,CAAC;IAC1B,CAAC;AACF,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, unreachableCase } from \"@fluidframework/core-utils/internal\";\n\nimport {\n\tLeafNodeStoredSchema,\n\tMapNodeStoredSchema,\n\tObjectNodeStoredSchema,\n\ttype StoredSchemaCollection,\n\ttype TreeFieldStoredSchema,\n\ttype TreeNodeSchemaIdentifier,\n\tValueSchema,\n\tMultiplicity,\n\tidentifierFieldKindIdentifier,\n} from \"../../../core/index.js\";\nimport { fail } from \"../../../util/index.js\";\nimport type { FullSchemaPolicy } from \"../../modular-schema/index.js\";\n\nimport {\n\tEncoderCache,\n\ttype FieldEncoder,\n\ttype FieldShaper,\n\ttype KeyedFieldEncoder,\n\ttype TreeShaper,\n\tanyNodeEncoder,\n\tasFieldEncoder,\n\tcompressedEncode,\n} from \"./compressedEncode.js\";\nimport type { FieldBatch } from \"./fieldBatch.js\";\nimport { type EncodedFieldBatch, type EncodedValueShape, SpecialField } from \"./format.js\";\nimport { NodeShape } from \"./nodeShape.js\";\nimport type { IIdCompressor } from \"@fluidframework/id-compressor\";\n\n/**\n * Encode data from `fieldBatch` in into an `EncodedChunk`.\n *\n * Optimized for encoded size and encoding performance.\n * TODO: This function should eventually also take in the root FieldSchema to more efficiently compress the nodes.\n */\nexport function schemaCompressedEncode(\n\tschema: StoredSchemaCollection,\n\tpolicy: FullSchemaPolicy,\n\tfieldBatch: FieldBatch,\n\tidCompressor: IIdCompressor,\n): EncodedFieldBatch {\n\treturn compressedEncode(fieldBatch, buildCache(schema, policy, idCompressor));\n}\n\nexport function buildCache(\n\tschema: StoredSchemaCollection,\n\tpolicy: FullSchemaPolicy,\n\tidCompressor: IIdCompressor,\n): EncoderCache {\n\tconst cache: EncoderCache = new EncoderCache(\n\t\t(fieldHandler: FieldShaper, schemaName: TreeNodeSchemaIdentifier) =>\n\t\t\ttreeShaper(schema, policy, fieldHandler, schemaName),\n\t\t(treeHandler: TreeShaper, field: TreeFieldStoredSchema) =>\n\t\t\tfieldShaper(treeHandler, field, cache, schema),\n\t\tpolicy.fieldKinds,\n\t\tidCompressor,\n\t);\n\treturn cache;\n}\n\n/**\n * Selects shapes to use to encode fields.\n */\nexport function fieldShaper(\n\ttreeHandler: TreeShaper,\n\tfield: TreeFieldStoredSchema,\n\tcache: EncoderCache,\n\tstoredSchema: StoredSchemaCollection,\n): FieldEncoder {\n\tconst kind = cache.fieldShapes.get(field.kind) ?? fail(0xb52 /* missing FieldKind */);\n\tconst type = oneFromSet(field.types);\n\tconst nodeEncoder = type !== undefined ? treeHandler.shapeFromTree(type) : anyNodeEncoder;\n\tif (kind.multiplicity === Multiplicity.Single) {\n\t\tif (field.kind === identifierFieldKindIdentifier) {\n\t\t\tassert(type !== undefined, 0x999 /* field type must be defined in identifier field */);\n\t\t\tconst nodeSchema = storedSchema.nodeSchema.get(type);\n\t\t\tassert(nodeSchema !== undefined, 0x99a /* nodeSchema must be defined */);\n\t\t\tassert(\n\t\t\t\tnodeSchema instanceof LeafNodeStoredSchema,\n\t\t\t\t0x99b /* nodeSchema must be LeafNodeStoredSchema */,\n\t\t\t);\n\t\t\tassert(\n\t\t\t\tnodeSchema.leafValue === ValueSchema.String,\n\t\t\t\t0x99c /* identifier field can only be type string */,\n\t\t\t);\n\t\t\tconst identifierNodeEncoder = new NodeShape(\n\t\t\t\ttype,\n\t\t\t\tSpecialField.Identifier,\n\t\t\t\t[],\n\t\t\t\tundefined,\n\t\t\t);\n\t\t\treturn asFieldEncoder(identifierNodeEncoder);\n\t\t}\n\t\treturn asFieldEncoder(nodeEncoder);\n\t} else {\n\t\treturn cache.nestedArray(nodeEncoder);\n\t}\n}\n\n/**\n * Selects shapes to use to encode trees.\n */\nexport function treeShaper(\n\tfullSchema: StoredSchemaCollection,\n\tpolicy: FullSchemaPolicy,\n\tfieldHandler: FieldShaper,\n\tschemaName: TreeNodeSchemaIdentifier,\n): NodeShape {\n\tconst schema =\n\t\tfullSchema.nodeSchema.get(schemaName) ?? fail(0xb53 /* missing node schema */);\n\n\tif (schema instanceof ObjectNodeStoredSchema) {\n\t\t// TODO:Performance:\n\t\t// consider moving some optional and sequence fields to extra fields if they are commonly empty\n\t\t// to reduce encoded size.\n\n\t\tconst objectNodeFields: KeyedFieldEncoder[] = [];\n\t\tfor (const [key, field] of schema.objectNodeFields ?? []) {\n\t\t\tobjectNodeFields.push({ key, shape: fieldHandler.shapeFromField(field) });\n\t\t}\n\n\t\tconst shape = new NodeShape(schemaName, false, objectNodeFields, undefined);\n\t\treturn shape;\n\t}\n\tif (schema instanceof LeafNodeStoredSchema) {\n\t\tconst shape = new NodeShape(\n\t\t\tschemaName,\n\t\t\tvalueShapeFromSchema(schema.leafValue),\n\t\t\t[],\n\t\t\tundefined,\n\t\t);\n\t\treturn shape;\n\t}\n\tif (schema instanceof MapNodeStoredSchema) {\n\t\tconst shape = new NodeShape(\n\t\t\tschemaName,\n\t\t\tfalse,\n\t\t\t[],\n\t\t\tfieldHandler.shapeFromField(schema.mapFields),\n\t\t);\n\t\treturn shape;\n\t}\n\tfail(0xb54 /* unsupported node kind */);\n}\n\nexport function oneFromSet<T>(set: ReadonlySet<T> | undefined): T | undefined {\n\tif (set === undefined) {\n\t\treturn undefined;\n\t}\n\tif (set.size !== 1) {\n\t\treturn undefined;\n\t}\n\tfor (const item of set) {\n\t\treturn item;\n\t}\n}\n\nfunction valueShapeFromSchema(schema: ValueSchema | undefined): undefined | EncodedValueShape {\n\tswitch (schema) {\n\t\tcase undefined:\n\t\t\treturn false;\n\t\tcase ValueSchema.Number:\n\t\tcase ValueSchema.String:\n\t\tcase ValueSchema.Boolean:\n\t\tcase ValueSchema.FluidHandle:\n\t\t\treturn true;\n\t\tcase ValueSchema.Null:\n\t\t\treturn [null];\n\t\tdefault:\n\t\t\tunreachableCase(schema);\n\t}\n}\n"]}
1
+ {"version":3,"file":"schemaBasedEncode.js","sourceRoot":"","sources":["../../../../src/feature-libraries/chunked-forest/codec/schemaBasedEncode.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAAoF;AAEpF,qDAUgC;AAGhC,+DAS+B;AAE/B,2CAA2F;AAC3F,iDAA2C;AAG3C;;;;;GAKG;AACH,SAAgB,sBAAsB,CACrC,MAA8B,EAC9B,MAAwB,EACxB,UAAsB,EACtB,YAA2B;IAE3B,OAAO,IAAA,sCAAgB,EAAC,UAAU,EAAE,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,YAAY,CAAC,CAAC,CAAC;AAC/E,CAAC;AAPD,wDAOC;AAED,SAA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ors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, unreachableCase, fail } from \"@fluidframework/core-utils/internal\";\n\nimport {\n\tLeafNodeStoredSchema,\n\tMapNodeStoredSchema,\n\tObjectNodeStoredSchema,\n\ttype StoredSchemaCollection,\n\ttype TreeFieldStoredSchema,\n\ttype TreeNodeSchemaIdentifier,\n\tValueSchema,\n\tMultiplicity,\n\tidentifierFieldKindIdentifier,\n} from \"../../../core/index.js\";\nimport type { FullSchemaPolicy } from \"../../modular-schema/index.js\";\n\nimport {\n\tEncoderCache,\n\ttype FieldEncoder,\n\ttype FieldShaper,\n\ttype KeyedFieldEncoder,\n\ttype TreeShaper,\n\tanyNodeEncoder,\n\tasFieldEncoder,\n\tcompressedEncode,\n} from \"./compressedEncode.js\";\nimport type { FieldBatch } from \"./fieldBatch.js\";\nimport { type EncodedFieldBatch, type EncodedValueShape, SpecialField } from \"./format.js\";\nimport { NodeShape } from \"./nodeShape.js\";\nimport type { IIdCompressor } from \"@fluidframework/id-compressor\";\n\n/**\n * Encode data from `fieldBatch` in into an `EncodedChunk`.\n *\n * Optimized for encoded size and encoding performance.\n * TODO: This function should eventually also take in the root FieldSchema to more efficiently compress the nodes.\n */\nexport function schemaCompressedEncode(\n\tschema: StoredSchemaCollection,\n\tpolicy: FullSchemaPolicy,\n\tfieldBatch: FieldBatch,\n\tidCompressor: IIdCompressor,\n): EncodedFieldBatch {\n\treturn compressedEncode(fieldBatch, buildCache(schema, policy, idCompressor));\n}\n\nexport function buildCache(\n\tschema: StoredSchemaCollection,\n\tpolicy: FullSchemaPolicy,\n\tidCompressor: IIdCompressor,\n): EncoderCache {\n\tconst cache: EncoderCache = new EncoderCache(\n\t\t(fieldHandler: FieldShaper, schemaName: TreeNodeSchemaIdentifier) =>\n\t\t\ttreeShaper(schema, policy, fieldHandler, schemaName),\n\t\t(treeHandler: TreeShaper, field: TreeFieldStoredSchema) =>\n\t\t\tfieldShaper(treeHandler, field, cache, schema),\n\t\tpolicy.fieldKinds,\n\t\tidCompressor,\n\t);\n\treturn cache;\n}\n\n/**\n * Selects shapes to use to encode fields.\n */\nexport function fieldShaper(\n\ttreeHandler: TreeShaper,\n\tfield: TreeFieldStoredSchema,\n\tcache: EncoderCache,\n\tstoredSchema: StoredSchemaCollection,\n): FieldEncoder {\n\tconst kind = cache.fieldShapes.get(field.kind) ?? fail(0xb52 /* missing FieldKind */);\n\tconst type = oneFromSet(field.types);\n\tconst nodeEncoder = type !== undefined ? treeHandler.shapeFromTree(type) : anyNodeEncoder;\n\tif (kind.multiplicity === Multiplicity.Single) {\n\t\tif (field.kind === identifierFieldKindIdentifier) {\n\t\t\tassert(type !== undefined, 0x999 /* field type must be defined in identifier field */);\n\t\t\tconst nodeSchema = storedSchema.nodeSchema.get(type);\n\t\t\tassert(nodeSchema !== undefined, 0x99a /* nodeSchema must be defined */);\n\t\t\tassert(\n\t\t\t\tnodeSchema instanceof LeafNodeStoredSchema,\n\t\t\t\t0x99b /* nodeSchema must be LeafNodeStoredSchema */,\n\t\t\t);\n\t\t\tassert(\n\t\t\t\tnodeSchema.leafValue === ValueSchema.String,\n\t\t\t\t0x99c /* identifier field can only be type string */,\n\t\t\t);\n\t\t\tconst identifierNodeEncoder = new NodeShape(\n\t\t\t\ttype,\n\t\t\t\tSpecialField.Identifier,\n\t\t\t\t[],\n\t\t\t\tundefined,\n\t\t\t);\n\t\t\treturn asFieldEncoder(identifierNodeEncoder);\n\t\t}\n\t\treturn asFieldEncoder(nodeEncoder);\n\t} else {\n\t\treturn cache.nestedArray(nodeEncoder);\n\t}\n}\n\n/**\n * Selects shapes to use to encode trees.\n */\nexport function treeShaper(\n\tfullSchema: StoredSchemaCollection,\n\tpolicy: FullSchemaPolicy,\n\tfieldHandler: FieldShaper,\n\tschemaName: TreeNodeSchemaIdentifier,\n): NodeShape {\n\tconst schema =\n\t\tfullSchema.nodeSchema.get(schemaName) ?? fail(0xb53 /* missing node schema */);\n\n\tif (schema instanceof ObjectNodeStoredSchema) {\n\t\t// TODO:Performance:\n\t\t// consider moving some optional and sequence fields to extra fields if they are commonly empty\n\t\t// to reduce encoded size.\n\n\t\tconst objectNodeFields: KeyedFieldEncoder[] = [];\n\t\tfor (const [key, field] of schema.objectNodeFields ?? []) {\n\t\t\tobjectNodeFields.push({ key, shape: fieldHandler.shapeFromField(field) });\n\t\t}\n\n\t\tconst shape = new NodeShape(schemaName, false, objectNodeFields, undefined);\n\t\treturn shape;\n\t}\n\tif (schema instanceof LeafNodeStoredSchema) {\n\t\tconst shape = new NodeShape(\n\t\t\tschemaName,\n\t\t\tvalueShapeFromSchema(schema.leafValue),\n\t\t\t[],\n\t\t\tundefined,\n\t\t);\n\t\treturn shape;\n\t}\n\tif (schema instanceof MapNodeStoredSchema) {\n\t\tconst shape = new NodeShape(\n\t\t\tschemaName,\n\t\t\tfalse,\n\t\t\t[],\n\t\t\tfieldHandler.shapeFromField(schema.mapFields),\n\t\t);\n\t\treturn shape;\n\t}\n\tfail(0xb54 /* unsupported node kind */);\n}\n\nexport function oneFromSet<T>(set: ReadonlySet<T> | undefined): T | undefined {\n\tif (set === undefined) {\n\t\treturn undefined;\n\t}\n\tif (set.size !== 1) {\n\t\treturn undefined;\n\t}\n\tfor (const item of set) {\n\t\treturn item;\n\t}\n}\n\nfunction valueShapeFromSchema(schema: ValueSchema | undefined): undefined | EncodedValueShape {\n\tswitch (schema) {\n\t\tcase undefined:\n\t\t\treturn false;\n\t\tcase ValueSchema.Number:\n\t\tcase ValueSchema.String:\n\t\tcase ValueSchema.Boolean:\n\t\tcase ValueSchema.FluidHandle:\n\t\t\treturn true;\n\t\tcase ValueSchema.Null:\n\t\t\treturn [null];\n\t\tdefault:\n\t\t\tunreachableCase(schema);\n\t}\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"emptyChunk.d.ts","sourceRoot":"","sources":["../../../src/feature-libraries/chunked-forest/emptyChunk.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAON,KAAK,aAAa,EAClB,KAAK,SAAS,EAGd,MAAM,qBAAqB,CAAC;AAI7B;;;;;;GAMG;AACH,eAAO,MAAM,UAAU,EAAE,SAUxB,CAAC;AAOF;;;GAGG;AACH,eAAO,MAAM,WAAW,EAAE,aAoEzB,CAAC"}
1
+ {"version":3,"file":"emptyChunk.d.ts","sourceRoot":"","sources":["../../../src/feature-libraries/chunked-forest/emptyChunk.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAON,KAAK,aAAa,EAClB,KAAK,SAAS,EAGd,MAAM,qBAAqB,CAAC;AAG7B;;;;;;GAMG;AACH,eAAO,MAAM,UAAU,EAAE,SAUxB,CAAC;AAOF;;;GAGG;AACH,eAAO,MAAM,WAAW,EAAE,aAoEzB,CAAC"}
@@ -5,8 +5,8 @@
5
5
  */
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
7
  exports.emptyCursor = exports.emptyChunk = void 0;
8
+ const internal_1 = require("@fluidframework/core-utils/internal");
8
9
  const index_js_1 = require("../../core/index.js");
9
- const index_js_2 = require("../../util/index.js");
10
10
  const treeCursorUtils_js_1 = require("../treeCursorUtils.js");
11
11
  /**
12
12
  * Chunk that is empty.
@@ -40,10 +40,10 @@ exports.emptyCursor = {
40
40
  mode: 1 /* CursorLocationType.Fields */,
41
41
  [index_js_1.cursorChunk]: exports.emptyChunk,
42
42
  nextField() {
43
- (0, index_js_2.fail)(0xafb /* cannot navigate above root */);
43
+ (0, internal_1.fail)(0xafb /* cannot navigate above root */);
44
44
  },
45
45
  exitField() {
46
- (0, index_js_2.fail)(0xafc /* cannot navigate above root */);
46
+ (0, internal_1.fail)(0xafc /* cannot navigate above root */);
47
47
  },
48
48
  skipPendingFields() {
49
49
  return true;
@@ -58,43 +58,43 @@ exports.emptyCursor = {
58
58
  return false;
59
59
  },
60
60
  enterNode(childIndex) {
61
- (0, index_js_2.fail)(0xafd /* empty cursor has no nodes */);
61
+ (0, internal_1.fail)(0xafd /* empty cursor has no nodes */);
62
62
  },
63
63
  getFieldPath(prefix) {
64
64
  return (0, treeCursorUtils_js_1.prefixFieldPath)(prefix, emptyPath);
65
65
  },
66
66
  getPath() {
67
- (0, index_js_2.fail)(0xafe /* empty cursor has no nodes */);
67
+ (0, internal_1.fail)(0xafe /* empty cursor has no nodes */);
68
68
  },
69
69
  get fieldIndex() {
70
- return (0, index_js_2.fail)(0xaff /* empty cursor has no nodes */);
70
+ return (0, internal_1.fail)(0xaff /* empty cursor has no nodes */);
71
71
  },
72
72
  get chunkStart() {
73
- return (0, index_js_2.fail)(0xb00 /* empty cursor has no nodes */);
73
+ return (0, internal_1.fail)(0xb00 /* empty cursor has no nodes */);
74
74
  },
75
75
  get chunkLength() {
76
- return (0, index_js_2.fail)(0xb01 /* empty cursor has no nodes */);
76
+ return (0, internal_1.fail)(0xb01 /* empty cursor has no nodes */);
77
77
  },
78
78
  seekNodes(offset) {
79
- (0, index_js_2.fail)(0xb02 /* empty cursor has no nodes */);
79
+ (0, internal_1.fail)(0xb02 /* empty cursor has no nodes */);
80
80
  },
81
81
  nextNode() {
82
- (0, index_js_2.fail)(0xb03 /* empty cursor has no nodes */);
82
+ (0, internal_1.fail)(0xb03 /* empty cursor has no nodes */);
83
83
  },
84
84
  exitNode() {
85
- (0, index_js_2.fail)(0xb04 /* empty cursor has no nodes */);
85
+ (0, internal_1.fail)(0xb04 /* empty cursor has no nodes */);
86
86
  },
87
87
  firstField() {
88
- (0, index_js_2.fail)(0xb05 /* empty cursor has no nodes */);
88
+ (0, internal_1.fail)(0xb05 /* empty cursor has no nodes */);
89
89
  },
90
90
  enterField(key) {
91
- (0, index_js_2.fail)(0xb06 /* empty cursor has no nodes */);
91
+ (0, internal_1.fail)(0xb06 /* empty cursor has no nodes */);
92
92
  },
93
93
  get type() {
94
- return (0, index_js_2.fail)(0xb07 /* empty cursor has no nodes */);
94
+ return (0, internal_1.fail)(0xb07 /* empty cursor has no nodes */);
95
95
  },
96
96
  get value() {
97
- return (0, index_js_2.fail)(0xb08 /* empty cursor has no nodes */);
97
+ return (0, internal_1.fail)(0xb08 /* empty cursor has no nodes */);
98
98
  },
99
99
  atChunkRoot() {
100
100
  return true;
@@ -1 +1 @@
1
- {"version":3,"file":"emptyChunk.js","sourceRoot":"","sources":["../../../src/feature-libraries/chunked-forest/emptyChunk.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kDAW6B;AAC7B,kDAA2C;AAC3C,8DAAwD;AAExD;;;;;;GAMG;AACU,QAAA,UAAU,GAAc;IACpC,cAAc,EAAE,CAAC;IACjB,MAAM;QACL,OAAO,mBAAW,CAAC;IACpB,CAAC;IACD,cAAc,KAAU,CAAC;IACzB,gBAAgB,KAAU,CAAC;IAC3B,QAAQ;QACP,OAAO,KAAK,CAAC,CAAC,yCAAyC;IACxD,CAAC;CACD,CAAC;AAEF,MAAM,SAAS,GAAgB;IAC9B,MAAM,EAAE,SAAS;IACjB,KAAK,EAAE,oBAAS;CAChB,CAAC;AAEF;;;GAGG;AACU,QAAA,WAAW,GAAkB;IACzC,CAAC,uBAAY,CAAC,EAAE,IAAI;IACpB,OAAO,EAAE,KAAK;IACd,IAAI,mCAA2B;IAC/B,CAAC,sBAAW,CAAC,EAAE,kBAAU;IACzB,SAAS;QACR,IAAA,eAAI,EAAC,KAAK,CAAC,gCAAgC,CAAC,CAAC;IAC9C,CAAC;IACD,SAAS;QACR,IAAA,eAAI,EAAC,KAAK,CAAC,gCAAgC,CAAC,CAAC;IAC9C,CAAC;IACD,iBAAiB;QAChB,OAAO,IAAI,CAAC;IACb,CAAC;IACD,WAAW;QACV,OAAO,SAAS,CAAC,KAAK,CAAC;IACxB,CAAC;IACD,cAAc;QACb,OAAO,CAAC,CAAC;IACV,CAAC;IACD,SAAS;QACR,OAAO,KAAK,CAAC;IACd,CAAC;IACD,SAAS,CAAC,UAAkB;QAC3B,IAAA,eAAI,EAAC,KAAK,CAAC,+BAA+B,CAAC,CAAC;IAC7C,CAAC;IACD,YAAY,CAAC,MAAuB;QACnC,OAAO,IAAA,oCAAe,EAAC,MAAM,EAAE,SAAS,CAAC,CAAC;IAC3C,CAAC;IACD,OAAO;QACN,IAAA,eAAI,EAAC,KAAK,CAAC,+BAA+B,CAAC,CAAC;IAC7C,CAAC;IACD,IAAI,UAAU;QACb,OAAO,IAAA,eAAI,EAAC,KAAK,CAAC,+BAA+B,CAAC,CAAC;IACpD,CAAC;IACD,IAAI,UAAU;QACb,OAAO,IAAA,eAAI,EAAC,KAAK,CAAC,+BAA+B,CAAC,CAAC;IACpD,CAAC;IACD,IAAI,WAAW;QACd,OAAO,IAAA,eAAI,EAAC,KAAK,CAAC,+BAA+B,CAAC,CAAC;IACpD,CAAC;IACD,SAAS,CAAC,MAAc;QACvB,IAAA,eAAI,EAAC,KAAK,CAAC,+BAA+B,CAAC,CAAC;IAC7C,CAAC;IACD,QAAQ;QACP,IAAA,eAAI,EAAC,KAAK,CAAC,+BAA+B,CAAC,CAAC;IAC7C,CAAC;IACD,QAAQ;QACP,IAAA,eAAI,EAAC,KAAK,CAAC,+BAA+B,CAAC,CAAC;IAC7C,CAAC;IACD,UAAU;QACT,IAAA,eAAI,EAAC,KAAK,CAAC,+BAA+B,CAAC,CAAC;IAC7C,CAAC;IACD,UAAU,CAAC,GAAa;QACvB,IAAA,eAAI,EAAC,KAAK,CAAC,+BAA+B,CAAC,CAAC;IAC7C,CAAC;IACD,IAAI,IAAI;QACP,OAAO,IAAA,eAAI,EAAC,KAAK,CAAC,+BAA+B,CAAC,CAAC;IACpD,CAAC;IACD,IAAI,KAAK;QACR,OAAO,IAAA,eAAI,EAAC,KAAK,CAAC,+BAA+B,CAAC,CAAC;IACpD,CAAC;IACD,WAAW;QACV,OAAO,IAAI,CAAC;IACb,CAAC;IACD,IAAI;QACH,OAAO,mBAAW,CAAC;IACpB,CAAC;CACD,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\tCursorLocationType,\n\tCursorMarker,\n\ttype FieldKey,\n\ttype FieldUpPath,\n\ttype PathRootPrefix,\n\ttype UpPath,\n\ttype ChunkedCursor,\n\ttype TreeChunk,\n\tcursorChunk,\n\tdummyRoot,\n} from \"../../core/index.js\";\nimport { fail } from \"../../util/index.js\";\nimport { prefixFieldPath } from \"../treeCursorUtils.js\";\n\n/**\n * Chunk that is empty.\n *\n * Since all emptiness is the same, this is a singleton.\n *\n * Useful for when a chunk or cursor is needed for an empty field or detached sequence.\n */\nexport const emptyChunk: TreeChunk = {\n\ttopLevelLength: 0,\n\tcursor(): ChunkedCursor {\n\t\treturn emptyCursor;\n\t},\n\treferenceAdded(): void {},\n\treferenceRemoved(): void {},\n\tisShared(): boolean {\n\t\treturn false; // Immutable, so sharing does not matter.\n\t},\n};\n\nconst emptyPath: FieldUpPath = {\n\tparent: undefined,\n\tfield: dummyRoot,\n};\n\n/**\n * Cursor over an empty field.\n * Contains no nodes and is stateless.\n */\nexport const emptyCursor: ChunkedCursor = {\n\t[CursorMarker]: true,\n\tpending: false,\n\tmode: CursorLocationType.Fields,\n\t[cursorChunk]: emptyChunk,\n\tnextField(): boolean {\n\t\tfail(0xafb /* cannot navigate above root */);\n\t},\n\texitField(): void {\n\t\tfail(0xafc /* cannot navigate above root */);\n\t},\n\tskipPendingFields(): boolean {\n\t\treturn true;\n\t},\n\tgetFieldKey(): FieldKey {\n\t\treturn emptyPath.field;\n\t},\n\tgetFieldLength(): number {\n\t\treturn 0;\n\t},\n\tfirstNode(): boolean {\n\t\treturn false;\n\t},\n\tenterNode(childIndex: number): void {\n\t\tfail(0xafd /* empty cursor has no nodes */);\n\t},\n\tgetFieldPath(prefix?: PathRootPrefix): FieldUpPath {\n\t\treturn prefixFieldPath(prefix, emptyPath);\n\t},\n\tgetPath(): UpPath | undefined {\n\t\tfail(0xafe /* empty cursor has no nodes */);\n\t},\n\tget fieldIndex(): never {\n\t\treturn fail(0xaff /* empty cursor has no nodes */);\n\t},\n\tget chunkStart(): never {\n\t\treturn fail(0xb00 /* empty cursor has no nodes */);\n\t},\n\tget chunkLength(): never {\n\t\treturn fail(0xb01 /* empty cursor has no nodes */);\n\t},\n\tseekNodes(offset: number): boolean {\n\t\tfail(0xb02 /* empty cursor has no nodes */);\n\t},\n\tnextNode(): boolean {\n\t\tfail(0xb03 /* empty cursor has no nodes */);\n\t},\n\texitNode(): void {\n\t\tfail(0xb04 /* empty cursor has no nodes */);\n\t},\n\tfirstField(): boolean {\n\t\tfail(0xb05 /* empty cursor has no nodes */);\n\t},\n\tenterField(key: FieldKey): void {\n\t\tfail(0xb06 /* empty cursor has no nodes */);\n\t},\n\tget type(): never {\n\t\treturn fail(0xb07 /* empty cursor has no nodes */);\n\t},\n\tget value(): never {\n\t\treturn fail(0xb08 /* empty cursor has no nodes */);\n\t},\n\tatChunkRoot(): boolean {\n\t\treturn true;\n\t},\n\tfork(): ChunkedCursor {\n\t\treturn emptyCursor;\n\t},\n};\n"]}
1
+ {"version":3,"file":"emptyChunk.js","sourceRoot":"","sources":["../../../src/feature-libraries/chunked-forest/emptyChunk.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAA2D;AAC3D,kDAW6B;AAC7B,8DAAwD;AAExD;;;;;;GAMG;AACU,QAAA,UAAU,GAAc;IACpC,cAAc,EAAE,CAAC;IACjB,MAAM;QACL,OAAO,mBAAW,CAAC;IACpB,CAAC;IACD,cAAc,KAAU,CAAC;IACzB,gBAAgB,KAAU,CAAC;IAC3B,QAAQ;QACP,OAAO,KAAK,CAAC,CAAC,yCAAyC;IACxD,CAAC;CACD,CAAC;AAEF,MAAM,SAAS,GAAgB;IAC9B,MAAM,EAAE,SAAS;IACjB,KAAK,EAAE,oBAAS;CAChB,CAAC;AAEF;;;GAGG;AACU,QAAA,WAAW,GAAkB;IACzC,CAAC,uBAAY,CAAC,EAAE,IAAI;IACpB,OAAO,EAAE,KAAK;IACd,IAAI,mCAA2B;IAC/B,CAAC,sBAAW,CAAC,EAAE,kBAAU;IACzB,SAAS;Q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AC,GAAa;QACvB,IAAA,eAAI,EAAC,KAAK,CAAC,+BAA+B,CAAC,CAAC;IAC7C,CAAC;IACD,IAAI,IAAI;QACP,OAAO,IAAA,eAAI,EAAC,KAAK,CAAC,+BAA+B,CAAC,CAAC;IACpD,CAAC;IACD,IAAI,KAAK;QACR,OAAO,IAAA,eAAI,EAAC,KAAK,CAAC,+BAA+B,CAAC,CAAC;IACpD,CAAC;IACD,WAAW;QACV,OAAO,IAAI,CAAC;IACb,CAAC;IACD,IAAI;QACH,OAAO,mBAAW,CAAC;IACpB,CAAC;CACD,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { fail } from \"@fluidframework/core-utils/internal\";\nimport {\n\tCursorLocationType,\n\tCursorMarker,\n\ttype FieldKey,\n\ttype FieldUpPath,\n\ttype PathRootPrefix,\n\ttype UpPath,\n\ttype ChunkedCursor,\n\ttype TreeChunk,\n\tcursorChunk,\n\tdummyRoot,\n} from \"../../core/index.js\";\nimport { prefixFieldPath } from \"../treeCursorUtils.js\";\n\n/**\n * Chunk that is empty.\n *\n * Since all emptiness is the same, this is a singleton.\n *\n * Useful for when a chunk or cursor is needed for an empty field or detached sequence.\n */\nexport const emptyChunk: TreeChunk = {\n\ttopLevelLength: 0,\n\tcursor(): ChunkedCursor {\n\t\treturn emptyCursor;\n\t},\n\treferenceAdded(): void {},\n\treferenceRemoved(): void {},\n\tisShared(): boolean {\n\t\treturn false; // Immutable, so sharing does not matter.\n\t},\n};\n\nconst emptyPath: FieldUpPath = {\n\tparent: undefined,\n\tfield: dummyRoot,\n};\n\n/**\n * Cursor over an empty field.\n * Contains no nodes and is stateless.\n */\nexport const emptyCursor: ChunkedCursor = {\n\t[CursorMarker]: true,\n\tpending: false,\n\tmode: CursorLocationType.Fields,\n\t[cursorChunk]: emptyChunk,\n\tnextField(): boolean {\n\t\tfail(0xafb /* cannot navigate above root */);\n\t},\n\texitField(): void {\n\t\tfail(0xafc /* cannot navigate above root */);\n\t},\n\tskipPendingFields(): boolean {\n\t\treturn true;\n\t},\n\tgetFieldKey(): FieldKey {\n\t\treturn emptyPath.field;\n\t},\n\tgetFieldLength(): number {\n\t\treturn 0;\n\t},\n\tfirstNode(): boolean {\n\t\treturn false;\n\t},\n\tenterNode(childIndex: number): void {\n\t\tfail(0xafd /* empty cursor has no nodes */);\n\t},\n\tgetFieldPath(prefix?: PathRootPrefix): FieldUpPath {\n\t\treturn prefixFieldPath(prefix, emptyPath);\n\t},\n\tgetPath(): UpPath | undefined {\n\t\tfail(0xafe /* empty cursor has no nodes */);\n\t},\n\tget fieldIndex(): never {\n\t\treturn fail(0xaff /* empty cursor has no nodes */);\n\t},\n\tget chunkStart(): never {\n\t\treturn fail(0xb00 /* empty cursor has no nodes */);\n\t},\n\tget chunkLength(): never {\n\t\treturn fail(0xb01 /* empty cursor has no nodes */);\n\t},\n\tseekNodes(offset: number): boolean {\n\t\tfail(0xb02 /* empty cursor has no nodes */);\n\t},\n\tnextNode(): boolean {\n\t\tfail(0xb03 /* empty cursor has no nodes */);\n\t},\n\texitNode(): void {\n\t\tfail(0xb04 /* empty cursor has no nodes */);\n\t},\n\tfirstField(): boolean {\n\t\tfail(0xb05 /* empty cursor has no nodes */);\n\t},\n\tenterField(key: FieldKey): void {\n\t\tfail(0xb06 /* empty cursor has no nodes */);\n\t},\n\tget type(): never {\n\t\treturn fail(0xb07 /* empty cursor has no nodes */);\n\t},\n\tget value(): never {\n\t\treturn fail(0xb08 /* empty cursor has no nodes */);\n\t},\n\tatChunkRoot(): boolean {\n\t\treturn true;\n\t},\n\tfork(): ChunkedCursor {\n\t\treturn emptyCursor;\n\t},\n};\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"uniformChunk.d.ts","sourceRoot":"","sources":["../../../src/feature-libraries/chunked-forest/uniformChunk.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EACN,kBAAkB,EAClB,KAAK,QAAQ,EACb,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AG,SAAS,CAEnD;IAEM,WAAW,IAAI,OAAO;IAWtB,IAAI,IAAI,MAAM;IASrB;;;;;;OAMG;IACH,OAAO,CAAC,cAAc;IAStB;;;;;;;;;OASG;IACH,OAAO,CAAC,QAAQ;IAST,SAAS,IAAI,OAAO;IAYpB,SAAS,IAAI,IAAI;IAOjB,WAAW,IAAI,QAAQ;IAIvB,cAAc,IAAI,MAAM;IAexB,SAAS,IAAI,OAAO;IAepB,SAAS,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI;IAkB1C;;;OAGG;IACH,OAAO,CAAC,cAAc;IAiBtB,OAAO,CAAC,kBAAkB;IAQnB,YAAY,CAAC,MAAM,CAAC,EAAE,cAAc,GAAG,WAAW;IAOlD,OAAO,CAAC,MAAM,CAAC,EAAE,cAAc,GAAG,MAAM,GAAG,SAAS;IAI3D,IAAW,UAAU,IAAI,MAAM,CAE9B;IAED,SAAgB,UAAU,EAAE,MAAM,CAAK;IAEvC,IAAW,WAAW,IAAI,MAAM,CAE/B;IAEM,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO;IAWlC,QAAQ,IAAI,OAAO;IAanB,QAAQ,IAAI,IAAI;IAahB,UAAU,IAAI,OAAO;IAYrB,UAAU,CAAC,GAAG,EAAE,QAAQ,GAAG,IAAI;IAWtC,IAAW,IAAI,IAAI,wBAAwB,CAE1C;IAED,IAAW,KAAK,IAAI,KAAK,CAYxB;CACD"}
@@ -278,7 +278,7 @@ class Cursor extends treeCursorUtils_js_1.SynchronousCursor {
278
278
  this.mode = 0 /* CursorLocationType.Nodes */;
279
279
  }
280
280
  getFieldKey() {
281
- return this.fieldKey ?? (0, index_js_2.fail)(0xb09 /* not in a field */);
281
+ return this.fieldKey ?? (0, internal_1.fail)(0xb09 /* not in a field */);
282
282
  }
283
283
  getFieldLength() {
284
284
  (0, internal_1.assert)(this.mode === 1 /* CursorLocationType.Fields */, 0x53f /* tried to access cursor when in wrong mode */);
@@ -381,11 +381,11 @@ class Cursor extends treeCursorUtils_js_1.SynchronousCursor {
381
381
  const info = this.nodeInfo(0 /* CursorLocationType.Nodes */);
382
382
  this.indexOfField =
383
383
  info.indexOfParentField ??
384
- (0, index_js_2.fail)(0xb0a /* navigation up to root field not yet supported */); // TODO;
384
+ (0, internal_1.fail)(0xb0a /* navigation up to root field not yet supported */); // TODO;
385
385
  this.fieldKey = info.parentField;
386
386
  this.mode = 1 /* CursorLocationType.Fields */;
387
387
  this.moveToPosition(info.indexOfParentPosition ??
388
- (0, index_js_2.fail)(0xb0b /* navigation up to root field not yet supported */)); // TODO
388
+ (0, internal_1.fail)(0xb0b /* navigation up to root field not yet supported */)); // TODO
389
389
  }
390
390
  firstField() {
391
391
  const fieldsArray = this.nodeInfo(0 /* CursorLocationType.Nodes */).shape.fieldsArray;
@@ -404,7 +404,7 @@ class Cursor extends treeCursorUtils_js_1.SynchronousCursor {
404
404
  this.indexOfField =
405
405
  fieldInfo === undefined
406
406
  ? fieldMap.size
407
- : (fieldInfo.indexOfParentField ?? (0, index_js_2.fail)(0xb0c /* children should have parents */));
407
+ : (fieldInfo.indexOfParentField ?? (0, internal_1.fail)(0xb0c /* children should have parents */));
408
408
  this.fieldKey = key;
409
409
  this.mode = 1 /* CursorLocationType.Fields */;
410
410
  }