@fluidframework/sequence 0.58.0-55561 → 0.58.1001

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 (67) hide show
  1. package/dist/intervalCollection.d.ts +6 -8
  2. package/dist/intervalCollection.d.ts.map +1 -1
  3. package/dist/intervalCollection.js +19 -39
  4. package/dist/intervalCollection.js.map +1 -1
  5. package/dist/localValues.d.ts.map +1 -1
  6. package/dist/localValues.js +0 -1
  7. package/dist/localValues.js.map +1 -1
  8. package/dist/mapKernel.d.ts +1 -1
  9. package/dist/mapKernel.js +4 -4
  10. package/dist/mapKernel.js.map +1 -1
  11. package/dist/packageVersion.d.ts +1 -1
  12. package/dist/packageVersion.d.ts.map +1 -1
  13. package/dist/packageVersion.js +1 -1
  14. package/dist/packageVersion.js.map +1 -1
  15. package/dist/sequence.js +6 -6
  16. package/dist/sequence.js.map +1 -1
  17. package/dist/sequenceFactory.js +0 -3
  18. package/dist/sequenceFactory.js.map +1 -1
  19. package/dist/sharedIntervalCollection.d.ts +1 -1
  20. package/dist/sharedIntervalCollection.js +1 -1
  21. package/dist/sharedIntervalCollection.js.map +1 -1
  22. package/dist/sharedObjectSequence.js +0 -1
  23. package/dist/sharedObjectSequence.js.map +1 -1
  24. package/dist/sharedString.d.ts +1 -1
  25. package/dist/sharedString.d.ts.map +1 -1
  26. package/dist/sharedString.js.map +1 -1
  27. package/dist/sparsematrix.js +0 -3
  28. package/dist/sparsematrix.js.map +1 -1
  29. package/lib/intervalCollection.d.ts +6 -8
  30. package/lib/intervalCollection.d.ts.map +1 -1
  31. package/lib/intervalCollection.js +20 -40
  32. package/lib/intervalCollection.js.map +1 -1
  33. package/lib/localValues.d.ts.map +1 -1
  34. package/lib/localValues.js +0 -1
  35. package/lib/localValues.js.map +1 -1
  36. package/lib/mapKernel.d.ts +1 -1
  37. package/lib/mapKernel.js +4 -4
  38. package/lib/mapKernel.js.map +1 -1
  39. package/lib/packageVersion.d.ts +1 -1
  40. package/lib/packageVersion.d.ts.map +1 -1
  41. package/lib/packageVersion.js +1 -1
  42. package/lib/packageVersion.js.map +1 -1
  43. package/lib/sequence.js +6 -6
  44. package/lib/sequence.js.map +1 -1
  45. package/lib/sequenceFactory.js +0 -3
  46. package/lib/sequenceFactory.js.map +1 -1
  47. package/lib/sharedIntervalCollection.d.ts +1 -1
  48. package/lib/sharedIntervalCollection.js +1 -1
  49. package/lib/sharedIntervalCollection.js.map +1 -1
  50. package/lib/sharedObjectSequence.js +0 -1
  51. package/lib/sharedObjectSequence.js.map +1 -1
  52. package/lib/sharedString.d.ts +1 -1
  53. package/lib/sharedString.d.ts.map +1 -1
  54. package/lib/sharedString.js.map +1 -1
  55. package/lib/sparsematrix.js +0 -3
  56. package/lib/sparsematrix.js.map +1 -1
  57. package/package.json +14 -14
  58. package/src/intervalCollection.ts +29 -44
  59. package/src/localValues.ts +0 -2
  60. package/src/mapKernel.ts +4 -4
  61. package/src/packageVersion.ts +1 -1
  62. package/src/sequence.ts +6 -6
  63. package/src/sequenceFactory.ts +3 -3
  64. package/src/sharedIntervalCollection.ts +1 -1
  65. package/src/sharedObjectSequence.ts +1 -1
  66. package/src/sharedString.ts +1 -3
  67. package/src/sparsematrix.ts +4 -4
@@ -18,9 +18,7 @@ import {
18
18
  IntervalNode,
19
19
  IntervalTree,
20
20
  LocalReference,
21
- MergeTree,
22
21
  MergeTreeDeltaType,
23
- ordinalToArray,
24
22
  PropertiesManager,
25
23
  PropertySet,
26
24
  RedBlackTree,
@@ -61,7 +59,7 @@ export interface ISerializableInterval extends IInterval {
61
59
  export interface IIntervalHelpers<TInterval extends ISerializableInterval> {
62
60
  compareEnds(a: TInterval, b: TInterval): number;
63
61
  create(label: string, start: number, end: number,
64
- client: Client, intervalType?: IntervalType): TInterval;
62
+ client: Client, intervalType?: IntervalType, op?: ISequencedDocumentMessage): TInterval;
65
63
  }
66
64
 
67
65
  export class Interval implements ISerializableInterval {
@@ -181,7 +179,7 @@ export class Interval implements ISerializableInterval {
181
179
  }
182
180
  }
183
181
 
184
- public modify(label: string, start: number, end: number) {
182
+ public modify(label: string, start: number, end: number, op?: ISequencedDocumentMessage) {
185
183
  const startPos = start ?? this.start;
186
184
  const endPos = end ?? this.end;
187
185
  if (this.start === startPos && this.end === endPos) {
@@ -195,7 +193,6 @@ export class Interval implements ISerializableInterval {
195
193
  export class SequenceInterval implements ISerializableInterval {
196
194
  public properties: PropertySet;
197
195
  public propertyManager: PropertiesManager;
198
- private readonly checkMergeTree: MergeTree;
199
196
 
200
197
  constructor(
201
198
  public start: LocalReference,
@@ -260,9 +257,6 @@ export class SequenceInterval implements ISerializableInterval {
260
257
  public overlaps(b: SequenceInterval) {
261
258
  const result = (this.start.compare(b.end) < 0) &&
262
259
  (this.end.compare(b.start) >= 0);
263
- if (this.checkMergeTree) {
264
- this.checkOverlaps(b, result);
265
- }
266
260
  return result;
267
261
  }
268
262
 
@@ -300,34 +294,17 @@ export class SequenceInterval implements ISerializableInterval {
300
294
  return (endPos > bstart) && (startPos < bend);
301
295
  }
302
296
 
303
- private checkOverlaps(b: SequenceInterval, result: boolean) {
304
- const astart = this.start.toPosition();
305
- const bstart = b.start.toPosition();
306
- const aend = this.end.toPosition();
307
- const bend = b.end.toPosition();
308
- const checkResult = ((astart < bend) && (bstart < aend));
309
- if (checkResult !== result) {
310
- // eslint-disable-next-line max-len
311
- console.log(`check mismatch: res ${result} ${this.start.segment === b.end.segment} ${b.start.segment === this.end.segment}`);
312
- console.log(`as ${astart} ae ${aend} bs ${bstart} be ${bend}`);
313
- console.log(`as ${ordinalToArray(this.start.segment.ordinal)}@${this.start.offset}`);
314
- console.log(`ae ${ordinalToArray(this.end.segment.ordinal)}@${this.end.offset}`);
315
- console.log(`bs ${ordinalToArray(b.start.segment.ordinal)}@${b.start.offset}`);
316
- console.log(`be ${ordinalToArray(b.end.segment.ordinal)}@${b.end.offset}`);
317
- console.log(this.checkMergeTree.nodeToString(b.start.segment.parent, ""));
318
- }
319
- }
297
+ public modify(label: string, start: number, end: number, op?: ISequencedDocumentMessage) {
298
+ const startPos = start ?? this.start.toPosition();
299
+ const endPos = end ?? this.end.toPosition();
320
300
 
321
- public modify(label: string, start: number, end: number) {
322
- const startPos = start ?? this.start.getOffset();
323
- const endPos = end ?? this.end.getOffset();
324
-
325
- if (this.start.getOffset() === startPos && this.end.getOffset() === endPos) {
301
+ if (this.start.toPosition() === startPos && this.end.toPosition() === endPos) {
326
302
  // Return undefined to indicate that no change is necessary.
327
303
  return;
328
304
  }
329
305
 
330
- const newInterval = createSequenceInterval(label, startPos, endPos, this.start.getClient(), this.intervalType);
306
+ const newInterval =
307
+ createSequenceInterval(label, startPos, endPos, this.start.getClient(), this.intervalType, op);
331
308
  if (this.properties) {
332
309
  newInterval.addProperties(this.properties);
333
310
  }
@@ -338,8 +315,9 @@ export class SequenceInterval implements ISerializableInterval {
338
315
  function createPositionReference(
339
316
  client: Client,
340
317
  pos: number,
341
- refType: ReferenceType): LocalReference {
342
- const segoff = client.getContainingSegment(pos);
318
+ refType: ReferenceType,
319
+ op?: ISequencedDocumentMessage): LocalReference {
320
+ const segoff = client.getContainingSegment(pos, op);
343
321
  if (segoff && segoff.segment) {
344
322
  const lref = new LocalReference(client, segoff.segment, segoff.offset, refType);
345
323
  if (refType !== ReferenceType.Transient) {
@@ -355,7 +333,8 @@ function createSequenceInterval(
355
333
  start: number,
356
334
  end: number,
357
335
  client: Client,
358
- intervalType: IntervalType): SequenceInterval {
336
+ intervalType: IntervalType,
337
+ op?: ISequencedDocumentMessage): SequenceInterval {
359
338
  let beginRefType = ReferenceType.RangeBegin;
360
339
  let endRefType = ReferenceType.RangeEnd;
361
340
  if (intervalType === IntervalType.Nest) {
@@ -372,8 +351,8 @@ function createSequenceInterval(
372
351
  endRefType |= ReferenceType.SlideOnRemove;
373
352
  }
374
353
 
375
- const startLref = createPositionReference(client, start, beginRefType);
376
- const endLref = createPositionReference(client, end, endRefType);
354
+ const startLref = createPositionReference(client, start, beginRefType, op);
355
+ const endLref = createPositionReference(client, end, endRefType, op);
377
356
  if (startLref && endLref) {
378
357
  startLref.pairedRef = endLref;
379
358
  endLref.pairedRef = startLref;
@@ -594,16 +573,21 @@ export class LocalIntervalCollection<TInterval extends ISerializableInterval> {
594
573
  this.endIntervalTree.remove(interval);
595
574
  }
596
575
 
597
- public createInterval(start: number, end: number, intervalType: IntervalType): TInterval {
598
- return this.helpers.create(this.label, start, end, this.client, intervalType);
576
+ public createInterval(
577
+ start: number,
578
+ end: number,
579
+ intervalType: IntervalType,
580
+ op?: ISequencedDocumentMessage): TInterval {
581
+ return this.helpers.create(this.label, start, end, this.client, intervalType, op);
599
582
  }
600
583
 
601
584
  public addInterval(
602
585
  start: number,
603
586
  end: number,
604
587
  intervalType: IntervalType,
605
- props?: PropertySet) {
606
- const interval: TInterval = this.createInterval(start, end, intervalType);
588
+ props?: PropertySet,
589
+ op?: ISequencedDocumentMessage) {
590
+ const interval: TInterval = this.createInterval(start, end, intervalType, op);
607
591
  if (interval) {
608
592
  if (!interval.properties) {
609
593
  interval.properties = createMap<any>();
@@ -643,8 +627,8 @@ export class LocalIntervalCollection<TInterval extends ISerializableInterval> {
643
627
  return result;
644
628
  }
645
629
 
646
- public changeInterval(interval: TInterval, start: number, end: number) {
647
- const newInterval = interval.modify(this.label, start, end) as TInterval | undefined;
630
+ public changeInterval(interval: TInterval, start: number, end: number, op?: ISequencedDocumentMessage) {
631
+ const newInterval = interval.modify(this.label, start, end, op) as TInterval | undefined;
648
632
  if (newInterval) {
649
633
  this.removeExistingInterval(interval);
650
634
  this.add(newInterval);
@@ -1120,7 +1104,7 @@ export class IntervalCollection<TInterval extends ISerializableInterval>
1120
1104
  if (start !== undefined || end !== undefined) {
1121
1105
  // If changeInterval gives us a new interval, work with that one. Otherwise keep working with
1122
1106
  // the one we originally found in the tree.
1123
- interval = this.localCollection.changeInterval(interval, start, end) ?? interval;
1107
+ interval = this.localCollection.changeInterval(interval, start, end, op) ?? interval;
1124
1108
  }
1125
1109
  const deltaProps = interval.addProperties(serializedInterval.properties, true, op.sequenceNumber);
1126
1110
  if (this.onDeserialize) {
@@ -1168,7 +1152,8 @@ export class IntervalCollection<TInterval extends ISerializableInterval>
1168
1152
  serializedInterval.start,
1169
1153
  serializedInterval.end,
1170
1154
  serializedInterval.intervalType,
1171
- serializedInterval.properties);
1155
+ serializedInterval.properties,
1156
+ op);
1172
1157
 
1173
1158
  if (interval) {
1174
1159
  // Local ops get submitted to the server. Remote ops have the deserializer run.
@@ -248,8 +248,6 @@ export class LocalValueMaker {
248
248
  if (!valueType) {
249
249
  throw new Error(`Unknown type '${type}' specified`);
250
250
  }
251
-
252
- // eslint-disable-next-line @typescript-eslint/no-unsafe-return
253
251
  return valueType.factory.load(emitter, params);
254
252
  }
255
253
  }
package/src/mapKernel.ts CHANGED
@@ -168,7 +168,7 @@ export class MapKernel implements IValueTypeCreator {
168
168
  private readonly pendingKeys: Map<string, number> = new Map();
169
169
 
170
170
  /**
171
- * This is used to assign a unique id to every outgoing operation and helps in tracking unack'd ops.
171
+ * This is used to assign a unique id to every outgoing operation and helps in tracking unacked ops.
172
172
  */
173
173
  private pendingMessageId: number = -1;
174
174
 
@@ -636,14 +636,14 @@ export class MapKernel implements IValueTypeCreator {
636
636
  if (this.pendingClearMessageId !== -1) {
637
637
  if (local) {
638
638
  assert(localOpMetadata !== undefined && localOpMetadata as number < this.pendingClearMessageId,
639
- 0x1f1 /* "Received out of order op when there is an unackd clear message" */);
639
+ 0x1f1 /* "Received out of order op when there is an unacked clear message" */);
640
640
  }
641
- // If we have an unack'd clear, we can ignore all ops.
641
+ // If we have an unacked clear, we can ignore all ops.
642
642
  return false;
643
643
  }
644
644
 
645
645
  if (this.pendingKeys.has(op.key)) {
646
- // Found an unack'd op. Clear it from the map if the pendingMessageId in the map matches this message's
646
+ // Found an unacked op. Clear it from the map if the pendingMessageId in the map matches this message's
647
647
  // and don't process the op.
648
648
  if (local) {
649
649
  assert(localOpMetadata !== undefined,
@@ -6,4 +6,4 @@
6
6
  */
7
7
 
8
8
  export const pkgName = "@fluidframework/sequence";
9
- export const pkgVersion = "0.58.0-55561";
9
+ export const pkgVersion = "0.58.1001";
package/src/sequence.ts CHANGED
@@ -156,7 +156,7 @@ export abstract class SharedSegmentSequence<T extends ISegment>
156
156
  protected client: Client;
157
157
  // Deferred that triggers once the object is loaded
158
158
  protected loadedDeferred = new Deferred<void>();
159
- // cache out going ops created when parital loading
159
+ // cache out going ops created when partial loading
160
160
  private readonly loadedDeferredOutgoingOps:
161
161
  [IMergeTreeOp, SegmentGroup | SegmentGroup[]][] = [];
162
162
  // cache incoming ops that arrive when partial loading
@@ -544,7 +544,7 @@ export abstract class SharedSegmentSequence<T extends ISegment>
544
544
  this.loadFinished(error);
545
545
  });
546
546
  if (this.dataStoreRuntime.options?.sequenceInitializeFromHeaderOnly !== true) {
547
- // if we not doing parital load, await the catch up ops,
547
+ // if we not doing partial load, await the catch up ops,
548
548
  // and the finalization of the load
549
549
  await loadCatchUpOps;
550
550
  }
@@ -600,14 +600,14 @@ export abstract class SharedSegmentSequence<T extends ISegment>
600
600
  const message = parseHandles(rawMessage, this.serializer);
601
601
 
602
602
  const ops: IMergeTreeDeltaOp[] = [];
603
- function transfromOps(event: SequenceDeltaEvent) {
603
+ function transformOps(event: SequenceDeltaEvent) {
604
604
  ops.push(...SharedSegmentSequence.createOpsFromDelta(event));
605
605
  }
606
606
  const needsTransformation = message.referenceSequenceNumber !== message.sequenceNumber - 1;
607
607
  let stashMessage: Readonly<ISequencedDocumentMessage> = message;
608
608
  if (this.runtime.options?.newMergeTreeSnapshotFormat !== true) {
609
609
  if (needsTransformation) {
610
- this.on("sequenceDelta", transfromOps);
610
+ this.on("sequenceDelta", transformOps);
611
611
  }
612
612
  }
613
613
 
@@ -615,7 +615,7 @@ export abstract class SharedSegmentSequence<T extends ISegment>
615
615
 
616
616
  if (this.runtime.options?.newMergeTreeSnapshotFormat !== true) {
617
617
  if (needsTransformation) {
618
- this.removeListener("sequenceDelta", transfromOps);
618
+ this.removeListener("sequenceDelta", transformOps);
619
619
  // shallow clone the message as we only overwrite top level properties,
620
620
  // like referenceSequenceNumber and content only
621
621
  stashMessage = {
@@ -660,7 +660,7 @@ export abstract class SharedSegmentSequence<T extends ISegment>
660
660
  throw error;
661
661
  } else {
662
662
  // it is important this series remains synchronous
663
- // first we stop defering incoming ops, and apply then all
663
+ // first we stop deferring incoming ops, and apply then all
664
664
  this.deferIncomingOps = false;
665
665
  while (this.loadedDeferredIncomingOps.length > 0) {
666
666
  this.processCore(this.loadedDeferredIncomingOps.shift(), false, undefined);
@@ -94,10 +94,10 @@ export class SharedObjectSequenceFactory implements IChannelFactory {
94
94
  * For more info, please see [Github issue 8526](https://github.com/microsoft/FluidFramework/issues/8526)
95
95
  */
96
96
  public static segmentFromSpec(segSpec: IJSONSegment) {
97
- // eslint-disable-next-line @typescript-eslint/ban-types
97
+
98
98
  const runSegment = segSpec as IJSONRunSegment<object>;
99
99
  if (runSegment.items) {
100
- // eslint-disable-next-line @typescript-eslint/ban-types
100
+
101
101
  const seg = new SubSequence<object>(runSegment.items);
102
102
  if (runSegment.props) {
103
103
  seg.addProperties(runSegment.props);
@@ -133,7 +133,7 @@ export class SharedObjectSequenceFactory implements IChannelFactory {
133
133
  id: string,
134
134
  services: IChannelServices,
135
135
  attributes: IChannelAttributes): Promise<ISharedObject> {
136
- // eslint-disable-next-line @typescript-eslint/ban-types
136
+
137
137
  const sharedSeq = new SharedObjectSequence<object>(runtime, id, attributes);
138
138
  await sharedSeq.load(services);
139
139
  return sharedSeq;
@@ -172,7 +172,7 @@ export class SharedIntervalCollection<TInterval extends ISerializableInterval =
172
172
 
173
173
  /**
174
174
  * Creates the full path of the intervalCollection label
175
- * @param label - the incoming lable
175
+ * @param label - the incoming label
176
176
  */
177
177
  protected getIntervalCollectionPath(label: string): string {
178
178
  return label;
@@ -27,7 +27,7 @@ export class SharedObjectSequence<T> extends SharedSequence<T> {
27
27
  * @deprecated SharedObjectSequence is not recommended for use and will be removed in an upcoming release.
28
28
  * For more info, please see [Github issue 8526](https://github.com/microsoft/FluidFramework/issues/8526)
29
29
  */
30
- // eslint-disable-next-line @typescript-eslint/no-shadow
30
+
31
31
  public static create<T>(runtime: IFluidDataStoreRuntime, id?: string) {
32
32
  return runtime.createChannel(id, SharedObjectSequenceFactory.Type) as SharedObjectSequence<T>;
33
33
  }
@@ -3,8 +3,6 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
 
6
- // eslint-disable-next-line import/no-unassigned-import
7
- import { } from "@fluidframework/core-interfaces";
8
6
  import {
9
7
  ICombiningOp,
10
8
  IMergeTreeInsertMsg,
@@ -30,7 +28,7 @@ export interface ISharedString extends SharedSegmentSequence<SharedStringSegment
30
28
  * Inserts the text at the position.
31
29
  * @param pos - The position to insert the text at
32
30
  * @param text - The text to insert
33
- * @param props - The properties of text
31
+ * @param props - The properties of the text
34
32
  */
35
33
  insertText(pos: number, text: string, props?: PropertySet): void;
36
34
 
@@ -159,7 +159,7 @@ export class RunSegment extends SubSequence<SparseMatrixItem> {
159
159
  }
160
160
 
161
161
  public getTag(pos: number) {
162
- // eslint-disable-next-line @typescript-eslint/no-unsafe-return
162
+
163
163
  return this.tags[pos];
164
164
  }
165
165
 
@@ -276,13 +276,13 @@ export class SparseMatrix extends SharedSegmentSequence<MatrixSegment> {
276
276
 
277
277
  public getItem(row: number, col: number):
278
278
  // The return type is defined explicitly here to prevent TypeScript from generating dynamic imports
279
- // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-arguments
279
+
280
280
  Jsonable<string | number | boolean | IFluidHandle<IFluidObject & FluidObject & IFluidLoadable>> {
281
281
  const pos = rowColToPosition(row, col);
282
282
  const { segment, offset } =
283
283
  this.getContainingSegment(pos);
284
284
  if (RunSegment.is(segment)) {
285
- // eslint-disable-next-line @typescript-eslint/no-unsafe-return
285
+
286
286
  return segment.items[offset];
287
287
  } else if (PaddingSegment.is(segment)) {
288
288
  return undefined;
@@ -294,7 +294,7 @@ export class SparseMatrix extends SharedSegmentSequence<MatrixSegment> {
294
294
  public getTag(row: number, col: number) {
295
295
  const { segment, offset } = this.getSegment(row, col);
296
296
  if (RunSegment.is(segment)) {
297
- // eslint-disable-next-line @typescript-eslint/no-unsafe-return
297
+
298
298
  return segment.getTag(offset);
299
299
  }
300
300
  return undefined;