@fluidframework/tree 2.61.0 → 2.62.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 (388) hide show
  1. package/CHANGELOG.md +162 -0
  2. package/api-report/tree.alpha.api.md +26 -21
  3. package/api-report/tree.beta.api.md +15 -0
  4. package/api-report/tree.legacy.beta.api.md +18 -0
  5. package/dist/alpha.d.ts +8 -8
  6. package/dist/api.d.ts +17 -0
  7. package/dist/api.d.ts.map +1 -0
  8. package/dist/api.js +24 -0
  9. package/dist/api.js.map +1 -0
  10. package/dist/beta.d.ts +5 -0
  11. package/dist/codec/codec.d.ts +3 -5
  12. package/dist/codec/codec.d.ts.map +1 -1
  13. package/dist/codec/codec.js +9 -2
  14. package/dist/codec/codec.js.map +1 -1
  15. package/dist/codec/index.d.ts +0 -1
  16. package/dist/codec/index.d.ts.map +1 -1
  17. package/dist/codec/index.js +1 -3
  18. package/dist/codec/index.js.map +1 -1
  19. package/dist/core/index.d.ts +1 -1
  20. package/dist/core/index.d.ts.map +1 -1
  21. package/dist/core/index.js +2 -1
  22. package/dist/core/index.js.map +1 -1
  23. package/dist/core/rebase/index.d.ts +1 -1
  24. package/dist/core/rebase/index.d.ts.map +1 -1
  25. package/dist/core/rebase/index.js +2 -1
  26. package/dist/core/rebase/index.js.map +1 -1
  27. package/dist/core/rebase/utils.d.ts +10 -0
  28. package/dist/core/rebase/utils.d.ts.map +1 -1
  29. package/dist/core/rebase/utils.js +20 -1
  30. package/dist/core/rebase/utils.js.map +1 -1
  31. package/dist/core/tree/detachedFieldIndex.js +1 -1
  32. package/dist/core/tree/detachedFieldIndex.js.map +1 -1
  33. package/dist/external-utilities/index.d.ts +1 -1
  34. package/dist/external-utilities/index.d.ts.map +1 -1
  35. package/dist/external-utilities/index.js +1 -2
  36. package/dist/external-utilities/index.js.map +1 -1
  37. package/dist/external-utilities/typeboxValidator.d.ts +0 -13
  38. package/dist/external-utilities/typeboxValidator.d.ts.map +1 -1
  39. package/dist/external-utilities/typeboxValidator.js +3 -5
  40. package/dist/external-utilities/typeboxValidator.js.map +1 -1
  41. package/dist/feature-libraries/flex-tree/flexTreeTypes.d.ts +2 -0
  42. package/dist/feature-libraries/flex-tree/flexTreeTypes.d.ts.map +1 -1
  43. package/dist/feature-libraries/flex-tree/flexTreeTypes.js.map +1 -1
  44. package/dist/feature-libraries/flex-tree/index.d.ts +1 -0
  45. package/dist/feature-libraries/flex-tree/index.d.ts.map +1 -1
  46. package/dist/feature-libraries/flex-tree/index.js +4 -1
  47. package/dist/feature-libraries/flex-tree/index.js.map +1 -1
  48. package/dist/feature-libraries/flex-tree/lazyNode.d.ts.map +1 -1
  49. package/dist/feature-libraries/flex-tree/lazyNode.js +15 -8
  50. package/dist/feature-libraries/flex-tree/lazyNode.js.map +1 -1
  51. package/dist/feature-libraries/flex-tree/observer.d.ts +32 -0
  52. package/dist/feature-libraries/flex-tree/observer.d.ts.map +1 -0
  53. package/dist/feature-libraries/flex-tree/observer.js +33 -0
  54. package/dist/feature-libraries/flex-tree/observer.js.map +1 -0
  55. package/dist/feature-libraries/index.d.ts +1 -1
  56. package/dist/feature-libraries/index.d.ts.map +1 -1
  57. package/dist/feature-libraries/index.js +3 -1
  58. package/dist/feature-libraries/index.js.map +1 -1
  59. package/dist/index.d.ts +5 -5
  60. package/dist/index.d.ts.map +1 -1
  61. package/dist/index.js +9 -8
  62. package/dist/index.js.map +1 -1
  63. package/dist/legacy.d.ts +7 -1
  64. package/dist/packageVersion.d.ts +1 -1
  65. package/dist/packageVersion.js +1 -1
  66. package/dist/packageVersion.js.map +1 -1
  67. package/dist/shared-tree/index.d.ts +2 -2
  68. package/dist/shared-tree/index.d.ts.map +1 -1
  69. package/dist/shared-tree/index.js.map +1 -1
  70. package/dist/shared-tree/schematizingTreeView.js +2 -2
  71. package/dist/shared-tree/schematizingTreeView.js.map +1 -1
  72. package/dist/shared-tree/sharedTree.d.ts +21 -6
  73. package/dist/shared-tree/sharedTree.d.ts.map +1 -1
  74. package/dist/shared-tree/sharedTree.js +76 -37
  75. package/dist/shared-tree/sharedTree.js.map +1 -1
  76. package/dist/shared-tree/treeAlpha.d.ts +114 -1
  77. package/dist/shared-tree/treeAlpha.d.ts.map +1 -1
  78. package/dist/shared-tree/treeAlpha.js +140 -1
  79. package/dist/shared-tree/treeAlpha.js.map +1 -1
  80. package/dist/shared-tree/treeCheckout.d.ts +13 -7
  81. package/dist/shared-tree/treeCheckout.d.ts.map +1 -1
  82. package/dist/shared-tree/treeCheckout.js +115 -85
  83. package/dist/shared-tree/treeCheckout.js.map +1 -1
  84. package/dist/shared-tree-core/branch.d.ts +3 -0
  85. package/dist/shared-tree-core/branch.d.ts.map +1 -1
  86. package/dist/shared-tree-core/branch.js.map +1 -1
  87. package/dist/shared-tree-core/branchIdCodec.d.ts +11 -0
  88. package/dist/shared-tree-core/branchIdCodec.d.ts.map +1 -0
  89. package/dist/shared-tree-core/branchIdCodec.js +18 -0
  90. package/dist/shared-tree-core/branchIdCodec.js.map +1 -0
  91. package/dist/shared-tree-core/editManager.d.ts +39 -64
  92. package/dist/shared-tree-core/editManager.d.ts.map +1 -1
  93. package/dist/shared-tree-core/editManager.js +455 -295
  94. package/dist/shared-tree-core/editManager.js.map +1 -1
  95. package/dist/shared-tree-core/editManagerCodecs.d.ts +1 -1
  96. package/dist/shared-tree-core/editManagerCodecs.d.ts.map +1 -1
  97. package/dist/shared-tree-core/editManagerCodecs.js +7 -96
  98. package/dist/shared-tree-core/editManagerCodecs.js.map +1 -1
  99. package/dist/shared-tree-core/editManagerCodecsCommons.d.ts +17 -0
  100. package/dist/shared-tree-core/editManagerCodecsCommons.d.ts.map +1 -0
  101. package/dist/shared-tree-core/editManagerCodecsCommons.js +139 -0
  102. package/dist/shared-tree-core/editManagerCodecsCommons.js.map +1 -0
  103. package/dist/shared-tree-core/editManagerCodecsV1toV4.d.ts +16 -0
  104. package/dist/shared-tree-core/editManagerCodecsV1toV4.d.ts.map +1 -0
  105. package/dist/shared-tree-core/editManagerCodecsV1toV4.js +39 -0
  106. package/dist/shared-tree-core/editManagerCodecsV1toV4.js.map +1 -0
  107. package/dist/shared-tree-core/editManagerCodecsV5.d.ts +16 -0
  108. package/dist/shared-tree-core/editManagerCodecsV5.d.ts.map +1 -0
  109. package/dist/shared-tree-core/editManagerCodecsV5.js +58 -0
  110. package/dist/shared-tree-core/editManagerCodecsV5.js.map +1 -0
  111. package/dist/shared-tree-core/{editManagerFormat.d.ts → editManagerFormatCommons.d.ts} +31 -7
  112. package/dist/shared-tree-core/editManagerFormatCommons.d.ts.map +1 -0
  113. package/dist/shared-tree-core/{editManagerFormat.js → editManagerFormatCommons.js} +13 -12
  114. package/dist/shared-tree-core/editManagerFormatCommons.js.map +1 -0
  115. package/dist/shared-tree-core/editManagerFormatV1toV4.d.ts +31 -0
  116. package/dist/shared-tree-core/editManagerFormatV1toV4.d.ts.map +1 -0
  117. package/dist/shared-tree-core/editManagerFormatV1toV4.js +24 -0
  118. package/dist/shared-tree-core/editManagerFormatV1toV4.js.map +1 -0
  119. package/dist/shared-tree-core/editManagerFormatV5.d.ts +62 -0
  120. package/dist/shared-tree-core/editManagerFormatV5.d.ts.map +1 -0
  121. package/dist/shared-tree-core/editManagerFormatV5.js +20 -0
  122. package/dist/shared-tree-core/editManagerFormatV5.js.map +1 -0
  123. package/dist/shared-tree-core/index.d.ts +3 -3
  124. package/dist/shared-tree-core/index.d.ts.map +1 -1
  125. package/dist/shared-tree-core/index.js.map +1 -1
  126. package/dist/shared-tree-core/messageCodecV1ToV4.d.ts +11 -0
  127. package/dist/shared-tree-core/messageCodecV1ToV4.d.ts.map +1 -0
  128. package/dist/shared-tree-core/messageCodecV1ToV4.js +59 -0
  129. package/dist/shared-tree-core/messageCodecV1ToV4.js.map +1 -0
  130. package/dist/shared-tree-core/messageCodecV5.d.ts +11 -0
  131. package/dist/shared-tree-core/messageCodecV5.d.ts.map +1 -0
  132. package/dist/shared-tree-core/messageCodecV5.js +78 -0
  133. package/dist/shared-tree-core/messageCodecV5.js.map +1 -0
  134. package/dist/shared-tree-core/messageCodecs.d.ts.map +1 -1
  135. package/dist/shared-tree-core/messageCodecs.js +16 -47
  136. package/dist/shared-tree-core/messageCodecs.js.map +1 -1
  137. package/dist/shared-tree-core/{messageFormat.d.ts → messageFormatV1ToV4.d.ts} +1 -1
  138. package/dist/shared-tree-core/messageFormatV1ToV4.d.ts.map +1 -0
  139. package/dist/shared-tree-core/{messageFormat.js → messageFormatV1ToV4.js} +1 -1
  140. package/dist/shared-tree-core/messageFormatV1ToV4.js.map +1 -0
  141. package/dist/shared-tree-core/messageFormatV5.d.ts +42 -0
  142. package/dist/shared-tree-core/messageFormatV5.d.ts.map +1 -0
  143. package/dist/shared-tree-core/messageFormatV5.js +20 -0
  144. package/dist/shared-tree-core/messageFormatV5.js.map +1 -0
  145. package/dist/shared-tree-core/messageTypes.d.ts +12 -2
  146. package/dist/shared-tree-core/messageTypes.d.ts.map +1 -1
  147. package/dist/shared-tree-core/messageTypes.js.map +1 -1
  148. package/dist/shared-tree-core/sequenceIdUtils.d.ts +1 -1
  149. package/dist/shared-tree-core/sequenceIdUtils.d.ts.map +1 -1
  150. package/dist/shared-tree-core/sequenceIdUtils.js.map +1 -1
  151. package/dist/shared-tree-core/sharedTreeCore.d.ts +19 -5
  152. package/dist/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
  153. package/dist/shared-tree-core/sharedTreeCore.js +182 -58
  154. package/dist/shared-tree-core/sharedTreeCore.js.map +1 -1
  155. package/dist/simple-tree/api/tree.d.ts +17 -0
  156. package/dist/simple-tree/api/tree.d.ts.map +1 -1
  157. package/dist/simple-tree/api/tree.js +2 -0
  158. package/dist/simple-tree/api/tree.js.map +1 -1
  159. package/dist/simple-tree/core/unhydratedFlexTree.d.ts.map +1 -1
  160. package/dist/simple-tree/core/unhydratedFlexTree.js +7 -1
  161. package/dist/simple-tree/core/unhydratedFlexTree.js.map +1 -1
  162. package/dist/treeFactory.d.ts +38 -9
  163. package/dist/treeFactory.d.ts.map +1 -1
  164. package/dist/treeFactory.js +44 -9
  165. package/dist/treeFactory.js.map +1 -1
  166. package/lib/alpha.d.ts +8 -8
  167. package/lib/api.d.ts +17 -0
  168. package/lib/api.d.ts.map +1 -0
  169. package/lib/api.js +22 -0
  170. package/lib/api.js.map +1 -0
  171. package/lib/beta.d.ts +5 -0
  172. package/lib/codec/codec.d.ts +3 -5
  173. package/lib/codec/codec.d.ts.map +1 -1
  174. package/lib/codec/codec.js +8 -1
  175. package/lib/codec/codec.js.map +1 -1
  176. package/lib/codec/index.d.ts +0 -1
  177. package/lib/codec/index.d.ts.map +1 -1
  178. package/lib/codec/index.js +0 -1
  179. package/lib/codec/index.js.map +1 -1
  180. package/lib/core/index.d.ts +1 -1
  181. package/lib/core/index.d.ts.map +1 -1
  182. package/lib/core/index.js +1 -1
  183. package/lib/core/index.js.map +1 -1
  184. package/lib/core/rebase/index.d.ts +1 -1
  185. package/lib/core/rebase/index.d.ts.map +1 -1
  186. package/lib/core/rebase/index.js +1 -1
  187. package/lib/core/rebase/index.js.map +1 -1
  188. package/lib/core/rebase/utils.d.ts +10 -0
  189. package/lib/core/rebase/utils.d.ts.map +1 -1
  190. package/lib/core/rebase/utils.js +18 -0
  191. package/lib/core/rebase/utils.js.map +1 -1
  192. package/lib/core/tree/detachedFieldIndex.js +2 -2
  193. package/lib/core/tree/detachedFieldIndex.js.map +1 -1
  194. package/lib/external-utilities/index.d.ts +1 -1
  195. package/lib/external-utilities/index.d.ts.map +1 -1
  196. package/lib/external-utilities/index.js +1 -1
  197. package/lib/external-utilities/index.js.map +1 -1
  198. package/lib/external-utilities/typeboxValidator.d.ts +0 -13
  199. package/lib/external-utilities/typeboxValidator.d.ts.map +1 -1
  200. package/lib/external-utilities/typeboxValidator.js +1 -3
  201. package/lib/external-utilities/typeboxValidator.js.map +1 -1
  202. package/lib/feature-libraries/flex-tree/flexTreeTypes.d.ts +2 -0
  203. package/lib/feature-libraries/flex-tree/flexTreeTypes.d.ts.map +1 -1
  204. package/lib/feature-libraries/flex-tree/flexTreeTypes.js.map +1 -1
  205. package/lib/feature-libraries/flex-tree/index.d.ts +1 -0
  206. package/lib/feature-libraries/flex-tree/index.d.ts.map +1 -1
  207. package/lib/feature-libraries/flex-tree/index.js +1 -0
  208. package/lib/feature-libraries/flex-tree/index.js.map +1 -1
  209. package/lib/feature-libraries/flex-tree/lazyNode.d.ts.map +1 -1
  210. package/lib/feature-libraries/flex-tree/lazyNode.js +15 -8
  211. package/lib/feature-libraries/flex-tree/lazyNode.js.map +1 -1
  212. package/lib/feature-libraries/flex-tree/observer.d.ts +32 -0
  213. package/lib/feature-libraries/flex-tree/observer.d.ts.map +1 -0
  214. package/lib/feature-libraries/flex-tree/observer.js +40 -0
  215. package/lib/feature-libraries/flex-tree/observer.js.map +1 -0
  216. package/lib/feature-libraries/index.d.ts +1 -1
  217. package/lib/feature-libraries/index.d.ts.map +1 -1
  218. package/lib/feature-libraries/index.js +1 -1
  219. package/lib/feature-libraries/index.js.map +1 -1
  220. package/lib/index.d.ts +5 -5
  221. package/lib/index.d.ts.map +1 -1
  222. package/lib/index.js +3 -3
  223. package/lib/index.js.map +1 -1
  224. package/lib/legacy.d.ts +7 -1
  225. package/lib/packageVersion.d.ts +1 -1
  226. package/lib/packageVersion.js +1 -1
  227. package/lib/packageVersion.js.map +1 -1
  228. package/lib/shared-tree/index.d.ts +2 -2
  229. package/lib/shared-tree/index.d.ts.map +1 -1
  230. package/lib/shared-tree/index.js.map +1 -1
  231. package/lib/shared-tree/schematizingTreeView.js +2 -2
  232. package/lib/shared-tree/schematizingTreeView.js.map +1 -1
  233. package/lib/shared-tree/sharedTree.d.ts +21 -6
  234. package/lib/shared-tree/sharedTree.d.ts.map +1 -1
  235. package/lib/shared-tree/sharedTree.js +78 -39
  236. package/lib/shared-tree/sharedTree.js.map +1 -1
  237. package/lib/shared-tree/treeAlpha.d.ts +114 -1
  238. package/lib/shared-tree/treeAlpha.d.ts.map +1 -1
  239. package/lib/shared-tree/treeAlpha.js +143 -4
  240. package/lib/shared-tree/treeAlpha.js.map +1 -1
  241. package/lib/shared-tree/treeCheckout.d.ts +13 -7
  242. package/lib/shared-tree/treeCheckout.d.ts.map +1 -1
  243. package/lib/shared-tree/treeCheckout.js +117 -87
  244. package/lib/shared-tree/treeCheckout.js.map +1 -1
  245. package/lib/shared-tree-core/branch.d.ts +3 -0
  246. package/lib/shared-tree-core/branch.d.ts.map +1 -1
  247. package/lib/shared-tree-core/branch.js.map +1 -1
  248. package/lib/shared-tree-core/branchIdCodec.d.ts +11 -0
  249. package/lib/shared-tree-core/branchIdCodec.d.ts.map +1 -0
  250. package/lib/shared-tree-core/branchIdCodec.js +13 -0
  251. package/lib/shared-tree-core/branchIdCodec.js.map +1 -0
  252. package/lib/shared-tree-core/editManager.d.ts +39 -64
  253. package/lib/shared-tree-core/editManager.d.ts.map +1 -1
  254. package/lib/shared-tree-core/editManager.js +455 -295
  255. package/lib/shared-tree-core/editManager.js.map +1 -1
  256. package/lib/shared-tree-core/editManagerCodecs.d.ts +1 -1
  257. package/lib/shared-tree-core/editManagerCodecs.d.ts.map +1 -1
  258. package/lib/shared-tree-core/editManagerCodecs.js +4 -93
  259. package/lib/shared-tree-core/editManagerCodecs.js.map +1 -1
  260. package/lib/shared-tree-core/editManagerCodecsCommons.d.ts +17 -0
  261. package/lib/shared-tree-core/editManagerCodecsCommons.d.ts.map +1 -0
  262. package/lib/shared-tree-core/editManagerCodecsCommons.js +134 -0
  263. package/lib/shared-tree-core/editManagerCodecsCommons.js.map +1 -0
  264. package/lib/shared-tree-core/editManagerCodecsV1toV4.d.ts +16 -0
  265. package/lib/shared-tree-core/editManagerCodecsV1toV4.d.ts.map +1 -0
  266. package/lib/shared-tree-core/editManagerCodecsV1toV4.js +35 -0
  267. package/lib/shared-tree-core/editManagerCodecsV1toV4.js.map +1 -0
  268. package/lib/shared-tree-core/editManagerCodecsV5.d.ts +16 -0
  269. package/lib/shared-tree-core/editManagerCodecsV5.d.ts.map +1 -0
  270. package/lib/shared-tree-core/editManagerCodecsV5.js +54 -0
  271. package/lib/shared-tree-core/editManagerCodecsV5.js.map +1 -0
  272. package/lib/shared-tree-core/{editManagerFormat.d.ts → editManagerFormatCommons.d.ts} +31 -7
  273. package/lib/shared-tree-core/editManagerFormatCommons.d.ts.map +1 -0
  274. package/lib/shared-tree-core/{editManagerFormat.js → editManagerFormatCommons.js} +10 -11
  275. package/lib/shared-tree-core/editManagerFormatCommons.js.map +1 -0
  276. package/lib/shared-tree-core/editManagerFormatV1toV4.d.ts +31 -0
  277. package/lib/shared-tree-core/editManagerFormatV1toV4.d.ts.map +1 -0
  278. package/lib/shared-tree-core/editManagerFormatV1toV4.js +20 -0
  279. package/lib/shared-tree-core/editManagerFormatV1toV4.js.map +1 -0
  280. package/lib/shared-tree-core/editManagerFormatV5.d.ts +62 -0
  281. package/lib/shared-tree-core/editManagerFormatV5.d.ts.map +1 -0
  282. package/lib/shared-tree-core/editManagerFormatV5.js +16 -0
  283. package/lib/shared-tree-core/editManagerFormatV5.js.map +1 -0
  284. package/lib/shared-tree-core/index.d.ts +3 -3
  285. package/lib/shared-tree-core/index.d.ts.map +1 -1
  286. package/lib/shared-tree-core/index.js.map +1 -1
  287. package/lib/shared-tree-core/messageCodecV1ToV4.d.ts +11 -0
  288. package/lib/shared-tree-core/messageCodecV1ToV4.d.ts.map +1 -0
  289. package/lib/shared-tree-core/messageCodecV1ToV4.js +55 -0
  290. package/lib/shared-tree-core/messageCodecV1ToV4.js.map +1 -0
  291. package/lib/shared-tree-core/messageCodecV5.d.ts +11 -0
  292. package/lib/shared-tree-core/messageCodecV5.d.ts.map +1 -0
  293. package/lib/shared-tree-core/messageCodecV5.js +74 -0
  294. package/lib/shared-tree-core/messageCodecV5.js.map +1 -0
  295. package/lib/shared-tree-core/messageCodecs.d.ts.map +1 -1
  296. package/lib/shared-tree-core/messageCodecs.js +17 -48
  297. package/lib/shared-tree-core/messageCodecs.js.map +1 -1
  298. package/lib/shared-tree-core/{messageFormat.d.ts → messageFormatV1ToV4.d.ts} +1 -1
  299. package/lib/shared-tree-core/messageFormatV1ToV4.d.ts.map +1 -0
  300. package/lib/shared-tree-core/{messageFormat.js → messageFormatV1ToV4.js} +1 -1
  301. package/lib/shared-tree-core/messageFormatV1ToV4.js.map +1 -0
  302. package/lib/shared-tree-core/messageFormatV5.d.ts +42 -0
  303. package/lib/shared-tree-core/messageFormatV5.d.ts.map +1 -0
  304. package/lib/shared-tree-core/messageFormatV5.js +16 -0
  305. package/lib/shared-tree-core/messageFormatV5.js.map +1 -0
  306. package/lib/shared-tree-core/messageTypes.d.ts +12 -2
  307. package/lib/shared-tree-core/messageTypes.d.ts.map +1 -1
  308. package/lib/shared-tree-core/messageTypes.js.map +1 -1
  309. package/lib/shared-tree-core/sequenceIdUtils.d.ts +1 -1
  310. package/lib/shared-tree-core/sequenceIdUtils.d.ts.map +1 -1
  311. package/lib/shared-tree-core/sequenceIdUtils.js.map +1 -1
  312. package/lib/shared-tree-core/sharedTreeCore.d.ts +19 -5
  313. package/lib/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
  314. package/lib/shared-tree-core/sharedTreeCore.js +183 -59
  315. package/lib/shared-tree-core/sharedTreeCore.js.map +1 -1
  316. package/lib/simple-tree/api/tree.d.ts +17 -0
  317. package/lib/simple-tree/api/tree.d.ts.map +1 -1
  318. package/lib/simple-tree/api/tree.js +2 -0
  319. package/lib/simple-tree/api/tree.js.map +1 -1
  320. package/lib/simple-tree/core/unhydratedFlexTree.d.ts.map +1 -1
  321. package/lib/simple-tree/core/unhydratedFlexTree.js +8 -2
  322. package/lib/simple-tree/core/unhydratedFlexTree.js.map +1 -1
  323. package/lib/treeFactory.d.ts +38 -9
  324. package/lib/treeFactory.d.ts.map +1 -1
  325. package/lib/treeFactory.js +41 -8
  326. package/lib/treeFactory.js.map +1 -1
  327. package/package.json +25 -25
  328. package/src/api.ts +30 -0
  329. package/src/codec/codec.ts +12 -6
  330. package/src/codec/index.ts +0 -1
  331. package/src/core/index.ts +1 -0
  332. package/src/core/rebase/index.ts +1 -0
  333. package/src/core/rebase/utils.ts +27 -0
  334. package/src/core/tree/detachedFieldIndex.ts +2 -2
  335. package/src/external-utilities/index.ts +1 -1
  336. package/src/external-utilities/typeboxValidator.ts +1 -3
  337. package/src/feature-libraries/flex-tree/flexTreeTypes.ts +2 -0
  338. package/src/feature-libraries/flex-tree/index.ts +2 -0
  339. package/src/feature-libraries/flex-tree/lazyNode.ts +13 -3
  340. package/src/feature-libraries/flex-tree/observer.ts +64 -0
  341. package/src/feature-libraries/index.ts +3 -0
  342. package/src/index.ts +6 -4
  343. package/src/packageVersion.ts +1 -1
  344. package/src/shared-tree/index.ts +2 -0
  345. package/src/shared-tree/schematizingTreeView.ts +2 -2
  346. package/src/shared-tree/sharedTree.ts +116 -52
  347. package/src/shared-tree/treeAlpha.ts +309 -4
  348. package/src/shared-tree/treeCheckout.ts +152 -100
  349. package/src/shared-tree-core/branch.ts +7 -0
  350. package/src/shared-tree-core/branchIdCodec.ts +28 -0
  351. package/src/shared-tree-core/editManager.ts +729 -430
  352. package/src/shared-tree-core/editManagerCodecs.ts +4 -164
  353. package/src/shared-tree-core/editManagerCodecsCommons.ts +245 -0
  354. package/src/shared-tree-core/editManagerCodecsV1toV4.ts +108 -0
  355. package/src/shared-tree-core/editManagerCodecsV5.ts +156 -0
  356. package/src/shared-tree-core/{editManagerFormat.ts → editManagerFormatCommons.ts} +17 -13
  357. package/src/shared-tree-core/editManagerFormatV1toV4.ts +42 -0
  358. package/src/shared-tree-core/editManagerFormatV5.ts +35 -0
  359. package/src/shared-tree-core/index.ts +3 -1
  360. package/src/shared-tree-core/messageCodecV1ToV4.ts +104 -0
  361. package/src/shared-tree-core/messageCodecV5.ts +131 -0
  362. package/src/shared-tree-core/messageCodecs.ts +16 -85
  363. package/src/shared-tree-core/messageFormatV5.ts +50 -0
  364. package/src/shared-tree-core/messageTypes.ts +15 -2
  365. package/src/shared-tree-core/sequenceIdUtils.ts +1 -1
  366. package/src/shared-tree-core/sharedTreeCore.ts +281 -85
  367. package/src/simple-tree/api/tree.ts +23 -0
  368. package/src/simple-tree/core/unhydratedFlexTree.ts +11 -2
  369. package/src/treeFactory.ts +48 -8
  370. package/dist/codec/noopValidator.d.ts +0 -13
  371. package/dist/codec/noopValidator.d.ts.map +0 -1
  372. package/dist/codec/noopValidator.js +0 -17
  373. package/dist/codec/noopValidator.js.map +0 -1
  374. package/dist/shared-tree-core/editManagerFormat.d.ts.map +0 -1
  375. package/dist/shared-tree-core/editManagerFormat.js.map +0 -1
  376. package/dist/shared-tree-core/messageFormat.d.ts.map +0 -1
  377. package/dist/shared-tree-core/messageFormat.js.map +0 -1
  378. package/docs/user-facing/schema-evolution.md +0 -309
  379. package/lib/codec/noopValidator.d.ts +0 -13
  380. package/lib/codec/noopValidator.d.ts.map +0 -1
  381. package/lib/codec/noopValidator.js +0 -14
  382. package/lib/codec/noopValidator.js.map +0 -1
  383. package/lib/shared-tree-core/editManagerFormat.d.ts.map +0 -1
  384. package/lib/shared-tree-core/editManagerFormat.js.map +0 -1
  385. package/lib/shared-tree-core/messageFormat.d.ts.map +0 -1
  386. package/lib/shared-tree-core/messageFormat.js.map +0 -1
  387. package/src/codec/noopValidator.ts +0 -18
  388. /package/src/shared-tree-core/{messageFormat.ts → messageFormatV1ToV4.ts} +0 -0
@@ -13,6 +13,7 @@ import {
13
13
  SessionIdSchema,
14
14
  } from "../core/index.js";
15
15
  import { type Brand, brandedNumberType } from "../util/index.js";
16
+ import type { EncodedBranchId } from "./branch.js";
16
17
 
17
18
  /**
18
19
  * Contains a single change to the `SharedTree` and associated metadata.
@@ -67,7 +68,7 @@ export type SequenceId = Static<typeof SequenceId>;
67
68
  */
68
69
  export interface SequencedCommit<TChangeset> extends Commit<TChangeset>, SequenceId {}
69
70
 
70
- const SequencedCommit = <ChangeSchema extends TSchema>(tChange: ChangeSchema) =>
71
+ export const SequencedCommit = <ChangeSchema extends TSchema>(tChange: ChangeSchema) =>
71
72
  Type.Composite([CommitBase(tChange), SequenceId], noAdditionalProps);
72
73
 
73
74
  /**
@@ -86,7 +87,7 @@ export interface EncodedSummarySessionBranch<TChangeset> {
86
87
  readonly commits: Commit<TChangeset>[];
87
88
  }
88
89
 
89
- const SummarySessionBranch = <ChangeSchema extends TSchema>(tChange: ChangeSchema) =>
90
+ export const SummarySessionBranch = <ChangeSchema extends TSchema>(tChange: ChangeSchema) =>
90
91
  Type.Object(
91
92
  {
92
93
  base: RevisionTagSchema,
@@ -95,23 +96,26 @@ const SummarySessionBranch = <ChangeSchema extends TSchema>(tChange: ChangeSchem
95
96
  noAdditionalProps,
96
97
  );
97
98
 
98
- export interface EncodedEditManager<TChangeset> {
99
+ export interface EncodedSharedBranch<TChangeset> {
100
+ readonly id?: EncodedBranchId;
101
+ readonly name?: string;
102
+ readonly author?: string;
103
+ readonly session?: SessionId;
104
+ readonly base?: EncodedRevisionTag;
99
105
  readonly trunk: readonly Readonly<SequencedCommit<TChangeset>>[];
100
- readonly branches: readonly [SessionId, Readonly<EncodedSummarySessionBranch<TChangeset>>][];
101
- readonly version: 1 | 2 | 3 | 4;
106
+ readonly peers: readonly [SessionId, Readonly<EncodedSummarySessionBranch<TChangeset>>][];
102
107
  }
103
108
 
104
- export const EncodedEditManager = <ChangeSchema extends TSchema>(tChange: ChangeSchema) =>
109
+ export const EncodedSharedBranch = <ChangeSchema extends TSchema>(tChange: ChangeSchema) =>
105
110
  Type.Object(
106
111
  {
107
- version: Type.Union([
108
- Type.Literal(1),
109
- Type.Literal(2),
110
- Type.Literal(3),
111
- Type.Literal(4),
112
- ]),
112
+ id: Type.Optional(Type.Number()),
113
+ name: Type.Optional(Type.String()),
114
+ session: Type.Optional(SessionIdSchema),
115
+ author: Type.Optional(Type.String()),
116
+ base: Type.Optional(RevisionTagSchema),
113
117
  trunk: Type.Array(SequencedCommit(tChange)),
114
- branches: Type.Array(Type.Tuple([SessionIdSchema, SummarySessionBranch(tChange)])),
118
+ peers: Type.Array(Type.Tuple([SessionIdSchema, SummarySessionBranch(tChange)])),
115
119
  },
116
120
  noAdditionalProps,
117
121
  );
@@ -0,0 +1,42 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+
6
+ import type { SessionId } from "@fluidframework/id-compressor";
7
+ import { type ObjectOptions, type TSchema, Type } from "@sinclair/typebox";
8
+
9
+ import { SessionIdSchema } from "../core/index.js";
10
+ import {
11
+ type EncodedSummarySessionBranch,
12
+ SequencedCommit,
13
+ SummarySessionBranch,
14
+ } from "./editManagerFormatCommons.js";
15
+
16
+ const noAdditionalProps: ObjectOptions = { additionalProperties: false };
17
+
18
+ // Many of the return types in this module are intentionally derived, rather than explicitly specified.
19
+ /* eslint-disable @typescript-eslint/explicit-function-return-type */
20
+
21
+ export interface EncodedEditManager<TChangeset> {
22
+ readonly trunk: readonly Readonly<SequencedCommit<TChangeset>>[];
23
+ readonly branches: readonly [SessionId, Readonly<EncodedSummarySessionBranch<TChangeset>>][];
24
+ readonly version: 1 | 2 | 3 | 4;
25
+ }
26
+
27
+ export const EncodedEditManager = <ChangeSchema extends TSchema>(tChange: ChangeSchema) =>
28
+ Type.Object(
29
+ {
30
+ version: Type.Union([
31
+ Type.Literal(1),
32
+ Type.Literal(2),
33
+ Type.Literal(3),
34
+ Type.Literal(4),
35
+ ]),
36
+ trunk: Type.Array(SequencedCommit(tChange)),
37
+ branches: Type.Array(Type.Tuple([SessionIdSchema, SummarySessionBranch(tChange)])),
38
+ },
39
+ noAdditionalProps,
40
+ );
41
+
42
+ /* eslint-enable @typescript-eslint/explicit-function-return-type */
@@ -0,0 +1,35 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+
6
+ import { type ObjectOptions, type TSchema, Type } from "@sinclair/typebox";
7
+ import type { SessionId } from "@fluidframework/id-compressor";
8
+
9
+ import { EncodedSharedBranch } from "./editManagerFormatCommons.js";
10
+ import { SessionIdSchema } from "../core/index.js";
11
+
12
+ const noAdditionalProps: ObjectOptions = { additionalProperties: false };
13
+
14
+ // Many of the return types in this module are intentionally derived, rather than explicitly specified.
15
+ /* eslint-disable @typescript-eslint/explicit-function-return-type */
16
+
17
+ export interface EncodedEditManager<TChangeset> {
18
+ readonly version: 5;
19
+ readonly originator: SessionId;
20
+ readonly main: EncodedSharedBranch<TChangeset>;
21
+ readonly branches?: readonly EncodedSharedBranch<TChangeset>[];
22
+ }
23
+
24
+ export const EncodedEditManager = <ChangeSchema extends TSchema>(tChange: ChangeSchema) =>
25
+ Type.Object(
26
+ {
27
+ version: Type.Union([Type.Literal(5)]),
28
+ originator: SessionIdSchema,
29
+ main: EncodedSharedBranch(tChange),
30
+ branches: Type.Optional(Type.Array(EncodedSharedBranch(tChange))),
31
+ },
32
+ noAdditionalProps,
33
+ );
34
+
35
+ /* eslint-enable @typescript-eslint/explicit-function-return-type */
@@ -8,6 +8,7 @@ export {
8
8
  SharedTreeBranch,
9
9
  type SharedTreeBranchChange,
10
10
  type SharedTreeBranchEvents,
11
+ type BranchId,
11
12
  } from "./branch.js";
12
13
 
13
14
  export {
@@ -44,6 +45,7 @@ export {
44
45
  EditManager,
45
46
  minimumPossibleSequenceNumber,
46
47
  type SummaryData,
48
+ type SharedBranchSummaryData,
47
49
  } from "./editManager.js";
48
50
  export type {
49
51
  Commit,
@@ -51,4 +53,4 @@ export type {
51
53
  SequencedCommit,
52
54
  SummarySessionBranch,
53
55
  EncodedCommit,
54
- } from "./editManagerFormat.js";
56
+ } from "./editManagerFormatCommons.js";
@@ -0,0 +1,104 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+
6
+ import { type TAnySchema, Type } from "@sinclair/typebox";
7
+ import { assert } from "@fluidframework/core-utils/internal";
8
+
9
+ import { type ICodecOptions, type IJsonCodec, withSchemaValidation } from "../codec/index.js";
10
+ import type {
11
+ ChangeEncodingContext,
12
+ ChangeFamilyCodec,
13
+ EncodedRevisionTag,
14
+ RevisionTag,
15
+ } from "../core/index.js";
16
+ import type { JsonCompatibleReadOnly } from "../util/index.js";
17
+
18
+ import { Message } from "./messageFormatV1ToV4.js";
19
+ import type { DecodedMessage } from "./messageTypes.js";
20
+ import type { MessageEncodingContext } from "./messageCodecs.js";
21
+
22
+ export function makeV1ToV4CodecWithVersion<TChangeset>(
23
+ changeCodec: ChangeFamilyCodec<TChangeset>,
24
+ revisionTagCodec: IJsonCodec<
25
+ RevisionTag,
26
+ EncodedRevisionTag,
27
+ EncodedRevisionTag,
28
+ ChangeEncodingContext
29
+ >,
30
+ options: ICodecOptions,
31
+ version: 1 | 2 | 3 | 4,
32
+ ): IJsonCodec<
33
+ DecodedMessage<TChangeset>,
34
+ JsonCompatibleReadOnly,
35
+ JsonCompatibleReadOnly,
36
+ MessageEncodingContext
37
+ > {
38
+ return withSchemaValidation<
39
+ DecodedMessage<TChangeset>,
40
+ TAnySchema,
41
+ JsonCompatibleReadOnly,
42
+ JsonCompatibleReadOnly,
43
+ MessageEncodingContext
44
+ >(
45
+ Message(changeCodec.encodedSchema ?? Type.Any()),
46
+ {
47
+ encode: (decoded: DecodedMessage<TChangeset>, context: MessageEncodingContext) => {
48
+ assert(decoded.type === "commit", 0xc68 /* Only commit messages are supported */);
49
+ assert(
50
+ decoded.branchId === "main",
51
+ 0xc69 /* Only commit messages to main are supported */,
52
+ );
53
+ const { commit, sessionId: originatorId } = decoded;
54
+ const message: Message = {
55
+ revision: revisionTagCodec.encode(commit.revision, {
56
+ originatorId,
57
+ idCompressor: context.idCompressor,
58
+ revision: undefined,
59
+ }),
60
+ originatorId,
61
+ changeset: changeCodec.encode(commit.change, {
62
+ originatorId,
63
+ schema: context.schema,
64
+ idCompressor: context.idCompressor,
65
+ revision: commit.revision,
66
+ }),
67
+ version,
68
+ };
69
+ return message as unknown as JsonCompatibleReadOnly;
70
+ },
71
+ decode: (
72
+ encoded: JsonCompatibleReadOnly,
73
+ context: MessageEncodingContext,
74
+ ): DecodedMessage<TChangeset> => {
75
+ const {
76
+ revision: encodedRevision,
77
+ originatorId,
78
+ changeset,
79
+ } = encoded as unknown as Message;
80
+
81
+ const revision = revisionTagCodec.decode(encodedRevision, {
82
+ originatorId,
83
+ revision: undefined,
84
+ idCompressor: context.idCompressor,
85
+ });
86
+
87
+ return {
88
+ branchId: "main",
89
+ type: "commit",
90
+ commit: {
91
+ revision,
92
+ change: changeCodec.decode(changeset, {
93
+ originatorId,
94
+ revision,
95
+ idCompressor: context.idCompressor,
96
+ }),
97
+ },
98
+ sessionId: originatorId,
99
+ };
100
+ },
101
+ },
102
+ options.jsonValidator,
103
+ );
104
+ }
@@ -0,0 +1,131 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+
6
+ import { type TAnySchema, Type } from "@sinclair/typebox";
7
+
8
+ import { type ICodecOptions, type IJsonCodec, withSchemaValidation } from "../codec/index.js";
9
+ import type {
10
+ ChangeEncodingContext,
11
+ ChangeFamilyCodec,
12
+ EncodedRevisionTag,
13
+ RevisionTag,
14
+ } from "../core/index.js";
15
+ import type { JsonCompatibleReadOnly } from "../util/index.js";
16
+
17
+ import { Message } from "./messageFormatV5.js";
18
+ import type { DecodedMessage } from "./messageTypes.js";
19
+ import { assert, unreachableCase } from "@fluidframework/core-utils/internal";
20
+ import type { MessageEncodingContext } from "./messageCodecs.js";
21
+ import { decodeBranchId, encodeBranchId } from "./branchIdCodec.js";
22
+
23
+ export function makeV5CodecWithVersion<TChangeset>(
24
+ changeCodec: ChangeFamilyCodec<TChangeset>,
25
+ revisionTagCodec: IJsonCodec<
26
+ RevisionTag,
27
+ EncodedRevisionTag,
28
+ EncodedRevisionTag,
29
+ ChangeEncodingContext
30
+ >,
31
+ options: ICodecOptions,
32
+ version: 5,
33
+ ): IJsonCodec<
34
+ DecodedMessage<TChangeset>,
35
+ JsonCompatibleReadOnly,
36
+ JsonCompatibleReadOnly,
37
+ MessageEncodingContext
38
+ > {
39
+ return withSchemaValidation<
40
+ DecodedMessage<TChangeset>,
41
+ TAnySchema,
42
+ JsonCompatibleReadOnly,
43
+ JsonCompatibleReadOnly,
44
+ MessageEncodingContext
45
+ >(
46
+ Message(changeCodec.encodedSchema ?? Type.Any()),
47
+ {
48
+ encode: (
49
+ message: DecodedMessage<TChangeset>,
50
+ context: MessageEncodingContext,
51
+ ): JsonCompatibleReadOnly => {
52
+ const type = message.type;
53
+ switch (type) {
54
+ case "commit": {
55
+ const changeContext: ChangeEncodingContext = {
56
+ originatorId: message.sessionId,
57
+ schema: context.schema,
58
+ idCompressor: context.idCompressor,
59
+ revision: message.commit.revision,
60
+ };
61
+
62
+ return {
63
+ revision: revisionTagCodec.encode(message.commit.revision, {
64
+ originatorId: message.sessionId,
65
+ idCompressor: context.idCompressor,
66
+ revision: undefined,
67
+ }),
68
+ originatorId: message.sessionId,
69
+ changeset: changeCodec.encode(message.commit.change, changeContext),
70
+ branchId: encodeBranchId(context.idCompressor, message.branchId),
71
+ version,
72
+ } satisfies Message & JsonCompatibleReadOnly;
73
+ }
74
+ case "branch": {
75
+ return {
76
+ originatorId: message.sessionId,
77
+ branchId: encodeBranchId(context.idCompressor, message.branchId),
78
+ version,
79
+ } satisfies Message & JsonCompatibleReadOnly;
80
+ }
81
+ default:
82
+ unreachableCase(type);
83
+ }
84
+ },
85
+ decode: (
86
+ encoded: JsonCompatibleReadOnly,
87
+ context: MessageEncodingContext,
88
+ ): DecodedMessage<TChangeset> => {
89
+ const {
90
+ revision: encodedRevision,
91
+ originatorId,
92
+ changeset,
93
+ branchId: encodedBranchId,
94
+ } = encoded as unknown as Message;
95
+
96
+ const changeContext = {
97
+ originatorId,
98
+ revision: undefined,
99
+ idCompressor: context.idCompressor,
100
+ };
101
+
102
+ const branchId = decodeBranchId(context.idCompressor, encodedBranchId, changeContext);
103
+
104
+ if (changeset === undefined) {
105
+ return { type: "branch", sessionId: originatorId, branchId };
106
+ }
107
+
108
+ assert(
109
+ encodedRevision !== undefined,
110
+ 0xc6a /* Commit messages must have a revision */,
111
+ );
112
+ const revision = revisionTagCodec.decode(encodedRevision, changeContext);
113
+
114
+ return {
115
+ type: "commit",
116
+ commit: {
117
+ revision,
118
+ change: changeCodec.decode(changeset, {
119
+ originatorId,
120
+ revision,
121
+ idCompressor: context.idCompressor,
122
+ }),
123
+ },
124
+ branchId,
125
+ sessionId: originatorId,
126
+ };
127
+ },
128
+ },
129
+ options.jsonValidator,
130
+ );
131
+ }
@@ -3,28 +3,25 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
 
6
- import { type TAnySchema, Type } from "@sinclair/typebox";
7
-
8
6
  import {
9
7
  type ICodecFamily,
10
8
  type ICodecOptions,
11
9
  type IJsonCodec,
12
10
  makeCodecFamily,
13
11
  makeVersionDispatchingCodec,
14
- withSchemaValidation,
15
12
  } from "../codec/index.js";
16
13
  import type {
17
14
  ChangeEncodingContext,
18
- ChangeFamilyCodec,
19
15
  EncodedRevisionTag,
20
16
  RevisionTag,
21
17
  SchemaAndPolicy,
22
18
  } from "../core/index.js";
23
19
  import type { JsonCompatibleReadOnly } from "../util/index.js";
24
20
 
25
- import { Message } from "./messageFormat.js";
26
21
  import type { DecodedMessage } from "./messageTypes.js";
27
22
  import type { IIdCompressor } from "@fluidframework/id-compressor";
23
+ import { makeV1ToV4CodecWithVersion } from "./messageCodecV1ToV4.js";
24
+ import { makeV5CodecWithVersion } from "./messageCodecV5.js";
28
25
 
29
26
  export interface MessageEncodingContext {
30
27
  idCompressor: IIdCompressor;
@@ -64,7 +61,7 @@ export function makeMessageCodecs<TChangeset>(
64
61
  >,
65
62
  options: ICodecOptions,
66
63
  ): ICodecFamily<DecodedMessage<TChangeset>, MessageEncodingContext> {
67
- const v1Codec = makeV1CodecWithVersion(
64
+ const v1Codec = makeV1ToV4CodecWithVersion(
68
65
  changeCodecs.resolve(1).json,
69
66
  revisionTagCodec,
70
67
  options,
@@ -74,84 +71,18 @@ export function makeMessageCodecs<TChangeset>(
74
71
  // Back-compat: messages weren't always written with an explicit version field.
75
72
  [undefined, v1Codec],
76
73
  [1, v1Codec],
77
- [2, makeV1CodecWithVersion(changeCodecs.resolve(2).json, revisionTagCodec, options, 2)],
78
- [3, makeV1CodecWithVersion(changeCodecs.resolve(3).json, revisionTagCodec, options, 3)],
79
- [4, makeV1CodecWithVersion(changeCodecs.resolve(4).json, revisionTagCodec, options, 4)],
74
+ [
75
+ 2,
76
+ makeV1ToV4CodecWithVersion(changeCodecs.resolve(2).json, revisionTagCodec, options, 2),
77
+ ],
78
+ [
79
+ 3,
80
+ makeV1ToV4CodecWithVersion(changeCodecs.resolve(3).json, revisionTagCodec, options, 3),
81
+ ],
82
+ [
83
+ 4,
84
+ makeV1ToV4CodecWithVersion(changeCodecs.resolve(4).json, revisionTagCodec, options, 4),
85
+ ],
86
+ [5, makeV5CodecWithVersion(changeCodecs.resolve(4).json, revisionTagCodec, options, 5)],
80
87
  ]);
81
88
  }
82
-
83
- function makeV1CodecWithVersion<TChangeset>(
84
- changeCodec: ChangeFamilyCodec<TChangeset>,
85
- revisionTagCodec: IJsonCodec<
86
- RevisionTag,
87
- EncodedRevisionTag,
88
- EncodedRevisionTag,
89
- ChangeEncodingContext
90
- >,
91
- options: ICodecOptions,
92
- version: 1 | 2 | 3 | 4,
93
- ): IJsonCodec<
94
- DecodedMessage<TChangeset>,
95
- JsonCompatibleReadOnly,
96
- JsonCompatibleReadOnly,
97
- MessageEncodingContext
98
- > {
99
- return withSchemaValidation<
100
- DecodedMessage<TChangeset>,
101
- TAnySchema,
102
- JsonCompatibleReadOnly,
103
- JsonCompatibleReadOnly,
104
- MessageEncodingContext
105
- >(
106
- Message(changeCodec.encodedSchema ?? Type.Any()),
107
- {
108
- encode: (
109
- { commit, sessionId: originatorId }: DecodedMessage<TChangeset>,
110
- context: MessageEncodingContext,
111
- ) => {
112
- const message: Message = {
113
- revision: revisionTagCodec.encode(commit.revision, {
114
- originatorId,
115
- idCompressor: context.idCompressor,
116
- revision: undefined,
117
- }),
118
- originatorId,
119
- changeset: changeCodec.encode(commit.change, {
120
- originatorId,
121
- schema: context.schema,
122
- idCompressor: context.idCompressor,
123
- revision: commit.revision,
124
- }),
125
- version,
126
- };
127
- return message as unknown as JsonCompatibleReadOnly;
128
- },
129
- decode: (encoded: JsonCompatibleReadOnly, context: MessageEncodingContext) => {
130
- const {
131
- revision: encodedRevision,
132
- originatorId,
133
- changeset,
134
- } = encoded as unknown as Message;
135
-
136
- const revision = revisionTagCodec.decode(encodedRevision, {
137
- originatorId,
138
- revision: undefined,
139
- idCompressor: context.idCompressor,
140
- });
141
-
142
- return {
143
- commit: {
144
- revision,
145
- change: changeCodec.decode(changeset, {
146
- originatorId,
147
- revision,
148
- idCompressor: context.idCompressor,
149
- }),
150
- },
151
- sessionId: originatorId,
152
- };
153
- },
154
- },
155
- options.jsonValidator,
156
- );
157
- }
@@ -0,0 +1,50 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+
6
+ import type { SessionId } from "@fluidframework/id-compressor";
7
+ import { type TSchema, Type } from "@sinclair/typebox";
8
+
9
+ import { type EncodedRevisionTag, RevisionTagSchema, SessionIdSchema } from "../core/index.js";
10
+ import type { JsonCompatibleReadOnly } from "../util/index.js";
11
+ import type { EncodedBranchId } from "./branch.js";
12
+
13
+ /**
14
+ * The format of messages that SharedTree sends and receives.
15
+ */
16
+ export interface Message {
17
+ /**
18
+ * The revision tag for the change in this message
19
+ */
20
+ readonly revision?: EncodedRevisionTag;
21
+ /**
22
+ * The stable ID that identifies the originator of the message.
23
+ */
24
+ readonly originatorId: SessionId;
25
+ /**
26
+ * The changeset to be applied.
27
+ */
28
+ readonly changeset?: JsonCompatibleReadOnly;
29
+
30
+ readonly branchId?: EncodedBranchId;
31
+
32
+ /**
33
+ * The version of the message. This controls how the message is encoded.
34
+ *
35
+ * This was not set historically and was added before making any breaking changes to the format.
36
+ * For that reason, absence of a 'version' field is synonymous with version 1.
37
+ */
38
+ readonly version?: number;
39
+ }
40
+
41
+ // Return type is intentionally derived.
42
+ // eslint-disable-next-line @typescript-eslint/explicit-function-return-type
43
+ export const Message = <ChangeSchema extends TSchema>(tChange: ChangeSchema) =>
44
+ Type.Object({
45
+ revision: Type.Optional(RevisionTagSchema),
46
+ originatorId: SessionIdSchema,
47
+ changeset: Type.Optional(tChange),
48
+ branchId: Type.Optional(Type.Number()),
49
+ version: Type.Optional(Type.Number()),
50
+ });
@@ -6,8 +6,21 @@
6
6
  import type { SessionId } from "@fluidframework/id-compressor";
7
7
 
8
8
  import type { GraphCommit } from "../core/index.js";
9
+ import type { BranchId } from "./branch.js";
9
10
 
10
- export interface DecodedMessage<TChange> {
11
- commit: GraphCommit<TChange>;
11
+ export type DecodedMessage<TChange> = CommitMessage<TChange> | BranchMessage;
12
+
13
+ export interface MessageBase {
12
14
  sessionId: SessionId;
13
15
  }
16
+
17
+ export interface CommitMessage<TChange> extends MessageBase {
18
+ type: "commit";
19
+ commit: GraphCommit<TChange>;
20
+ branchId: BranchId;
21
+ }
22
+
23
+ export interface BranchMessage extends MessageBase {
24
+ type: "branch";
25
+ branchId: BranchId;
26
+ }
@@ -7,7 +7,7 @@ import { assert } from "@fluidframework/core-utils/internal";
7
7
 
8
8
  import { brand } from "../util/index.js";
9
9
 
10
- import type { SequenceId } from "./editManagerFormat.js";
10
+ import type { SequenceId } from "./editManagerFormatCommons.js";
11
11
 
12
12
  /**
13
13
  * Compares two sequenceIds. Returns a negative number if a \< b, a positive number if a \> b, and 0 if a === b.