@fluidframework/tree 2.61.0 → 2.62.0-356644

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 (237) hide show
  1. package/api-report/tree.alpha.api.md +3 -0
  2. package/dist/core/index.d.ts +1 -1
  3. package/dist/core/index.d.ts.map +1 -1
  4. package/dist/core/index.js +2 -1
  5. package/dist/core/index.js.map +1 -1
  6. package/dist/core/rebase/index.d.ts +1 -1
  7. package/dist/core/rebase/index.d.ts.map +1 -1
  8. package/dist/core/rebase/index.js +2 -1
  9. package/dist/core/rebase/index.js.map +1 -1
  10. package/dist/core/rebase/utils.d.ts +10 -0
  11. package/dist/core/rebase/utils.d.ts.map +1 -1
  12. package/dist/core/rebase/utils.js +20 -1
  13. package/dist/core/rebase/utils.js.map +1 -1
  14. package/dist/packageVersion.d.ts +1 -1
  15. package/dist/packageVersion.d.ts.map +1 -1
  16. package/dist/packageVersion.js +1 -1
  17. package/dist/packageVersion.js.map +1 -1
  18. package/dist/shared-tree/schematizingTreeView.js +2 -2
  19. package/dist/shared-tree/schematizingTreeView.js.map +1 -1
  20. package/dist/shared-tree/sharedTree.d.ts +12 -2
  21. package/dist/shared-tree/sharedTree.d.ts.map +1 -1
  22. package/dist/shared-tree/sharedTree.js +71 -33
  23. package/dist/shared-tree/sharedTree.js.map +1 -1
  24. package/dist/shared-tree/treeCheckout.d.ts +13 -7
  25. package/dist/shared-tree/treeCheckout.d.ts.map +1 -1
  26. package/dist/shared-tree/treeCheckout.js +114 -84
  27. package/dist/shared-tree/treeCheckout.js.map +1 -1
  28. package/dist/shared-tree-core/branch.d.ts +3 -0
  29. package/dist/shared-tree-core/branch.d.ts.map +1 -1
  30. package/dist/shared-tree-core/branch.js.map +1 -1
  31. package/dist/shared-tree-core/branchIdCodec.d.ts +11 -0
  32. package/dist/shared-tree-core/branchIdCodec.d.ts.map +1 -0
  33. package/dist/shared-tree-core/branchIdCodec.js +18 -0
  34. package/dist/shared-tree-core/branchIdCodec.js.map +1 -0
  35. package/dist/shared-tree-core/editManager.d.ts +33 -63
  36. package/dist/shared-tree-core/editManager.d.ts.map +1 -1
  37. package/dist/shared-tree-core/editManager.js +437 -290
  38. package/dist/shared-tree-core/editManager.js.map +1 -1
  39. package/dist/shared-tree-core/editManagerCodecs.d.ts +1 -1
  40. package/dist/shared-tree-core/editManagerCodecs.d.ts.map +1 -1
  41. package/dist/shared-tree-core/editManagerCodecs.js +7 -96
  42. package/dist/shared-tree-core/editManagerCodecs.js.map +1 -1
  43. package/dist/shared-tree-core/editManagerCodecsCommons.d.ts +17 -0
  44. package/dist/shared-tree-core/editManagerCodecsCommons.d.ts.map +1 -0
  45. package/dist/shared-tree-core/editManagerCodecsCommons.js +139 -0
  46. package/dist/shared-tree-core/editManagerCodecsCommons.js.map +1 -0
  47. package/dist/shared-tree-core/editManagerCodecsV1toV4.d.ts +16 -0
  48. package/dist/shared-tree-core/editManagerCodecsV1toV4.d.ts.map +1 -0
  49. package/dist/shared-tree-core/editManagerCodecsV1toV4.js +39 -0
  50. package/dist/shared-tree-core/editManagerCodecsV1toV4.js.map +1 -0
  51. package/dist/shared-tree-core/editManagerCodecsV5.d.ts +16 -0
  52. package/dist/shared-tree-core/editManagerCodecsV5.d.ts.map +1 -0
  53. package/dist/shared-tree-core/editManagerCodecsV5.js +58 -0
  54. package/dist/shared-tree-core/editManagerCodecsV5.js.map +1 -0
  55. package/dist/shared-tree-core/{editManagerFormat.d.ts → editManagerFormatCommons.d.ts} +31 -7
  56. package/dist/shared-tree-core/editManagerFormatCommons.d.ts.map +1 -0
  57. package/dist/shared-tree-core/{editManagerFormat.js → editManagerFormatCommons.js} +13 -12
  58. package/dist/shared-tree-core/editManagerFormatCommons.js.map +1 -0
  59. package/dist/shared-tree-core/editManagerFormatV1toV4.d.ts +31 -0
  60. package/dist/shared-tree-core/editManagerFormatV1toV4.d.ts.map +1 -0
  61. package/dist/shared-tree-core/editManagerFormatV1toV4.js +24 -0
  62. package/dist/shared-tree-core/editManagerFormatV1toV4.js.map +1 -0
  63. package/dist/shared-tree-core/editManagerFormatV5.d.ts +62 -0
  64. package/dist/shared-tree-core/editManagerFormatV5.d.ts.map +1 -0
  65. package/dist/shared-tree-core/editManagerFormatV5.js +20 -0
  66. package/dist/shared-tree-core/editManagerFormatV5.js.map +1 -0
  67. package/dist/shared-tree-core/index.d.ts +3 -3
  68. package/dist/shared-tree-core/index.d.ts.map +1 -1
  69. package/dist/shared-tree-core/index.js.map +1 -1
  70. package/dist/shared-tree-core/messageCodecV1ToV4.d.ts +11 -0
  71. package/dist/shared-tree-core/messageCodecV1ToV4.d.ts.map +1 -0
  72. package/dist/shared-tree-core/messageCodecV1ToV4.js +59 -0
  73. package/dist/shared-tree-core/messageCodecV1ToV4.js.map +1 -0
  74. package/dist/shared-tree-core/messageCodecV5.d.ts +11 -0
  75. package/dist/shared-tree-core/messageCodecV5.d.ts.map +1 -0
  76. package/dist/shared-tree-core/messageCodecV5.js +78 -0
  77. package/dist/shared-tree-core/messageCodecV5.js.map +1 -0
  78. package/dist/shared-tree-core/messageCodecs.d.ts.map +1 -1
  79. package/dist/shared-tree-core/messageCodecs.js +16 -47
  80. package/dist/shared-tree-core/messageCodecs.js.map +1 -1
  81. package/dist/shared-tree-core/{messageFormat.d.ts → messageFormatV1ToV4.d.ts} +1 -1
  82. package/dist/shared-tree-core/messageFormatV1ToV4.d.ts.map +1 -0
  83. package/dist/shared-tree-core/{messageFormat.js → messageFormatV1ToV4.js} +1 -1
  84. package/dist/shared-tree-core/messageFormatV1ToV4.js.map +1 -0
  85. package/dist/shared-tree-core/messageFormatV5.d.ts +42 -0
  86. package/dist/shared-tree-core/messageFormatV5.d.ts.map +1 -0
  87. package/dist/shared-tree-core/messageFormatV5.js +20 -0
  88. package/dist/shared-tree-core/messageFormatV5.js.map +1 -0
  89. package/dist/shared-tree-core/messageTypes.d.ts +12 -2
  90. package/dist/shared-tree-core/messageTypes.d.ts.map +1 -1
  91. package/dist/shared-tree-core/messageTypes.js.map +1 -1
  92. package/dist/shared-tree-core/sequenceIdUtils.d.ts +1 -1
  93. package/dist/shared-tree-core/sequenceIdUtils.d.ts.map +1 -1
  94. package/dist/shared-tree-core/sequenceIdUtils.js.map +1 -1
  95. package/dist/shared-tree-core/sharedTreeCore.d.ts +18 -5
  96. package/dist/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
  97. package/dist/shared-tree-core/sharedTreeCore.js +175 -56
  98. package/dist/shared-tree-core/sharedTreeCore.js.map +1 -1
  99. package/dist/simple-tree/api/tree.d.ts +10 -0
  100. package/dist/simple-tree/api/tree.d.ts.map +1 -1
  101. package/dist/simple-tree/api/tree.js.map +1 -1
  102. package/lib/core/index.d.ts +1 -1
  103. package/lib/core/index.d.ts.map +1 -1
  104. package/lib/core/index.js +1 -1
  105. package/lib/core/index.js.map +1 -1
  106. package/lib/core/rebase/index.d.ts +1 -1
  107. package/lib/core/rebase/index.d.ts.map +1 -1
  108. package/lib/core/rebase/index.js +1 -1
  109. package/lib/core/rebase/index.js.map +1 -1
  110. package/lib/core/rebase/utils.d.ts +10 -0
  111. package/lib/core/rebase/utils.d.ts.map +1 -1
  112. package/lib/core/rebase/utils.js +18 -0
  113. package/lib/core/rebase/utils.js.map +1 -1
  114. package/lib/packageVersion.d.ts +1 -1
  115. package/lib/packageVersion.d.ts.map +1 -1
  116. package/lib/packageVersion.js +1 -1
  117. package/lib/packageVersion.js.map +1 -1
  118. package/lib/shared-tree/schematizingTreeView.js +2 -2
  119. package/lib/shared-tree/schematizingTreeView.js.map +1 -1
  120. package/lib/shared-tree/sharedTree.d.ts +12 -2
  121. package/lib/shared-tree/sharedTree.d.ts.map +1 -1
  122. package/lib/shared-tree/sharedTree.js +72 -34
  123. package/lib/shared-tree/sharedTree.js.map +1 -1
  124. package/lib/shared-tree/treeCheckout.d.ts +13 -7
  125. package/lib/shared-tree/treeCheckout.d.ts.map +1 -1
  126. package/lib/shared-tree/treeCheckout.js +115 -85
  127. package/lib/shared-tree/treeCheckout.js.map +1 -1
  128. package/lib/shared-tree-core/branch.d.ts +3 -0
  129. package/lib/shared-tree-core/branch.d.ts.map +1 -1
  130. package/lib/shared-tree-core/branch.js.map +1 -1
  131. package/lib/shared-tree-core/branchIdCodec.d.ts +11 -0
  132. package/lib/shared-tree-core/branchIdCodec.d.ts.map +1 -0
  133. package/lib/shared-tree-core/branchIdCodec.js +13 -0
  134. package/lib/shared-tree-core/branchIdCodec.js.map +1 -0
  135. package/lib/shared-tree-core/editManager.d.ts +33 -63
  136. package/lib/shared-tree-core/editManager.d.ts.map +1 -1
  137. package/lib/shared-tree-core/editManager.js +437 -290
  138. package/lib/shared-tree-core/editManager.js.map +1 -1
  139. package/lib/shared-tree-core/editManagerCodecs.d.ts +1 -1
  140. package/lib/shared-tree-core/editManagerCodecs.d.ts.map +1 -1
  141. package/lib/shared-tree-core/editManagerCodecs.js +4 -93
  142. package/lib/shared-tree-core/editManagerCodecs.js.map +1 -1
  143. package/lib/shared-tree-core/editManagerCodecsCommons.d.ts +17 -0
  144. package/lib/shared-tree-core/editManagerCodecsCommons.d.ts.map +1 -0
  145. package/lib/shared-tree-core/editManagerCodecsCommons.js +134 -0
  146. package/lib/shared-tree-core/editManagerCodecsCommons.js.map +1 -0
  147. package/lib/shared-tree-core/editManagerCodecsV1toV4.d.ts +16 -0
  148. package/lib/shared-tree-core/editManagerCodecsV1toV4.d.ts.map +1 -0
  149. package/lib/shared-tree-core/editManagerCodecsV1toV4.js +35 -0
  150. package/lib/shared-tree-core/editManagerCodecsV1toV4.js.map +1 -0
  151. package/lib/shared-tree-core/editManagerCodecsV5.d.ts +16 -0
  152. package/lib/shared-tree-core/editManagerCodecsV5.d.ts.map +1 -0
  153. package/lib/shared-tree-core/editManagerCodecsV5.js +54 -0
  154. package/lib/shared-tree-core/editManagerCodecsV5.js.map +1 -0
  155. package/lib/shared-tree-core/{editManagerFormat.d.ts → editManagerFormatCommons.d.ts} +31 -7
  156. package/lib/shared-tree-core/editManagerFormatCommons.d.ts.map +1 -0
  157. package/lib/shared-tree-core/{editManagerFormat.js → editManagerFormatCommons.js} +10 -11
  158. package/lib/shared-tree-core/editManagerFormatCommons.js.map +1 -0
  159. package/lib/shared-tree-core/editManagerFormatV1toV4.d.ts +31 -0
  160. package/lib/shared-tree-core/editManagerFormatV1toV4.d.ts.map +1 -0
  161. package/lib/shared-tree-core/editManagerFormatV1toV4.js +20 -0
  162. package/lib/shared-tree-core/editManagerFormatV1toV4.js.map +1 -0
  163. package/lib/shared-tree-core/editManagerFormatV5.d.ts +62 -0
  164. package/lib/shared-tree-core/editManagerFormatV5.d.ts.map +1 -0
  165. package/lib/shared-tree-core/editManagerFormatV5.js +16 -0
  166. package/lib/shared-tree-core/editManagerFormatV5.js.map +1 -0
  167. package/lib/shared-tree-core/index.d.ts +3 -3
  168. package/lib/shared-tree-core/index.d.ts.map +1 -1
  169. package/lib/shared-tree-core/index.js.map +1 -1
  170. package/lib/shared-tree-core/messageCodecV1ToV4.d.ts +11 -0
  171. package/lib/shared-tree-core/messageCodecV1ToV4.d.ts.map +1 -0
  172. package/lib/shared-tree-core/messageCodecV1ToV4.js +55 -0
  173. package/lib/shared-tree-core/messageCodecV1ToV4.js.map +1 -0
  174. package/lib/shared-tree-core/messageCodecV5.d.ts +11 -0
  175. package/lib/shared-tree-core/messageCodecV5.d.ts.map +1 -0
  176. package/lib/shared-tree-core/messageCodecV5.js +74 -0
  177. package/lib/shared-tree-core/messageCodecV5.js.map +1 -0
  178. package/lib/shared-tree-core/messageCodecs.d.ts.map +1 -1
  179. package/lib/shared-tree-core/messageCodecs.js +17 -48
  180. package/lib/shared-tree-core/messageCodecs.js.map +1 -1
  181. package/lib/shared-tree-core/{messageFormat.d.ts → messageFormatV1ToV4.d.ts} +1 -1
  182. package/lib/shared-tree-core/messageFormatV1ToV4.d.ts.map +1 -0
  183. package/lib/shared-tree-core/{messageFormat.js → messageFormatV1ToV4.js} +1 -1
  184. package/lib/shared-tree-core/messageFormatV1ToV4.js.map +1 -0
  185. package/lib/shared-tree-core/messageFormatV5.d.ts +42 -0
  186. package/lib/shared-tree-core/messageFormatV5.d.ts.map +1 -0
  187. package/lib/shared-tree-core/messageFormatV5.js +16 -0
  188. package/lib/shared-tree-core/messageFormatV5.js.map +1 -0
  189. package/lib/shared-tree-core/messageTypes.d.ts +12 -2
  190. package/lib/shared-tree-core/messageTypes.d.ts.map +1 -1
  191. package/lib/shared-tree-core/messageTypes.js.map +1 -1
  192. package/lib/shared-tree-core/sequenceIdUtils.d.ts +1 -1
  193. package/lib/shared-tree-core/sequenceIdUtils.d.ts.map +1 -1
  194. package/lib/shared-tree-core/sequenceIdUtils.js.map +1 -1
  195. package/lib/shared-tree-core/sharedTreeCore.d.ts +18 -5
  196. package/lib/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
  197. package/lib/shared-tree-core/sharedTreeCore.js +176 -57
  198. package/lib/shared-tree-core/sharedTreeCore.js.map +1 -1
  199. package/lib/simple-tree/api/tree.d.ts +10 -0
  200. package/lib/simple-tree/api/tree.d.ts.map +1 -1
  201. package/lib/simple-tree/api/tree.js.map +1 -1
  202. package/package.json +20 -20
  203. package/src/core/index.ts +1 -0
  204. package/src/core/rebase/index.ts +1 -0
  205. package/src/core/rebase/utils.ts +27 -0
  206. package/src/packageVersion.ts +1 -1
  207. package/src/shared-tree/schematizingTreeView.ts +2 -2
  208. package/src/shared-tree/sharedTree.ts +103 -46
  209. package/src/shared-tree/treeCheckout.ts +147 -98
  210. package/src/shared-tree-core/branch.ts +7 -0
  211. package/src/shared-tree-core/branchIdCodec.ts +28 -0
  212. package/src/shared-tree-core/editManager.ts +709 -437
  213. package/src/shared-tree-core/editManagerCodecs.ts +4 -164
  214. package/src/shared-tree-core/editManagerCodecsCommons.ts +236 -0
  215. package/src/shared-tree-core/editManagerCodecsV1toV4.ts +108 -0
  216. package/src/shared-tree-core/editManagerCodecsV5.ts +150 -0
  217. package/src/shared-tree-core/{editManagerFormat.ts → editManagerFormatCommons.ts} +17 -13
  218. package/src/shared-tree-core/editManagerFormatV1toV4.ts +42 -0
  219. package/src/shared-tree-core/editManagerFormatV5.ts +35 -0
  220. package/src/shared-tree-core/index.ts +3 -1
  221. package/src/shared-tree-core/messageCodecV1ToV4.ts +101 -0
  222. package/src/shared-tree-core/messageCodecV5.ts +128 -0
  223. package/src/shared-tree-core/messageCodecs.ts +16 -85
  224. package/src/shared-tree-core/messageFormatV5.ts +50 -0
  225. package/src/shared-tree-core/messageTypes.ts +15 -2
  226. package/src/shared-tree-core/sequenceIdUtils.ts +1 -1
  227. package/src/shared-tree-core/sharedTreeCore.ts +270 -84
  228. package/src/simple-tree/api/tree.ts +15 -0
  229. package/dist/shared-tree-core/editManagerFormat.d.ts.map +0 -1
  230. package/dist/shared-tree-core/editManagerFormat.js.map +0 -1
  231. package/dist/shared-tree-core/messageFormat.d.ts.map +0 -1
  232. package/dist/shared-tree-core/messageFormat.js.map +0 -1
  233. package/lib/shared-tree-core/editManagerFormat.d.ts.map +0 -1
  234. package/lib/shared-tree-core/editManagerFormat.js.map +0 -1
  235. package/lib/shared-tree-core/messageFormat.d.ts.map +0 -1
  236. package/lib/shared-tree-core/messageFormat.js.map +0 -1
  237. /package/src/shared-tree-core/{messageFormat.ts → messageFormatV1ToV4.ts} +0 -0
@@ -4,7 +4,7 @@
4
4
  */
5
5
 
6
6
  import type { IFluidLoadable, ITelemetryBaseLogger } from "@fluidframework/core-interfaces";
7
- import { assert } from "@fluidframework/core-utils/internal";
7
+ import { assert, fail, unreachableCase } from "@fluidframework/core-utils/internal";
8
8
  import type { IChannelStorageService } from "@fluidframework/datastore-definitions/internal";
9
9
  import type { ISnapshotTree } from "@fluidframework/driver-definitions/internal";
10
10
  import type { IIdCompressor, SessionId } from "@fluidframework/id-compressor";
@@ -42,13 +42,13 @@ import {
42
42
  breakingClass,
43
43
  } from "../util/index.js";
44
44
 
45
- import type { SharedTreeBranch } from "./branch.js";
45
+ import type { BranchId, SharedTreeBranch } from "./branch.js";
46
46
  import { BranchCommitEnricher } from "./branchCommitEnricher.js";
47
47
  import { type ChangeEnricherReadonlyCheckout, NoOpChangeEnricher } from "./changeEnricher.js";
48
48
  import { DefaultResubmitMachine } from "./defaultResubmitMachine.js";
49
49
  import { EditManager, minimumPossibleSequenceNumber } from "./editManager.js";
50
50
  import { makeEditManagerCodec } from "./editManagerCodecs.js";
51
- import type { SeqNumber } from "./editManagerFormat.js";
51
+ import type { SeqNumber } from "./editManagerFormatCommons.js";
52
52
  import { EditManagerSummarizer } from "./editManagerSummarizer.js";
53
53
  import { type MessageEncodingContext, makeMessageCodec } from "./messageCodecs.js";
54
54
  import type { DecodedMessage } from "./messageTypes.js";
@@ -98,8 +98,7 @@ export class SharedTreeCore<TEditor extends ChangeFamilyEditor, TChange>
98
98
  MessageEncodingContext
99
99
  >;
100
100
 
101
- private readonly resubmitMachine: ResubmitMachine<TChange>;
102
- public readonly commitEnricher: BranchCommitEnricher<TChange>;
101
+ private readonly enrichers: Map<BranchId, EnricherState<TChange>> = new Map();
103
102
 
104
103
  public readonly mintRevisionTag: () => RevisionTag;
105
104
 
@@ -120,10 +119,10 @@ export class SharedTreeCore<TEditor extends ChangeFamilyEditor, TChange>
120
119
  public readonly submitLocalMessage: (content: unknown, localOpMetadata?: unknown) => void,
121
120
  logger: ITelemetryBaseLogger | undefined,
122
121
  summarizables: readonly Summarizable[],
123
- changeFamily: ChangeFamily<TEditor, TChange>,
122
+ protected readonly changeFamily: ChangeFamily<TEditor, TChange>,
124
123
  options: ICodecOptions,
125
124
  formatOptions: ExplicitCoreCodecVersions,
126
- private readonly idCompressor: IIdCompressor,
125
+ protected readonly idCompressor: IIdCompressor,
127
126
  schema: TreeStoredSchemaRepository,
128
127
  schemaPolicy: SchemaPolicy,
129
128
  resubmitMachine?: ResubmitMachine<TChange>,
@@ -154,17 +153,7 @@ export class SharedTreeCore<TEditor extends ChangeFamilyEditor, TChange>
154
153
  rebaseLogger,
155
154
  );
156
155
 
157
- this.editManager.localBranch.events.on("beforeChange", (change) => {
158
- if (this.detachedRevision === undefined) {
159
- // Commit enrichment is only necessary for changes that will be submitted as ops, and changes issued while detached are not submitted.
160
- this.commitEnricher.processChange(change);
161
- }
162
- if (change.type === "append") {
163
- for (const commit of change.newCommits) {
164
- this.submitCommit(commit, this.schemaAndPolicy, false);
165
- }
166
- }
167
- });
156
+ this.registerSharedBranch("main");
168
157
 
169
158
  const revisionTagCodec = new RevisionTagCodec(idCompressor);
170
159
  const editManagerCodec = makeEditManagerCodec(
@@ -194,15 +183,11 @@ export class SharedTreeCore<TEditor extends ChangeFamilyEditor, TChange>
194
183
  formatOptions.message,
195
184
  );
196
185
 
197
- const changeEnricher = enricher ?? new NoOpChangeEnricher();
198
- this.resubmitMachine =
199
- resubmitMachine ??
200
- new DefaultResubmitMachine(
201
- (change: TaggedChange<TChange>) =>
202
- changeFamily.rebaser.invert(change, true, this.mintRevisionTag()),
203
- changeEnricher,
204
- );
205
- this.commitEnricher = new BranchCommitEnricher(changeFamily.rebaser, changeEnricher);
186
+ this.registerSharedBranchForEditing(
187
+ "main",
188
+ enricher ?? new NoOpChangeEnricher(),
189
+ resubmitMachine,
190
+ );
206
191
  }
207
192
 
208
193
  // TODO: SharedObject's merging of the two summary methods into summarizeCore is not what we want here:
@@ -245,7 +230,7 @@ export class SharedTreeCore<TEditor extends ChangeFamilyEditor, TChange>
245
230
 
246
231
  public async loadCore(services: IChannelStorageService): Promise<void> {
247
232
  assert(
248
- this.editManager.localBranch.getHead() === this.editManager.getTrunkHead(),
233
+ this.getLocalBranch().getHead() === this.editManager.getTrunkHead("main"),
249
234
  0xaaa /* All local changes should be applied to the trunk before loading from summary */,
250
235
  );
251
236
  const [editManagerSummarizer, ...summarizables] = this.summarizables;
@@ -259,8 +244,7 @@ export class SharedTreeCore<TEditor extends ChangeFamilyEditor, TChange>
259
244
  // First, finish loading the edit manager so that we can inspect the sequence numbers of the commits on the trunk.
260
245
  await loadEditManager;
261
246
 
262
- const head = this.editManager.getTrunkHead();
263
- const latestDetachedSequenceNumber = this.editManager.getSequenceNumber(head);
247
+ const latestDetachedSequenceNumber = this.editManager.getLatestSequenceNumber();
264
248
  // When we load a summary for a tree that was never attached,
265
249
  // latestDetachedSequenceNumber is either undefined (no commits in summary) or negative (all commits in summary were made while detached).
266
250
  // We only need to update `this.detachedRevision` in the latter case.
@@ -273,6 +257,21 @@ export class SharedTreeCore<TEditor extends ChangeFamilyEditor, TChange>
273
257
  }
274
258
  }
275
259
 
260
+ private registerSharedBranch(branchId: BranchId): void {
261
+ this.editManager.getLocalBranch(branchId).events.on("beforeChange", (change) => {
262
+ if (change.type === "append") {
263
+ if (this.detachedRevision === undefined) {
264
+ // Commit enrichment is only necessary for changes that will be submitted as ops, and changes issued while detached are not submitted.
265
+ this.getCommitEnricher(branchId).processChange(change);
266
+ }
267
+
268
+ for (const commit of change.newCommits) {
269
+ this.submitCommit(branchId, commit, this.schemaAndPolicy, false);
270
+ }
271
+ }
272
+ });
273
+ }
274
+
276
275
  private async loadSummarizable(
277
276
  summarizable: Summarizable,
278
277
  services: IChannelStorageService,
@@ -290,6 +289,7 @@ export class SharedTreeCore<TEditor extends ChangeFamilyEditor, TChange>
290
289
  * and may differ from `commit` due to enrichments like detached tree refreshers.
291
290
  */
292
291
  protected submitCommit(
292
+ branchId: BranchId,
293
293
  commit: GraphCommit<TChange>,
294
294
  schemaAndPolicy: ClonableSchemaAndPolicy,
295
295
  isResubmit: boolean,
@@ -301,7 +301,7 @@ export class SharedTreeCore<TEditor extends ChangeFamilyEditor, TChange>
301
301
 
302
302
  const enrichedCommit =
303
303
  this.detachedRevision === undefined && !isResubmit
304
- ? this.commitEnricher.enrich(commit)
304
+ ? this.getCommitEnricher(branchId).enrich(commit)
305
305
  : commit;
306
306
 
307
307
  // Edits submitted before the first attach are treated as sequenced because they will be included
@@ -319,22 +319,40 @@ export class SharedTreeCore<TEditor extends ChangeFamilyEditor, TChange>
319
319
  this.editManager.advanceMinimumSequenceNumber(newRevision, false);
320
320
  return undefined;
321
321
  }
322
- const message = this.messageCodec.encode(
322
+
323
+ this.submitMessage(
323
324
  {
325
+ type: "commit",
324
326
  commit: enrichedCommit,
325
327
  sessionId: this.editManager.localSessionId,
328
+ branchId,
326
329
  },
327
- {
328
- idCompressor: this.idCompressor,
329
- schema: schemaAndPolicy,
330
- },
330
+ schemaAndPolicy,
331
331
  );
332
- this.submitLocalMessage(message, {
332
+
333
+ this.getResubmitMachine(branchId).onCommitSubmitted(enrichedCommit);
334
+ }
335
+
336
+ protected submitBranchCreation(branchId: BranchId): void {
337
+ this.submitMessage(
338
+ { type: "branch", sessionId: this.editManager.localSessionId, branchId },
339
+ this.schemaAndPolicy,
340
+ );
341
+ }
342
+
343
+ private submitMessage(
344
+ message: DecodedMessage<TChange>,
345
+ schemaAndPolicy: ClonableSchemaAndPolicy,
346
+ ): void {
347
+ const encodedMessage = this.messageCodec.encode(message, {
348
+ idCompressor: this.idCompressor,
349
+ schema: schemaAndPolicy,
350
+ });
351
+ this.submitLocalMessage(encodedMessage, {
333
352
  // Clone the schema to ensure that during resubmit the schema has not been mutated by later changes
334
353
  schema: schemaAndPolicy.schema.clone(),
335
354
  policy: schemaAndPolicy.policy,
336
355
  });
337
- this.resubmitMachine.onCommitSubmitted(enrichedCommit);
338
356
  }
339
357
 
340
358
  /**
@@ -344,43 +362,113 @@ export class SharedTreeCore<TEditor extends ChangeFamilyEditor, TChange>
344
362
  const { envelope, local, messagesContent } = messagesCollection;
345
363
  const commits: GraphCommit<TChange>[] = [];
346
364
  let messagesSessionId: SessionId | undefined;
365
+ let branchId: BranchId | undefined;
366
+
367
+ const processBunch = (branch: BranchId): void => {
368
+ assert(messagesSessionId !== undefined, 0xada /* Messages must have a session ID */);
369
+ this.processCommits(
370
+ messagesSessionId,
371
+ brand(envelope.sequenceNumber),
372
+ brand(envelope.referenceSequenceNumber),
373
+ local,
374
+ branch,
375
+ commits,
376
+ );
377
+
378
+ commits.length = 0;
379
+ };
347
380
 
348
381
  // Get a list of all the commits from the messages.
349
382
  for (const messageContent of messagesContent) {
350
383
  // Empty context object is passed in, as our decode function is schema-agnostic.
351
- const { commit, sessionId } = this.messageCodec.decode(messageContent.contents, {
384
+ const message = this.messageCodec.decode(messageContent.contents, {
352
385
  idCompressor: this.idCompressor,
353
386
  });
354
- commits.push(commit);
355
387
 
356
388
  if (messagesSessionId !== undefined) {
357
389
  assert(
358
- messagesSessionId === sessionId,
390
+ messagesSessionId === message.sessionId,
359
391
  0xad9 /* All messages in a bunch must have the same session ID */,
360
392
  );
361
393
  }
362
- messagesSessionId = sessionId;
394
+ messagesSessionId = message.sessionId;
395
+
396
+ const type = message.type;
397
+ switch (type) {
398
+ case "commit": {
399
+ if (branchId !== undefined && message.branchId !== branchId) {
400
+ processBunch(branchId);
401
+ }
402
+
403
+ branchId = message.branchId;
404
+ commits.push(message.commit);
405
+ break;
406
+ }
407
+ case "branch": {
408
+ if (branchId !== undefined) {
409
+ processBunch(branchId);
410
+ }
411
+ this.editManager.sequenceBranchCreation(
412
+ messagesSessionId,
413
+ brand(envelope.referenceSequenceNumber),
414
+ message.branchId,
415
+ );
416
+
417
+ this.registerSharedBranch(message.branchId);
418
+ break;
419
+ }
420
+ default:
421
+ unreachableCase(type);
422
+ }
423
+ }
424
+
425
+ if (branchId !== undefined) {
426
+ processBunch(branchId);
363
427
  }
364
428
 
365
- assert(messagesSessionId !== undefined, 0xada /* Messages must have a session ID */);
429
+ this.editManager.advanceMinimumSequenceNumber(brand(envelope.minimumSequenceNumber));
430
+ }
366
431
 
432
+ private processCommits(
433
+ sessionId: SessionId,
434
+ sequenceNumber: SeqNumber,
435
+ referenceSequenceNumber: SeqNumber,
436
+ isLocal: boolean,
437
+ branchId: BranchId,
438
+ commits: readonly GraphCommit<TChange>[],
439
+ ): void {
367
440
  this.editManager.addSequencedChanges(
368
441
  commits,
369
- messagesSessionId,
370
- brand(envelope.sequenceNumber),
371
- brand(envelope.referenceSequenceNumber),
442
+ sessionId,
443
+ sequenceNumber,
444
+ referenceSequenceNumber,
445
+ branchId,
372
446
  );
373
447
 
374
448
  // Update the resubmit machine for each commit applied.
375
- for (const _ of messagesContent) {
376
- this.resubmitMachine.onSequencedCommitApplied(local);
449
+ for (const _ of commits) {
450
+ this.tryGetResubmitMachine(branchId)?.onSequencedCommitApplied(isLocal);
377
451
  }
378
-
379
- this.editManager.advanceMinimumSequenceNumber(brand(envelope.minimumSequenceNumber));
380
452
  }
381
453
 
382
454
  public getLocalBranch(): SharedTreeBranch<TEditor, TChange> {
383
- return this.editManager.localBranch;
455
+ return this.editManager.getLocalBranch("main");
456
+ }
457
+
458
+ public createSharedBranch(): string {
459
+ const branchId = this.idCompressor.generateCompressedId();
460
+ this.addBranch(branchId);
461
+ this.submitBranchCreation(branchId);
462
+ return this.idCompressor.decompress(branchId);
463
+ }
464
+
465
+ protected addBranch(branchId: BranchId): void {
466
+ this.editManager.addBranch(branchId);
467
+ this.registerSharedBranch(branchId);
468
+ }
469
+
470
+ public getSharedBranch(branchId: BranchId): SharedTreeBranch<TEditor, TChange> {
471
+ return this.editManager.getLocalBranch(branchId);
384
472
  }
385
473
 
386
474
  public didAttach(): void {
@@ -389,52 +477,150 @@ export class SharedTreeCore<TEditor extends ChangeFamilyEditor, TChange>
389
477
 
390
478
  public reSubmitCore(content: JsonCompatibleReadOnly, localOpMetadata: unknown): void {
391
479
  // Empty context object is passed in, as our decode function is schema-agnostic.
392
- const {
393
- commit: { revision },
394
- } = this.messageCodec.decode(this.serializer.decode(content), {
480
+ const message = this.messageCodec.decode(this.serializer.decode(content), {
395
481
  idCompressor: this.idCompressor,
396
482
  });
397
- // If a resubmit phase is not already in progress, then this must be the first commit of a new resubmit phase.
398
- if (this.resubmitMachine.isInResubmitPhase === false) {
399
- const localCommits = this.editManager.getLocalCommits();
400
- const revisionIndex = localCommits.findIndex((c) => c.revision === revision);
401
- assert(revisionIndex >= 0, 0xbdb /* revision must exist in local commits */);
402
- const toResubmit = localCommits.slice(revisionIndex);
403
- this.resubmitMachine.prepareForResubmit(toResubmit);
483
+
484
+ const type = message.type;
485
+ switch (type) {
486
+ case "commit": {
487
+ const {
488
+ commit: { revision },
489
+ branchId,
490
+ } = message;
491
+
492
+ const resubmitMachine = this.getResubmitMachine(branchId);
493
+ // If a resubmit phase is not already in progress, then this must be the first commit of a new resubmit phase.
494
+ if (resubmitMachine.isInResubmitPhase === false) {
495
+ const localCommits = this.editManager.getLocalCommits(branchId);
496
+ const revisionIndex = localCommits.findIndex((c) => c.revision === revision);
497
+ assert(revisionIndex >= 0, 0xbdb /* revision must exist in local commits */);
498
+ const toResubmit = localCommits.slice(revisionIndex);
499
+ resubmitMachine.prepareForResubmit(toResubmit);
500
+ }
501
+ assert(
502
+ isClonableSchemaPolicy(localOpMetadata),
503
+ 0x95e /* Local metadata must contain schema and policy. */,
504
+ );
505
+ assert(
506
+ resubmitMachine.isInResubmitPhase !== false,
507
+ 0x984 /* Invalid resubmit outside of resubmit phase */,
508
+ );
509
+ const enrichedCommit = resubmitMachine.peekNextCommit();
510
+ this.submitCommit(branchId, enrichedCommit, localOpMetadata, true);
511
+ break;
512
+ }
513
+ case "branch": {
514
+ this.submitBranchCreation(message.branchId);
515
+ break;
516
+ }
517
+ default:
518
+ unreachableCase(type);
404
519
  }
405
- assert(
406
- isClonableSchemaPolicy(localOpMetadata),
407
- 0x95e /* Local metadata must contain schema and policy. */,
408
- );
409
- assert(
410
- this.resubmitMachine.isInResubmitPhase !== false,
411
- 0x984 /* Invalid resubmit outside of resubmit phase */,
412
- );
413
- const enrichedCommit = this.resubmitMachine.peekNextCommit();
414
- this.submitCommit(enrichedCommit, localOpMetadata, true);
415
520
  }
521
+
416
522
  public rollback(content: JsonCompatibleReadOnly, localOpMetadata: unknown): void {
417
523
  // Empty context object is passed in, as our decode function is schema-agnostic.
418
- const {
419
- commit: { revision },
420
- } = this.messageCodec.decode(this.serializer.decode(content), {
524
+ const message = this.messageCodec.decode(this.serializer.decode(content), {
421
525
  idCompressor: this.idCompressor,
422
526
  });
423
- const [commit] = this.editManager.findLocalCommit(revision);
424
- const { parent } = commit;
425
- assert(parent !== undefined, 0xbdc /* must have parent */);
426
- const [precedingCommit] = this.editManager.findLocalCommit(parent.revision);
427
- this.editManager.localBranch.removeAfter(precedingCommit);
428
- this.resubmitMachine.onCommitRollback(commit);
527
+
528
+ const type = message.type;
529
+ switch (type) {
530
+ case "commit": {
531
+ const {
532
+ commit: { revision },
533
+ branchId,
534
+ } = message;
535
+ const branch = this.editManager.getLocalBranch(branchId);
536
+ const head = branch.getHead();
537
+ assert(head.revision === revision, "Can only rollback latest commit");
538
+ const newHead = head.parent ?? fail("must have parent");
539
+ branch.removeAfter(newHead);
540
+ this.getResubmitMachine(branchId).onCommitRollback(head);
541
+ break;
542
+ }
543
+ case "branch": {
544
+ this.editManager.removeBranch(message.branchId);
545
+ break;
546
+ }
547
+ default:
548
+ unreachableCase(type);
549
+ }
429
550
  }
430
551
 
431
552
  public applyStashedOp(content: JsonCompatibleReadOnly): void {
432
553
  // Empty context object is passed in, as our decode function is schema-agnostic.
433
- const {
434
- commit: { revision, change },
435
- } = this.messageCodec.decode(content, { idCompressor: this.idCompressor });
436
- this.editManager.localBranch.apply({ change, revision });
554
+ const message = this.messageCodec.decode(this.serializer.decode(content), {
555
+ idCompressor: this.idCompressor,
556
+ });
557
+
558
+ const type = message.type;
559
+ switch (type) {
560
+ case "commit": {
561
+ const {
562
+ commit: { revision, change },
563
+ branchId,
564
+ } = message;
565
+ this.editManager.getLocalBranch(branchId).apply({ change, revision });
566
+ break;
567
+ }
568
+ case "branch": {
569
+ this.editManager.addBranch(message.branchId);
570
+ break;
571
+ }
572
+ default:
573
+ unreachableCase(type);
574
+ }
575
+ }
576
+
577
+ protected registerSharedBranchForEditing(
578
+ branchId: BranchId,
579
+ enricher: ChangeEnricherReadonlyCheckout<TChange>,
580
+ resubmitMachine?: ResubmitMachine<TChange>,
581
+ ): void {
582
+ const changeEnricher = enricher ?? new NoOpChangeEnricher();
583
+ const commitEnricher = new BranchCommitEnricher(this.changeFamily.rebaser, changeEnricher);
584
+ assert(!this.enrichers.has(branchId), "Branch already registered");
585
+ this.enrichers.set(branchId, {
586
+ enricher: commitEnricher,
587
+ resubmitMachine:
588
+ resubmitMachine ??
589
+ new DefaultResubmitMachine(
590
+ (change: TaggedChange<TChange>) =>
591
+ this.changeFamily.rebaser.invert(change, true, this.mintRevisionTag()),
592
+ changeEnricher,
593
+ ),
594
+ });
595
+ }
596
+
597
+ private getResubmitMachine(branchId: BranchId): ResubmitMachine<TChange> {
598
+ return this.getEnricherState(branchId).resubmitMachine;
437
599
  }
600
+
601
+ private tryGetResubmitMachine(branchId: BranchId): ResubmitMachine<TChange> | undefined {
602
+ return this.tryGetEnricherState(branchId)?.resubmitMachine;
603
+ }
604
+
605
+ public getCommitEnricher(branchId: BranchId): BranchCommitEnricher<TChange> {
606
+ return this.getEnricherState(branchId).enricher;
607
+ }
608
+
609
+ private getEnricherState(branchId: BranchId): EnricherState<TChange> {
610
+ return (
611
+ this.tryGetEnricherState(branchId) ??
612
+ fail("Expected to have a resubmit machine for this branch")
613
+ );
614
+ }
615
+
616
+ private tryGetEnricherState(branchId: BranchId): EnricherState<TChange> | undefined {
617
+ return this.enrichers.get(branchId);
618
+ }
619
+ }
620
+
621
+ interface EnricherState<TChange> {
622
+ readonly enricher: BranchCommitEnricher<TChange>;
623
+ readonly resubmitMachine: ResubmitMachine<TChange>;
438
624
  }
439
625
 
440
626
  function isClonableSchemaPolicy(
@@ -99,6 +99,21 @@ export interface ITreeAlpha extends ITree {
99
99
  * To get the schema using property keys, use {@link getSimpleSchema} on the view schema.
100
100
  */
101
101
  exportSimpleSchema(): SimpleTreeSchema;
102
+
103
+ /**
104
+ * Creates a fork of the current state of the main branch.
105
+ * This new branch will be shared with and editable by all clients.
106
+ */
107
+ createSharedBranch(): string;
108
+
109
+ /**
110
+ * Returns a view of the tree on the specified shared branch, using the provided schema.
111
+ * See {@link ViewableTree.viewWith}.
112
+ */
113
+ viewSharedBranchWith<TRoot extends ImplicitFieldSchema>(
114
+ branchId: string,
115
+ config: TreeViewConfiguration<TRoot>,
116
+ ): TreeView<TRoot>;
102
117
  }
103
118
 
104
119
  /**
@@ -1 +0,0 @@
1
- {"version":3,"file":"editManagerFormat.d.ts","sourceRoot":"","sources":["../../src/shared-tree-core/editManagerFormat.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAC/D,OAAO,EAAsB,KAAK,MAAM,EAAE,KAAK,OAAO,EAAQ,MAAM,mBAAmB,CAAC;AAExF,OAAO,EACN,KAAK,kBAAkB,EACvB,KAAK,WAAW,EAGhB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,KAAK,KAAK,EAAqB,MAAM,kBAAkB,CAAC;AAEjE;;;;;GAKG;AACH,MAAM,WAAW,MAAM,CAAC,UAAU;IACjC,QAAQ,CAAC,QAAQ,EAAE,WAAW,CAAC;IAC/B,QAAQ,CAAC,MAAM,EAAE,UAAU,CAAC;IAC5B,+EAA+E;IAC/E,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAC;CAC9B;AAGD,MAAM,MAAM,aAAa,CAAC,UAAU,IAAI;IACvC,QAAQ,CAAC,QAAQ,EAAE,kBAAkB,CAAC;IACtC,QAAQ,CAAC,MAAM,EAAE,UAAU,CAAC;IAC5B,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAC;CAC9B,CAAC;AAoBF,MAAM,MAAM,SAAS,GAAG,KAAK,CAAC,MAAM,EAAE,wBAAwB,CAAC,CAAC;AAGhE,QAAA,MAAM,UAAU;;;EAGd,CAAC;AAEH,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC,OAAO,UAAU,CAAC,CAAC;AAEnD;;GAEG;AACH,MAAM,WAAW,eAAe,CAAC,UAAU,CAAE,SAAQ,MAAM,CAAC,UAAU,CAAC,EAAE,UAAU;CAAG;AAKtF;;;;;GAKG;A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B,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;CAClF,EACD,iBAAiB,CACjB,CAAC;AAbU,QAAA,kBAAkB,sBAa5B;AAEH,oEAAoE","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 ObjectOptions, type Static, type TSchema, Type } from \"@sinclair/typebox\";\n\nimport {\n\ttype EncodedRevisionTag,\n\ttype RevisionTag,\n\tRevisionTagSchema,\n\tSessionIdSchema,\n} from \"../core/index.js\";\nimport { type Brand, brandedNumberType } from \"../util/index.js\";\n\n/**\n * Contains a single change to the `SharedTree` and associated metadata.\n *\n * TODO: if this type is not used in the encoded format, move it out of this file, and stop using it in EncodedEditManager.\n * If this is an encoded format, clarify the difference between it and EncodedCommit.\n */\nexport interface Commit<TChangeset> {\n\treadonly revision: RevisionTag;\n\treadonly change: TChangeset;\n\t/** An identifier representing the session/user/client that made this commit */\n\treadonly sessionId: SessionId;\n}\n\n// eslint-disable-next-line @typescript-eslint/consistent-type-definitions\nexport type EncodedCommit<TChangeset> = {\n\treadonly revision: EncodedRevisionTag;\n\treadonly change: TChangeset;\n\treadonly sessionId: SessionId;\n};\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\nconst CommitBase = <ChangeSchema extends TSchema>(tChange: ChangeSchema) =>\n\tType.Object({\n\t\trevision: RevisionTagSchema,\n\t\tchange: tChange,\n\t\tsessionId: SessionIdSchema,\n\t});\n/**\n * @privateRemarks Commits are generally encoded from `GraphCommit`s, which often contain extra data.\n * This `noAdditionalProps` is especially important in that light.\n */\nconst Commit = <ChangeSchema extends TSchema>(tChange: ChangeSchema) =>\n\tType.Composite([CommitBase(tChange)], noAdditionalProps);\n\nexport type SeqNumber = Brand<number, \"edit-manager.SeqNumber\">;\nconst SeqNumber = brandedNumberType<SeqNumber>({ multipleOf: 1 });\n\nconst SequenceId = Type.Object({\n\tsequenceNumber: SeqNumber,\n\tindexInBatch: Type.Optional(Type.Number({ multipleOf: 1, minimum: 0 })),\n});\n\nexport type SequenceId = Static<typeof SequenceId>;\n\n/**\n * A commit with a sequence number but no parentage; used for serializing the `EditManager` into a summary\n */\nexport interface SequencedCommit<TChangeset> extends Commit<TChangeset>, SequenceId {}\n\nconst SequencedCommit = <ChangeSchema extends TSchema>(tChange: ChangeSchema) =>\n\tType.Composite([CommitBase(tChange), SequenceId], noAdditionalProps);\n\n/**\n * A branch off of the trunk for use in summaries.\n *\n * TODO: if this type is not used in the encoded format, move it out of this file, and stop using it in EncodedEditManager.\n * If this is an encoded format, use EncodedCommit instead of Commit or clarify that Commit is also an encoded format.\n */\nexport interface SummarySessionBranch<TChangeset> {\n\treadonly base: RevisionTag;\n\treadonly commits: Commit<TChangeset>[];\n}\n\nexport interface EncodedSummarySessionBranch<TChangeset> {\n\treadonly base: EncodedRevisionTag;\n\treadonly commits: Commit<TChangeset>[];\n}\n\nconst SummarySessionBranch = <ChangeSchema extends TSchema>(tChange: ChangeSchema) =>\n\tType.Object(\n\t\t{\n\t\t\tbase: RevisionTagSchema,\n\t\t\tcommits: Type.Array(Commit(tChange)),\n\t\t},\n\t\tnoAdditionalProps,\n\t);\n\nexport interface EncodedEditManager<TChangeset> {\n\treadonly trunk: readonly Readonly<SequencedCommit<TChangeset>>[];\n\treadonly branches: readonly [SessionId, Readonly<EncodedSummarySessionBranch<TChangeset>>][];\n\treadonly version: 1 | 2 | 3 | 4;\n}\n\nexport const EncodedEditManager = <ChangeSchema extends TSchema>(tChange: ChangeSchema) =>\n\tType.Object(\n\t\t{\n\t\t\tversion: Type.Union([\n\t\t\t\tType.Literal(1),\n\t\t\t\tType.Literal(2),\n\t\t\t\tType.Literal(3),\n\t\t\t\tType.Literal(4),\n\t\t\t]),\n\t\t\ttrunk: Type.Array(SequencedCommit(tChange)),\n\t\t\tbranches: Type.Array(Type.Tuple([SessionIdSchema, SummarySessionBranch(tChange)])),\n\t\t},\n\t\tnoAdditionalProps,\n\t);\n\n/* eslint-enable @typescript-eslint/explicit-function-return-type */\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"messageFormat.d.ts","sourceRoot":"","sources":["../../src/shared-tree-core/messageFormat.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"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"messageFormat.js","sourceRoot":"","sources":["../../src/shared-tree-core/messageFormat.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,+CAAuD;AAEvD,+CAA+F;AA6B/F,wCAAwC;AACxC,4EAA4E;AACrE,MAAM,OAAO,GAAG,CAA+B,OAAqB,EAAE,EAAE,CAC9E,cAAI,CAAC,MAAM,CAAC;IACX,QAAQ,EAAE,4BAAiB;IAC3B,YAAY,EAAE,0BAAe;IAC7B,SAAS,EAAE,OAAO;IAClB,OAAO,EAAE,cAAI,CAAC,QAAQ,CAAC,cAAI,CAAC,MAAM,EAAE,CAAC;CACrC,CAAC,CAAC;AANS,QAAA,OAAO,WAMhB","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"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"editManagerFormat.d.ts","sourceRoot":"","sources":["../../src/shared-tree-core/editManagerFormat.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAC/D,OAAO,EAAsB,KAAK,MAAM,EAAE,KAAK,OAAO,EAAQ,MAAM,mBAAmB,CAAC;AAExF,OAAO,EACN,KAAK,kBAAkB,EACvB,KAAK,WAAW,EAGhB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,KAAK,KAAK,EAAqB,MAA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CAAC;AASH,MAAM,eAAe,GAAG,CAA+B,OAAqB,EAAE,EAAE,CAC/E,IAAI,CAAC,SAAS,CAAC,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,UAAU,CAAC,EAAE,iBAAiB,CAAC,CAAC;AAkBtE,MAAM,oBAAoB,GAAG,CAA+B,OAAqB,EAAE,EAAE,CACpF,IAAI,CAAC,MAAM,CACV;IACC,IAAI,EAAE,iBAAiB;IACvB,OAAO,EAAE,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;CACpC,EACD,iBAAiB,CACjB,CAAC;AAQH,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAA+B,OAAqB,EAAE,EAAE,CACzF,IAAI,CAAC,MAAM,CACV;IACC,OAAO,EAAE,IAAI,CAAC,KAAK,CAAC;QACnB,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;QACf,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;QACf,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;QACf,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;KACf,CAAC;IACF,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC;IAC3C,QAAQ,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,eAAe,EAAE,oBAAoB,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;CAClF,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 { SessionId } from \"@fluidframework/id-compressor\";\nimport { type ObjectOptions, type Static, type TSchema, Type } from \"@sinclair/typebox\";\n\nimport {\n\ttype EncodedRevisionTag,\n\ttype RevisionTag,\n\tRevisionTagSchema,\n\tSessionIdSchema,\n} from \"../core/index.js\";\nimport { type Brand, brandedNumberType } from \"../util/index.js\";\n\n/**\n * Contains a single change to the `SharedTree` and associated metadata.\n *\n * TODO: if this type is not used in the encoded format, move it out of this file, and stop using it in EncodedEditManager.\n * If this is an encoded format, clarify the difference between it and EncodedCommit.\n */\nexport interface Commit<TChangeset> {\n\treadonly revision: RevisionTag;\n\treadonly change: TChangeset;\n\t/** An identifier representing the session/user/client that made this commit */\n\treadonly sessionId: SessionId;\n}\n\n// eslint-disable-next-line @typescript-eslint/consistent-type-definitions\nexport type EncodedCommit<TChangeset> = {\n\treadonly revision: EncodedRevisionTag;\n\treadonly change: TChangeset;\n\treadonly sessionId: SessionId;\n};\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\nconst CommitBase = <ChangeSchema extends TSchema>(tChange: ChangeSchema) =>\n\tType.Object({\n\t\trevision: RevisionTagSchema,\n\t\tchange: tChange,\n\t\tsessionId: SessionIdSchema,\n\t});\n/**\n * @privateRemarks Commits are generally encoded from `GraphCommit`s, which often contain extra data.\n * This `noAdditionalProps` is especially important in that light.\n */\nconst Commit = <ChangeSchema extends TSchema>(tChange: ChangeSchema) =>\n\tType.Composite([CommitBase(tChange)], noAdditionalProps);\n\nexport type SeqNumber = Brand<number, \"edit-manager.SeqNumber\">;\nconst SeqNumber = brandedNumberType<SeqNumber>({ multipleOf: 1 });\n\nconst SequenceId = Type.Object({\n\tsequenceNumber: SeqNumber,\n\tindexInBatch: Type.Optional(Type.Number({ multipleOf: 1, minimum: 0 })),\n});\n\nexport type SequenceId = Static<typeof SequenceId>;\n\n/**\n * A commit with a sequence number but no parentage; used for serializing the `EditManager` into a summary\n */\nexport interface SequencedCommit<TChangeset> extends Commit<TChangeset>, SequenceId {}\n\nconst SequencedCommit = <ChangeSchema extends TSchema>(tChange: ChangeSchema) =>\n\tType.Composite([CommitBase(tChange), SequenceId], noAdditionalProps);\n\n/**\n * A branch off of the trunk for use in summaries.\n *\n * TODO: if this type is not used in the encoded format, move it out of this file, and stop using it in EncodedEditManager.\n * If this is an encoded format, use EncodedCommit instead of Commit or clarify that Commit is also an encoded format.\n */\nexport interface SummarySessionBranch<TChangeset> {\n\treadonly base: RevisionTag;\n\treadonly commits: Commit<TChangeset>[];\n}\n\nexport interface EncodedSummarySessionBranch<TChangeset> {\n\treadonly base: EncodedRevisionTag;\n\treadonly commits: Commit<TChangeset>[];\n}\n\nconst SummarySessionBranch = <ChangeSchema extends TSchema>(tChange: ChangeSchema) =>\n\tType.Object(\n\t\t{\n\t\t\tbase: RevisionTagSchema,\n\t\t\tcommits: Type.Array(Commit(tChange)),\n\t\t},\n\t\tnoAdditionalProps,\n\t);\n\nexport interface EncodedEditManager<TChangeset> {\n\treadonly trunk: readonly Readonly<SequencedCommit<TChangeset>>[];\n\treadonly branches: readonly [SessionId, Readonly<EncodedSummarySessionBranch<TChangeset>>][];\n\treadonly version: 1 | 2 | 3 | 4;\n}\n\nexport const EncodedEditManager = <ChangeSchema extends TSchema>(tChange: ChangeSchema) =>\n\tType.Object(\n\t\t{\n\t\t\tversion: Type.Union([\n\t\t\t\tType.Literal(1),\n\t\t\t\tType.Literal(2),\n\t\t\t\tType.Literal(3),\n\t\t\t\tType.Literal(4),\n\t\t\t]),\n\t\t\ttrunk: Type.Array(SequencedCommit(tChange)),\n\t\t\tbranches: Type.Array(Type.Tuple([SessionIdSchema, SummarySessionBranch(tChange)])),\n\t\t},\n\t\tnoAdditionalProps,\n\t);\n\n/* eslint-enable @typescript-eslint/explicit-function-return-type */\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"messageFormat.d.ts","sourceRoot":"","sources":["../../src/shared-tree-core/messageFormat.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"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"messageFormat.js","sourceRoot":"","sources":["../../src/shared-tree-core/messageFormat.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"]}