@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":"codec.js","sourceRoot":"","sources":["../../src/codec/codec.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAAyE;AACzE,kEAA6D;AAI7D,+CAAqE;AA+KrE;;;GAGG;AACH,SAAgB,eAAe,CAC9B,QAOC;IAED,MAAM,MAAM,GAGR,IAAI,GAAG,EAAE,CAAC;IACd,KAAK,MAAM,CAAC,aAAa,EAAE,KAAK,CAAC,IAAI,QAAQ,EAAE,CAAC;QAC/C,IAAI,MAAM,CAAC,GAAG,CAAC,aAAa,CAAC,EAAE,CAAC;YAC/B,IAAA,eAAI,EAAC,KAAK,CAAC,iCAAiC,CAAC,CAAC;QAC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AAC,EAAE,CAAC;gBACpC,IAAA,eAAI,EAAC,KAAK,CAAC,oCAAoC,CAAC,CAAC;YAClD,CAAC;YACD,2GAA2G;YAC3G,OAAO,KAAK,CAAC,MAAM,CAAC,OAAO,EAAE,OAAO,CAA+B,CAAC;QACrE,CAAC;KACD,CAAC;AACH,CAAC;AA/BD,oDA+BC;AAED;;;;;;;;;;;;;GAaG;AACH,IAAY,kBASX;AATD,WAAY,kBAAkB;IAC7B,4CAA4C;IAC5C,mCAAa,CAAA;IACb,4CAA4C;IAC5C,mCAAa,CAAA;IACb,4CAA4C;IAC5C,mCAAa,CAAA;IACb,4CAA4C;IAC5C,mCAAa,CAAA;AACd,CAAC,EATW,kBAAkB,kCAAlB,kBAAkB,QAS7B","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IsoBuffer, bufferToString } from \"@fluid-internal/client-utils\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport type { Static, TAnySchema, TSchema } from \"@sinclair/typebox\";\n\nimport type { ChangeEncodingContext } from \"../core/index.js\";\nimport { type JsonCompatibleReadOnly, fail } from \"../util/index.js\";\n\n/**\n * Translates decoded data to encoded data.\n * @remarks Typically paired with an {@link IEncoder}.\n */\nexport interface IEncoder<TDecoded, TEncoded, TContext> {\n\t/**\n\t * Encodes `obj` into some encoded format.\n\t */\n\tencode(obj: TDecoded, context: TContext): TEncoded;\n}\n\n/**\n * Translates encoded data to decoded data.\n * @remarks Typically paired with an {@link IEncoder}.\n */\nexport interface IDecoder<TDecoded, TEncoded, TContext> {\n\t/**\n\t * Decodes `obj` from some encoded format.\n\t */\n\tdecode(obj: TEncoded, context: TContext): TDecoded;\n}\n\n/**\n * Validates data complies with some particular schema.\n * Implementations are typically created by a {@link JsonValidator}.\n * @alpha\n */\nexport interface SchemaValidationFunction<Schema extends TSchema> {\n\t/**\n\t * Returns whether the data matches a schema.\n\t */\n\tcheck(data: unknown): data is Static<Schema>;\n}\n\n/**\n * JSON schema validator compliant with draft 6 schema. See https://json-schema.org.\n * @alpha\n */\nexport interface JsonValidator {\n\t/**\n\t * Compiles the provided JSON schema into a validator for that schema.\n\t * @param schema - A valid draft 6 JSON schema\n\t * @remarks IFluidHandles--which have circular property references--are used in various places in SharedTree's persisted\n\t * format. Handles should only be contained in sections of data which are validated against the empty schema `{}`\n\t * (see https://datatracker.ietf.org/doc/html/draft-wright-json-schema-01#section-4.4).\n\t *\n\t * Implementations of `JsonValidator` must therefore tolerate these values, despite the input not being valid JSON.\n\t */\n\tcompile<Schema extends TSchema>(schema: Schema): SchemaValidationFunction<Schema>;\n}\n\n/**\n * Options relating to handling of persisted data.\n * @alpha\n */\nexport interface ICodecOptions {\n\t/**\n\t * {@link JsonValidator} which SharedTree uses to validate persisted data it reads & writes\n\t * matches the expected encoded format (i.e. the wire format for ops and summaries).\n\t *\n\t * See {@link noopValidator} and {@link typeboxValidator} for out-of-the-box implementations.\n\t *\n\t * This option is not \"on-by-default\" because JSON schema validation comes with a small but noticeable\n\t * runtime performance cost, and popular schema validation libraries have relatively large bundle size.\n\t *\n\t * SharedTree users are still encouraged to use a non-trivial validator (i.e. not `noopValidator`)\n\t * whenever reasonable: it gives better fail-fast behavior when unexpected encoded data is found,\n\t * which reduces the risk of unrecoverable data corruption.\n\t */\n\treadonly jsonValidator: JsonValidator;\n}\n\n/**\n * `TContext` allows passing context to the codec which may configure how data is encoded/decoded.\n * This parameter is typically used for:\n * - Codecs which can pick from multiple encoding options, and imbue the encoded data with information about which option was used.\n * The caller of such a codec can provide context about which encoding choice to make as part of the `encode` call without creating\n * additional codecs. Note that this pattern can always be implemented by having the caller create multiple codecs and selecting the\n * appropriate one, but depending on API layering this might be less ergonomic.\n * - Context for the object currently being encoded, which might enable more efficient encoding. When used in this fashion, the codec author\n * should be careful to include the context somewhere in the encoded data such that decoding can correctly round-trip.\n * For example, a composed set of codecs could implement a form of [dictionary coding](https://en.wikipedia.org/wiki/Dictionary_coder)\n * using a context map which was created by the top-level codec and passed to the inner codecs.\n * This pattern is used:\n * - To avoid repeatedly encoding session ids on commits (only recording it once at the top level)\n * @remarks `TEncoded` should always be valid Json (i.e. not contain functions), but due to TypeScript's handling\n * of index signatures and `JsonCompatibleReadOnly`'s index signature in the Json object case, specifying this as a\n * type-system level constraint makes code that uses this interface more difficult to write.\n *\n * If provided, `TValidate` allows the input type passed to `decode` to be different than `TEncoded`.\n * This is useful when, for example, the type being decoded is `unknown` and must be validated to be a `TEncoded` before being decoded to a `TDecoded`.\n */\nexport interface IJsonCodec<\n\tTDecoded,\n\tTEncoded = JsonCompatibleReadOnly,\n\tTValidate = TEncoded,\n\tTContext = void,\n> extends IEncoder<TDecoded, TEncoded, TContext>,\n\t\tIDecoder<TDecoded, TValidate, TContext> {\n\tencodedSchema?: TAnySchema;\n}\n\n/**\n * @remarks TODO: We might consider using DataView or some kind of writer instead of IsoBuffer.\n */\nexport interface IBinaryCodec<TDecoded, TContext = void>\n\textends IEncoder<TDecoded, IsoBuffer, TContext>,\n\t\tIDecoder<TDecoded, IsoBuffer, TContext> {}\n\n/**\n * Contains knowledge of how to encode some in-memory type into JSON and binary formats,\n * as well as how to decode those representations.\n *\n * @remarks Codecs are typically used in shared-tree to convert data into some persisted format.\n * For this common use case, any format for encoding that was ever actually used needs to\n * be supported for decoding in all future code versions.\n *\n * Using an {@link ICodecFamily} is the recommended strategy for managing this support, keeping in\n * mind evolution of encodings over time.\n */\nexport interface IMultiFormatCodec<\n\tTDecoded,\n\tTJsonEncoded extends JsonCompatibleReadOnly = JsonCompatibleReadOnly,\n\tTJsonValidate = TJsonEncoded,\n\tTContext = void,\n> {\n\tjson: IJsonCodec<TDecoded, TJsonEncoded, TJsonValidate, TContext>;\n\tbinary: IBinaryCodec<TDecoded, TContext>;\n\n\t/** Ensures multi-format codecs cannot also be single-format codecs. */\n\tencode?: never;\n\t/** Ensures multi-format codecs cannot also be single-format codecs. */\n\tdecode?: never;\n}\n\n/**\n * Represents a family of codecs that can be used to encode and decode data in different formats.\n * The family is identified by a format version, which is typically used to select the codec to use.\n *\n * Separating codecs into families rather than having a single codec support multiple versions (i.e. currying\n * the `formatVersion` parameter)\n * allows avoiding some duplicate work at encode/decode time, since the vast majority of document usage will not\n * involve mixed format versions.\n *\n * @privateRemarks - This interface currently assumes all codecs in a family require the same encode/decode context,\n * which isn't necessarily true.\n * This may need to be relaxed in the future.\n */\nexport interface ICodecFamily<TDecoded, TContext = void> {\n\t/**\n\t * @returns a codec that can be used to encode and decode data in the specified format.\n\t * @throws - if the format version is not supported by this family.\n\t * @remarks Implementations should typically emit telemetry (either indirectly by throwing a well-known error with\n\t * logged properties or directly using some logger) when a format version is requested that is not supported.\n\t * This ensures that applications can diagnose compatibility issues.\n\t */\n\tresolve(\n\t\tformatVersion: FormatVersion,\n\t): IMultiFormatCodec<TDecoded, JsonCompatibleReadOnly, JsonCompatibleReadOnly, TContext>;\n\n\t/**\n\t * @returns an iterable of all format versions supported by this family.\n\t */\n\tgetSupportedFormats(): Iterable<FormatVersion>;\n}\n\n/**\n * A version stamp for encoded data.\n *\n * Undefined is tolerated to enable the scenario where data was not initially versioned.\n */\nexport type FormatVersion = number | undefined;\n\n/**\n * Creates a codec family from a registry of codecs.\n * Any codec that is not a {@link IMultiFormatCodec} will be wrapped with a default binary encoding.\n */\nexport function makeCodecFamily<TDecoded, TContext>(\n\tregistry: Iterable<\n\t\t[\n\t\t\tformatVersion: FormatVersion,\n\t\t\tcodec:\n\t\t\t\t| IMultiFormatCodec<TDecoded, JsonCompatibleReadOnly, JsonCompatibleReadOnly, TContext>\n\t\t\t\t| IJsonCodec<TDecoded, JsonCompatibleReadOnly, JsonCompatibleReadOnly, TContext>,\n\t\t]\n\t>,\n): ICodecFamily<TDecoded, TContext> {\n\tconst codecs: Map<\n\t\tFormatVersion,\n\t\tIMultiFormatCodec<TDecoded, JsonCompatibleReadOnly, JsonCompatibleReadOnly, TContext>\n\t> = new Map();\n\tfor (const [formatVersion, codec] of registry) {\n\t\tif (codecs.has(formatVersion)) {\n\t\t\tfail(0xabf /* Duplicate codecs specified. */);\n\t\t}\n\t\tcodecs.set(formatVersion, ensureBinaryEncoding(codec));\n\t}\n\n\treturn {\n\t\tresolve(\n\t\t\tformatVersion: number,\n\t\t): IMultiFormatCodec<TDecoded, JsonCompatibleReadOnly, JsonCompatibleReadOnly, TContext> {\n\t\t\tconst codec = codecs.get(formatVersion);\n\t\t\tassert(codec !== undefined, 0x5e6 /* Requested coded for unsupported format. */);\n\t\t\treturn codec;\n\t\t},\n\t\tgetSupportedFormats(): Iterable<FormatVersion> {\n\t\t\treturn codecs.keys();\n\t\t},\n\t};\n}\n\nclass DefaultBinaryCodec<TDecoded, TContext> implements IBinaryCodec<TDecoded, TContext> {\n\tpublic constructor(\n\t\tprivate readonly jsonCodec: IJsonCodec<TDecoded, unknown, unknown, TContext>,\n\t) {}\n\n\tpublic encode(change: TDecoded, context: TContext): IsoBuffer {\n\t\tconst jsonable = this.jsonCodec.encode(change, context);\n\t\tconst json = JSON.stringify(jsonable);\n\t\treturn IsoBuffer.from(json);\n\t}\n\n\tpublic decode(change: IsoBuffer, context: TContext): TDecoded {\n\t\tconst json = bufferToString(change, \"utf8\");\n\t\tconst jsonable = JSON.parse(json);\n\t\treturn this.jsonCodec.decode(jsonable, context);\n\t}\n}\n\nfunction isJsonCodec<TDecoded, TContext>(\n\tcodec:\n\t\t| IMultiFormatCodec<TDecoded, JsonCompatibleReadOnly, JsonCompatibleReadOnly, TContext>\n\t\t| IJsonCodec<TDecoded, JsonCompatibleReadOnly, JsonCompatibleReadOnly, TContext>,\n): codec is IJsonCodec<TDecoded, JsonCompatibleReadOnly, JsonCompatibleReadOnly, TContext> {\n\treturn typeof codec.encode === \"function\" && typeof codec.decode === \"function\";\n}\n\n/**\n * Constructs a {@link IMultiFormatCodec} from a `IJsonCodec` using a generic binary encoding that simply writes\n * the json representation of the object to a buffer.\n */\nexport function withDefaultBinaryEncoding<TDecoded, TContext>(\n\tjsonCodec: IJsonCodec<TDecoded, JsonCompatibleReadOnly, JsonCompatibleReadOnly, TContext>,\n): IMultiFormatCodec<TDecoded, JsonCompatibleReadOnly, JsonCompatibleReadOnly, TContext> {\n\treturn {\n\t\tjson: jsonCodec,\n\t\tbinary: new DefaultBinaryCodec(jsonCodec),\n\t};\n}\n\n/**\n * Ensures that the provided single or multi-format codec has a binary encoding.\n * Adapts the json encoding using {@link withDefaultBinaryEncoding} if necessary.\n */\nexport function ensureBinaryEncoding<TDecoded, TContext>(\n\tcodec:\n\t\t| IMultiFormatCodec<TDecoded, JsonCompatibleReadOnly, JsonCompatibleReadOnly, TContext>\n\t\t| IJsonCodec<TDecoded, JsonCompatibleReadOnly, JsonCompatibleReadOnly, TContext>,\n): IMultiFormatCodec<TDecoded, JsonCompatibleReadOnly, JsonCompatibleReadOnly, TContext> {\n\treturn isJsonCodec(codec) ? withDefaultBinaryEncoding(codec) : codec;\n}\n\n/**\n * Codec for objects which carry no information.\n */\nexport const unitCodec: IMultiFormatCodec<\n\t0,\n\tJsonCompatibleReadOnly,\n\tJsonCompatibleReadOnly,\n\tunknown\n> = {\n\tjson: {\n\t\tencode: () => 0,\n\t\tdecode: () => 0,\n\t},\n\tbinary: {\n\t\tencode: () => IsoBuffer.from(\"\"),\n\t\tdecode: () => 0,\n\t},\n};\n\n/**\n * Wraps a codec with JSON schema validation for its encoded type.\n * @returns An {@link IJsonCodec} which validates the data it encodes and decodes matches the provided schema.\n */\nexport function withSchemaValidation<\n\tTInMemoryFormat,\n\tEncodedSchema extends TSchema,\n\tTEncodedFormat = JsonCompatibleReadOnly,\n\tTValidate = TEncodedFormat,\n\tTContext = ChangeEncodingContext,\n>(\n\tschema: EncodedSchema,\n\tcodec: IJsonCodec<TInMemoryFormat, TEncodedFormat, TValidate, TContext>,\n\tvalidator?: JsonValidator,\n): IJsonCodec<TInMemoryFormat, TEncodedFormat, TValidate, TContext> {\n\tif (!validator) {\n\t\treturn codec;\n\t}\n\tconst compiledFormat = validator.compile(schema);\n\treturn {\n\t\tencode: (obj: TInMemoryFormat, context: TContext): TEncodedFormat => {\n\t\t\tconst encoded = codec.encode(obj, context);\n\t\t\tif (!compiledFormat.check(encoded)) {\n\t\t\t\tfail(0xac0 /* Encoded schema should validate */);\n\t\t\t}\n\t\t\treturn encoded;\n\t\t},\n\t\tdecode: (encoded: TValidate, context: TContext): TInMemoryFormat => {\n\t\t\tif (!compiledFormat.check(encoded)) {\n\t\t\t\tfail(0xac1 /* Encoded schema should validate */);\n\t\t\t}\n\t\t\t// TODO: would be nice to provide a more specific validate type to the inner codec than the outer one gets.\n\t\t\treturn codec.decode(encoded, context) as unknown as TInMemoryFormat;\n\t\t},\n\t};\n}\n\n/**\n * Versions of Fluid Framework client packages.\n * @remarks\n * Used to express compatibility requirements by indicating the oldest version with which compatibility must be maintained.\n * @privateRemarks\n * This scheme assumes a single version will always be enough to communicate compatibility.\n * For this to work, compatibility has to be strictly increasing.\n * If this is violated (for example a subset of incompatible features from 3.x that are not in 3.0 are back ported to 2.x),\n * a more complex scheme may be needed to allow safely opting into incompatible features in those cases:\n * such a system can be added if/when its needed since it will be opt in and thus non-breaking.\n *\n * TODO: this should likely be defined higher in the stack and specified when creating the container, possibly as part of its schema.\n * @alpha\n */\nexport enum FluidClientVersion {\n\t/** Fluid Framework Client 2.0 and newer. */\n\tv2_0 = \"v2_0\",\n\t/** Fluid Framework Client 2.1 and newer. */\n\tv2_1 = \"v2_1\",\n\t/** Fluid Framework Client 2.2 and newer. */\n\tv2_2 = \"v2_2\",\n\t/** Fluid Framework Client 2.4 and newer. */\n\tv2_3 = \"v2_3\",\n}\n"]}
1
+ {"version":3,"file":"codec.js","sourceRoot":"","sources":["../../src/codec/codec.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAAyE;AACzE,kEAAmE;AAmLnE;;;GAGG;AACH,SAAgB,eAAe,CAC9B,QAOC;IAED,MAAM,MAAM,GAGR,IAAI,GAAG,EAAE,CAAC;IACd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EAAC,KAAK,CAAC,oCAAoC,CAAC,CAAC;YAClD,CAAC;YACD,OAAO,OAAO,CAAC;QAChB,CAAC;QACD,MAAM,EAAE,CAAC,OAAkB,EAAE,OAAiB,EAAmB,EAAE;YAClE,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,CAAC;gBACpC,IAAA,eAAI,EAAC,KAAK,CAAC,oCAAoC,CAAC,CAAC;YAClD,CAAC;YACD,2GAA2G;YAC3G,OAAO,KAAK,CAAC,MAAM,CAAC,OAAO,EAAE,OAAO,CAA+B,CAAC;QACrE,CAAC;KACD,CAAC;AACH,CAAC;AA/BD,oDA+BC;AAED;;;;;;;;;;;;;GAaG;AACH,IAAY,kBASX;AATD,WAAY,kBAAkB;IAC7B,4CAA4C;IAC5C,mCAAa,CAAA;IACb,4CAA4C;IAC5C,mCAAa,CAAA;IACb,4CAA4C;IAC5C,mCAAa,CAAA;IACb,4CAA4C;IAC5C,mCAAa,CAAA;AACd,CAAC,EATW,kBAAkB,kCAAlB,kBAAkB,QAS7B","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IsoBuffer, bufferToString } from \"@fluid-internal/client-utils\";\nimport { assert, fail } from \"@fluidframework/core-utils/internal\";\nimport type { Static, TAnySchema, TSchema } from \"@sinclair/typebox\";\n\nimport type { ChangeEncodingContext } from \"../core/index.js\";\nimport type { JsonCompatibleReadOnly } from \"../util/index.js\";\n\n/**\n * Translates decoded data to encoded data.\n * @remarks Typically paired with an {@link IEncoder}.\n */\nexport interface IEncoder<TDecoded, TEncoded, TContext> {\n\t/**\n\t * Encodes `obj` into some encoded format.\n\t */\n\tencode(obj: TDecoded, context: TContext): TEncoded;\n}\n\n/**\n * Translates encoded data to decoded data.\n * @remarks Typically paired with an {@link IEncoder}.\n */\nexport interface IDecoder<TDecoded, TEncoded, TContext> {\n\t/**\n\t * Decodes `obj` from some encoded format.\n\t */\n\tdecode(obj: TEncoded, context: TContext): TDecoded;\n}\n\n/**\n * Validates data complies with some particular schema.\n * Implementations are typically created by a {@link JsonValidator}.\n * @alpha\n */\nexport interface SchemaValidationFunction<Schema extends TSchema> {\n\t/**\n\t * Returns whether the data matches a schema.\n\t */\n\tcheck(data: unknown): data is Static<Schema>;\n}\n\n/**\n * JSON schema validator compliant with draft 6 schema. See https://json-schema.org.\n * @alpha\n */\nexport interface JsonValidator {\n\t/**\n\t * Compiles the provided JSON schema into a validator for that schema.\n\t * @param schema - A valid draft 6 JSON schema\n\t * @remarks IFluidHandles--which have circular property references--are used in various places in SharedTree's persisted\n\t * format. Handles should only be contained in sections of data which are validated against the empty schema `{}`\n\t * (see https://datatracker.ietf.org/doc/html/draft-wright-json-schema-01#section-4.4).\n\t *\n\t * Implementations of `JsonValidator` must therefore tolerate these values, despite the input not being valid JSON.\n\t */\n\tcompile<Schema extends TSchema>(schema: Schema): SchemaValidationFunction<Schema>;\n}\n\n/**\n * Options relating to handling of persisted data.\n * @alpha\n */\nexport interface ICodecOptions {\n\t/**\n\t * {@link JsonValidator} which SharedTree uses to validate persisted data it reads & writes\n\t * matches the expected encoded format (i.e. the wire format for ops and summaries).\n\t *\n\t * See {@link noopValidator} and {@link typeboxValidator} for out-of-the-box implementations.\n\t *\n\t * This option is not \"on-by-default\" because JSON schema validation comes with a small but noticeable\n\t * runtime performance cost, and popular schema validation libraries have relatively large bundle size.\n\t *\n\t * SharedTree users are still encouraged to use a non-trivial validator (i.e. not `noopValidator`)\n\t * whenever reasonable: it gives better fail-fast behavior when unexpected encoded data is found,\n\t * which reduces the risk of unrecoverable data corruption.\n\t */\n\treadonly jsonValidator: JsonValidator;\n}\n\n/**\n * `TContext` allows passing context to the codec which may configure how data is encoded/decoded.\n * This parameter is typically used for:\n * - Codecs which can pick from multiple encoding options, and imbue the encoded data with information about which option was used.\n * The caller of such a codec can provide context about which encoding choice to make as part of the `encode` call without creating\n * additional codecs. Note that this pattern can always be implemented by having the caller create multiple codecs and selecting the\n * appropriate one, but depending on API layering this might be less ergonomic.\n * - Context for the object currently being encoded, which might enable more efficient encoding. When used in this fashion, the codec author\n * should be careful to include the context somewhere in the encoded data such that decoding can correctly round-trip.\n * For example, a composed set of codecs could implement a form of [dictionary coding](https://en.wikipedia.org/wiki/Dictionary_coder)\n * using a context map which was created by the top-level codec and passed to the inner codecs.\n * This pattern is used:\n * - To avoid repeatedly encoding session ids on commits (only recording it once at the top level)\n * @remarks `TEncoded` should always be valid Json (i.e. not contain functions), but due to TypeScript's handling\n * of index signatures and `JsonCompatibleReadOnly`'s index signature in the Json object case, specifying this as a\n * type-system level constraint makes code that uses this interface more difficult to write.\n *\n * If provided, `TValidate` allows the input type passed to `decode` to be different than `TEncoded`.\n * This is useful when, for example, the type being decoded is `unknown` and must be validated to be a `TEncoded` before being decoded to a `TDecoded`.\n */\nexport interface IJsonCodec<\n\tTDecoded,\n\tTEncoded = JsonCompatibleReadOnly,\n\tTValidate = TEncoded,\n\tTContext = void,\n> extends IEncoder<TDecoded, TEncoded, TContext>,\n\t\tIDecoder<TDecoded, TValidate, TContext> {\n\tencodedSchema?: TAnySchema;\n}\n\n/**\n * @remarks TODO: We might consider using DataView or some kind of writer instead of IsoBuffer.\n */\nexport interface IBinaryCodec<TDecoded, TContext = void>\n\textends IEncoder<TDecoded, IsoBuffer, TContext>,\n\t\tIDecoder<TDecoded, IsoBuffer, TContext> {}\n\n/**\n * Contains knowledge of how to encode some in-memory type into JSON and binary formats,\n * as well as how to decode those representations.\n *\n * @remarks Codecs are typically used in shared-tree to convert data into some persisted format.\n * For this common use case, any format for encoding that was ever actually used needs to\n * be supported for decoding in all future code versions.\n *\n * Using an {@link ICodecFamily} is the recommended strategy for managing this support, keeping in\n * mind evolution of encodings over time.\n */\nexport interface IMultiFormatCodec<\n\tTDecoded,\n\tTJsonEncoded extends JsonCompatibleReadOnly = JsonCompatibleReadOnly,\n\tTJsonValidate = TJsonEncoded,\n\tTContext = void,\n> {\n\tjson: IJsonCodec<TDecoded, TJsonEncoded, TJsonValidate, TContext>;\n\tbinary: IBinaryCodec<TDecoded, TContext>;\n\n\t/** Ensures multi-format codecs cannot also be single-format codecs. */\n\tencode?: never;\n\t/** Ensures multi-format codecs cannot also be single-format codecs. */\n\tdecode?: never;\n}\n\n/**\n * Represents a family of codecs that can be used to encode and decode data in different formats.\n * The family is identified by a format version, which is typically used to select the codec to use.\n *\n * Separating codecs into families rather than having a single codec support multiple versions (i.e. currying\n * the `formatVersion` parameter)\n * allows avoiding some duplicate work at encode/decode time, since the vast majority of document usage will not\n * involve mixed format versions.\n *\n * @privateRemarks - This interface currently assumes all codecs in a family require the same encode/decode context,\n * which isn't necessarily true.\n * This may need to be relaxed in the future.\n */\nexport interface ICodecFamily<TDecoded, TContext = void> {\n\t/**\n\t * @returns a codec that can be used to encode and decode data in the specified format.\n\t * @throws - if the format version is not supported by this family.\n\t * @remarks Implementations should typically emit telemetry (either indirectly by throwing a well-known error with\n\t * logged properties or directly using some logger) when a format version is requested that is not supported.\n\t * This ensures that applications can diagnose compatibility issues.\n\t */\n\tresolve(\n\t\tformatVersion: FormatVersion,\n\t): IMultiFormatCodec<TDecoded, JsonCompatibleReadOnly, JsonCompatibleReadOnly, TContext>;\n\n\t/**\n\t * @returns an iterable of all format versions supported by this family.\n\t */\n\tgetSupportedFormats(): Iterable<FormatVersion>;\n}\n\n/**\n * A version stamp for encoded data.\n *\n * Undefined is tolerated to enable the scenario where data was not initially versioned.\n */\nexport type FormatVersion = number | undefined;\n\n/**\n * Creates a codec family from a registry of codecs.\n * Any codec that is not a {@link IMultiFormatCodec} will be wrapped with a default binary encoding.\n */\nexport function makeCodecFamily<TDecoded, TContext>(\n\tregistry: Iterable<\n\t\t[\n\t\t\tformatVersion: FormatVersion,\n\t\t\tcodec:\n\t\t\t\t| IMultiFormatCodec<TDecoded, JsonCompatibleReadOnly, JsonCompatibleReadOnly, TContext>\n\t\t\t\t| IJsonCodec<TDecoded, JsonCompatibleReadOnly, JsonCompatibleReadOnly, TContext>,\n\t\t]\n\t>,\n): ICodecFamily<TDecoded, TContext> {\n\tconst codecs: Map<\n\t\tFormatVersion,\n\t\tIMultiFormatCodec<TDecoded, JsonCompatibleReadOnly, JsonCompatibleReadOnly, TContext>\n\t> = new Map();\n\tfor (const [formatVersion, codec] of registry) {\n\t\tif (codecs.has(formatVersion)) {\n\t\t\tfail(0xabf /* Duplicate codecs specified. */);\n\t\t}\n\t\tcodecs.set(formatVersion, ensureBinaryEncoding(codec));\n\t}\n\n\treturn {\n\t\tresolve(\n\t\t\tformatVersion: number,\n\t\t): IMultiFormatCodec<TDecoded, JsonCompatibleReadOnly, JsonCompatibleReadOnly, TContext> {\n\t\t\tconst codec = codecs.get(formatVersion);\n\t\t\tassert(codec !== undefined, 0x5e6 /* Requested coded for unsupported format. */);\n\t\t\treturn codec;\n\t\t},\n\t\tgetSupportedFormats(): Iterable<FormatVersion> {\n\t\t\treturn codecs.keys();\n\t\t},\n\t};\n}\n\nclass DefaultBinaryCodec<TDecoded, TContext> implements IBinaryCodec<TDecoded, TContext> {\n\tpublic constructor(\n\t\tprivate readonly jsonCodec: IJsonCodec<TDecoded, unknown, unknown, TContext>,\n\t) {}\n\n\tpublic encode(change: TDecoded, context: TContext): IsoBuffer {\n\t\tconst jsonable = this.jsonCodec.encode(change, context);\n\t\tconst json = JSON.stringify(jsonable);\n\t\treturn IsoBuffer.from(json);\n\t}\n\n\tpublic decode(change: IsoBuffer, context: TContext): TDecoded {\n\t\tconst json = bufferToString(change, \"utf8\");\n\t\tconst jsonable = JSON.parse(json);\n\t\treturn this.jsonCodec.decode(jsonable, context);\n\t}\n}\n\nfunction isJsonCodec<TDecoded, TContext>(\n\tcodec:\n\t\t| IMultiFormatCodec<TDecoded, JsonCompatibleReadOnly, JsonCompatibleReadOnly, TContext>\n\t\t| IJsonCodec<TDecoded, JsonCompatibleReadOnly, JsonCompatibleReadOnly, TContext>,\n): codec is IJsonCodec<TDecoded, JsonCompatibleReadOnly, JsonCompatibleReadOnly, TContext> {\n\treturn typeof codec.encode === \"function\" && typeof codec.decode === \"function\";\n}\n\n/**\n * Constructs a {@link IMultiFormatCodec} from a `IJsonCodec` using a generic binary encoding that simply writes\n * the json representation of the object to a buffer.\n */\nexport function withDefaultBinaryEncoding<TDecoded, TContext>(\n\tjsonCodec: IJsonCodec<TDecoded, JsonCompatibleReadOnly, JsonCompatibleReadOnly, TContext>,\n): IMultiFormatCodec<TDecoded, JsonCompatibleReadOnly, JsonCompatibleReadOnly, TContext> {\n\treturn {\n\t\tjson: jsonCodec,\n\t\tbinary: new DefaultBinaryCodec(jsonCodec),\n\t};\n}\n\n/**\n * Ensures that the provided single or multi-format codec has a binary encoding.\n * Adapts the json encoding using {@link withDefaultBinaryEncoding} if necessary.\n */\nexport function ensureBinaryEncoding<TDecoded, TContext>(\n\tcodec:\n\t\t| IMultiFormatCodec<TDecoded, JsonCompatibleReadOnly, JsonCompatibleReadOnly, TContext>\n\t\t| IJsonCodec<TDecoded, JsonCompatibleReadOnly, JsonCompatibleReadOnly, TContext>,\n): IMultiFormatCodec<TDecoded, JsonCompatibleReadOnly, JsonCompatibleReadOnly, TContext> {\n\treturn isJsonCodec(codec) ? withDefaultBinaryEncoding(codec) : codec;\n}\n\n/**\n * Codec for objects which carry no information.\n */\nexport const unitCodec: IMultiFormatCodec<\n\t0,\n\tJsonCompatibleReadOnly,\n\tJsonCompatibleReadOnly,\n\tunknown\n> = {\n\tjson: {\n\t\tencode: () => 0,\n\t\tdecode: () => 0,\n\t},\n\tbinary: {\n\t\tencode: () => IsoBuffer.from(\"\"),\n\t\tdecode: () => 0,\n\t},\n};\n\n/**\n * Wraps a codec with JSON schema validation for its encoded type.\n * @returns An {@link IJsonCodec} which validates the data it encodes and decodes matches the provided schema.\n */\nexport function withSchemaValidation<\n\tTInMemoryFormat,\n\tEncodedSchema extends TSchema,\n\tTEncodedFormat = JsonCompatibleReadOnly,\n\tTValidate = TEncodedFormat,\n\tTContext = ChangeEncodingContext,\n>(\n\tschema: EncodedSchema,\n\tcodec: IJsonCodec<TInMemoryFormat, TEncodedFormat, TValidate, TContext>,\n\tvalidator?: JsonValidator,\n): IJsonCodec<TInMemoryFormat, TEncodedFormat, TValidate, TContext> {\n\tif (!validator) {\n\t\treturn codec;\n\t}\n\tconst compiledFormat = validator.compile(schema);\n\treturn {\n\t\tencode: (obj: TInMemoryFormat, context: TContext): TEncodedFormat => {\n\t\t\tconst encoded = codec.encode(obj, context);\n\t\t\tif (!compiledFormat.check(encoded)) {\n\t\t\t\tfail(0xac0 /* Encoded schema should validate */);\n\t\t\t}\n\t\t\treturn encoded;\n\t\t},\n\t\tdecode: (encoded: TValidate, context: TContext): TInMemoryFormat => {\n\t\t\tif (!compiledFormat.check(encoded)) {\n\t\t\t\tfail(0xac1 /* Encoded schema should validate */);\n\t\t\t}\n\t\t\t// TODO: would be nice to provide a more specific validate type to the inner codec than the outer one gets.\n\t\t\treturn codec.decode(encoded, context) as unknown as TInMemoryFormat;\n\t\t},\n\t};\n}\n\n/**\n * Versions of Fluid Framework client packages.\n * @remarks\n * Used to express compatibility requirements by indicating the oldest version with which compatibility must be maintained.\n * @privateRemarks\n * This scheme assumes a single version will always be enough to communicate compatibility.\n * For this to work, compatibility has to be strictly increasing.\n * If this is violated (for example a subset of incompatible features from 3.x that are not in 3.0 are back ported to 2.x),\n * a more complex scheme may be needed to allow safely opting into incompatible features in those cases:\n * such a system can be added if/when its needed since it will be opt in and thus non-breaking.\n *\n * TODO: this should likely be defined higher in the stack and specified when creating the container, possibly as part of its schema.\n * @alpha\n */\nexport enum FluidClientVersion {\n\t/** Fluid Framework Client 2.0 and newer. */\n\tv2_0 = \"v2_0\",\n\t/** Fluid Framework Client 2.1 and newer. */\n\tv2_1 = \"v2_1\",\n\t/** Fluid Framework Client 2.2 and newer. */\n\tv2_2 = \"v2_2\",\n\t/** Fluid Framework Client 2.4 and newer. */\n\tv2_3 = \"v2_3\",\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"discriminatedUnions.d.ts","sourceRoot":"","sources":["../../src/codec/discriminatedUnions.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAEvD,OAAO,EAAE,KAAK,YAAY,EAAqB,MAAM,kBAAkB,CAAC;AAExE;;;;GAIG;AAEH;;;;GAIG;AACH,eAAO,MAAM,YAAY,EAAE,aAI1B,CAAC;AAEF;;;;GAIG;AACH,MAAM,MAAM,yBAAyB,CACpC,MAAM,SAAS,MAAM,EAErB,KAAK,SAAS,GAAG,EAAE,EACnB,OAAO,IACJ;IACH;QACC,QAAQ,EAAE,QAAQ,IAAI,MAAM,MAAM,CAAC,CAAC,GAAG,CACtC,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC,QAAQ,CAAC,EACjC,GAAG,IAAI,EAAE,KAAK,KACV,OAAO;KACZ;CACD,CAAC,YAAY,CAAC,CAAC;AAEhB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsDG;AACH,qBAAa,4BAA4B,CACxC,MAAM,SAAS,MAAM,EAErB,KAAK,SAAS,GAAG,EAAE,EACnB,OAAO;IAEP,OAAO,CAAC,QAAQ,CAAC,OAAO,CAGtB;gBAEiB,OAAO,EAAE,yBAAyB,CAAC,MAAM,EAAE,KAAK,EAAE,OAAO,CAAC;IAMtE,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,KAAK,GAAG,OAAO;CAavD"}
1
+ {"version":3,"file":"discriminatedUnions.d.ts","sourceRoot":"","sources":["../../src/codec/discriminatedUnions.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAEvD,OAAO,EAAE,KAAK,YAAY,EAAe,MAAM,kBAAkB,CAAC;AAElE;;;;GAIG;AAEH;;;;GAIG;AACH,eAAO,MAAM,YAAY,EAAE,aAI1B,CAAC;AAEF;;;;GAIG;AACH,MAAM,MAAM,yBAAyB,CACpC,MAAM,SAAS,MAAM,EAErB,KAAK,SAAS,GAAG,EAAE,EACnB,OAAO,IACJ;IACH;QACC,QAAQ,EAAE,QAAQ,IAAI,MAAM,MAAM,CAAC,CAAC,GAAG,CACtC,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC,QAAQ,CAAC,EACjC,GAAG,IAAI,EAAE,KAAK,KACV,OAAO;KACZ;CACD,CAAC,YAAY,CAAC,CAAC;AAEhB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsDG;AACH,qBAAa,4BAA4B,CACxC,MAAM,SAAS,MAAM,EAErB,KAAK,SAAS,GAAG,EAAE,EACnB,OAAO;IAEP,OAAO,CAAC,QAAQ,CAAC,OAAO,CAGtB;gBAEiB,OAAO,EAAE,yBAAyB,CAAC,MAAM,EAAE,KAAK,EAAE,OAAO,CAAC;IAMtE,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,KAAK,GAAG,OAAO;CAavD"}
@@ -86,7 +86,7 @@ class DiscriminatedUnionDispatcher {
86
86
  (0, internal_1.assert)(keys.length === 1, 0x733 /* discriminated union type should have exactly one member */);
87
87
  const key = keys[0];
88
88
  const value = union[key];
89
- const factory = this.library.get(key) ?? (0, index_js_1.fail)(0xac2 /* missing function for union member */);
89
+ const factory = this.library.get(key) ?? (0, internal_1.fail)(0xac2 /* missing function for union member */);
90
90
  const result = factory(value, ...args);
91
91
  return result;
92
92
  }
@@ -1 +1 @@
1
- {"version":3,"file":"discriminatedUnions.js","sourceRoot":"","sources":["../../src/codec/discriminatedUnions.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAA6D;AAG7D,+CAAwE;AAExE;;;;GAIG;AAEH;;;;GAIG;AACU,QAAA,YAAY,GAAkB;IAC1C,oBAAoB,EAAE,KAAK;IAC3B,aAAa,EAAE,CAAC;IAChB,aAAa,EAAE,CAAC;CAChB,CAAC;AAqBF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsDG;AACH,MAAa,4BAA4B;IAWxC,YAAmB,OAA0D;QAC5E,IAAI,CAAC,OAAO,GAAG,IAAA,sBAAW,EACzB,OAA4E,CAC5E,CAAC;IACH,CAAC;IAEM,QAAQ,CAAC,KAAa,EAAE,GAAG,IAAW;QAC5C,MAAM,IAAI,GAAG,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;QACpC,IAAA,iBAAM,EACL,IAAI,CAAC,MAAM,KAAK,CAAC,EACjB,KAAK,CAAC,6DAA6D,CACnE,CAAC;QACF,MAAM,GAAG,GAAiB,IAAI,CAAC,CAAC,CAAiB,CAAC;QAClD,MAAM,KAAK,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC;QACzB,MAAM,OAAO,GACZ,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,IAAA,eAAI,EAAC,KAAK,CAAC,uCAAuC,CAAC,CAAC;QAC9E,MAAM,MAAM,GAAG,OAAO,CAAC,KAAK,EAAE,GAAG,IAAI,CAAC,CAAC;QACvC,OAAO,MAAM,CAAC;IACf,CAAC;CACD;AA9BD,oEA8BC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport type { ObjectOptions } from \"@sinclair/typebox\";\n\nimport { type _InlineTrick, fail, objectToMap } from \"../util/index.js\";\n\n/**\n * This module contains utilities for an encoding of a discriminated union that is efficient to validate using\n * a JSON schema validator.\n * See {@link DiscriminatedUnionDispatcher} for more information on this pattern.\n */\n\n/**\n * Options to configure a TypeBox schema as a discriminated union that is simple to validate data against.\n *\n * See {@link DiscriminatedUnionDispatcher} for more information on this pattern.\n */\nexport const unionOptions: ObjectOptions = {\n\tadditionalProperties: false,\n\tminProperties: 1,\n\tmaxProperties: 1,\n};\n\n/**\n * An object containing functions for each member of the union.\n *\n * See {@link DiscriminatedUnionDispatcher}.\n */\nexport type DiscriminatedUnionLibrary<\n\tTUnion extends object,\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tTArgs extends any[],\n\tTResult,\n> = [\n\t{\n\t\treadonly [Property in keyof TUnion]-?: (\n\t\t\tvalue: Required<TUnion>[Property],\n\t\t\t...args: TArgs\n\t\t) => TResult;\n\t},\n][_InlineTrick];\n\n/**\n * Applies a function to the content of a [discriminated union](https://en.wikipedia.org/wiki/Tagged_union)\n * where the function to apply depends on which value from the union it holds.\n *\n * This uses a rather non-standard encoding of the union where it is an object with many differently named optional fields,\n * and which of the fields is populated determines the content type.\n * This union encoding has the advantage that schema validation (such as that implemented by TypeBox) can validate the data efficiently.\n * Other encodings--such as using an untagged union, then tagging the content types with a marker enum--require the schema validator to disambiguate the union members.\n * Most JSON validator implementations fail to recognize the marker enum determines which component of the discriminated union the data must be,\n * and end up checking against all candidate members of the union.\n *\n * @example\n *\n * The following union:\n * ```typescript\n * type Operation = Add | Subtract | Multiply | Divide;\n *\n * interface BinaryOperation {\n * readonly left: number;\n * readonly right: number;\n * }\n *\n * interface Add extends BinaryOperation {\n * readonly type: \"add\";\n * }\n *\n * interface Subtract extends BinaryOperation {\n * readonly type: \"subtract\";\n * }\n *\n * interface Multiply extends BinaryOperation {\n * readonly type: \"multiply\";\n * }\n *\n * interface Divide extends BinaryOperation {\n * readonly type: \"divide\";\n * }\n *\n * ```\n * Would be encoded using this strategy as:\n * ```typescript\n * interface EncodedBinaryOperation {\n * readonly left: number;\n * readonly right: number;\n * }\n *\n * interface EncodedOperation {\n * add?: EncodedBinaryOperation;\n * subtract?: EncodedBinaryOperation;\n * multiply?: EncodedBinaryOperation;\n * divide?: EncodedBinaryOperation;\n * }\n * ```\n * where only a single property of `EncodedOperation` is populated for a given encoded value.\n */\nexport class DiscriminatedUnionDispatcher<\n\tTUnion extends object,\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tTArgs extends any[],\n\tTResult,\n> {\n\tprivate readonly library: ReadonlyMap<\n\t\tkeyof TUnion,\n\t\t(value: unknown, ...args: TArgs) => TResult\n\t>;\n\n\tpublic constructor(library: DiscriminatedUnionLibrary<TUnion, TArgs, TResult>) {\n\t\tthis.library = objectToMap(\n\t\t\tlibrary as Record<keyof TUnion, (value: unknown, ...args: TArgs) => TResult>,\n\t\t);\n\t}\n\n\tpublic dispatch(union: TUnion, ...args: TArgs): TResult {\n\t\tconst keys = Reflect.ownKeys(union);\n\t\tassert(\n\t\t\tkeys.length === 1,\n\t\t\t0x733 /* discriminated union type should have exactly one member */,\n\t\t);\n\t\tconst key: keyof TUnion = keys[0] as keyof TUnion;\n\t\tconst value = union[key];\n\t\tconst factory =\n\t\t\tthis.library.get(key) ?? fail(0xac2 /* missing function for union member */);\n\t\tconst result = factory(value, ...args);\n\t\treturn result;\n\t}\n}\n"]}
1
+ {"version":3,"file":"discriminatedUnions.js","sourceRoot":"","sources":["../../src/codec/discriminatedUnions.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAAmE;AAGnE,+CAAkE;AAElE;;;;GAIG;AAEH;;;;GAIG;AACU,QAAA,YAAY,GAAkB;IAC1C,oBAAoB,EAAE,KAAK;IAC3B,aAAa,EAAE,CAAC;IAChB,aAAa,EAAE,CAAC;CAChB,CAAC;AAqBF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsDG;AACH,MAAa,4BAA4B;IAWxC,YAAmB,OAA0D;QAC5E,IAAI,CAAC,OAAO,GAAG,IAAA,sBAAW,EACzB,OAA4E,CAC5E,CAAC;IACH,CAAC;IAEM,QAAQ,CAAC,KAAa,EAAE,GAAG,IAAW;QAC5C,MAAM,IAAI,GAAG,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;QACpC,IAAA,iBAAM,EACL,IAAI,CAAC,MAAM,KAAK,CAAC,EACjB,KAAK,CAAC,6DAA6D,CACnE,CAAC;QACF,MAAM,GAAG,GAAiB,IAAI,CAAC,CAAC,CAAiB,CAAC;QAClD,MAAM,KAAK,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC;QACzB,MAAM,OAAO,GACZ,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,IAAA,eAAI,EAAC,KAAK,CAAC,uCAAuC,CAAC,CAAC;QAC9E,MAAM,MAAM,GAAG,OAAO,CAAC,KAAK,EAAE,GAAG,IAAI,CAAC,CAAC;QACvC,OAAO,MAAM,CAAC;IACf,CAAC;CACD;AA9BD,oEA8BC","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\";\nimport type { ObjectOptions } from \"@sinclair/typebox\";\n\nimport { type _InlineTrick, objectToMap } from \"../util/index.js\";\n\n/**\n * This module contains utilities for an encoding of a discriminated union that is efficient to validate using\n * a JSON schema validator.\n * See {@link DiscriminatedUnionDispatcher} for more information on this pattern.\n */\n\n/**\n * Options to configure a TypeBox schema as a discriminated union that is simple to validate data against.\n *\n * See {@link DiscriminatedUnionDispatcher} for more information on this pattern.\n */\nexport const unionOptions: ObjectOptions = {\n\tadditionalProperties: false,\n\tminProperties: 1,\n\tmaxProperties: 1,\n};\n\n/**\n * An object containing functions for each member of the union.\n *\n * See {@link DiscriminatedUnionDispatcher}.\n */\nexport type DiscriminatedUnionLibrary<\n\tTUnion extends object,\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tTArgs extends any[],\n\tTResult,\n> = [\n\t{\n\t\treadonly [Property in keyof TUnion]-?: (\n\t\t\tvalue: Required<TUnion>[Property],\n\t\t\t...args: TArgs\n\t\t) => TResult;\n\t},\n][_InlineTrick];\n\n/**\n * Applies a function to the content of a [discriminated union](https://en.wikipedia.org/wiki/Tagged_union)\n * where the function to apply depends on which value from the union it holds.\n *\n * This uses a rather non-standard encoding of the union where it is an object with many differently named optional fields,\n * and which of the fields is populated determines the content type.\n * This union encoding has the advantage that schema validation (such as that implemented by TypeBox) can validate the data efficiently.\n * Other encodings--such as using an untagged union, then tagging the content types with a marker enum--require the schema validator to disambiguate the union members.\n * Most JSON validator implementations fail to recognize the marker enum determines which component of the discriminated union the data must be,\n * and end up checking against all candidate members of the union.\n *\n * @example\n *\n * The following union:\n * ```typescript\n * type Operation = Add | Subtract | Multiply | Divide;\n *\n * interface BinaryOperation {\n * readonly left: number;\n * readonly right: number;\n * }\n *\n * interface Add extends BinaryOperation {\n * readonly type: \"add\";\n * }\n *\n * interface Subtract extends BinaryOperation {\n * readonly type: \"subtract\";\n * }\n *\n * interface Multiply extends BinaryOperation {\n * readonly type: \"multiply\";\n * }\n *\n * interface Divide extends BinaryOperation {\n * readonly type: \"divide\";\n * }\n *\n * ```\n * Would be encoded using this strategy as:\n * ```typescript\n * interface EncodedBinaryOperation {\n * readonly left: number;\n * readonly right: number;\n * }\n *\n * interface EncodedOperation {\n * add?: EncodedBinaryOperation;\n * subtract?: EncodedBinaryOperation;\n * multiply?: EncodedBinaryOperation;\n * divide?: EncodedBinaryOperation;\n * }\n * ```\n * where only a single property of `EncodedOperation` is populated for a given encoded value.\n */\nexport class DiscriminatedUnionDispatcher<\n\tTUnion extends object,\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tTArgs extends any[],\n\tTResult,\n> {\n\tprivate readonly library: ReadonlyMap<\n\t\tkeyof TUnion,\n\t\t(value: unknown, ...args: TArgs) => TResult\n\t>;\n\n\tpublic constructor(library: DiscriminatedUnionLibrary<TUnion, TArgs, TResult>) {\n\t\tthis.library = objectToMap(\n\t\t\tlibrary as Record<keyof TUnion, (value: unknown, ...args: TArgs) => TResult>,\n\t\t);\n\t}\n\n\tpublic dispatch(union: TUnion, ...args: TArgs): TResult {\n\t\tconst keys = Reflect.ownKeys(union);\n\t\tassert(\n\t\t\tkeys.length === 1,\n\t\t\t0x733 /* discriminated union type should have exactly one member */,\n\t\t);\n\t\tconst key: keyof TUnion = keys[0] as keyof TUnion;\n\t\tconst value = union[key];\n\t\tconst factory =\n\t\t\tthis.library.get(key) ?? fail(0xac2 /* missing function for union member */);\n\t\tconst result = factory(value, ...args);\n\t\treturn result;\n\t}\n}\n"]}
@@ -105,7 +105,7 @@ function rebaseBranch(mintRevisionTag, changeRebaser, sourceHead, targetCommit,
105
105
  const revisionMetadata = revisionMetadataSourceFromInfo(revInfos);
106
106
  let editsToCompose = targetRebasePath.slice();
107
107
  for (const c of sourcePath) {
108
- const rollback = rollbackFromCommit(changeRebaser, c, mintRevisionTag, false);
108
+ const rollback = rollbackFromCommit(changeRebaser, c, mintRevisionTag, true /* cache */);
109
109
  if (sourceSet.has(c.revision)) {
110
110
  const currentComposedEdit = (0, changeRebaser_js_1.makeAnonChange)(changeRebaser.compose(editsToCompose));
111
111
  editsToCompose = [currentComposedEdit];
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/core/rebase/utils.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAAkE;AAElE,kDAAsF;AAEtF,yDAS4B;AAC5B,yCAA4E;AAuK5E,SAAgB,YAAY,CAC3B,eAAkC,EAClC,aAAqC,EACrC,UAAgC,EAChC,YAAkC,EAClC,UAAU,GAAG,YAAY;IAEzB,4CAA4C;IAC5C,MAAM,UAAU,GAA2B,EAAE,CAAC;IAC9C,MAAM,UAAU,GAA2B,EAAE,CAAC;IAC9C,MAAM,QAAQ,GAAG,kBAAkB,CAAC,CAAC,UAAU,EAAE,UAAU,CAAC,EAAE,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC,CAAC;IACxF,IAAA,iBAAM,EAAC,QAAQ,KAAK,SAAS,EAAE,KAAK,CAAC,8BAA8B,CAAC,CAAC;IAErE,MAAM,kBAAkB,GAAG,UAAU,CAAC,MAAM,CAAC;IAE7C,o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O,GAAG,OAAO,CAAC,MAAM,CAAC;IAC1B,CAAC;IAED,OAAO,KAAK,CAAC;AACd,CAAC;AAlBD,gCAkBC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, oob } from \"@fluidframework/core-utils/internal\";\n\nimport { defineLazyCachedProperty, hasSome, type Mutable } from \"../../util/index.js\";\n\nimport {\n\ttype ChangeRebaser,\n\ttype RevisionInfo,\n\ttype RevisionMetadataSource,\n\ttype TaggedChange,\n\tmakeAnonChange,\n\tmapTaggedChange,\n\ttagChange,\n\ttagRollbackInverse,\n} from \"./changeRebaser.js\";\nimport { type GraphCommit, type RevisionTag, mintCommit } from \"./types.js\";\n\n/**\n * Contains information about how the commit graph changed as the result of rebasing a source branch onto another target branch.\n * @remarks\n * ```text\n * Consider the commit graph below containing two branches, X and Y, with head commits C and E, respectively.\n * Branch Y branches off of Branch X at their common ancestor commit A, i.e. \"Y is based off of X at commit A\".\n *\n * A ─ B ─ C ← Branch X\n * └─ D ─ E ← Branch Y\n *\n * Branch Y is then rebased onto Branch X. This results in the following commit graph:\n *\n * A ─ B ─ C ← Branch X\n * └─ D'─ E'← Branch Y\n *\n * Commits D' and E' are the rebased versions of commits D and E, respectively. This results in:\n * deletedSourceCommits: [D, E],\n * targetCommits: [B, C],\n * sourceCommits: [D', E']\n * ```\n */\nexport interface RebasedCommits<TChange> {\n\t/**\n\t * The commits on the original source branch that were rebased. These are no longer referenced by the source branch and have\n\t * been replaced with new versions on the new source branch, see {@link sourceCommits}. In the case that the source\n\t * branch was already ahead of the target branch before the rebase, this list will be empty.\n\t */\n\tdeletedSourceCommits: GraphCommit<TChange>[];\n\t/**\n\t * All commits on the target branch that the source branch's commits were rebased over. These are now the direct\n\t * ancestors of {@link sourceCommits}. In the case that the source branch was already ahead of the target branch\n\t * before the rebase, this list will be empty.\n\t */\n\ttargetCommits: GraphCommit<TChange>[];\n\t/**\n\t * All commits on the source branch that are not also on the target branch after the rebase operation. In the case that the\n\t * source branch was already ahead of the target branch before the rebase, these are the same commits that were already on\n\t * the source branch before the rebase, otherwise these are the new, rebased versions of {@link deletedSourceCommits}.\n\t */\n\tsourceCommits: GraphCommit<TChange>[];\n}\n\n/**\n * Telemetry metrics for a rebase operation.\n */\nexport interface RebaseStats {\n\t/**\n\t * The length of the source branch before the rebase.\n\t */\n\treadonly sourceBranchLength: number;\n\t/**\n\t * Number of commits rebased over on the target branch.\n\t */\n\treadonly rebaseDistance: number;\n\t/**\n\t * The number of commits that are dropped from the source branch when rebased to the target branch.\n\t */\n\treadonly countDropped: number;\n}\n\nexport interface RebaseStatsWithDuration extends RebaseStats {\n\treadonly duration: number;\n}\n\nexport interface BranchRebaseResult<TChange> {\n\t/**\n\t * The head of a rebased source branch.\n\t */\n\treadonly newSourceHead: GraphCommit<TChange>;\n\t/**\n\t * A thunk that computes the cumulative change to the source branch (undefined if no change occurred)\n\t */\n\treadonly sourceChange: TChange | undefined;\n\t/**\n\t * Details about how the commits on the source branch changed\n\t */\n\treadonly commits: RebasedCommits<TChange>;\n\t/**\n\t * Telemetry properties for the rebase operation.\n\t */\n\treadonly telemetryProperties: RebaseStats;\n}\n\ninterface RebaseChangeResult<TChange> {\n\treadonly change: TChange;\n\t/**\n\t * Telemetry properties for the rebase operation.\n\t */\n\treadonly telemetryProperties: RebaseStats;\n}\n\n/**\n * Rebases a source branch onto another commit in a target branch.\n *\n * A \"branch\" is defined as a \"head\" commit and all ancestors of that commit, i.e. one linked list in a graph of commits.\n *\n * The source and target branch must share an ancestor.\n * @param changeRebaser - the change rebaser responsible for rebasing the changes in the commits of each branch\n * @param sourceHead - the head of the source branch, which will be rebased onto `targetHead`\n * @param targetHead - the commit to rebase the source branch onto\n * @returns a {@link BranchRebaseResult}\n * @remarks While a single branch must not have multiple commits with the same revision tag (that will result in undefined\n * behavior), there may be a commit on the source branch with the same revision tag as a commit on the target branch. If such\n * a pair is encountered while rebasing, it will be \"cancelled out\" in the new branch. For example:\n * ```\n * // (A)-(B)-(C) <- Branch X\n * // \\\n * // (B')-(D) <- Branch Y\n * //\n * // As Branch Y is rebased onto Branch X, commits B and B' cancel out so there is no version of B on the new rebased source branch\n * //\n * // (A)-(B)-(C) <- Branch X\n * // \\\n * // (D') <- Branch Y'\n * //\n * ```\n */\nexport function rebaseBranch<TChange>(\n\tmintRevisionTag: () => RevisionTag,\n\tchangeRebaser: ChangeRebaser<TChange>,\n\tsourceHead: GraphCommit<TChange>,\n\ttargetHead: GraphCommit<TChange>,\n): BranchRebaseResult<TChange>;\n\n/**\n * Rebases a source branch onto another commit in a target branch.\n *\n * A \"branch\" is defined as a \"head\" commit and all ancestors of that commit, i.e. one linked list in a graph of commits.\n *\n * The source and target branch must share an ancestor.\n * @param changeRebaser - the change rebaser responsible for rebasing the changes in the commits of each branch\n * @param sourceHead - the head of the source branch, which will be rebased onto `newBase`\n * @param targetCommit - the commit on the target branch to rebase the source branch onto.\n * @param targetHead - the head of the branch that `newBase` belongs to. Must be `newBase` or a descendent of `newBase`.\n * @returns a {@link BranchRebaseResult}\n * @remarks While a single branch must not have multiple commits with the same revision tag (that will result in undefined\n * behavior), there may be a commit on the source branch with the same revision tag as a commit on the target branch. If such\n * a pair is encountered while rebasing, it will be \"cancelled out\" in the new branch. Additionally, this function will rebase\n * the source branch _farther_ than `newBase` if the source branch's next commits after `newBase` match those on the target branch.\n * For example:\n * ```\n * // (A)-(B)-(C)-(D)-(E) <- Branch X\n * // \\\n * // (B')-(D')-(F) <- Branch Y\n * //\n * // If Branch Y is rebased onto commit C of Branch X, the branches must at least look like this afterwards (B was cancelled out):\n * //\n * // (A)-(B)-(C)-(D)-(E) <- Branch X\n * // \\\n * // (D'')-(F') <- Branch Y'\n * //\n * // But this function will recognize that B is equivalent to B' and D is equivalent to D', and instead produce:\n * //\n * // (A)-(B)-(C)-(D)-(E) <- Branch X\n * // \\\n * // (F') <- Branch Y'\n * ```\n */\nexport function rebaseBranch<TChange>(\n\tmintRevisionTag: () => RevisionTag,\n\tchangeRebaser: ChangeRebaser<TChange>,\n\tsourceHead: GraphCommit<TChange>,\n\ttargetCommit: GraphCommit<TChange>,\n\ttargetHead: GraphCommit<TChange>,\n): BranchRebaseResult<TChange>;\nexport function rebaseBranch<TChange>(\n\tmintRevisionTag: () => RevisionTag,\n\tchangeRebaser: ChangeRebaser<TChange>,\n\tsourceHead: GraphCommit<TChange>,\n\ttargetCommit: GraphCommit<TChange>,\n\ttargetHead = targetCommit,\n): BranchRebaseResult<TChange> {\n\t// Get both source and target as path arrays\n\tconst sourcePath: GraphCommit<TChange>[] = [];\n\tconst targetPath: GraphCommit<TChange>[] = [];\n\tconst ancestor = findCommonAncestor([sourceHead, sourcePath], [targetHead, targetPath]);\n\tassert(ancestor !== undefined, 0x675 /* branches must be related */);\n\n\tconst sourceBranchLength = sourcePath.length;\n\n\t// Find where `targetCommit` is in the target branch\n\tconst targetCommitIndex = targetPath.findIndex((r) => r === targetCommit);\n\tif (targetCommitIndex === -1) {\n\t\t// If the targetCommit is not in the target path, then it is either disjoint from `target` or it is behind/at\n\t\t// the commit where source and target diverge (ancestor), in which case there is nothing more to rebase\n\t\t// TODO: Ideally, this would be an \"assertExpensive\". It is commented out because it causes O(N²) behavior when\n\t\t// processing N inbound commits from the same client whose ref seq# is not advancing (which is a common case).\n\t\t// N can be large when the client is sending a burst of changes (potentially on reconnection).\n\t\t// assert(\n\t\t// \tfindCommonAncestor(targetCommit, targetHead) !== undefined,\n\t\t// \t0x676 /* target commit is not in target branch */,\n\t\t// );\n\t\treturn {\n\t\t\tnewSourceHead: sourceHead,\n\t\t\tsourceChange: undefined,\n\t\t\tcommits: { deletedSourceCommits: [], targetCommits: [], sourceCommits: sourcePath },\n\t\t\ttelemetryProperties: {\n\t\t\t\tsourceBranchLength,\n\t\t\t\trebaseDistance: targetCommitIndex + 1,\n\t\t\t\tcountDropped: 0,\n\t\t\t},\n\t\t};\n\t}\n\n\t// Iterate through the target path and look for commits that are also present on the source branch (i.e. they\n\t// have matching tags). Each commit found in the target branch can be skipped when processing the source branch\n\t// because it has already been rebased onto the target. In the case that one or more of these commits are present\n\t// directly after `targetCommit`, then the new base can be advanced further without having to do any work.\n\tconst sourceSet = new Set(sourcePath.map((r) => r.revision));\n\tlet newBaseIndex = targetCommitIndex;\n\n\tfor (const [i, { revision }] of targetPath.entries()) {\n\t\tif (sourceSet.has(revision)) {\n\t\t\tsourceSet.delete(revision);\n\t\t\tnewBaseIndex = Math.max(newBaseIndex, i);\n\t\t} else if (i > targetCommitIndex) {\n\t\t\tbreak;\n\t\t}\n\t}\n\n\t/** The commit on the target branch that the new source branch branches off of (i.e. the new common ancestor) */\n\tconst newBase = targetPath[newBaseIndex] ?? oob();\n\t// Figure out how much of the trunk to start rebasing over.\n\tconst targetCommits = targetPath.slice(0, newBaseIndex + 1);\n\tconst deletedSourceCommits = [...sourcePath];\n\n\t// If the source and target rebase path begin with a range that has all the same revisions, remove it; it is\n\t// equivalent on both branches and doesn't need to be rebased.\n\tconst targetRebasePath = [...targetCommits];\n\tif (hasSome(sourcePath) && hasSome(targetRebasePath)) {\n\t\tconst minLength = Math.min(sourcePath.length, targetRebasePath.length);\n\t\tfor (let i = 0; i < minLength; i++) {\n\t\t\tconst firstSourcePath = sourcePath[0];\n\t\t\tconst firstTargetRebasePath = targetRebasePath[0];\n\t\t\tif (firstSourcePath.revision === firstTargetRebasePath.revision) {\n\t\t\t\tsourcePath.shift();\n\t\t\t\ttargetRebasePath.shift();\n\t\t\t}\n\t\t}\n\t}\n\n\tconst sourceCommits: GraphCommit<TChange>[] = [];\n\n\t// If all commits that are about to be rebased over on the target branch already comprise the start of the source branch,\n\t// are in the same order, and have no other commits interleaving them, then no rebasing needs to occur. Those commits can\n\t// simply be removed from the source branch, and the remaining commits on the source branch are reparented off of the new\n\t// base commit.\n\tif (!hasSome(targetRebasePath)) {\n\t\tfor (const c of sourcePath) {\n\t\t\tsourceCommits.push(mintCommit(sourceCommits[sourceCommits.length - 1] ?? newBase, c));\n\t\t}\n\t\treturn {\n\t\t\tnewSourceHead: sourceCommits[sourceCommits.length - 1] ?? newBase,\n\t\t\tsourceChange: undefined,\n\t\t\tcommits: {\n\t\t\t\tdeletedSourceCommits,\n\t\t\t\ttargetCommits,\n\t\t\t\tsourceCommits,\n\t\t\t},\n\t\t\ttelemetryProperties: {\n\t\t\t\tsourceBranchLength,\n\t\t\t\trebaseDistance: targetCommits.length,\n\t\t\t\tcountDropped: sourceBranchLength - sourceSet.size,\n\t\t\t},\n\t\t};\n\t}\n\n\t// For each source commit, rebase backwards over the inverses of any commits already rebased, and then\n\t// rebase forwards over the rest of the commits up to the new base before advancing the new base.\n\tlet newHead = newBase;\n\tconst revInfos = getRevInfoFromTaggedChanges([...targetRebasePath, ...sourcePath]);\n\t// Note that the `revisionMetadata` gets updated as `revInfos` gets updated.\n\tconst revisionMetadata = revisionMetadataSourceFromInfo(revInfos);\n\tlet editsToCompose: TaggedChange<TChange>[] = targetRebasePath.slice();\n\tfor (const c of sourcePath) {\n\t\tconst rollback = rollbackFromCommit(changeRebaser, c, mintRevisionTag, false);\n\t\tif (sourceSet.has(c.revision)) {\n\t\t\tconst currentComposedEdit = makeAnonChange(changeRebaser.compose(editsToCompose));\n\t\t\teditsToCompose = [currentComposedEdit];\n\t\t\tconst change = changeRebaser.rebase(c, currentComposedEdit, revisionMetadata);\n\t\t\tnewHead = {\n\t\t\t\trevision: c.revision,\n\t\t\t\tchange,\n\t\t\t\tparent: newHead,\n\t\t\t};\n\t\t\tsourceCommits.push(newHead);\n\t\t\teditsToCompose.push(tagChange(change, c.revision));\n\t\t}\n\t\trevInfos.push({ revision: c.revision });\n\t\teditsToCompose.unshift(rollback);\n\t\trevInfos.unshift({ revision: rollback.revision, rollbackOf: rollback.rollbackOf });\n\t}\n\n\treturn defineLazyCachedProperty(\n\t\t{\n\t\t\tnewSourceHead: newHead,\n\t\t\tcommits: {\n\t\t\t\tdeletedSourceCommits,\n\t\t\t\ttargetCommits,\n\t\t\t\tsourceCommits,\n\t\t\t},\n\t\t\ttelemetryProperties: {\n\t\t\t\tsourceBranchLength,\n\t\t\t\trebaseDistance: targetCommits.length,\n\t\t\t\tcountDropped: sourceBranchLength - sourceSet.size,\n\t\t\t},\n\t\t},\n\t\t\"sourceChange\",\n\t\t() => changeRebaser.compose(editsToCompose),\n\t);\n}\n\n/**\n * \"Sandwich/Horseshoe Rebase\" a change over the given source and target branches\n * @param changeRebaser - the change rebaser responsible for rebasing the change over the commits in each branch\n * @param change - the change to rebase\n * @param sourceHead - the head of the branch that `change` is based on\n * @param targetHead - the branch to rebase `change` onto\n * @returns the rebased change\n *\n * @remarks inverses will be cached.\n */\nexport function rebaseChange<TChange>(\n\tchangeRebaser: ChangeRebaser<TChange>,\n\tchange: TaggedChange<TChange>,\n\tsourceHead: GraphCommit<TChange>,\n\ttargetHead: GraphCommit<TChange>,\n\tmintRevisionTag: () => RevisionTag,\n): RebaseChangeResult<TChange> {\n\tconst sourcePath: GraphCommit<TChange>[] = [];\n\tconst targetPath: GraphCommit<TChange>[] = [];\n\tassert(\n\t\tfindCommonAncestor([sourceHead, sourcePath], [targetHead, targetPath]) !== undefined,\n\t\t0x576 /* branch A and branch B must be related */,\n\t);\n\n\tconst inverses = sourcePath.map((commit) =>\n\t\trollbackFromCommit(changeRebaser, commit, mintRevisionTag, true),\n\t);\n\tinverses.reverse();\n\n\tconst telemetryProperties = {\n\t\tsourceBranchLength: 1,\n\t\trebaseDistance: sourcePath.length + targetPath.length,\n\t\tcountDropped: 0,\n\t};\n\n\treturn {\n\t\tchange: rebaseChangeOverChanges(changeRebaser, change, [...inverses, ...targetPath]),\n\t\ttelemetryProperties,\n\t};\n}\n\n/**\n */\nexport function revisionMetadataSourceFromInfo(\n\trevInfos: readonly RevisionInfo[],\n): RevisionMetadataSource {\n\tconst getIndex = (revision: RevisionTag): number | undefined => {\n\t\tconst index = revInfos.findIndex((revInfo) => revInfo.revision === revision);\n\t\treturn index >= 0 ? index : undefined;\n\t};\n\tconst tryGetInfo = (revision: RevisionTag | undefined): RevisionInfo | undefined => {\n\t\tif (revision === undefined) {\n\t\t\treturn undefined;\n\t\t}\n\t\tconst index = getIndex(revision);\n\t\treturn index === undefined ? undefined : revInfos[index];\n\t};\n\n\tconst hasRollback = (revision: RevisionTag): boolean => {\n\t\treturn revInfos.find((info) => info.rollbackOf === revision) !== undefined;\n\t};\n\n\treturn { getIndex, tryGetInfo, hasRollback };\n}\n\nexport function rebaseChangeOverChanges<TChange>(\n\tchangeRebaser: ChangeRebaser<TChange>,\n\tchangeToRebase: TaggedChange<TChange>,\n\tchangesToRebaseOver: TaggedChange<TChange>[],\n): TChange {\n\tconst revisionMetadata = revisionMetadataSourceFromInfo(\n\t\tgetRevInfoFromTaggedChanges([...changesToRebaseOver, changeToRebase]),\n\t);\n\n\treturn changesToRebaseOver.reduce(\n\t\t(a, b) => mapTaggedChange(changeToRebase, changeRebaser.rebase(a, b, revisionMetadata)),\n\t\tchangeToRebase,\n\t).change;\n}\n\n// TODO: Deduplicate\nfunction getRevInfoFromTaggedChanges(changes: TaggedChange<unknown>[]): RevisionInfo[] {\n\tconst revInfos: RevisionInfo[] = [];\n\tfor (const taggedChange of changes) {\n\t\trevInfos.push(...revisionInfoFromTaggedChange(taggedChange));\n\t}\n\n\treturn revInfos;\n}\n\n// TODO: Deduplicate\nfunction revisionInfoFromTaggedChange(taggedChange: TaggedChange<unknown>): RevisionInfo[] {\n\tconst revInfos: RevisionInfo[] = [];\n\tif (taggedChange.revision !== undefined) {\n\t\tconst info: Mutable<RevisionInfo> = { revision: taggedChange.revision };\n\t\tif (taggedChange.rollbackOf !== undefined) {\n\t\t\tinfo.rollbackOf = taggedChange.rollbackOf;\n\t\t}\n\t\trevInfos.push(info);\n\t}\n\treturn revInfos;\n}\n\nfunction rollbackFromCommit<TChange>(\n\tchangeRebaser: ChangeRebaser<TChange>,\n\tcommit: GraphCommit<TChange>,\n\tmintRevisionTag: () => RevisionTag,\n\tcache?: boolean,\n): TaggedChange<TChange, RevisionTag> {\n\tconst rollback = Rollback.get(commit);\n\tif (rollback !== undefined) {\n\t\treturn rollback;\n\t}\n\tconst tag = mintRevisionTag();\n\tconst untagged = changeRebaser.invert(commit, true, tag);\n\tconst deeplyTaggedRollback = changeRebaser.changeRevision(untagged, tag, commit.revision);\n\tconst fullyTaggedRollback = tagRollbackInverse(deeplyTaggedRollback, tag, commit.revision);\n\n\tif (cache === true) {\n\t\tRollback.set(commit, fullyTaggedRollback);\n\t}\n\treturn fullyTaggedRollback;\n}\n\n/**\n * Find the furthest ancestor of some descendant.\n * @param descendant - a descendant. If an empty `path` array is included, it will be populated\n * with the chain of ancestry for `descendant` from most distant to closest (not including the furthest ancestor,\n * but otherwise including `descendant`).\n * @returns the furthest ancestor of `descendant`, or `descendant` itself if `descendant` has no ancestors.\n */\nexport function findAncestor<T extends { parent?: T }>(\n\tdescendant: T | [descendant: T, path?: T[]],\n): T;\n/**\n * Find the furthest ancestor of some descendant.\n * @param descendant - a descendant. If an empty `path` array is included, it will be populated\n * with the chain of ancestry for `descendant` from most distant to closest (not including the furthest ancestor,\n * but otherwise including `descendant`).\n * @returns the furthest ancestor of `descendant`, or `descendant` itself if `descendant` has no ancestors. Returns\n * `undefined` if `descendant` is undefined.\n */\nexport function findAncestor<T extends { parent?: T }>(\n\tdescendant: T | [descendant: T | undefined, path?: T[]] | undefined,\n): T | undefined;\n/**\n * Find an ancestor of some descendant.\n * @param descendant - a descendant. If an empty `path` array is included, it will be populated\n * with the chain of ancestry for `descendant` from most distant to closest (not including the ancestor found by `predicate`,\n * but otherwise including `descendant`).\n * @param predicate - a function which will be evaluated on `descendant` and then ancestor of `descendant` (in ascending order) until it returns true.\n * @returns the closest ancestor of `descendant` that satisfies `predicate`, or `undefined` if no such ancestor exists.\n *\n * @example\n *\n * ```typescript\n * interface Parented {\n * id: string;\n * parent?: Parented;\n * }\n * const g = { id: \"g\" }; // Grandparent\n * const p = { parent: g, id: \"p\" }; // Parent\n * const c = { parent: p, id: \"c\" }; // Child\n * const path: Parented[] = [];\n * const ancestor = findAncestor<Parented>([c, path], (n) => n.id === \"g\");\n * // ancestor === g\n * // path === [p, c]\n * ```\n */\nexport function findAncestor<T extends { parent?: T }>(\n\tdescendant: T | [descendant: T | undefined, path?: T[]] | undefined,\n\tpredicate: (t: T) => boolean,\n): T | undefined;\nexport function findAncestor<T extends { parent?: T }>(\n\tdescendant: T | [descendant: T | undefined, path?: T[]] | undefined,\n\tpredicate: (t: T) => boolean = (t): boolean => t.parent === undefined,\n): T | undefined {\n\tlet d: T | undefined;\n\tlet path: T[] | undefined;\n\tif (Array.isArray(descendant)) {\n\t\t[d, path] = descendant;\n\t} else {\n\t\td = descendant;\n\t}\n\tfor (let cur = d; cur !== undefined; cur = cur.parent) {\n\t\tif (predicate(cur)) {\n\t\t\tpath?.reverse();\n\t\t\treturn cur;\n\t\t}\n\t\tpath?.push(cur);\n\t}\n\n\tif (path !== undefined) {\n\t\tpath.length = 0;\n\t}\n\treturn undefined;\n}\n\n/**\n * Find a common ancestor between two descendants that are linked by parent pointers.\n * @param descendantA - a descendant. If an empty `path` array is included, it will be populated\n * with the chain of commits from the ancestor to `descendantA` (not including the ancestor).\n * @param descendantB - another descendant. If an empty `path` array is included, it will be populated\n * with the chain of commits from the ancestor to `descendantB` (not including the ancestor).\n * @returns the common ancestor of `descendantA` and `descendantB`, or `undefined` if no such ancestor exists.\n *\n * @example\n *\n * ```typescript\n * interface Parented {\n * parent?: Parented;\n * }\n * const shared = {};\n * const a = { parent: shared };\n * const b1 = { parent: shared };\n * const b2 = { parent: b1 };\n * const pathB: Parented[] = []\n * const ancestor = findCommonAncestor<Parented>(a, [b2, pathB]);\n * // ancestor === shared\n * // pathB === [b1, b2]\n * ```\n */\nexport function findCommonAncestor<T extends { parent?: T }>(\n\tdescendantA: T | [descendantA: T, path?: T[]] | undefined,\n\tdescendantB: T | [descendantB: T, path?: T[]] | undefined,\n): T | undefined {\n\tlet a: T | undefined;\n\tlet b: T | undefined;\n\tlet pathA: T[] | undefined;\n\tlet pathB: T[] | undefined;\n\tif (Array.isArray(descendantA)) {\n\t\t[a, pathA] = descendantA;\n\t\tassert(pathA === undefined || pathA.length === 0, 0x578 /* Path A must be empty */);\n\t} else {\n\t\ta = descendantA;\n\t}\n\tif (Array.isArray(descendantB)) {\n\t\t[b, pathB] = descendantB;\n\t\tassert(pathB === undefined || pathB.length === 0, 0x579 /* Path B must be empty */);\n\t} else {\n\t\tb = descendantB;\n\t}\n\n\tif (a === b) {\n\t\treturn a;\n\t}\n\n\tconst reversePaths = (): void => {\n\t\tpathA?.reverse();\n\t\tpathB?.reverse();\n\t};\n\n\tconst visited = new Set();\n\twhile (a !== undefined || b !== undefined) {\n\t\tif (a !== undefined) {\n\t\t\tif (visited.has(a)) {\n\t\t\t\tif (pathB !== undefined) {\n\t\t\t\t\tpathB.length = pathB.findIndex((r) => Object.is(r, a));\n\t\t\t\t}\n\t\t\t\treversePaths();\n\t\t\t\treturn a;\n\t\t\t}\n\t\t\tvisited.add(a);\n\t\t\tpathA?.push(a);\n\t\t\ta = a.parent;\n\t\t}\n\n\t\tif (b !== undefined) {\n\t\t\tif (visited.has(b)) {\n\t\t\t\tif (pathA !== undefined) {\n\t\t\t\t\tpathA.length = pathA.findIndex((r) => Object.is(r, b));\n\t\t\t\t}\n\t\t\t\treversePaths();\n\t\t\t\treturn b;\n\t\t\t}\n\t\t\tvisited.add(b);\n\t\t\tpathB?.push(b);\n\t\t\tb = b.parent;\n\t\t}\n\t}\n\n\tif (pathA !== undefined) {\n\t\tpathA.length = 0;\n\t}\n\tif (pathB !== undefined) {\n\t\tpathB.length = 0;\n\t}\n\treturn undefined;\n}\n\nexport function replaceChange<TChange>(\n\tcommit: GraphCommit<TChange>,\n\tchange: TChange,\n): GraphCommit<TChange> {\n\tconst output = { ...commit, change };\n\tRollback.set(output, undefined);\n\treturn output;\n}\n\n/** Associates rollback data with commits */\nnamespace Rollback {\n\tconst map = new WeakMap<GraphCommit<unknown>, TaggedChange<unknown, RevisionTag>>();\n\n\texport function get<TChange>(\n\t\tcommit: GraphCommit<TChange>,\n\t): TaggedChange<TChange, RevisionTag> | undefined {\n\t\treturn map.get(commit) as TaggedChange<TChange, RevisionTag> | undefined;\n\t}\n\n\texport function set<TChange>(\n\t\tcommit: GraphCommit<TChange>,\n\t\trollback: TaggedChange<TChange, RevisionTag> | undefined,\n\t): void {\n\t\tif (rollback === undefined) {\n\t\t\tmap.delete(commit);\n\t\t} else {\n\t\t\tmap.set(commit, rollback);\n\t\t}\n\t}\n}\n\n/**\n * Checks if one node is an ancestor of another in a parent-linked tree structure.\n * @param ancestor - The potential ancestor node\n * @param descendant - The potential descendant node\n * @param allowEqual - If true, returns true when ancestor === descendant\n * @returns true if ancestor is an ancestor of descendant (or equal if allowEqual is true)\n */\nexport function isAncestor<TNode extends { readonly parent?: TNode }>(\n\tancestor: TNode,\n\tdescendant: TNode,\n\tallowEqual: boolean,\n): boolean {\n\tif (allowEqual && ancestor === descendant) {\n\t\treturn true;\n\t}\n\n\tlet current = descendant.parent;\n\twhile (current !== undefined) {\n\t\tif (current === ancestor) {\n\t\t\treturn true;\n\t\t}\n\t\tcurrent = current.parent;\n\t}\n\n\treturn false;\n}\n"]}
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/core/rebase/utils.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAAkE;AAElE,kDAAsF;AAEtF,yDAS4B;AAC5B,yCAA4E;AAuK5E,SAAgB,YAAY,CAC3B,eAAkC,EAClC,aAAqC,EACrC,UAAgC,EAChC,YAAkC,EAClC,UAAU,GAAG,YAAY;IAEzB,4CAA4C;IAC5C,MAAM,UAAU,GAA2B,EAAE,CAAC;IAC9C,MAAM,UAAU,GAA2B,EAAE,CAAC;IAC9C,MAAM,QAAQ,GAAG,kBAAkB,CAAC,CAAC,UAAU,EAAE,UAAU,CAAC,EAAE,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC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AAG,UAAU,CAAC,MAAM,CAAC;IAChC,OAAO,OAAO,KAAK,SAAS,EAAE,CAAC;QAC9B,IAAI,OAAO,KAAK,QAAQ,EAAE,CAAC;YAC1B,OAAO,IAAI,CAAC;QACb,CAAC;QACD,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC;IAC1B,CAAC;IAED,OAAO,KAAK,CAAC;AACd,CAAC;AAlBD,gCAkBC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, oob } from \"@fluidframework/core-utils/internal\";\n\nimport { defineLazyCachedProperty, hasSome, type Mutable } from \"../../util/index.js\";\n\nimport {\n\ttype ChangeRebaser,\n\ttype RevisionInfo,\n\ttype RevisionMetadataSource,\n\ttype TaggedChange,\n\tmakeAnonChange,\n\tmapTaggedChange,\n\ttagChange,\n\ttagRollbackInverse,\n} from \"./changeRebaser.js\";\nimport { type GraphCommit, type RevisionTag, mintCommit } from \"./types.js\";\n\n/**\n * Contains information about how the commit graph changed as the result of rebasing a source branch onto another target branch.\n * @remarks\n * ```text\n * Consider the commit graph below containing two branches, X and Y, with head commits C and E, respectively.\n * Branch Y branches off of Branch X at their common ancestor commit A, i.e. \"Y is based off of X at commit A\".\n *\n * A ─ B ─ C ← Branch X\n * └─ D ─ E ← Branch Y\n *\n * Branch Y is then rebased onto Branch X. This results in the following commit graph:\n *\n * A ─ B ─ C ← Branch X\n * └─ D'─ E'← Branch Y\n *\n * Commits D' and E' are the rebased versions of commits D and E, respectively. This results in:\n * deletedSourceCommits: [D, E],\n * targetCommits: [B, C],\n * sourceCommits: [D', E']\n * ```\n */\nexport interface RebasedCommits<TChange> {\n\t/**\n\t * The commits on the original source branch that were rebased. These are no longer referenced by the source branch and have\n\t * been replaced with new versions on the new source branch, see {@link sourceCommits}. In the case that the source\n\t * branch was already ahead of the target branch before the rebase, this list will be empty.\n\t */\n\tdeletedSourceCommits: GraphCommit<TChange>[];\n\t/**\n\t * All commits on the target branch that the source branch's commits were rebased over. These are now the direct\n\t * ancestors of {@link sourceCommits}. In the case that the source branch was already ahead of the target branch\n\t * before the rebase, this list will be empty.\n\t */\n\ttargetCommits: GraphCommit<TChange>[];\n\t/**\n\t * All commits on the source branch that are not also on the target branch after the rebase operation. In the case that the\n\t * source branch was already ahead of the target branch before the rebase, these are the same commits that were already on\n\t * the source branch before the rebase, otherwise these are the new, rebased versions of {@link deletedSourceCommits}.\n\t */\n\tsourceCommits: GraphCommit<TChange>[];\n}\n\n/**\n * Telemetry metrics for a rebase operation.\n */\nexport interface RebaseStats {\n\t/**\n\t * The length of the source branch before the rebase.\n\t */\n\treadonly sourceBranchLength: number;\n\t/**\n\t * Number of commits rebased over on the target branch.\n\t */\n\treadonly rebaseDistance: number;\n\t/**\n\t * The number of commits that are dropped from the source branch when rebased to the target branch.\n\t */\n\treadonly countDropped: number;\n}\n\nexport interface RebaseStatsWithDuration extends RebaseStats {\n\treadonly duration: number;\n}\n\nexport interface BranchRebaseResult<TChange> {\n\t/**\n\t * The head of a rebased source branch.\n\t */\n\treadonly newSourceHead: GraphCommit<TChange>;\n\t/**\n\t * A thunk that computes the cumulative change to the source branch (undefined if no change occurred)\n\t */\n\treadonly sourceChange: TChange | undefined;\n\t/**\n\t * Details about how the commits on the source branch changed\n\t */\n\treadonly commits: RebasedCommits<TChange>;\n\t/**\n\t * Telemetry properties for the rebase operation.\n\t */\n\treadonly telemetryProperties: RebaseStats;\n}\n\ninterface RebaseChangeResult<TChange> {\n\treadonly change: TChange;\n\t/**\n\t * Telemetry properties for the rebase operation.\n\t */\n\treadonly telemetryProperties: RebaseStats;\n}\n\n/**\n * Rebases a source branch onto another commit in a target branch.\n *\n * A \"branch\" is defined as a \"head\" commit and all ancestors of that commit, i.e. one linked list in a graph of commits.\n *\n * The source and target branch must share an ancestor.\n * @param changeRebaser - the change rebaser responsible for rebasing the changes in the commits of each branch\n * @param sourceHead - the head of the source branch, which will be rebased onto `targetHead`\n * @param targetHead - the commit to rebase the source branch onto\n * @returns a {@link BranchRebaseResult}\n * @remarks While a single branch must not have multiple commits with the same revision tag (that will result in undefined\n * behavior), there may be a commit on the source branch with the same revision tag as a commit on the target branch. If such\n * a pair is encountered while rebasing, it will be \"cancelled out\" in the new branch. For example:\n * ```\n * // (A)-(B)-(C) <- Branch X\n * // \\\n * // (B')-(D) <- Branch Y\n * //\n * // As Branch Y is rebased onto Branch X, commits B and B' cancel out so there is no version of B on the new rebased source branch\n * //\n * // (A)-(B)-(C) <- Branch X\n * // \\\n * // (D') <- Branch Y'\n * //\n * ```\n */\nexport function rebaseBranch<TChange>(\n\tmintRevisionTag: () => RevisionTag,\n\tchangeRebaser: ChangeRebaser<TChange>,\n\tsourceHead: GraphCommit<TChange>,\n\ttargetHead: GraphCommit<TChange>,\n): BranchRebaseResult<TChange>;\n\n/**\n * Rebases a source branch onto another commit in a target branch.\n *\n * A \"branch\" is defined as a \"head\" commit and all ancestors of that commit, i.e. one linked list in a graph of commits.\n *\n * The source and target branch must share an ancestor.\n * @param changeRebaser - the change rebaser responsible for rebasing the changes in the commits of each branch\n * @param sourceHead - the head of the source branch, which will be rebased onto `newBase`\n * @param targetCommit - the commit on the target branch to rebase the source branch onto.\n * @param targetHead - the head of the branch that `newBase` belongs to. Must be `newBase` or a descendent of `newBase`.\n * @returns a {@link BranchRebaseResult}\n * @remarks While a single branch must not have multiple commits with the same revision tag (that will result in undefined\n * behavior), there may be a commit on the source branch with the same revision tag as a commit on the target branch. If such\n * a pair is encountered while rebasing, it will be \"cancelled out\" in the new branch. Additionally, this function will rebase\n * the source branch _farther_ than `newBase` if the source branch's next commits after `newBase` match those on the target branch.\n * For example:\n * ```\n * // (A)-(B)-(C)-(D)-(E) <- Branch X\n * // \\\n * // (B')-(D')-(F) <- Branch Y\n * //\n * // If Branch Y is rebased onto commit C of Branch X, the branches must at least look like this afterwards (B was cancelled out):\n * //\n * // (A)-(B)-(C)-(D)-(E) <- Branch X\n * // \\\n * // (D'')-(F') <- Branch Y'\n * //\n * // But this function will recognize that B is equivalent to B' and D is equivalent to D', and instead produce:\n * //\n * // (A)-(B)-(C)-(D)-(E) <- Branch X\n * // \\\n * // (F') <- Branch Y'\n * ```\n */\nexport function rebaseBranch<TChange>(\n\tmintRevisionTag: () => RevisionTag,\n\tchangeRebaser: ChangeRebaser<TChange>,\n\tsourceHead: GraphCommit<TChange>,\n\ttargetCommit: GraphCommit<TChange>,\n\ttargetHead: GraphCommit<TChange>,\n): BranchRebaseResult<TChange>;\nexport function rebaseBranch<TChange>(\n\tmintRevisionTag: () => RevisionTag,\n\tchangeRebaser: ChangeRebaser<TChange>,\n\tsourceHead: GraphCommit<TChange>,\n\ttargetCommit: GraphCommit<TChange>,\n\ttargetHead = targetCommit,\n): BranchRebaseResult<TChange> {\n\t// Get both source and target as path arrays\n\tconst sourcePath: GraphCommit<TChange>[] = [];\n\tconst targetPath: GraphCommit<TChange>[] = [];\n\tconst ancestor = findCommonAncestor([sourceHead, sourcePath], [targetHead, targetPath]);\n\tassert(ancestor !== undefined, 0x675 /* branches must be related */);\n\n\tconst sourceBranchLength = sourcePath.length;\n\n\t// Find where `targetCommit` is in the target branch\n\tconst targetCommitIndex = targetPath.findIndex((r) => r === targetCommit);\n\tif (targetCommitIndex === -1) {\n\t\t// If the targetCommit is not in the target path, then it is either disjoint from `target` or it is behind/at\n\t\t// the commit where source and target diverge (ancestor), in which case there is nothing more to rebase\n\t\t// TODO: Ideally, this would be an \"assertExpensive\". It is commented out because it causes O(N²) behavior when\n\t\t// processing N inbound commits from the same client whose ref seq# is not advancing (which is a common case).\n\t\t// N can be large when the client is sending a burst of changes (potentially on reconnection).\n\t\t// assert(\n\t\t// \tfindCommonAncestor(targetCommit, targetHead) !== undefined,\n\t\t// \t0x676 /* target commit is not in target branch */,\n\t\t// );\n\t\treturn {\n\t\t\tnewSourceHead: sourceHead,\n\t\t\tsourceChange: undefined,\n\t\t\tcommits: { deletedSourceCommits: [], targetCommits: [], sourceCommits: sourcePath },\n\t\t\ttelemetryProperties: {\n\t\t\t\tsourceBranchLength,\n\t\t\t\trebaseDistance: targetCommitIndex + 1,\n\t\t\t\tcountDropped: 0,\n\t\t\t},\n\t\t};\n\t}\n\n\t// Iterate through the target path and look for commits that are also present on the source branch (i.e. they\n\t// have matching tags). Each commit found in the target branch can be skipped when processing the source branch\n\t// because it has already been rebased onto the target. In the case that one or more of these commits are present\n\t// directly after `targetCommit`, then the new base can be advanced further without having to do any work.\n\tconst sourceSet = new Set(sourcePath.map((r) => r.revision));\n\tlet newBaseIndex = targetCommitIndex;\n\n\tfor (const [i, { revision }] of targetPath.entries()) {\n\t\tif (sourceSet.has(revision)) {\n\t\t\tsourceSet.delete(revision);\n\t\t\tnewBaseIndex = Math.max(newBaseIndex, i);\n\t\t} else if (i > targetCommitIndex) {\n\t\t\tbreak;\n\t\t}\n\t}\n\n\t/** The commit on the target branch that the new source branch branches off of (i.e. the new common ancestor) */\n\tconst newBase = targetPath[newBaseIndex] ?? oob();\n\t// Figure out how much of the trunk to start rebasing over.\n\tconst targetCommits = targetPath.slice(0, newBaseIndex + 1);\n\tconst deletedSourceCommits = [...sourcePath];\n\n\t// If the source and target rebase path begin with a range that has all the same revisions, remove it; it is\n\t// equivalent on both branches and doesn't need to be rebased.\n\tconst targetRebasePath = [...targetCommits];\n\tif (hasSome(sourcePath) && hasSome(targetRebasePath)) {\n\t\tconst minLength = Math.min(sourcePath.length, targetRebasePath.length);\n\t\tfor (let i = 0; i < minLength; i++) {\n\t\t\tconst firstSourcePath = sourcePath[0];\n\t\t\tconst firstTargetRebasePath = targetRebasePath[0];\n\t\t\tif (firstSourcePath.revision === firstTargetRebasePath.revision) {\n\t\t\t\tsourcePath.shift();\n\t\t\t\ttargetRebasePath.shift();\n\t\t\t}\n\t\t}\n\t}\n\n\tconst sourceCommits: GraphCommit<TChange>[] = [];\n\n\t// If all commits that are about to be rebased over on the target branch already comprise the start of the source branch,\n\t// are in the same order, and have no other commits interleaving them, then no rebasing needs to occur. Those commits can\n\t// simply be removed from the source branch, and the remaining commits on the source branch are reparented off of the new\n\t// base commit.\n\tif (!hasSome(targetRebasePath)) {\n\t\tfor (const c of sourcePath) {\n\t\t\tsourceCommits.push(mintCommit(sourceCommits[sourceCommits.length - 1] ?? newBase, c));\n\t\t}\n\t\treturn {\n\t\t\tnewSourceHead: sourceCommits[sourceCommits.length - 1] ?? newBase,\n\t\t\tsourceChange: undefined,\n\t\t\tcommits: {\n\t\t\t\tdeletedSourceCommits,\n\t\t\t\ttargetCommits,\n\t\t\t\tsourceCommits,\n\t\t\t},\n\t\t\ttelemetryProperties: {\n\t\t\t\tsourceBranchLength,\n\t\t\t\trebaseDistance: targetCommits.length,\n\t\t\t\tcountDropped: sourceBranchLength - sourceSet.size,\n\t\t\t},\n\t\t};\n\t}\n\n\t// For each source commit, rebase backwards over the inverses of any commits already rebased, and then\n\t// rebase forwards over the rest of the commits up to the new base before advancing the new base.\n\tlet newHead = newBase;\n\tconst revInfos = getRevInfoFromTaggedChanges([...targetRebasePath, ...sourcePath]);\n\t// Note that the `revisionMetadata` gets updated as `revInfos` gets updated.\n\tconst revisionMetadata = revisionMetadataSourceFromInfo(revInfos);\n\tlet editsToCompose: TaggedChange<TChange>[] = targetRebasePath.slice();\n\tfor (const c of sourcePath) {\n\t\tconst rollback = rollbackFromCommit(changeRebaser, c, mintRevisionTag, true /* cache */);\n\t\tif (sourceSet.has(c.revision)) {\n\t\t\tconst currentComposedEdit = makeAnonChange(changeRebaser.compose(editsToCompose));\n\t\t\teditsToCompose = [currentComposedEdit];\n\t\t\tconst change = changeRebaser.rebase(c, currentComposedEdit, revisionMetadata);\n\t\t\tnewHead = {\n\t\t\t\trevision: c.revision,\n\t\t\t\tchange,\n\t\t\t\tparent: newHead,\n\t\t\t};\n\t\t\tsourceCommits.push(newHead);\n\t\t\teditsToCompose.push(tagChange(change, c.revision));\n\t\t}\n\t\trevInfos.push({ revision: c.revision });\n\t\teditsToCompose.unshift(rollback);\n\t\trevInfos.unshift({ revision: rollback.revision, rollbackOf: rollback.rollbackOf });\n\t}\n\n\treturn defineLazyCachedProperty(\n\t\t{\n\t\t\tnewSourceHead: newHead,\n\t\t\tcommits: {\n\t\t\t\tdeletedSourceCommits,\n\t\t\t\ttargetCommits,\n\t\t\t\tsourceCommits,\n\t\t\t},\n\t\t\ttelemetryProperties: {\n\t\t\t\tsourceBranchLength,\n\t\t\t\trebaseDistance: targetCommits.length,\n\t\t\t\tcountDropped: sourceBranchLength - sourceSet.size,\n\t\t\t},\n\t\t},\n\t\t\"sourceChange\",\n\t\t() => changeRebaser.compose(editsToCompose),\n\t);\n}\n\n/**\n * \"Sandwich/Horseshoe Rebase\" a change over the given source and target branches\n * @param changeRebaser - the change rebaser responsible for rebasing the change over the commits in each branch\n * @param change - the change to rebase\n * @param sourceHead - the head of the branch that `change` is based on\n * @param targetHead - the branch to rebase `change` onto\n * @returns the rebased change\n *\n * @remarks inverses will be cached.\n */\nexport function rebaseChange<TChange>(\n\tchangeRebaser: ChangeRebaser<TChange>,\n\tchange: TaggedChange<TChange>,\n\tsourceHead: GraphCommit<TChange>,\n\ttargetHead: GraphCommit<TChange>,\n\tmintRevisionTag: () => RevisionTag,\n): RebaseChangeResult<TChange> {\n\tconst sourcePath: GraphCommit<TChange>[] = [];\n\tconst targetPath: GraphCommit<TChange>[] = [];\n\tassert(\n\t\tfindCommonAncestor([sourceHead, sourcePath], [targetHead, targetPath]) !== undefined,\n\t\t0x576 /* branch A and branch B must be related */,\n\t);\n\n\tconst inverses = sourcePath.map((commit) =>\n\t\trollbackFromCommit(changeRebaser, commit, mintRevisionTag, true),\n\t);\n\tinverses.reverse();\n\n\tconst telemetryProperties = {\n\t\tsourceBranchLength: 1,\n\t\trebaseDistance: sourcePath.length + targetPath.length,\n\t\tcountDropped: 0,\n\t};\n\n\treturn {\n\t\tchange: rebaseChangeOverChanges(changeRebaser, change, [...inverses, ...targetPath]),\n\t\ttelemetryProperties,\n\t};\n}\n\n/**\n */\nexport function revisionMetadataSourceFromInfo(\n\trevInfos: readonly RevisionInfo[],\n): RevisionMetadataSource {\n\tconst getIndex = (revision: RevisionTag): number | undefined => {\n\t\tconst index = revInfos.findIndex((revInfo) => revInfo.revision === revision);\n\t\treturn index >= 0 ? index : undefined;\n\t};\n\tconst tryGetInfo = (revision: RevisionTag | undefined): RevisionInfo | undefined => {\n\t\tif (revision === undefined) {\n\t\t\treturn undefined;\n\t\t}\n\t\tconst index = getIndex(revision);\n\t\treturn index === undefined ? undefined : revInfos[index];\n\t};\n\n\tconst hasRollback = (revision: RevisionTag): boolean => {\n\t\treturn revInfos.find((info) => info.rollbackOf === revision) !== undefined;\n\t};\n\n\treturn { getIndex, tryGetInfo, hasRollback };\n}\n\nexport function rebaseChangeOverChanges<TChange>(\n\tchangeRebaser: ChangeRebaser<TChange>,\n\tchangeToRebase: TaggedChange<TChange>,\n\tchangesToRebaseOver: TaggedChange<TChange>[],\n): TChange {\n\tconst revisionMetadata = revisionMetadataSourceFromInfo(\n\t\tgetRevInfoFromTaggedChanges([...changesToRebaseOver, changeToRebase]),\n\t);\n\n\treturn changesToRebaseOver.reduce(\n\t\t(a, b) => mapTaggedChange(changeToRebase, changeRebaser.rebase(a, b, revisionMetadata)),\n\t\tchangeToRebase,\n\t).change;\n}\n\n// TODO: Deduplicate\nfunction getRevInfoFromTaggedChanges(changes: TaggedChange<unknown>[]): RevisionInfo[] {\n\tconst revInfos: RevisionInfo[] = [];\n\tfor (const taggedChange of changes) {\n\t\trevInfos.push(...revisionInfoFromTaggedChange(taggedChange));\n\t}\n\n\treturn revInfos;\n}\n\n// TODO: Deduplicate\nfunction revisionInfoFromTaggedChange(taggedChange: TaggedChange<unknown>): RevisionInfo[] {\n\tconst revInfos: RevisionInfo[] = [];\n\tif (taggedChange.revision !== undefined) {\n\t\tconst info: Mutable<RevisionInfo> = { revision: taggedChange.revision };\n\t\tif (taggedChange.rollbackOf !== undefined) {\n\t\t\tinfo.rollbackOf = taggedChange.rollbackOf;\n\t\t}\n\t\trevInfos.push(info);\n\t}\n\treturn revInfos;\n}\n\nfunction rollbackFromCommit<TChange>(\n\tchangeRebaser: ChangeRebaser<TChange>,\n\tcommit: GraphCommit<TChange>,\n\tmintRevisionTag: () => RevisionTag,\n\tcache?: boolean,\n): TaggedChange<TChange, RevisionTag> {\n\tconst rollback = Rollback.get(commit);\n\tif (rollback !== undefined) {\n\t\treturn rollback;\n\t}\n\tconst tag = mintRevisionTag();\n\tconst untagged = changeRebaser.invert(commit, true, tag);\n\tconst deeplyTaggedRollback = changeRebaser.changeRevision(untagged, tag, commit.revision);\n\tconst fullyTaggedRollback = tagRollbackInverse(deeplyTaggedRollback, tag, commit.revision);\n\n\tif (cache === true) {\n\t\tRollback.set(commit, fullyTaggedRollback);\n\t}\n\treturn fullyTaggedRollback;\n}\n\n/**\n * Find the furthest ancestor of some descendant.\n * @param descendant - a descendant. If an empty `path` array is included, it will be populated\n * with the chain of ancestry for `descendant` from most distant to closest (not including the furthest ancestor,\n * but otherwise including `descendant`).\n * @returns the furthest ancestor of `descendant`, or `descendant` itself if `descendant` has no ancestors.\n */\nexport function findAncestor<T extends { parent?: T }>(\n\tdescendant: T | [descendant: T, path?: T[]],\n): T;\n/**\n * Find the furthest ancestor of some descendant.\n * @param descendant - a descendant. If an empty `path` array is included, it will be populated\n * with the chain of ancestry for `descendant` from most distant to closest (not including the furthest ancestor,\n * but otherwise including `descendant`).\n * @returns the furthest ancestor of `descendant`, or `descendant` itself if `descendant` has no ancestors. Returns\n * `undefined` if `descendant` is undefined.\n */\nexport function findAncestor<T extends { parent?: T }>(\n\tdescendant: T | [descendant: T | undefined, path?: T[]] | undefined,\n): T | undefined;\n/**\n * Find an ancestor of some descendant.\n * @param descendant - a descendant. If an empty `path` array is included, it will be populated\n * with the chain of ancestry for `descendant` from most distant to closest (not including the ancestor found by `predicate`,\n * but otherwise including `descendant`).\n * @param predicate - a function which will be evaluated on `descendant` and then ancestor of `descendant` (in ascending order) until it returns true.\n * @returns the closest ancestor of `descendant` that satisfies `predicate`, or `undefined` if no such ancestor exists.\n *\n * @example\n *\n * ```typescript\n * interface Parented {\n * id: string;\n * parent?: Parented;\n * }\n * const g = { id: \"g\" }; // Grandparent\n * const p = { parent: g, id: \"p\" }; // Parent\n * const c = { parent: p, id: \"c\" }; // Child\n * const path: Parented[] = [];\n * const ancestor = findAncestor<Parented>([c, path], (n) => n.id === \"g\");\n * // ancestor === g\n * // path === [p, c]\n * ```\n */\nexport function findAncestor<T extends { parent?: T }>(\n\tdescendant: T | [descendant: T | undefined, path?: T[]] | undefined,\n\tpredicate: (t: T) => boolean,\n): T | undefined;\nexport function findAncestor<T extends { parent?: T }>(\n\tdescendant: T | [descendant: T | undefined, path?: T[]] | undefined,\n\tpredicate: (t: T) => boolean = (t): boolean => t.parent === undefined,\n): T | undefined {\n\tlet d: T | undefined;\n\tlet path: T[] | undefined;\n\tif (Array.isArray(descendant)) {\n\t\t[d, path] = descendant;\n\t} else {\n\t\td = descendant;\n\t}\n\tfor (let cur = d; cur !== undefined; cur = cur.parent) {\n\t\tif (predicate(cur)) {\n\t\t\tpath?.reverse();\n\t\t\treturn cur;\n\t\t}\n\t\tpath?.push(cur);\n\t}\n\n\tif (path !== undefined) {\n\t\tpath.length = 0;\n\t}\n\treturn undefined;\n}\n\n/**\n * Find a common ancestor between two descendants that are linked by parent pointers.\n * @param descendantA - a descendant. If an empty `path` array is included, it will be populated\n * with the chain of commits from the ancestor to `descendantA` (not including the ancestor).\n * @param descendantB - another descendant. If an empty `path` array is included, it will be populated\n * with the chain of commits from the ancestor to `descendantB` (not including the ancestor).\n * @returns the common ancestor of `descendantA` and `descendantB`, or `undefined` if no such ancestor exists.\n *\n * @example\n *\n * ```typescript\n * interface Parented {\n * parent?: Parented;\n * }\n * const shared = {};\n * const a = { parent: shared };\n * const b1 = { parent: shared };\n * const b2 = { parent: b1 };\n * const pathB: Parented[] = []\n * const ancestor = findCommonAncestor<Parented>(a, [b2, pathB]);\n * // ancestor === shared\n * // pathB === [b1, b2]\n * ```\n */\nexport function findCommonAncestor<T extends { parent?: T }>(\n\tdescendantA: T | [descendantA: T, path?: T[]] | undefined,\n\tdescendantB: T | [descendantB: T, path?: T[]] | undefined,\n): T | undefined {\n\tlet a: T | undefined;\n\tlet b: T | undefined;\n\tlet pathA: T[] | undefined;\n\tlet pathB: T[] | undefined;\n\tif (Array.isArray(descendantA)) {\n\t\t[a, pathA] = descendantA;\n\t\tassert(pathA === undefined || pathA.length === 0, 0x578 /* Path A must be empty */);\n\t} else {\n\t\ta = descendantA;\n\t}\n\tif (Array.isArray(descendantB)) {\n\t\t[b, pathB] = descendantB;\n\t\tassert(pathB === undefined || pathB.length === 0, 0x579 /* Path B must be empty */);\n\t} else {\n\t\tb = descendantB;\n\t}\n\n\tif (a === b) {\n\t\treturn a;\n\t}\n\n\tconst reversePaths = (): void => {\n\t\tpathA?.reverse();\n\t\tpathB?.reverse();\n\t};\n\n\tconst visited = new Set();\n\twhile (a !== undefined || b !== undefined) {\n\t\tif (a !== undefined) {\n\t\t\tif (visited.has(a)) {\n\t\t\t\tif (pathB !== undefined) {\n\t\t\t\t\tpathB.length = pathB.findIndex((r) => Object.is(r, a));\n\t\t\t\t}\n\t\t\t\treversePaths();\n\t\t\t\treturn a;\n\t\t\t}\n\t\t\tvisited.add(a);\n\t\t\tpathA?.push(a);\n\t\t\ta = a.parent;\n\t\t}\n\n\t\tif (b !== undefined) {\n\t\t\tif (visited.has(b)) {\n\t\t\t\tif (pathA !== undefined) {\n\t\t\t\t\tpathA.length = pathA.findIndex((r) => Object.is(r, b));\n\t\t\t\t}\n\t\t\t\treversePaths();\n\t\t\t\treturn b;\n\t\t\t}\n\t\t\tvisited.add(b);\n\t\t\tpathB?.push(b);\n\t\t\tb = b.parent;\n\t\t}\n\t}\n\n\tif (pathA !== undefined) {\n\t\tpathA.length = 0;\n\t}\n\tif (pathB !== undefined) {\n\t\tpathB.length = 0;\n\t}\n\treturn undefined;\n}\n\nexport function replaceChange<TChange>(\n\tcommit: GraphCommit<TChange>,\n\tchange: TChange,\n): GraphCommit<TChange> {\n\tconst output = { ...commit, change };\n\tRollback.set(output, undefined);\n\treturn output;\n}\n\n/** Associates rollback data with commits */\nnamespace Rollback {\n\tconst map = new WeakMap<GraphCommit<unknown>, TaggedChange<unknown, RevisionTag>>();\n\n\texport function get<TChange>(\n\t\tcommit: GraphCommit<TChange>,\n\t): TaggedChange<TChange, RevisionTag> | undefined {\n\t\treturn map.get(commit) as TaggedChange<TChange, RevisionTag> | undefined;\n\t}\n\n\texport function set<TChange>(\n\t\tcommit: GraphCommit<TChange>,\n\t\trollback: TaggedChange<TChange, RevisionTag> | undefined,\n\t): void {\n\t\tif (rollback === undefined) {\n\t\t\tmap.delete(commit);\n\t\t} else {\n\t\t\tmap.set(commit, rollback);\n\t\t}\n\t}\n}\n\n/**\n * Checks if one node is an ancestor of another in a parent-linked tree structure.\n * @param ancestor - The potential ancestor node\n * @param descendant - The potential descendant node\n * @param allowEqual - If true, returns true when ancestor === descendant\n * @returns true if ancestor is an ancestor of descendant (or equal if allowEqual is true)\n */\nexport function isAncestor<TNode extends { readonly parent?: TNode }>(\n\tancestor: TNode,\n\tdescendant: TNode,\n\tallowEqual: boolean,\n): boolean {\n\tif (allowEqual && ancestor === descendant) {\n\t\treturn true;\n\t}\n\n\tlet current = descendant.parent;\n\twhile (current !== undefined) {\n\t\tif (current === ancestor) {\n\t\t\treturn true;\n\t\t}\n\t\tcurrent = current.parent;\n\t}\n\n\treturn false;\n}\n"]}
@@ -11,7 +11,10 @@ import type { Multiplicity } from "./multiplicity.js";
11
11
  * Schema for what {@link TreeLeafValue} is allowed on a Leaf node.
12
12
  * @privateRemarks
13
13
  * See also {@link TreeValue}.
14
- * @internal
14
+ * If further stabilizing this,
15
+ * consider the implications of how this might prevent adding of new leaf types in the future.
16
+ * Maybe add a disclaimer that it might be extended like on {@link NodeKind}?
17
+ * @alpha
15
18
  */
16
19
  export declare enum ValueSchema {
17
20
  Number = 0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5,7 @@
5
5
  */
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
7
  exports.decodeFieldSchema = exports.encodeFieldSchema = exports.storedSchemaDecodeDispatcher = exports.LeafNodeStoredSchema = exports.MapNodeStoredSchema = exports.ObjectNodeStoredSchema = exports.TreeNodeStoredSchema = exports.toTreeNodeSchemaDataFormat = exports.identifierFieldKindIdentifier = exports.storedEmptyFieldSchema = exports.forbiddenFieldKindIdentifier = exports.ValueSchema = void 0;
8
+ const internal_1 = require("@fluidframework/core-utils/internal");
8
9
  const index_js_1 = require("../../codec/index.js");
9
10
  const index_js_2 = require("../../util/index.js");
10
11
  const format_js_1 = require("./format.js");
@@ -12,7 +13,10 @@ const format_js_1 = require("./format.js");
12
13
  * Schema for what {@link TreeLeafValue} is allowed on a Leaf node.
13
14
  * @privateRemarks
14
15
  * See also {@link TreeValue}.
15
- * @internal
16
+ * If further stabilizing this,
17
+ * consider the implications of how this might prevent adding of new leaf types in the future.
18
+ * Maybe add a disclaimer that it might be extended like on {@link NodeKind}?
19
+ * @alpha
16
20
  */
17
21
  var ValueSchema;
18
22
  (function (ValueSchema) {
@@ -81,7 +85,7 @@ class ObjectNodeStoredSchema extends TreeNodeStoredSchema {
81
85
  enumerable: true,
82
86
  configurable: true,
83
87
  writable: true,
84
- value: encodeFieldSchema(this.objectNodeFields.get(key) ?? (0, index_js_2.fail)(0xae7 /* missing field */)),
88
+ value: encodeFieldSchema(this.objectNodeFields.get(key) ?? (0, internal_1.fail)(0xae7 /* missing field */)),
85
89
  });
86
90
  }
87
91
  return toErasedTreeNodeSchemaDataFormat({
@@ -167,10 +171,10 @@ const valueSchemaEncode = new Map([
167
171
  ]);
168
172
  const valueSchemaDecode = (0, index_js_2.invertMap)(valueSchemaEncode);
169
173
  function encodeValueSchema(inMemory) {
170
- return valueSchemaEncode.get(inMemory) ?? (0, index_js_2.fail)(0xae8 /* missing PersistedValueSchema */);
174
+ return valueSchemaEncode.get(inMemory) ?? (0, internal_1.fail)(0xae8 /* missing PersistedValueSchema */);
171
175
  }
172
176
  function decodeValueSchema(inMemory) {
173
- return valueSchemaDecode.get(inMemory) ?? (0, index_js_2.fail)(0xae9 /* missing ValueSchema */);
177
+ return valueSchemaDecode.get(inMemory) ?? (0, internal_1.fail)(0xae9 /* missing ValueSchema */);
174
178
  }
175
179
  function encodeFieldSchema(schema) {
176
180
  return {
@@ -1 +1 @@
1
- {"version":3,"file":"schema.js","sourceRoot":"","sources":["../../../src/core/schema-stored/schema.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,mDAAoE;AACpE,kDAA+E;AAC/E,2CAOqB;AAGrB;;;;;GAKG;AACH,IAAY,WAMX;AAND,WAAY,WAAW;IACtB,iDAAM,CAAA;IACN,iDAAM,CAAA;IACN,mDAAO,CAAA;IACP,2DAAW,CAAA;IACX,6CAAI,CAAA;AACL,CAAC,EANW,WAAW,2BAAX,WAAW,QAMtB;AA0FD;;;;;;;GAOG;AACU,QAAA,4BAA4B,GAAG,WAAW,CAAC;AAExD;;;GAGG;AACU,QAAA,sBAAsB,GAA0B;IAC5D,4CAA4C;IAC5C,IAAI,EAAE,IAAA,gBAAK,EAAC,oCAA4B,CAAC;IACzC,qFAAqF;IACrF,KAAK,EAAE,IAAI,GAAG,EAAE;CAChB,CAAC;AAEF;;GAEG;AACU,QAAA,6BAA6B,GAAG,YAAY,CAAC;AAQ1D,SAAS,gCAAgC,CACxC,IAA8B;IAE9B,OAAO,IAAiD,CAAC;AAC1D,CAAC;AAED,SAAgB,0BAA0B,CACzC,IAAoC;IAEpC,OAAO,IAA2C,CAAC;AACpD,CAAC;AAJD,gEAIC;AAED;GACG;AACH,MAAsB,oBAAoB;CAezC;AAfD,oDAeC;AAED;GACG;AACH,MAAa,sBAAuB,SAAQ,oBAAoB;IAC/D;;;;;;;OAOG;IACH,YACiB,gBAA8D;QAE9E,KAAK,EAAE,CAAC;QAFQ,qBAAgB,GAAhB,gBAAgB,CAA8C;IAG/E,CAAC;IAEe,MAAM;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CAAC;AAEH,MAAM,iBAAiB,GAAG,IAAA,oBAAS,EAAC,iBAAiB,CAAC,CAAC;AAEvD,SAAS,iBAAiB,CAAC,QAAqB;IAC/C,OAAO,iBAAiB,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,IAAA,eAAI,EAAC,KAAK,CAAC,kCAAkC,CAAC,CAAC;AAC1F,CAAC;AAED,SAAS,iBAAiB,CAAC,QAA8B;IACxD,OAAO,iBAAiB,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,IAAA,eAAI,EAAC,KAAK,CAAC,yBAAyB,CAAC,CAAC;AACjF,CAAC;AAED,SAAgB,iBAAiB,CAAC,MAA6B;IAC9D,OAAO;QACN,IAAI,EAAE,MAAM,CAAC,IAAI;QACjB,iHAAiH;QACjH,KAAK,EAAE,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE;KAC/B,CAAC;AACH,CAAC;AAND,8CAMC;AAED,SAAgB,iBAAiB,CAAC,MAAyB;IAC1D,MAAM,GAAG,GAA0B;QAClC,kFAAkF;QAClF,IAAI,EAAE,MAAM,CAAC,IAAI;QACjB,KAAK,EAAE,IAAI,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC;KAC5B,CAAC;IACF,OAAO,GAAG,CAAC;AACZ,CAAC;AAPD,8CAOC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { ErasedType } from \"@fluidframework/core-interfaces\";\nimport { DiscriminatedUnionDispatcher } from \"../../codec/index.js\";\nimport { type MakeNominal, brand, fail, invertMap } from \"../../util/index.js\";\nimport {\n\ttype FieldKey,\n\ttype FieldKindIdentifier,\n\ttype FieldSchemaFormat,\n\tPersistedValueSchema,\n\ttype TreeNodeSchemaDataFormat,\n\ttype TreeNodeSchemaIdentifier,\n} from \"./format.js\";\nimport type { Multiplicity } from \"./multiplicity.js\";\n\n/**\n * Schema for what {@link TreeLeafValue} is allowed on a Leaf node.\n * @privateRemarks\n * See also {@link TreeValue}.\n * @internal\n */\nexport enum ValueSchema {\n\tNumber,\n\tString,\n\tBoolean,\n\tFluidHandle,\n\tNull,\n}\n\n/**\n * Set of allowed tree types.\n * Providing multiple values here allows polymorphism, tagged union style.\n *\n * In the future, this could be extended to allow inlining a TreeNodeStoredSchema here\n * (or some similar structural schema system).\n * For structural types which could go here, there are a few interesting options:\n *\n * - Allow replacing the whole set with a structural type for terminal / non-tree data,\n * and use this as a replacement for values on the tree nodes.\n *\n * - Allow expression structural constraints for child trees, for example requiring specific traits\n * (ex: via TreeNodeStoredSchema), instead of by type.\n *\n * There are two ways this could work:\n *\n * - Constrain the child nodes based on their shape:\n * this makes schema safe editing difficult because nodes would incur extra editing constraints to prevent them\n * from going out of schema based on their location in such a field.\n *\n * - Constrain the types allowed based on which types guarantee their data will always meet the constraints.\n *\n * Care would need to be taken to make sure this is sound for the schema updating mechanisms.\n */\nexport type TreeTypeSet = ReadonlySet<TreeNodeSchemaIdentifier>;\n\n/**\n * Declarative portion of a Field Kind.\n *\n * @remarks\n * Enough info about a field kind to know if a given tree is is schema.\n */\nexport interface FieldKindData {\n\treadonly identifier: FieldKindIdentifier;\n\treadonly multiplicity: Multiplicity;\n}\n\n/**\n * Everything needed to define what it means for a tree to be in schema.\n */\nexport interface SchemaAndPolicy {\n\treadonly schema: StoredSchemaCollection;\n\treadonly policy: SchemaPolicy;\n}\n\n/**\n * Extra data needed to interpret schema.\n */\nexport interface SchemaPolicy {\n\t/**\n\t * Policy information about FieldKinds:\n\t * This is typically stored as code, not in documents, and defines how to handle fields based on their kind.\n\t * It is assumed that all users of a document will have exactly the same FieldKind policies,\n\t * though older applications might be missing some,\n\t * and will be unable to process any changes that use those FieldKinds.\n\t */\n\treadonly fieldKinds: ReadonlyMap<FieldKindIdentifier, FieldKindData>;\n\n\t/**\n\t * If true, new content inserted into the tree should be validated against the stored schema.\n\t */\n\treadonly validateSchema: boolean;\n\n\t/**\n\t * Whether to allow a document to be opened when a particular stored schema (identified by `identifier`)\n\t * contains optional fields that are not known to the view schema.\n\t *\n\t * @privateRemarks\n\t * Plumbing this in via `SchemaPolicy` avoids needing to walk the view schema representation repeatedly in places\n\t * that need it (schema validation, view vs stored compatibility checks).\n\t */\n\tallowUnknownOptionalFields(identifier: TreeNodeSchemaIdentifier): boolean;\n}\n\n/**\n * Schema for a field.\n * Object implementing this interface should never be modified.\n */\nexport interface TreeFieldStoredSchema {\n\treadonly kind: FieldKindIdentifier;\n\n\t/**\n\t * The set of allowed child types.\n\t * If not specified, types are unconstrained.\n\t */\n\treadonly types: TreeTypeSet;\n}\n\n/**\n * Identifier used for the FieldKind for fields which must be empty.\n *\n * @remarks\n * This mainly show up in:\n * 1. The root default field for documents.\n * 2. The schema used for out of schema fields (which thus must be empty/not exist) on object and leaf nodes.\n */\nexport const forbiddenFieldKindIdentifier = \"Forbidden\";\n\n/**\n * A schema for empty fields (fields which must always be empty).\n * There are multiple ways this could be encoded, but this is the most explicit.\n */\nexport const storedEmptyFieldSchema: TreeFieldStoredSchema = {\n\t// This kind requires the field to be empty.\n\tkind: brand(forbiddenFieldKindIdentifier),\n\t// This type set also forces the field to be empty not not allowing any types as all.\n\ttypes: new Set(),\n};\n\n/**\n * Identifier used for the FieldKind for fields of type identifier.\n */\nexport const identifierFieldKindIdentifier = \"Identifier\";\n\n/**\n * Opaque type erased handle to the encoded representation of the contents of a stored schema.\n */\nexport interface ErasedTreeNodeSchemaDataFormat\n\textends ErasedType<\"TreeNodeSchemaDataFormat\"> {}\n\nfunction toErasedTreeNodeSchemaDataFormat(\n\tdata: TreeNodeSchemaDataFormat,\n): ErasedTreeNodeSchemaDataFormat {\n\treturn data as unknown as ErasedTreeNodeSchemaDataFormat;\n}\n\nexport function toTreeNodeSchemaDataFormat(\n\tdata: ErasedTreeNodeSchemaDataFormat,\n): TreeNodeSchemaDataFormat {\n\treturn data as unknown as TreeNodeSchemaDataFormat;\n}\n\n/**\n */\nexport abstract class TreeNodeStoredSchema {\n\tprotected _typeCheck!: MakeNominal;\n\n\t/**\n\t * @privateRemarks\n\t * Returns TreeNodeSchemaDataFormat.\n\t * This is uses an opaque type to avoid leaking these types out of the package,\n\t * and is runtime validated by the codec.\n\t */\n\tpublic abstract encode(): ErasedTreeNodeSchemaDataFormat;\n\n\t/**\n\t * Returns the schema for the provided field.\n\t */\n\tpublic abstract getFieldSchema(field: FieldKey): TreeFieldStoredSchema;\n}\n\n/**\n */\nexport class ObjectNodeStoredSchema extends TreeNodeStoredSchema {\n\t/**\n\t * @param objectNodeFields -\n\t * Schema for fields with keys scoped to this TreeNodeStoredSchema.\n\t * This refers to the TreeFieldStoredSchema directly\n\t * (as opposed to just supporting FieldSchemaIdentifier and having a central FieldKey -\\> TreeFieldStoredSchema map).\n\t * This allows us short friendly field keys which can be ergonomically used as field names in code.\n\t * It also interoperates well with mapFields being used as a map with arbitrary data as keys.\n\t */\n\tpublic constructor(\n\t\tpublic readonly objectNodeFields: ReadonlyMap<FieldKey, TreeFieldStoredSchema>,\n\t) {\n\t\tsuper();\n\t}\n\n\tpublic override encode(): ErasedTreeNodeSchemaDataFormat {\n\t\tconst fieldsObject: Record<string, FieldSchemaFormat> = Object.create(null);\n\t\t// Sort fields to ensure output is identical for for equivalent schema (since field order is not considered significant).\n\t\t// This makes comparing schema easier, and ensures chunk reuse for schema summaries isn't needlessly broken.\n\t\tfor (const key of [...this.objectNodeFields.keys()].sort()) {\n\t\t\tObject.defineProperty(fieldsObject, key, {\n\t\t\t\tenumerable: true,\n\t\t\t\tconfigurable: true,\n\t\t\t\twritable: true,\n\t\t\t\tvalue: encodeFieldSchema(\n\t\t\t\t\tthis.objectNodeFields.get(key) ?? fail(0xae7 /* missing field */),\n\t\t\t\t),\n\t\t\t});\n\t\t}\n\t\treturn toErasedTreeNodeSchemaDataFormat({\n\t\t\tobject: fieldsObject,\n\t\t});\n\t}\n\n\tpublic override getFieldSchema(field: FieldKey): TreeFieldStoredSchema {\n\t\treturn this.objectNodeFields.get(field) ?? storedEmptyFieldSchema;\n\t}\n}\n\n/**\n */\nexport class MapNodeStoredSchema extends TreeNodeStoredSchema {\n\t/**\n\t * @param mapFields -\n\t * Allows using the fields as a map, with the keys being\n\t * FieldKeys and the values being constrained by this TreeFieldStoredSchema.\n\t * Usually `FieldKind.Value` should NOT be used here\n\t * since no nodes can ever be in schema if you use `FieldKind.Value` here\n\t * (that would require infinite children).\n\t */\n\tpublic constructor(public readonly mapFields: TreeFieldStoredSchema) {\n\t\tsuper();\n\t}\n\n\tpublic override encode(): ErasedTreeNodeSchemaDataFormat {\n\t\treturn toErasedTreeNodeSchemaDataFormat({\n\t\t\tmap: encodeFieldSchema(this.mapFields),\n\t\t});\n\t}\n\n\tpublic override getFieldSchema(field: FieldKey): TreeFieldStoredSchema {\n\t\treturn this.mapFields;\n\t}\n}\n\n/**\n */\nexport class LeafNodeStoredSchema extends TreeNodeStoredSchema {\n\t/**\n\t * @param leafValue -\n\t * There are several approaches for how to store actual data in the tree\n\t * (special node types, special field contents, data on nodes etc.)\n\t * as well as several options about how the data should be modeled at this level\n\t * (byte sequence? javascript type? json?),\n\t * as well as options for how much of this would be exposed in the schema language\n\t * (ex: would all nodes with values be special built-ins, or could any schema add them?)\n\t * A simple easy to do in javascript approach is taken here:\n\t * this is not intended to be a suggestion of what approach to take, or what to expose in the schema language.\n\t * This is simply one approach that can work for modeling them in the internal schema representation.\n\t */\n\tpublic constructor(public readonly leafValue: ValueSchema) {\n\t\tsuper();\n\t}\n\n\tpublic override encode(): ErasedTreeNodeSchemaDataFormat {\n\t\treturn toErasedTreeNodeSchemaDataFormat({\n\t\t\tleaf: encodeValueSchema(this.leafValue),\n\t\t});\n\t}\n\n\tpublic override getFieldSchema(field: FieldKey): TreeFieldStoredSchema {\n\t\treturn storedEmptyFieldSchema;\n\t}\n}\n\nexport const storedSchemaDecodeDispatcher: DiscriminatedUnionDispatcher<\n\tTreeNodeSchemaDataFormat,\n\t[],\n\tTreeNodeStoredSchema\n> = new DiscriminatedUnionDispatcher({\n\tleaf: (data: PersistedValueSchema) => new LeafNodeStoredSchema(decodeValueSchema(data)),\n\tobject: (\n\t\tdata: Record<TreeNodeSchemaIdentifier, FieldSchemaFormat>,\n\t): TreeNodeStoredSchema => {\n\t\tconst map = new Map();\n\t\tfor (const [key, value] of Object.entries(data)) {\n\t\t\tmap.set(key, decodeFieldSchema(value));\n\t\t}\n\t\treturn new ObjectNodeStoredSchema(map);\n\t},\n\tmap: (data: FieldSchemaFormat) => new MapNodeStoredSchema(decodeFieldSchema(data)),\n});\n\nconst valueSchemaEncode = new Map([\n\t[ValueSchema.Number, PersistedValueSchema.Number],\n\t[ValueSchema.String, PersistedValueSchema.String],\n\t[ValueSchema.Boolean, PersistedValueSchema.Boolean],\n\t[ValueSchema.FluidHandle, PersistedValueSchema.FluidHandle],\n\t[ValueSchema.Null, PersistedValueSchema.Null],\n]);\n\nconst valueSchemaDecode = invertMap(valueSchemaEncode);\n\nfunction encodeValueSchema(inMemory: ValueSchema): PersistedValueSchema {\n\treturn valueSchemaEncode.get(inMemory) ?? fail(0xae8 /* missing PersistedValueSchema */);\n}\n\nfunction decodeValueSchema(inMemory: PersistedValueSchema): ValueSchema {\n\treturn valueSchemaDecode.get(inMemory) ?? fail(0xae9 /* missing ValueSchema */);\n}\n\nexport function encodeFieldSchema(schema: TreeFieldStoredSchema): FieldSchemaFormat {\n\treturn {\n\t\tkind: schema.kind,\n\t\t// Types are sorted by identifier to improve stability of persisted data to increase chance of schema blob reuse.\n\t\ttypes: [...schema.types].sort(),\n\t};\n}\n\nexport function decodeFieldSchema(schema: FieldSchemaFormat): TreeFieldStoredSchema {\n\tconst out: TreeFieldStoredSchema = {\n\t\t// TODO: maybe provide actual FieldKind objects here, error on unrecognized kinds.\n\t\tkind: schema.kind,\n\t\ttypes: new Set(schema.types),\n\t};\n\treturn out;\n}\n\n/**\n * Document schema data that can be stored in a document.\n *\n * @remarks\n * Note: the owner of this may modify it over time:\n * thus if needing to hand onto a specific version, make a copy.\n */\nexport interface TreeStoredSchema extends StoredSchemaCollection {\n\t/**\n\t * Schema for the root field which contains the whole tree.\n\t */\n\treadonly rootFieldSchema: TreeFieldStoredSchema;\n}\n\n/**\n * Collection of TreeNodeSchema data that can be stored in a document.\n *\n * @remarks\n * Note: the owner of this may modify it over time:\n * thus if needing to hang onto a specific version, make a copy.\n */\nexport interface StoredSchemaCollection {\n\t/**\n\t * {@inheritdoc StoredSchemaCollection}\n\t */\n\treadonly nodeSchema: ReadonlyMap<TreeNodeSchemaIdentifier, TreeNodeStoredSchema>;\n}\n"]}
1
+ {"version":3,"file":"schema.js","sourceRoot":"","sources":["../../../src/core/schema-stored/schema.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAA2D;AAE3D,mDAAoE;AACpE,kDAAyE;AACzE,2CAOqB;AAGrB;;;;;;;;GAQG;AACH,IAAY,WAMX;AAND,WAAY,WAAW;IACtB,iDAAM,CAAA;IACN,iDAAM,CAAA;IACN,mDAAO,CAAA;IACP,2DAAW,CAAA;IACX,6CAAI,CAAA;AACL,CAAC,EANW,WAAW,2BAAX,WAAW,QAMtB;AA0FD;;;;;;;GAOG;AACU,QAAA,4BAA4B,GAAG,WAAW,CAAC;AAExD;;;GAGG;AACU,QAAA,sBAAsB,GAA0B;IAC5D,4CAA4C;IAC5C,IAAI,EAAE,IAAA,gBAAK,EAAC,oCAA4B,CAAC;IACzC,qFAAqF;IACrF,KAAK,EAAE,IAAI,GAAG,EAAE;CAChB,CAAC;AAEF;;GAEG;AACU,QAAA,6BAA6B,GAAG,YAAY,CAAC;AAQ1D,SAAS,gCAAgC,CACxC,IAA8B;IAE9B,OAAO,IAAiD,CAAC;AAC1D,CAAC;AAED,SAAgB,0BAA0B,CACzC,IAAoC;IAEpC,OAAO,IAA2C,CAAC;AACpD,CAAC;AAJD,gEAIC;AAED;GACG;AACH,MAAsB,oBAAoB;CAezC;AAfD,oDAeC;AAED;GACG;AACH,MAAa,sBAAuB,SAAQ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ACnD,CAAC,WAAW,CAAC,WAAW,EAAE,gCAAoB,CAAC,WAAW,CAAC;IAC3D,CAAC,WAAW,CAAC,IAAI,EAAE,gCAAoB,CAAC,IAAI,CAAC;CAC7C,CAAC,CAAC;AAEH,MAAM,iBAAiB,GAAG,IAAA,oBAAS,EAAC,iBAAiB,CAAC,CAAC;AAEvD,SAAS,iBAAiB,CAAC,QAAqB;IAC/C,OAAO,iBAAiB,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,IAAA,eAAI,EAAC,KAAK,CAAC,kCAAkC,CAAC,CAAC;AAC1F,CAAC;AAED,SAAS,iBAAiB,CAAC,QAA8B;IACxD,OAAO,iBAAiB,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,IAAA,eAAI,EAAC,KAAK,CAAC,yBAAyB,CAAC,CAAC;AACjF,CAAC;AAED,SAAgB,iBAAiB,CAAC,MAA6B;IAC9D,OAAO;QACN,IAAI,EAAE,MAAM,CAAC,IAAI;QACjB,iHAAiH;QACjH,KAAK,EAAE,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE;KAC/B,CAAC;AACH,CAAC;AAND,8CAMC;AAED,SAAgB,iBAAiB,CAAC,MAAyB;IAC1D,MAAM,GAAG,GAA0B;QAClC,kFAAkF;QAClF,IAAI,EAAE,MAAM,CAAC,IAAI;QACjB,KAAK,EAAE,IAAI,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC;KAC5B,CAAC;IACF,OAAO,GAAG,CAAC;AACZ,CAAC;AAPD,8CAOC","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 { ErasedType } from \"@fluidframework/core-interfaces\";\nimport { DiscriminatedUnionDispatcher } from \"../../codec/index.js\";\nimport { type MakeNominal, brand, invertMap } from \"../../util/index.js\";\nimport {\n\ttype FieldKey,\n\ttype FieldKindIdentifier,\n\ttype FieldSchemaFormat,\n\tPersistedValueSchema,\n\ttype TreeNodeSchemaDataFormat,\n\ttype TreeNodeSchemaIdentifier,\n} from \"./format.js\";\nimport type { Multiplicity } from \"./multiplicity.js\";\n\n/**\n * Schema for what {@link TreeLeafValue} is allowed on a Leaf node.\n * @privateRemarks\n * See also {@link TreeValue}.\n * If further stabilizing this,\n * consider the implications of how this might prevent adding of new leaf types in the future.\n * Maybe add a disclaimer that it might be extended like on {@link NodeKind}?\n * @alpha\n */\nexport enum ValueSchema {\n\tNumber,\n\tString,\n\tBoolean,\n\tFluidHandle,\n\tNull,\n}\n\n/**\n * Set of allowed tree types.\n * Providing multiple values here allows polymorphism, tagged union style.\n *\n * In the future, this could be extended to allow inlining a TreeNodeStoredSchema here\n * (or some similar structural schema system).\n * For structural types which could go here, there are a few interesting options:\n *\n * - Allow replacing the whole set with a structural type for terminal / non-tree data,\n * and use this as a replacement for values on the tree nodes.\n *\n * - Allow expression structural constraints for child trees, for example requiring specific traits\n * (ex: via TreeNodeStoredSchema), instead of by type.\n *\n * There are two ways this could work:\n *\n * - Constrain the child nodes based on their shape:\n * this makes schema safe editing difficult because nodes would incur extra editing constraints to prevent them\n * from going out of schema based on their location in such a field.\n *\n * - Constrain the types allowed based on which types guarantee their data will always meet the constraints.\n *\n * Care would need to be taken to make sure this is sound for the schema updating mechanisms.\n */\nexport type TreeTypeSet = ReadonlySet<TreeNodeSchemaIdentifier>;\n\n/**\n * Declarative portion of a Field Kind.\n *\n * @remarks\n * Enough info about a field kind to know if a given tree is is schema.\n */\nexport interface FieldKindData {\n\treadonly identifier: FieldKindIdentifier;\n\treadonly multiplicity: Multiplicity;\n}\n\n/**\n * Everything needed to define what it means for a tree to be in schema.\n */\nexport interface SchemaAndPolicy {\n\treadonly schema: StoredSchemaCollection;\n\treadonly policy: SchemaPolicy;\n}\n\n/**\n * Extra data needed to interpret schema.\n */\nexport interface SchemaPolicy {\n\t/**\n\t * Policy information about FieldKinds:\n\t * This is typically stored as code, not in documents, and defines how to handle fields based on their kind.\n\t * It is assumed that all users of a document will have exactly the same FieldKind policies,\n\t * though older applications might be missing some,\n\t * and will be unable to process any changes that use those FieldKinds.\n\t */\n\treadonly fieldKinds: ReadonlyMap<FieldKindIdentifier, FieldKindData>;\n\n\t/**\n\t * If true, new content inserted into the tree should be validated against the stored schema.\n\t */\n\treadonly validateSchema: boolean;\n\n\t/**\n\t * Whether to allow a document to be opened when a particular stored schema (identified by `identifier`)\n\t * contains optional fields that are not known to the view schema.\n\t *\n\t * @privateRemarks\n\t * Plumbing this in via `SchemaPolicy` avoids needing to walk the view schema representation repeatedly in places\n\t * that need it (schema validation, view vs stored compatibility checks).\n\t */\n\tallowUnknownOptionalFields(identifier: TreeNodeSchemaIdentifier): boolean;\n}\n\n/**\n * Schema for a field.\n * Object implementing this interface should never be modified.\n */\nexport interface TreeFieldStoredSchema {\n\treadonly kind: FieldKindIdentifier;\n\n\t/**\n\t * The set of allowed child types.\n\t * If not specified, types are unconstrained.\n\t */\n\treadonly types: TreeTypeSet;\n}\n\n/**\n * Identifier used for the FieldKind for fields which must be empty.\n *\n * @remarks\n * This mainly show up in:\n * 1. The root default field for documents.\n * 2. The schema used for out of schema fields (which thus must be empty/not exist) on object and leaf nodes.\n */\nexport const forbiddenFieldKindIdentifier = \"Forbidden\";\n\n/**\n * A schema for empty fields (fields which must always be empty).\n * There are multiple ways this could be encoded, but this is the most explicit.\n */\nexport const storedEmptyFieldSchema: TreeFieldStoredSchema = {\n\t// This kind requires the field to be empty.\n\tkind: brand(forbiddenFieldKindIdentifier),\n\t// This type set also forces the field to be empty not not allowing any types as all.\n\ttypes: new Set(),\n};\n\n/**\n * Identifier used for the FieldKind for fields of type identifier.\n */\nexport const identifierFieldKindIdentifier = \"Identifier\";\n\n/**\n * Opaque type erased handle to the encoded representation of the contents of a stored schema.\n */\nexport interface ErasedTreeNodeSchemaDataFormat\n\textends ErasedType<\"TreeNodeSchemaDataFormat\"> {}\n\nfunction toErasedTreeNodeSchemaDataFormat(\n\tdata: TreeNodeSchemaDataFormat,\n): ErasedTreeNodeSchemaDataFormat {\n\treturn data as unknown as ErasedTreeNodeSchemaDataFormat;\n}\n\nexport function toTreeNodeSchemaDataFormat(\n\tdata: ErasedTreeNodeSchemaDataFormat,\n): TreeNodeSchemaDataFormat {\n\treturn data as unknown as TreeNodeSchemaDataFormat;\n}\n\n/**\n */\nexport abstract class TreeNodeStoredSchema {\n\tprotected _typeCheck!: MakeNominal;\n\n\t/**\n\t * @privateRemarks\n\t * Returns TreeNodeSchemaDataFormat.\n\t * This is uses an opaque type to avoid leaking these types out of the package,\n\t * and is runtime validated by the codec.\n\t */\n\tpublic abstract encode(): ErasedTreeNodeSchemaDataFormat;\n\n\t/**\n\t * Returns the schema for the provided field.\n\t */\n\tpublic abstract getFieldSchema(field: FieldKey): TreeFieldStoredSchema;\n}\n\n/**\n */\nexport class ObjectNodeStoredSchema extends TreeNodeStoredSchema {\n\t/**\n\t * @param objectNodeFields -\n\t * Schema for fields with keys scoped to this TreeNodeStoredSchema.\n\t * This refers to the TreeFieldStoredSchema directly\n\t * (as opposed to just supporting FieldSchemaIdentifier and having a central FieldKey -\\> TreeFieldStoredSchema map).\n\t * This allows us short friendly field keys which can be ergonomically used as field names in code.\n\t * It also interoperates well with mapFields being used as a map with arbitrary data as keys.\n\t */\n\tpublic constructor(\n\t\tpublic readonly objectNodeFields: ReadonlyMap<FieldKey, TreeFieldStoredSchema>,\n\t) {\n\t\tsuper();\n\t}\n\n\tpublic override encode(): ErasedTreeNodeSchemaDataFormat {\n\t\tconst fieldsObject: Record<string, FieldSchemaFormat> = Object.create(null);\n\t\t// Sort fields to ensure output is identical for for equivalent schema (since field order is not considered significant).\n\t\t// This makes comparing schema easier, and ensures chunk reuse for schema summaries isn't needlessly broken.\n\t\tfor (const key of [...this.objectNodeFields.keys()].sort()) {\n\t\t\tObject.defineProperty(fieldsObject, key, {\n\t\t\t\tenumerable: true,\n\t\t\t\tconfigurable: true,\n\t\t\t\twritable: true,\n\t\t\t\tvalue: encodeFieldSchema(\n\t\t\t\t\tthis.objectNodeFields.get(key) ?? fail(0xae7 /* missing field */),\n\t\t\t\t),\n\t\t\t});\n\t\t}\n\t\treturn toErasedTreeNodeSchemaDataFormat({\n\t\t\tobject: fieldsObject,\n\t\t});\n\t}\n\n\tpublic override getFieldSchema(field: FieldKey): TreeFieldStoredSchema {\n\t\treturn this.objectNodeFields.get(field) ?? storedEmptyFieldSchema;\n\t}\n}\n\n/**\n */\nexport class MapNodeStoredSchema extends TreeNodeStoredSchema {\n\t/**\n\t * @param mapFields -\n\t * Allows using the fields as a map, with the keys being\n\t * FieldKeys and the values being constrained by this TreeFieldStoredSchema.\n\t * Usually `FieldKind.Value` should NOT be used here\n\t * since no nodes can ever be in schema if you use `FieldKind.Value` here\n\t * (that would require infinite children).\n\t */\n\tpublic constructor(public readonly mapFields: TreeFieldStoredSchema) {\n\t\tsuper();\n\t}\n\n\tpublic override encode(): ErasedTreeNodeSchemaDataFormat {\n\t\treturn toErasedTreeNodeSchemaDataFormat({\n\t\t\tmap: encodeFieldSchema(this.mapFields),\n\t\t});\n\t}\n\n\tpublic override getFieldSchema(field: FieldKey): TreeFieldStoredSchema {\n\t\treturn this.mapFields;\n\t}\n}\n\n/**\n */\nexport class LeafNodeStoredSchema extends TreeNodeStoredSchema {\n\t/**\n\t * @param leafValue -\n\t * There are several approaches for how to store actual data in the tree\n\t * (special node types, special field contents, data on nodes etc.)\n\t * as well as several options about how the data should be modeled at this level\n\t * (byte sequence? javascript type? json?),\n\t * as well as options for how much of this would be exposed in the schema language\n\t * (ex: would all nodes with values be special built-ins, or could any schema add them?)\n\t * A simple easy to do in javascript approach is taken here:\n\t * this is not intended to be a suggestion of what approach to take, or what to expose in the schema language.\n\t * This is simply one approach that can work for modeling them in the internal schema representation.\n\t */\n\tpublic constructor(public readonly leafValue: ValueSchema) {\n\t\tsuper();\n\t}\n\n\tpublic override encode(): ErasedTreeNodeSchemaDataFormat {\n\t\treturn toErasedTreeNodeSchemaDataFormat({\n\t\t\tleaf: encodeValueSchema(this.leafValue),\n\t\t});\n\t}\n\n\tpublic override getFieldSchema(field: FieldKey): TreeFieldStoredSchema {\n\t\treturn storedEmptyFieldSchema;\n\t}\n}\n\nexport const storedSchemaDecodeDispatcher: DiscriminatedUnionDispatcher<\n\tTreeNodeSchemaDataFormat,\n\t[],\n\tTreeNodeStoredSchema\n> = new DiscriminatedUnionDispatcher({\n\tleaf: (data: PersistedValueSchema) => new LeafNodeStoredSchema(decodeValueSchema(data)),\n\tobject: (\n\t\tdata: Record<TreeNodeSchemaIdentifier, FieldSchemaFormat>,\n\t): TreeNodeStoredSchema => {\n\t\tconst map = new Map();\n\t\tfor (const [key, value] of Object.entries(data)) {\n\t\t\tmap.set(key, decodeFieldSchema(value));\n\t\t}\n\t\treturn new ObjectNodeStoredSchema(map);\n\t},\n\tmap: (data: FieldSchemaFormat) => new MapNodeStoredSchema(decodeFieldSchema(data)),\n});\n\nconst valueSchemaEncode = new Map([\n\t[ValueSchema.Number, PersistedValueSchema.Number],\n\t[ValueSchema.String, PersistedValueSchema.String],\n\t[ValueSchema.Boolean, PersistedValueSchema.Boolean],\n\t[ValueSchema.FluidHandle, PersistedValueSchema.FluidHandle],\n\t[ValueSchema.Null, PersistedValueSchema.Null],\n]);\n\nconst valueSchemaDecode = invertMap(valueSchemaEncode);\n\nfunction encodeValueSchema(inMemory: ValueSchema): PersistedValueSchema {\n\treturn valueSchemaEncode.get(inMemory) ?? fail(0xae8 /* missing PersistedValueSchema */);\n}\n\nfunction decodeValueSchema(inMemory: PersistedValueSchema): ValueSchema {\n\treturn valueSchemaDecode.get(inMemory) ?? fail(0xae9 /* missing ValueSchema */);\n}\n\nexport function encodeFieldSchema(schema: TreeFieldStoredSchema): FieldSchemaFormat {\n\treturn {\n\t\tkind: schema.kind,\n\t\t// Types are sorted by identifier to improve stability of persisted data to increase chance of schema blob reuse.\n\t\ttypes: [...schema.types].sort(),\n\t};\n}\n\nexport function decodeFieldSchema(schema: FieldSchemaFormat): TreeFieldStoredSchema {\n\tconst out: TreeFieldStoredSchema = {\n\t\t// TODO: maybe provide actual FieldKind objects here, error on unrecognized kinds.\n\t\tkind: schema.kind,\n\t\ttypes: new Set(schema.types),\n\t};\n\treturn out;\n}\n\n/**\n * Document schema data that can be stored in a document.\n *\n * @remarks\n * Note: the owner of this may modify it over time:\n * thus if needing to hand onto a specific version, make a copy.\n */\nexport interface TreeStoredSchema extends StoredSchemaCollection {\n\t/**\n\t * Schema for the root field which contains the whole tree.\n\t */\n\treadonly rootFieldSchema: TreeFieldStoredSchema;\n}\n\n/**\n * Collection of TreeNodeSchema data that can be stored in a document.\n *\n * @remarks\n * Note: the owner of this may modify it over time:\n * thus if needing to hang onto a specific version, make a copy.\n */\nexport interface StoredSchemaCollection {\n\t/**\n\t * {@inheritdoc StoredSchemaCollection}\n\t */\n\treadonly nodeSchema: ReadonlyMap<TreeNodeSchemaIdentifier, TreeNodeStoredSchema>;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"anchorSet.d.ts","sourceRoot":"","sources":["../../../src/core/tree/anchorSet.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAMH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0CAA0C,CAAC;AAE3E,OAAO,EACN,KAAK,KAAK,EACV,KAAK,UAAU,EACf,KAAK,gBAAgB,EACrB,KAAK,MAAM,EACX,oBAAoB,EAMpB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAE1D,OAAO,KAAK,KAAK,KAAK,MAAM,YAAY,CAAC;AACzC,OAAO,EAEN,KAAK,iBAAiB,EAItB,KAAK,MAAM,EACX,MAAM,eAAe,CAAC;AAEvB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAIpD;;;GAGG;AACH,MAAM,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,EAAE,gBAAgB,CAA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1E;;;;OAIG;IACI,WAAW,CAAC,KAAK,EAAE,QAAQ,GAAG,IAAI;IAczC;;;;OAIG;IACI,eAAe,CAAC,GAAG,EAAE,QAAQ,GAAG,IAAI;IAM3C;;;;;;OAMG;IACH,OAAO,CAAC,eAAe;CASvB"}
@@ -225,7 +225,7 @@ class AnchorSet {
225
225
  };
226
226
  }
227
227
  }
228
- return path ?? (0, index_js_1.fail)(0xaea /* internalize path must be a path */);
228
+ return path ?? (0, internal_1.fail)(0xaea /* internalize path must be a path */);
229
229
  }
230
230
  /**
231
231
  * Recursively marks the given `nodes` and their descendants as disposed and pointing to a deleted node.
@@ -464,7 +464,7 @@ class AnchorSet {
464
464
  if (event === "childrenChangedAfterBatch") {
465
465
  const keys = (0, index_js_1.getOrCreate)(eventsByNode, node, () => new Set());
466
466
  keys.add(changedField ??
467
- (0, index_js_1.fail)(0xb57 /* childrenChangedAfterBatch events should have a changedField */));
467
+ (0, internal_1.fail)(0xb57 /* childrenChangedAfterBatch events should have a changedField */));
468
468
  }
469
469
  }
470
470
  const alreadyEmitted = new Map();
@@ -476,7 +476,7 @@ class AnchorSet {
476
476
  emittedEvents.push(event);
477
477
  if (event === "childrenChangedAfterBatch") {
478
478
  const changedFields = eventsByNode.get(node) ??
479
- (0, index_js_1.fail)(0xaeb /* childrenChangedAfterBatch events should have changedFields */);
479
+ (0, internal_1.fail)(0xaeb /* childrenChangedAfterBatch events should have changedFields */);
480
480
  node.events.emit(event, { changedFields });
481
481
  }
482
482
  else {
@@ -711,7 +711,7 @@ class PathNode extends index_js_1.ReferenceCountedBase {
711
711
  getOrCreateChildRef(key, index) {
712
712
  const anchor = this.anchorSet.track(this.child(key, index));
713
713
  const node = this.anchorSet.locate(anchor) ??
714
- (0, index_js_1.fail)(0xaec /* cannot reference child that does not exist */);
714
+ (0, internal_1.fail)(0xaec /* cannot reference child that does not exist */);
715
715
  return [anchor, node];
716
716
  }
717
717
  /**