@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
@@ -43,25 +43,11 @@ class EditManager {
43
43
  this.localSessionId = localSessionId;
44
44
  this.mintRevisionTag = mintRevisionTag;
45
45
  this._events = (0, client_utils_1.createEmitter)();
46
+ this.sharedBranches = new Map();
46
47
  /**
47
- * Records extra data associated with commits in the {@link trunk}.
48
- * This does not include an entry for the {@link trunkBase}.
49
- */
50
- this.trunkMetadata = new Map();
51
- /**
52
- * A map from a sequence id to the commit in the {@link trunk} which has that sequence id.
53
- * This also includes an entry for the {@link trunkBase} which always has the lowest key in the map.
54
- */
55
- this.sequenceMap = new sorted_btree_es6_1.BTree(undefined, sequenceIdUtils_js_1.sequenceIdComparator);
56
- /**
57
- * Branches are maintained to represent the local change list that the issuing client had
58
- * at the time of submitting the latest known edit on the branch.
59
- * This means the head commit of each branch is always in its original (non-rebased) form.
60
- */
61
- this.peerLocalBranches = new Map();
62
- /**
63
- * Tracks where on the trunk all registered branches are based. Each key is the sequence id of a commit on
64
- * the trunk, and the value is the set of all branches who have that commit as their common ancestor with the trunk.
48
+ * Tracks where on the trunk of the main branch all registered branches are based.
49
+ * Each key is the sequence id of a commit on the trunk,
50
+ * and the value is the set of all branches who have that commit as their common ancestor with the trunk.
65
51
  *
66
52
  * @remarks
67
53
  * This does not include the local branch.
@@ -74,39 +60,28 @@ class EditManager {
74
60
  * @remarks If there are more than one commit with the same sequence number we assume this refers to the last commit in the batch.
75
61
  */
76
62
  this.minimumSequenceNumber = exports.minimumPossibleSequenceNumber;
77
- /**
78
- * The list of commits (from oldest to most recent) that are on the local branch but not on the trunk.
79
- * When a local commit is sequenced, the first commit in this list shifted onto the tip of the trunk.
80
- */
81
- this.localCommits = [];
82
63
  this.trunkBase = {
83
64
  revision: rootRevision,
84
65
  change: changeFamily.rebaser.compose([]),
85
66
  };
86
- this.sequenceMap.set(minimumPossibleSequenceId, this.trunkBase);
87
67
  if (logger !== undefined) {
88
68
  this.telemetryEventBatcher = new internal_2.TelemetryEventBatcher({
89
69
  eventName: "rebaseProcessing",
90
70
  category: "performance",
91
71
  }, logger, maxRebaseStatsAggregationCount);
92
72
  }
93
- this.trunk = new branch_js_1.SharedTreeBranch(this.trunkBase, changeFamily, mintRevisionTag, this._events, this.telemetryEventBatcher);
94
- this.localBranch = new branch_js_1.SharedTreeBranch(this.trunk.getHead(), changeFamily, mintRevisionTag, this._events, this.telemetryEventBatcher);
95
- this.localBranch.events.on("afterChange", (event) => {
96
- if (event.type === "append") {
97
- for (const commit of event.newCommits) {
98
- this.localCommits.push(commit);
99
- }
100
- }
101
- else {
102
- this.localCommits.length = 0;
103
- (0, index_js_1.findCommonAncestor)([this.localBranch.getHead(), this.localCommits], this.trunk.getHead());
104
- }
105
- });
73
+ const mainTrunk = new branch_js_1.SharedTreeBranch(this.trunkBase, changeFamily, mintRevisionTag, this._events, this.telemetryEventBatcher);
74
+ const mainBranch = this.createSharedBranch("main", undefined, undefined, mainTrunk);
106
75
  // Track all forks of the local branch for purposes of trunk eviction. Unlike the local branch, they have
107
76
  // an unknown lifetime and rebase frequency, so we can not make any assumptions about which trunk commits
108
77
  // they require and therefore we monitor them explicitly.
109
- (0, branch_js_1.onForkTransitive)(this.localBranch, (fork) => this.registerBranch(fork));
78
+ (0, branch_js_1.onForkTransitive)(mainBranch.localBranch, (fork) => this.registerBranch(fork));
79
+ }
80
+ getLocalBranch(branchId) {
81
+ return this.getSharedBranch(branchId).localBranch;
82
+ }
83
+ getSharedBranch(branchId) {
84
+ return this.sharedBranches.get(branchId) ?? (0, internal_1.fail)("Branch does not exist");
110
85
  }
111
86
  /**
112
87
  * Make the given branch known to the `EditManager`. The `EditManager` will ensure that all registered
@@ -128,30 +103,32 @@ class EditManager {
128
103
  const offAfterRebase = branch.events.on("afterChange", (args) => {
129
104
  if (args.type === "rebase") {
130
105
  this.trackBranch(branch);
131
- this.trimTrunk();
106
+ this.trimHistory();
132
107
  }
133
108
  });
134
109
  // When the branch is disposed, update our branch set and trim the trunk
135
110
  const offDispose = branch.events.on("dispose", () => {
136
111
  this.untrackBranch(branch);
137
- this.trimTrunk();
112
+ this.trimHistory();
138
113
  offBeforeRebase();
139
114
  offAfterRebase();
140
115
  offDispose();
141
116
  });
142
117
  }
143
118
  trackBranch(b) {
144
- const trunkCommit = (0, index_js_1.findCommonAncestor)(this.trunk.getHead(), b.getHead()) ??
145
- (0, internal_1.fail)(0xad2 /* Expected branch to be related to trunk */);
146
- const sequenceId = this.getCommitSequenceId(trunkCommit);
119
+ const main = this.getSharedBranch("main");
120
+ const trunkCommit = (0, index_js_1.findCommonAncestor)(main.trunk.getHead(), b.getHead()) ??
121
+ (0, internal_1.fail)(0xad2 /* Expected branch to be related to main */);
122
+ const sequenceId = main.getCommitSequenceId(trunkCommit.revision);
147
123
  const branches = (0, index_js_2.getOrCreate)(this.trunkBranches, sequenceId, () => new Set());
148
124
  (0, internal_1.assert)(!branches.has(b), 0x670 /* Branch was registered more than once */);
149
125
  branches.add(b);
150
126
  }
151
127
  untrackBranch(b) {
152
- const trunkCommit = (0, index_js_1.findCommonAncestor)(this.trunk.getHead(), b.getHead()) ??
153
- (0, internal_1.fail)(0xad3 /* Expected branch to be related to trunk */);
154
- const sequenceId = this.getCommitSequenceId(trunkCommit);
128
+ const main = this.getSharedBranch("main");
129
+ const trunkCommit = (0, index_js_1.findCommonAncestor)(main.trunk.getHead(), b.getHead()) ??
130
+ (0, internal_1.fail)(0xad3 /* Expected branch to be related to main */);
131
+ const sequenceId = main.getCommitSequenceId(trunkCommit.revision);
155
132
  const branches = this.trunkBranches.get(sequenceId) ?? (0, internal_1.fail)(0xad4 /* Expected branch to be tracked */);
156
133
  (0, internal_1.assert)(branches.delete(b), 0x671 /* Expected branch to be tracked */);
157
134
  if (branches.size === 0) {
@@ -159,54 +136,17 @@ class EditManager {
159
136
  }
160
137
  }
161
138
  /**
162
- * Promote the oldest un-sequenced commit on the local branch to the head of the trunk.
163
- * @param sequenceId - The sequence id of the new trunk commit
164
- * @remarks This method is a performance optimization for the scenario where this client receives its own change back after sequencing.
165
- * The normal (not optimized) process in this case would be to apply the new sequenced commit to the trunk and then rebase the local branch over the trunk.
166
- * The first commit will be "the same" (as in, it will have the same revision) as the commit that was just sequenced, so the rebase will be a no-op.
167
- * Because the rebase is a no-op, we can skip it entirely and simply remove the commit from the local branch and append it to the trunk.
168
- * Avoiding the overhead of the rebase process, even when it's a no-op, has real measured performance benefits and is worth the added complexity here.
139
+ * Return the sequenced number of the latest sequenced change.
169
140
  */
170
- fastForwardNextLocalCommit(sequenceId) {
171
- // First, push the local commit to the trunk.
172
- // We are mutating our `localCommits` cache here, but there is no need to actually change the `localBranch` itself because it will simply catch up later if/when it next rebases.
173
- const firstLocalCommit = this.localCommits.shift();
174
- (0, internal_1.assert)(firstLocalCommit !== undefined, 0x6b5 /* Received a sequenced change from the local session despite having no local changes */);
175
- const previousSequenceId = this.getCommitSequenceId(this.trunk.getHead());
176
- this.pushGraphCommitToTrunk(sequenceId, firstLocalCommit, this.localSessionId);
177
- // Next, we need to update the sequence IDs that our local branches (user's branches, not peer branches) are associated with.
178
- // In particular, if a local branch is based on the previous trunk head (the branch's first ancestor in the trunk is the commit that was the head before we pushed the new commit)
179
- // and also branches off of the local branch (it has an ancestor that is part of the local branch), it needs to have its sequence number advanced to be that of the new trunk head.
180
- // Intuitively, this makes sense because:
181
- // 1. The trunk's head just advanced forward by some (sequence) amount.
182
- // 2. The local branch is always rebased to be branching off of the head of the trunk (not literally in this case, because of the optimization, but in effect).
183
- // 3. Therefore, the entire local branch just advanced forward by some (sequence) amount, and any commits downstream of it which track the sequence numbers of their base commits on the trunk should also advance.
184
- // This update is not necessarily required for all local branches, since some may have fallen behind the local branch and are based on older trunk commits (such branches do not need updating).
185
- const currentBranches = this.trunkBranches.get(previousSequenceId);
186
- if (currentBranches !== undefined) {
187
- const newBranches = (0, index_js_2.getOrCreate)(this.trunkBranches, sequenceId, () => new Set());
188
- for (const branch of currentBranches) {
189
- // Check every branch associated with the old sequence ID and advance it if it is based on the local branch (specifically, on the local branch as it was before we pushed its first commit to the trunk).
190
- // We validate this by checking if the branch's head is a descendant of the local commit that we just pushed.
191
- if ((0, index_js_1.findAncestor)(branch.getHead(), (c) => c === firstLocalCommit) !== undefined) {
192
- newBranches.add(branch);
193
- currentBranches.delete(branch);
194
- }
195
- }
196
- // Clean up our trunk branches map by removing any empty sets.
197
- if (currentBranches.size === 0) {
198
- this.trunkBranches.delete(previousSequenceId);
199
- }
200
- if (newBranches.size === 0) {
201
- this.trunkBranches.delete(sequenceId);
141
+ getLatestSequenceNumber() {
142
+ let maxSequenceNumber;
143
+ for (const branch of this.sharedBranches.values()) {
144
+ const branchMax = branch.getCommitSequenceId(branch.trunk.getHead().revision).sequenceNumber;
145
+ if (maxSequenceNumber === undefined || maxSequenceNumber < branchMax) {
146
+ maxSequenceNumber = branchMax;
202
147
  }
203
148
  }
204
- }
205
- /**
206
- * Return the sequence number at which the given commit was sequenced on the trunk, or undefined if the commit is not part of the trunk.
207
- */
208
- getSequenceNumber(trunkCommit) {
209
- return this.trunkMetadata.get(trunkCommit.revision)?.sequenceId.sequenceNumber;
149
+ return maxSequenceNumber;
210
150
  }
211
151
  /**
212
152
  * Advances the minimum sequence number, and removes all commits from the trunk which lie outside the collaboration window,
@@ -215,21 +155,21 @@ class EditManager {
215
155
  *
216
156
  * @remarks If there are more than one commit with the same sequence number we assume this refers to the last commit in the batch.
217
157
  */
218
- advanceMinimumSequenceNumber(minimumSequenceNumber, trimTrunk = true) {
158
+ advanceMinimumSequenceNumber(minimumSequenceNumber, trimHistory = true) {
219
159
  if (minimumSequenceNumber === this.minimumSequenceNumber) {
220
160
  return;
221
161
  }
222
162
  (0, internal_1.assert)(minimumSequenceNumber > this.minimumSequenceNumber, 0x476 /* number must be larger or equal to current minimumSequenceNumber. */);
223
163
  this.minimumSequenceNumber = minimumSequenceNumber;
224
- if (trimTrunk) {
225
- this.trimTrunk();
164
+ if (trimHistory) {
165
+ this.trimHistory();
226
166
  }
227
167
  }
228
168
  /**
229
169
  * Examines the latest known minimum sequence number and the trunk bases of any registered branches to determine
230
170
  * if any commits on the trunk are unreferenced and unneeded for future computation; those found are evicted from the trunk.
231
171
  */
232
- trimTrunk() {
172
+ trimHistory() {
233
173
  /** The sequence id of the most recent commit on the trunk that will be trimmed */
234
174
  let trunkTailSequenceId = {
235
175
  sequenceNumber: this.minimumSequenceNumber,
@@ -243,118 +183,72 @@ class EditManager {
243
183
  const sequenceIdBeforeMinimumBranchBase = (0, sequenceIdUtils_js_1.getUpperBoundOfPreviousSequenceId)(minimumBranchBaseSequenceId);
244
184
  trunkTailSequenceId = (0, sequenceIdUtils_js_1.minSequenceId)(trunkTailSequenceId, sequenceIdBeforeMinimumBranchBase);
245
185
  }
246
- const [sequenceId, latestEvicted] = this.getClosestTrunkCommit((0, sequenceIdUtils_js_1.maxSequenceId)(trunkTailSequenceId, this.sequenceMap.minKey() ?? minimumPossibleSequenceId));
186
+ const mainBranch = this.getSharedBranch("main");
187
+ const [sequenceId, latestEvicted] = mainBranch.getClosestTrunkCommit((0, sequenceIdUtils_js_1.maxSequenceId)(trunkTailSequenceId, mainBranch.sequenceIdToCommit.minKey() ?? minimumPossibleSequenceId));
247
188
  // Don't do any work if the commit found by the search is already the tail of the trunk
248
- if (latestEvicted !== this.trunkBase) {
249
- // The minimum sequence number informs us that all peer branches are at least caught up to the tail commit,
250
- // so rebase them accordingly. This is necessary to prevent peer branches from referencing any evicted commits.
251
- for (const [, branch] of this.peerLocalBranches) {
252
- branch.rebaseOnto(this.trunk, latestEvicted);
253
- }
254
- // This mutation is a performance hack. If commits are truly immutable, then changing the trunk's tail requires
255
- // regenerating the entire commit graph. Instead, we can simply chop off the tail like this if we're certain
256
- // that there are no outstanding references to any of the commits being removed (other than the references via
257
- // the trunk). The peer branches have been rebased to the head of the trunk, the local branch is already rebased
258
- // to the head of the trunk, and all other branches are tracked by `trunkBranches` and known to be ahead of or at
259
- // `newTrunkBase`. Therefore, no branches should have unique references to any of the commits being evicted here.
260
- // We mutate the most recent of the evicted commits to become the new trunk base. That way, any other commits that
261
- // have parent pointers to the latest evicted commit will stay linked, even though that it is no longer part of the trunk.
262
- const newTrunkBase = latestEvicted;
263
- // The metadata for new trunk base revision needs to be deleted before modifying it.
264
- this.trunkMetadata.delete(newTrunkBase.revision);
265
- // collect the revisions that will be trimmed to send as part of the branch trimmed event
266
- const trimmedRevisions = getPathFromBase(newTrunkBase, this.trunkBase).map((c) => c.revision);
267
- // Dropping the parent field removes (transitively) all references to the evicted commits so they can be garbage collected.
268
- delete newTrunkBase.parent;
269
- this.trunkBase = newTrunkBase;
270
- // Update any state that is derived from trunk commits
271
- this.sequenceMap.editRange(minimumPossibleSequenceId, sequenceId, true, (s, commit) => {
272
- // Cleanup look-aside data for each evicted commit
273
- this.trunkMetadata.delete(commit.revision);
274
- // Delete all evicted commits from `sequenceMap` except for the latest one, which is the new `trunkBase`
275
- if ((0, sequenceIdUtils_js_1.equalSequenceIds)(s, sequenceId)) {
276
- (0, internal_1.assert)(commit === newTrunkBase, 0x729 /* Expected last evicted commit to be new trunk base */);
277
- }
278
- else {
279
- Reflect.defineProperty(commit, "change", {
280
- get: () => (0, internal_1.assert)(false, 0xa5e /* Should not access 'change' property of an evicted commit */),
281
- });
282
- Reflect.defineProperty(commit, "revision", {
283
- get: () => (0, internal_1.assert)(false, 0xa5f /* Should not access 'revision' property of an evicted commit */),
284
- });
285
- Reflect.defineProperty(commit, "parent", {
286
- get: () => (0, internal_1.assert)(false, 0xa60 /* Should not access 'parent' property of an evicted commit */),
287
- });
288
- return { delete: true };
289
- }
189
+ if (latestEvicted === this.trunkBase) {
190
+ return;
191
+ }
192
+ // This mutation is a performance hack. If commits are truly immutable, then changing the trunk's tail requires
193
+ // regenerating the entire commit graph. Instead, we can simply chop off the tail like this if we're certain
194
+ // that there are no outstanding references to any of the commits being removed (other than the references via
195
+ // the trunk). The peer branches have been rebased to the head of the trunk, the local branch is already rebased
196
+ // to the head of the trunk, and all other branches are tracked by `trunkBranches` and known to be ahead of or at
197
+ // `newTrunkBase`. Therefore, no branches should have unique references to any of the commits being evicted here.
198
+ // We mutate the most recent of the evicted commits to become the new trunk base. That way, any other commits that
199
+ // have parent pointers to the latest evicted commit will stay linked, even though that it is no longer part of the trunk.
200
+ const newTrunkBase = latestEvicted;
201
+ // collect the revisions that will be trimmed to send as part of the branch trimmed event
202
+ const trimmedCommits = getPathFromBase(newTrunkBase, this.trunkBase);
203
+ const trimmedRevisions = trimmedCommits.map((c) => c.revision);
204
+ // The minimum sequence number informs us that all peer branches are at least caught up to the tail commit,
205
+ // so rebase them accordingly. This is necessary to prevent peer branches from referencing any evicted commits.
206
+ mainBranch.trimHistory(latestEvicted, sequenceId);
207
+ // Only the last trimmed commit, which is the new trunk base, should remain accessible.
208
+ for (const commit of trimmedCommits.slice(0, -1)) {
209
+ Reflect.defineProperty(commit, "change", {
210
+ get: () => (0, internal_1.assert)(false, 0xa5e /* Should not access 'change' property of an evicted commit */),
211
+ });
212
+ Reflect.defineProperty(commit, "revision", {
213
+ get: () => (0, internal_1.assert)(false, 0xa5f /* Should not access 'revision' property of an evicted commit */),
214
+ });
215
+ Reflect.defineProperty(commit, "parent", {
216
+ get: () => (0, internal_1.assert)(false, 0xa60 /* Should not access 'parent' property of an evicted commit */),
290
217
  });
291
- const trunkSize = getPathFromBase(this.trunk.getHead(), this.trunkBase).length;
292
- (0, internal_1.assert)(this.sequenceMap.size === trunkSize + 1, 0x744 /* The size of the sequenceMap must have one element more than the trunk */);
293
- (0, internal_1.assert)(this.trunkMetadata.size === trunkSize, 0x745 /* The size of the trunkMetadata must be the same as the trunk */);
294
- this._events.emit("ancestryTrimmed", trimmedRevisions);
295
218
  }
219
+ // Dropping the parent field removes (transitively) all references to the evicted commits so they can be garbage collected.
220
+ delete newTrunkBase.parent;
221
+ this.trunkBase = newTrunkBase;
222
+ this._events.emit("ancestryTrimmed", trimmedRevisions);
296
223
  }
297
224
  isEmpty() {
298
- return (this.trunk.getHead() === this.trunkBase &&
299
- this.peerLocalBranches.size === 0 &&
300
- this.localBranch.getHead() === this.trunk.getHead() &&
301
- this.minimumSequenceNumber === exports.minimumPossibleSequenceNumber);
225
+ for (const branch of this.sharedBranches.values()) {
226
+ if (!branch.isEmpty(this.trunkBase)) {
227
+ return false;
228
+ }
229
+ }
230
+ return this.minimumSequenceNumber === exports.minimumPossibleSequenceNumber;
302
231
  }
303
232
  getSummaryData() {
304
- // The assert below is acceptable at present because summarization only ever occurs on a client with no
305
- // local/in-flight changes.
306
- // In the future we may wish to relax this constraint. For that to work, the current implementation of
307
- // `EditManager` would have to be amended in one of two ways:
308
- // A) Changes made by the local session should be represented by a branch in `EditManager.branches`.
309
- // B) The contents of such a branch should be computed on demand based on the trunk.
310
- // Note that option (A) would be a simple change to `addSequencedChanges` whereas (B) would likely require
311
- // rebasing trunk changes over the inverse of trunk changes.
312
- (0, internal_1.assert)(this.localBranch.getHead() === this.trunk.getHead(), 0x428 /* Clients with local changes cannot be used to generate summaries */);
313
233
  // Trimming the trunk before serializing ensures that the trunk data in the summary is as minimal as possible.
314
- this.trimTrunk();
315
- let oldestCommitInCollabWindow = this.getClosestTrunkCommit(this.minimumSequenceNumber)[1];
316
- (0, internal_1.assert)(oldestCommitInCollabWindow.parent !== undefined ||
317
- oldestCommitInCollabWindow === this.trunkBase, 0x8c7 /* Expected oldest commit in collab window to have a parent or be the trunk base */);
318
- // Path construction is exclusive, so we need to use the parent of the oldest commit in the window if it exists
319
- oldestCommitInCollabWindow =
320
- oldestCommitInCollabWindow.parent ?? oldestCommitInCollabWindow;
321
- const trunk = getPathFromBase(this.trunk.getHead(), oldestCommitInCollabWindow).map((c) => {
322
- (0, internal_1.assert)(c !== this.trunkBase, 0xa61 /* Serialized trunk should not include the trunk base */);
323
- const metadata = this.trunkMetadata.get(c.revision) ??
324
- (0, internal_1.fail)(0xad5 /* Expected metadata for trunk commit */);
325
- const commit = {
326
- change: c.change,
327
- revision: c.revision,
328
- sequenceNumber: metadata.sequenceId.sequenceNumber,
329
- sessionId: metadata.sessionId,
330
- };
331
- if (metadata.sequenceId.indexInBatch !== undefined) {
332
- commit.indexInBatch = metadata.sequenceId.indexInBatch;
234
+ this.trimHistory();
235
+ const minSeqNumberToSummarize = {
236
+ sequenceNumber: (0, index_js_2.brand)(this.minimumSequenceNumber + 1),
237
+ };
238
+ let minBaseSeqId = minSeqNumberToSummarize;
239
+ const mainBranch = this.getSharedBranch("main");
240
+ const branches = new Map();
241
+ for (const [branchId, branch] of this.sharedBranches) {
242
+ if (branchId !== "main") {
243
+ const branchSummary = branch.getSummaryData(minSeqNumberToSummarize, this.trunkBase.revision);
244
+ branches.set(branchId, branchSummary);
245
+ (0, internal_1.assert)(branchSummary.base !== undefined, "Branch summary must have a base");
246
+ const baseSequenceId = mainBranch.getCommitSequenceId(branchSummary.base);
247
+ minBaseSeqId = (0, sequenceIdUtils_js_1.minSequenceId)(minBaseSeqId, baseSequenceId);
333
248
  }
334
- return commit;
335
- });
336
- const peerLocalBranches = new Map((0, index_js_2.mapIterable)(this.peerLocalBranches.entries(), ([sessionId, branch]) => {
337
- const branchPath = [];
338
- const ancestor = (0, index_js_1.findCommonAncestor)([branch.getHead(), branchPath], this.trunk.getHead()) ??
339
- (0, internal_1.fail)(0xad6 /* Expected branch to be based on trunk */);
340
- const base = ancestor === this.trunkBase ? rootRevision : ancestor.revision;
341
- return [
342
- sessionId,
343
- {
344
- base,
345
- commits: branchPath.map((c) => {
346
- (0, internal_1.assert)(c !== this.trunkBase, 0xa62 /* Serialized branch should not include the trunk base */);
347
- const commit = {
348
- change: c.change,
349
- revision: c.revision,
350
- sessionId,
351
- };
352
- return commit;
353
- }),
354
- },
355
- ];
356
- }));
357
- return { trunk, peerLocalBranches };
249
+ }
250
+ const mainSummary = mainBranch.getSummaryData(minBaseSeqId, this.trunkBase.revision);
251
+ return { main: mainSummary, branches, originator: this.localSessionId };
358
252
  }
359
253
  loadSummaryData(data) {
360
254
  (0, internal_1.assert)(this.isEmpty(), 0x68a /* Attempted to load from summary after edit manager was already mutated */);
@@ -362,53 +256,30 @@ class EditManager {
362
256
  // when hydrating the peer branches below
363
257
  const trunkRevisionCache = new Map();
364
258
  trunkRevisionCache.set(this.trunkBase.revision, this.trunkBase);
365
- this.trunk.setHead(data.trunk.reduce((base, c) => {
366
- const sequenceId = c.indexInBatch === undefined
367
- ? {
368
- sequenceNumber: c.sequenceNumber,
369
- }
370
- : {
371
- sequenceNumber: c.sequenceNumber,
372
- indexInBatch: c.indexInBatch,
373
- };
374
- const commit = (0, index_js_1.mintCommit)(base, c);
375
- this.sequenceMap.set(sequenceId, commit);
376
- this.trunkMetadata.set(c.revision, {
377
- sequenceId,
378
- sessionId: c.sessionId,
379
- });
380
- trunkRevisionCache.set(c.revision, commit);
381
- return commit;
382
- }, this.trunkBase));
383
- this.localBranch.setHead(this.trunk.getHead());
384
- for (const [sessionId, branch] of data.peerLocalBranches) {
385
- const commit = trunkRevisionCache.get(branch.base) ??
386
- (0, internal_1.fail)(0xad7 /* Expected summary branch to be based off of a revision in the trunk */);
387
- this.peerLocalBranches.set(sessionId, new branch_js_1.SharedTreeBranch(branch.commits.reduce(index_js_1.mintCommit, commit), this.changeFamily, this.mintRevisionTag));
388
- }
389
- }
390
- getCommitSequenceId(trunkCommitOrTrunkBase) {
391
- const id = this.trunkMetadata.get(trunkCommitOrTrunkBase.revision)?.sequenceId;
392
- if (id === undefined) {
393
- (0, internal_1.assert)(trunkCommitOrTrunkBase === this.trunkBase, 0xa63 /* Commit must be either be on the trunk or be the trunk base */);
394
- return minimumPossibleSequenceId;
259
+ const mainBranch = this.sharedBranches.get("main") ?? (0, internal_1.fail)("Main branch must exist");
260
+ mainBranch.loadSummaryData(data.main, trunkRevisionCache);
261
+ if (data.branches !== undefined) {
262
+ for (const [branchId, branchData] of data.branches) {
263
+ const branch = this.createSharedBranch(branchId, branchData.session, mainBranch, mainBranch.trunk.fork());
264
+ branch.loadSummaryData(branchData, trunkRevisionCache);
265
+ }
395
266
  }
396
- return id;
397
267
  }
398
- getTrunkChanges() {
399
- return this.getTrunkCommits().map((c) => c.change);
268
+ getTrunkHead(branchId) {
269
+ return this.getSharedBranch(branchId).trunk.getHead();
400
270
  }
401
- getTrunkCommits() {
402
- return getPathFromBase(this.trunk.getHead(), this.trunkBase);
271
+ getTrunkChanges(branchId) {
272
+ return this.getTrunkCommits(branchId).map((c) => c.change);
403
273
  }
404
- getTrunkHead() {
405
- return this.trunk.getHead();
274
+ getTrunkCommits(branchId) {
275
+ return getPathFromBase(this.getTrunkHead(branchId), this.trunkBase);
406
276
  }
407
- getLocalChanges() {
408
- return this.getLocalCommits().map((c) => c.change);
277
+ getLocalChanges(branchId) {
278
+ return this.getLocalCommits(branchId).map((c) => c.change);
409
279
  }
410
- getLocalCommits() {
411
- return this.localCommits;
280
+ getLocalCommits(branchId) {
281
+ const branch = this.getSharedBranch(branchId);
282
+ return branch.getLocalCommits();
412
283
  }
413
284
  /**
414
285
  * Gets the length of the longest branch maintained by this `EditManager`.
@@ -420,15 +291,36 @@ class EditManager {
420
291
  */
421
292
  getLongestBranchLength() {
422
293
  let max = 0;
423
- const trunkHead = this.trunk.getHead();
424
- for (const branch of this.peerLocalBranches.values()) {
425
- const branchPath = getPathFromBase(branch.getHead(), trunkHead);
426
- if (branchPath.length > max) {
427
- max = branchPath.length;
428
- }
294
+ for (const branch of this.sharedBranches.values()) {
295
+ max = Math.max(max, branch.getLongestBranchLength());
429
296
  }
430
- const localPath = getPathFromBase(this.localBranch.getHead(), trunkHead);
431
- return Math.max(max, localPath.length);
297
+ return max;
298
+ }
299
+ sequenceBranchCreation(sessionId, referenceSequenceNumber, branchId) {
300
+ if (sessionId === this.localSessionId) {
301
+ (0, internal_1.assert)(this.sharedBranches.has(branchId), "Expected branch to already exist");
302
+ return;
303
+ }
304
+ const mainBranch = this.getSharedBranch("main");
305
+ const branchTrunk = mainBranch.rebasePeer(sessionId, referenceSequenceNumber).fork();
306
+ const sharedBranch = this.createSharedBranch(branchId, sessionId, mainBranch, branchTrunk);
307
+ this.registerBranch(sharedBranch.localBranch);
308
+ (0, branch_js_1.onForkTransitive)(sharedBranch.localBranch, (fork) => this.registerBranch(fork));
309
+ }
310
+ addBranch(branchId) {
311
+ const main = this.getSharedBranch("main") ?? (0, internal_1.fail)("Main branch must exist");
312
+ this.createSharedBranch(branchId, this.localSessionId, main, this.getLocalBranch("main").fork());
313
+ }
314
+ removeBranch(branchId) {
315
+ (0, internal_1.assert)(branchId !== "main", "Cannot remove main branch");
316
+ const hadBranch = this.sharedBranches.delete(branchId);
317
+ (0, internal_1.assert)(hadBranch, "Expected branch to exist");
318
+ }
319
+ createSharedBranch(branchId, sessionId, parent, branch) {
320
+ const sharedBranch = new SharedBranch(parent, branch, branchId, sessionId, minimumPossibleSequenceId, this.changeFamily, this.mintRevisionTag, this._events, this.telemetryEventBatcher);
321
+ (0, internal_1.assert)(!this.sharedBranches.has(branchId), "A branch with this ID already exists");
322
+ this.sharedBranches.set(branchId, sharedBranch);
323
+ return sharedBranch;
432
324
  }
433
325
  /* eslint-disable jsdoc/check-indentation */
434
326
  /**
@@ -441,34 +333,119 @@ class EditManager {
441
333
  * - They are not interleaved with messages from other clients.
442
334
  */
443
335
  /* eslint-enable jsdoc/check-indentation */
444
- addSequencedChanges(newCommits, sessionId, sequenceNumber, referenceSequenceNumber) {
336
+ addSequencedChanges(newCommits, sessionId, sequenceNumber, referenceSequenceNumber, branchId = "main") {
445
337
  (0, internal_1.assert)(newCommits.length > 0, 0xad8 /* Expected at least one sequenced change */);
446
338
  (0, internal_1.assert)(sequenceNumber > this.minimumSequenceNumber, 0x713 /* Expected change sequence number to exceed the last known minimum sequence number */);
447
- (0, internal_1.assert)(sequenceNumber >= // This is ">=", not ">" because changes in the same batch will have the same sequence number
448
- (this.sequenceMap.maxKey()?.sequenceNumber ?? exports.minimumPossibleSequenceNumber), 0xa64 /* Attempted to sequence change with an outdated sequence number */);
449
- // Returns the sequence id for the next commit to be processed in the bunch. Since all the commits have the
450
- // same sequence number, only the index in the batch needs to be incremented.
451
- const getNextSequenceId = (sequenceId) => {
452
- return {
453
- sequenceNumber: sequenceId.sequenceNumber,
454
- indexInBatch: (sequenceId.indexInBatch ?? 0) + 1,
455
- };
339
+ const branch = this.getSharedBranch(branchId);
340
+ const onSequenceLocalCommit = (commit, sequenceId, previousSequenceId) => {
341
+ // Next, we need to update the sequence IDs that our local branches (user's branches, not peer branches) are associated with.
342
+ // In particular, if a local branch is based on the previous trunk head (the branch's first ancestor in the trunk is the commit that was the head before we pushed the new commit)
343
+ // and also branches off of the local branch (it has an ancestor that is part of the local branch), it needs to have its sequence number advanced to be that of the new trunk head.
344
+ // Intuitively, this makes sense because:
345
+ // 1. The trunk's head just advanced forward by some (sequence) amount.
346
+ // 2. The local branch is always rebased to be branching off of the head of the trunk (not literally in this case, because of the optimization, but in effect).
347
+ // 3. Therefore, the entire local branch just advanced forward by some (sequence) amount, and any commits downstream of it which track the sequence numbers of their base commits on the trunk should also advance.
348
+ // This update is not necessarily required for all local branches, since some may have fallen behind the local branch and are based on older trunk commits (such branches do not need updating).
349
+ const currentBranches = this.trunkBranches.get(previousSequenceId);
350
+ if (currentBranches !== undefined) {
351
+ const newBranches = (0, index_js_2.getOrCreate)(this.trunkBranches, sequenceId, () => new Set());
352
+ for (const forkedBranch of currentBranches) {
353
+ // Check every branch associated with the old sequence ID and advance it if it is based on the local branch (specifically, on the local branch as it was before we pushed its first commit to the trunk).
354
+ // We validate this by checking if the branch's head is a descendant of the local commit that we just pushed.
355
+ if ((0, index_js_1.findAncestor)(forkedBranch.getHead(), (c) => c === commit) !== undefined) {
356
+ newBranches.add(forkedBranch);
357
+ currentBranches.delete(forkedBranch);
358
+ }
359
+ }
360
+ // Clean up our trunk branches map by removing any empty sets.
361
+ if (currentBranches.size === 0) {
362
+ this.trunkBranches.delete(previousSequenceId);
363
+ }
364
+ if (newBranches.size === 0) {
365
+ this.trunkBranches.delete(sequenceId);
366
+ }
367
+ }
456
368
  };
457
- const commitsSequenceNumber = this.getBatch(sequenceNumber);
369
+ const areLocalCommits = sessionId === this.localSessionId;
370
+ branch.addSequencedChanges(newCommits, sessionId, sequenceNumber, areLocalCommits, referenceSequenceNumber, onSequenceLocalCommit);
371
+ }
372
+ findLocalCommit(branchId, revision) {
373
+ const commits = [];
374
+ const commit = (0, index_js_1.findAncestor)([this.getSharedBranch(branchId).localBranch.getHead(), commits], (c) => c.revision === revision);
375
+ (0, internal_1.assert)(commit !== undefined, 0x599 /* Expected local branch to contain revision */);
376
+ return [commit, commits];
377
+ }
378
+ }
379
+ exports.EditManager = EditManager;
380
+ /**
381
+ * Gets the path from the base of a branch to its head.
382
+ */
383
+ function getPathFromBase(branchHead, baseBranchHead) {
384
+ const path = [];
385
+ (0, internal_1.assert)((0, index_js_1.findCommonAncestor)([branchHead, path], baseBranchHead) !== undefined, 0x573 /* Expected branches to be related */);
386
+ return path;
387
+ }
388
+ class SharedBranch {
389
+ constructor(parentBranch, trunk, id, sessionId, baseCommitSequenceId, changeFamily, mintRevisionTag, branchTrimmer, telemetryEventBatcher) {
390
+ this.parentBranch = parentBranch;
391
+ this.trunk = trunk;
392
+ this.id = id;
393
+ this.sessionId = sessionId;
394
+ this.changeFamily = changeFamily;
395
+ this.mintRevisionTag = mintRevisionTag;
396
+ /**
397
+ * Branches are maintained to represent the local change list that the issuing client had
398
+ * at the time of submitting the latest known edit on the branch.
399
+ * This means the head commit of each branch is always in its original (non-rebased) form.
400
+ */
401
+ this.peerLocalBranches = new Map();
402
+ /**
403
+ * A map from a sequence id to the commit which has that sequence id.
404
+ * This also includes an entry for the {@link trunkBase} which always has the lowest key in the map.
405
+ */
406
+ this.sequenceIdToCommit = new sorted_btree_es6_1.BTree(undefined, sequenceIdUtils_js_1.sequenceIdComparator);
407
+ /**
408
+ * The list of commits (from oldest to most recent) that are on the local branch but not on the trunk.
409
+ * When a local commit is sequenced, the first commit in this list shifted onto the tip of the trunk.
410
+ */
411
+ this.localCommits = [];
412
+ /**
413
+ * Records extra data associated with sequenced commits.
414
+ * This does not include an entry for the {@link trunkBase}.
415
+ */
416
+ this.commitMetadata = new Map();
417
+ this.localBranch = new branch_js_1.SharedTreeBranch(this.trunk.getHead(), changeFamily, mintRevisionTag, branchTrimmer, telemetryEventBatcher);
418
+ this.sequenceIdToCommit.set(baseCommitSequenceId, this.trunk.getHead());
419
+ this.localBranch.events.on("afterChange", (event) => {
420
+ if (event.type === "append") {
421
+ for (const commit of event.newCommits) {
422
+ this.localCommits.push(commit);
423
+ }
424
+ }
425
+ else {
426
+ this.localCommits.length = 0;
427
+ (0, index_js_1.findCommonAncestor)([this.localBranch.getHead(), this.localCommits], this.trunk.getHead());
428
+ }
429
+ });
430
+ }
431
+ addSequencedChanges(newCommits, sessionId, sequenceNumber, areLocalCommits, referenceSequenceNumber, onSequenceLocalCommit) {
432
+ (0, internal_1.assert)(sequenceNumber >= // This is ">=", not ">" because changes in the same batch will have the same sequence number
433
+ (this.sequenceIdToCommit.maxKey()?.sequenceNumber ?? exports.minimumPossibleSequenceNumber), 0xa64 /* Attempted to sequence change with an outdated sequence number */);
434
+ const batchSize = this.getBatchSize(sequenceNumber);
458
435
  // The sequence id for the next commit to be processed in the bunch.
459
- let nextSequenceId = commitsSequenceNumber.length === 0
436
+ let nextSequenceId = batchSize === 0
460
437
  ? {
461
438
  sequenceNumber,
462
439
  }
463
440
  : {
464
441
  sequenceNumber,
465
- indexInBatch: commitsSequenceNumber.length,
442
+ indexInBatch: batchSize,
466
443
  };
467
444
  // Local changes, i.e., changes from this client are applied by fast forwarding the local branch commit onto
468
445
  // the trunk.
469
- if (sessionId === this.localSessionId) {
446
+ if (areLocalCommits) {
470
447
  for (const _ of newCommits) {
471
- this.fastForwardNextLocalCommit(nextSequenceId);
448
+ this.sequenceLocalCommit(nextSequenceId, sessionId, onSequenceLocalCommit);
472
449
  nextSequenceId = getNextSequenceId(nextSequenceId);
473
450
  }
474
451
  return;
@@ -478,9 +455,7 @@ class EditManager {
478
455
  // Get the revision that the remote change is based on and rebase that peer local branch over the part of the
479
456
  // trunk up to the base revision. This will be a no-op if the sending client has not advanced since the last
480
457
  // time we received an edit from it
481
- const [, baseRevisionInTrunk] = this.getClosestTrunkCommit(referenceSequenceNumber);
482
- const peerLocalBranch = (0, index_js_2.getOrCreate)(this.peerLocalBranches, sessionId, () => new branch_js_1.SharedTreeBranch(baseRevisionInTrunk, this.changeFamily, this.mintRevisionTag));
483
- peerLocalBranch.rebaseOnto(this.trunk, baseRevisionInTrunk);
458
+ const peerLocalBranch = this.rebasePeer(sessionId, referenceSequenceNumber);
484
459
  // Step 2 - Append the changes to the peer branch and rebase the changes to the tip of the trunk.
485
460
  if (peerLocalBranch.getHead() === this.trunk.getHead()) {
486
461
  // If the peer local branch is fully caught up and empty (no changes relative to the trunk) after being
@@ -501,8 +476,8 @@ class EditManager {
501
476
  // If the merge resulted in any changes to the trunk, update the sequence map and trunk metadata
502
477
  // with the rebased commits.
503
478
  for (const sourceCommit of result.sourceCommits) {
504
- this.sequenceMap.set(nextSequenceId, sourceCommit);
505
- this.trunkMetadata.set(sourceCommit.revision, {
479
+ this.sequenceIdToCommit.set(nextSequenceId, sourceCommit);
480
+ this.commitMetadata.set(sourceCommit.revision, {
506
481
  sequenceId: nextSequenceId,
507
482
  sessionId,
508
483
  });
@@ -513,21 +488,85 @@ class EditManager {
513
488
  // Step 3 - Rebase the local branch over the updated trunk.
514
489
  this.localBranch.rebaseOnto(this.trunk);
515
490
  }
516
- findLocalCommit(revision) {
517
- const commits = [];
518
- const commit = (0, index_js_1.findAncestor)([this.localBranch.getHead(), commits], (c) => c.revision === revision);
519
- (0, internal_1.assert)(commit !== undefined, 0x599 /* Expected local branch to contain revision */);
520
- return [commit, commits];
491
+ isEmpty(baseCommit) {
492
+ return (this.trunk.getHead() === baseCommit &&
493
+ this.peerLocalBranches.size === 0 &&
494
+ this.localBranch.getHead() === this.trunk.getHead());
521
495
  }
522
- pushCommitToTrunk(sequenceId, commit) {
523
- const mintedCommit = (0, index_js_1.mintCommit)(this.trunk.getHead(), commit);
524
- this.pushGraphCommitToTrunk(sequenceId, mintedCommit, commit.sessionId);
496
+ rebasePeer(sessionId, referenceSequenceNumber) {
497
+ const [, baseRevisionInTrunk] = this.getClosestTrunkCommit(referenceSequenceNumber);
498
+ const peerLocalBranch = (0, index_js_2.getOrCreate)(this.peerLocalBranches, sessionId, () => new branch_js_1.SharedTreeBranch(baseRevisionInTrunk, this.changeFamily, this.mintRevisionTag));
499
+ peerLocalBranch.rebaseOnto(this.trunk, baseRevisionInTrunk);
500
+ return peerLocalBranch;
525
501
  }
526
- pushGraphCommitToTrunk(sequenceId, graphCommit, sessionId) {
527
- this.trunk.setHead(graphCommit);
502
+ getPeerBranchOrTrunk(sessionId) {
503
+ return this.peerLocalBranches.get(sessionId) ?? this.trunk;
504
+ }
505
+ /**
506
+ * Gets the length of the longest branch maintained by this `SharedBranch`.
507
+ * This may be the length of a peer branch or the local branch.
508
+ *
509
+ * @remarks
510
+ * The length is counted from the lowest common ancestor with the trunk such that a fully sequenced branch would
511
+ * have length zero.
512
+ */
513
+ getLongestBranchLength() {
514
+ let max = 0;
528
515
  const trunkHead = this.trunk.getHead();
529
- this.sequenceMap.set(sequenceId, trunkHead);
530
- this.trunkMetadata.set(trunkHead.revision, { sequenceId, sessionId });
516
+ for (const branch of this.peerLocalBranches.values()) {
517
+ const branchPath = getPathFromBase(branch.getHead(), trunkHead);
518
+ if (branchPath.length > max) {
519
+ max = branchPath.length;
520
+ }
521
+ }
522
+ const localPath = getPathFromBase(this.localBranch.getHead(), trunkHead);
523
+ return Math.max(max, localPath.length);
524
+ }
525
+ trimHistory(newBase, sequenceId) {
526
+ this.rebasePeers(newBase);
527
+ this.sequenceIdToCommit.editRange(minimumPossibleSequenceId, sequenceId, true, (s, commit) => {
528
+ // Cleanup look-aside data for each evicted commit
529
+ this.commitMetadata.delete(commit.revision);
530
+ // Delete all evicted commits from `sequenceMap` except for the latest one, which is the new `trunkBase`
531
+ if ((0, sequenceIdUtils_js_1.equalSequenceIds)(s, sequenceId)) {
532
+ (0, internal_1.assert)(commit === newBase, 0x729 /* Expected last evicted commit to be new trunk base */);
533
+ }
534
+ else {
535
+ return { delete: true };
536
+ }
537
+ });
538
+ const trunkSize = getPathFromBase(this.trunk.getHead(), newBase).length;
539
+ (0, internal_1.assert)(this.sequenceIdToCommit.size === trunkSize + 1, 0x744 /* The size of the sequenceMap must have one element more than the trunk */);
540
+ (0, internal_1.assert)(this.commitMetadata.size === trunkSize, 0x745 /* The size of the trunkMetadata must be the same as the trunk */);
541
+ }
542
+ rebasePeers(commit) {
543
+ for (const [, branch] of this.peerLocalBranches) {
544
+ branch.rebaseOnto(this.trunk, commit);
545
+ }
546
+ // The metadata for new trunk base revision needs to be deleted before modifying it.
547
+ this.commitMetadata.delete(commit.revision);
548
+ }
549
+ getLocalCommits() {
550
+ return this.localCommits;
551
+ }
552
+ /**
553
+ * Promote the oldest un-sequenced commit on the local branch to the head of the trunk.
554
+ * @param sequenceId - The sequence id of the new trunk commit
555
+ * @remarks This method is a performance optimization for the scenario where this client receives its own change back after sequencing.
556
+ * The normal (not optimized) process in this case would be to apply the new sequenced commit to the trunk and then rebase the local branch over the trunk.
557
+ * The first commit will be "the same" (as in, it will have the same revision) as the commit that was just sequenced, so the rebase will be a no-op.
558
+ * Because the rebase is a no-op, we can skip it entirely and simply remove the commit from the local branch and append it to the trunk.
559
+ * Avoiding the overhead of the rebase process, even when it's a no-op, has real measured performance benefits and is worth the added complexity here.
560
+ */
561
+ sequenceLocalCommit(sequenceId, sessionId, onSequenceLocalCommit) {
562
+ // First, push the local commit to the trunk.
563
+ // We are mutating our `localCommits` cache here,but there is no need to actually change the `localBranch` itself because it will simply catch up later if/when it next rebases.
564
+ const firstLocalCommit = this.localCommits.shift();
565
+ (0, internal_1.assert)(firstLocalCommit !== undefined, 0x6b5 /* Received a sequenced change from the local session despite having no local changes */);
566
+ const prevSequenceId = this.getCommitSequenceId(this.trunk.getHead().revision);
567
+ this.pushGraphCommitToTrunk(sequenceId, firstLocalCommit, sessionId);
568
+ onSequenceLocalCommit(firstLocalCommit, sequenceId, prevSequenceId);
569
+ return firstLocalCommit;
531
570
  }
532
571
  getClosestTrunkCommit(searchBy) {
533
572
  const sequenceId = typeof searchBy === "number"
@@ -539,27 +578,135 @@ class EditManager {
539
578
  indexInBatch: Number.POSITIVE_INFINITY,
540
579
  }
541
580
  : searchBy;
542
- const commit = this.sequenceMap.getPairOrNextLower(sequenceId);
581
+ const commit = this.sequenceIdToCommit.getPairOrNextLower(sequenceId);
543
582
  (0, internal_1.assert)(commit !== undefined, 0x746 /* sequence id has been evicted */);
544
583
  return commit;
545
584
  }
546
- getBatch(sequenceNumber) {
585
+ pushGraphCommitToTrunk(sequenceId, graphCommit, sessionId) {
586
+ this.trunk.setHead(graphCommit);
587
+ this.registerSequencedCommit(sequenceId, sessionId, graphCommit);
588
+ }
589
+ pushCommitToTrunk(sequenceId, commit) {
590
+ const mintedCommit = (0, index_js_1.mintCommit)(this.trunk.getHead(), commit);
591
+ this.pushGraphCommitToTrunk(sequenceId, mintedCommit, commit.sessionId);
592
+ }
593
+ registerSequencedCommit(sequenceId, sessionId, commit) {
594
+ this.sequenceIdToCommit.set(sequenceId, commit);
595
+ this.commitMetadata.set(commit.revision, { sequenceId, sessionId });
596
+ }
597
+ getCommitSequenceId(commitRevision) {
598
+ const id = this.commitMetadata.get(commitRevision)?.sequenceId;
599
+ if (id === undefined) {
600
+ return minimumPossibleSequenceId;
601
+ }
602
+ return id;
603
+ }
604
+ // TODO: Document that this is to handle receiving separate commits with the same sequence ID,
605
+ // as a batch of changes are not guaranteed to be processed as one bunch.
606
+ getBatchSize(sequenceNumber) {
547
607
  const startSequenceId = {
548
608
  sequenceNumber,
549
609
  };
550
610
  const endSequenceId = {
551
611
  sequenceNumber: (0, index_js_2.brand)(sequenceNumber + 1),
552
612
  };
553
- return this.sequenceMap.getRange(startSequenceId, endSequenceId, false);
613
+ return this.sequenceIdToCommit.getRange(startSequenceId, endSequenceId, false).length;
614
+ }
615
+ getSummaryData(minSeqNumberToSummarize, trunkBaseRevision) {
616
+ // The assert below is acceptable at present because summarization only ever occurs on a client with no
617
+ // local/in-flight changes.
618
+ // In the future we may wish to relax this constraint. For that to work, the current implementation of
619
+ // `EditManager` would have to be amended in one of two ways:
620
+ // A) Changes made by the local session should be represented by a branch in `EditManager.branches`.
621
+ // B) The contents of such a branch should be computed on demand based on the trunk.
622
+ // Note that option (A) would be a simple change to `addSequencedChanges` whereas (B) would likely require
623
+ // rebasing trunk changes over the inverse of trunk changes.
624
+ (0, internal_1.assert)(this.localBranch.getHead() === this.trunk.getHead(), "Clients with local changes cannot be used to generate summaries");
625
+ let parentHead;
626
+ if (this.parentBranch === undefined) {
627
+ const oldestCommitInCollabWindow = this.getClosestTrunkCommit(minSeqNumberToSummarize)[1];
628
+ // Path construction is exclusive, so we need to use the parent of the oldest commit in the window if it exists
629
+ parentHead = oldestCommitInCollabWindow.parent ?? oldestCommitInCollabWindow;
630
+ }
631
+ else {
632
+ parentHead = this.parentBranch.trunk.getHead();
633
+ }
634
+ const childBranchTrunkCommits = [];
635
+ const forkPointFromMainTrunk = (0, index_js_1.findCommonAncestor)([this.trunk.getHead(), childBranchTrunkCommits], parentHead);
636
+ (0, internal_1.assert)(forkPointFromMainTrunk !== undefined, "Expected child branch to be based on main branch");
637
+ const trunk = childBranchTrunkCommits.map((c) => {
638
+ const metadata = this.commitMetadata.get(c.revision) ??
639
+ (0, internal_1.fail)(0xad5 /* Expected metadata for trunk commit */);
640
+ const commit = {
641
+ change: c.change,
642
+ revision: c.revision,
643
+ sequenceNumber: metadata.sequenceId.sequenceNumber,
644
+ sessionId: metadata.sessionId,
645
+ };
646
+ if (metadata.sequenceId.indexInBatch !== undefined) {
647
+ commit.indexInBatch = metadata.sequenceId.indexInBatch;
648
+ }
649
+ return commit;
650
+ });
651
+ const peerLocalBranches = new Map((0, index_js_2.mapIterable)(this.peerLocalBranches.entries(), ([sessionId, branch]) => {
652
+ const branchPath = [];
653
+ const ancestor = (0, index_js_1.findCommonAncestor)([branch.getHead(), branchPath], this.trunk.getHead()) ??
654
+ (0, internal_1.fail)(0xad6 /* Expected branch to be based on trunk */);
655
+ const base = ancestor.revision === trunkBaseRevision ? rootRevision : ancestor.revision;
656
+ return [
657
+ sessionId,
658
+ {
659
+ base,
660
+ commits: branchPath.map((c) => {
661
+ const commit = {
662
+ change: c.change,
663
+ revision: c.revision,
664
+ sessionId,
665
+ };
666
+ return commit;
667
+ }),
668
+ },
669
+ ];
670
+ }));
671
+ const trunkBase = this.parentBranch === undefined ? undefined : forkPointFromMainTrunk.revision;
672
+ return { trunk, peerLocalBranches, base: trunkBase, id: this.id, session: this.sessionId };
673
+ }
674
+ loadSummaryData(data, trunkRevisionCache) {
675
+ (0, internal_1.assert)((this.parentBranch === undefined) === (data.base === undefined), "Expected branch base to match presence of parent branch");
676
+ const parentTrunkBase = trunkRevisionCache.get(data.base ?? rootRevision) ??
677
+ (0, internal_1.fail)("Expected base revision to be in trunk cache");
678
+ this.trunk.setHead(data.trunk.reduce((base, c) => {
679
+ const sequenceId = c.indexInBatch === undefined
680
+ ? {
681
+ sequenceNumber: c.sequenceNumber,
682
+ }
683
+ : {
684
+ sequenceNumber: c.sequenceNumber,
685
+ indexInBatch: c.indexInBatch,
686
+ };
687
+ const commit = (0, index_js_1.mintCommit)(base, c);
688
+ this.sequenceIdToCommit.set(sequenceId, commit);
689
+ this.commitMetadata.set(c.revision, {
690
+ sequenceId,
691
+ sessionId: c.sessionId,
692
+ });
693
+ trunkRevisionCache.set(c.revision, commit);
694
+ return commit;
695
+ }, parentTrunkBase));
696
+ this.localBranch.setHead(this.trunk.getHead());
697
+ for (const [sessionId, branch] of data.peerLocalBranches) {
698
+ const commit = trunkRevisionCache.get(branch.base) ??
699
+ (0, internal_1.fail)(0xad7 /* Expected summary branch to be based off of a revision in the trunk */);
700
+ this.peerLocalBranches.set(sessionId, new branch_js_1.SharedTreeBranch(branch.commits.reduce(index_js_1.mintCommit, commit), this.changeFamily, this.mintRevisionTag));
701
+ }
554
702
  }
555
703
  }
556
- exports.EditManager = EditManager;
557
- /**
558
- * Gets the path from the base of a branch to its head.
559
- */
560
- function getPathFromBase(branchHead, baseBranchHead) {
561
- const path = [];
562
- (0, internal_1.assert)((0, index_js_1.findCommonAncestor)([branchHead, path], baseBranchHead) !== undefined, 0x573 /* Expected branches to be related */);
563
- return path;
704
+ // Returns the sequence id for the next commit to be processed in the bunch. Since all the commits have the
705
+ // same sequence number, only the index in the batch needs to be incremented.
706
+ function getNextSequenceId(sequenceId) {
707
+ return {
708
+ sequenceNumber: sequenceId.sequenceNumber,
709
+ indexInBatch: (sequenceId.indexInBatch ?? 0) + 1,
710
+ };
564
711
  }
565
712
  //# sourceMappingURL=editManager.js.map