@fluidframework/sequence 2.0.0-rc.4.0.5 → 2.0.0-rc.5.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (168) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/api-extractor/api-extractor-lint-beta.cjs.json +5 -0
  3. package/api-extractor/api-extractor-lint-beta.esm.json +5 -0
  4. package/api-extractor/api-extractor-lint-bundle.json +5 -0
  5. package/api-extractor/api-extractor-lint-legacy.cjs.json +5 -0
  6. package/api-extractor/api-extractor-lint-legacy.esm.json +5 -0
  7. package/api-extractor/api-extractor-lint-public.cjs.json +5 -0
  8. package/api-extractor/api-extractor-lint-public.esm.json +5 -0
  9. package/api-extractor.json +1 -1
  10. package/api-report/{sequence.api.md → sequence.alpha.api.md} +71 -244
  11. package/api-report/sequence.beta.api.md +83 -0
  12. package/api-report/sequence.public.api.md +83 -0
  13. package/biome.jsonc +4 -0
  14. package/dist/IntervalCollectionValues.d.ts +1 -1
  15. package/dist/IntervalCollectionValues.d.ts.map +1 -1
  16. package/dist/IntervalCollectionValues.js.map +1 -1
  17. package/dist/index.d.ts +1 -1
  18. package/dist/index.d.ts.map +1 -1
  19. package/dist/index.js.map +1 -1
  20. package/dist/intervalCollection.d.ts +1 -1
  21. package/dist/intervalCollection.d.ts.map +1 -1
  22. package/dist/intervalCollection.js +4 -6
  23. package/dist/intervalCollection.js.map +1 -1
  24. package/dist/intervalCollectionMap.d.ts +2 -2
  25. package/dist/intervalCollectionMap.d.ts.map +1 -1
  26. package/dist/intervalCollectionMap.js.map +1 -1
  27. package/dist/intervalCollectionMapInterfaces.d.ts +2 -2
  28. package/dist/intervalCollectionMapInterfaces.d.ts.map +1 -1
  29. package/dist/intervalCollectionMapInterfaces.js.map +1 -1
  30. package/dist/intervalIndex/endpointInRangeIndex.d.ts.map +1 -1
  31. package/dist/intervalIndex/endpointInRangeIndex.js.map +1 -1
  32. package/dist/intervalIndex/endpointIndex.d.ts.map +1 -1
  33. package/dist/intervalIndex/endpointIndex.js.map +1 -1
  34. package/dist/intervalIndex/overlappingIntervalsIndex.js.map +1 -1
  35. package/dist/intervalIndex/overlappingSequenceIntervalsIndex.d.ts.map +1 -1
  36. package/dist/intervalIndex/overlappingSequenceIntervalsIndex.js +0 -3
  37. package/dist/intervalIndex/overlappingSequenceIntervalsIndex.js.map +1 -1
  38. package/dist/intervalIndex/startpointInRangeIndex.d.ts.map +1 -1
  39. package/dist/intervalIndex/startpointInRangeIndex.js.map +1 -1
  40. package/dist/intervalTree.js.map +1 -1
  41. package/dist/intervals/interval.d.ts +1 -1
  42. package/dist/intervals/interval.d.ts.map +1 -1
  43. package/dist/intervals/interval.js.map +1 -1
  44. package/dist/intervals/intervalUtils.d.ts +2 -2
  45. package/dist/intervals/intervalUtils.d.ts.map +1 -1
  46. package/dist/intervals/intervalUtils.js +0 -1
  47. package/dist/intervals/intervalUtils.js.map +1 -1
  48. package/dist/intervals/sequenceInterval.d.ts +1 -1
  49. package/dist/intervals/sequenceInterval.d.ts.map +1 -1
  50. package/dist/intervals/sequenceInterval.js +1 -1
  51. package/dist/intervals/sequenceInterval.js.map +1 -1
  52. package/dist/legacy.d.ts +1 -0
  53. package/dist/packageVersion.d.ts +1 -1
  54. package/dist/packageVersion.js +1 -1
  55. package/dist/packageVersion.js.map +1 -1
  56. package/dist/revertibles.d.ts.map +1 -1
  57. package/dist/revertibles.js +3 -3
  58. package/dist/revertibles.js.map +1 -1
  59. package/dist/sequence.d.ts +168 -133
  60. package/dist/sequence.d.ts.map +1 -1
  61. package/dist/sequence.js +59 -240
  62. package/dist/sequence.js.map +1 -1
  63. package/dist/sequenceDeltaEvent.js.map +1 -1
  64. package/dist/sequenceFactory.d.ts +2 -3
  65. package/dist/sequenceFactory.d.ts.map +1 -1
  66. package/dist/sequenceFactory.js.map +1 -1
  67. package/dist/sharedIntervalCollection.d.ts +4 -5
  68. package/dist/sharedIntervalCollection.d.ts.map +1 -1
  69. package/dist/sharedIntervalCollection.js +5 -5
  70. package/dist/sharedIntervalCollection.js.map +1 -1
  71. package/dist/sharedSequence.d.ts +1 -2
  72. package/dist/sharedSequence.d.ts.map +1 -1
  73. package/dist/sharedSequence.js.map +1 -1
  74. package/dist/sharedString.d.ts +3 -3
  75. package/dist/sharedString.d.ts.map +1 -1
  76. package/dist/sharedString.js.map +1 -1
  77. package/lib/IntervalCollectionValues.d.ts +1 -1
  78. package/lib/IntervalCollectionValues.d.ts.map +1 -1
  79. package/lib/IntervalCollectionValues.js +1 -1
  80. package/lib/IntervalCollectionValues.js.map +1 -1
  81. package/lib/index.d.ts +1 -1
  82. package/lib/index.d.ts.map +1 -1
  83. package/lib/index.js +1 -1
  84. package/lib/index.js.map +1 -1
  85. package/lib/intervalCollection.d.ts +1 -1
  86. package/lib/intervalCollection.d.ts.map +1 -1
  87. package/lib/intervalCollection.js +4 -6
  88. package/lib/intervalCollection.js.map +1 -1
  89. package/lib/intervalCollectionMap.d.ts +2 -2
  90. package/lib/intervalCollectionMap.d.ts.map +1 -1
  91. package/lib/intervalCollectionMap.js +1 -1
  92. package/lib/intervalCollectionMap.js.map +1 -1
  93. package/lib/intervalCollectionMapInterfaces.d.ts +2 -2
  94. package/lib/intervalCollectionMapInterfaces.d.ts.map +1 -1
  95. package/lib/intervalCollectionMapInterfaces.js.map +1 -1
  96. package/lib/intervalIndex/endpointInRangeIndex.d.ts.map +1 -1
  97. package/lib/intervalIndex/endpointInRangeIndex.js +1 -1
  98. package/lib/intervalIndex/endpointInRangeIndex.js.map +1 -1
  99. package/lib/intervalIndex/endpointIndex.d.ts.map +1 -1
  100. package/lib/intervalIndex/endpointIndex.js.map +1 -1
  101. package/lib/intervalIndex/overlappingIntervalsIndex.js.map +1 -1
  102. package/lib/intervalIndex/overlappingSequenceIntervalsIndex.d.ts.map +1 -1
  103. package/lib/intervalIndex/overlappingSequenceIntervalsIndex.js +0 -3
  104. package/lib/intervalIndex/overlappingSequenceIntervalsIndex.js.map +1 -1
  105. package/lib/intervalIndex/startpointInRangeIndex.d.ts.map +1 -1
  106. package/lib/intervalIndex/startpointInRangeIndex.js +1 -1
  107. package/lib/intervalIndex/startpointInRangeIndex.js.map +1 -1
  108. package/lib/intervalTree.js.map +1 -1
  109. package/lib/intervals/interval.d.ts +1 -1
  110. package/lib/intervals/interval.d.ts.map +1 -1
  111. package/lib/intervals/interval.js.map +1 -1
  112. package/lib/intervals/intervalUtils.d.ts +2 -2
  113. package/lib/intervals/intervalUtils.d.ts.map +1 -1
  114. package/lib/intervals/intervalUtils.js +0 -1
  115. package/lib/intervals/intervalUtils.js.map +1 -1
  116. package/lib/intervals/sequenceInterval.d.ts +1 -1
  117. package/lib/intervals/sequenceInterval.d.ts.map +1 -1
  118. package/lib/intervals/sequenceInterval.js +1 -1
  119. package/lib/intervals/sequenceInterval.js.map +1 -1
  120. package/lib/legacy.d.ts +1 -0
  121. package/lib/packageVersion.d.ts +1 -1
  122. package/lib/packageVersion.js +1 -1
  123. package/lib/packageVersion.js.map +1 -1
  124. package/lib/revertibles.d.ts.map +1 -1
  125. package/lib/revertibles.js +3 -3
  126. package/lib/revertibles.js.map +1 -1
  127. package/lib/sequence.d.ts +168 -133
  128. package/lib/sequence.d.ts.map +1 -1
  129. package/lib/sequence.js +42 -223
  130. package/lib/sequence.js.map +1 -1
  131. package/lib/sequenceDeltaEvent.js.map +1 -1
  132. package/lib/sequenceFactory.d.ts +2 -3
  133. package/lib/sequenceFactory.d.ts.map +1 -1
  134. package/lib/sequenceFactory.js.map +1 -1
  135. package/lib/sharedIntervalCollection.d.ts +4 -5
  136. package/lib/sharedIntervalCollection.d.ts.map +1 -1
  137. package/lib/sharedIntervalCollection.js +2 -2
  138. package/lib/sharedIntervalCollection.js.map +1 -1
  139. package/lib/sharedSequence.d.ts +1 -2
  140. package/lib/sharedSequence.d.ts.map +1 -1
  141. package/lib/sharedSequence.js.map +1 -1
  142. package/lib/sharedString.d.ts +3 -3
  143. package/lib/sharedString.d.ts.map +1 -1
  144. package/lib/sharedString.js.map +1 -1
  145. package/lib/tsdoc-metadata.json +1 -1
  146. package/package.json +77 -30
  147. package/src/IntervalCollectionValues.ts +8 -3
  148. package/src/index.ts +5 -1
  149. package/src/intervalCollection.ts +29 -18
  150. package/src/intervalCollectionMap.ts +6 -4
  151. package/src/intervalCollectionMapInterfaces.ts +2 -2
  152. package/src/intervalIndex/endpointInRangeIndex.ts +28 -22
  153. package/src/intervalIndex/endpointIndex.ts +3 -1
  154. package/src/intervalIndex/overlappingIntervalsIndex.ts +2 -2
  155. package/src/intervalIndex/overlappingSequenceIntervalsIndex.ts +0 -3
  156. package/src/intervalIndex/startpointInRangeIndex.ts +26 -20
  157. package/src/intervals/interval.ts +12 -9
  158. package/src/intervals/intervalUtils.ts +13 -5
  159. package/src/intervals/sequenceInterval.ts +2 -2
  160. package/src/packageVersion.ts +1 -1
  161. package/src/revertibles.ts +15 -11
  162. package/src/sequence.ts +302 -277
  163. package/src/sequenceFactory.ts +3 -5
  164. package/src/sharedIntervalCollection.ts +12 -6
  165. package/src/sharedSequence.ts +5 -2
  166. package/src/sharedString.ts +11 -4
  167. package/tsconfig.json +2 -0
  168. package/tsdoc.json +4 -0
package/dist/sequence.js CHANGED
@@ -10,11 +10,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
10
10
  exports.resetReentrancyLogCounter = exports.SharedSegmentSequence = void 0;
11
11
  const client_utils_1 = require("@fluid-internal/client-utils");
12
12
  const internal_1 = require("@fluidframework/core-utils/internal");
13
- const internal_2 = require("@fluidframework/merge-tree/internal");
14
- const protocol_definitions_1 = require("@fluidframework/protocol-definitions");
15
- const internal_3 = require("@fluidframework/runtime-utils/internal");
16
- const internal_4 = require("@fluidframework/shared-object-base/internal");
17
- const internal_5 = require("@fluidframework/telemetry-utils/internal");
13
+ const internal_2 = require("@fluidframework/driver-definitions/internal");
14
+ const internal_3 = require("@fluidframework/merge-tree/internal");
15
+ const internal_4 = require("@fluidframework/runtime-utils/internal");
16
+ const internal_5 = require("@fluidframework/shared-object-base/internal");
17
+ const internal_6 = require("@fluidframework/telemetry-utils/internal");
18
18
  const double_ended_queue_1 = __importDefault(require("double-ended-queue"));
19
19
  const intervalCollection_js_1 = require("./intervalCollection.js");
20
20
  const intervalCollectionMap_js_1 = require("./intervalCollectionMap.js");
@@ -24,15 +24,20 @@ const contentPath = "content";
24
24
  /**
25
25
  * @alpha
26
26
  */
27
- class SharedSegmentSequence extends internal_4.SharedObject {
27
+ class SharedSegmentSequence extends internal_5.SharedObject {
28
+ /**
29
+ * This promise is always immediately resolved, and awaiting it has no effect.
30
+ * @deprecated SharedSegmentSequence no longer supports partial loading.
31
+ * References to this promise may safely be deleted without affecting behavior.
32
+ */
28
33
  get loaded() {
29
- return this.loadedDeferred.promise;
34
+ return Promise.resolve();
30
35
  }
31
36
  static createOpsFromDelta(event) {
32
37
  const ops = [];
33
38
  for (const r of event.ranges) {
34
39
  switch (event.deltaOperation) {
35
- case internal_2.MergeTreeDeltaType.ANNOTATE: {
40
+ case internal_3.MergeTreeDeltaType.ANNOTATE: {
36
41
  const lastAnnotate = ops[ops.length - 1];
37
42
  const props = {};
38
43
  for (const key of Object.keys(r.propertyDeltas)) {
@@ -40,29 +45,29 @@ class SharedSegmentSequence extends internal_4.SharedObject {
40
45
  }
41
46
  if (lastAnnotate &&
42
47
  lastAnnotate.pos2 === r.position &&
43
- (0, internal_2.matchProperties)(lastAnnotate.props, props)) {
48
+ (0, internal_3.matchProperties)(lastAnnotate.props, props)) {
44
49
  lastAnnotate.pos2 += r.segment.cachedLength;
45
50
  }
46
51
  else {
47
- ops.push((0, internal_2.createAnnotateRangeOp)(r.position, r.position + r.segment.cachedLength, props));
52
+ ops.push((0, internal_3.createAnnotateRangeOp)(r.position, r.position + r.segment.cachedLength, props));
48
53
  }
49
54
  break;
50
55
  }
51
- case internal_2.MergeTreeDeltaType.INSERT:
52
- ops.push((0, internal_2.createInsertOp)(r.position, r.segment.clone().toJSONObject()));
56
+ case internal_3.MergeTreeDeltaType.INSERT:
57
+ ops.push((0, internal_3.createInsertOp)(r.position, r.segment.clone().toJSONObject()));
53
58
  break;
54
- case internal_2.MergeTreeDeltaType.REMOVE: {
59
+ case internal_3.MergeTreeDeltaType.REMOVE: {
55
60
  const lastRem = ops[ops.length - 1];
56
61
  if (lastRem?.pos1 === r.position) {
57
62
  (0, internal_1.assert)(lastRem.pos2 !== undefined, 0x3ff /* pos2 should not be undefined here */);
58
63
  lastRem.pos2 += r.segment.cachedLength;
59
64
  }
60
65
  else {
61
- ops.push((0, internal_2.createRemoveRangeOp)(r.position, r.position + r.segment.cachedLength));
66
+ ops.push((0, internal_3.createRemoveRangeOp)(r.position, r.position + r.segment.cachedLength));
62
67
  }
63
68
  break;
64
69
  }
65
- case internal_2.MergeTreeDeltaType.OBLITERATE: {
70
+ case internal_3.MergeTreeDeltaType.OBLITERATE: {
66
71
  // eslint-disable-next-line import/no-deprecated
67
72
  const lastRem = ops[ops.length - 1];
68
73
  if (lastRem?.pos1 === r.position) {
@@ -70,7 +75,7 @@ class SharedSegmentSequence extends internal_4.SharedObject {
70
75
  lastRem.pos2 += r.segment.cachedLength;
71
76
  }
72
77
  else {
73
- ops.push((0, internal_2.createObliterateRangeOp)(r.position, r.position + r.segment.cachedLength));
78
+ ops.push((0, internal_3.createObliterateRangeOp)(r.position, r.position + r.segment.cachedLength));
74
79
  }
75
80
  break;
76
81
  }
@@ -96,7 +101,6 @@ class SharedSegmentSequence extends internal_4.SharedObject {
96
101
  }
97
102
  constructor(dataStoreRuntime, id, attributes, segmentFromSpec) {
98
103
  super(id, dataStoreRuntime, attributes, "fluid_sequence_");
99
- this.dataStoreRuntime = dataStoreRuntime;
100
104
  this.id = id;
101
105
  this.segmentFromSpec = segmentFromSpec;
102
106
  /**
@@ -114,14 +118,6 @@ class SharedSegmentSequence extends internal_4.SharedObject {
114
118
  * runtime).
115
119
  */
116
120
  this.inFlightRefSeqs = new double_ended_queue_1.default();
117
- /** `Deferred` that triggers once the object is loaded */
118
- this.loadedDeferred = new internal_1.Deferred();
119
- // cache out going ops created when partial loading
120
- // eslint-disable-next-line import/no-deprecated
121
- this.loadedDeferredOutgoingOps = [];
122
- // cache incoming ops that arrive when partial loading
123
- this.deferIncomingOps = true;
124
- this.loadedDeferredIncomingOps = [];
125
121
  this.messagesSinceMSNChange = [];
126
122
  const getMinInFlightRefSeq = () => this.inFlightRefSeqs.get(0);
127
123
  this.guardReentrancy =
@@ -130,14 +126,11 @@ class SharedSegmentSequence extends internal_4.SharedObject {
130
126
  : createReentrancyDetector((depth) => {
131
127
  if (totalReentrancyLogs > 0) {
132
128
  totalReentrancyLogs--;
133
- this.logger.sendTelemetryEvent({ eventName: "LocalOpReentry", depth }, new internal_5.LoggingError(reentrancyErrorMessage));
129
+ this.logger.sendTelemetryEvent({ eventName: "LocalOpReentry", depth }, new internal_6.LoggingError(reentrancyErrorMessage));
134
130
  }
135
131
  });
136
- this.loadedDeferred.promise.catch((error) => {
137
- this.logger.sendErrorEvent({ eventName: "SequenceLoadFailed" }, error);
138
- });
139
132
  // eslint-disable-next-line import/no-deprecated
140
- this.client = new internal_2.Client(segmentFromSpec, (0, internal_5.createChildLogger)({
133
+ this.client = new internal_3.Client(segmentFromSpec, (0, internal_6.createChildLogger)({
141
134
  logger: this.logger,
142
135
  namespace: "SharedSegmentSequence.MergeTreeClient",
143
136
  }), dataStoreRuntime.options, getMinInFlightRefSeq);
@@ -159,62 +152,25 @@ class SharedSegmentSequence extends internal_4.SharedObject {
159
152
  this.submitLocalMessage(op, localOpMetadata);
160
153
  }, new intervalCollection_js_1.SequenceIntervalCollectionValueType(), dataStoreRuntime.options);
161
154
  }
162
- /**
163
- * @param start - The inclusive start of the range to remove
164
- * @param end - The exclusive end of the range to remove
165
- */
166
155
  removeRange(start, end) {
167
156
  this.guardReentrancy(() => this.client.removeRangeLocal(start, end));
168
157
  }
169
- /**
170
- * Obliterate is similar to remove, but differs in that segments concurrently
171
- * inserted into an obliterated range will also be removed
172
- *
173
- * @param start - The inclusive start of the range to obliterate
174
- * @param end - The exclusive end of the range to obliterate
175
- */
176
158
  obliterateRange(start, end) {
177
159
  this.guardReentrancy(() => this.client.obliterateRangeLocal(start, end));
178
160
  }
179
- /**
180
- * @deprecated The ability to create group ops will be removed in an upcoming
181
- * release, as group ops are redundant with the native batching capabilities
182
- * of the runtime
183
- */
184
161
  // eslint-disable-next-line import/no-deprecated
185
162
  groupOperation(groupOp) {
186
163
  this.guardReentrancy(() => this.client.localTransaction(groupOp));
187
164
  }
188
- /**
189
- * Finds the segment information (i.e. segment + offset) corresponding to a character position in the SharedString.
190
- * If the position is past the end of the string, `segment` and `offset` on the returned object may be undefined.
191
- * @param pos - Character position (index) into the current local view of the SharedString.
192
- */
193
165
  getContainingSegment(pos) {
194
166
  return this.client.getContainingSegment(pos);
195
167
  }
196
- /**
197
- * Returns the length of the current sequence for the client
198
- */
199
168
  getLength() {
200
169
  return this.client.getLength();
201
170
  }
202
- /**
203
- * Returns the current position of a segment, and -1 if the segment
204
- * does not exist in this sequence
205
- * @param segment - The segment to get the position of
206
- */
207
171
  getPosition(segment) {
208
172
  return this.client.getPosition(segment);
209
173
  }
210
- /**
211
- * Annotates the range with the provided properties
212
- *
213
- * @param start - The inclusive start position of the range to annotate
214
- * @param end - The exclusive end position of the range to annotate
215
- * @param props - The properties to annotate the range with
216
- *
217
- */
218
174
  annotateRange(start, end, props) {
219
175
  this.guardReentrancy(() => this.client.annotateRangeLocal(start, end, props));
220
176
  }
@@ -224,48 +180,15 @@ class SharedSegmentSequence extends internal_4.SharedObject {
224
180
  getRangeExtentsOfPosition(pos) {
225
181
  return this.client.getRangeExtentsOfPosition(pos);
226
182
  }
227
- /**
228
- * Creates a `LocalReferencePosition` on this SharedString. If the refType does not include
229
- * ReferenceType.Transient, the returned reference will be added to the localRefs on the provided segment.
230
- * @param segment - Segment to add the local reference on
231
- * @param offset - Offset on the segment at which to place the local reference
232
- * @param refType - ReferenceType for the created local reference
233
- * @param properties - PropertySet to place on the created local reference
234
- */
235
183
  createLocalReferencePosition(segment, offset, refType, properties, slidingPreference, canSlideToEndpoint) {
236
184
  return this.client.createLocalReferencePosition(segment, offset, refType, properties, slidingPreference, canSlideToEndpoint);
237
185
  }
238
- /**
239
- * Resolves a `ReferencePosition` into a character position using this client's perspective.
240
- *
241
- * Reference positions that point to a character that has been removed will
242
- * always return the position of the nearest non-removed character, regardless
243
- * of `ReferenceType`. To handle this case specifically, one may wish
244
- * to look at the segment returned by `ReferencePosition.getSegment`.
245
- */
246
186
  localReferencePositionToPosition(lref) {
247
187
  return this.client.localReferencePositionToPosition(lref);
248
188
  }
249
- /**
250
- * Removes a `LocalReferencePosition` from this SharedString.
251
- */
252
189
  removeLocalReferencePosition(lref) {
253
190
  return this.client.removeLocalReferencePosition(lref);
254
191
  }
255
- /**
256
- * Resolves a remote client's position against the local sequence
257
- * and returns the remote client's position relative to the local
258
- * sequence. The client ref seq must be above the minimum sequence number
259
- * or the return value will be undefined.
260
- * Generally this method is used in conjunction with signals which provide
261
- * point in time values for the below parameters, and is useful for things
262
- * like displaying user position. It should not be used with persisted values
263
- * as persisted values will quickly become invalid as the remoteClientRefSeq
264
- * moves below the minimum sequence number
265
- * @param remoteClientPosition - The remote client's position to resolve
266
- * @param remoteClientRefSeq - The reference sequence number of the remote client
267
- * @param remoteClientId - The client id of the remote client
268
- */
269
192
  resolveRemoteClientPosition(remoteClientPosition, remoteClientRefSeq, remoteClientId) {
270
193
  return this.client.resolveRemoteClientPosition(remoteClientPosition, remoteClientRefSeq, remoteClientId);
271
194
  }
@@ -274,85 +197,28 @@ class SharedSegmentSequence extends internal_4.SharedObject {
274
197
  return;
275
198
  }
276
199
  this.inFlightRefSeqs.push(this.currentRefSeq);
277
- const metadata = this.client.peekPendingSegmentGroups(message.type === internal_2.MergeTreeDeltaType.GROUP ? message.ops.length : 1);
278
- // if loading isn't complete, we need to cache
279
- // local ops until loading is complete, and then
280
- // they will be present
281
- if (!this.loadedDeferred.isCompleted) {
282
- this.loadedDeferredOutgoingOps.push(metadata ? [message, metadata] : message);
283
- }
284
- else {
285
- this.submitLocalMessage(message, metadata);
286
- }
200
+ const metadata = this.client.peekPendingSegmentGroups(message.type === internal_3.MergeTreeDeltaType.GROUP ? message.ops.length : 1);
201
+ this.submitLocalMessage(message, metadata);
287
202
  }
288
- /**
289
- * Given a position specified relative to a marker id, lookup the marker
290
- * and convert the position to a character position.
291
- * @param relativePos - Id of marker (may be indirect) and whether position is before or after marker.
292
- */
293
203
  posFromRelativePos(relativePos) {
294
204
  return this.client.posFromRelativePos(relativePos);
295
205
  }
296
- /**
297
- * Walk the underlying segments of the sequence.
298
- * The walked segments may extend beyond the range if the segments cross the
299
- * ranges start or end boundaries.
300
- *
301
- * Set split range to true to ensure only segments within the range are walked.
302
- *
303
- * @param handler - The function to handle each segment. Traversal ends if
304
- * this function returns true.
305
- * @param start - Optional. The start of range walk.
306
- * @param end - Optional. The end of range walk
307
- * @param accum - Optional. An object that will be passed to the handler for accumulation
308
- * @param splitRange - Optional. Splits boundary segments on the range boundaries
309
- */
310
206
  walkSegments(handler, start, end, accum, splitRange = false) {
311
207
  this.client.walkSegments(handler, start, end, accum, splitRange);
312
208
  }
313
- /**
314
- * @returns The most recent sequence number which has been acked by the server and processed by this
315
- * SharedSegmentSequence.
316
- */
317
209
  getCurrentSeq() {
318
210
  return this.client.getCurrentSeq();
319
211
  }
320
- /**
321
- * Inserts a segment directly before a `ReferencePosition`.
322
- * @param refPos - The reference position to insert the segment at
323
- * @param segment - The segment to insert
324
- */
325
212
  insertAtReferencePosition(pos, segment) {
326
213
  this.guardReentrancy(() => this.client.insertAtReferencePositionLocal(pos, segment));
327
214
  }
328
- /**
329
- * Inserts a segment
330
- * @param start - The position to insert the segment at
331
- * @param spec - The segment to inserts spec
332
- */
333
215
  insertFromSpec(pos, spec) {
334
216
  const segment = this.segmentFromSpec(spec);
335
217
  this.guardReentrancy(() => this.client.insertSegmentLocal(pos, segment));
336
218
  }
337
- /**
338
- * Retrieves the interval collection keyed on `label`. If no such interval collection exists,
339
- * creates one.
340
- */
341
219
  getIntervalCollection(label) {
342
220
  return this.intervalCollections.get(label);
343
221
  }
344
- /**
345
- * @returns An iterable object that enumerates the IntervalCollection labels.
346
- *
347
- * @example
348
- *
349
- * ```typescript
350
- * const iter = this.getIntervalCollectionKeys();
351
- * for (key of iter)
352
- * const collection = this.getIntervalCollection(key);
353
- * ...
354
- * ```
355
- */
356
222
  getIntervalCollectionLabels() {
357
223
  return this.intervalCollections.keys();
358
224
  }
@@ -360,7 +226,7 @@ class SharedSegmentSequence extends internal_4.SharedObject {
360
226
  * {@inheritDoc @fluidframework/shared-object-base#SharedObject.summarizeCore}
361
227
  */
362
228
  summarizeCore(serializer, telemetryContext) {
363
- const builder = new internal_3.SummaryTreeBuilder();
229
+ const builder = new internal_4.SummaryTreeBuilder();
364
230
  // conditionally write the interval collection blob
365
231
  // only if it has entries
366
232
  if (this.intervalCollections.size > 0) {
@@ -435,45 +301,35 @@ class SharedSegmentSequence extends internal_4.SharedObject {
435
301
  // this will load the header, and return a promise
436
302
  // that will resolve when the body is loaded
437
303
  // and the catchup ops are available.
438
- const { catchupOpsP } = await this.client.load(this.runtime, new internal_3.ObjectStoragePartition(storage, contentPath), this.serializer);
439
- // setup a promise to process the
440
- // catch up ops, and finishing the loading process
441
- const loadCatchUpOps = catchupOpsP
442
- .then((msgs) => {
443
- msgs.forEach((m) => {
444
- const collabWindow = this.client.getCollabWindow();
445
- if (m.minimumSequenceNumber < collabWindow.minSeq ||
446
- m.referenceSequenceNumber < collabWindow.minSeq ||
447
- m.sequenceNumber <= collabWindow.minSeq ||
448
- // sequenceNumber could be the same if messages are part of a grouped batch
449
- m.sequenceNumber < collabWindow.currentSeq) {
450
- throw new Error(`Invalid catchup operations in snapshot: ${JSON.stringify({
451
- op: {
452
- seq: m.sequenceNumber,
453
- minSeq: m.minimumSequenceNumber,
454
- refSeq: m.referenceSequenceNumber,
455
- },
456
- collabWindow: {
457
- seq: collabWindow.currentSeq,
458
- minSeq: collabWindow.minSeq,
459
- },
460
- })}`);
461
- }
462
- this.processMergeTreeMsg(m);
463
- });
464
- this.loadFinished();
465
- })
466
- .catch((error) => {
467
- this.loadFinished(error);
304
+ const { catchupOpsP } = await this.client.load(this.runtime, new internal_4.ObjectStoragePartition(storage, contentPath), this.serializer);
305
+ // process the catch up ops, and finishing the loading process
306
+ (await catchupOpsP).forEach((m) => {
307
+ const collabWindow = this.client.getCollabWindow();
308
+ if (m.minimumSequenceNumber < collabWindow.minSeq ||
309
+ m.referenceSequenceNumber < collabWindow.minSeq ||
310
+ m.sequenceNumber <= collabWindow.minSeq ||
311
+ // sequenceNumber could be the same if messages are part of a grouped batch
312
+ m.sequenceNumber < collabWindow.currentSeq) {
313
+ throw new Error(`Invalid catchup operations in snapshot: ${JSON.stringify({
314
+ op: {
315
+ seq: m.sequenceNumber,
316
+ minSeq: m.minimumSequenceNumber,
317
+ refSeq: m.referenceSequenceNumber,
318
+ },
319
+ collabWindow: {
320
+ seq: collabWindow.currentSeq,
321
+ minSeq: collabWindow.minSeq,
322
+ },
323
+ })}`);
324
+ }
325
+ this.processMergeTreeMsg(m);
468
326
  });
469
- if (this.dataStoreRuntime.options.sequenceInitializeFromHeaderOnly !== true) {
470
- // if we not doing partial load, await the catch up ops,
471
- // and the finalization of the load
472
- await loadCatchUpOps;
473
- }
327
+ // Initialize the interval collections
328
+ this.initializeIntervalCollections();
474
329
  }
475
330
  catch (error) {
476
- this.loadFinished(error);
331
+ this.logger.sendErrorEvent({ eventName: "SequenceLoadFailed" }, error);
332
+ throw error;
477
333
  }
478
334
  }
479
335
  /**
@@ -491,18 +347,10 @@ class SharedSegmentSequence extends internal_4.SharedObject {
491
347
  // See "handles stashed ops created on top of sequenced local ops" for one such test case.
492
348
  // assert(recordedRefSeq <= message.referenceSequenceNumber, "RefSeq mismatch");
493
349
  }
494
- // if loading isn't complete, we need to cache all
495
- // incoming ops to be applied after loading is complete
496
- if (this.deferIncomingOps) {
497
- (0, internal_1.assert)(!local, 0x072 /* "Unexpected local op when loading not finished" */);
498
- this.loadedDeferredIncomingOps.push(message);
499
- }
500
- else {
501
- (0, internal_1.assert)(message.type === protocol_definitions_1.MessageType.Operation, 0x073 /* "Sequence message not operation" */);
502
- const handled = this.intervalCollections.tryProcessMessage(message.contents, local, message, localOpMetadata);
503
- if (!handled) {
504
- this.processMergeTreeMsg(message, local);
505
- }
350
+ (0, internal_1.assert)(message.type === internal_2.MessageType.Operation, 0x073 /* "Sequence message not operation" */);
351
+ const handled = this.intervalCollections.tryProcessMessage(message.contents, local, message, localOpMetadata);
352
+ if (!handled) {
353
+ this.processMergeTreeMsg(message, local);
506
354
  }
507
355
  }
508
356
  /**
@@ -520,7 +368,7 @@ class SharedSegmentSequence extends internal_4.SharedObject {
520
368
  */
521
369
  initializeLocalCore() {
522
370
  super.initializeLocalCore();
523
- this.loadFinished();
371
+ this.initializeIntervalCollections();
524
372
  }
525
373
  /**
526
374
  * {@inheritDoc @fluidframework/shared-object-base#SharedObjectCore.applyStashedOp}
@@ -531,8 +379,6 @@ class SharedSegmentSequence extends internal_4.SharedObject {
531
379
  }
532
380
  }
533
381
  summarizeMergeTree(serializer) {
534
- // Are we fully loaded? If not, things will go south
535
- (0, internal_1.assert)(this.loadedDeferred.isCompleted, 0x074 /* "Snapshot called when not fully loaded" */);
536
382
  const minSeq = this.deltaManager.minimumSequenceNumber;
537
383
  this.processMinSequenceNumberChanged(minSeq);
538
384
  this.messagesSinceMSNChange.forEach((m) => {
@@ -566,7 +412,7 @@ class SharedSegmentSequence extends internal_4.SharedObject {
566
412
  ...message,
567
413
  referenceSequenceNumber: stashMessage.sequenceNumber - 1,
568
414
  // eslint-disable-next-line import/no-deprecated
569
- contents: ops.length !== 1 ? (0, internal_2.createGroupOp)(...ops) : ops[0],
415
+ contents: ops.length !== 1 ? (0, internal_3.createGroupOp)(...ops) : ops[0],
570
416
  };
571
417
  }
572
418
  this.messagesSinceMSNChange.push(stashMessage);
@@ -588,33 +434,6 @@ class SharedSegmentSequence extends internal_4.SharedObject {
588
434
  this.messagesSinceMSNChange = this.messagesSinceMSNChange.slice(index);
589
435
  }
590
436
  }
591
- loadFinished(error) {
592
- if (!this.loadedDeferred.isCompleted) {
593
- // Initialize the interval collections
594
- this.initializeIntervalCollections();
595
- if (error) {
596
- this.loadedDeferred.reject(error);
597
- throw error;
598
- }
599
- else {
600
- // it is important this series remains synchronous
601
- // first we stop deferring incoming ops, and apply then all
602
- this.deferIncomingOps = false;
603
- for (const message of this.loadedDeferredIncomingOps) {
604
- this.processCore(message, false, undefined);
605
- }
606
- this.loadedDeferredIncomingOps.length = 0;
607
- // then resolve the loaded promise
608
- // and resubmit all the outstanding ops, as the snapshot
609
- // is fully loaded, and all outstanding ops are applied
610
- this.loadedDeferred.resolve();
611
- for (const [messageContent, opMetadata] of this.loadedDeferredOutgoingOps) {
612
- this.reSubmitCore(messageContent, opMetadata);
613
- }
614
- this.loadedDeferredOutgoingOps.length = 0;
615
- }
616
- }
617
- }
618
437
  initializeIntervalCollections() {
619
438
  // Listen and initialize new SharedIntervalCollections
620
439
  this.intervalCollections.eventEmitter.on("create", ({ key, previousValue }, local) => {
@@ -678,6 +497,6 @@ function resetReentrancyLogCounter() {
678
497
  exports.resetReentrancyLogCounter = resetReentrancyLogCounter;
679
498
  const reentrancyErrorMessage = "Reentrancy detected in sequence local ops";
680
499
  const ensureNoReentrancy = createReentrancyDetector(() => {
681
- throw new internal_5.LoggingError(reentrancyErrorMessage);
500
+ throw new internal_6.LoggingError(reentrancyErrorMessage);
682
501
  });
683
502
  //# sourceMappingURL=sequence.js.map