@fluidframework/sequence 0.59.1000 → 0.59.2000-63294

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.
@@ -6,4 +6,4 @@
6
6
  */
7
7
 
8
8
  export const pkgName = "@fluidframework/sequence";
9
- export const pkgVersion = "0.59.1000";
9
+ export const pkgVersion = "0.59.2000-63294";
package/src/sequence.ts CHANGED
@@ -579,7 +579,7 @@ export abstract class SharedSegmentSequence<T extends ISegment>
579
579
  const handled = this.intervalMapKernel.tryProcessMessage(message.contents, local, message, localOpMetadata);
580
580
 
581
581
  if (!handled) {
582
- this.processMergeTreeMsg(message);
582
+ this.processMergeTreeMsg(message, local);
583
583
  }
584
584
  }
585
585
  }
@@ -597,6 +597,10 @@ export abstract class SharedSegmentSequence<T extends ISegment>
597
597
  this.loadFinished();
598
598
  }
599
599
 
600
+ protected applyStashedOp(content: any) {
601
+ return this.client.applyStashedOp(content);
602
+ }
603
+
600
604
  private summarizeMergeTree(serializer: IFluidSerializer): ISummaryTreeWithStats {
601
605
  // Are we fully loaded? If not, things will go south
602
606
  assert(this.loadedDeferred.isCompleted, 0x074 /* "Snapshot called when not fully loaded" */);
@@ -609,8 +613,7 @@ export abstract class SharedSegmentSequence<T extends ISegment>
609
613
  return this.client.summarize(this.runtime, this.handle, serializer, this.messagesSinceMSNChange);
610
614
  }
611
615
 
612
- private processMergeTreeMsg(
613
- rawMessage: ISequencedDocumentMessage) {
616
+ private processMergeTreeMsg(rawMessage: ISequencedDocumentMessage, local?: boolean) {
614
617
  const message = parseHandles(rawMessage, this.serializer);
615
618
 
616
619
  const ops: IMergeTreeDeltaOp[] = [];
@@ -625,7 +628,7 @@ export abstract class SharedSegmentSequence<T extends ISegment>
625
628
  }
626
629
  }
627
630
 
628
- this.client.applyMsg(message);
631
+ this.client.applyMsg(message, local);
629
632
 
630
633
  if (this.runtime.options?.newMergeTreeSnapshotFormat !== true) {
631
634
  if (needsTransformation) {
@@ -709,8 +712,4 @@ export abstract class SharedSegmentSequence<T extends ISegment>
709
712
  intervalCollection.attachGraph(this.client, key);
710
713
  }
711
714
  }
712
-
713
- protected applyStashedOp() {
714
- throw new Error("not implemented");
715
- }
716
715
  }
@@ -3,6 +3,7 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
 
6
+ import { assert } from "@fluidframework/common-utils";
6
7
  import {
7
8
  Client,
8
9
  IMergeTreeDeltaCallbackArgs,
@@ -19,22 +20,28 @@ import {
19
20
  /**
20
21
  * Base class for SequenceDeltaEvent and SequenceMaintenanceEvent.
21
22
  *
22
- * The properties of this object and its sub-objects represent a point in time state
23
- * at the time the operation was applied. They will not take into any future modifications
24
- * performed to the underlying sequence and merge tree.
23
+ * The properties of this object and its sub-objects represent the state of the sequence at the
24
+ * point in time at which the operation was applied.
25
+ * They will not take into any future modifications performed to the underlying sequence and merge tree.
25
26
  */
26
27
  export abstract class SequenceEvent<TOperation extends MergeTreeDeltaOperationTypes = MergeTreeDeltaOperationTypes> {
28
+ /**
29
+ * @deprecated - Events no longer fire when the change they correspond to had no impact (e.g. a remote delete
30
+ * event for a range that had already been deleted locally).
31
+ * Clients can therefore assume this property is false.
32
+ */
27
33
  public readonly isEmpty: boolean;
28
34
  public readonly deltaOperation: TOperation;
29
35
  private readonly sortedRanges: Lazy<SortedSegmentSet<ISequenceDeltaRange<TOperation>>>;
30
- private readonly pFirst: Lazy<ISequenceDeltaRange<TOperation> | undefined>;
31
- private readonly pLast: Lazy<ISequenceDeltaRange<TOperation> | undefined>;
36
+ private readonly pFirst: Lazy<ISequenceDeltaRange<TOperation>>;
37
+ private readonly pLast: Lazy<ISequenceDeltaRange<TOperation>>;
32
38
 
33
39
  constructor(
34
40
  public readonly deltaArgs: IMergeTreeDeltaCallbackArgs<TOperation>,
35
41
  private readonly mergeTreeClient: Client,
36
42
  ) {
37
- this.isEmpty = deltaArgs.deltaSegments.length === 0;
43
+ assert(deltaArgs.deltaSegments.length > 0, 0x2d8 /* "Empty change event should not be emitted." */);
44
+ this.isEmpty = false;
38
45
  this.deltaOperation = deltaArgs.operation;
39
46
 
40
47
  this.sortedRanges = new Lazy<SortedSegmentSet<ISequenceDeltaRange<TOperation>>>(
@@ -53,25 +60,17 @@ export abstract class SequenceEvent<TOperation extends MergeTreeDeltaOperationTy
53
60
  });
54
61
 
55
62
  this.pFirst = new Lazy<ISequenceDeltaRange<TOperation>>(
56
- () => {
57
- if (this.isEmpty) {
58
- return undefined;
59
- }
60
- return this.sortedRanges.value.items[0];
61
- });
63
+ () => this.sortedRanges.value.items[0],
64
+ );
62
65
 
63
66
  this.pLast = new Lazy<ISequenceDeltaRange<TOperation>>(
64
- () => {
65
- if (this.isEmpty) {
66
- return undefined;
67
- }
68
- return this.sortedRanges.value.items[this.sortedRanges.value.size - 1];
69
- });
67
+ () => this.sortedRanges.value.items[this.sortedRanges.value.size - 1],
68
+ );
70
69
  }
71
70
 
72
71
  /**
73
72
  * The in-order ranges affected by this delta.
74
- * These may not be continuos.
73
+ * These may not be continuous.
75
74
  */
76
75
  public get ranges(): readonly Readonly<ISequenceDeltaRange<TOperation>>[] {
77
76
  return this.sortedRanges.value.items;
@@ -85,18 +84,16 @@ export abstract class SequenceEvent<TOperation extends MergeTreeDeltaOperationTy
85
84
  }
86
85
 
87
86
  /**
88
- * The first of the modified ranges. Undefined if delta is empty,
89
- * like in the case where a delete comes in for a previously deleted range
87
+ * The first of the modified ranges.
90
88
  */
91
- public get first(): Readonly<ISequenceDeltaRange<TOperation>> | undefined {
89
+ public get first(): Readonly<ISequenceDeltaRange<TOperation>> {
92
90
  return this.pFirst.value;
93
91
  }
94
92
 
95
93
  /**
96
- * The last of the modified ranges. Undefined if delta is empty,
97
- * like in the case where a delete comes in for a previously deleted range
94
+ * The last of the modified ranges.
98
95
  */
99
- public get last(): Readonly<ISequenceDeltaRange<TOperation>> | undefined {
96
+ public get last(): Readonly<ISequenceDeltaRange<TOperation>> {
100
97
  return this.pLast.value;
101
98
  }
102
99
  }
@@ -104,11 +101,11 @@ export abstract class SequenceEvent<TOperation extends MergeTreeDeltaOperationTy
104
101
  /**
105
102
  * The event object returned on sequenceDelta events.
106
103
  *
107
- * The properties of this object and its sub-objects represent a point in time state
108
- * at the time the operation was applied. They will not take into consideration any future modifications
109
- * performed to the underlying sequence and merge tree.
104
+ * The properties of this object and its sub-objects represent the state of the sequence at the
105
+ * point in time at which the operation was applied.
106
+ * They will not take into consideration any future modifications performed to the underlying sequence and merge tree.
110
107
  *
111
- * For group ops, each op will get it's own event, and the group op property will be set on the op args.
108
+ * For group ops, each op will get its own event, and the group op property will be set on the op args.
112
109
  *
113
110
  * Ops may get multiple events. For instance, an insert-replace will get a remove then an insert event.
114
111
  */
@@ -131,9 +128,9 @@ export class SequenceDeltaEvent extends SequenceEvent<MergeTreeDeltaOperationTyp
131
128
  /**
132
129
  * The event object returned on maintenance events.
133
130
  *
134
- * The properties of this object and its sub-objects represent a point in time state
135
- * at the time the operation was applied. They will not take into any future modifications
136
- * performed to the underlying sequence and merge tree.
131
+ * The properties of this object and its sub-objects represent the state of the sequence at the
132
+ * point in time at which the operation was applied.
133
+ * They will not take into consideration any future modifications performed to the underlying sequence and merge tree.
137
134
  */
138
135
  export class SequenceMaintenanceEvent extends SequenceEvent<MergeTreeMaintenanceType> {
139
136
  constructor(