@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
@@ -0,0 +1,16 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ import { Type } from "@sinclair/typebox";
6
+ import { EncodedSharedBranch } from "./editManagerFormatCommons.js";
7
+ import { SessionIdSchema } from "../core/index.js";
8
+ const noAdditionalProps = { additionalProperties: false };
9
+ export const EncodedEditManager = (tChange) => Type.Object({
10
+ version: Type.Union([Type.Literal(5)]),
11
+ originator: SessionIdSchema,
12
+ main: EncodedSharedBranch(tChange),
13
+ branches: Type.Optional(Type.Array(EncodedSharedBranch(tChange))),
14
+ }, noAdditionalProps);
15
+ /* eslint-enable @typescript-eslint/explicit-function-return-type */
16
+ //# sourceMappingURL=editManagerFormatV5.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"editManagerFormatV5.js","sourceRoot":"","sources":["../../src/shared-tree-core/editManagerFormatV5.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAoC,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAG3E,OAAO,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AACpE,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAEnD,MAAM,iBAAiB,GAAkB,EAAE,oBAAoB,EAAE,KAAK,EAAE,CAAC;AAYzE,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAA+B,OAAqB,EAAE,EAAE,CACzF,IAAI,CAAC,MAAM,CACV;IACC,OAAO,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;IACtC,UAAU,EAAE,eAAe;IAC3B,IAAI,EAAE,mBAAmB,CAAC,OAAO,CAAC;IAClC,QAAQ,EAAE,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,mBAAmB,CAAC,OAAO,CAAC,CAAC,CAAC;CACjE,EACD,iBAAiB,CACjB,CAAC;AAEH,oEAAoE","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { type ObjectOptions, type TSchema, Type } from \"@sinclair/typebox\";\nimport type { SessionId } from \"@fluidframework/id-compressor\";\n\nimport { EncodedSharedBranch } from \"./editManagerFormatCommons.js\";\nimport { SessionIdSchema } from \"../core/index.js\";\n\nconst noAdditionalProps: ObjectOptions = { additionalProperties: false };\n\n// Many of the return types in this module are intentionally derived, rather than explicitly specified.\n/* eslint-disable @typescript-eslint/explicit-function-return-type */\n\nexport interface EncodedEditManager<TChangeset> {\n\treadonly version: 5;\n\treadonly originator: SessionId;\n\treadonly main: EncodedSharedBranch<TChangeset>;\n\treadonly branches?: readonly EncodedSharedBranch<TChangeset>[];\n}\n\nexport const EncodedEditManager = <ChangeSchema extends TSchema>(tChange: ChangeSchema) =>\n\tType.Object(\n\t\t{\n\t\t\tversion: Type.Union([Type.Literal(5)]),\n\t\t\toriginator: SessionIdSchema,\n\t\t\tmain: EncodedSharedBranch(tChange),\n\t\t\tbranches: Type.Optional(Type.Array(EncodedSharedBranch(tChange))),\n\t\t},\n\t\tnoAdditionalProps,\n\t);\n\n/* eslint-enable @typescript-eslint/explicit-function-return-type */\n"]}
@@ -2,7 +2,7 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
- export { onForkTransitive, SharedTreeBranch, type SharedTreeBranchChange, type SharedTreeBranchEvents, } from "./branch.js";
5
+ export { onForkTransitive, SharedTreeBranch, type SharedTreeBranchChange, type SharedTreeBranchEvents, type BranchId, } from "./branch.js";
6
6
  export { TransactionResult, type Transactor, type TransactionEvents, TransactionStack, SquashingTransactionStack, type OnPush, type OnPop, } from "./transaction.js";
7
7
  export { type ExplicitCoreCodecVersions, SharedTreeCore, type Summarizable, type SummaryElementParser, type SummaryElementStringifier, type ClonableSchemaAndPolicy, } from "./sharedTreeCore.js";
8
8
  export type { ResubmitMachine } from "./resubmitMachine.js";
@@ -10,6 +10,6 @@ export { DefaultResubmitMachine } from "./defaultResubmitMachine.js";
10
10
  export { type ChangeEnricherReadonlyCheckout, type ChangeEnricherMutableCheckout, NoOpChangeEnricher, } from "./changeEnricher.js";
11
11
  export { makeEditManagerCodec } from "./editManagerCodecs.js";
12
12
  export { EditManagerSummarizer } from "./editManagerSummarizer.js";
13
- export { EditManager, minimumPossibleSequenceNumber, type SummaryData, } from "./editManager.js";
14
- export type { Commit, SeqNumber, SequencedCommit, SummarySessionBranch, EncodedCommit, } from "./editManagerFormat.js";
13
+ export { EditManager, minimumPossibleSequenceNumber, type SummaryData, type SharedBranchSummaryData, } from "./editManager.js";
14
+ export type { Commit, SeqNumber, SequencedCommit, SummarySessionBranch, EncodedCommit, } from "./editManagerFormatCommons.js";
15
15
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/shared-tree-core/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,gBAAgB,EAChB,gBAAgB,EAChB,KAAK,sBAAsB,EAC3B,KAAK,sBAAsB,GAC3B,MAAM,aAAa,CAAC;AAErB,OAAO,EACN,iBAAiB,EACjB,KAAK,UAAU,EACf,KAAK,iBAAiB,EACtB,gBAAgB,EAChB,yBAAyB,EACzB,KAAK,MAAM,EACX,KAAK,KAAK,GACV,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EACN,KAAK,yBAAyB,EAC9B,cAAc,EACd,KAAK,YAAY,EACjB,KAAK,oBAAoB,EACzB,KAAK,yBAAyB,EAC9B,KAAK,uBAAuB,GAC5B,MAAM,qBAAqB,CAAC;AAE7B,YAAY,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AAErE,OAAO,EACN,KAAK,8BAA8B,EACnC,KAAK,6BAA6B,EAClC,kBAAkB,GAClB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,EACN,WAAW,EACX,6BAA6B,EAC7B,KAAK,WAAW,GAChB,MAAM,kBAAkB,CAAC;AAC1B,YAAY,EACX,MAAM,EACN,SAAS,EACT,eAAe,EACf,oBAAoB,EACpB,aAAa,GACb,MAAM,wBAAwB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/shared-tree-core/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,gBAAgB,EAChB,gBAAgB,EAChB,KAAK,sBAAsB,EAC3B,KAAK,sBAAsB,EAC3B,KAAK,QAAQ,GACb,MAAM,aAAa,CAAC;AAErB,OAAO,EACN,iBAAiB,EACjB,KAAK,UAAU,EACf,KAAK,iBAAiB,EACtB,gBAAgB,EAChB,yBAAyB,EACzB,KAAK,MAAM,EACX,KAAK,KAAK,GACV,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EACN,KAAK,yBAAyB,EAC9B,cAAc,EACd,KAAK,YAAY,EACjB,KAAK,oBAAoB,EACzB,KAAK,yBAAyB,EAC9B,KAAK,uBAAuB,GAC5B,MAAM,qBAAqB,CAAC;AAE7B,YAAY,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AAErE,OAAO,EACN,KAAK,8BAA8B,EACnC,KAAK,6BAA6B,EAClC,kBAAkB,GAClB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,EACN,WAAW,EACX,6BAA6B,EAC7B,KAAK,WAAW,EAChB,KAAK,uBAAuB,GAC5B,MAAM,kBAAkB,CAAC;AAC1B,YAAY,EACX,MAAM,EACN,SAAS,EACT,eAAe,EACf,oBAAoB,EACpB,aAAa,GACb,MAAM,+BAA+B,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/shared-tree-core/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,gBAAgB,EAChB,gBAAgB,GAGhB,MAAM,aAAa,CAAC;AAErB,OAAO,EACN,iBAAiB,EAGjB,gBAAgB,EAChB,yBAAyB,GAGzB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAEN,cAAc,GAKd,MAAM,qBAAqB,CAAC;AAG7B,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AAErE,OAAO,EAGN,kBAAkB,GAClB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,EACN,WAAW,EACX,6BAA6B,GAE7B,MAAM,kBAAkB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport {\n\tonForkTransitive,\n\tSharedTreeBranch,\n\ttype SharedTreeBranchChange,\n\ttype SharedTreeBranchEvents,\n} from \"./branch.js\";\n\nexport {\n\tTransactionResult,\n\ttype Transactor,\n\ttype TransactionEvents,\n\tTransactionStack,\n\tSquashingTransactionStack,\n\ttype OnPush,\n\ttype OnPop,\n} from \"./transaction.js\";\n\nexport {\n\ttype ExplicitCoreCodecVersions,\n\tSharedTreeCore,\n\ttype Summarizable,\n\ttype SummaryElementParser,\n\ttype SummaryElementStringifier,\n\ttype ClonableSchemaAndPolicy,\n} from \"./sharedTreeCore.js\";\n\nexport type { ResubmitMachine } from \"./resubmitMachine.js\";\nexport { DefaultResubmitMachine } from \"./defaultResubmitMachine.js\";\n\nexport {\n\ttype ChangeEnricherReadonlyCheckout,\n\ttype ChangeEnricherMutableCheckout,\n\tNoOpChangeEnricher,\n} from \"./changeEnricher.js\";\n\nexport { makeEditManagerCodec } from \"./editManagerCodecs.js\";\nexport { EditManagerSummarizer } from \"./editManagerSummarizer.js\";\nexport {\n\tEditManager,\n\tminimumPossibleSequenceNumber,\n\ttype SummaryData,\n} from \"./editManager.js\";\nexport type {\n\tCommit,\n\tSeqNumber,\n\tSequencedCommit,\n\tSummarySessionBranch,\n\tEncodedCommit,\n} from \"./editManagerFormat.js\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/shared-tree-core/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,gBAAgB,EAChB,gBAAgB,GAIhB,MAAM,aAAa,CAAC;AAErB,OAAO,EACN,iBAAiB,EAGjB,gBAAgB,EAChB,yBAAyB,GAGzB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAEN,cAAc,GAKd,MAAM,qBAAqB,CAAC;AAG7B,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AAErE,OAAO,EAGN,kBAAkB,GAClB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,EACN,WAAW,EACX,6BAA6B,GAG7B,MAAM,kBAAkB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport {\n\tonForkTransitive,\n\tSharedTreeBranch,\n\ttype SharedTreeBranchChange,\n\ttype SharedTreeBranchEvents,\n\ttype BranchId,\n} from \"./branch.js\";\n\nexport {\n\tTransactionResult,\n\ttype Transactor,\n\ttype TransactionEvents,\n\tTransactionStack,\n\tSquashingTransactionStack,\n\ttype OnPush,\n\ttype OnPop,\n} from \"./transaction.js\";\n\nexport {\n\ttype ExplicitCoreCodecVersions,\n\tSharedTreeCore,\n\ttype Summarizable,\n\ttype SummaryElementParser,\n\ttype SummaryElementStringifier,\n\ttype ClonableSchemaAndPolicy,\n} from \"./sharedTreeCore.js\";\n\nexport type { ResubmitMachine } from \"./resubmitMachine.js\";\nexport { DefaultResubmitMachine } from \"./defaultResubmitMachine.js\";\n\nexport {\n\ttype ChangeEnricherReadonlyCheckout,\n\ttype ChangeEnricherMutableCheckout,\n\tNoOpChangeEnricher,\n} from \"./changeEnricher.js\";\n\nexport { makeEditManagerCodec } from \"./editManagerCodecs.js\";\nexport { EditManagerSummarizer } from \"./editManagerSummarizer.js\";\nexport {\n\tEditManager,\n\tminimumPossibleSequenceNumber,\n\ttype SummaryData,\n\ttype SharedBranchSummaryData,\n} from \"./editManager.js\";\nexport type {\n\tCommit,\n\tSeqNumber,\n\tSequencedCommit,\n\tSummarySessionBranch,\n\tEncodedCommit,\n} from \"./editManagerFormatCommons.js\";\n"]}
@@ -0,0 +1,11 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ import { type ICodecOptions, type IJsonCodec } from "../codec/index.js";
6
+ import type { ChangeEncodingContext, ChangeFamilyCodec, EncodedRevisionTag, RevisionTag } from "../core/index.js";
7
+ import type { JsonCompatibleReadOnly } from "../util/index.js";
8
+ import type { DecodedMessage } from "./messageTypes.js";
9
+ import type { MessageEncodingContext } from "./messageCodecs.js";
10
+ export declare function makeV1ToV4CodecWithVersion<TChangeset>(changeCodec: ChangeFamilyCodec<TChangeset>, revisionTagCodec: IJsonCodec<RevisionTag, EncodedRevisionTag, EncodedRevisionTag, ChangeEncodingContext>, options: ICodecOptions, version: 1 | 2 | 3 | 4): IJsonCodec<DecodedMessage<TChangeset>, JsonCompatibleReadOnly, JsonCompatibleReadOnly, MessageEncodingContext>;
11
+ //# sourceMappingURL=messageCodecV1ToV4.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"messageCodecV1ToV4.d.ts","sourceRoot":"","sources":["../../src/shared-tree-core/messageCodecV1ToV4.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,EAAE,KAAK,aAAa,EAAE,KAAK,UAAU,EAAwB,MAAM,mBAAmB,CAAC;AAC9F,OAAO,KAAK,EACX,qBAAqB,EACrB,iBAAiB,EACjB,kBAAkB,EAClB,WAAW,EACX,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAG/D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAEjE,wBAAgB,0BAA0B,CAAC,UAAU,EACpD,WAAW,EAAE,iBAAiB,CAAC,UAAU,CAAC,EAC1C,gBAAgB,EAAE,UAAU,CAC3B,WAAW,EACX,kBAAkB,EAClB,kBAAkB,EAClB,qBAAqB,CACrB,EACD,OAAO,EAAE,aAAa,EACtB,OAAO,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GACpB,UAAU,CACZ,cAAc,CAAC,UAAU,CAAC,EAC1B,sBAAsB,EACtB,sBAAsB,EACtB,sBAAsB,CACtB,CAmEA"}
@@ -0,0 +1,55 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ import { Type } from "@sinclair/typebox";
6
+ import { assert } from "@fluidframework/core-utils/internal";
7
+ import { withSchemaValidation } from "../codec/index.js";
8
+ import { Message } from "./messageFormatV1ToV4.js";
9
+ export function makeV1ToV4CodecWithVersion(changeCodec, revisionTagCodec, options, version) {
10
+ return withSchemaValidation(Message(changeCodec.encodedSchema ?? Type.Any()), {
11
+ encode: (decoded, context) => {
12
+ assert(decoded.type === "commit", 0xc68 /* Only commit messages are supported */);
13
+ assert(decoded.branchId === "main", 0xc69 /* Only commit messages to main are supported */);
14
+ const { commit, sessionId: originatorId } = decoded;
15
+ const message = {
16
+ revision: revisionTagCodec.encode(commit.revision, {
17
+ originatorId,
18
+ idCompressor: context.idCompressor,
19
+ revision: undefined,
20
+ }),
21
+ originatorId,
22
+ changeset: changeCodec.encode(commit.change, {
23
+ originatorId,
24
+ schema: context.schema,
25
+ idCompressor: context.idCompressor,
26
+ revision: commit.revision,
27
+ }),
28
+ version,
29
+ };
30
+ return message;
31
+ },
32
+ decode: (encoded, context) => {
33
+ const { revision: encodedRevision, originatorId, changeset, } = encoded;
34
+ const revision = revisionTagCodec.decode(encodedRevision, {
35
+ originatorId,
36
+ revision: undefined,
37
+ idCompressor: context.idCompressor,
38
+ });
39
+ return {
40
+ branchId: "main",
41
+ type: "commit",
42
+ commit: {
43
+ revision,
44
+ change: changeCodec.decode(changeset, {
45
+ originatorId,
46
+ revision,
47
+ idCompressor: context.idCompressor,
48
+ }),
49
+ },
50
+ sessionId: originatorId,
51
+ };
52
+ },
53
+ }, options.jsonValidator);
54
+ }
55
+ //# sourceMappingURL=messageCodecV1ToV4.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"messageCodecV1ToV4.js","sourceRoot":"","sources":["../../src/shared-tree-core/messageCodecV1ToV4.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAmB,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAE7D,OAAO,EAAuC,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAS9F,OAAO,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAC;AAInD,MAAM,UAAU,0BAA0B,CACzC,WAA0C,EAC1C,gBAKC,EACD,OAAsB,EACtB,OAAsB;IAOtB,OAAO,oBAAoB,CAO1B,OAAO,CAAC,WAAW,CAAC,aAAa,IAAI,IAAI,CAAC,GAAG,EAAE,CAAC,EAChD;QACC,MAAM,EAAE,CAAC,OAAmC,EAAE,OAA+B,EAAE,EAAE;YAChF,MAAM,CAAC,OAAO,CAAC,IAAI,KAAK,QAAQ,EAAE,KAAK,CAAC,wCAAwC,CAAC,CAAC;YAClF,MAAM,CACL,OAAO,CAAC,QAAQ,KAAK,MAAM,EAC3B,KAAK,CAAC,gDAAgD,CACtD,CAAC;YACF,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,YAAY,EAAE,GAAG,OAAO,CAAC;YACpD,MAAM,OAAO,GAAY;gBACxB,QAAQ,EAAE,gBAAgB,CAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,EAAE;oBAClD,YAAY;oBACZ,YAAY,EAAE,OAAO,CAAC,YAAY;oBAClC,QAAQ,EAAE,SAAS;iBACnB,CAAC;gBACF,YAAY;gBACZ,SAAS,EAAE,WAAW,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE;oBAC5C,YAAY;oBACZ,MAAM,EAAE,OAAO,CAAC,MAAM;oBACtB,YAAY,EAAE,OAAO,CAAC,YAAY;oBAClC,QAAQ,EAAE,MAAM,CAAC,QAAQ;iBACzB,CAAC;gBACF,OAAO;aACP,CAAC;YACF,OAAO,OAA4C,CAAC;QACrD,CAAC;QACD,MAAM,EAAE,CACP,OAA+B,EAC/B,OAA+B,EACF,EAAE;YAC/B,MAAM,EACL,QAAQ,EAAE,eAAe,EACzB,YAAY,EACZ,SAAS,GACT,GAAG,OAA6B,CAAC;YAElC,MAAM,QAAQ,GAAG,gBAAgB,CAAC,MAAM,CAAC,eAAe,EAAE;gBACzD,YAAY;gBACZ,QAAQ,EAAE,SAAS;gBACnB,YAAY,EAAE,OAAO,CAAC,YAAY;aAClC,CAAC,CAAC;YAEH,OAAO;gBACN,QAAQ,EAAE,MAAM;gBAChB,IAAI,EAAE,QAAQ;gBACd,MAAM,EAAE;oBACP,QAAQ;oBACR,MAAM,EAAE,WAAW,CAAC,MAAM,CAAC,SAAS,EAAE;wBACrC,YAAY;wBACZ,QAAQ;wBACR,YAAY,EAAE,OAAO,CAAC,YAAY;qBAClC,CAAC;iBACF;gBACD,SAAS,EAAE,YAAY;aACvB,CAAC;QACH,CAAC;KACD,EACD,OAAO,CAAC,aAAa,CACrB,CAAC;AACH,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { type TAnySchema, Type } from \"@sinclair/typebox\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\n\nimport { type ICodecOptions, type IJsonCodec, withSchemaValidation } from \"../codec/index.js\";\nimport type {\n\tChangeEncodingContext,\n\tChangeFamilyCodec,\n\tEncodedRevisionTag,\n\tRevisionTag,\n} from \"../core/index.js\";\nimport type { JsonCompatibleReadOnly } from \"../util/index.js\";\n\nimport { Message } from \"./messageFormatV1ToV4.js\";\nimport type { DecodedMessage } from \"./messageTypes.js\";\nimport type { MessageEncodingContext } from \"./messageCodecs.js\";\n\nexport function makeV1ToV4CodecWithVersion<TChangeset>(\n\tchangeCodec: ChangeFamilyCodec<TChangeset>,\n\trevisionTagCodec: IJsonCodec<\n\t\tRevisionTag,\n\t\tEncodedRevisionTag,\n\t\tEncodedRevisionTag,\n\t\tChangeEncodingContext\n\t>,\n\toptions: ICodecOptions,\n\tversion: 1 | 2 | 3 | 4,\n): IJsonCodec<\n\tDecodedMessage<TChangeset>,\n\tJsonCompatibleReadOnly,\n\tJsonCompatibleReadOnly,\n\tMessageEncodingContext\n> {\n\treturn withSchemaValidation<\n\t\tDecodedMessage<TChangeset>,\n\t\tTAnySchema,\n\t\tJsonCompatibleReadOnly,\n\t\tJsonCompatibleReadOnly,\n\t\tMessageEncodingContext\n\t>(\n\t\tMessage(changeCodec.encodedSchema ?? Type.Any()),\n\t\t{\n\t\t\tencode: (decoded: DecodedMessage<TChangeset>, context: MessageEncodingContext) => {\n\t\t\t\tassert(decoded.type === \"commit\", 0xc68 /* Only commit messages are supported */);\n\t\t\t\tassert(\n\t\t\t\t\tdecoded.branchId === \"main\",\n\t\t\t\t\t0xc69 /* Only commit messages to main are supported */,\n\t\t\t\t);\n\t\t\t\tconst { commit, sessionId: originatorId } = decoded;\n\t\t\t\tconst message: Message = {\n\t\t\t\t\trevision: revisionTagCodec.encode(commit.revision, {\n\t\t\t\t\t\toriginatorId,\n\t\t\t\t\t\tidCompressor: context.idCompressor,\n\t\t\t\t\t\trevision: undefined,\n\t\t\t\t\t}),\n\t\t\t\t\toriginatorId,\n\t\t\t\t\tchangeset: changeCodec.encode(commit.change, {\n\t\t\t\t\t\toriginatorId,\n\t\t\t\t\t\tschema: context.schema,\n\t\t\t\t\t\tidCompressor: context.idCompressor,\n\t\t\t\t\t\trevision: commit.revision,\n\t\t\t\t\t}),\n\t\t\t\t\tversion,\n\t\t\t\t};\n\t\t\t\treturn message as unknown as JsonCompatibleReadOnly;\n\t\t\t},\n\t\t\tdecode: (\n\t\t\t\tencoded: JsonCompatibleReadOnly,\n\t\t\t\tcontext: MessageEncodingContext,\n\t\t\t): DecodedMessage<TChangeset> => {\n\t\t\t\tconst {\n\t\t\t\t\trevision: encodedRevision,\n\t\t\t\t\toriginatorId,\n\t\t\t\t\tchangeset,\n\t\t\t\t} = encoded as unknown as Message;\n\n\t\t\t\tconst revision = revisionTagCodec.decode(encodedRevision, {\n\t\t\t\t\toriginatorId,\n\t\t\t\t\trevision: undefined,\n\t\t\t\t\tidCompressor: context.idCompressor,\n\t\t\t\t});\n\n\t\t\t\treturn {\n\t\t\t\t\tbranchId: \"main\",\n\t\t\t\t\ttype: \"commit\",\n\t\t\t\t\tcommit: {\n\t\t\t\t\t\trevision,\n\t\t\t\t\t\tchange: changeCodec.decode(changeset, {\n\t\t\t\t\t\t\toriginatorId,\n\t\t\t\t\t\t\trevision,\n\t\t\t\t\t\t\tidCompressor: context.idCompressor,\n\t\t\t\t\t\t}),\n\t\t\t\t\t},\n\t\t\t\t\tsessionId: originatorId,\n\t\t\t\t};\n\t\t\t},\n\t\t},\n\t\toptions.jsonValidator,\n\t);\n}\n"]}
@@ -0,0 +1,11 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ import { type ICodecOptions, type IJsonCodec } from "../codec/index.js";
6
+ import type { ChangeEncodingContext, ChangeFamilyCodec, EncodedRevisionTag, RevisionTag } from "../core/index.js";
7
+ import type { JsonCompatibleReadOnly } from "../util/index.js";
8
+ import type { DecodedMessage } from "./messageTypes.js";
9
+ import type { MessageEncodingContext } from "./messageCodecs.js";
10
+ export declare function makeV5CodecWithVersion<TChangeset>(changeCodec: ChangeFamilyCodec<TChangeset>, revisionTagCodec: IJsonCodec<RevisionTag, EncodedRevisionTag, EncodedRevisionTag, ChangeEncodingContext>, options: ICodecOptions, version: 5): IJsonCodec<DecodedMessage<TChangeset>, JsonCompatibleReadOnly, JsonCompatibleReadOnly, MessageEncodingContext>;
11
+ //# sourceMappingURL=messageCodecV5.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"messageCodecV5.d.ts","sourceRoot":"","sources":["../../src/shared-tree-core/messageCodecV5.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,KAAK,aAAa,EAAE,KAAK,UAAU,EAAwB,MAAM,mBAAmB,CAAC;AAC9F,OAAO,KAAK,EACX,qBAAqB,EACrB,iBAAiB,EACjB,kBAAkB,EAClB,WAAW,EACX,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAG/D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAExD,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAGjE,wBAAgB,sBAAsB,CAAC,UAAU,EAChD,WAAW,EAAE,iBAAiB,CAAC,UAAU,CAAC,EAC1C,gBAAgB,EAAE,UAAU,CAC3B,WAAW,EACX,kBAAkB,EAClB,kBAAkB,EAClB,qBAAqB,CACrB,EACD,OAAO,EAAE,aAAa,EACtB,OAAO,EAAE,CAAC,GACR,UAAU,CACZ,cAAc,CAAC,UAAU,CAAC,EAC1B,sBAAsB,EACtB,sBAAsB,EACtB,sBAAsB,CACtB,CA6FA"}
@@ -0,0 +1,74 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ import { Type } from "@sinclair/typebox";
6
+ import { withSchemaValidation } from "../codec/index.js";
7
+ import { Message } from "./messageFormatV5.js";
8
+ import { assert, unreachableCase } from "@fluidframework/core-utils/internal";
9
+ import { decodeBranchId, encodeBranchId } from "./branchIdCodec.js";
10
+ export function makeV5CodecWithVersion(changeCodec, revisionTagCodec, options, version) {
11
+ return withSchemaValidation(Message(changeCodec.encodedSchema ?? Type.Any()), {
12
+ encode: (message, context) => {
13
+ const type = message.type;
14
+ switch (type) {
15
+ case "commit": {
16
+ const changeContext = {
17
+ originatorId: message.sessionId,
18
+ schema: context.schema,
19
+ idCompressor: context.idCompressor,
20
+ revision: message.commit.revision,
21
+ };
22
+ return {
23
+ revision: revisionTagCodec.encode(message.commit.revision, {
24
+ originatorId: message.sessionId,
25
+ idCompressor: context.idCompressor,
26
+ revision: undefined,
27
+ }),
28
+ originatorId: message.sessionId,
29
+ changeset: changeCodec.encode(message.commit.change, changeContext),
30
+ branchId: encodeBranchId(context.idCompressor, message.branchId),
31
+ version,
32
+ };
33
+ }
34
+ case "branch": {
35
+ return {
36
+ originatorId: message.sessionId,
37
+ branchId: encodeBranchId(context.idCompressor, message.branchId),
38
+ version,
39
+ };
40
+ }
41
+ default:
42
+ unreachableCase(type);
43
+ }
44
+ },
45
+ decode: (encoded, context) => {
46
+ const { revision: encodedRevision, originatorId, changeset, branchId: encodedBranchId, } = encoded;
47
+ const changeContext = {
48
+ originatorId,
49
+ revision: undefined,
50
+ idCompressor: context.idCompressor,
51
+ };
52
+ const branchId = decodeBranchId(context.idCompressor, encodedBranchId, changeContext);
53
+ if (changeset === undefined) {
54
+ return { type: "branch", sessionId: originatorId, branchId };
55
+ }
56
+ assert(encodedRevision !== undefined, 0xc6a /* Commit messages must have a revision */);
57
+ const revision = revisionTagCodec.decode(encodedRevision, changeContext);
58
+ return {
59
+ type: "commit",
60
+ commit: {
61
+ revision,
62
+ change: changeCodec.decode(changeset, {
63
+ originatorId,
64
+ revision,
65
+ idCompressor: context.idCompressor,
66
+ }),
67
+ },
68
+ branchId,
69
+ sessionId: originatorId,
70
+ };
71
+ },
72
+ }, options.jsonValidator);
73
+ }
74
+ //# sourceMappingURL=messageCodecV5.js.map
@@ -0,0 +1 @@
1
+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,EAAE;wBACrC,YAAY;wBACZ,QAAQ;wBACR,YAAY,EAAE,OAAO,CAAC,YAAY;qBAClC,CAAC;iBACF;gBACD,QAAQ;gBACR,SAAS,EAAE,YAAY;aACvB,CAAC;QACH,CAAC;KACD,EACD,OAAO,CAAC,aAAa,CACrB,CAAC;AACH,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { type TAnySchema, Type } from \"@sinclair/typebox\";\n\nimport { type ICodecOptions, type IJsonCodec, withSchemaValidation } from \"../codec/index.js\";\nimport type {\n\tChangeEncodingContext,\n\tChangeFamilyCodec,\n\tEncodedRevisionTag,\n\tRevisionTag,\n} from \"../core/index.js\";\nimport type { JsonCompatibleReadOnly } from \"../util/index.js\";\n\nimport { Message } from \"./messageFormatV5.js\";\nimport type { DecodedMessage } from \"./messageTypes.js\";\nimport { assert, unreachableCase } from \"@fluidframework/core-utils/internal\";\nimport type { MessageEncodingContext } from \"./messageCodecs.js\";\nimport { decodeBranchId, encodeBranchId } from \"./branchIdCodec.js\";\n\nexport function makeV5CodecWithVersion<TChangeset>(\n\tchangeCodec: ChangeFamilyCodec<TChangeset>,\n\trevisionTagCodec: IJsonCodec<\n\t\tRevisionTag,\n\t\tEncodedRevisionTag,\n\t\tEncodedRevisionTag,\n\t\tChangeEncodingContext\n\t>,\n\toptions: ICodecOptions,\n\tversion: 5,\n): IJsonCodec<\n\tDecodedMessage<TChangeset>,\n\tJsonCompatibleReadOnly,\n\tJsonCompatibleReadOnly,\n\tMessageEncodingContext\n> {\n\treturn withSchemaValidation<\n\t\tDecodedMessage<TChangeset>,\n\t\tTAnySchema,\n\t\tJsonCompatibleReadOnly,\n\t\tJsonCompatibleReadOnly,\n\t\tMessageEncodingContext\n\t>(\n\t\tMessage(changeCodec.encodedSchema ?? Type.Any()),\n\t\t{\n\t\t\tencode: (\n\t\t\t\tmessage: DecodedMessage<TChangeset>,\n\t\t\t\tcontext: MessageEncodingContext,\n\t\t\t): JsonCompatibleReadOnly => {\n\t\t\t\tconst type = message.type;\n\t\t\t\tswitch (type) {\n\t\t\t\t\tcase \"commit\": {\n\t\t\t\t\t\tconst changeContext: ChangeEncodingContext = {\n\t\t\t\t\t\t\toriginatorId: message.sessionId,\n\t\t\t\t\t\t\tschema: context.schema,\n\t\t\t\t\t\t\tidCompressor: context.idCompressor,\n\t\t\t\t\t\t\trevision: message.commit.revision,\n\t\t\t\t\t\t};\n\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\trevision: revisionTagCodec.encode(message.commit.revision, {\n\t\t\t\t\t\t\t\toriginatorId: message.sessionId,\n\t\t\t\t\t\t\t\tidCompressor: context.idCompressor,\n\t\t\t\t\t\t\t\trevision: undefined,\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\toriginatorId: message.sessionId,\n\t\t\t\t\t\t\tchangeset: changeCodec.encode(message.commit.change, changeContext),\n\t\t\t\t\t\t\tbranchId: encodeBranchId(context.idCompressor, message.branchId),\n\t\t\t\t\t\t\tversion,\n\t\t\t\t\t\t} satisfies Message & JsonCompatibleReadOnly;\n\t\t\t\t\t}\n\t\t\t\t\tcase \"branch\": {\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\toriginatorId: message.sessionId,\n\t\t\t\t\t\t\tbranchId: encodeBranchId(context.idCompressor, message.branchId),\n\t\t\t\t\t\t\tversion,\n\t\t\t\t\t\t} satisfies Message & JsonCompatibleReadOnly;\n\t\t\t\t\t}\n\t\t\t\t\tdefault:\n\t\t\t\t\t\tunreachableCase(type);\n\t\t\t\t}\n\t\t\t},\n\t\t\tdecode: (\n\t\t\t\tencoded: JsonCompatibleReadOnly,\n\t\t\t\tcontext: MessageEncodingContext,\n\t\t\t): DecodedMessage<TChangeset> => {\n\t\t\t\tconst {\n\t\t\t\t\trevision: encodedRevision,\n\t\t\t\t\toriginatorId,\n\t\t\t\t\tchangeset,\n\t\t\t\t\tbranchId: encodedBranchId,\n\t\t\t\t} = encoded as unknown as Message;\n\n\t\t\t\tconst changeContext = {\n\t\t\t\t\toriginatorId,\n\t\t\t\t\trevision: undefined,\n\t\t\t\t\tidCompressor: context.idCompressor,\n\t\t\t\t};\n\n\t\t\t\tconst branchId = decodeBranchId(context.idCompressor, encodedBranchId, changeContext);\n\n\t\t\t\tif (changeset === undefined) {\n\t\t\t\t\treturn { type: \"branch\", sessionId: originatorId, branchId };\n\t\t\t\t}\n\n\t\t\t\tassert(\n\t\t\t\t\tencodedRevision !== undefined,\n\t\t\t\t\t0xc6a /* Commit messages must have a revision */,\n\t\t\t\t);\n\t\t\t\tconst revision = revisionTagCodec.decode(encodedRevision, changeContext);\n\n\t\t\t\treturn {\n\t\t\t\t\ttype: \"commit\",\n\t\t\t\t\tcommit: {\n\t\t\t\t\t\trevision,\n\t\t\t\t\t\tchange: changeCodec.decode(changeset, {\n\t\t\t\t\t\t\toriginatorId,\n\t\t\t\t\t\t\trevision,\n\t\t\t\t\t\t\tidCompressor: context.idCompressor,\n\t\t\t\t\t\t}),\n\t\t\t\t\t},\n\t\t\t\t\tbranchId,\n\t\t\t\t\tsessionId: originatorId,\n\t\t\t\t};\n\t\t\t},\n\t\t},\n\t\toptions.jsonValidator,\n\t);\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"messageCodecs.d.ts","sourceRoot":"","sources":["../../src/shared-tree-core/messageCodecs.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EACN,KAAK,YAAY,EACjB,KAAK,aAAa,EAClB,KAAK,UAAU,EAIf,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EACX,qBAAqB,EAErB,kBAAkB,EAClB,WAAW,EACX,eAAe,EACf,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAG/D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM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AAE,aAAa,CAAC;IAC5B,MAAM,CAAC,EAAE,eAAe,CAAC;CACzB;AAED,wBAAgB,gBAAgB,CAAC,UAAU,EAC1C,YAAY,EAAE,YAAY,CAAC,UAAU,EAAE,qBAAqB,CAAC,EAC7D,gBAAgB,EAAE,UAAU,CAC3B,WAAW,EACX,kBAAkB,EAClB,kBAAkB,EAClB,qBAAqB,CACrB,EACD,OAAO,EAAE,aAAa,EACtB,YAAY,EAAE,MAAM,GAClB,UAAU,CACZ,cAAc,CAAC,UAAU,CAAC,EAC1B,sBAAsB,EACtB,sBAAsB,EACtB,sBAAsB,CACtB,CAGA;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,UAAU,EAC3C,YAAY,EAAE,YAAY,CAAC,UAAU,EAAE,qBAAqB,CAAC,EAC7D,gBAAgB,EAAE,UAAU,CAC3B,WAAW,EACX,kBAAkB,EAClB,kBAAkB,EAClB,qBAAqB,CACrB,EACD,OAAO,EAAE,aAAa,GACpB,YAAY,CAAC,cAAc,CAAC,UAAU,CAAC,EAAE,sBAAsB,CAAC,CAyBlE"}
@@ -2,9 +2,9 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
- import { Type } from "@sinclair/typebox";
6
- import { makeCodecFamily, makeVersionDispatchingCodec, withSchemaValidation, } from "../codec/index.js";
7
- import { Message } from "./messageFormat.js";
5
+ import { makeCodecFamily, makeVersionDispatchingCodec, } from "../codec/index.js";
6
+ import { makeV1ToV4CodecWithVersion } from "./messageCodecV1ToV4.js";
7
+ import { makeV5CodecWithVersion } from "./messageCodecV5.js";
8
8
  export function makeMessageCodec(changeCodecs, revisionTagCodec, options, writeVersion) {
9
9
  const family = makeMessageCodecs(changeCodecs, revisionTagCodec, options);
10
10
  return makeVersionDispatchingCodec(family, { ...options, writeVersion });
@@ -13,55 +13,24 @@ export function makeMessageCodec(changeCodecs, revisionTagCodec, options, writeV
13
13
  * @privateRemarks Exported for testing.
14
14
  */
15
15
  export function makeMessageCodecs(changeCodecs, revisionTagCodec, options) {
16
- const v1Codec = makeV1CodecWithVersion(changeCodecs.resolve(1).json, revisionTagCodec, options, 1);
16
+ const v1Codec = makeV1ToV4CodecWithVersion(changeCodecs.resolve(1).json, revisionTagCodec, options, 1);
17
17
  return makeCodecFamily([
18
18
  // Back-compat: messages weren't always written with an explicit version field.
19
19
  [undefined, v1Codec],
20
20
  [1, v1Codec],
21
- [2, makeV1CodecWithVersion(changeCodecs.resolve(2).json, revisionTagCodec, options, 2)],
22
- [3, makeV1CodecWithVersion(changeCodecs.resolve(3).json, revisionTagCodec, options, 3)],
23
- [4, makeV1CodecWithVersion(changeCodecs.resolve(4).json, revisionTagCodec, options, 4)],
21
+ [
22
+ 2,
23
+ makeV1ToV4CodecWithVersion(changeCodecs.resolve(2).json, revisionTagCodec, options, 2),
24
+ ],
25
+ [
26
+ 3,
27
+ makeV1ToV4CodecWithVersion(changeCodecs.resolve(3).json, revisionTagCodec, options, 3),
28
+ ],
29
+ [
30
+ 4,
31
+ makeV1ToV4CodecWithVersion(changeCodecs.resolve(4).json, revisionTagCodec, options, 4),
32
+ ],
33
+ [5, makeV5CodecWithVersion(changeCodecs.resolve(4).json, revisionTagCodec, options, 5)],
24
34
  ]);
25
35
  }
26
- function makeV1CodecWithVersion(changeCodec, revisionTagCodec, options, version) {
27
- return withSchemaValidation(Message(changeCodec.encodedSchema ?? Type.Any()), {
28
- encode: ({ commit, sessionId: originatorId }, context) => {
29
- const message = {
30
- revision: revisionTagCodec.encode(commit.revision, {
31
- originatorId,
32
- idCompressor: context.idCompressor,
33
- revision: undefined,
34
- }),
35
- originatorId,
36
- changeset: changeCodec.encode(commit.change, {
37
- originatorId,
38
- schema: context.schema,
39
- idCompressor: context.idCompressor,
40
- revision: commit.revision,
41
- }),
42
- version,
43
- };
44
- return message;
45
- },
46
- decode: (encoded, context) => {
47
- const { revision: encodedRevision, originatorId, changeset, } = encoded;
48
- const revision = revisionTagCodec.decode(encodedRevision, {
49
- originatorId,
50
- revision: undefined,
51
- idCompressor: context.idCompressor,
52
- });
53
- return {
54
- commit: {
55
- revision,
56
- change: changeCodec.decode(changeset, {
57
- originatorId,
58
- revision,
59
- idCompressor: context.idCompressor,
60
- }),
61
- },
62
- sessionId: originatorId,
63
- };
64
- },
65
- }, options.jsonValidator);
66
- }
67
36
  //# sourceMappingURL=messageCodecs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"messageCodecs.js","sourceRoot":"","sources":["../../src/shared-tree-core/messageCodecs.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAmB,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAE1D,OAAO,EAIN,eAAe,EACf,2BAA2B,EAC3B,oBAAoB,GACpB,MAAM,mBAAmB,CAAC;AAU3B,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAS7C,MAAM,UAAU,gBAAgB,CAC/B,YAA6D,EAC7D,gBAKC,EACD,OAAsB,EACtB,YAAoB;IAOpB,MAAM,MAAM,GAAG,iBAAiB,CAAC,YAAY,EAAE,gBAAgB,EAAE,OAAO,CAAC,CAAC;IAC1E,OAAO,2BAA2B,CAAC,MAAM,EAAE,EAAE,GAAG,OAAO,EAAE,YAAY,EAAE,CAAC,CAAC;AAC1E,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,iBAAiB,CAChC,YAA6D,EAC7D,gBAKC,EACD,OAAsB;IAEtB,MAAM,OAAO,GAAG,sBAAsB,CACrC,YAAY,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,IAAI,EAC5B,gBAAgB,EAChB,OAAO,EACP,CAAC,CACD,CAAC;IACF,OAAO,eAAe,CAAC;QACtB,+EAA+E;QAC/E,CAAC,SAAS,EAAE,OAAO,CAAC;QACpB,CAAC,CAAC,EAAE,OAAO,CAAC;QACZ,CAAC,CAAC,EAAE,sBAAsB,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,IAAI,E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,MAAM,QAAQ,GAAG,gBAAgB,CAAC,MAAM,CAAC,eAAe,EAAE;gBACzD,YAAY;gBACZ,QAAQ,EAAE,SAAS;gBACnB,YAAY,EAAE,OAAO,CAAC,YAAY;aAClC,CAAC,CAAC;YAEH,OAAO;gBACN,MAAM,EAAE;oBACP,QAAQ;oBACR,MAAM,EAAE,WAAW,CAAC,MAAM,CAAC,SAAS,EAAE;wBACrC,YAAY;wBACZ,QAAQ;wBACR,YAAY,EAAE,OAAO,CAAC,YAAY;qBAClC,CAAC;iBACF;gBACD,SAAS,EAAE,YAAY;aACvB,CAAC;QACH,CAAC;KACD,EACD,OAAO,CAAC,aAAa,CACrB,CAAC;AACH,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { type TAnySchema, Type } from \"@sinclair/typebox\";\n\nimport {\n\ttype ICodecFamily,\n\ttype ICodecOptions,\n\ttype IJsonCodec,\n\tmakeCodecFamily,\n\tmakeVersionDispatchingCodec,\n\twithSchemaValidation,\n} from \"../codec/index.js\";\nimport type {\n\tChangeEncodingContext,\n\tChangeFamilyCodec,\n\tEncodedRevisionTag,\n\tRevisionTag,\n\tSchemaAndPolicy,\n} from \"../core/index.js\";\nimport type { JsonCompatibleReadOnly } from \"../util/index.js\";\n\nimport { Message } from \"./messageFormat.js\";\nimport type { DecodedMessage } from \"./messageTypes.js\";\nimport type { IIdCompressor } from \"@fluidframework/id-compressor\";\n\nexport interface MessageEncodingContext {\n\tidCompressor: IIdCompressor;\n\tschema?: SchemaAndPolicy;\n}\n\nexport function makeMessageCodec<TChangeset>(\n\tchangeCodecs: ICodecFamily<TChangeset, ChangeEncodingContext>,\n\trevisionTagCodec: IJsonCodec<\n\t\tRevisionTag,\n\t\tEncodedRevisionTag,\n\t\tEncodedRevisionTag,\n\t\tChangeEncodingContext\n\t>,\n\toptions: ICodecOptions,\n\twriteVersion: number,\n): IJsonCodec<\n\tDecodedMessage<TChangeset>,\n\tJsonCompatibleReadOnly,\n\tJsonCompatibleReadOnly,\n\tMessageEncodingContext\n> {\n\tconst family = makeMessageCodecs(changeCodecs, revisionTagCodec, options);\n\treturn makeVersionDispatchingCodec(family, { ...options, writeVersion });\n}\n\n/**\n * @privateRemarks Exported for testing.\n */\nexport function makeMessageCodecs<TChangeset>(\n\tchangeCodecs: ICodecFamily<TChangeset, ChangeEncodingContext>,\n\trevisionTagCodec: IJsonCodec<\n\t\tRevisionTag,\n\t\tEncodedRevisionTag,\n\t\tEncodedRevisionTag,\n\t\tChangeEncodingContext\n\t>,\n\toptions: ICodecOptions,\n): ICodecFamily<DecodedMessage<TChangeset>, MessageEncodingContext> {\n\tconst v1Codec = makeV1CodecWithVersion(\n\t\tchangeCodecs.resolve(1).json,\n\t\trevisionTagCodec,\n\t\toptions,\n\t\t1,\n\t);\n\treturn makeCodecFamily([\n\t\t// Back-compat: messages weren't always written with an explicit version field.\n\t\t[undefined, v1Codec],\n\t\t[1, v1Codec],\n\t\t[2, makeV1CodecWithVersion(changeCodecs.resolve(2).json, revisionTagCodec, options, 2)],\n\t\t[3, makeV1CodecWithVersion(changeCodecs.resolve(3).json, revisionTagCodec, options, 3)],\n\t\t[4, makeV1CodecWithVersion(changeCodecs.resolve(4).json, revisionTagCodec, options, 4)],\n\t]);\n}\n\nfunction makeV1CodecWithVersion<TChangeset>(\n\tchangeCodec: ChangeFamilyCodec<TChangeset>,\n\trevisionTagCodec: IJsonCodec<\n\t\tRevisionTag,\n\t\tEncodedRevisionTag,\n\t\tEncodedRevisionTag,\n\t\tChangeEncodingContext\n\t>,\n\toptions: ICodecOptions,\n\tversion: 1 | 2 | 3 | 4,\n): IJsonCodec<\n\tDecodedMessage<TChangeset>,\n\tJsonCompatibleReadOnly,\n\tJsonCompatibleReadOnly,\n\tMessageEncodingContext\n> {\n\treturn withSchemaValidation<\n\t\tDecodedMessage<TChangeset>,\n\t\tTAnySchema,\n\t\tJsonCompatibleReadOnly,\n\t\tJsonCompatibleReadOnly,\n\t\tMessageEncodingContext\n\t>(\n\t\tMessage(changeCodec.encodedSchema ?? Type.Any()),\n\t\t{\n\t\t\tencode: (\n\t\t\t\t{ commit, sessionId: originatorId }: DecodedMessage<TChangeset>,\n\t\t\t\tcontext: MessageEncodingContext,\n\t\t\t) => {\n\t\t\t\tconst message: Message = {\n\t\t\t\t\trevision: revisionTagCodec.encode(commit.revision, {\n\t\t\t\t\t\toriginatorId,\n\t\t\t\t\t\tidCompressor: context.idCompressor,\n\t\t\t\t\t\trevision: undefined,\n\t\t\t\t\t}),\n\t\t\t\t\toriginatorId,\n\t\t\t\t\tchangeset: changeCodec.encode(commit.change, {\n\t\t\t\t\t\toriginatorId,\n\t\t\t\t\t\tschema: context.schema,\n\t\t\t\t\t\tidCompressor: context.idCompressor,\n\t\t\t\t\t\trevision: commit.revision,\n\t\t\t\t\t}),\n\t\t\t\t\tversion,\n\t\t\t\t};\n\t\t\t\treturn message as unknown as JsonCompatibleReadOnly;\n\t\t\t},\n\t\t\tdecode: (encoded: JsonCompatibleReadOnly, context: MessageEncodingContext) => {\n\t\t\t\tconst {\n\t\t\t\t\trevision: encodedRevision,\n\t\t\t\t\toriginatorId,\n\t\t\t\t\tchangeset,\n\t\t\t\t} = encoded as unknown as Message;\n\n\t\t\t\tconst revision = revisionTagCodec.decode(encodedRevision, {\n\t\t\t\t\toriginatorId,\n\t\t\t\t\trevision: undefined,\n\t\t\t\t\tidCompressor: context.idCompressor,\n\t\t\t\t});\n\n\t\t\t\treturn {\n\t\t\t\t\tcommit: {\n\t\t\t\t\t\trevision,\n\t\t\t\t\t\tchange: changeCodec.decode(changeset, {\n\t\t\t\t\t\t\toriginatorId,\n\t\t\t\t\t\t\trevision,\n\t\t\t\t\t\t\tidCompressor: context.idCompressor,\n\t\t\t\t\t\t}),\n\t\t\t\t\t},\n\t\t\t\t\tsessionId: originatorId,\n\t\t\t\t};\n\t\t\t},\n\t\t},\n\t\toptions.jsonValidator,\n\t);\n}\n"]}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AE,OAAO,EAAE,CAAC,CAAC;SACtF;QACD,CAAC,CAAC,EAAE,sBAAsB,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,gBAAgB,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC;KACvF,CAAC,CAAC;AACJ,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\ttype ICodecFamily,\n\ttype ICodecOptions,\n\ttype IJsonCodec,\n\tmakeCodecFamily,\n\tmakeVersionDispatchingCodec,\n} from \"../codec/index.js\";\nimport type {\n\tChangeEncodingContext,\n\tEncodedRevisionTag,\n\tRevisionTag,\n\tSchemaAndPolicy,\n} from \"../core/index.js\";\nimport type { JsonCompatibleReadOnly } from \"../util/index.js\";\n\nimport type { DecodedMessage } from \"./messageTypes.js\";\nimport type { IIdCompressor } from \"@fluidframework/id-compressor\";\nimport { makeV1ToV4CodecWithVersion } from \"./messageCodecV1ToV4.js\";\nimport { makeV5CodecWithVersion } from \"./messageCodecV5.js\";\n\nexport interface MessageEncodingContext {\n\tidCompressor: IIdCompressor;\n\tschema?: SchemaAndPolicy;\n}\n\nexport function makeMessageCodec<TChangeset>(\n\tchangeCodecs: ICodecFamily<TChangeset, ChangeEncodingContext>,\n\trevisionTagCodec: IJsonCodec<\n\t\tRevisionTag,\n\t\tEncodedRevisionTag,\n\t\tEncodedRevisionTag,\n\t\tChangeEncodingContext\n\t>,\n\toptions: ICodecOptions,\n\twriteVersion: number,\n): IJsonCodec<\n\tDecodedMessage<TChangeset>,\n\tJsonCompatibleReadOnly,\n\tJsonCompatibleReadOnly,\n\tMessageEncodingContext\n> {\n\tconst family = makeMessageCodecs(changeCodecs, revisionTagCodec, options);\n\treturn makeVersionDispatchingCodec(family, { ...options, writeVersion });\n}\n\n/**\n * @privateRemarks Exported for testing.\n */\nexport function makeMessageCodecs<TChangeset>(\n\tchangeCodecs: ICodecFamily<TChangeset, ChangeEncodingContext>,\n\trevisionTagCodec: IJsonCodec<\n\t\tRevisionTag,\n\t\tEncodedRevisionTag,\n\t\tEncodedRevisionTag,\n\t\tChangeEncodingContext\n\t>,\n\toptions: ICodecOptions,\n): ICodecFamily<DecodedMessage<TChangeset>, MessageEncodingContext> {\n\tconst v1Codec = makeV1ToV4CodecWithVersion(\n\t\tchangeCodecs.resolve(1).json,\n\t\trevisionTagCodec,\n\t\toptions,\n\t\t1,\n\t);\n\treturn makeCodecFamily([\n\t\t// Back-compat: messages weren't always written with an explicit version field.\n\t\t[undefined, v1Codec],\n\t\t[1, v1Codec],\n\t\t[\n\t\t\t2,\n\t\t\tmakeV1ToV4CodecWithVersion(changeCodecs.resolve(2).json, revisionTagCodec, options, 2),\n\t\t],\n\t\t[\n\t\t\t3,\n\t\t\tmakeV1ToV4CodecWithVersion(changeCodecs.resolve(3).json, revisionTagCodec, options, 3),\n\t\t],\n\t\t[\n\t\t\t4,\n\t\t\tmakeV1ToV4CodecWithVersion(changeCodecs.resolve(4).json, revisionTagCodec, options, 4),\n\t\t],\n\t\t[5, makeV5CodecWithVersion(changeCodecs.resolve(4).json, revisionTagCodec, options, 5)],\n\t]);\n}\n"]}
@@ -36,4 +36,4 @@ export declare const Message: <ChangeSchema extends TSchema>(tChange: ChangeSche
36
36
  changeset: ChangeSchema;
37
37
  version: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
38
38
  }>;
39
- //# sourceMappingURL=messageFormat.d.ts.map
39
+ //# sourceMappingURL=messageFormatV1ToV4.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"messageFormatV1ToV4.d.ts","sourceRoot":"","sources":["../../src/shared-tree-core/messageFormatV1ToV4.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAC/D,OAAO,EAAE,KAAK,OAAO,EAAQ,MAAM,mBAAmB,CAAC;AAEvD,OAAO,EAAE,KAAK,kBAAkB,EAAsC,MAAM,kBAAkB,CAAC;AAC/F,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAE/D;;GAEG;AACH,MAAM,WAAW,OAAO;IACvB;;OAEG;IACH,QAAQ,CAAC,QAAQ,EAAE,kBAAkB,CAAC;IACtC;;OAEG;IACH,QAAQ,CAAC,YAAY,EAAE,SAAS,CAAC;IACjC;;OAEG;IACH,QAAQ,CAAC,SAAS,EAAE,sBAAsB,CAAC;IAE3C;;;;;OAKG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;CAC1B;AAID,eAAO,MAAM,OAAO,0CAA2C,YAAY;;;;;EAMxE,CAAC"}
@@ -12,4 +12,4 @@ export const Message = (tChange) => Type.Object({
12
12
  changeset: tChange,
13
13
  version: Type.Optional(Type.Number()),
14
14
  });
15
- //# sourceMappingURL=messageFormat.js.map
15
+ //# sourceMappingURL=messageFormatV1ToV4.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"messageFormatV1ToV4.js","sourceRoot":"","sources":["../../src/shared-tree-core/messageFormatV1ToV4.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAgB,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAEvD,OAAO,EAA2B,iBAAiB,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AA6B/F,wCAAwC;AACxC,4EAA4E;AAC5E,MAAM,CAAC,MAAM,OAAO,GAAG,CAA+B,OAAqB,EAAE,EAAE,CAC9E,IAAI,CAAC,MAAM,CAAC;IACX,QAAQ,EAAE,iBAAiB;IAC3B,YAAY,EAAE,eAAe;IAC7B,SAAS,EAAE,OAAO;IAClB,OAAO,EAAE,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;CACrC,CAAC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { SessionId } from \"@fluidframework/id-compressor\";\nimport { type TSchema, Type } from \"@sinclair/typebox\";\n\nimport { type EncodedRevisionTag, RevisionTagSchema, SessionIdSchema } from \"../core/index.js\";\nimport type { JsonCompatibleReadOnly } from \"../util/index.js\";\n\n/**\n * The format of messages that SharedTree sends and receives.\n */\nexport interface Message {\n\t/**\n\t * The revision tag for the change in this message\n\t */\n\treadonly revision: EncodedRevisionTag;\n\t/**\n\t * The stable ID that identifies the originator of the message.\n\t */\n\treadonly originatorId: SessionId;\n\t/**\n\t * The changeset to be applied.\n\t */\n\treadonly changeset: JsonCompatibleReadOnly;\n\n\t/**\n\t * The version of the message. This controls how the message is encoded.\n\t *\n\t * This was not set historically and was added before making any breaking changes to the format.\n\t * For that reason, absence of a 'version' field is synonymous with version 1.\n\t */\n\treadonly version?: number;\n}\n\n// Return type is intentionally derived.\n// eslint-disable-next-line @typescript-eslint/explicit-function-return-type\nexport const Message = <ChangeSchema extends TSchema>(tChange: ChangeSchema) =>\n\tType.Object({\n\t\trevision: RevisionTagSchema,\n\t\toriginatorId: SessionIdSchema,\n\t\tchangeset: tChange,\n\t\tversion: Type.Optional(Type.Number()),\n\t});\n"]}
@@ -0,0 +1,42 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ import type { SessionId } from "@fluidframework/id-compressor";
6
+ import { type TSchema } from "@sinclair/typebox";
7
+ import { type EncodedRevisionTag } from "../core/index.js";
8
+ import type { JsonCompatibleReadOnly } from "../util/index.js";
9
+ import type { EncodedBranchId } from "./branch.js";
10
+ /**
11
+ * The format of messages that SharedTree sends and receives.
12
+ */
13
+ export interface Message {
14
+ /**
15
+ * The revision tag for the change in this message
16
+ */
17
+ readonly revision?: EncodedRevisionTag;
18
+ /**
19
+ * The stable ID that identifies the originator of the message.
20
+ */
21
+ readonly originatorId: SessionId;
22
+ /**
23
+ * The changeset to be applied.
24
+ */
25
+ readonly changeset?: JsonCompatibleReadOnly;
26
+ readonly branchId?: EncodedBranchId;
27
+ /**
28
+ * The version of the message. This controls how the message is encoded.
29
+ *
30
+ * This was not set historically and was added before making any breaking changes to the format.
31
+ * For that reason, absence of a 'version' field is synonymous with version 1.
32
+ */
33
+ readonly version?: number;
34
+ }
35
+ export declare const Message: <ChangeSchema extends TSchema>(tChange: ChangeSchema) => import("@sinclair/typebox").TObject<{
36
+ revision: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"root">, import("@sinclair/typebox").TUnsafe<import("../util/brand.js").Brand<import("@fluidframework/id-compressor").OpSpaceCompressedId, "EncodedRevisionTag">>]>>;
37
+ originatorId: import("@sinclair/typebox").TUnsafe<SessionId>;
38
+ changeset: ChangeSchema extends import("@sinclair/typebox").TOptional<infer S extends TSchema> ? import("@sinclair/typebox").TOptional<S> : import("@sinclair/typebox").Ensure<import("@sinclair/typebox").TOptional<ChangeSchema>>;
39
+ branchId: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
40
+ version: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
41
+ }>;
42
+ //# sourceMappingURL=messageFormatV5.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"messageFormatV5.d.ts","sourceRoot":"","sources":["../../src/shared-tree-core/messageFormatV5.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAC/D,OAAO,EAAE,KAAK,OAAO,EAAQ,MAAM,mBAAmB,CAAC;AAEvD,OAAO,EAAE,KAAK,kBAAkB,EAAsC,MAAM,kBAAkB,CAAC;AAC/F,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAC/D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAEnD;;GAEG;AACH,MAAM,WAAW,OAAO;IACvB;;OAEG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,kBAAkB,CAAC;IACvC;;OAEG;IACH,QAAQ,CAAC,YAAY,EAAE,SAAS,CAAC;IACjC;;OAEG;IACH,QAAQ,CAAC,SAAS,CAAC,EAAE,sBAAsB,CAAC;IAE5C,QAAQ,CAAC,QAAQ,CAAC,EAAE,eAAe,CAAC;IAEpC;;;;;OAKG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;CAC1B;AAID,eAAO,MAAM,OAAO,0CAA2C,YAAY;;;;;;EAOxE,CAAC"}
@@ -0,0 +1,16 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ import { Type } from "@sinclair/typebox";
6
+ import { RevisionTagSchema, SessionIdSchema } from "../core/index.js";
7
+ // Return type is intentionally derived.
8
+ // eslint-disable-next-line @typescript-eslint/explicit-function-return-type
9
+ export const Message = (tChange) => Type.Object({
10
+ revision: Type.Optional(RevisionTagSchema),
11
+ originatorId: SessionIdSchema,
12
+ changeset: Type.Optional(tChange),
13
+ branchId: Type.Optional(Type.Number()),
14
+ version: Type.Optional(Type.Number()),
15
+ });
16
+ //# sourceMappingURL=messageFormatV5.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"messageFormatV5.js","sourceRoot":"","sources":["../../src/shared-tree-core/messageFormatV5.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAgB,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAEvD,OAAO,EAA2B,iBAAiB,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAgC/F,wCAAwC;AACxC,4EAA4E;AAC5E,MAAM,CAAC,MAAM,OAAO,GAAG,CAA+B,OAAqB,EAAE,EAAE,CAC9E,IAAI,CAAC,MAAM,CAAC;IACX,QAAQ,EAAE,IAAI,CAAC,QAAQ,CAAC,iBAAiB,CAAC;IAC1C,YAAY,EAAE,eAAe;IAC7B,SAAS,EAAE,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC;IACjC,QAAQ,EAAE,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;IACtC,OAAO,EAAE,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;CACrC,CAAC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { SessionId } from \"@fluidframework/id-compressor\";\nimport { type TSchema, Type } from \"@sinclair/typebox\";\n\nimport { type EncodedRevisionTag, RevisionTagSchema, SessionIdSchema } from \"../core/index.js\";\nimport type { JsonCompatibleReadOnly } from \"../util/index.js\";\nimport type { EncodedBranchId } from \"./branch.js\";\n\n/**\n * The format of messages that SharedTree sends and receives.\n */\nexport interface Message {\n\t/**\n\t * The revision tag for the change in this message\n\t */\n\treadonly revision?: EncodedRevisionTag;\n\t/**\n\t * The stable ID that identifies the originator of the message.\n\t */\n\treadonly originatorId: SessionId;\n\t/**\n\t * The changeset to be applied.\n\t */\n\treadonly changeset?: JsonCompatibleReadOnly;\n\n\treadonly branchId?: EncodedBranchId;\n\n\t/**\n\t * The version of the message. This controls how the message is encoded.\n\t *\n\t * This was not set historically and was added before making any breaking changes to the format.\n\t * For that reason, absence of a 'version' field is synonymous with version 1.\n\t */\n\treadonly version?: number;\n}\n\n// Return type is intentionally derived.\n// eslint-disable-next-line @typescript-eslint/explicit-function-return-type\nexport const Message = <ChangeSchema extends TSchema>(tChange: ChangeSchema) =>\n\tType.Object({\n\t\trevision: Type.Optional(RevisionTagSchema),\n\t\toriginatorId: SessionIdSchema,\n\t\tchangeset: Type.Optional(tChange),\n\t\tbranchId: Type.Optional(Type.Number()),\n\t\tversion: Type.Optional(Type.Number()),\n\t});\n"]}
@@ -4,8 +4,18 @@
4
4
  */
5
5
  import type { SessionId } from "@fluidframework/id-compressor";
6
6
  import type { GraphCommit } from "../core/index.js";
7
- export interface DecodedMessage<TChange> {
8
- commit: GraphCommit<TChange>;
7
+ import type { BranchId } from "./branch.js";
8
+ export type DecodedMessage<TChange> = CommitMessage<TChange> | BranchMessage;
9
+ export interface MessageBase {
9
10
  sessionId: SessionId;
10
11
  }
12
+ export interface CommitMessage<TChange> extends MessageBase {
13
+ type: "commit";
14
+ commit: GraphCommit<TChange>;
15
+ branchId: BranchId;
16
+ }
17
+ export interface BranchMessage extends MessageBase {
18
+ type: "branch";
19
+ branchId: BranchId;
20
+ }
11
21
  //# sourceMappingURL=messageTypes.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"messageTypes.d.ts","sourceRoot":"","sources":["../../src/shared-tree-core/messageTypes.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAE/D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAEpD,MAAM,WAAW,cAAc,CAAC,OAAO;IACtC,MAAM,EAAE,WAAW,CAAC,OAAO,CAAC,CAAC;IAC7B,SAAS,EAAE,SAAS,CAAC;CACrB"}
1
+ {"version":3,"file":"messageTypes.d.ts","sourceRoot":"","sources":["../../src/shared-tree-core/messageTypes.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAE/D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAE5C,MAAM,MAAM,cAAc,CAAC,OAAO,IAAI,aAAa,CAAC,OAAO,CAAC,GAAG,aAAa,CAAC;AAE7E,MAAM,WAAW,WAAW;IAC3B,SAAS,EAAE,SAAS,CAAC;CACrB;AAED,MAAM,WAAW,aAAa,CAAC,OAAO,CAAE,SAAQ,WAAW;IAC1D,IAAI,EAAE,QAAQ,CAAC;IACf,MAAM,EAAE,WAAW,CAAC,OAAO,CAAC,CAAC;IAC7B,QAAQ,EAAE,QAAQ,CAAC;CACnB;AAED,MAAM,WAAW,aAAc,SAAQ,WAAW;IACjD,IAAI,EAAE,QAAQ,CAAC;IACf,QAAQ,EAAE,QAAQ,CAAC;CACnB"}
@@ -1 +1 @@
1
- {"version":3,"file":"messageTypes.js","sourceRoot":"","sources":["../../src/shared-tree-core/messageTypes.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { SessionId } from \"@fluidframework/id-compressor\";\n\nimport type { GraphCommit } from \"../core/index.js\";\n\nexport interface DecodedMessage<TChange> {\n\tcommit: GraphCommit<TChange>;\n\tsessionId: SessionId;\n}\n"]}
1
+ {"version":3,"file":"messageTypes.js","sourceRoot":"","sources":["../../src/shared-tree-core/messageTypes.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { SessionId } from \"@fluidframework/id-compressor\";\n\nimport type { GraphCommit } from \"../core/index.js\";\nimport type { BranchId } from \"./branch.js\";\n\nexport type DecodedMessage<TChange> = CommitMessage<TChange> | BranchMessage;\n\nexport interface MessageBase {\n\tsessionId: SessionId;\n}\n\nexport interface CommitMessage<TChange> extends MessageBase {\n\ttype: \"commit\";\n\tcommit: GraphCommit<TChange>;\n\tbranchId: BranchId;\n}\n\nexport interface BranchMessage extends MessageBase {\n\ttype: \"branch\";\n\tbranchId: BranchId;\n}\n"]}
@@ -2,7 +2,7 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
- import type { SequenceId } from "./editManagerFormat.js";
5
+ import type { SequenceId } from "./editManagerFormatCommons.js";
6
6
  /**
7
7
  * Compares two sequenceIds. Returns a negative number if a \< b, a positive number if a \> b, and 0 if a === b.
8
8
  * Note that this handles cases where indexInBatch is Number.POSITIVE_INFINITY.
@@ -1 +1 @@
1
- {"version":3,"file":"sequenceIdUtils.d.ts","sourceRoot":"","sources":["../../src/shared-tree-core/sequenceIdUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAMH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAEzD;;;GAGG;AACH,eAAO,MAAM,oBAAoB,MAAO,UAAU,KAAK,UAAU,KAAG,MAKlB,CAAC;AACnD,eAAO,MAAM,gBAAgB,MAAO,UAAU,KAAK,UAAU,KAAG,OAC/B,CAAC;AAClC,eAAO,MAAM,aAAa,MAAO,UAAU,KAAK,UAAU,KAAG,UACtB,CAAC;AACxC,eAAO,MAAM,aAAa,MAAO,UAAU,KAAK,UAAU,KAAG,UACtB,CAAC;AACxC;;;;;;GAMG;AACH,eAAO,MAAM,iCAAiC,eAAgB,UAAU,KAAG,UAc1E,CAAC"}
1
+ {"version":3,"file":"sequenceIdUtils.d.ts","sourceRoot":"","sources":["../../src/shared-tree-core/sequenceIdUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAMH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAEhE;;;GAGG;AACH,eAAO,MAAM,oBAAoB,MAAO,UAAU,KAAK,UAAU,KAAG,MAKlB,CAAC;AACnD,eAAO,MAAM,gBAAgB,MAAO,UAAU,KAAK,UAAU,KAAG,OAC/B,CAAC;AAClC,eAAO,MAAM,aAAa,MAAO,UAAU,KAAK,UAAU,KAAG,UACtB,CAAC;AACxC,eAAO,MAAM,aAAa,MAAO,UAAU,KAAK,UAAU,KAAG,UACtB,CAAC;AACxC;;;;;;GAMG;AACH,eAAO,MAAM,iCAAiC,eAAgB,UAAU,KAAG,UAc1E,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"sequenceIdUtils.js","sourceRoot":"","sources":["../../src/shared-tree-core/sequenceIdUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,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K,SAAS,IAAI,UAAU,CAAC,YAAY,KAAK,CAAC;QAC5E,CAAC,CAAC;YACA,cAAc,EAAE,KAAK,CAAC,UAAU,CAAC,cAAc,GAAG,CAAC,CAAC;YACpD,YAAY,EAAE,MAAM,CAAC,iBAAiB;SACtC;QACF,CAAC,CAAC;YACA,cAAc,EAAE,KAAK,CAAC,UAAU,CAAC,cAAc,CAAC;YAChD,YAAY,EAAE,UAAU,CAAC,YAAY,GAAG,CAAC;SACzC,CAAC;AACL,CAAC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\n\nimport { brand } from \"../util/index.js\";\n\nimport type { SequenceId } from \"./editManagerFormat.js\";\n\n/**\n * Compares two sequenceIds. Returns a negative number if a \\< b, a positive number if a \\> b, and 0 if a === b.\n * Note that this handles cases where indexInBatch is Number.POSITIVE_INFINITY.\n */\nexport const sequenceIdComparator = (a: SequenceId, b: SequenceId): number =>\n\ta.sequenceNumber !== b.sequenceNumber\n\t\t? a.sequenceNumber - b.sequenceNumber\n\t\t: a.indexInBatch === b.indexInBatch\n\t\t\t? 0\n\t\t\t: (a.indexInBatch ?? 0) - (b.indexInBatch ?? 0);\nexport const equalSequenceIds = (a: SequenceId, b: SequenceId): boolean =>\n\tsequenceIdComparator(a, b) === 0;\nexport const minSequenceId = (a: SequenceId, b: SequenceId): SequenceId =>\n\tsequenceIdComparator(a, b) < 0 ? a : b;\nexport const maxSequenceId = (a: SequenceId, b: SequenceId): SequenceId =>\n\tsequenceIdComparator(a, b) > 0 ? a : b;\n/**\n * Returns the upper bound (maximum possible) sequenceId that can occur just before the given sequenceId.\n * Some examples:\n * 1. sequenceId = \\{ sequenceNumber: 1, indexInBatch: 2 \\}. The upper bound is \\{ sequenceNumber: 1, indexInBatch: 1 \\}.\n * 2. sequenceId = \\{ sequenceNumber: 2 \\}. The upper bound is \\{ sequenceNumber: 1, indexInBatch: Number.POSITIVE_INFINITY \\}.\n * The indexInBatch value of the previous commit will depend on how many ops were in the previous batch of messages received.\n */\nexport const getUpperBoundOfPreviousSequenceId = (sequenceId: SequenceId): SequenceId => {\n\tassert(\n\t\tsequenceId.indexInBatch === undefined || Number.isFinite(sequenceId.indexInBatch),\n\t\t0xabc /* indexInBatch must not be infinity */,\n\t);\n\treturn sequenceId.indexInBatch === undefined || sequenceId.indexInBatch === 0\n\t\t? {\n\t\t\t\tsequenceNumber: brand(sequenceId.sequenceNumber - 1),\n\t\t\t\tindexInBatch: Number.POSITIVE_INFINITY,\n\t\t\t}\n\t\t: {\n\t\t\t\tsequenceNumber: brand(sequenceId.sequenceNumber),\n\t\t\t\tindexInBatch: sequenceId.indexInBatch - 1,\n\t\t\t};\n};\n"]}
1
+ {"version":3,"file":"sequenceIdUtils.js","sourceRoot":"","sources":["../../src/shared-tree-core/sequenceIdUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAE7D,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAIzC;;;GAGG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,CAAa,EAAE,CAAa,EAAU,EAAE,CAC5E,CAAC,CAAC,cAAc,KAAK,CAAC,CAAC,cAAc;IACpC,CAAC,CAAC,CAAC,CAAC,cAAc,GAAG,CAAC,CAAC,cAAc;IACrC,CAAC,CAAC,CAAC,CAAC,YAAY,KAAK,CAAC,CAAC,YAAY;QAClC,CAAC,CAAC,CAAC;QACH,CAAC,CAAC,CAAC,CAAC,CAAC,YAAY,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,YAAY,IAAI,CAAC,CAAC,CAAC;AACnD,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,CAAa,EAAE,CAAa,EAAW,EAAE,CACzE,oBAAoB,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC;AAClC,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,CAAa,EAAE,CAAa,EAAc,EAAE,CACzE,oBAAoB,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AACxC,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,CAAa,EAAE,CAAa,EAAc,EAAE,CACzE,oBAAoB,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AACxC;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,iCAAiC,GAAG,CAAC,UAAsB,EAAc,EAAE;IACvF,MAAM,CACL,UAAU,CAAC,YAAY,KAAK,SAAS,IAAI,MAAM,CAAC,QAAQ,CAAC,UAAU,CAAC,YAAY,CAAC,EACjF,KAAK,CAAC,uCAAuC,CAC7C,CAAC;IACF,OAAO,UAAU,CAAC,YAAY,KAAK,SAAS,IAAI,UAAU,CAAC,YAAY,KAAK,CAAC;QAC5E,CAAC,CAAC;YACA,cAAc,EAAE,KAAK,CAAC,UAAU,CAAC,cAAc,GAAG,CAAC,CAAC;YACpD,YAAY,EAAE,MAAM,CAAC,iBAAiB;SACtC;QACF,CAAC,CAAC;YACA,cAAc,EAAE,KAAK,CAAC,UAAU,CAAC,cAAc,CAAC;YAChD,YAAY,EAAE,UAAU,CAAC,YAAY,GAAG,CAAC;SACzC,CAAC;AACL,CAAC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\n\nimport { brand } from \"../util/index.js\";\n\nimport type { SequenceId } from \"./editManagerFormatCommons.js\";\n\n/**\n * Compares two sequenceIds. Returns a negative number if a \\< b, a positive number if a \\> b, and 0 if a === b.\n * Note that this handles cases where indexInBatch is Number.POSITIVE_INFINITY.\n */\nexport const sequenceIdComparator = (a: SequenceId, b: SequenceId): number =>\n\ta.sequenceNumber !== b.sequenceNumber\n\t\t? a.sequenceNumber - b.sequenceNumber\n\t\t: a.indexInBatch === b.indexInBatch\n\t\t\t? 0\n\t\t\t: (a.indexInBatch ?? 0) - (b.indexInBatch ?? 0);\nexport const equalSequenceIds = (a: SequenceId, b: SequenceId): boolean =>\n\tsequenceIdComparator(a, b) === 0;\nexport const minSequenceId = (a: SequenceId, b: SequenceId): SequenceId =>\n\tsequenceIdComparator(a, b) < 0 ? a : b;\nexport const maxSequenceId = (a: SequenceId, b: SequenceId): SequenceId =>\n\tsequenceIdComparator(a, b) > 0 ? a : b;\n/**\n * Returns the upper bound (maximum possible) sequenceId that can occur just before the given sequenceId.\n * Some examples:\n * 1. sequenceId = \\{ sequenceNumber: 1, indexInBatch: 2 \\}. The upper bound is \\{ sequenceNumber: 1, indexInBatch: 1 \\}.\n * 2. sequenceId = \\{ sequenceNumber: 2 \\}. The upper bound is \\{ sequenceNumber: 1, indexInBatch: Number.POSITIVE_INFINITY \\}.\n * The indexInBatch value of the previous commit will depend on how many ops were in the previous batch of messages received.\n */\nexport const getUpperBoundOfPreviousSequenceId = (sequenceId: SequenceId): SequenceId => {\n\tassert(\n\t\tsequenceId.indexInBatch === undefined || Number.isFinite(sequenceId.indexInBatch),\n\t\t0xabc /* indexInBatch must not be infinity */,\n\t);\n\treturn sequenceId.indexInBatch === undefined || sequenceId.indexInBatch === 0\n\t\t? {\n\t\t\t\tsequenceNumber: brand(sequenceId.sequenceNumber - 1),\n\t\t\t\tindexInBatch: Number.POSITIVE_INFINITY,\n\t\t\t}\n\t\t: {\n\t\t\t\tsequenceNumber: brand(sequenceId.sequenceNumber),\n\t\t\t\tindexInBatch: sequenceId.indexInBatch - 1,\n\t\t\t};\n};\n"]}