@fluidframework/sequence 2.0.0-dev-rc.3.0.0.254866 → 2.0.0-dev-rc.5.0.0.263932
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.
- package/.eslintrc.cjs +29 -0
- package/CHANGELOG.md +41 -0
- package/README.md +10 -3
- package/api-report/sequence.api.md +35 -38
- package/beta.d.ts +11 -0
- package/dist/IntervalCollectionValues.d.ts +0 -2
- package/dist/IntervalCollectionValues.d.ts.map +1 -1
- package/dist/IntervalCollectionValues.js +0 -2
- package/dist/IntervalCollectionValues.js.map +1 -1
- package/dist/beta.d.ts +3 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/dist/intervalCollection.js +1 -1
- package/dist/intervalCollection.js.map +1 -1
- package/dist/intervalIndex/endpointInRangeIndex.d.ts +2 -2
- package/dist/intervalIndex/endpointInRangeIndex.d.ts.map +1 -1
- package/dist/intervalIndex/endpointInRangeIndex.js.map +1 -1
- package/dist/intervalIndex/endpointIndex.d.ts +2 -2
- package/dist/intervalIndex/endpointIndex.d.ts.map +1 -1
- package/dist/intervalIndex/endpointIndex.js.map +1 -1
- package/dist/intervalIndex/overlappingIntervalsIndex.d.ts +2 -2
- package/dist/intervalIndex/overlappingIntervalsIndex.d.ts.map +1 -1
- package/dist/intervalIndex/overlappingIntervalsIndex.js.map +1 -1
- package/dist/intervalIndex/overlappingSequenceIntervalsIndex.d.ts +2 -2
- package/dist/intervalIndex/overlappingSequenceIntervalsIndex.d.ts.map +1 -1
- package/dist/intervalIndex/overlappingSequenceIntervalsIndex.js.map +1 -1
- package/dist/intervalIndex/startpointInRangeIndex.d.ts +2 -2
- package/dist/intervalIndex/startpointInRangeIndex.d.ts.map +1 -1
- package/dist/intervalIndex/startpointInRangeIndex.js.map +1 -1
- package/dist/intervals/interval.js +1 -1
- package/dist/intervals/interval.js.map +1 -1
- package/dist/intervals/sequenceInterval.js +1 -1
- package/dist/intervals/sequenceInterval.js.map +1 -1
- package/dist/{alpha.d.ts → legacy.d.ts} +4 -2
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/public.d.ts +3 -0
- package/dist/revertibles.d.ts +6 -6
- package/dist/revertibles.d.ts.map +1 -1
- package/dist/revertibles.js.map +1 -1
- package/dist/sequence.d.ts +5 -8
- package/dist/sequence.d.ts.map +1 -1
- package/dist/sequence.js +44 -101
- package/dist/sequence.js.map +1 -1
- package/dist/sequenceDeltaEvent.d.ts +24 -3
- package/dist/sequenceDeltaEvent.d.ts.map +1 -1
- package/dist/sequenceDeltaEvent.js +16 -3
- package/dist/sequenceDeltaEvent.js.map +1 -1
- package/dist/sequenceFactory.d.ts +15 -7
- package/dist/sequenceFactory.d.ts.map +1 -1
- package/dist/sequenceFactory.js +9 -6
- package/dist/sequenceFactory.js.map +1 -1
- package/dist/sharedString.d.ts +70 -47
- package/dist/sharedString.d.ts.map +1 -1
- package/dist/sharedString.js +15 -52
- package/dist/sharedString.js.map +1 -1
- package/internal.d.ts +11 -0
- package/legacy.d.ts +11 -0
- package/lib/IntervalCollectionValues.d.ts +0 -2
- package/lib/IntervalCollectionValues.d.ts.map +1 -1
- package/lib/IntervalCollectionValues.js +0 -2
- package/lib/IntervalCollectionValues.js.map +1 -1
- package/lib/beta.d.ts +3 -0
- package/lib/index.d.ts +2 -2
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +2 -2
- package/lib/index.js.map +1 -1
- package/lib/intervalCollection.js +1 -1
- package/lib/intervalCollection.js.map +1 -1
- package/lib/intervalIndex/endpointInRangeIndex.d.ts +2 -2
- package/lib/intervalIndex/endpointInRangeIndex.d.ts.map +1 -1
- package/lib/intervalIndex/endpointInRangeIndex.js.map +1 -1
- package/lib/intervalIndex/endpointIndex.d.ts +2 -2
- package/lib/intervalIndex/endpointIndex.d.ts.map +1 -1
- package/lib/intervalIndex/endpointIndex.js.map +1 -1
- package/lib/intervalIndex/overlappingIntervalsIndex.d.ts +2 -2
- package/lib/intervalIndex/overlappingIntervalsIndex.d.ts.map +1 -1
- package/lib/intervalIndex/overlappingIntervalsIndex.js.map +1 -1
- package/lib/intervalIndex/overlappingSequenceIntervalsIndex.d.ts +2 -2
- package/lib/intervalIndex/overlappingSequenceIntervalsIndex.d.ts.map +1 -1
- package/lib/intervalIndex/overlappingSequenceIntervalsIndex.js.map +1 -1
- package/lib/intervalIndex/startpointInRangeIndex.d.ts +2 -2
- package/lib/intervalIndex/startpointInRangeIndex.d.ts.map +1 -1
- package/lib/intervalIndex/startpointInRangeIndex.js.map +1 -1
- package/lib/intervals/interval.js +1 -1
- package/lib/intervals/interval.js.map +1 -1
- package/lib/intervals/sequenceInterval.js +1 -1
- package/lib/intervals/sequenceInterval.js.map +1 -1
- package/lib/{alpha.d.ts → legacy.d.ts} +4 -2
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/lib/public.d.ts +3 -0
- package/lib/revertibles.d.ts +6 -6
- package/lib/revertibles.d.ts.map +1 -1
- package/lib/revertibles.js.map +1 -1
- package/lib/sequence.d.ts +5 -8
- package/lib/sequence.d.ts.map +1 -1
- package/lib/sequence.js +47 -103
- package/lib/sequence.js.map +1 -1
- package/lib/sequenceDeltaEvent.d.ts +24 -3
- package/lib/sequenceDeltaEvent.d.ts.map +1 -1
- package/lib/sequenceDeltaEvent.js +16 -3
- package/lib/sequenceDeltaEvent.js.map +1 -1
- package/lib/sequenceFactory.d.ts +15 -7
- package/lib/sequenceFactory.d.ts.map +1 -1
- package/lib/sequenceFactory.js +9 -6
- package/lib/sequenceFactory.js.map +1 -1
- package/lib/sharedString.d.ts +70 -47
- package/lib/sharedString.d.ts.map +1 -1
- package/lib/sharedString.js +13 -50
- package/lib/sharedString.js.map +1 -1
- package/lib/tsdoc-metadata.json +1 -1
- package/package.json +47 -33
- package/src/IntervalCollectionValues.ts +0 -2
- package/src/index.ts +2 -2
- package/src/intervalCollection.ts +1 -1
- package/src/intervalIndex/endpointInRangeIndex.ts +2 -2
- package/src/intervalIndex/endpointIndex.ts +2 -2
- package/src/intervalIndex/overlappingIntervalsIndex.ts +2 -2
- package/src/intervalIndex/overlappingSequenceIntervalsIndex.ts +2 -2
- package/src/intervalIndex/startpointInRangeIndex.ts +2 -2
- package/src/intervals/interval.ts +1 -1
- package/src/intervals/sequenceInterval.ts +1 -1
- package/src/packageVersion.ts +1 -1
- package/src/revertibles.ts +18 -14
- package/src/sequence.ts +63 -121
- package/src/sequenceDeltaEvent.ts +12 -1
- package/src/sequenceFactory.ts +21 -9
- package/src/sharedString.ts +89 -56
|
@@ -16,7 +16,7 @@ import {
|
|
|
16
16
|
SequenceInterval,
|
|
17
17
|
sequenceIntervalHelpers,
|
|
18
18
|
} from "../intervals/index.js";
|
|
19
|
-
import {
|
|
19
|
+
import { ISharedString } from "../sharedString.js";
|
|
20
20
|
|
|
21
21
|
import { IntervalIndex } from "./intervalIndex.js";
|
|
22
22
|
|
|
@@ -182,7 +182,7 @@ export class OverlappingIntervalsIndex<TInterval extends ISerializableInterval>
|
|
|
182
182
|
* @alpha
|
|
183
183
|
*/
|
|
184
184
|
export function createOverlappingIntervalsIndex(
|
|
185
|
-
sharedString:
|
|
185
|
+
sharedString: ISharedString,
|
|
186
186
|
): IOverlappingIntervalsIndex<SequenceInterval> {
|
|
187
187
|
const client = (sharedString as unknown as { client: Client }).client;
|
|
188
188
|
return new OverlappingIntervalsIndex<SequenceInterval>(client, sequenceIntervalHelpers);
|
|
@@ -19,7 +19,7 @@ import {
|
|
|
19
19
|
createPositionReferenceFromSegoff,
|
|
20
20
|
sequenceIntervalHelpers,
|
|
21
21
|
} from "../intervals/index.js";
|
|
22
|
-
import {
|
|
22
|
+
import { ISharedString } from "../sharedString.js";
|
|
23
23
|
|
|
24
24
|
import { OverlappingIntervalsIndex } from "./overlappingIntervalsIndex.js";
|
|
25
25
|
import { SequenceIntervalIndexes } from "./sequenceIntervalIndexes.js";
|
|
@@ -76,7 +76,7 @@ class OverlappingSequenceIntervalsIndex
|
|
|
76
76
|
* @internal
|
|
77
77
|
*/
|
|
78
78
|
export function createOverlappingSequenceIntervalsIndex(
|
|
79
|
-
sharedString:
|
|
79
|
+
sharedString: ISharedString,
|
|
80
80
|
): SequenceIntervalIndexes.Overlapping {
|
|
81
81
|
const client = (sharedString as unknown as { client: Client }).client;
|
|
82
82
|
return new OverlappingSequenceIntervalsIndex(client);
|
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
SequenceInterval,
|
|
15
15
|
sequenceIntervalHelpers,
|
|
16
16
|
} from "../intervals/index.js";
|
|
17
|
-
import {
|
|
17
|
+
import { ISharedString } from "../sharedString.js";
|
|
18
18
|
|
|
19
19
|
import { IntervalIndex } from "./intervalIndex.js";
|
|
20
20
|
import { HasComparisonOverride, compareOverrideables, forceCompare } from "./intervalIndexUtils.js";
|
|
@@ -110,7 +110,7 @@ export class StartpointInRangeIndex<TInterval extends ISerializableInterval>
|
|
|
110
110
|
* @internal
|
|
111
111
|
*/
|
|
112
112
|
export function createStartpointInRangeIndex(
|
|
113
|
-
sharedString:
|
|
113
|
+
sharedString: ISharedString,
|
|
114
114
|
): IStartpointInRangeIndex<SequenceInterval> {
|
|
115
115
|
const client = (sharedString as unknown as { client: Client }).client;
|
|
116
116
|
return new StartpointInRangeIndex<SequenceInterval>(client, sequenceIntervalHelpers);
|
|
@@ -89,7 +89,7 @@ export class Interval implements ISerializableInterval {
|
|
|
89
89
|
start: this.start,
|
|
90
90
|
};
|
|
91
91
|
if (this.properties) {
|
|
92
|
-
serializedInterval.properties = this.properties;
|
|
92
|
+
serializedInterval.properties = { ...this.properties };
|
|
93
93
|
}
|
|
94
94
|
return serializedInterval;
|
|
95
95
|
}
|
|
@@ -198,7 +198,7 @@ export class SequenceInterval implements ISerializableInterval {
|
|
|
198
198
|
};
|
|
199
199
|
|
|
200
200
|
if (this.properties) {
|
|
201
|
-
serializedInterval.properties = this.properties;
|
|
201
|
+
serializedInterval.properties = { ...this.properties };
|
|
202
202
|
}
|
|
203
203
|
|
|
204
204
|
return serializedInterval;
|
package/src/packageVersion.ts
CHANGED
package/src/revertibles.ts
CHANGED
|
@@ -26,7 +26,7 @@ import {
|
|
|
26
26
|
import { InteriorSequencePlace, Side } from "./intervalCollection.js";
|
|
27
27
|
import { IntervalOpType, SequenceInterval } from "./intervals/index.js";
|
|
28
28
|
import { ISequenceDeltaRange, SequenceDeltaEvent } from "./sequenceDeltaEvent.js";
|
|
29
|
-
import {
|
|
29
|
+
import { ISharedString, SharedStringSegment } from "./sharedString.js";
|
|
30
30
|
|
|
31
31
|
/**
|
|
32
32
|
* Data for undoing edits on SharedStrings and Intervals.
|
|
@@ -111,7 +111,7 @@ export function appendAddIntervalToRevertibles(
|
|
|
111
111
|
* @alpha
|
|
112
112
|
*/
|
|
113
113
|
export function appendDeleteIntervalToRevertibles(
|
|
114
|
-
string:
|
|
114
|
+
string: ISharedString,
|
|
115
115
|
interval: SequenceInterval,
|
|
116
116
|
revertibles: SharedStringRevertible[],
|
|
117
117
|
): SharedStringRevertible[] {
|
|
@@ -163,7 +163,7 @@ export function appendDeleteIntervalToRevertibles(
|
|
|
163
163
|
* @alpha
|
|
164
164
|
*/
|
|
165
165
|
export function appendChangeIntervalToRevertibles(
|
|
166
|
-
string:
|
|
166
|
+
string: ISharedString,
|
|
167
167
|
newInterval: SequenceInterval,
|
|
168
168
|
previousInterval: SequenceInterval,
|
|
169
169
|
revertibles: SharedStringRevertible[],
|
|
@@ -273,7 +273,7 @@ function addIfRevertibleRef(
|
|
|
273
273
|
* @alpha
|
|
274
274
|
*/
|
|
275
275
|
export function appendSharedStringDeltaToRevertibles(
|
|
276
|
-
string:
|
|
276
|
+
string: ISharedString,
|
|
277
277
|
delta: SequenceDeltaEvent,
|
|
278
278
|
revertibles: SharedStringRevertible[],
|
|
279
279
|
) {
|
|
@@ -366,7 +366,7 @@ export function appendSharedStringDeltaToRevertibles(
|
|
|
366
366
|
* @alpha
|
|
367
367
|
*/
|
|
368
368
|
export function discardSharedStringRevertibles(
|
|
369
|
-
sharedString:
|
|
369
|
+
sharedString: ISharedString,
|
|
370
370
|
revertibles: SharedStringRevertible[],
|
|
371
371
|
) {
|
|
372
372
|
revertibles.forEach((r) => {
|
|
@@ -379,7 +379,11 @@ export function discardSharedStringRevertibles(
|
|
|
379
379
|
});
|
|
380
380
|
}
|
|
381
381
|
|
|
382
|
-
function getSlidePosition(
|
|
382
|
+
function getSlidePosition(
|
|
383
|
+
string: ISharedString,
|
|
384
|
+
lref: LocalReferencePosition,
|
|
385
|
+
pos: number,
|
|
386
|
+
): number {
|
|
383
387
|
const slide = getSlideToSegoff(
|
|
384
388
|
{ segment: lref.getSegment(), offset: undefined },
|
|
385
389
|
lref.slidingPreference,
|
|
@@ -397,7 +401,7 @@ function isValidRange(
|
|
|
397
401
|
startSlide: SlidingPreference | undefined,
|
|
398
402
|
end: number,
|
|
399
403
|
endSlide: SlidingPreference | undefined,
|
|
400
|
-
string:
|
|
404
|
+
string: ISharedString,
|
|
401
405
|
) {
|
|
402
406
|
return (
|
|
403
407
|
start >= 0 &&
|
|
@@ -412,7 +416,7 @@ function isValidRange(
|
|
|
412
416
|
}
|
|
413
417
|
|
|
414
418
|
function revertLocalAdd(
|
|
415
|
-
string:
|
|
419
|
+
string: ISharedString,
|
|
416
420
|
revertible: TypedRevertible<typeof IntervalOpType.ADD>,
|
|
417
421
|
) {
|
|
418
422
|
const id = getUpdatedIdFromInterval(revertible.interval);
|
|
@@ -441,7 +445,7 @@ function createSequencePlace(
|
|
|
441
445
|
}
|
|
442
446
|
|
|
443
447
|
function revertLocalDelete(
|
|
444
|
-
string:
|
|
448
|
+
string: ISharedString,
|
|
445
449
|
revertible: TypedRevertible<typeof IntervalOpType.DELETE>,
|
|
446
450
|
) {
|
|
447
451
|
const label = revertible.interval.properties.referenceRangeLabels[0];
|
|
@@ -480,7 +484,7 @@ function revertLocalDelete(
|
|
|
480
484
|
}
|
|
481
485
|
|
|
482
486
|
function revertLocalChange(
|
|
483
|
-
string:
|
|
487
|
+
string: ISharedString,
|
|
484
488
|
revertible: TypedRevertible<typeof IntervalOpType.CHANGE>,
|
|
485
489
|
) {
|
|
486
490
|
const label = revertible.interval.properties.referenceRangeLabels[0];
|
|
@@ -520,7 +524,7 @@ function revertLocalChange(
|
|
|
520
524
|
}
|
|
521
525
|
|
|
522
526
|
function revertLocalPropertyChanged(
|
|
523
|
-
string:
|
|
527
|
+
string: ISharedString,
|
|
524
528
|
revertible: TypedRevertible<typeof IntervalOpType.PROPERTY_CHANGED>,
|
|
525
529
|
) {
|
|
526
530
|
const label = revertible.interval.properties.referenceRangeLabels[0];
|
|
@@ -554,7 +558,7 @@ function newPosition(offset: number | undefined, restoredRanges: SortedRangeSet)
|
|
|
554
558
|
function newEndpointPosition(
|
|
555
559
|
offset: number | undefined,
|
|
556
560
|
restoredRanges: SortedRangeSet,
|
|
557
|
-
sharedString:
|
|
561
|
+
sharedString: ISharedString,
|
|
558
562
|
) {
|
|
559
563
|
const pos = newPosition(offset, restoredRanges);
|
|
560
564
|
return pos === undefined ? undefined : sharedString.getPosition(pos.segment) + pos.offset;
|
|
@@ -573,7 +577,7 @@ class SortedRangeSet extends SortedSet<RangeInfo, string> {
|
|
|
573
577
|
}
|
|
574
578
|
|
|
575
579
|
function revertLocalSequenceRemove(
|
|
576
|
-
sharedString:
|
|
580
|
+
sharedString: ISharedString,
|
|
577
581
|
revertible: TypedRevertible<typeof IntervalOpType.POSITION_REMOVE>,
|
|
578
582
|
) {
|
|
579
583
|
const restoredRanges = new SortedRangeSet();
|
|
@@ -657,7 +661,7 @@ function revertLocalSequenceRemove(
|
|
|
657
661
|
* @alpha
|
|
658
662
|
*/
|
|
659
663
|
export function revertSharedStringRevertibles(
|
|
660
|
-
sharedString:
|
|
664
|
+
sharedString: ISharedString,
|
|
661
665
|
revertibles: SharedStringRevertible[],
|
|
662
666
|
) {
|
|
663
667
|
while (revertibles.length > 0) {
|
package/src/sequence.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
import { bufferToString } from "@fluid-internal/client-utils";
|
|
7
7
|
import { IEventThisPlaceHolder } from "@fluidframework/core-interfaces";
|
|
8
|
-
import { assert
|
|
8
|
+
import { assert } from "@fluidframework/core-utils/internal";
|
|
9
9
|
import {
|
|
10
10
|
IChannelAttributes,
|
|
11
11
|
IChannelStorageService,
|
|
@@ -17,7 +17,9 @@ import {
|
|
|
17
17
|
IJSONSegment,
|
|
18
18
|
IMergeTreeAnnotateMsg,
|
|
19
19
|
IMergeTreeDeltaOp,
|
|
20
|
+
// eslint-disable-next-line import/no-deprecated
|
|
20
21
|
IMergeTreeGroupMsg,
|
|
22
|
+
// eslint-disable-next-line import/no-deprecated
|
|
21
23
|
IMergeTreeObliterateMsg,
|
|
22
24
|
IMergeTreeOp,
|
|
23
25
|
IMergeTreeRemoveMsg,
|
|
@@ -30,9 +32,11 @@ import {
|
|
|
30
32
|
PropertySet,
|
|
31
33
|
ReferencePosition,
|
|
32
34
|
ReferenceType,
|
|
35
|
+
// eslint-disable-next-line import/no-deprecated
|
|
33
36
|
SegmentGroup,
|
|
34
37
|
SlidingPreference,
|
|
35
|
-
createAnnotateRangeOp,
|
|
38
|
+
createAnnotateRangeOp,
|
|
39
|
+
// eslint-disable-next-line import/no-deprecated
|
|
36
40
|
createGroupOp,
|
|
37
41
|
createInsertOp,
|
|
38
42
|
createObliterateRangeOp,
|
|
@@ -113,8 +117,13 @@ export abstract class SharedSegmentSequence<T extends ISegment>
|
|
|
113
117
|
extends SharedObject<ISharedSegmentSequenceEvents>
|
|
114
118
|
implements ISharedIntervalCollection<SequenceInterval>, MergeTreeRevertibleDriver
|
|
115
119
|
{
|
|
120
|
+
/**
|
|
121
|
+
* This promise is always immediately resolved, and awaiting it has no effect.
|
|
122
|
+
* @deprecated SharedSegmentSequence no longer supports partial loading.
|
|
123
|
+
* References to this promise may safely be deleted without affecting behavior.
|
|
124
|
+
*/
|
|
116
125
|
get loaded(): Promise<void> {
|
|
117
|
-
return
|
|
126
|
+
return Promise.resolve();
|
|
118
127
|
}
|
|
119
128
|
|
|
120
129
|
/**
|
|
@@ -180,6 +189,7 @@ export abstract class SharedSegmentSequence<T extends ISegment>
|
|
|
180
189
|
}
|
|
181
190
|
|
|
182
191
|
case MergeTreeDeltaType.OBLITERATE: {
|
|
192
|
+
// eslint-disable-next-line import/no-deprecated
|
|
183
193
|
const lastRem = ops[ops.length - 1] as IMergeTreeObliterateMsg;
|
|
184
194
|
if (lastRem?.pos1 === r.position) {
|
|
185
195
|
assert(
|
|
@@ -235,24 +245,15 @@ export abstract class SharedSegmentSequence<T extends ISegment>
|
|
|
235
245
|
* DDS submits over the wire. See `inFlightRefSeqs` for more details.
|
|
236
246
|
*/
|
|
237
247
|
private get currentRefSeq() {
|
|
238
|
-
return this.ongoingResubmitRefSeq ?? this.
|
|
248
|
+
return this.ongoingResubmitRefSeq ?? this.deltaManager.lastSequenceNumber;
|
|
239
249
|
}
|
|
240
250
|
|
|
241
251
|
// eslint-disable-next-line import/no-deprecated
|
|
242
252
|
protected client: Client;
|
|
243
|
-
/** `Deferred` that triggers once the object is loaded */
|
|
244
|
-
protected loadedDeferred = new Deferred<void>();
|
|
245
|
-
// cache out going ops created when partial loading
|
|
246
|
-
private readonly loadedDeferredOutgoingOps: [IMergeTreeOp, SegmentGroup | SegmentGroup[]][] =
|
|
247
|
-
[];
|
|
248
|
-
// cache incoming ops that arrive when partial loading
|
|
249
|
-
private deferIncomingOps = true;
|
|
250
|
-
private readonly loadedDeferredIncomingOps: ISequencedDocumentMessage[] = [];
|
|
251
|
-
|
|
252
253
|
private messagesSinceMSNChange: ISequencedDocumentMessage[] = [];
|
|
253
254
|
private readonly intervalCollections: IntervalCollectionMap<SequenceInterval>;
|
|
254
255
|
constructor(
|
|
255
|
-
|
|
256
|
+
dataStoreRuntime: IFluidDataStoreRuntime,
|
|
256
257
|
public id: string,
|
|
257
258
|
attributes: IChannelAttributes,
|
|
258
259
|
public readonly segmentFromSpec: (spec: IJSONSegment) => ISegment,
|
|
@@ -273,10 +274,6 @@ export abstract class SharedSegmentSequence<T extends ISegment>
|
|
|
273
274
|
}
|
|
274
275
|
});
|
|
275
276
|
|
|
276
|
-
this.loadedDeferred.promise.catch((error) => {
|
|
277
|
-
this.logger.sendErrorEvent({ eventName: "SequenceLoadFailed" }, error);
|
|
278
|
-
});
|
|
279
|
-
|
|
280
277
|
// eslint-disable-next-line import/no-deprecated
|
|
281
278
|
this.client = new Client(
|
|
282
279
|
segmentFromSpec,
|
|
@@ -340,6 +337,7 @@ export abstract class SharedSegmentSequence<T extends ISegment>
|
|
|
340
337
|
* release, as group ops are redundant with the native batching capabilities
|
|
341
338
|
* of the runtime
|
|
342
339
|
*/
|
|
340
|
+
// eslint-disable-next-line import/no-deprecated
|
|
343
341
|
public groupOperation(groupOp: IMergeTreeGroupMsg) {
|
|
344
342
|
this.guardReentrancy(() => this.client.localTransaction(groupOp));
|
|
345
343
|
}
|
|
@@ -474,14 +472,7 @@ export abstract class SharedSegmentSequence<T extends ISegment>
|
|
|
474
472
|
message.type === MergeTreeDeltaType.GROUP ? message.ops.length : 1,
|
|
475
473
|
);
|
|
476
474
|
|
|
477
|
-
|
|
478
|
-
// local ops until loading is complete, and then
|
|
479
|
-
// they will be present
|
|
480
|
-
if (!this.loadedDeferred.isCompleted) {
|
|
481
|
-
this.loadedDeferredOutgoingOps.push(metadata ? [message, metadata] : (message as any));
|
|
482
|
-
} else {
|
|
483
|
-
this.submitLocalMessage(message, metadata);
|
|
484
|
-
}
|
|
475
|
+
this.submitLocalMessage(message, metadata);
|
|
485
476
|
}
|
|
486
477
|
|
|
487
478
|
/**
|
|
@@ -654,6 +645,7 @@ export abstract class SharedSegmentSequence<T extends ISegment>
|
|
|
654
645
|
this.submitSequenceMessage(
|
|
655
646
|
this.client.regeneratePendingOp(
|
|
656
647
|
content as IMergeTreeOp,
|
|
648
|
+
// eslint-disable-next-line import/no-deprecated
|
|
657
649
|
localOpMetadata as SegmentGroup | SegmentGroup[],
|
|
658
650
|
),
|
|
659
651
|
);
|
|
@@ -681,47 +673,38 @@ export abstract class SharedSegmentSequence<T extends ISegment>
|
|
|
681
673
|
this.serializer,
|
|
682
674
|
);
|
|
683
675
|
|
|
684
|
-
//
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
this.loadFinished();
|
|
714
|
-
})
|
|
715
|
-
.catch((error) => {
|
|
716
|
-
this.loadFinished(error);
|
|
717
|
-
});
|
|
718
|
-
if (this.dataStoreRuntime.options.sequenceInitializeFromHeaderOnly !== true) {
|
|
719
|
-
// if we not doing partial load, await the catch up ops,
|
|
720
|
-
// and the finalization of the load
|
|
721
|
-
await loadCatchUpOps;
|
|
722
|
-
}
|
|
676
|
+
// process the catch up ops, and finishing the loading process
|
|
677
|
+
(await catchupOpsP).forEach((m) => {
|
|
678
|
+
const collabWindow = this.client.getCollabWindow();
|
|
679
|
+
if (
|
|
680
|
+
m.minimumSequenceNumber < collabWindow.minSeq ||
|
|
681
|
+
m.referenceSequenceNumber < collabWindow.minSeq ||
|
|
682
|
+
m.sequenceNumber <= collabWindow.minSeq ||
|
|
683
|
+
// sequenceNumber could be the same if messages are part of a grouped batch
|
|
684
|
+
m.sequenceNumber < collabWindow.currentSeq
|
|
685
|
+
) {
|
|
686
|
+
throw new Error(
|
|
687
|
+
`Invalid catchup operations in snapshot: ${JSON.stringify({
|
|
688
|
+
op: {
|
|
689
|
+
seq: m.sequenceNumber,
|
|
690
|
+
minSeq: m.minimumSequenceNumber,
|
|
691
|
+
refSeq: m.referenceSequenceNumber,
|
|
692
|
+
},
|
|
693
|
+
collabWindow: {
|
|
694
|
+
seq: collabWindow.currentSeq,
|
|
695
|
+
minSeq: collabWindow.minSeq,
|
|
696
|
+
},
|
|
697
|
+
})}`,
|
|
698
|
+
);
|
|
699
|
+
}
|
|
700
|
+
this.processMergeTreeMsg(m);
|
|
701
|
+
});
|
|
702
|
+
|
|
703
|
+
// Initialize the interval collections
|
|
704
|
+
this.initializeIntervalCollections();
|
|
723
705
|
} catch (error) {
|
|
724
|
-
this.
|
|
706
|
+
this.logger.sendErrorEvent({ eventName: "SequenceLoadFailed" }, error);
|
|
707
|
+
throw error;
|
|
725
708
|
}
|
|
726
709
|
}
|
|
727
710
|
|
|
@@ -745,27 +728,20 @@ export abstract class SharedSegmentSequence<T extends ISegment>
|
|
|
745
728
|
// assert(recordedRefSeq <= message.referenceSequenceNumber, "RefSeq mismatch");
|
|
746
729
|
}
|
|
747
730
|
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
this.loadedDeferredIncomingOps.push(message);
|
|
753
|
-
} else {
|
|
754
|
-
assert(
|
|
755
|
-
message.type === MessageType.Operation,
|
|
756
|
-
0x073 /* "Sequence message not operation" */,
|
|
757
|
-
);
|
|
731
|
+
assert(
|
|
732
|
+
message.type === MessageType.Operation,
|
|
733
|
+
0x073 /* "Sequence message not operation" */,
|
|
734
|
+
);
|
|
758
735
|
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
736
|
+
const handled = this.intervalCollections.tryProcessMessage(
|
|
737
|
+
message.contents as IMapOperation,
|
|
738
|
+
local,
|
|
739
|
+
message,
|
|
740
|
+
localOpMetadata,
|
|
741
|
+
);
|
|
765
742
|
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
}
|
|
743
|
+
if (!handled) {
|
|
744
|
+
this.processMergeTreeMsg(message, local);
|
|
769
745
|
}
|
|
770
746
|
}
|
|
771
747
|
|
|
@@ -785,7 +761,7 @@ export abstract class SharedSegmentSequence<T extends ISegment>
|
|
|
785
761
|
*/
|
|
786
762
|
protected initializeLocalCore() {
|
|
787
763
|
super.initializeLocalCore();
|
|
788
|
-
this.
|
|
764
|
+
this.initializeIntervalCollections();
|
|
789
765
|
}
|
|
790
766
|
|
|
791
767
|
/**
|
|
@@ -798,12 +774,7 @@ export abstract class SharedSegmentSequence<T extends ISegment>
|
|
|
798
774
|
}
|
|
799
775
|
|
|
800
776
|
private summarizeMergeTree(serializer: IFluidSerializer): ISummaryTreeWithStats {
|
|
801
|
-
|
|
802
|
-
assert(
|
|
803
|
-
this.loadedDeferred.isCompleted,
|
|
804
|
-
0x074 /* "Snapshot called when not fully loaded" */,
|
|
805
|
-
);
|
|
806
|
-
const minSeq = this.runtime.deltaManager.minimumSequenceNumber;
|
|
777
|
+
const minSeq = this.deltaManager.minimumSequenceNumber;
|
|
807
778
|
|
|
808
779
|
this.processMinSequenceNumberChanged(minSeq);
|
|
809
780
|
|
|
@@ -875,35 +846,6 @@ export abstract class SharedSegmentSequence<T extends ISegment>
|
|
|
875
846
|
}
|
|
876
847
|
}
|
|
877
848
|
|
|
878
|
-
private loadFinished(error?: any) {
|
|
879
|
-
if (!this.loadedDeferred.isCompleted) {
|
|
880
|
-
// Initialize the interval collections
|
|
881
|
-
this.initializeIntervalCollections();
|
|
882
|
-
if (error) {
|
|
883
|
-
this.loadedDeferred.reject(error);
|
|
884
|
-
throw error;
|
|
885
|
-
} else {
|
|
886
|
-
// it is important this series remains synchronous
|
|
887
|
-
// first we stop deferring incoming ops, and apply then all
|
|
888
|
-
this.deferIncomingOps = false;
|
|
889
|
-
for (const message of this.loadedDeferredIncomingOps) {
|
|
890
|
-
this.processCore(message, false, undefined);
|
|
891
|
-
}
|
|
892
|
-
this.loadedDeferredIncomingOps.length = 0;
|
|
893
|
-
|
|
894
|
-
// then resolve the loaded promise
|
|
895
|
-
// and resubmit all the outstanding ops, as the snapshot
|
|
896
|
-
// is fully loaded, and all outstanding ops are applied
|
|
897
|
-
this.loadedDeferred.resolve();
|
|
898
|
-
|
|
899
|
-
for (const [messageContent, opMetadata] of this.loadedDeferredOutgoingOps) {
|
|
900
|
-
this.reSubmitCore(messageContent, opMetadata);
|
|
901
|
-
}
|
|
902
|
-
this.loadedDeferredOutgoingOps.length = 0;
|
|
903
|
-
}
|
|
904
|
-
}
|
|
905
|
-
}
|
|
906
|
-
|
|
907
849
|
private initializeIntervalCollections() {
|
|
908
850
|
// Listen and initialize new SharedIntervalCollections
|
|
909
851
|
this.intervalCollections.eventEmitter.on(
|
|
@@ -36,6 +36,9 @@ export abstract class SequenceEvent<
|
|
|
36
36
|
private readonly pLast: Lazy<ISequenceDeltaRange<TOperation>>;
|
|
37
37
|
|
|
38
38
|
constructor(
|
|
39
|
+
/**
|
|
40
|
+
* Arguments reflecting the type of change that caused this event.
|
|
41
|
+
*/
|
|
39
42
|
public readonly deltaArgs: IMergeTreeDeltaCallbackArgs<TOperation>,
|
|
40
43
|
// eslint-disable-next-line import/no-deprecated
|
|
41
44
|
private readonly mergeTreeClient: Client,
|
|
@@ -73,7 +76,10 @@ export abstract class SequenceEvent<
|
|
|
73
76
|
|
|
74
77
|
/**
|
|
75
78
|
* The in-order ranges affected by this delta.
|
|
76
|
-
* These
|
|
79
|
+
* These are not necessarily contiguous.
|
|
80
|
+
*
|
|
81
|
+
* @remarks - If processing code doesn't care about the order of the ranges, it may instead consider using the
|
|
82
|
+
* {@link @fluidframework/merge-tree#IMergeTreeDeltaCallbackArgs.deltaSegments|deltaSegments} field on {@link SequenceEvent.deltaArgs|deltaArgs}.
|
|
77
83
|
*/
|
|
78
84
|
public get ranges(): readonly Readonly<ISequenceDeltaRange<TOperation>>[] {
|
|
79
85
|
return this.sortedRanges.value.items;
|
|
@@ -140,6 +146,11 @@ export class SequenceDeltaEvent extends SequenceEvent<MergeTreeDeltaOperationTyp
|
|
|
140
146
|
*/
|
|
141
147
|
export class SequenceMaintenanceEvent extends SequenceEvent<MergeTreeMaintenanceType> {
|
|
142
148
|
constructor(
|
|
149
|
+
/**
|
|
150
|
+
* Defined iff `deltaArgs.operation` is {@link @fluidframework/merge-tree#MergeTreeMaintenanceType.ACKNOWLEDGED|MergeTreeMaintenanceType.ACKNOWLEDGED}.
|
|
151
|
+
*
|
|
152
|
+
* In that case, this argument provides information about the change which was acknowledged.
|
|
153
|
+
*/
|
|
143
154
|
public readonly opArgs: IMergeTreeDeltaOpArgs | undefined,
|
|
144
155
|
deltaArgs: IMergeTreeMaintenanceCallbackArgs,
|
|
145
156
|
// eslint-disable-next-line import/no-deprecated
|
package/src/sequenceFactory.ts
CHANGED
|
@@ -10,14 +10,13 @@ import {
|
|
|
10
10
|
IFluidDataStoreRuntime,
|
|
11
11
|
} from "@fluidframework/datastore-definitions";
|
|
12
12
|
import { Marker, TextSegment } from "@fluidframework/merge-tree/internal";
|
|
13
|
+
import type { ISharedObjectKind } from "@fluidframework/shared-object-base";
|
|
14
|
+
import { createSharedObjectKind } from "@fluidframework/shared-object-base/internal";
|
|
13
15
|
|
|
14
16
|
import { pkgVersion } from "./packageVersion.js";
|
|
15
|
-
import {
|
|
17
|
+
import { SharedStringClass, SharedStringSegment, type ISharedString } from "./sharedString.js";
|
|
16
18
|
|
|
17
|
-
|
|
18
|
-
* @alpha
|
|
19
|
-
*/
|
|
20
|
-
export class SharedStringFactory implements IChannelFactory {
|
|
19
|
+
export class SharedStringFactory implements IChannelFactory<ISharedString> {
|
|
21
20
|
// TODO rename back to https://graph.microsoft.com/types/mergeTree/string once paparazzi is able to dynamically
|
|
22
21
|
// load code (UPDATE: paparazzi is gone... anything to do here?)
|
|
23
22
|
public static Type = "https://graph.microsoft.com/types/mergeTree";
|
|
@@ -58,8 +57,8 @@ export class SharedStringFactory implements IChannelFactory {
|
|
|
58
57
|
id: string,
|
|
59
58
|
services: IChannelServices,
|
|
60
59
|
attributes: IChannelAttributes,
|
|
61
|
-
): Promise<
|
|
62
|
-
const sharedString = new
|
|
60
|
+
): Promise<SharedStringClass> {
|
|
61
|
+
const sharedString = new SharedStringClass(runtime, id, attributes);
|
|
63
62
|
await sharedString.load(services);
|
|
64
63
|
return sharedString;
|
|
65
64
|
}
|
|
@@ -67,9 +66,22 @@ export class SharedStringFactory implements IChannelFactory {
|
|
|
67
66
|
/**
|
|
68
67
|
* {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.create}
|
|
69
68
|
*/
|
|
70
|
-
public create(document: IFluidDataStoreRuntime, id: string):
|
|
71
|
-
const sharedString = new
|
|
69
|
+
public create(document: IFluidDataStoreRuntime, id: string): SharedStringClass {
|
|
70
|
+
const sharedString = new SharedStringClass(document, id, this.attributes);
|
|
72
71
|
sharedString.initializeLocal();
|
|
73
72
|
return sharedString;
|
|
74
73
|
}
|
|
75
74
|
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Entrypoint for {@link ISharedString} creation.
|
|
78
|
+
* @alpha
|
|
79
|
+
*/
|
|
80
|
+
export const SharedString: ISharedObjectKind<ISharedString> =
|
|
81
|
+
createSharedObjectKind(SharedStringFactory);
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Alias for {@link ISharedString} for compatibility.
|
|
85
|
+
* @alpha
|
|
86
|
+
*/
|
|
87
|
+
export type SharedString = ISharedString;
|