@fluidframework/sequence 0.59.4001 → 1.1.0-75972
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.js +1 -1
- package/README.md +18 -6
- package/dist/defaultMap.d.ts +2 -6
- package/dist/defaultMap.d.ts.map +1 -1
- package/dist/defaultMap.js +27 -37
- package/dist/defaultMap.js.map +1 -1
- package/dist/defaultMapInterfaces.d.ts +24 -3
- package/dist/defaultMapInterfaces.d.ts.map +1 -1
- package/dist/defaultMapInterfaces.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/intervalCollection.d.ts +93 -8
- package/dist/intervalCollection.d.ts.map +1 -1
- package/dist/intervalCollection.js +434 -178
- package/dist/intervalCollection.js.map +1 -1
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.d.ts.map +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/sequence.d.ts +6 -7
- package/dist/sequence.d.ts.map +1 -1
- package/dist/sequence.js +17 -21
- package/dist/sequence.js.map +1 -1
- package/dist/sharedIntervalCollection.d.ts.map +1 -1
- package/dist/sharedIntervalCollection.js +2 -2
- package/dist/sharedIntervalCollection.js.map +1 -1
- package/dist/sharedSequence.js.map +1 -1
- package/dist/sparsematrix.js +2 -2
- package/dist/sparsematrix.js.map +1 -1
- package/lib/defaultMap.d.ts +2 -6
- package/lib/defaultMap.d.ts.map +1 -1
- package/lib/defaultMap.js +27 -37
- package/lib/defaultMap.js.map +1 -1
- package/lib/defaultMapInterfaces.d.ts +24 -3
- package/lib/defaultMapInterfaces.d.ts.map +1 -1
- package/lib/defaultMapInterfaces.js.map +1 -1
- package/lib/index.d.ts +2 -2
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js.map +1 -1
- package/lib/intervalCollection.d.ts +93 -8
- package/lib/intervalCollection.d.ts.map +1 -1
- package/lib/intervalCollection.js +435 -179
- package/lib/intervalCollection.js.map +1 -1
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.d.ts.map +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/lib/sequence.d.ts +6 -7
- package/lib/sequence.d.ts.map +1 -1
- package/lib/sequence.js +18 -22
- package/lib/sequence.js.map +1 -1
- package/lib/sharedIntervalCollection.d.ts.map +1 -1
- package/lib/sharedIntervalCollection.js +2 -2
- package/lib/sharedIntervalCollection.js.map +1 -1
- package/lib/sharedSequence.js.map +1 -1
- package/lib/sparsematrix.js +2 -2
- package/lib/sparsematrix.js.map +1 -1
- package/package.json +23 -45
- package/src/defaultMap.ts +39 -41
- package/src/defaultMapInterfaces.ts +28 -3
- package/src/index.ts +3 -0
- package/src/intervalCollection.ts +575 -211
- package/src/packageVersion.ts +1 -1
- package/src/sequence.ts +36 -38
- package/src/sharedIntervalCollection.ts +4 -3
- package/src/sharedSequence.ts +1 -1
- package/src/sparsematrix.ts +2 -2
package/src/packageVersion.ts
CHANGED
package/src/sequence.ts
CHANGED
|
@@ -30,6 +30,7 @@ import {
|
|
|
30
30
|
ISegment,
|
|
31
31
|
ISegmentAction,
|
|
32
32
|
LocalReference,
|
|
33
|
+
LocalReferencePosition,
|
|
33
34
|
matchProperties,
|
|
34
35
|
MergeTreeDeltaType,
|
|
35
36
|
PropertySet,
|
|
@@ -48,15 +49,15 @@ import {
|
|
|
48
49
|
SummarySerializer,
|
|
49
50
|
} from "@fluidframework/shared-object-base";
|
|
50
51
|
import { IEventThisPlaceHolder } from "@fluidframework/common-definitions";
|
|
51
|
-
import { ISummaryTreeWithStats } from "@fluidframework/runtime-definitions";
|
|
52
|
+
import { ISummaryTreeWithStats, ITelemetryContext } from "@fluidframework/runtime-definitions";
|
|
52
53
|
|
|
53
54
|
import {
|
|
54
55
|
IntervalCollection,
|
|
55
56
|
SequenceInterval,
|
|
56
57
|
SequenceIntervalCollectionValueType,
|
|
57
58
|
} from "./intervalCollection";
|
|
58
|
-
import {
|
|
59
|
-
import { IValueChanged } from "./defaultMapInterfaces";
|
|
59
|
+
import { DefaultMap } from "./defaultMap";
|
|
60
|
+
import { IMapMessageLocalMetadata, IValueChanged } from "./defaultMapInterfaces";
|
|
60
61
|
import { SequenceDeltaEvent, SequenceMaintenanceEvent } from "./sequenceDeltaEvent";
|
|
61
62
|
import { ISharedIntervalCollection } from "./sharedIntervalCollection";
|
|
62
63
|
|
|
@@ -115,8 +116,7 @@ export abstract class SharedSegmentSequence<T extends ISegment>
|
|
|
115
116
|
const lastAnnotate = ops[ops.length - 1] as IMergeTreeAnnotateMsg;
|
|
116
117
|
const props = {};
|
|
117
118
|
for (const key of Object.keys(r.propertyDeltas)) {
|
|
118
|
-
props[key] =
|
|
119
|
-
r.segment.properties[key] === undefined ? null : r.segment.properties[key];
|
|
119
|
+
props[key] = r.segment.properties?.[key] ?? null;
|
|
120
120
|
}
|
|
121
121
|
if (lastAnnotate && lastAnnotate.pos2 === r.position &&
|
|
122
122
|
matchProperties(lastAnnotate.props, props)) {
|
|
@@ -173,7 +173,7 @@ export abstract class SharedSegmentSequence<T extends ISegment>
|
|
|
173
173
|
attributes: IChannelAttributes,
|
|
174
174
|
public readonly segmentFromSpec: (spec: IJSONSegment) => ISegment,
|
|
175
175
|
) {
|
|
176
|
-
super(id, dataStoreRuntime, attributes);
|
|
176
|
+
super(id, dataStoreRuntime, attributes, "fluid_sequence_");
|
|
177
177
|
|
|
178
178
|
this.loadedDeferred.promise.catch((error) => {
|
|
179
179
|
this.logger.sendErrorEvent({ eventName: "SequenceLoadFailed" }, error);
|
|
@@ -232,7 +232,7 @@ export abstract class SharedSegmentSequence<T extends ISegment>
|
|
|
232
232
|
* @param start - The inclusive start of the range to remove
|
|
233
233
|
* @param end - The exclusive end of the range to remove
|
|
234
234
|
*/
|
|
235
|
-
public removeRange(start: number, end: number) {
|
|
235
|
+
public removeRange(start: number, end: number): IMergeTreeRemoveMsg {
|
|
236
236
|
const removeOp = this.client.removeRangeLocal(start, end);
|
|
237
237
|
if (removeOp) {
|
|
238
238
|
this.submitSequenceMessage(removeOp);
|
|
@@ -312,7 +312,7 @@ export abstract class SharedSegmentSequence<T extends ISegment>
|
|
|
312
312
|
segment: T,
|
|
313
313
|
offset: number,
|
|
314
314
|
refType: ReferenceType,
|
|
315
|
-
properties: PropertySet | undefined):
|
|
315
|
+
properties: PropertySet | undefined): LocalReferencePosition {
|
|
316
316
|
return this.client.createLocalReferencePosition(
|
|
317
317
|
segment,
|
|
318
318
|
offset,
|
|
@@ -387,7 +387,7 @@ export abstract class SharedSegmentSequence<T extends ISegment>
|
|
|
387
387
|
return this.client.removeLocalReferencePosition(lref);
|
|
388
388
|
}
|
|
389
389
|
|
|
390
|
-
public removeLocalReferencePosition(lref:
|
|
390
|
+
public removeLocalReferencePosition(lref: LocalReferencePosition) {
|
|
391
391
|
return this.client.removeLocalReferencePosition(lref);
|
|
392
392
|
}
|
|
393
393
|
|
|
@@ -442,13 +442,11 @@ export abstract class SharedSegmentSequence<T extends ISegment>
|
|
|
442
442
|
public async waitIntervalCollection(
|
|
443
443
|
label: string,
|
|
444
444
|
): Promise<IntervalCollection<SequenceInterval>> {
|
|
445
|
-
return this.intervalCollections.get(
|
|
445
|
+
return this.intervalCollections.get(label);
|
|
446
446
|
}
|
|
447
447
|
|
|
448
448
|
public getIntervalCollection(label: string): IntervalCollection<SequenceInterval> {
|
|
449
|
-
|
|
450
|
-
const sharedCollection = this.intervalCollections.get(labelPath);
|
|
451
|
-
return sharedCollection;
|
|
449
|
+
return this.intervalCollections.get(label);
|
|
452
450
|
}
|
|
453
451
|
|
|
454
452
|
/**
|
|
@@ -463,7 +461,10 @@ export abstract class SharedSegmentSequence<T extends ISegment>
|
|
|
463
461
|
return this.intervalCollections.keys();
|
|
464
462
|
}
|
|
465
463
|
|
|
466
|
-
protected summarizeCore(
|
|
464
|
+
protected summarizeCore(
|
|
465
|
+
serializer: IFluidSerializer,
|
|
466
|
+
telemetryContext?: ITelemetryContext,
|
|
467
|
+
): ISummaryTreeWithStats {
|
|
467
468
|
const builder = new SummaryTreeBuilder();
|
|
468
469
|
|
|
469
470
|
// conditionally write the interval collection blob
|
|
@@ -519,10 +520,10 @@ export abstract class SharedSegmentSequence<T extends ISegment>
|
|
|
519
520
|
this.client.startOrUpdateCollaboration(this.runtime.clientId);
|
|
520
521
|
}
|
|
521
522
|
|
|
522
|
-
protected onDisconnect() {}
|
|
523
|
+
protected onDisconnect() { }
|
|
523
524
|
|
|
524
525
|
protected reSubmitCore(content: any, localOpMetadata: unknown) {
|
|
525
|
-
if (!this.intervalCollections.
|
|
526
|
+
if (!this.intervalCollections.tryResubmitMessage(content, localOpMetadata as IMapMessageLocalMetadata)) {
|
|
526
527
|
this.submitSequenceMessage(
|
|
527
528
|
this.client.regeneratePendingOp(
|
|
528
529
|
content as IMergeTreeOp,
|
|
@@ -559,18 +560,17 @@ export abstract class SharedSegmentSequence<T extends ISegment>
|
|
|
559
560
|
|| m.referenceSequenceNumber < collabWindow.minSeq
|
|
560
561
|
|| m.sequenceNumber <= collabWindow.minSeq
|
|
561
562
|
|| m.sequenceNumber <= collabWindow.currentSeq) {
|
|
562
|
-
throw new Error(`Invalid catchup operations in snapshot: ${
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
})}`);
|
|
563
|
+
throw new Error(`Invalid catchup operations in snapshot: ${JSON.stringify({
|
|
564
|
+
op: {
|
|
565
|
+
seq: m.sequenceNumber,
|
|
566
|
+
minSeq: m.minimumSequenceNumber,
|
|
567
|
+
refSeq: m.referenceSequenceNumber,
|
|
568
|
+
},
|
|
569
|
+
collabWindow: {
|
|
570
|
+
seq: collabWindow.currentSeq,
|
|
571
|
+
minSeq: collabWindow.minSeq,
|
|
572
|
+
},
|
|
573
|
+
})}`);
|
|
574
574
|
}
|
|
575
575
|
this.processMergeTreeMsg(m);
|
|
576
576
|
});
|
|
@@ -666,7 +666,7 @@ export abstract class SharedSegmentSequence<T extends ISegment>
|
|
|
666
666
|
// shallow clone the message as we only overwrite top level properties,
|
|
667
667
|
// like referenceSequenceNumber and content only
|
|
668
668
|
stashMessage = {
|
|
669
|
-
...
|
|
669
|
+
...message,
|
|
670
670
|
referenceSequenceNumber: stashMessage.sequenceNumber - 1,
|
|
671
671
|
contents: ops.length !== 1 ? createGroupOp(...ops) : ops[0],
|
|
672
672
|
};
|
|
@@ -682,10 +682,6 @@ export abstract class SharedSegmentSequence<T extends ISegment>
|
|
|
682
682
|
}
|
|
683
683
|
}
|
|
684
684
|
|
|
685
|
-
private getIntervalCollectionPath(label: string) {
|
|
686
|
-
return `intervalCollections/${label}`;
|
|
687
|
-
}
|
|
688
|
-
|
|
689
685
|
private processMinSequenceNumberChanged(minSeq: number) {
|
|
690
686
|
let index = 0;
|
|
691
687
|
for (; index < this.messagesSinceMSNChange.length; index++) {
|
|
@@ -709,18 +705,20 @@ export abstract class SharedSegmentSequence<T extends ISegment>
|
|
|
709
705
|
// it is important this series remains synchronous
|
|
710
706
|
// first we stop deferring incoming ops, and apply then all
|
|
711
707
|
this.deferIncomingOps = false;
|
|
712
|
-
|
|
713
|
-
this.processCore(
|
|
708
|
+
for (const message of this.loadedDeferredIncomingOps) {
|
|
709
|
+
this.processCore(message, false, undefined);
|
|
714
710
|
}
|
|
711
|
+
this.loadedDeferredIncomingOps.length = 0;
|
|
712
|
+
|
|
715
713
|
// then resolve the loaded promise
|
|
716
714
|
// and resubmit all the outstanding ops, as the snapshot
|
|
717
715
|
// is fully loaded, and all outstanding ops are applied
|
|
718
716
|
this.loadedDeferred.resolve();
|
|
719
717
|
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
this.reSubmitCore(opData[0], opData[1]);
|
|
718
|
+
for (const [messageContent, opMetadata] of this.loadedDeferredOutgoingOps) {
|
|
719
|
+
this.reSubmitCore(messageContent, opMetadata);
|
|
723
720
|
}
|
|
721
|
+
this.loadedDeferredOutgoingOps.length = 0;
|
|
724
722
|
}
|
|
725
723
|
}
|
|
726
724
|
}
|
|
@@ -24,8 +24,9 @@ import {
|
|
|
24
24
|
IntervalCollectionValueType,
|
|
25
25
|
ISerializableInterval,
|
|
26
26
|
} from "./intervalCollection";
|
|
27
|
-
import {
|
|
27
|
+
import { DefaultMap } from "./defaultMap";
|
|
28
28
|
import { pkgVersion } from "./packageVersion";
|
|
29
|
+
import { IMapMessageLocalMetadata } from "./defaultMapInterfaces";
|
|
29
30
|
|
|
30
31
|
const snapshotFileName = "header";
|
|
31
32
|
|
|
@@ -117,7 +118,7 @@ export class SharedIntervalCollection
|
|
|
117
118
|
runtime: IFluidDataStoreRuntime,
|
|
118
119
|
attributes: IChannelAttributes,
|
|
119
120
|
) {
|
|
120
|
-
super(id, runtime, attributes);
|
|
121
|
+
super(id, runtime, attributes, "fluid_sharedIntervalCollection_");
|
|
121
122
|
this.intervalCollections = new DefaultMap(
|
|
122
123
|
this.serializer,
|
|
123
124
|
this.handle,
|
|
@@ -147,7 +148,7 @@ export class SharedIntervalCollection
|
|
|
147
148
|
}
|
|
148
149
|
|
|
149
150
|
protected reSubmitCore(content: any, localOpMetadata: unknown) {
|
|
150
|
-
this.intervalCollections.
|
|
151
|
+
this.intervalCollections.tryResubmitMessage(content, localOpMetadata as IMapMessageLocalMetadata);
|
|
151
152
|
}
|
|
152
153
|
|
|
153
154
|
protected onDisconnect() { }
|
package/src/sharedSequence.ts
CHANGED
|
@@ -149,7 +149,7 @@ export class SharedSequence<T> extends SharedSegmentSequence<SubSequence<T>> {
|
|
|
149
149
|
*/
|
|
150
150
|
public getItems(start: number, end?: number): Serializable<T>[] {
|
|
151
151
|
const items: Serializable<T>[] = [];
|
|
152
|
-
let firstSegment: ISegment;
|
|
152
|
+
let firstSegment: ISegment | undefined;
|
|
153
153
|
|
|
154
154
|
// Return if the range is incorrect.
|
|
155
155
|
if (end !== undefined && end <= start) {
|
package/src/sparsematrix.ts
CHANGED
|
@@ -279,10 +279,10 @@ export class SparseMatrix extends SharedSegmentSequence<MatrixSegment> {
|
|
|
279
279
|
Jsonable<string | number | boolean | IFluidHandle> {
|
|
280
280
|
const pos = rowColToPosition(row, col);
|
|
281
281
|
const { segment, offset } = this.getContainingSegment(pos);
|
|
282
|
-
if (RunSegment.is(segment)) {
|
|
282
|
+
if (segment && RunSegment.is(segment)) {
|
|
283
283
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
284
284
|
return segment.items[offset];
|
|
285
|
-
} else if (PaddingSegment.is(segment)) {
|
|
285
|
+
} else if (segment && PaddingSegment.is(segment)) {
|
|
286
286
|
return undefined;
|
|
287
287
|
}
|
|
288
288
|
|