@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":"editManager.js","sourceRoot":"","sources":["../../src/shared-tree-core/editManager.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAC7D,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAE7D,OAAO,EAAE,KAAK,EAAE,MAAM,2BAA2B,CAAC;AAElD,OAAO,EAKN,YAAY,EACZ,kBAAkB,EAClB,UAAU,EACV,YAAY,EAEZ,SAAS,GACT,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAgB,KAAK,EAAE,IAAI,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,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M,IAAI,GAAc,EAAE,CAAC;IAC3B,MAAM,CACL,kBAAkB,CAAC,CAAC,UAAU,EAAE,IAAI,CAAC,EAAE,cAAc,CAAC,KAAK,SAAS,EACpE,KAAK,CAAC,qCAAqC,CAC3C,CAAC;IACF,OAAO,IAAI,CAAC;AACb,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport { createEmitter } from \"@fluid-internal/client-utils\";\nimport type { SessionId } from \"@fluidframework/id-compressor\";\nimport { BTree } from \"@tylerbu/sorted-btree-es6\";\n\nimport {\n\ttype ChangeFamily,\n\ttype ChangeFamilyEditor,\n\ttype GraphCommit,\n\ttype RevisionTag,\n\tfindAncestor,\n\tfindCommonAncestor,\n\tmintCommit,\n\trebaseChange,\n\ttype RebaseStatsWithDuration,\n\ttagChange,\n} from \"../core/index.js\";\nimport { type Mutable, brand, fail, getOrCreate, mapIterable } from \"../util/index.js\";\n\nimport { SharedTreeBranch, type BranchTrimmingEvents, onForkTransitive } from \"./branch.js\";\nimport type {\n\tCommit,\n\tSeqNumber,\n\tSequenceId,\n\tSequencedCommit,\n\tSummarySessionBranch,\n} from \"./editManagerFormat.js\";\nimport {\n\tgetUpperBoundOfPreviousSequenceId,\n\tequalSequenceIds,\n\tmaxSequenceId,\n\tminSequenceId,\n\tsequenceIdComparator,\n} from \"./sequenceIdUtils.js\";\nimport {\n\tTelemetryEventBatcher,\n\tmeasure,\n\ttype ITelemetryLoggerExt,\n} from \"@fluidframework/telemetry-utils/internal\";\n\nexport const minimumPossibleSequenceNumber: SeqNumber = brand(Number.MIN_SAFE_INTEGER);\nconst minimumPossibleSequenceId: SequenceId = {\n\tsequenceNumber: minimumPossibleSequenceNumber,\n};\n\n/**\n * A special revision tag for the initial {@link EditManager.trunkBase} commit.\n * @remarks This tag is used to supply the _initial_ trunk base with a known revision.\n * The trunk base may advance over time, after which point the trunk base will have a different revision.\n * When {@link EditManager.getSummaryData | serializing} and deserializing, peer branches that include the trunk base commit in their history will always use this tag.\n */\nconst rootRevision = \"root\" as const satisfies RevisionTag;\n\n/**\n * Max number of telemetry log call that may be aggregated before being sent.\n */\nconst maxRebaseStatsAggregationCount = 1000;\n\n/**\n * Represents a local branch of a document and interprets the effect on the document of adding sequenced changes,\n * which were based on a given session's branch, to the document history\n */\n// TODO: Try to reduce this to a single type parameter\nexport class EditManager<\n\tTEditor extends ChangeFamilyEditor,\n\tTChangeset,\n\tTChangeFamily extends ChangeFamily<TEditor, TChangeset>,\n> {\n\tprivate readonly _events = createEmitter<BranchTrimmingEvents>();\n\n\t/** The \"trunk\" branch. The trunk represents the list of received sequenced changes. */\n\tprivate readonly trunk: SharedTreeBranch<TEditor, TChangeset>;\n\n\t/**\n\t * Records extra data associated with commits in the {@link trunk}.\n\t * This does not include an entry for the {@link trunkBase}.\n\t */\n\tprivate readonly trunkMetadata = new Map<\n\t\tRevisionTag,\n\t\t{ sequenceId: SequenceId; sessionId: SessionId }\n\t>();\n\t/**\n\t * A map from a sequence id to the commit in the {@link trunk} which has that sequence id.\n\t * This also includes an entry for the {@link trunkBase} which always has the lowest key in the map.\n\t */\n\tprivate readonly sequenceMap = new BTree<SequenceId, GraphCommit<TChangeset>>(\n\t\tundefined,\n\t\tsequenceIdComparator,\n\t);\n\n\t/**\n\t * Branches are maintained to represent the local change list that the issuing client had\n\t * at the time of submitting the latest known edit on the branch.\n\t * This means the head commit of each branch is always in its original (non-rebased) form.\n\t */\n\tprivate readonly peerLocalBranches: Map<SessionId, SharedTreeBranch<TEditor, TChangeset>> =\n\t\tnew Map();\n\n\t/**\n\t * This branch holds the changes made by this client which have not yet been confirmed as sequenced changes.\n\t */\n\tpublic readonly localBranch: SharedTreeBranch<TEditor, TChangeset>;\n\n\t/**\n\t * Tracks where on the trunk all registered branches are based. Each key is the sequence id of a commit on\n\t * the trunk, and the value is the set of all branches who have that commit as their common ancestor with the trunk.\n\t *\n\t * @remarks\n\t * This does not include the local branch.\n\t */\n\tprivate readonly trunkBranches = new BTree<\n\t\tSequenceId,\n\t\tSet<SharedTreeBranch<TEditor, TChangeset>>\n\t>(undefined, sequenceIdComparator);\n\n\t/**\n\t * The sequence number of the newest commit on the trunk that has been received by all peers.\n\t * Defaults to {@link minimumPossibleSequenceNumber} if no commits have been received.\n\t *\n\t * @remarks If there are more than one commit with the same sequence number we assume this refers to the last commit in the batch.\n\t */\n\tprivate minimumSequenceNumber = minimumPossibleSequenceNumber;\n\n\t/**\n\t * A special commit that is a \"base\" (tail) of the trunk, though not part of the trunk itself.\n\t * This makes it possible to model the trunk in the same way as any other branch (it branches off of a base commit)\n\t * which allows it to use branching APIs to interact with the other branches.\n\t * Each time trunk eviction occurs, the most recent evicted commit becomes the new `trunkBase`.\n\t */\n\tprivate trunkBase: GraphCommit<TChangeset>;\n\n\t/**\n\t * The list of commits (from oldest to most recent) that are on the local branch but not on the trunk.\n\t * When a local commit is sequenced, the first commit in this list shifted onto the tip of the trunk.\n\t */\n\tprivate readonly localCommits: GraphCommit<TChangeset>[] = [];\n\n\tprivate readonly telemetryEventBatcher:\n\t\t| TelemetryEventBatcher<keyof RebaseStatsWithDuration>\n\t\t| undefined;\n\n\t/**\n\t * @param changeFamily - the change family of changes on the trunk and local branch\n\t * @param localSessionId - the id of the local session that will be used for local commits\n\t */\n\tpublic constructor(\n\t\tpublic readonly changeFamily: TChangeFamily,\n\t\tpublic readonly localSessionId: SessionId,\n\t\tprivate readonly mintRevisionTag: () => RevisionTag,\n\t\tlogger?: ITelemetryLoggerExt,\n\t) {\n\t\tthis.trunkBase = {\n\t\t\trevision: rootRevision,\n\t\t\tchange: changeFamily.rebaser.compose([]),\n\t\t};\n\t\tthis.sequenceMap.set(minimumPossibleSequenceId, this.trunkBase);\n\n\t\tif (logger !== undefined) {\n\t\t\tthis.telemetryEventBatcher = new TelemetryEventBatcher(\n\t\t\t\t{\n\t\t\t\t\teventName: \"rebaseProcessing\",\n\t\t\t\t\tcategory: \"performance\",\n\t\t\t\t},\n\t\t\t\tlogger,\n\t\t\t\tmaxRebaseStatsAggregationCount,\n\t\t\t);\n\t\t}\n\n\t\tthis.trunk = new SharedTreeBranch(\n\t\t\tthis.trunkBase,\n\t\t\tchangeFamily,\n\t\t\tmintRevisionTag,\n\t\t\tthis._events,\n\t\t\tthis.telemetryEventBatcher,\n\t\t);\n\t\tthis.localBranch = new SharedTreeBranch(\n\t\t\tthis.trunk.getHead(),\n\t\t\tchangeFamily,\n\t\t\tmintRevisionTag,\n\t\t\tthis._events,\n\t\t\tthis.telemetryEventBatcher,\n\t\t);\n\n\t\tthis.localBranch.events.on(\"afterChange\", (event) => {\n\t\t\tif (event.type === \"append\") {\n\t\t\t\tfor (const commit of event.newCommits) {\n\t\t\t\t\tthis.localCommits.push(commit);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tthis.localCommits.length = 0;\n\t\t\t\tfindCommonAncestor(\n\t\t\t\t\t[this.localBranch.getHead(), this.localCommits],\n\t\t\t\t\tthis.trunk.getHead(),\n\t\t\t\t);\n\t\t\t}\n\t\t});\n\n\t\t// Track all forks of the local branch for purposes of trunk eviction. Unlike the local branch, they have\n\t\t// an unknown lifetime and rebase frequency, so we can not make any assumptions about which trunk commits\n\t\t// they require and therefore we monitor them explicitly.\n\t\tonForkTransitive(this.localBranch, (fork) => this.registerBranch(fork));\n\t}\n\n\t/**\n\t * Make the given branch known to the `EditManager`. The `EditManager` will ensure that all registered\n\t * branches remain usable even as the minimum sequence number advances.\n\t *\n\t * TODO#AB6926: Refactor local branch management into a separate class that encapsulates `trunkBranches` and everything\n\t * that touches it.\n\t * TODO#AB6925: Maintain the divergence point between each branch and the trunk so that we don't have to recompute\n\t * it so often.\n\t */\n\tprivate registerBranch(branch: SharedTreeBranch<TEditor, TChangeset>): void {\n\t\tthis.trackBranch(branch);\n\t\t// Whenever the branch is rebased, update our record of its base trunk commit\n\t\tconst offBeforeRebase = branch.events.on(\"beforeChange\", (args) => {\n\t\t\tif (args.type === \"rebase\") {\n\t\t\t\tthis.untrackBranch(branch);\n\t\t\t}\n\t\t});\n\t\tconst offAfterRebase = branch.events.on(\"afterChange\", (args) => {\n\t\t\tif (args.type === \"rebase\") {\n\t\t\t\tthis.trackBranch(branch);\n\t\t\t\tthis.trimTrunk();\n\t\t\t}\n\t\t});\n\t\t// When the branch is disposed, update our branch set and trim the trunk\n\t\tconst offDispose = branch.events.on(\"dispose\", () => {\n\t\t\tthis.untrackBranch(branch);\n\t\t\tthis.trimTrunk();\n\t\t\toffBeforeRebase();\n\t\t\toffAfterRebase();\n\t\t\toffDispose();\n\t\t});\n\t}\n\n\tprivate trackBranch(b: SharedTreeBranch<TEditor, TChangeset>): void {\n\t\tconst trunkCommit =\n\t\t\tfindCommonAncestor(this.trunk.getHead(), b.getHead()) ??\n\t\t\tfail(0xad2 /* Expected branch to be related to trunk */);\n\t\tconst sequenceId = this.getCommitSequenceId(trunkCommit);\n\t\tconst branches = getOrCreate(this.trunkBranches, sequenceId, () => new Set());\n\n\t\tassert(!branches.has(b), 0x670 /* Branch was registered more than once */);\n\t\tbranches.add(b);\n\t}\n\n\tprivate untrackBranch(b: SharedTreeBranch<TEditor, TChangeset>): void {\n\t\tconst trunkCommit =\n\t\t\tfindCommonAncestor(this.trunk.getHead(), b.getHead()) ??\n\t\t\tfail(0xad3 /* Expected branch to be related to trunk */);\n\t\tconst sequenceId = this.getCommitSequenceId(trunkCommit);\n\t\tconst branches =\n\t\t\tthis.trunkBranches.get(sequenceId) ?? fail(0xad4 /* Expected branch to be tracked */);\n\n\t\tassert(branches.delete(b), 0x671 /* Expected branch to be tracked */);\n\t\tif (branches.size === 0) {\n\t\t\tthis.trunkBranches.delete(sequenceId);\n\t\t}\n\t}\n\n\t/**\n\t * Promote the oldest un-sequenced commit on the local branch to the head of the trunk.\n\t * @param sequenceId - The sequence id of the new trunk commit\n\t * @remarks This method is a performance optimization for the scenario where this client receives its own change back after sequencing.\n\t * The normal (not optimized) process in this case would be to apply the new sequenced commit to the trunk and then rebase the local branch over the trunk.\n\t * The first commit will be \"the same\" (as in, it will have the same revision) as the commit that was just sequenced, so the rebase will be a no-op.\n\t * Because the rebase is a no-op, we can skip it entirely and simply remove the commit from the local branch and append it to the trunk.\n\t * Avoiding the overhead of the rebase process, even when it's a no-op, has real measured performance benefits and is worth the added complexity here.\n\t */\n\tprivate fastForwardNextLocalCommit(sequenceId: SequenceId): void {\n\t\t// First, push the local commit to the trunk.\n\t\t// We are mutating our `localCommits` cache here, but there is no need to actually change the `localBranch` itself because it will simply catch up later if/when it next rebases.\n\t\tconst firstLocalCommit = this.localCommits.shift();\n\t\tassert(\n\t\t\tfirstLocalCommit !== undefined,\n\t\t\t0x6b5 /* Received a sequenced change from the local session despite having no local changes */,\n\t\t);\n\n\t\tconst previousSequenceId = this.getCommitSequenceId(this.trunk.getHead());\n\t\tthis.pushGraphCommitToTrunk(sequenceId, firstLocalCommit, this.localSessionId);\n\n\t\t// Next, we need to update the sequence IDs that our local branches (user's branches, not peer branches) are associated with.\n\t\t// In particular, if a local branch is based on the previous trunk head (the branch's first ancestor in the trunk is the commit that was the head before we pushed the new commit)\n\t\t// and also branches off of the local branch (it has an ancestor that is part of the local branch), it needs to have its sequence number advanced to be that of the new trunk head.\n\t\t// Intuitively, this makes sense because:\n\t\t// 1. The trunk's head just advanced forward by some (sequence) amount.\n\t\t// 2. The local branch is always rebased to be branching off of the head of the trunk (not literally in this case, because of the optimization, but in effect).\n\t\t// 3. Therefore, the entire local branch just advanced forward by some (sequence) amount, and any commits downstream of it which track the sequence numbers of their base commits on the trunk should also advance.\n\t\t// This update is not necessarily required for all local branches, since some may have fallen behind the local branch and are based on older trunk commits (such branches do not need updating).\n\t\tconst currentBranches = this.trunkBranches.get(previousSequenceId);\n\t\tif (currentBranches !== undefined) {\n\t\t\tconst newBranches = getOrCreate(this.trunkBranches, sequenceId, () => new Set());\n\t\t\tfor (const branch of currentBranches) {\n\t\t\t\t// Check every branch associated with the old sequence ID and advance it if it is based on the local branch (specifically, on the local branch as it was before we pushed its first commit to the trunk).\n\t\t\t\t// We validate this by checking if the branch's head is a descendant of the local commit that we just pushed.\n\t\t\t\tif (findAncestor(branch.getHead(), (c) => c === firstLocalCommit) !== undefined) {\n\t\t\t\t\tnewBranches.add(branch);\n\t\t\t\t\tcurrentBranches.delete(branch);\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Clean up our trunk branches map by removing any empty sets.\n\t\t\tif (currentBranches.size === 0) {\n\t\t\t\tthis.trunkBranches.delete(previousSequenceId);\n\t\t\t}\n\t\t\tif (newBranches.size === 0) {\n\t\t\t\tthis.trunkBranches.delete(sequenceId);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Return the sequence number at which the given commit was sequenced on the trunk, or undefined if the commit is not part of the trunk.\n\t */\n\tpublic getSequenceNumber(trunkCommit: GraphCommit<TChangeset>): SeqNumber | undefined {\n\t\treturn this.trunkMetadata.get(trunkCommit.revision)?.sequenceId.sequenceNumber;\n\t}\n\n\t/**\n\t * Advances the minimum sequence number, and removes all commits from the trunk which lie outside the collaboration window,\n\t * if they are not retained by revertibles or local branches.\n\t * @param minimumSequenceNumber - the sequence number of the newest commit that all peers (including this one) have received and applied to their trunks.\n\t *\n\t * @remarks If there are more than one commit with the same sequence number we assume this refers to the last commit in the batch.\n\t */\n\tpublic advanceMinimumSequenceNumber(\n\t\tminimumSequenceNumber: SeqNumber,\n\t\ttrimTrunk = true,\n\t): void {\n\t\tif (minimumSequenceNumber === this.minimumSequenceNumber) {\n\t\t\treturn;\n\t\t}\n\n\t\tassert(\n\t\t\tminimumSequenceNumber > this.minimumSequenceNumber,\n\t\t\t0x476 /* number must be larger or equal to current minimumSequenceNumber. */,\n\t\t);\n\n\t\tthis.minimumSequenceNumber = minimumSequenceNumber;\n\t\tif (trimTrunk) {\n\t\t\tthis.trimTrunk();\n\t\t}\n\t}\n\n\t/**\n\t * Examines the latest known minimum sequence number and the trunk bases of any registered branches to determine\n\t * if any commits on the trunk are unreferenced and unneeded for future computation; those found are evicted from the trunk.\n\t */\n\tprivate trimTrunk(): void {\n\t\t/** The sequence id of the most recent commit on the trunk that will be trimmed */\n\t\tlet trunkTailSequenceId: SequenceId = {\n\t\t\tsequenceNumber: this.minimumSequenceNumber,\n\t\t\tindexInBatch: Number.POSITIVE_INFINITY,\n\t\t};\n\t\t// If there are any outstanding registered branches, get the one that is the oldest (has the \"most behind\" trunk base)\n\t\tconst minimumBranchBaseSequenceId = this.trunkBranches.minKey();\n\t\tif (minimumBranchBaseSequenceId !== undefined) {\n\t\t\t// If that branch is behind the minimum sequence id, we only want to evict commits older than it,\n\t\t\t// even if those commits are behind the minimum sequence id\n\t\t\tconst sequenceIdBeforeMinimumBranchBase = getUpperBoundOfPreviousSequenceId(\n\t\t\t\tminimumBranchBaseSequenceId,\n\t\t\t);\n\t\t\ttrunkTailSequenceId = minSequenceId(\n\t\t\t\ttrunkTailSequenceId,\n\t\t\t\tsequenceIdBeforeMinimumBranchBase,\n\t\t\t);\n\t\t}\n\n\t\tconst [sequenceId, latestEvicted] = this.getClosestTrunkCommit(\n\t\t\tmaxSequenceId(\n\t\t\t\ttrunkTailSequenceId,\n\t\t\t\tthis.sequenceMap.minKey() ?? minimumPossibleSequenceId,\n\t\t\t),\n\t\t);\n\n\t\t// Don't do any work if the commit found by the search is already the tail of the trunk\n\t\tif (latestEvicted !== this.trunkBase) {\n\t\t\t// The minimum sequence number informs us that all peer branches are at least caught up to the tail commit,\n\t\t\t// so rebase them accordingly. This is necessary to prevent peer branches from referencing any evicted commits.\n\t\t\tfor (const [, branch] of this.peerLocalBranches) {\n\t\t\t\tbranch.rebaseOnto(this.trunk, latestEvicted);\n\t\t\t}\n\n\t\t\t// This mutation is a performance hack. If commits are truly immutable, then changing the trunk's tail requires\n\t\t\t// regenerating the entire commit graph. Instead, we can simply chop off the tail like this if we're certain\n\t\t\t// that there are no outstanding references to any of the commits being removed (other than the references via\n\t\t\t// the trunk). The peer branches have been rebased to the head of the trunk, the local branch is already rebased\n\t\t\t// to the head of the trunk, and all other branches are tracked by `trunkBranches` and known to be ahead of or at\n\t\t\t// `newTrunkBase`. Therefore, no branches should have unique references to any of the commits being evicted here.\n\t\t\t// We mutate the most recent of the evicted commits to become the new trunk base. That way, any other commits that\n\t\t\t// have parent pointers to the latest evicted commit will stay linked, even though that it is no longer part of the trunk.\n\t\t\tconst newTrunkBase = latestEvicted as Mutable<typeof latestEvicted>;\n\t\t\t// The metadata for new trunk base revision needs to be deleted before modifying it.\n\t\t\tthis.trunkMetadata.delete(newTrunkBase.revision);\n\t\t\t// collect the revisions that will be trimmed to send as part of the branch trimmed event\n\t\t\tconst trimmedRevisions: RevisionTag[] = getPathFromBase(\n\t\t\t\tnewTrunkBase,\n\t\t\t\tthis.trunkBase,\n\t\t\t).map((c) => c.revision);\n\t\t\t// Dropping the parent field removes (transitively) all references to the evicted commits so they can be garbage collected.\n\t\t\tdelete newTrunkBase.parent;\n\t\t\tthis.trunkBase = newTrunkBase;\n\n\t\t\t// Update any state that is derived from trunk commits\n\t\t\tthis.sequenceMap.editRange(minimumPossibleSequenceId, sequenceId, true, (s, commit) => {\n\t\t\t\t// Cleanup look-aside data for each evicted commit\n\t\t\t\tthis.trunkMetadata.delete(commit.revision);\n\t\t\t\t// Delete all evicted commits from `sequenceMap` except for the latest one, which is the new `trunkBase`\n\t\t\t\tif (equalSequenceIds(s, sequenceId)) {\n\t\t\t\t\tassert(\n\t\t\t\t\t\tcommit === newTrunkBase,\n\t\t\t\t\t\t0x729 /* Expected last evicted commit to be new trunk base */,\n\t\t\t\t\t);\n\t\t\t\t} else {\n\t\t\t\t\tReflect.defineProperty(commit, \"change\", {\n\t\t\t\t\t\tget: () =>\n\t\t\t\t\t\t\tassert(\n\t\t\t\t\t\t\t\tfalse,\n\t\t\t\t\t\t\t\t0xa5e /* Should not access 'change' property of an evicted commit */,\n\t\t\t\t\t\t\t),\n\t\t\t\t\t});\n\t\t\t\t\tReflect.defineProperty(commit, \"revision\", {\n\t\t\t\t\t\tget: () =>\n\t\t\t\t\t\t\tassert(\n\t\t\t\t\t\t\t\tfalse,\n\t\t\t\t\t\t\t\t0xa5f /* Should not access 'revision' property of an evicted commit */,\n\t\t\t\t\t\t\t),\n\t\t\t\t\t});\n\t\t\t\t\tReflect.defineProperty(commit, \"parent\", {\n\t\t\t\t\t\tget: () =>\n\t\t\t\t\t\t\tassert(\n\t\t\t\t\t\t\t\tfalse,\n\t\t\t\t\t\t\t\t0xa60 /* Should not access 'parent' property of an evicted commit */,\n\t\t\t\t\t\t\t),\n\t\t\t\t\t});\n\t\t\t\t\treturn { delete: true };\n\t\t\t\t}\n\t\t\t});\n\n\t\t\tconst trunkSize = getPathFromBase(this.trunk.getHead(), this.trunkBase).length;\n\t\t\tassert(\n\t\t\t\tthis.sequenceMap.size === trunkSize + 1,\n\t\t\t\t0x744 /* The size of the sequenceMap must have one element more than the trunk */,\n\t\t\t);\n\t\t\tassert(\n\t\t\t\tthis.trunkMetadata.size === trunkSize,\n\t\t\t\t0x745 /* The size of the trunkMetadata must be the same as the trunk */,\n\t\t\t);\n\n\t\t\tthis._events.emit(\"ancestryTrimmed\", trimmedRevisions);\n\t\t}\n\t}\n\n\tpublic isEmpty(): boolean {\n\t\treturn (\n\t\t\tthis.trunk.getHead() === this.trunkBase &&\n\t\t\tthis.peerLocalBranches.size === 0 &&\n\t\t\tthis.localBranch.getHead() === this.trunk.getHead() &&\n\t\t\tthis.minimumSequenceNumber === minimumPossibleSequenceNumber\n\t\t);\n\t}\n\n\tpublic getSummaryData(): SummaryData<TChangeset> {\n\t\t// The assert below is acceptable at present because summarization only ever occurs on a client with no\n\t\t// local/in-flight changes.\n\t\t// In the future we may wish to relax this constraint. For that to work, the current implementation of\n\t\t// `EditManager` would have to be amended in one of two ways:\n\t\t// A) Changes made by the local session should be represented by a branch in `EditManager.branches`.\n\t\t// B) The contents of such a branch should be computed on demand based on the trunk.\n\t\t// Note that option (A) would be a simple change to `addSequencedChanges` whereas (B) would likely require\n\t\t// rebasing trunk changes over the inverse of trunk changes.\n\t\tassert(\n\t\t\tthis.localBranch.getHead() === this.trunk.getHead(),\n\t\t\t0x428 /* Clients with local changes cannot be used to generate summaries */,\n\t\t);\n\n\t\t// Trimming the trunk before serializing ensures that the trunk data in the summary is as minimal as possible.\n\t\tthis.trimTrunk();\n\n\t\tlet oldestCommitInCollabWindow = this.getClosestTrunkCommit(this.minimumSequenceNumber)[1];\n\t\tassert(\n\t\t\toldestCommitInCollabWindow.parent !== undefined ||\n\t\t\t\toldestCommitInCollabWindow === this.trunkBase,\n\t\t\t0x8c7 /* Expected oldest commit in collab window to have a parent or be the trunk base */,\n\t\t);\n\n\t\t// Path construction is exclusive, so we need to use the parent of the oldest commit in the window if it exists\n\t\toldestCommitInCollabWindow =\n\t\t\toldestCommitInCollabWindow.parent ?? oldestCommitInCollabWindow;\n\n\t\tconst trunk = getPathFromBase(this.trunk.getHead(), oldestCommitInCollabWindow).map(\n\t\t\t(c) => {\n\t\t\t\tassert(\n\t\t\t\t\tc !== this.trunkBase,\n\t\t\t\t\t0xa61 /* Serialized trunk should not include the trunk base */,\n\t\t\t\t);\n\t\t\t\tconst metadata =\n\t\t\t\t\tthis.trunkMetadata.get(c.revision) ??\n\t\t\t\t\tfail(0xad5 /* Expected metadata for trunk commit */);\n\t\t\t\tconst commit: SequencedCommit<TChangeset> = {\n\t\t\t\t\tchange: c.change,\n\t\t\t\t\trevision: c.revision,\n\t\t\t\t\tsequenceNumber: metadata.sequenceId.sequenceNumber,\n\t\t\t\t\tsessionId: metadata.sessionId,\n\t\t\t\t};\n\t\t\t\tif (metadata.sequenceId.indexInBatch !== undefined) {\n\t\t\t\t\tcommit.indexInBatch = metadata.sequenceId.indexInBatch;\n\t\t\t\t}\n\t\t\t\treturn commit;\n\t\t\t},\n\t\t);\n\n\t\tconst peerLocalBranches = new Map<SessionId, SummarySessionBranch<TChangeset>>(\n\t\t\tmapIterable(this.peerLocalBranches.entries(), ([sessionId, branch]) => {\n\t\t\t\tconst branchPath: GraphCommit<TChangeset>[] = [];\n\t\t\t\tconst ancestor =\n\t\t\t\t\tfindCommonAncestor([branch.getHead(), branchPath], this.trunk.getHead()) ??\n\t\t\t\t\tfail(0xad6 /* Expected branch to be based on trunk */);\n\n\t\t\t\tconst base = ancestor === this.trunkBase ? rootRevision : ancestor.revision;\n\t\t\t\treturn [\n\t\t\t\t\tsessionId,\n\t\t\t\t\t{\n\t\t\t\t\t\tbase,\n\t\t\t\t\t\tcommits: branchPath.map((c) => {\n\t\t\t\t\t\t\tassert(\n\t\t\t\t\t\t\t\tc !== this.trunkBase,\n\t\t\t\t\t\t\t\t0xa62 /* Serialized branch should not include the trunk base */,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tconst commit: Commit<TChangeset> = {\n\t\t\t\t\t\t\t\tchange: c.change,\n\t\t\t\t\t\t\t\trevision: c.revision,\n\t\t\t\t\t\t\t\tsessionId,\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\treturn commit;\n\t\t\t\t\t\t}),\n\t\t\t\t\t},\n\t\t\t\t];\n\t\t\t}),\n\t\t);\n\n\t\treturn { trunk, peerLocalBranches };\n\t}\n\n\tpublic loadSummaryData(data: SummaryData<TChangeset>): void {\n\t\tassert(\n\t\t\tthis.isEmpty(),\n\t\t\t0x68a /* Attempted to load from summary after edit manager was already mutated */,\n\t\t);\n\t\t// Record the tags of each trunk commit as we generate the trunk so they can be looked up quickly\n\t\t// when hydrating the peer branches below\n\t\tconst trunkRevisionCache = new Map<RevisionTag, GraphCommit<TChangeset>>();\n\t\ttrunkRevisionCache.set(this.trunkBase.revision, this.trunkBase);\n\t\tthis.trunk.setHead(\n\t\t\tdata.trunk.reduce((base, c) => {\n\t\t\t\tconst sequenceId: SequenceId =\n\t\t\t\t\tc.indexInBatch === undefined\n\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\tsequenceNumber: c.sequenceNumber,\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t: {\n\t\t\t\t\t\t\t\tsequenceNumber: c.sequenceNumber,\n\t\t\t\t\t\t\t\tindexInBatch: c.indexInBatch,\n\t\t\t\t\t\t\t};\n\t\t\t\tconst commit = mintCommit(base, c);\n\t\t\t\tthis.sequenceMap.set(sequenceId, commit);\n\t\t\t\tthis.trunkMetadata.set(c.revision, {\n\t\t\t\t\tsequenceId,\n\t\t\t\t\tsessionId: c.sessionId,\n\t\t\t\t});\n\t\t\t\ttrunkRevisionCache.set(c.revision, commit);\n\t\t\t\treturn commit;\n\t\t\t}, this.trunkBase),\n\t\t);\n\n\t\tthis.localBranch.setHead(this.trunk.getHead());\n\n\t\tfor (const [sessionId, branch] of data.peerLocalBranches) {\n\t\t\tconst commit =\n\t\t\t\ttrunkRevisionCache.get(branch.base) ??\n\t\t\t\tfail(0xad7 /* Expected summary branch to be based off of a revision in the trunk */);\n\n\t\t\tthis.peerLocalBranches.set(\n\t\t\t\tsessionId,\n\t\t\t\tnew SharedTreeBranch(\n\t\t\t\t\tbranch.commits.reduce(mintCommit, commit),\n\t\t\t\t\tthis.changeFamily,\n\t\t\t\t\tthis.mintRevisionTag,\n\t\t\t\t),\n\t\t\t);\n\t\t}\n\t}\n\n\tprivate getCommitSequenceId(trunkCommitOrTrunkBase: GraphCommit<TChangeset>): SequenceId {\n\t\tconst id = this.trunkMetadata.get(trunkCommitOrTrunkBase.revision)?.sequenceId;\n\t\tif (id === undefined) {\n\t\t\tassert(\n\t\t\t\ttrunkCommitOrTrunkBase === this.trunkBase,\n\t\t\t\t0xa63 /* Commit must be either be on the trunk or be the trunk base */,\n\t\t\t);\n\t\t\treturn minimumPossibleSequenceId;\n\t\t}\n\t\treturn id;\n\t}\n\n\tpublic getTrunkChanges(): readonly TChangeset[] {\n\t\treturn this.getTrunkCommits().map((c) => c.change);\n\t}\n\n\tpublic getTrunkCommits(): readonly GraphCommit<TChangeset>[] {\n\t\treturn getPathFromBase(this.trunk.getHead(), this.trunkBase);\n\t}\n\n\tpublic getTrunkHead(): GraphCommit<TChangeset> {\n\t\treturn this.trunk.getHead();\n\t}\n\n\tpublic getLocalChanges(): readonly TChangeset[] {\n\t\treturn this.getLocalCommits().map((c) => c.change);\n\t}\n\n\tpublic getLocalCommits(): readonly GraphCommit<TChangeset>[] {\n\t\treturn this.localCommits;\n\t}\n\n\t/**\n\t * @returns The length of the longest branch maintained by this EditManager.\n\t * This may be the length of a peer branch or the local branch.\n\t * The length is counted from the lowest common ancestor with the trunk such that a fully sequenced branch would\n\t * have length zero.\n\t */\n\tpublic getLongestBranchLength(): number {\n\t\tlet max = 0;\n\t\tconst trunkHead = this.trunk.getHead();\n\t\tfor (const branch of this.peerLocalBranches.values()) {\n\t\t\tconst branchPath = getPathFromBase(branch.getHead(), trunkHead);\n\t\t\tif (branchPath.length > max) {\n\t\t\t\tmax = branchPath.length;\n\t\t\t}\n\t\t}\n\t\tconst localPath = getPathFromBase(this.localBranch.getHead(), trunkHead);\n\t\treturn Math.max(max, localPath.length);\n\t}\n\n\t/* eslint-disable jsdoc/check-indentation */\n\t/**\n\t * Add a bunch of sequenced changes. A bunch is a group of sequenced commits that have the following properties:\n\t * - They are not interleaved with messages from other DDSes in the container.\n\t * - They are all part of the same batch, which entails:\n\t * - They are contiguous in sequencing order.\n\t * - They are all from the same client.\n\t * - They are all based on the same reference sequence number.\n\t * - They are not interleaved with messages from other clients.\n\t */\n\t/* eslint-enable jsdoc/check-indentation */\n\tpublic addSequencedChanges(\n\t\tnewCommits: readonly GraphCommit<TChangeset>[],\n\t\tsessionId: SessionId,\n\t\tsequenceNumber: SeqNumber,\n\t\treferenceSequenceNumber: SeqNumber,\n\t): void {\n\t\tassert(newCommits.length > 0, 0xad8 /* Expected at least one sequenced change */);\n\t\tassert(\n\t\t\tsequenceNumber > this.minimumSequenceNumber,\n\t\t\t0x713 /* Expected change sequence number to exceed the last known minimum sequence number */,\n\t\t);\n\t\tassert(\n\t\t\tsequenceNumber >= // This is \">=\", not \">\" because changes in the same batch will have the same sequence number\n\t\t\t\t(this.sequenceMap.maxKey()?.sequenceNumber ?? minimumPossibleSequenceNumber),\n\t\t\t0xa64 /* Attempted to sequence change with an outdated sequence number */,\n\t\t);\n\n\t\t// Returns the sequence id for the next commit to be processed in the bunch. Since all the commits have the\n\t\t// same sequence number, only the index in the batch needs to be incremented.\n\t\tconst getNextSequenceId = (sequenceId: SequenceId): SequenceId => {\n\t\t\treturn {\n\t\t\t\tsequenceNumber: sequenceId.sequenceNumber,\n\t\t\t\tindexInBatch: (sequenceId.indexInBatch ?? 0) + 1,\n\t\t\t};\n\t\t};\n\t\tconst commitsSequenceNumber = this.getBatch(sequenceNumber);\n\t\t// The sequence id for the next commit to be processed in the bunch.\n\t\tlet nextSequenceId =\n\t\t\tcommitsSequenceNumber.length === 0\n\t\t\t\t? {\n\t\t\t\t\t\tsequenceNumber,\n\t\t\t\t\t}\n\t\t\t\t: {\n\t\t\t\t\t\tsequenceNumber,\n\t\t\t\t\t\tindexInBatch: commitsSequenceNumber.length,\n\t\t\t\t\t};\n\n\t\t// Local changes, i.e., changes from this client are applied by fast forwarding the local branch commit onto\n\t\t// the trunk.\n\t\tif (sessionId === this.localSessionId) {\n\t\t\tfor (const _ of newCommits) {\n\t\t\t\tthis.fastForwardNextLocalCommit(nextSequenceId);\n\t\t\t\tnextSequenceId = getNextSequenceId(nextSequenceId);\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\n\t\t// Remote changes, i.e., changes from remote clients are applied in three steps.\n\t\tfor (const newCommit of newCommits) {\n\t\t\t// Step 1 - Recreate the peer remote client's local environment.\n\t\t\t// Get the revision that the remote change is based on\n\t\t\tconst [, baseRevisionInTrunk] = this.getClosestTrunkCommit(referenceSequenceNumber);\n\t\t\t// Rebase that peer local branch over the part of the trunk up to the base revision\n\t\t\t// This will be a no-op if the sending client has not advanced since the last time we received an edit from it\n\t\t\tconst peerLocalBranch = getOrCreate(\n\t\t\t\tthis.peerLocalBranches,\n\t\t\t\tsessionId,\n\t\t\t\t() =>\n\t\t\t\t\tnew SharedTreeBranch(baseRevisionInTrunk, this.changeFamily, this.mintRevisionTag),\n\t\t\t);\n\t\t\tpeerLocalBranch.rebaseOnto(this.trunk, baseRevisionInTrunk);\n\n\t\t\t// Step 2 - Append the change to the peer branch. Rebase the change to the tip of the trunk.\n\t\t\tif (peerLocalBranch.getHead() === this.trunk.getHead()) {\n\t\t\t\t// If the branch is fully caught up and empty after being rebased, then push to the trunk directly\n\t\t\t\tthis.pushCommitToTrunk(nextSequenceId, { ...newCommit, sessionId });\n\t\t\t\tpeerLocalBranch.setHead(this.trunk.getHead());\n\t\t\t} else {\n\t\t\t\t// Otherwise, rebase the change over the trunk and append it, and append the original change to the peer branch.\n\t\t\t\tconst { duration, output: newChangeFullyRebased } = measure(() =>\n\t\t\t\t\trebaseChange(\n\t\t\t\t\t\tthis.changeFamily.rebaser,\n\t\t\t\t\t\tnewCommit,\n\t\t\t\t\t\tpeerLocalBranch.getHead(),\n\t\t\t\t\t\tthis.trunk.getHead(),\n\t\t\t\t\t\tthis.mintRevisionTag,\n\t\t\t\t\t),\n\t\t\t\t);\n\n\t\t\t\tthis.telemetryEventBatcher?.accumulateAndLog({\n\t\t\t\t\tduration,\n\t\t\t\t\t...newChangeFullyRebased.telemetryProperties,\n\t\t\t\t});\n\n\t\t\t\tpeerLocalBranch.apply(tagChange(newCommit.change, newCommit.revision));\n\t\t\t\tthis.pushCommitToTrunk(nextSequenceId, {\n\t\t\t\t\t...newCommit,\n\t\t\t\t\tsessionId,\n\t\t\t\t\tchange: newChangeFullyRebased.change,\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tnextSequenceId = getNextSequenceId(nextSequenceId);\n\t\t}\n\n\t\t// Step 3 - Rebase the local branch over the updated trunk.\n\t\tthis.localBranch.rebaseOnto(this.trunk);\n\t}\n\n\tpublic findLocalCommit(\n\t\trevision: RevisionTag,\n\t): [commit: GraphCommit<TChangeset>, commitsAfter: GraphCommit<TChangeset>[]] {\n\t\tconst commits: GraphCommit<TChangeset>[] = [];\n\t\tconst commit = findAncestor(\n\t\t\t[this.localBranch.getHead(), commits],\n\t\t\t(c) => c.revision === revision,\n\t\t);\n\t\tassert(commit !== undefined, 0x599 /* Expected local branch to contain revision */);\n\t\treturn [commit, commits];\n\t}\n\n\tprivate pushCommitToTrunk(sequenceId: SequenceId, commit: Commit<TChangeset>): void {\n\t\tconst mintedCommit = mintCommit(this.trunk.getHead(), commit);\n\t\tthis.pushGraphCommitToTrunk(sequenceId, mintedCommit, commit.sessionId);\n\t}\n\n\tprivate pushGraphCommitToTrunk(\n\t\tsequenceId: SequenceId,\n\t\tgraphCommit: GraphCommit<TChangeset>,\n\t\tsessionId: SessionId,\n\t): void {\n\t\tthis.trunk.setHead(graphCommit);\n\t\tconst trunkHead = this.trunk.getHead();\n\t\tthis.sequenceMap.set(sequenceId, trunkHead);\n\t\tthis.trunkMetadata.set(trunkHead.revision, { sequenceId, sessionId });\n\t}\n\n\t/**\n\t * Finds the most recent trunk commit that was sequenced at or before the given point.\n\t * @param searchBy - the sequence number or the sequence id to search for\n\t * @remarks Fails if there is no eligible commit.\n\t * @returns the closest commit and its sequence id\n\t */\n\tprivate getClosestTrunkCommit(searchBy: SeqNumber): [SequenceId, GraphCommit<TChangeset>];\n\tprivate getClosestTrunkCommit(searchBy: SequenceId): [SequenceId, GraphCommit<TChangeset>];\n\tprivate getClosestTrunkCommit(\n\t\tsearchBy: SeqNumber | SequenceId,\n\t): [SequenceId, GraphCommit<TChangeset>] {\n\t\tconst sequenceId: SequenceId =\n\t\t\ttypeof searchBy === \"number\"\n\t\t\t\t? {\n\t\t\t\t\t\t// This is to make sure that the correct commit is selected in this 2 scenarios:\n\t\t\t\t\t\t// 1) The commit is unique for that sequence number\n\t\t\t\t\t\t// 2) There are more than one commit for the same sequence number, in this case we need to select the last one.\n\t\t\t\t\t\tsequenceNumber: searchBy,\n\t\t\t\t\t\tindexInBatch: Number.POSITIVE_INFINITY,\n\t\t\t\t\t}\n\t\t\t\t: searchBy;\n\n\t\tconst commit = this.sequenceMap.getPairOrNextLower(sequenceId);\n\t\tassert(commit !== undefined, 0x746 /* sequence id has been evicted */);\n\t\treturn commit;\n\t}\n\n\tprivate getBatch(sequenceNumber: SeqNumber): [SequenceId, GraphCommit<TChangeset>][] {\n\t\tconst startSequenceId: SequenceId = {\n\t\t\tsequenceNumber,\n\t\t};\n\t\tconst endSequenceId: SequenceId = {\n\t\t\tsequenceNumber: brand((sequenceNumber as number) + 1),\n\t\t};\n\n\t\treturn this.sequenceMap.getRange(startSequenceId, endSequenceId, false);\n\t}\n}\n\n/**\n * The in-memory data that summaries contain\n */\nexport interface SummaryData<TChangeset> {\n\treadonly trunk: readonly SequencedCommit<TChangeset>[];\n\treadonly peerLocalBranches: ReadonlyMap<SessionId, SummarySessionBranch<TChangeset>>;\n}\n\n/**\n * @returns the path from the base of a branch to its head\n */\nfunction getPathFromBase<TCommit extends { parent?: TCommit }>(\n\tbranchHead: TCommit,\n\tbaseBranchHead: TCommit,\n): TCommit[] {\n\tconst path: TCommit[] = [];\n\tassert(\n\t\tfindCommonAncestor([branchHead, path], baseBranchHead) !== undefined,\n\t\t0x573 /* Expected branches to be related */,\n\t);\n\treturn path;\n}\n"]}
1
+ {"version":3,"file":"editManager.js","sourceRoot":"","sources":["../../src/shared-tree-core/editManager.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,qCAAqC,CAAC;AACnE,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAE7D,OAAO,EAAE,KAAK,EAAE,MAAM,2BAA2B,CAAC;AAElD,OAAO,EAKN,YAAY,EACZ,kBAAkB,EAClB,UAAU,EAEV,SAAS,GACT,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAgB,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAEjF,OAAO,EAAE,gBAAgB,EAA6B,gBAAg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AAC;IAC3B,MAAM,CACL,kBAAkB,CAAC,CAAC,UAAU,EAAE,IAAI,CAAC,EAAE,cAAc,CAAC,KAAK,SAAS,EACpE,KAAK,CAAC,qCAAqC,CAC3C,CAAC;IACF,OAAO,IAAI,CAAC;AACb,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, fail } from \"@fluidframework/core-utils/internal\";\nimport { createEmitter } from \"@fluid-internal/client-utils\";\nimport type { SessionId } from \"@fluidframework/id-compressor\";\nimport { BTree } from \"@tylerbu/sorted-btree-es6\";\n\nimport {\n\ttype ChangeFamily,\n\ttype ChangeFamilyEditor,\n\ttype GraphCommit,\n\ttype RevisionTag,\n\tfindAncestor,\n\tfindCommonAncestor,\n\tmintCommit,\n\ttype RebaseStatsWithDuration,\n\ttagChange,\n} from \"../core/index.js\";\nimport { type Mutable, brand, getOrCreate, mapIterable } from \"../util/index.js\";\n\nimport { SharedTreeBranch, type BranchTrimmingEvents, onForkTransitive } from \"./branch.js\";\nimport type {\n\tCommit,\n\tSeqNumber,\n\tSequenceId,\n\tSequencedCommit,\n\tSummarySessionBranch,\n} from \"./editManagerFormat.js\";\nimport {\n\tgetUpperBoundOfPreviousSequenceId,\n\tequalSequenceIds,\n\tmaxSequenceId,\n\tminSequenceId,\n\tsequenceIdComparator,\n} from \"./sequenceIdUtils.js\";\nimport {\n\tTelemetryEventBatcher,\n\ttype ITelemetryLoggerExt,\n} from \"@fluidframework/telemetry-utils/internal\";\n\nexport const minimumPossibleSequenceNumber: SeqNumber = brand(Number.MIN_SAFE_INTEGER);\nconst minimumPossibleSequenceId: SequenceId = {\n\tsequenceNumber: minimumPossibleSequenceNumber,\n};\n\n/**\n * A special revision tag for the initial {@link EditManager.trunkBase} commit.\n * @remarks This tag is used to supply the _initial_ trunk base with a known revision.\n * The trunk base may advance over time, after which point the trunk base will have a different revision.\n * When {@link EditManager.getSummaryData | serializing} and deserializing, peer branches that include the trunk base commit in their history will always use this tag.\n */\nconst rootRevision = \"root\" as const satisfies RevisionTag;\n\n/**\n * Max number of telemetry log call that may be aggregated before being sent.\n */\nconst maxRebaseStatsAggregationCount = 1000;\n\n/**\n * Represents a local branch of a document and interprets the effect on the document of adding sequenced changes,\n * which were based on a given session's branch, to the document history\n */\n// TODO: Try to reduce this to a single type parameter\nexport class EditManager<\n\tTEditor extends ChangeFamilyEditor,\n\tTChangeset,\n\tTChangeFamily extends ChangeFamily<TEditor, TChangeset>,\n> {\n\tprivate readonly _events = createEmitter<BranchTrimmingEvents>();\n\n\t/** The \"trunk\" branch. The trunk represents the list of received sequenced changes. */\n\tprivate readonly trunk: SharedTreeBranch<TEditor, TChangeset>;\n\n\t/**\n\t * Records extra data associated with commits in the {@link trunk}.\n\t * This does not include an entry for the {@link trunkBase}.\n\t */\n\tprivate readonly trunkMetadata = new Map<\n\t\tRevisionTag,\n\t\t{ sequenceId: SequenceId; sessionId: SessionId }\n\t>();\n\t/**\n\t * A map from a sequence id to the commit in the {@link trunk} which has that sequence id.\n\t * This also includes an entry for the {@link trunkBase} which always has the lowest key in the map.\n\t */\n\tprivate readonly sequenceMap = new BTree<SequenceId, GraphCommit<TChangeset>>(\n\t\tundefined,\n\t\tsequenceIdComparator,\n\t);\n\n\t/**\n\t * Branches are maintained to represent the local change list that the issuing client had\n\t * at the time of submitting the latest known edit on the branch.\n\t * This means the head commit of each branch is always in its original (non-rebased) form.\n\t */\n\tprivate readonly peerLocalBranches: Map<SessionId, SharedTreeBranch<TEditor, TChangeset>> =\n\t\tnew Map();\n\n\t/**\n\t * This branch holds the changes made by this client which have not yet been confirmed as sequenced changes.\n\t */\n\tpublic readonly localBranch: SharedTreeBranch<TEditor, TChangeset>;\n\n\t/**\n\t * Tracks where on the trunk all registered branches are based. Each key is the sequence id of a commit on\n\t * the trunk, and the value is the set of all branches who have that commit as their common ancestor with the trunk.\n\t *\n\t * @remarks\n\t * This does not include the local branch.\n\t */\n\tprivate readonly trunkBranches = new BTree<\n\t\tSequenceId,\n\t\tSet<SharedTreeBranch<TEditor, TChangeset>>\n\t>(undefined, sequenceIdComparator);\n\n\t/**\n\t * The sequence number of the newest commit on the trunk that has been received by all peers.\n\t * Defaults to {@link minimumPossibleSequenceNumber} if no commits have been received.\n\t *\n\t * @remarks If there are more than one commit with the same sequence number we assume this refers to the last commit in the batch.\n\t */\n\tprivate minimumSequenceNumber = minimumPossibleSequenceNumber;\n\n\t/**\n\t * A special commit that is a \"base\" (tail) of the trunk, though not part of the trunk itself.\n\t * This makes it possible to model the trunk in the same way as any other branch (it branches off of a base commit)\n\t * which allows it to use branching APIs to interact with the other branches.\n\t * Each time trunk eviction occurs, the most recent evicted commit becomes the new `trunkBase`.\n\t */\n\tprivate trunkBase: GraphCommit<TChangeset>;\n\n\t/**\n\t * The list of commits (from oldest to most recent) that are on the local branch but not on the trunk.\n\t * When a local commit is sequenced, the first commit in this list shifted onto the tip of the trunk.\n\t */\n\tprivate readonly localCommits: GraphCommit<TChangeset>[] = [];\n\n\tprivate readonly telemetryEventBatcher:\n\t\t| TelemetryEventBatcher<keyof RebaseStatsWithDuration>\n\t\t| undefined;\n\n\t/**\n\t * @param changeFamily - the change family of changes on the trunk and local branch\n\t * @param localSessionId - the id of the local session that will be used for local commits\n\t */\n\tpublic constructor(\n\t\tpublic readonly changeFamily: TChangeFamily,\n\t\tpublic readonly localSessionId: SessionId,\n\t\tprivate readonly mintRevisionTag: () => RevisionTag,\n\t\tlogger?: ITelemetryLoggerExt,\n\t) {\n\t\tthis.trunkBase = {\n\t\t\trevision: rootRevision,\n\t\t\tchange: changeFamily.rebaser.compose([]),\n\t\t};\n\t\tthis.sequenceMap.set(minimumPossibleSequenceId, this.trunkBase);\n\n\t\tif (logger !== undefined) {\n\t\t\tthis.telemetryEventBatcher = new TelemetryEventBatcher(\n\t\t\t\t{\n\t\t\t\t\teventName: \"rebaseProcessing\",\n\t\t\t\t\tcategory: \"performance\",\n\t\t\t\t},\n\t\t\t\tlogger,\n\t\t\t\tmaxRebaseStatsAggregationCount,\n\t\t\t);\n\t\t}\n\n\t\tthis.trunk = new SharedTreeBranch(\n\t\t\tthis.trunkBase,\n\t\t\tchangeFamily,\n\t\t\tmintRevisionTag,\n\t\t\tthis._events,\n\t\t\tthis.telemetryEventBatcher,\n\t\t);\n\t\tthis.localBranch = new SharedTreeBranch(\n\t\t\tthis.trunk.getHead(),\n\t\t\tchangeFamily,\n\t\t\tmintRevisionTag,\n\t\t\tthis._events,\n\t\t\tthis.telemetryEventBatcher,\n\t\t);\n\n\t\tthis.localBranch.events.on(\"afterChange\", (event) => {\n\t\t\tif (event.type === \"append\") {\n\t\t\t\tfor (const commit of event.newCommits) {\n\t\t\t\t\tthis.localCommits.push(commit);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tthis.localCommits.length = 0;\n\t\t\t\tfindCommonAncestor(\n\t\t\t\t\t[this.localBranch.getHead(), this.localCommits],\n\t\t\t\t\tthis.trunk.getHead(),\n\t\t\t\t);\n\t\t\t}\n\t\t});\n\n\t\t// Track all forks of the local branch for purposes of trunk eviction. Unlike the local branch, they have\n\t\t// an unknown lifetime and rebase frequency, so we can not make any assumptions about which trunk commits\n\t\t// they require and therefore we monitor them explicitly.\n\t\tonForkTransitive(this.localBranch, (fork) => this.registerBranch(fork));\n\t}\n\n\t/**\n\t * Make the given branch known to the `EditManager`. The `EditManager` will ensure that all registered\n\t * branches remain usable even as the minimum sequence number advances.\n\t *\n\t * TODO#AB6926: Refactor local branch management into a separate class that encapsulates `trunkBranches` and everything\n\t * that touches it.\n\t * TODO#AB6925: Maintain the divergence point between each branch and the trunk so that we don't have to recompute\n\t * it so often.\n\t */\n\tprivate registerBranch(branch: SharedTreeBranch<TEditor, TChangeset>): void {\n\t\tthis.trackBranch(branch);\n\t\t// Whenever the branch is rebased, update our record of its base trunk commit\n\t\tconst offBeforeRebase = branch.events.on(\"beforeChange\", (args) => {\n\t\t\tif (args.type === \"rebase\") {\n\t\t\t\tthis.untrackBranch(branch);\n\t\t\t}\n\t\t});\n\t\tconst offAfterRebase = branch.events.on(\"afterChange\", (args) => {\n\t\t\tif (args.type === \"rebase\") {\n\t\t\t\tthis.trackBranch(branch);\n\t\t\t\tthis.trimTrunk();\n\t\t\t}\n\t\t});\n\t\t// When the branch is disposed, update our branch set and trim the trunk\n\t\tconst offDispose = branch.events.on(\"dispose\", () => {\n\t\t\tthis.untrackBranch(branch);\n\t\t\tthis.trimTrunk();\n\t\t\toffBeforeRebase();\n\t\t\toffAfterRebase();\n\t\t\toffDispose();\n\t\t});\n\t}\n\n\tprivate trackBranch(b: SharedTreeBranch<TEditor, TChangeset>): void {\n\t\tconst trunkCommit =\n\t\t\tfindCommonAncestor(this.trunk.getHead(), b.getHead()) ??\n\t\t\tfail(0xad2 /* Expected branch to be related to trunk */);\n\t\tconst sequenceId = this.getCommitSequenceId(trunkCommit);\n\t\tconst branches = getOrCreate(this.trunkBranches, sequenceId, () => new Set());\n\n\t\tassert(!branches.has(b), 0x670 /* Branch was registered more than once */);\n\t\tbranches.add(b);\n\t}\n\n\tprivate untrackBranch(b: SharedTreeBranch<TEditor, TChangeset>): void {\n\t\tconst trunkCommit =\n\t\t\tfindCommonAncestor(this.trunk.getHead(), b.getHead()) ??\n\t\t\tfail(0xad3 /* Expected branch to be related to trunk */);\n\t\tconst sequenceId = this.getCommitSequenceId(trunkCommit);\n\t\tconst branches =\n\t\t\tthis.trunkBranches.get(sequenceId) ?? fail(0xad4 /* Expected branch to be tracked */);\n\n\t\tassert(branches.delete(b), 0x671 /* Expected branch to be tracked */);\n\t\tif (branches.size === 0) {\n\t\t\tthis.trunkBranches.delete(sequenceId);\n\t\t}\n\t}\n\n\t/**\n\t * Promote the oldest un-sequenced commit on the local branch to the head of the trunk.\n\t * @param sequenceId - The sequence id of the new trunk commit\n\t * @remarks This method is a performance optimization for the scenario where this client receives its own change back after sequencing.\n\t * The normal (not optimized) process in this case would be to apply the new sequenced commit to the trunk and then rebase the local branch over the trunk.\n\t * The first commit will be \"the same\" (as in, it will have the same revision) as the commit that was just sequenced, so the rebase will be a no-op.\n\t * Because the rebase is a no-op, we can skip it entirely and simply remove the commit from the local branch and append it to the trunk.\n\t * Avoiding the overhead of the rebase process, even when it's a no-op, has real measured performance benefits and is worth the added complexity here.\n\t */\n\tprivate fastForwardNextLocalCommit(sequenceId: SequenceId): void {\n\t\t// First, push the local commit to the trunk.\n\t\t// We are mutating our `localCommits` cache here, but there is no need to actually change the `localBranch` itself because it will simply catch up later if/when it next rebases.\n\t\tconst firstLocalCommit = this.localCommits.shift();\n\t\tassert(\n\t\t\tfirstLocalCommit !== undefined,\n\t\t\t0x6b5 /* Received a sequenced change from the local session despite having no local changes */,\n\t\t);\n\n\t\tconst previousSequenceId = this.getCommitSequenceId(this.trunk.getHead());\n\t\tthis.pushGraphCommitToTrunk(sequenceId, firstLocalCommit, this.localSessionId);\n\n\t\t// Next, we need to update the sequence IDs that our local branches (user's branches, not peer branches) are associated with.\n\t\t// In particular, if a local branch is based on the previous trunk head (the branch's first ancestor in the trunk is the commit that was the head before we pushed the new commit)\n\t\t// and also branches off of the local branch (it has an ancestor that is part of the local branch), it needs to have its sequence number advanced to be that of the new trunk head.\n\t\t// Intuitively, this makes sense because:\n\t\t// 1. The trunk's head just advanced forward by some (sequence) amount.\n\t\t// 2. The local branch is always rebased to be branching off of the head of the trunk (not literally in this case, because of the optimization, but in effect).\n\t\t// 3. Therefore, the entire local branch just advanced forward by some (sequence) amount, and any commits downstream of it which track the sequence numbers of their base commits on the trunk should also advance.\n\t\t// This update is not necessarily required for all local branches, since some may have fallen behind the local branch and are based on older trunk commits (such branches do not need updating).\n\t\tconst currentBranches = this.trunkBranches.get(previousSequenceId);\n\t\tif (currentBranches !== undefined) {\n\t\t\tconst newBranches = getOrCreate(this.trunkBranches, sequenceId, () => new Set());\n\t\t\tfor (const branch of currentBranches) {\n\t\t\t\t// Check every branch associated with the old sequence ID and advance it if it is based on the local branch (specifically, on the local branch as it was before we pushed its first commit to the trunk).\n\t\t\t\t// We validate this by checking if the branch's head is a descendant of the local commit that we just pushed.\n\t\t\t\tif (findAncestor(branch.getHead(), (c) => c === firstLocalCommit) !== undefined) {\n\t\t\t\t\tnewBranches.add(branch);\n\t\t\t\t\tcurrentBranches.delete(branch);\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Clean up our trunk branches map by removing any empty sets.\n\t\t\tif (currentBranches.size === 0) {\n\t\t\t\tthis.trunkBranches.delete(previousSequenceId);\n\t\t\t}\n\t\t\tif (newBranches.size === 0) {\n\t\t\t\tthis.trunkBranches.delete(sequenceId);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Return the sequence number at which the given commit was sequenced on the trunk, or undefined if the commit is not part of the trunk.\n\t */\n\tpublic getSequenceNumber(trunkCommit: GraphCommit<TChangeset>): SeqNumber | undefined {\n\t\treturn this.trunkMetadata.get(trunkCommit.revision)?.sequenceId.sequenceNumber;\n\t}\n\n\t/**\n\t * Advances the minimum sequence number, and removes all commits from the trunk which lie outside the collaboration window,\n\t * if they are not retained by revertibles or local branches.\n\t * @param minimumSequenceNumber - the sequence number of the newest commit that all peers (including this one) have received and applied to their trunks.\n\t *\n\t * @remarks If there are more than one commit with the same sequence number we assume this refers to the last commit in the batch.\n\t */\n\tpublic advanceMinimumSequenceNumber(\n\t\tminimumSequenceNumber: SeqNumber,\n\t\ttrimTrunk = true,\n\t): void {\n\t\tif (minimumSequenceNumber === this.minimumSequenceNumber) {\n\t\t\treturn;\n\t\t}\n\n\t\tassert(\n\t\t\tminimumSequenceNumber > this.minimumSequenceNumber,\n\t\t\t0x476 /* number must be larger or equal to current minimumSequenceNumber. */,\n\t\t);\n\n\t\tthis.minimumSequenceNumber = minimumSequenceNumber;\n\t\tif (trimTrunk) {\n\t\t\tthis.trimTrunk();\n\t\t}\n\t}\n\n\t/**\n\t * Examines the latest known minimum sequence number and the trunk bases of any registered branches to determine\n\t * if any commits on the trunk are unreferenced and unneeded for future computation; those found are evicted from the trunk.\n\t */\n\tprivate trimTrunk(): void {\n\t\t/** The sequence id of the most recent commit on the trunk that will be trimmed */\n\t\tlet trunkTailSequenceId: SequenceId = {\n\t\t\tsequenceNumber: this.minimumSequenceNumber,\n\t\t\tindexInBatch: Number.POSITIVE_INFINITY,\n\t\t};\n\t\t// If there are any outstanding registered branches, get the one that is the oldest (has the \"most behind\" trunk base)\n\t\tconst minimumBranchBaseSequenceId = this.trunkBranches.minKey();\n\t\tif (minimumBranchBaseSequenceId !== undefined) {\n\t\t\t// If that branch is behind the minimum sequence id, we only want to evict commits older than it,\n\t\t\t// even if those commits are behind the minimum sequence id\n\t\t\tconst sequenceIdBeforeMinimumBranchBase = getUpperBoundOfPreviousSequenceId(\n\t\t\t\tminimumBranchBaseSequenceId,\n\t\t\t);\n\t\t\ttrunkTailSequenceId = minSequenceId(\n\t\t\t\ttrunkTailSequenceId,\n\t\t\t\tsequenceIdBeforeMinimumBranchBase,\n\t\t\t);\n\t\t}\n\n\t\tconst [sequenceId, latestEvicted] = this.getClosestTrunkCommit(\n\t\t\tmaxSequenceId(\n\t\t\t\ttrunkTailSequenceId,\n\t\t\t\tthis.sequenceMap.minKey() ?? minimumPossibleSequenceId,\n\t\t\t),\n\t\t);\n\n\t\t// Don't do any work if the commit found by the search is already the tail of the trunk\n\t\tif (latestEvicted !== this.trunkBase) {\n\t\t\t// The minimum sequence number informs us that all peer branches are at least caught up to the tail commit,\n\t\t\t// so rebase them accordingly. This is necessary to prevent peer branches from referencing any evicted commits.\n\t\t\tfor (const [, branch] of this.peerLocalBranches) {\n\t\t\t\tbranch.rebaseOnto(this.trunk, latestEvicted);\n\t\t\t}\n\n\t\t\t// This mutation is a performance hack. If commits are truly immutable, then changing the trunk's tail requires\n\t\t\t// regenerating the entire commit graph. Instead, we can simply chop off the tail like this if we're certain\n\t\t\t// that there are no outstanding references to any of the commits being removed (other than the references via\n\t\t\t// the trunk). The peer branches have been rebased to the head of the trunk, the local branch is already rebased\n\t\t\t// to the head of the trunk, and all other branches are tracked by `trunkBranches` and known to be ahead of or at\n\t\t\t// `newTrunkBase`. Therefore, no branches should have unique references to any of the commits being evicted here.\n\t\t\t// We mutate the most recent of the evicted commits to become the new trunk base. That way, any other commits that\n\t\t\t// have parent pointers to the latest evicted commit will stay linked, even though that it is no longer part of the trunk.\n\t\t\tconst newTrunkBase = latestEvicted as Mutable<typeof latestEvicted>;\n\t\t\t// The metadata for new trunk base revision needs to be deleted before modifying it.\n\t\t\tthis.trunkMetadata.delete(newTrunkBase.revision);\n\t\t\t// collect the revisions that will be trimmed to send as part of the branch trimmed event\n\t\t\tconst trimmedRevisions: RevisionTag[] = getPathFromBase(\n\t\t\t\tnewTrunkBase,\n\t\t\t\tthis.trunkBase,\n\t\t\t).map((c) => c.revision);\n\t\t\t// Dropping the parent field removes (transitively) all references to the evicted commits so they can be garbage collected.\n\t\t\tdelete newTrunkBase.parent;\n\t\t\tthis.trunkBase = newTrunkBase;\n\n\t\t\t// Update any state that is derived from trunk commits\n\t\t\tthis.sequenceMap.editRange(minimumPossibleSequenceId, sequenceId, true, (s, commit) => {\n\t\t\t\t// Cleanup look-aside data for each evicted commit\n\t\t\t\tthis.trunkMetadata.delete(commit.revision);\n\t\t\t\t// Delete all evicted commits from `sequenceMap` except for the latest one, which is the new `trunkBase`\n\t\t\t\tif (equalSequenceIds(s, sequenceId)) {\n\t\t\t\t\tassert(\n\t\t\t\t\t\tcommit === newTrunkBase,\n\t\t\t\t\t\t0x729 /* Expected last evicted commit to be new trunk base */,\n\t\t\t\t\t);\n\t\t\t\t} else {\n\t\t\t\t\tReflect.defineProperty(commit, \"change\", {\n\t\t\t\t\t\tget: () =>\n\t\t\t\t\t\t\tassert(\n\t\t\t\t\t\t\t\tfalse,\n\t\t\t\t\t\t\t\t0xa5e /* Should not access 'change' property of an evicted commit */,\n\t\t\t\t\t\t\t),\n\t\t\t\t\t});\n\t\t\t\t\tReflect.defineProperty(commit, \"revision\", {\n\t\t\t\t\t\tget: () =>\n\t\t\t\t\t\t\tassert(\n\t\t\t\t\t\t\t\tfalse,\n\t\t\t\t\t\t\t\t0xa5f /* Should not access 'revision' property of an evicted commit */,\n\t\t\t\t\t\t\t),\n\t\t\t\t\t});\n\t\t\t\t\tReflect.defineProperty(commit, \"parent\", {\n\t\t\t\t\t\tget: () =>\n\t\t\t\t\t\t\tassert(\n\t\t\t\t\t\t\t\tfalse,\n\t\t\t\t\t\t\t\t0xa60 /* Should not access 'parent' property of an evicted commit */,\n\t\t\t\t\t\t\t),\n\t\t\t\t\t});\n\t\t\t\t\treturn { delete: true };\n\t\t\t\t}\n\t\t\t});\n\n\t\t\tconst trunkSize = getPathFromBase(this.trunk.getHead(), this.trunkBase).length;\n\t\t\tassert(\n\t\t\t\tthis.sequenceMap.size === trunkSize + 1,\n\t\t\t\t0x744 /* The size of the sequenceMap must have one element more than the trunk */,\n\t\t\t);\n\t\t\tassert(\n\t\t\t\tthis.trunkMetadata.size === trunkSize,\n\t\t\t\t0x745 /* The size of the trunkMetadata must be the same as the trunk */,\n\t\t\t);\n\n\t\t\tthis._events.emit(\"ancestryTrimmed\", trimmedRevisions);\n\t\t}\n\t}\n\n\tpublic isEmpty(): boolean {\n\t\treturn (\n\t\t\tthis.trunk.getHead() === this.trunkBase &&\n\t\t\tthis.peerLocalBranches.size === 0 &&\n\t\t\tthis.localBranch.getHead() === this.trunk.getHead() &&\n\t\t\tthis.minimumSequenceNumber === minimumPossibleSequenceNumber\n\t\t);\n\t}\n\n\tpublic getSummaryData(): SummaryData<TChangeset> {\n\t\t// The assert below is acceptable at present because summarization only ever occurs on a client with no\n\t\t// local/in-flight changes.\n\t\t// In the future we may wish to relax this constraint. For that to work, the current implementation of\n\t\t// `EditManager` would have to be amended in one of two ways:\n\t\t// A) Changes made by the local session should be represented by a branch in `EditManager.branches`.\n\t\t// B) The contents of such a branch should be computed on demand based on the trunk.\n\t\t// Note that option (A) would be a simple change to `addSequencedChanges` whereas (B) would likely require\n\t\t// rebasing trunk changes over the inverse of trunk changes.\n\t\tassert(\n\t\t\tthis.localBranch.getHead() === this.trunk.getHead(),\n\t\t\t0x428 /* Clients with local changes cannot be used to generate summaries */,\n\t\t);\n\n\t\t// Trimming the trunk before serializing ensures that the trunk data in the summary is as minimal as possible.\n\t\tthis.trimTrunk();\n\n\t\tlet oldestCommitInCollabWindow = this.getClosestTrunkCommit(this.minimumSequenceNumber)[1];\n\t\tassert(\n\t\t\toldestCommitInCollabWindow.parent !== undefined ||\n\t\t\t\toldestCommitInCollabWindow === this.trunkBase,\n\t\t\t0x8c7 /* Expected oldest commit in collab window to have a parent or be the trunk base */,\n\t\t);\n\n\t\t// Path construction is exclusive, so we need to use the parent of the oldest commit in the window if it exists\n\t\toldestCommitInCollabWindow =\n\t\t\toldestCommitInCollabWindow.parent ?? oldestCommitInCollabWindow;\n\n\t\tconst trunk = getPathFromBase(this.trunk.getHead(), oldestCommitInCollabWindow).map(\n\t\t\t(c) => {\n\t\t\t\tassert(\n\t\t\t\t\tc !== this.trunkBase,\n\t\t\t\t\t0xa61 /* Serialized trunk should not include the trunk base */,\n\t\t\t\t);\n\t\t\t\tconst metadata =\n\t\t\t\t\tthis.trunkMetadata.get(c.revision) ??\n\t\t\t\t\tfail(0xad5 /* Expected metadata for trunk commit */);\n\t\t\t\tconst commit: SequencedCommit<TChangeset> = {\n\t\t\t\t\tchange: c.change,\n\t\t\t\t\trevision: c.revision,\n\t\t\t\t\tsequenceNumber: metadata.sequenceId.sequenceNumber,\n\t\t\t\t\tsessionId: metadata.sessionId,\n\t\t\t\t};\n\t\t\t\tif (metadata.sequenceId.indexInBatch !== undefined) {\n\t\t\t\t\tcommit.indexInBatch = metadata.sequenceId.indexInBatch;\n\t\t\t\t}\n\t\t\t\treturn commit;\n\t\t\t},\n\t\t);\n\n\t\tconst peerLocalBranches = new Map<SessionId, SummarySessionBranch<TChangeset>>(\n\t\t\tmapIterable(this.peerLocalBranches.entries(), ([sessionId, branch]) => {\n\t\t\t\tconst branchPath: GraphCommit<TChangeset>[] = [];\n\t\t\t\tconst ancestor =\n\t\t\t\t\tfindCommonAncestor([branch.getHead(), branchPath], this.trunk.getHead()) ??\n\t\t\t\t\tfail(0xad6 /* Expected branch to be based on trunk */);\n\n\t\t\t\tconst base = ancestor === this.trunkBase ? rootRevision : ancestor.revision;\n\t\t\t\treturn [\n\t\t\t\t\tsessionId,\n\t\t\t\t\t{\n\t\t\t\t\t\tbase,\n\t\t\t\t\t\tcommits: branchPath.map((c) => {\n\t\t\t\t\t\t\tassert(\n\t\t\t\t\t\t\t\tc !== this.trunkBase,\n\t\t\t\t\t\t\t\t0xa62 /* Serialized branch should not include the trunk base */,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tconst commit: Commit<TChangeset> = {\n\t\t\t\t\t\t\t\tchange: c.change,\n\t\t\t\t\t\t\t\trevision: c.revision,\n\t\t\t\t\t\t\t\tsessionId,\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\treturn commit;\n\t\t\t\t\t\t}),\n\t\t\t\t\t},\n\t\t\t\t];\n\t\t\t}),\n\t\t);\n\n\t\treturn { trunk, peerLocalBranches };\n\t}\n\n\tpublic loadSummaryData(data: SummaryData<TChangeset>): void {\n\t\tassert(\n\t\t\tthis.isEmpty(),\n\t\t\t0x68a /* Attempted to load from summary after edit manager was already mutated */,\n\t\t);\n\t\t// Record the tags of each trunk commit as we generate the trunk so they can be looked up quickly\n\t\t// when hydrating the peer branches below\n\t\tconst trunkRevisionCache = new Map<RevisionTag, GraphCommit<TChangeset>>();\n\t\ttrunkRevisionCache.set(this.trunkBase.revision, this.trunkBase);\n\t\tthis.trunk.setHead(\n\t\t\tdata.trunk.reduce((base, c) => {\n\t\t\t\tconst sequenceId: SequenceId =\n\t\t\t\t\tc.indexInBatch === undefined\n\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\tsequenceNumber: c.sequenceNumber,\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t: {\n\t\t\t\t\t\t\t\tsequenceNumber: c.sequenceNumber,\n\t\t\t\t\t\t\t\tindexInBatch: c.indexInBatch,\n\t\t\t\t\t\t\t};\n\t\t\t\tconst commit = mintCommit(base, c);\n\t\t\t\tthis.sequenceMap.set(sequenceId, commit);\n\t\t\t\tthis.trunkMetadata.set(c.revision, {\n\t\t\t\t\tsequenceId,\n\t\t\t\t\tsessionId: c.sessionId,\n\t\t\t\t});\n\t\t\t\ttrunkRevisionCache.set(c.revision, commit);\n\t\t\t\treturn commit;\n\t\t\t}, this.trunkBase),\n\t\t);\n\n\t\tthis.localBranch.setHead(this.trunk.getHead());\n\n\t\tfor (const [sessionId, branch] of data.peerLocalBranches) {\n\t\t\tconst commit =\n\t\t\t\ttrunkRevisionCache.get(branch.base) ??\n\t\t\t\tfail(0xad7 /* Expected summary branch to be based off of a revision in the trunk */);\n\n\t\t\tthis.peerLocalBranches.set(\n\t\t\t\tsessionId,\n\t\t\t\tnew SharedTreeBranch(\n\t\t\t\t\tbranch.commits.reduce(mintCommit, commit),\n\t\t\t\t\tthis.changeFamily,\n\t\t\t\t\tthis.mintRevisionTag,\n\t\t\t\t),\n\t\t\t);\n\t\t}\n\t}\n\n\tprivate getCommitSequenceId(trunkCommitOrTrunkBase: GraphCommit<TChangeset>): SequenceId {\n\t\tconst id = this.trunkMetadata.get(trunkCommitOrTrunkBase.revision)?.sequenceId;\n\t\tif (id === undefined) {\n\t\t\tassert(\n\t\t\t\ttrunkCommitOrTrunkBase === this.trunkBase,\n\t\t\t\t0xa63 /* Commit must be either be on the trunk or be the trunk base */,\n\t\t\t);\n\t\t\treturn minimumPossibleSequenceId;\n\t\t}\n\t\treturn id;\n\t}\n\n\tpublic getTrunkChanges(): readonly TChangeset[] {\n\t\treturn this.getTrunkCommits().map((c) => c.change);\n\t}\n\n\tpublic getTrunkCommits(): readonly GraphCommit<TChangeset>[] {\n\t\treturn getPathFromBase(this.trunk.getHead(), this.trunkBase);\n\t}\n\n\tpublic getTrunkHead(): GraphCommit<TChangeset> {\n\t\treturn this.trunk.getHead();\n\t}\n\n\tpublic getLocalChanges(): readonly TChangeset[] {\n\t\treturn this.getLocalCommits().map((c) => c.change);\n\t}\n\n\tpublic getLocalCommits(): readonly GraphCommit<TChangeset>[] {\n\t\treturn this.localCommits;\n\t}\n\n\t/**\n\t * @returns The length of the longest branch maintained by this EditManager.\n\t * This may be the length of a peer branch or the local branch.\n\t * The length is counted from the lowest common ancestor with the trunk such that a fully sequenced branch would\n\t * have length zero.\n\t */\n\tpublic getLongestBranchLength(): number {\n\t\tlet max = 0;\n\t\tconst trunkHead = this.trunk.getHead();\n\t\tfor (const branch of this.peerLocalBranches.values()) {\n\t\t\tconst branchPath = getPathFromBase(branch.getHead(), trunkHead);\n\t\t\tif (branchPath.length > max) {\n\t\t\t\tmax = branchPath.length;\n\t\t\t}\n\t\t}\n\t\tconst localPath = getPathFromBase(this.localBranch.getHead(), trunkHead);\n\t\treturn Math.max(max, localPath.length);\n\t}\n\n\t/* eslint-disable jsdoc/check-indentation */\n\t/**\n\t * Add a bunch of sequenced changes. A bunch is a group of sequenced commits that have the following properties:\n\t * - They are not interleaved with messages from other DDSes in the container.\n\t * - They are all part of the same batch, which entails:\n\t * - They are contiguous in sequencing order.\n\t * - They are all from the same client.\n\t * - They are all based on the same reference sequence number.\n\t * - They are not interleaved with messages from other clients.\n\t */\n\t/* eslint-enable jsdoc/check-indentation */\n\tpublic addSequencedChanges(\n\t\tnewCommits: readonly GraphCommit<TChangeset>[],\n\t\tsessionId: SessionId,\n\t\tsequenceNumber: SeqNumber,\n\t\treferenceSequenceNumber: SeqNumber,\n\t): void {\n\t\tassert(newCommits.length > 0, 0xad8 /* Expected at least one sequenced change */);\n\t\tassert(\n\t\t\tsequenceNumber > this.minimumSequenceNumber,\n\t\t\t0x713 /* Expected change sequence number to exceed the last known minimum sequence number */,\n\t\t);\n\t\tassert(\n\t\t\tsequenceNumber >= // This is \">=\", not \">\" because changes in the same batch will have the same sequence number\n\t\t\t\t(this.sequenceMap.maxKey()?.sequenceNumber ?? minimumPossibleSequenceNumber),\n\t\t\t0xa64 /* Attempted to sequence change with an outdated sequence number */,\n\t\t);\n\n\t\t// Returns the sequence id for the next commit to be processed in the bunch. Since all the commits have the\n\t\t// same sequence number, only the index in the batch needs to be incremented.\n\t\tconst getNextSequenceId = (sequenceId: SequenceId): SequenceId => {\n\t\t\treturn {\n\t\t\t\tsequenceNumber: sequenceId.sequenceNumber,\n\t\t\t\tindexInBatch: (sequenceId.indexInBatch ?? 0) + 1,\n\t\t\t};\n\t\t};\n\t\tconst commitsSequenceNumber = this.getBatch(sequenceNumber);\n\t\t// The sequence id for the next commit to be processed in the bunch.\n\t\tlet nextSequenceId =\n\t\t\tcommitsSequenceNumber.length === 0\n\t\t\t\t? {\n\t\t\t\t\t\tsequenceNumber,\n\t\t\t\t\t}\n\t\t\t\t: {\n\t\t\t\t\t\tsequenceNumber,\n\t\t\t\t\t\tindexInBatch: commitsSequenceNumber.length,\n\t\t\t\t\t};\n\n\t\t// Local changes, i.e., changes from this client are applied by fast forwarding the local branch commit onto\n\t\t// the trunk.\n\t\tif (sessionId === this.localSessionId) {\n\t\t\tfor (const _ of newCommits) {\n\t\t\t\tthis.fastForwardNextLocalCommit(nextSequenceId);\n\t\t\t\tnextSequenceId = getNextSequenceId(nextSequenceId);\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\n\t\t// Remote changes, i.e., changes from remote clients are applied in three steps.\n\t\t// Step 1 - Recreate the peer remote client's local environment.\n\t\t// Get the revision that the remote change is based on and rebase that peer local branch over the part of the\n\t\t// trunk up to the base revision. This will be a no-op if the sending client has not advanced since the last\n\t\t// time we received an edit from it\n\t\tconst [, baseRevisionInTrunk] = this.getClosestTrunkCommit(referenceSequenceNumber);\n\t\tconst peerLocalBranch = getOrCreate(\n\t\t\tthis.peerLocalBranches,\n\t\t\tsessionId,\n\t\t\t() => new SharedTreeBranch(baseRevisionInTrunk, this.changeFamily, this.mintRevisionTag),\n\t\t);\n\t\tpeerLocalBranch.rebaseOnto(this.trunk, baseRevisionInTrunk);\n\n\t\t// Step 2 - Append the changes to the peer branch and rebase the changes to the tip of the trunk.\n\t\tif (peerLocalBranch.getHead() === this.trunk.getHead()) {\n\t\t\t// If the peer local branch is fully caught up and empty (no changes relative to the trunk) after being\n\t\t\t// rebased, then push changes to the trunk directly and update the peer branch to the trunk's head.\n\t\t\tfor (const newCommit of newCommits) {\n\t\t\t\tthis.pushCommitToTrunk(nextSequenceId, { ...newCommit, sessionId });\n\t\t\t\tnextSequenceId = getNextSequenceId(nextSequenceId);\n\t\t\t}\n\t\t\tpeerLocalBranch.setHead(this.trunk.getHead());\n\t\t} else {\n\t\t\t// Otherwise, push the changes to the peer local branch and merge the branch into the trunk.\n\t\t\tfor (const newCommit of newCommits) {\n\t\t\t\tpeerLocalBranch.apply(tagChange(newCommit.change, newCommit.revision));\n\t\t\t}\n\t\t\tconst result = this.trunk.merge(peerLocalBranch);\n\t\t\tif (result !== undefined) {\n\t\t\t\t// If the merge resulted in any changes to the trunk, update the sequence map and trunk metadata\n\t\t\t\t// with the rebased commits.\n\t\t\t\tfor (const sourceCommit of result.sourceCommits) {\n\t\t\t\t\tthis.sequenceMap.set(nextSequenceId, sourceCommit);\n\t\t\t\t\tthis.trunkMetadata.set(sourceCommit.revision, {\n\t\t\t\t\t\tsequenceId: nextSequenceId,\n\t\t\t\t\t\tsessionId,\n\t\t\t\t\t});\n\t\t\t\t\tnextSequenceId = getNextSequenceId(nextSequenceId);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Step 3 - Rebase the local branch over the updated trunk.\n\t\tthis.localBranch.rebaseOnto(this.trunk);\n\t}\n\n\tpublic findLocalCommit(\n\t\trevision: RevisionTag,\n\t): [commit: GraphCommit<TChangeset>, commitsAfter: GraphCommit<TChangeset>[]] {\n\t\tconst commits: GraphCommit<TChangeset>[] = [];\n\t\tconst commit = findAncestor(\n\t\t\t[this.localBranch.getHead(), commits],\n\t\t\t(c) => c.revision === revision,\n\t\t);\n\t\tassert(commit !== undefined, 0x599 /* Expected local branch to contain revision */);\n\t\treturn [commit, commits];\n\t}\n\n\tprivate pushCommitToTrunk(sequenceId: SequenceId, commit: Commit<TChangeset>): void {\n\t\tconst mintedCommit = mintCommit(this.trunk.getHead(), commit);\n\t\tthis.pushGraphCommitToTrunk(sequenceId, mintedCommit, commit.sessionId);\n\t}\n\n\tprivate pushGraphCommitToTrunk(\n\t\tsequenceId: SequenceId,\n\t\tgraphCommit: GraphCommit<TChangeset>,\n\t\tsessionId: SessionId,\n\t): void {\n\t\tthis.trunk.setHead(graphCommit);\n\t\tconst trunkHead = this.trunk.getHead();\n\t\tthis.sequenceMap.set(sequenceId, trunkHead);\n\t\tthis.trunkMetadata.set(trunkHead.revision, { sequenceId, sessionId });\n\t}\n\n\t/**\n\t * Finds the most recent trunk commit that was sequenced at or before the given point.\n\t * @param searchBy - the sequence number or the sequence id to search for\n\t * @remarks Fails if there is no eligible commit.\n\t * @returns the closest commit and its sequence id\n\t */\n\tprivate getClosestTrunkCommit(searchBy: SeqNumber): [SequenceId, GraphCommit<TChangeset>];\n\tprivate getClosestTrunkCommit(searchBy: SequenceId): [SequenceId, GraphCommit<TChangeset>];\n\tprivate getClosestTrunkCommit(\n\t\tsearchBy: SeqNumber | SequenceId,\n\t): [SequenceId, GraphCommit<TChangeset>] {\n\t\tconst sequenceId: SequenceId =\n\t\t\ttypeof searchBy === \"number\"\n\t\t\t\t? {\n\t\t\t\t\t\t// This is to make sure that the correct commit is selected in this 2 scenarios:\n\t\t\t\t\t\t// 1) The commit is unique for that sequence number\n\t\t\t\t\t\t// 2) There are more than one commit for the same sequence number, in this case we need to select the last one.\n\t\t\t\t\t\tsequenceNumber: searchBy,\n\t\t\t\t\t\tindexInBatch: Number.POSITIVE_INFINITY,\n\t\t\t\t\t}\n\t\t\t\t: searchBy;\n\n\t\tconst commit = this.sequenceMap.getPairOrNextLower(sequenceId);\n\t\tassert(commit !== undefined, 0x746 /* sequence id has been evicted */);\n\t\treturn commit;\n\t}\n\n\tprivate getBatch(sequenceNumber: SeqNumber): [SequenceId, GraphCommit<TChangeset>][] {\n\t\tconst startSequenceId: SequenceId = {\n\t\t\tsequenceNumber,\n\t\t};\n\t\tconst endSequenceId: SequenceId = {\n\t\t\tsequenceNumber: brand((sequenceNumber as number) + 1),\n\t\t};\n\n\t\treturn this.sequenceMap.getRange(startSequenceId, endSequenceId, false);\n\t}\n}\n\n/**\n * The in-memory data that summaries contain\n */\nexport interface SummaryData<TChangeset> {\n\treadonly trunk: readonly SequencedCommit<TChangeset>[];\n\treadonly peerLocalBranches: ReadonlyMap<SessionId, SummarySessionBranch<TChangeset>>;\n}\n\n/**\n * @returns the path from the base of a branch to its head\n */\nfunction getPathFromBase<TCommit extends { parent?: TCommit }>(\n\tbranchHead: TCommit,\n\tbaseBranchHead: TCommit,\n): TCommit[] {\n\tconst path: TCommit[] = [];\n\tassert(\n\t\tfindCommonAncestor([branchHead, path], baseBranchHead) !== undefined,\n\t\t0x573 /* Expected branches to be related */,\n\t);\n\treturn path;\n}\n"]}
@@ -0,0 +1,18 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ import type { IChannelAttributes } from "@fluidframework/datastore-definitions/internal";
6
+ /**
7
+ * {@inheritDoc @fluidframework/shared-object-base#ISharedObjectFactory."type"}
8
+ * @alpha
9
+ * @legacy
10
+ */
11
+ export declare const SharedTreeFactoryType = "https://graph.microsoft.com/types/tree";
12
+ /**
13
+ * {@inheritDoc @fluidframework/shared-object-base#ISharedObjectFactory.attributes}
14
+ * @alpha
15
+ * @legacy
16
+ */
17
+ export declare const SharedTreeAttributes: IChannelAttributes;
18
+ //# sourceMappingURL=sharedTreeAttributes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sharedTreeAttributes.d.ts","sourceRoot":"","sources":["../src/sharedTreeAttributes.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gDAAgD,CAAC;AAGzF;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,2CAA2C,CAAC;AAE9E;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,EAAE,kBAIlC,CAAC"}
@@ -0,0 +1,22 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ import { pkgVersion } from "./packageVersion.js";
6
+ /**
7
+ * {@inheritDoc @fluidframework/shared-object-base#ISharedObjectFactory."type"}
8
+ * @alpha
9
+ * @legacy
10
+ */
11
+ export const SharedTreeFactoryType = "https://graph.microsoft.com/types/tree";
12
+ /**
13
+ * {@inheritDoc @fluidframework/shared-object-base#ISharedObjectFactory.attributes}
14
+ * @alpha
15
+ * @legacy
16
+ */
17
+ export const SharedTreeAttributes = {
18
+ type: SharedTreeFactoryType,
19
+ snapshotFormatVersion: "0.0.0",
20
+ packageVersion: pkgVersion,
21
+ };
22
+ //# sourceMappingURL=sharedTreeAttributes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sharedTreeAttributes.js","sourceRoot":"","sources":["../src/sharedTreeAttributes.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEjD;;;;GAIG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,wCAAwC,CAAC;AAE9E;;;;GAIG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAuB;IACvD,IAAI,EAAE,qBAAqB;IAC3B,qBAAqB,EAAE,OAAO;IAC9B,cAAc,EAAE,UAAU;CAC1B,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { IChannelAttributes } from \"@fluidframework/datastore-definitions/internal\";\nimport { pkgVersion } from \"./packageVersion.js\";\n\n/**\n * {@inheritDoc @fluidframework/shared-object-base#ISharedObjectFactory.\"type\"}\n * @alpha\n * @legacy\n */\nexport const SharedTreeFactoryType = \"https://graph.microsoft.com/types/tree\";\n\n/**\n * {@inheritDoc @fluidframework/shared-object-base#ISharedObjectFactory.attributes}\n * @alpha\n * @legacy\n */\nexport const SharedTreeAttributes: IChannelAttributes = {\n\ttype: SharedTreeFactoryType,\n\tsnapshotFormatVersion: \"0.0.0\",\n\tpackageVersion: pkgVersion,\n};\n"]}
@@ -3,9 +3,9 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
  import { isFluidHandle } from "@fluidframework/runtime-utils/internal";
6
- import { assert } from "@fluidframework/core-utils/internal";
6
+ import { assert, fail } from "@fluidframework/core-utils/internal";
7
7
  import { EmptyKey, forEachField, inCursorField, LeafNodeStoredSchema, mapCursorField, ObjectNodeStoredSchema, } from "../../core/index.js";
8
- import { fail, cloneWithReplacements } from "../../util/index.js";
8
+ import { cloneWithReplacements } from "../../util/index.js";
9
9
  import { NodeKind } from "../core/index.js";
10
10
  import { booleanSchema, handleSchema, nullSchema, numberSchema, stringSchema, } from "../leafNodeSchema.js";
11
11
  import { isObjectNodeSchema } from "../objectNodeTypes.js";
@@ -1 +1 @@
1
- {"version":3,"file":"customTree.js","sourceRoot":"","sources":["../../../src/simple-tree/api/customTree.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,aAAa,EAAE,MAAM,wCAAwC,CAAC;AACvE,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAE7D,OAAO,EACN,QAAQ,EACR,YAAY,EACZ,aAAa,EACb,oBAAoB,EACpB,cAAc,EACd,sBAAsB,GAKtB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,IAAI,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAElE,OAAO,EAAE,QAAQ,EAAuB,MAAM,kBAAkB,CAAC;AACjE,OAAO,EACN,aAAa,EACb,YAAY,EACZ,UAAU,EACV,YAAY,EACZ,YAAY,G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,CAAC,CAAC;QACpE,CAAC;IACF,CAAC,CAAC,CAAC;IACH,OAAO,MAAM,CAAC;AACf,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,sBAAsB,CACrC,MAA4B;IAE5B,IAAI,MAAM,YAAY,sBAAsB,EAAE,CAAC;QAC9C,MAAM,KAAK,GAAG,MAAM,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC;QAC9C,IAAI,KAAK,CAAC,IAAI,KAAK,UAAU,CAAC,QAAQ,CAAC,UAAU,EAAE,CAAC;YACnD,MAAM,CAAC,MAAM,CAAC,gBAAgB,CAAC,IAAI,KAAK,CAAC,EAAE,KAAK,CAAC,oBAAoB,CAAC,CAAC;YACvE,OAAO,KAAK,CAAC,KAAK,CAAC;QACpB,CAAC;IACF,CAAC;AACF,CAAC;AAED;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,cAAc,CAAI,IAAa,EAAE,QAA4B;IAC5E,OAAO,qBAAqB,CAAC,IAAI,EAAE,EAAE,EAAE,CAAC,GAAG,EAAE,KAAK,EAAE,EAAE;QACrD,kDAAkD;QAClD,IAAI,aAAa,CAAC,KAAK,CAAC,EAAE,CAAC;YAC1B,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;QACjD,CAAC;aAAM,CAAC;YACP,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;QAC/B,CAAC;IACF,CAAC,CAAC,CAAC;AACJ,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { IFluidHandle } from \"@fluidframework/core-interfaces\";\nimport { isFluidHandle } from \"@fluidframework/runtime-utils/internal\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\n\nimport {\n\tEmptyKey,\n\tforEachField,\n\tinCursorField,\n\tLeafNodeStoredSchema,\n\tmapCursorField,\n\tObjectNodeStoredSchema,\n\ttype FieldKey,\n\ttype ITreeCursor,\n\ttype TreeNodeSchemaIdentifier,\n\ttype TreeNodeStoredSchema,\n} from \"../../core/index.js\";\nimport { fail, cloneWithReplacements } from \"../../util/index.js\";\nimport type { TreeLeafValue } from \"../schemaTypes.js\";\nimport { NodeKind, type TreeNodeSchema } from \"../core/index.js\";\nimport {\n\tbooleanSchema,\n\thandleSchema,\n\tnullSchema,\n\tnumberSchema,\n\tstringSchema,\n} from \"../leafNodeSchema.js\";\nimport { isObjectNodeSchema } from \"../objectNodeTypes.js\";\nimport { FieldKinds, valueSchemaAllows } from \"../../feature-libraries/index.js\";\n\n/**\n * Options for how to encode a tree.\n * @alpha\n */\nexport interface EncodeOptions {\n\t/**\n\t * If true, interpret the input keys of object nodes as stored keys.\n\t * If false, interpret them as property keys.\n\t * @defaultValue false.\n\t */\n\treadonly useStoredKeys?: boolean;\n}\n\n/**\n * Options for how to transcode handles.\n * @remarks\n * Can be applied using {@link replaceHandles}.\n * @alpha\n */\nexport type HandleConverter<TCustom> = (data: IFluidHandle) => TCustom;\n\n/**\n * Options for how to interpret a `ConciseTree<TCustom>` without relying on schema.\n */\nexport interface SchemalessParseOptions {\n\t/**\n\t * Converts stored keys into whatever key the tree is using in its encoding.\n\t */\n\tkeyConverter?: {\n\t\tparse(type: string, inputKey: string): FieldKey;\n\t\tencode(type: string, key: FieldKey): string;\n\t};\n}\n\n/**\n * Tree representation with fields as properties and customized handle and child representations.\n */\nexport type CustomTree<TChild> = CustomTreeNode<TChild> | CustomTreeValue;\n\n/**\n * TreeLeafValue except the handle type is customized.\n */\nexport type CustomTreeValue = TreeLeafValue;\n\n/**\n * Tree node representation with fields as properties and customized child representation.\n */\nexport type CustomTreeNode<TChild> = TChild[] | { [key: string]: TChild };\n\n/**\n * Builds an {@link CustomTree} from a cursor in Nodes mode.\n */\nexport function customFromCursor<TChild>(\n\treader: ITreeCursor,\n\toptions: Required<EncodeOptions>,\n\tschema: ReadonlyMap<string, TreeNodeSchema>,\n\tchildHandler: (\n\t\treader: ITreeCursor,\n\t\toptions: Required<EncodeOptions>,\n\t\tschema: ReadonlyMap<string, TreeNodeSchema>,\n\t) => TChild,\n): CustomTree<TChild> {\n\tconst type = reader.type;\n\tconst nodeSchema = schema.get(type) ?? fail(0xb2e /* missing schema for type in cursor */);\n\n\tswitch (type) {\n\t\tcase numberSchema.identifier:\n\t\tcase booleanSchema.identifier:\n\t\tcase nullSchema.identifier:\n\t\tcase stringSchema.identifier:\n\t\t\tassert(reader.value !== undefined, 0xa50 /* out of schema: missing value */);\n\t\t\tassert(!isFluidHandle(reader.value), 0xa51 /* out of schema: unexpected FluidHandle */);\n\t\t\treturn reader.value;\n\t\tcase handleSchema.identifier:\n\t\t\tassert(reader.value !== undefined, 0xa52 /* out of schema: missing value */);\n\t\t\tassert(isFluidHandle(reader.value), 0xa53 /* out of schema: expected FluidHandle */);\n\t\t\treturn reader.value;\n\t\tdefault: {\n\t\t\tassert(reader.value === undefined, 0xa54 /* out of schema: unexpected value */);\n\t\t\tif (nodeSchema.kind === NodeKind.Array) {\n\t\t\t\tconst fields = inCursorField(reader, EmptyKey, () =>\n\t\t\t\t\tmapCursorField(reader, () => childHandler(reader, options, schema)),\n\t\t\t\t);\n\t\t\t\treturn fields;\n\t\t\t} else {\n\t\t\t\tconst fields: Record<string, TChild> = {};\n\t\t\t\tforEachField(reader, () => {\n\t\t\t\t\tconst children = mapCursorField(reader, () => childHandler(reader, options, schema));\n\t\t\t\t\tif (children.length === 1) {\n\t\t\t\t\t\tconst storedKey = reader.getFieldKey();\n\t\t\t\t\t\tconst key =\n\t\t\t\t\t\t\tisObjectNodeSchema(nodeSchema) && !options.useStoredKeys\n\t\t\t\t\t\t\t\t? (nodeSchema.storedKeyToPropertyKey.get(storedKey) ??\n\t\t\t\t\t\t\t\t\tfail(0xb2f /* missing property key */))\n\t\t\t\t\t\t\t\t: storedKey;\n\t\t\t\t\t\t// Length is checked above.\n\t\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t\t\t\tfields[key] = children[0]!;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tassert(children.length === 0, 0xa19 /* invalid children number */);\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t\treturn fields;\n\t\t\t}\n\t\t}\n\t}\n}\n\n/**\n * Builds an {@link CustomTree} from a cursor in Nodes mode.\n * @remarks\n * Uses stored keys and stored schema.\n */\nexport function customFromCursorStored<TChild>(\n\treader: ITreeCursor,\n\tschema: ReadonlyMap<TreeNodeSchemaIdentifier, TreeNodeStoredSchema>,\n\tchildHandler: (\n\t\treader: ITreeCursor,\n\t\tschema: ReadonlyMap<TreeNodeSchemaIdentifier, TreeNodeStoredSchema>,\n\t) => TChild,\n): CustomTree<TChild> {\n\tconst type = reader.type;\n\tconst nodeSchema = schema.get(type) ?? fail(0xb30 /* missing schema for type in cursor */);\n\n\tif (nodeSchema instanceof LeafNodeStoredSchema) {\n\t\tassert(valueSchemaAllows(nodeSchema.leafValue, reader.value), 0xa9c /* invalid value */);\n\t\treturn reader.value;\n\t}\n\n\tassert(reader.value === undefined, 0xa9d /* out of schema: unexpected value */);\n\n\tconst arrayTypes = tryStoredSchemaAsArray(nodeSchema);\n\tif (arrayTypes !== undefined) {\n\t\tconst field = inCursorField(reader, EmptyKey, () =>\n\t\t\tmapCursorField(reader, () => childHandler(reader, schema)),\n\t\t);\n\t\treturn field;\n\t}\n\n\tconst fields: Record<string, TChild> = {};\n\tforEachField(reader, () => {\n\t\tconst children = mapCursorField(reader, () => childHandler(reader, schema));\n\t\tif (children.length === 1) {\n\t\t\tconst storedKey = reader.getFieldKey();\n\t\t\t// Length is checked above.\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\tfields[storedKey] = children[0]!;\n\t\t} else {\n\t\t\tassert(children.length === 0, 0xa9e /* invalid children number */);\n\t\t}\n\t});\n\treturn fields;\n}\n\n/**\n * Assumes `schema` corresponds to a simple-tree schema.\n * If it is an array schema, returns the allowed types for the array field.\n * Otherwise returns `undefined`.\n */\nexport function tryStoredSchemaAsArray(\n\tschema: TreeNodeStoredSchema,\n): ReadonlySet<string> | undefined {\n\tif (schema instanceof ObjectNodeStoredSchema) {\n\t\tconst empty = schema.getFieldSchema(EmptyKey);\n\t\tif (empty.kind === FieldKinds.sequence.identifier) {\n\t\t\tassert(schema.objectNodeFields.size === 1, 0xa9f /* invalid schema */);\n\t\t\treturn empty.types;\n\t\t}\n\t}\n}\n\n/**\n * Clones tree, replacing any handles.\n * @remarks\n * This can be useful converting data containing handles to JSON compatible formats,\n * or just asserting that data does not contain handles.\n *\n * Reversing this replacement depends on how the replacer encodes handles, and can often be impossible if the replacer\n * does not have all the necessary context to restore the handles\n * (e.g. if the handles are something insufficiently descriptive,\n * if data referenced by the handle got garbage collected,\n * if the encoded form of the handle can't be differentiated from other data,\n * or the replacer doesn't have access to the correct Fluid container to to restore them from).\n *\n * Code attempting to reverse this replacement may want to use {@link cloneWithReplacements}.\n * @alpha\n */\nexport function replaceHandles<T>(tree: unknown, replacer: HandleConverter<T>): unknown {\n\treturn cloneWithReplacements(tree, \"\", (key, value) => {\n\t\t// eslint-disable-next-line unicorn/prefer-ternary\n\t\tif (isFluidHandle(value)) {\n\t\t\treturn { clone: false, value: replacer(value) };\n\t\t} else {\n\t\t\treturn { clone: true, value };\n\t\t}\n\t});\n}\n"]}
1
+ {"version":3,"file":"customTree.js","sourceRoot":"","sources":["../../../src/simple-tree/api/customTree.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,aAAa,EAAE,MAAM,wCAAwC,CAAC;AACvE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,qCAAqC,CAAC;AAEnE,OAAO,EACN,QAAQ,EACR,YAAY,EACZ,aAAa,EACb,oBAAoB,EACpB,cAAc,EACd,sBAAsB,GAKtB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CA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AAQ,CAAC,CAAC,CAAE,CAAC;QAClC,CAAC;aAAM,CAAC;YACP,MAAM,CAAC,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE,KAAK,CAAC,6BAA6B,CAAC,CAAC;QACpE,CAAC;IACF,CAAC,CAAC,CAAC;IACH,OAAO,MAAM,CAAC;AACf,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,sBAAsB,CACrC,MAA4B;IAE5B,IAAI,MAAM,YAAY,sBAAsB,EAAE,CAAC;QAC9C,MAAM,KAAK,GAAG,MAAM,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC;QAC9C,IAAI,KAAK,CAAC,IAAI,KAAK,UAAU,CAAC,QAAQ,CAAC,UAAU,EAAE,CAAC;YACnD,MAAM,CAAC,MAAM,CAAC,gBAAgB,CAAC,IAAI,KAAK,CAAC,EAAE,KAAK,CAAC,oBAAoB,CAAC,CAAC;YACvE,OAAO,KAAK,CAAC,KAAK,CAAC;QACpB,CAAC;IACF,CAAC;AACF,CAAC;AAED;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,cAAc,CAAI,IAAa,EAAE,QAA4B;IAC5E,OAAO,qBAAqB,CAAC,IAAI,EAAE,EAAE,EAAE,CAAC,GAAG,EAAE,KAAK,EAAE,EAAE;QACrD,kDAAkD;QAClD,IAAI,aAAa,CAAC,KAAK,CAAC,EAAE,CAAC;YAC1B,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;QACjD,CAAC;aAAM,CAAC;YACP,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;QAC/B,CAAC;IACF,CAAC,CAAC,CAAC;AACJ,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { IFluidHandle } from \"@fluidframework/core-interfaces\";\nimport { isFluidHandle } from \"@fluidframework/runtime-utils/internal\";\nimport { assert, fail } from \"@fluidframework/core-utils/internal\";\n\nimport {\n\tEmptyKey,\n\tforEachField,\n\tinCursorField,\n\tLeafNodeStoredSchema,\n\tmapCursorField,\n\tObjectNodeStoredSchema,\n\ttype FieldKey,\n\ttype ITreeCursor,\n\ttype TreeNodeSchemaIdentifier,\n\ttype TreeNodeStoredSchema,\n} from \"../../core/index.js\";\nimport { cloneWithReplacements } from \"../../util/index.js\";\nimport type { TreeLeafValue } from \"../schemaTypes.js\";\nimport { NodeKind, type TreeNodeSchema } from \"../core/index.js\";\nimport {\n\tbooleanSchema,\n\thandleSchema,\n\tnullSchema,\n\tnumberSchema,\n\tstringSchema,\n} from \"../leafNodeSchema.js\";\nimport { isObjectNodeSchema } from \"../objectNodeTypes.js\";\nimport { FieldKinds, valueSchemaAllows } from \"../../feature-libraries/index.js\";\n\n/**\n * Options for how to encode a tree.\n * @alpha\n */\nexport interface EncodeOptions {\n\t/**\n\t * If true, interpret the input keys of object nodes as stored keys.\n\t * If false, interpret them as property keys.\n\t * @defaultValue false.\n\t */\n\treadonly useStoredKeys?: boolean;\n}\n\n/**\n * Options for how to transcode handles.\n * @remarks\n * Can be applied using {@link replaceHandles}.\n * @alpha\n */\nexport type HandleConverter<TCustom> = (data: IFluidHandle) => TCustom;\n\n/**\n * Options for how to interpret a `ConciseTree<TCustom>` without relying on schema.\n */\nexport interface SchemalessParseOptions {\n\t/**\n\t * Converts stored keys into whatever key the tree is using in its encoding.\n\t */\n\tkeyConverter?: {\n\t\tparse(type: string, inputKey: string): FieldKey;\n\t\tencode(type: string, key: FieldKey): string;\n\t};\n}\n\n/**\n * Tree representation with fields as properties and customized handle and child representations.\n */\nexport type CustomTree<TChild> = CustomTreeNode<TChild> | CustomTreeValue;\n\n/**\n * TreeLeafValue except the handle type is customized.\n */\nexport type CustomTreeValue = TreeLeafValue;\n\n/**\n * Tree node representation with fields as properties and customized child representation.\n */\nexport type CustomTreeNode<TChild> = TChild[] | { [key: string]: TChild };\n\n/**\n * Builds an {@link CustomTree} from a cursor in Nodes mode.\n */\nexport function customFromCursor<TChild>(\n\treader: ITreeCursor,\n\toptions: Required<EncodeOptions>,\n\tschema: ReadonlyMap<string, TreeNodeSchema>,\n\tchildHandler: (\n\t\treader: ITreeCursor,\n\t\toptions: Required<EncodeOptions>,\n\t\tschema: ReadonlyMap<string, TreeNodeSchema>,\n\t) => TChild,\n): CustomTree<TChild> {\n\tconst type = reader.type;\n\tconst nodeSchema = schema.get(type) ?? fail(0xb2e /* missing schema for type in cursor */);\n\n\tswitch (type) {\n\t\tcase numberSchema.identifier:\n\t\tcase booleanSchema.identifier:\n\t\tcase nullSchema.identifier:\n\t\tcase stringSchema.identifier:\n\t\t\tassert(reader.value !== undefined, 0xa50 /* out of schema: missing value */);\n\t\t\tassert(!isFluidHandle(reader.value), 0xa51 /* out of schema: unexpected FluidHandle */);\n\t\t\treturn reader.value;\n\t\tcase handleSchema.identifier:\n\t\t\tassert(reader.value !== undefined, 0xa52 /* out of schema: missing value */);\n\t\t\tassert(isFluidHandle(reader.value), 0xa53 /* out of schema: expected FluidHandle */);\n\t\t\treturn reader.value;\n\t\tdefault: {\n\t\t\tassert(reader.value === undefined, 0xa54 /* out of schema: unexpected value */);\n\t\t\tif (nodeSchema.kind === NodeKind.Array) {\n\t\t\t\tconst fields = inCursorField(reader, EmptyKey, () =>\n\t\t\t\t\tmapCursorField(reader, () => childHandler(reader, options, schema)),\n\t\t\t\t);\n\t\t\t\treturn fields;\n\t\t\t} else {\n\t\t\t\tconst fields: Record<string, TChild> = {};\n\t\t\t\tforEachField(reader, () => {\n\t\t\t\t\tconst children = mapCursorField(reader, () => childHandler(reader, options, schema));\n\t\t\t\t\tif (children.length === 1) {\n\t\t\t\t\t\tconst storedKey = reader.getFieldKey();\n\t\t\t\t\t\tconst key =\n\t\t\t\t\t\t\tisObjectNodeSchema(nodeSchema) && !options.useStoredKeys\n\t\t\t\t\t\t\t\t? (nodeSchema.storedKeyToPropertyKey.get(storedKey) ??\n\t\t\t\t\t\t\t\t\tfail(0xb2f /* missing property key */))\n\t\t\t\t\t\t\t\t: storedKey;\n\t\t\t\t\t\t// Length is checked above.\n\t\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t\t\t\tfields[key] = children[0]!;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tassert(children.length === 0, 0xa19 /* invalid children number */);\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t\treturn fields;\n\t\t\t}\n\t\t}\n\t}\n}\n\n/**\n * Builds an {@link CustomTree} from a cursor in Nodes mode.\n * @remarks\n * Uses stored keys and stored schema.\n */\nexport function customFromCursorStored<TChild>(\n\treader: ITreeCursor,\n\tschema: ReadonlyMap<TreeNodeSchemaIdentifier, TreeNodeStoredSchema>,\n\tchildHandler: (\n\t\treader: ITreeCursor,\n\t\tschema: ReadonlyMap<TreeNodeSchemaIdentifier, TreeNodeStoredSchema>,\n\t) => TChild,\n): CustomTree<TChild> {\n\tconst type = reader.type;\n\tconst nodeSchema = schema.get(type) ?? fail(0xb30 /* missing schema for type in cursor */);\n\n\tif (nodeSchema instanceof LeafNodeStoredSchema) {\n\t\tassert(valueSchemaAllows(nodeSchema.leafValue, reader.value), 0xa9c /* invalid value */);\n\t\treturn reader.value;\n\t}\n\n\tassert(reader.value === undefined, 0xa9d /* out of schema: unexpected value */);\n\n\tconst arrayTypes = tryStoredSchemaAsArray(nodeSchema);\n\tif (arrayTypes !== undefined) {\n\t\tconst field = inCursorField(reader, EmptyKey, () =>\n\t\t\tmapCursorField(reader, () => childHandler(reader, schema)),\n\t\t);\n\t\treturn field;\n\t}\n\n\tconst fields: Record<string, TChild> = {};\n\tforEachField(reader, () => {\n\t\tconst children = mapCursorField(reader, () => childHandler(reader, schema));\n\t\tif (children.length === 1) {\n\t\t\tconst storedKey = reader.getFieldKey();\n\t\t\t// Length is checked above.\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\tfields[storedKey] = children[0]!;\n\t\t} else {\n\t\t\tassert(children.length === 0, 0xa9e /* invalid children number */);\n\t\t}\n\t});\n\treturn fields;\n}\n\n/**\n * Assumes `schema` corresponds to a simple-tree schema.\n * If it is an array schema, returns the allowed types for the array field.\n * Otherwise returns `undefined`.\n */\nexport function tryStoredSchemaAsArray(\n\tschema: TreeNodeStoredSchema,\n): ReadonlySet<string> | undefined {\n\tif (schema instanceof ObjectNodeStoredSchema) {\n\t\tconst empty = schema.getFieldSchema(EmptyKey);\n\t\tif (empty.kind === FieldKinds.sequence.identifier) {\n\t\t\tassert(schema.objectNodeFields.size === 1, 0xa9f /* invalid schema */);\n\t\t\treturn empty.types;\n\t\t}\n\t}\n}\n\n/**\n * Clones tree, replacing any handles.\n * @remarks\n * This can be useful converting data containing handles to JSON compatible formats,\n * or just asserting that data does not contain handles.\n *\n * Reversing this replacement depends on how the replacer encodes handles, and can often be impossible if the replacer\n * does not have all the necessary context to restore the handles\n * (e.g. if the handles are something insufficiently descriptive,\n * if data referenced by the handle got garbage collected,\n * if the encoded form of the handle can't be differentiated from other data,\n * or the replacer doesn't have access to the correct Fluid container to to restore them from).\n *\n * Code attempting to reverse this replacement may want to use {@link cloneWithReplacements}.\n * @alpha\n */\nexport function replaceHandles<T>(tree: unknown, replacer: HandleConverter<T>): unknown {\n\treturn cloneWithReplacements(tree, \"\", (key, value) => {\n\t\t// eslint-disable-next-line unicorn/prefer-ternary\n\t\tif (isFluidHandle(value)) {\n\t\t\treturn { clone: false, value: replacer(value) };\n\t\t} else {\n\t\t\treturn { clone: true, value };\n\t\t}\n\t});\n}\n"]}
@@ -49,6 +49,16 @@ import type { ImplicitFieldSchema } from "../schemaTypes.js";
49
49
  * @privateRemarks In the future, we may wish to move this to a more discoverable API location.
50
50
  * For now, while still an experimental API, it is surfaced as a free function.
51
51
  *
52
+ * TODO:
53
+ * This API should allow generating JSON schema for the whole matrix of combinations:
54
+ *
55
+ * 1. VerboseTree and ConciseTree
56
+ * 2. With and without requiring values with defaults (for insertion vs reading)
57
+ * 3. Using stored keys and property keys
58
+ *
59
+ * This current API seems to give ConciseTree with property keys and ignoring default values.
60
+ *
61
+ *
52
62
  * @alpha
53
63
  */
54
64
  export declare function getJsonSchema(schema: ImplicitFieldSchema): JsonTreeSchema;
@@ -1 +1 @@
1
- {"version":3,"file":"getJsonSchema.d.ts","sourceRoot":"","sources":["../../../src/simple-tree/api/getJsonSchema.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAW7D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8CG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,mBAAmB,GAAG,cAAc,CAKzE"}
1
+ {"version":3,"file":"getJsonSchema.d.ts","sourceRoot":"","sources":["../../../src/simple-tree/api/getJsonSchema.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAW7D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwDG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,mBAAmB,GAAG,cAAc,CAKzE"}
@@ -54,6 +54,16 @@ const jsonSchemaCache = new WeakMap();
54
54
  * @privateRemarks In the future, we may wish to move this to a more discoverable API location.
55
55
  * For now, while still an experimental API, it is surfaced as a free function.
56
56
  *
57
+ * TODO:
58
+ * This API should allow generating JSON schema for the whole matrix of combinations:
59
+ *
60
+ * 1. VerboseTree and ConciseTree
61
+ * 2. With and without requiring values with defaults (for insertion vs reading)
62
+ * 3. Using stored keys and property keys
63
+ *
64
+ * This current API seems to give ConciseTree with property keys and ignoring default values.
65
+ *
66
+ *
57
67
  * @alpha
58
68
  */
59
69
  export function getJsonSchema(schema) {
@@ -1 +1 @@
1
- {"version":3,"file":"getJsonSchema.js","sourceRoot":"","sources":["../../../src/simple-tree/api/getJsonSchema.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAC7D,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAGlD;;GAEG;AACH,MAAM,eAAe,GAAG,IAAI,OAAO,EAAkC,CAAC;AAEtE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8CG;AACH,MAAM,UAAU,aAAa,CAAC,MAA2B;IACxD,OAAO,WAAW,CAAC,eAAe,EAAE,MAAM,EAAE,GAAG,EAAE;QAChD,MAAM,YAAY,GAAG,eAAe,CAAC,MAAM,CAAC,CAAC;QAC7C,OAAO,YAAY,CAAC,YAAY,CAAC,CAAC;IACnC,CAAC,CAAC,CAAC;AACJ,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { JsonTreeSchema } from \"./jsonSchema.js\";\nimport type { ImplicitFieldSchema } from \"../schemaTypes.js\";\nimport { toJsonSchema } from \"./simpleSchemaToJsonSchema.js\";\nimport { getSimpleSchema } from \"./getSimpleSchema.js\";\nimport { getOrCreate } from \"../../util/index.js\";\nimport type { TreeNodeSchema } from \"../core/index.js\";\n\n/**\n * Cache in which the results of {@link getJsonSchema} are saved.\n */\nconst jsonSchemaCache = new WeakMap<TreeNodeSchema, JsonTreeSchema>();\n\n/**\n * Creates a {@link https://json-schema.org/ | JSON Schema} representation of the provided {@link TreeNodeSchema}.\n *\n * @remarks\n * Useful when communicating the schema to external libraries or services.\n * Caches the result for future calls.\n *\n * @example\n *\n * A Shared Tree schema like the following:\n *\n * ```typescript\n * class MyObject extends schemaFactory.object(\"MyObject\", {\n * \tfoo: schemaFactory.number,\n * \tbar: schemaFactory.optional(schemaFactory.string),\n * });\n * ```\n *\n * Will yield JSON Schema like the following:\n *\n * ```json\n * {\n * \t\"$defs\": {\n * \t\t\"com.fluidframework.leaf.string\": {\n * \t\t\t\"type\": \"string\",\n * \t\t},\n * \t\t\"com.fluidframework.leaf.number\": {\n * \t\t\t\"type\": \"number\",\n * \t\t},\n * \t\t\"com.myapp.MyObject\": {\n * \t\t\t\"type\": \"object\",\n * \t\t\t\"properties\": {\n * \t\t\t\t\"foo\": { \"$ref\": \"com.fluidframework.leaf.number\" },\n * \t\t\t\t\"bar\": { \"$ref\": \"com.fluidframework.leaf.string\" },\n * \t\t\t},\n * \t\t\t\"required\": [\"foo\"],\n * \t\t},\n * \t},\n * \t\"$ref\": \"#/$defs/com.myapp.MyObject\",\n * }\n * ```\n *\n * @privateRemarks In the future, we may wish to move this to a more discoverable API location.\n * For now, while still an experimental API, it is surfaced as a free function.\n *\n * @alpha\n */\nexport function getJsonSchema(schema: ImplicitFieldSchema): JsonTreeSchema {\n\treturn getOrCreate(jsonSchemaCache, schema, () => {\n\t\tconst simpleSchema = getSimpleSchema(schema);\n\t\treturn toJsonSchema(simpleSchema);\n\t});\n}\n"]}
1
+ {"version":3,"file":"getJsonSchema.js","sourceRoot":"","sources":["../../../src/simple-tree/api/getJsonSchema.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAC7D,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAGlD;;GAEG;AACH,MAAM,eAAe,GAAG,IAAI,OAAO,EAAkC,CAAC;AAEtE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwDG;AACH,MAAM,UAAU,aAAa,CAAC,MAA2B;IACxD,OAAO,WAAW,CAAC,eAAe,EAAE,MAAM,EAAE,GAAG,EAAE;QAChD,MAAM,YAAY,GAAG,eAAe,CAAC,MAAM,CAAC,CAAC;QAC7C,OAAO,YAAY,CAAC,YAAY,CAAC,CAAC;IACnC,CAAC,CAAC,CAAC;AACJ,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { JsonTreeSchema } from \"./jsonSchema.js\";\nimport type { ImplicitFieldSchema } from \"../schemaTypes.js\";\nimport { toJsonSchema } from \"./simpleSchemaToJsonSchema.js\";\nimport { getSimpleSchema } from \"./getSimpleSchema.js\";\nimport { getOrCreate } from \"../../util/index.js\";\nimport type { TreeNodeSchema } from \"../core/index.js\";\n\n/**\n * Cache in which the results of {@link getJsonSchema} are saved.\n */\nconst jsonSchemaCache = new WeakMap<TreeNodeSchema, JsonTreeSchema>();\n\n/**\n * Creates a {@link https://json-schema.org/ | JSON Schema} representation of the provided {@link TreeNodeSchema}.\n *\n * @remarks\n * Useful when communicating the schema to external libraries or services.\n * Caches the result for future calls.\n *\n * @example\n *\n * A Shared Tree schema like the following:\n *\n * ```typescript\n * class MyObject extends schemaFactory.object(\"MyObject\", {\n * \tfoo: schemaFactory.number,\n * \tbar: schemaFactory.optional(schemaFactory.string),\n * });\n * ```\n *\n * Will yield JSON Schema like the following:\n *\n * ```json\n * {\n * \t\"$defs\": {\n * \t\t\"com.fluidframework.leaf.string\": {\n * \t\t\t\"type\": \"string\",\n * \t\t},\n * \t\t\"com.fluidframework.leaf.number\": {\n * \t\t\t\"type\": \"number\",\n * \t\t},\n * \t\t\"com.myapp.MyObject\": {\n * \t\t\t\"type\": \"object\",\n * \t\t\t\"properties\": {\n * \t\t\t\t\"foo\": { \"$ref\": \"com.fluidframework.leaf.number\" },\n * \t\t\t\t\"bar\": { \"$ref\": \"com.fluidframework.leaf.string\" },\n * \t\t\t},\n * \t\t\t\"required\": [\"foo\"],\n * \t\t},\n * \t},\n * \t\"$ref\": \"#/$defs/com.myapp.MyObject\",\n * }\n * ```\n *\n * @privateRemarks In the future, we may wish to move this to a more discoverable API location.\n * For now, while still an experimental API, it is surfaced as a free function.\n *\n * TODO:\n * This API should allow generating JSON schema for the whole matrix of combinations:\n *\n * 1. VerboseTree and ConciseTree\n * 2. With and without requiring values with defaults (for insertion vs reading)\n * 3. Using stored keys and property keys\n *\n * This current API seems to give ConciseTree with property keys and ignoring default values.\n *\n *\n * @alpha\n */\nexport function getJsonSchema(schema: ImplicitFieldSchema): JsonTreeSchema {\n\treturn getOrCreate(jsonSchemaCache, schema, () => {\n\t\tconst simpleSchema = getSimpleSchema(schema);\n\t\treturn toJsonSchema(simpleSchema);\n\t});\n}\n"]}
@@ -3,56 +3,26 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
  import type { ImplicitFieldSchema } from "../schemaTypes.js";
6
- import type { SimpleTreeSchema } from "./simpleSchema.js";
6
+ import type { SimpleTreeSchema } from "../simpleSchema.js";
7
7
  /**
8
- * Creates a simplified representation of the provided {@link TreeNodeSchema}.
8
+ * Creates a {@link SimpleTreeSchema} from the provided {@link ImplicitFieldSchema}.
9
9
  *
10
- * @remarks Caches the result on the input schema for future calls.
10
+ * @remarks
11
+ * This provides easy access by identifier to any schema transitively referenced by the input schema via {@link SimpleTreeSchema.definitions}.
11
12
  *
12
- * @example
13
+ * Caches the result on the input schema for future calls.
13
14
  *
14
- * A Shared Tree schema like the following:
15
- *
16
- * ```typescript
17
- * class MyObject extends schemaFactory.object("MyObject", {
18
- * foo: schemaFactory.number,
19
- * bar: schemaFactory.optional(schemaFactory.string),
20
- * });
21
- * ```
15
+ * @privateRemarks
16
+ * In the future, we may wish to move this to a more discoverable API location.
17
+ * For now, while still an experimental API, it is surfaced as a free function.
22
18
  *
23
- * Will yield JSON Schema like the following:
19
+ * If the main use for this is the "definitions" map, we should provide a better way to access it (that doesn't type erase the TreeNodeSchema down to SimpleNodeSchema).
20
+ * TODO: Having TreeViewConfiguration implement SimpleTreeSchema directly but with more specific types would be a good way to do this.
24
21
  *
25
- * ```typescript
26
- * {
27
- * definitions: [
28
- * ["com.fluidframework.leaf.number", {
29
- * kind: "leaf",
30
- * type: "number",
31
- * }],
32
- * ["com.fluidframework.leaf.string", {
33
- * kind: "leaf",
34
- * type: "string",
35
- * }],
36
- * ["com.myapp.MyObject", {
37
- * kind: "object",
38
- * fields: {
39
- * foo: {
40
- * kind: "required",
41
- * allowedTypes: ["com.fluidframework.leaf.number"]
42
- * },
43
- * bar: {
44
- * kind: "optional",
45
- * allowedTypes: ["com.fluidframework.leaf.string"]
46
- * },
47
- * },
48
- * }],
49
- * ],
50
- * allowedTypes: ["com.myapp.MyObject"],
51
- * }
52
- * ```
22
+ * Note that all TreeNodeSchema get a {@link Context} cached on them as part of one time initialization which contains a map from identifier to all transitively referenced schema.
23
+ * Perhaps exposing access to that would cover this use-case as well.
53
24
  *
54
- * @privateRemarks In the future, we may wish to move this to a more discoverable API location.
55
- * For now, while still an experimental API, it is surfaced as a free function.
25
+ * TODO: does having this caching layer add value? Maybe this wrapper around toSimpleTreeSchema should be removed.
56
26
  *
57
27
  * @internal
58
28
  */
@@ -1 +1 @@
1
- {"version":3,"file":"getSimpleSchema.d.ts","sourceRoot":"","sources":["../../../src/simple-tree/api/getSimpleSchema.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAC7D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAQ1D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmDG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,mBAAmB,GAAG,gBAAgB,CAE7E"}
1
+ {"version":3,"file":"getSimpleSchema.d.ts","sourceRoot":"","sources":["../../../src/simple-tree/api/getSimpleSchema.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAC7D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAQ3D;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,mBAAmB,GAAG,gBAAgB,CAE7E"}
@@ -9,58 +9,28 @@ import { toSimpleTreeSchema } from "./viewSchemaToSimpleSchema.js";
9
9
  */
10
10
  const simpleSchemaCache = new WeakMap();
11
11
  /**
12
- * Creates a simplified representation of the provided {@link TreeNodeSchema}.
12
+ * Creates a {@link SimpleTreeSchema} from the provided {@link ImplicitFieldSchema}.
13
13
  *
14
- * @remarks Caches the result on the input schema for future calls.
14
+ * @remarks
15
+ * This provides easy access by identifier to any schema transitively referenced by the input schema via {@link SimpleTreeSchema.definitions}.
15
16
  *
16
- * @example
17
+ * Caches the result on the input schema for future calls.
17
18
  *
18
- * A Shared Tree schema like the following:
19
- *
20
- * ```typescript
21
- * class MyObject extends schemaFactory.object("MyObject", {
22
- * foo: schemaFactory.number,
23
- * bar: schemaFactory.optional(schemaFactory.string),
24
- * });
25
- * ```
19
+ * @privateRemarks
20
+ * In the future, we may wish to move this to a more discoverable API location.
21
+ * For now, while still an experimental API, it is surfaced as a free function.
26
22
  *
27
- * Will yield JSON Schema like the following:
23
+ * If the main use for this is the "definitions" map, we should provide a better way to access it (that doesn't type erase the TreeNodeSchema down to SimpleNodeSchema).
24
+ * TODO: Having TreeViewConfiguration implement SimpleTreeSchema directly but with more specific types would be a good way to do this.
28
25
  *
29
- * ```typescript
30
- * {
31
- * definitions: [
32
- * ["com.fluidframework.leaf.number", {
33
- * kind: "leaf",
34
- * type: "number",
35
- * }],
36
- * ["com.fluidframework.leaf.string", {
37
- * kind: "leaf",
38
- * type: "string",
39
- * }],
40
- * ["com.myapp.MyObject", {
41
- * kind: "object",
42
- * fields: {
43
- * foo: {
44
- * kind: "required",
45
- * allowedTypes: ["com.fluidframework.leaf.number"]
46
- * },
47
- * bar: {
48
- * kind: "optional",
49
- * allowedTypes: ["com.fluidframework.leaf.string"]
50
- * },
51
- * },
52
- * }],
53
- * ],
54
- * allowedTypes: ["com.myapp.MyObject"],
55
- * }
56
- * ```
26
+ * Note that all TreeNodeSchema get a {@link Context} cached on them as part of one time initialization which contains a map from identifier to all transitively referenced schema.
27
+ * Perhaps exposing access to that would cover this use-case as well.
57
28
  *
58
- * @privateRemarks In the future, we may wish to move this to a more discoverable API location.
59
- * For now, while still an experimental API, it is surfaced as a free function.
29
+ * TODO: does having this caching layer add value? Maybe this wrapper around toSimpleTreeSchema should be removed.
60
30
  *
61
31
  * @internal
62
32
  */
63
33
  export function getSimpleSchema(schema) {
64
- return getOrCreate(simpleSchemaCache, schema, () => toSimpleTreeSchema(schema));
34
+ return getOrCreate(simpleSchemaCache, schema, () => toSimpleTreeSchema(schema, false));
65
35
  }
66
36
  //# sourceMappingURL=getSimpleSchema.js.map