@fluidframework/sequence 1.2.2 → 2.0.0-internal.1.0.0.82159

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 (46) hide show
  1. package/dist/intervalCollection.d.ts +5 -10
  2. package/dist/intervalCollection.d.ts.map +1 -1
  3. package/dist/intervalCollection.js +20 -35
  4. package/dist/intervalCollection.js.map +1 -1
  5. package/dist/packageVersion.d.ts +1 -1
  6. package/dist/packageVersion.d.ts.map +1 -1
  7. package/dist/packageVersion.js +1 -1
  8. package/dist/packageVersion.js.map +1 -1
  9. package/dist/sequence.d.ts +5 -17
  10. package/dist/sequence.d.ts.map +1 -1
  11. package/dist/sequence.js +4 -28
  12. package/dist/sequence.js.map +1 -1
  13. package/dist/sequenceDeltaEvent.d.ts +0 -6
  14. package/dist/sequenceDeltaEvent.d.ts.map +1 -1
  15. package/dist/sequenceDeltaEvent.js +0 -1
  16. package/dist/sequenceDeltaEvent.js.map +1 -1
  17. package/dist/sharedString.d.ts +4 -0
  18. package/dist/sharedString.d.ts.map +1 -1
  19. package/dist/sharedString.js +11 -0
  20. package/dist/sharedString.js.map +1 -1
  21. package/lib/intervalCollection.d.ts +5 -10
  22. package/lib/intervalCollection.d.ts.map +1 -1
  23. package/lib/intervalCollection.js +21 -36
  24. package/lib/intervalCollection.js.map +1 -1
  25. package/lib/packageVersion.d.ts +1 -1
  26. package/lib/packageVersion.d.ts.map +1 -1
  27. package/lib/packageVersion.js +1 -1
  28. package/lib/packageVersion.js.map +1 -1
  29. package/lib/sequence.d.ts +5 -17
  30. package/lib/sequence.d.ts.map +1 -1
  31. package/lib/sequence.js +5 -29
  32. package/lib/sequence.js.map +1 -1
  33. package/lib/sequenceDeltaEvent.d.ts +0 -6
  34. package/lib/sequenceDeltaEvent.d.ts.map +1 -1
  35. package/lib/sequenceDeltaEvent.js +0 -1
  36. package/lib/sequenceDeltaEvent.js.map +1 -1
  37. package/lib/sharedString.d.ts +4 -0
  38. package/lib/sharedString.d.ts.map +1 -1
  39. package/lib/sharedString.js +11 -0
  40. package/lib/sharedString.js.map +1 -1
  41. package/package.json +60 -20
  42. package/src/intervalCollection.ts +33 -53
  43. package/src/packageVersion.ts +1 -1
  44. package/src/sequence.ts +4 -36
  45. package/src/sequenceDeltaEvent.ts +0 -7
  46. package/src/sharedString.ts +13 -2
@@ -16,7 +16,7 @@ var __rest = (this && this.__rest) || function (s, e) {
16
16
  /* eslint-disable no-bitwise */
17
17
  import { assert, TypedEventEmitter } from "@fluidframework/common-utils";
18
18
  import { UsageError } from "@fluidframework/container-utils";
19
- import { addProperties, createMap, IntervalTree, LocalReference, MergeTreeDeltaType, PropertiesManager, RedBlackTree, ReferenceType, refTypeIncludesFlag, reservedRangeLabelsKey, UnassignedSequenceNumber, } from "@fluidframework/merge-tree";
19
+ import { addProperties, compareReferencePositions, createMap, IntervalTree, MergeTreeDeltaType, minReferencePosition, PropertiesManager, RedBlackTree, ReferenceType, refTypeIncludesFlag, reservedRangeLabelsKey, UnassignedSequenceNumber, maxReferencePosition, createDetachedLocalReferencePosition, } from "@fluidframework/merge-tree";
20
20
  import { LoggingError } from "@fluidframework/telemetry-utils";
21
21
  import { v4 as uuid } from "uuid";
22
22
  const reservedIntervalIdKey = "intervalId";
@@ -180,7 +180,8 @@ export class Interval {
180
180
  }
181
181
  }
182
182
  export class SequenceInterval {
183
- constructor(start, end, intervalType, props) {
183
+ constructor(client, start, end, intervalType, props) {
184
+ this.client = client;
184
185
  this.start = start;
185
186
  this.end = end;
186
187
  this.intervalType = intervalType;
@@ -220,8 +221,8 @@ export class SequenceInterval {
220
221
  }
221
222
  }
222
223
  serialize(client) {
223
- const startPosition = this.start.toPosition();
224
- const endPosition = this.end.toPosition();
224
+ const startPosition = client.localReferencePositionToPosition(this.start);
225
+ const endPosition = client.localReferencePositionToPosition(this.end);
225
226
  const serializedInterval = {
226
227
  end: endPosition,
227
228
  intervalType: this.intervalType,
@@ -234,7 +235,7 @@ export class SequenceInterval {
234
235
  return serializedInterval;
235
236
  }
236
237
  clone() {
237
- return new SequenceInterval(this.start, this.end, this.intervalType, this.properties);
238
+ return new SequenceInterval(this.client, this.start, this.end, this.intervalType, this.properties);
238
239
  }
239
240
  compare(b) {
240
241
  const startResult = this.compareStart(b);
@@ -260,14 +261,14 @@ export class SequenceInterval {
260
261
  }
261
262
  }
262
263
  compareStart(b) {
263
- return this.start.compare(b.start);
264
+ return compareReferencePositions(this.start, b.start);
264
265
  }
265
266
  compareEnd(b) {
266
- return this.end.compare(b.end);
267
+ return compareReferencePositions(this.end, b.end);
267
268
  }
268
269
  overlaps(b) {
269
- const result = (this.start.compare(b.end) <= 0) &&
270
- (this.end.compare(b.start) >= 0);
270
+ const result = (compareReferencePositions(this.start, b.end) <= 0) &&
271
+ (compareReferencePositions(this.end, b.start) >= 0);
271
272
  return result;
272
273
  }
273
274
  getIntervalId() {
@@ -279,15 +280,15 @@ export class SequenceInterval {
279
280
  return `${id}`;
280
281
  }
281
282
  union(b) {
282
- return new SequenceInterval(this.start.min(b.start), this.end.max(b.end), this.intervalType);
283
+ return new SequenceInterval(this.client, minReferencePosition(this.start, b.start), maxReferencePosition(this.end, b.end), this.intervalType);
283
284
  }
284
285
  addProperties(newProps, collab = false, seq, op) {
285
286
  this.initializeProperties();
286
287
  return this.propertyManager.addProperties(this.properties, newProps, op, seq, collab);
287
288
  }
288
289
  overlapsPos(bstart, bend) {
289
- const startPos = this.start.toPosition();
290
- const endPos = this.start.toPosition();
290
+ const startPos = this.client.localReferencePositionToPosition(this.start);
291
+ const endPos = this.client.localReferencePositionToPosition(this.end);
291
292
  return (endPos > bstart) && (startPos < bend);
292
293
  }
293
294
  modify(label, start, end, op) {
@@ -301,17 +302,15 @@ export class SequenceInterval {
301
302
  };
302
303
  let startRef = this.start;
303
304
  if (start !== undefined) {
304
- startRef = createPositionReference(this.start.getClient(), start, getRefType(this.start.refType), op);
305
+ startRef = createPositionReference(this.client, start, getRefType(this.start.refType), op);
305
306
  startRef.addProperties(this.start.properties);
306
307
  }
307
308
  let endRef = this.end;
308
309
  if (end !== undefined) {
309
- endRef = createPositionReference(this.end.getClient(), end, getRefType(this.end.refType), op);
310
+ endRef = createPositionReference(this.client, end, getRefType(this.end.refType), op);
310
311
  endRef.addProperties(this.end.properties);
311
312
  }
312
- startRef.pairedRef = endRef;
313
- endRef.pairedRef = startRef;
314
- const newInterval = new SequenceInterval(startRef, endRef, this.intervalType);
313
+ const newInterval = new SequenceInterval(this.client, startRef, endRef, this.intervalType);
315
314
  if (this.properties) {
316
315
  newInterval.initializeProperties();
317
316
  this.propertyManager.copyTo(this.properties, newInterval.properties, newInterval.propertyManager);
@@ -336,8 +335,8 @@ function createPositionReferenceFromSegoff(client, segoff, refType, op) {
336
335
  if (!op && !refTypeIncludesFlag(refType, ReferenceType.Transient)) {
337
336
  throw new UsageError("Non-transient references need segment");
338
337
  }
339
- return new LocalReference(client, undefined, 0, refType);
340
338
  }
339
+ return createDetachedLocalReferencePosition(refType);
341
340
  }
342
341
  function createPositionReference(client, pos, refType, op, fromSnapshot) {
343
342
  let segoff;
@@ -378,14 +377,12 @@ function createSequenceInterval(label, start, end, client, intervalType, op, fro
378
377
  }
379
378
  const startLref = createPositionReference(client, start, beginRefType, op, fromSnapshot);
380
379
  const endLref = createPositionReference(client, end, endRefType, op, fromSnapshot);
381
- startLref.pairedRef = endLref;
382
- endLref.pairedRef = startLref;
383
380
  const rangeProp = {
384
381
  [reservedRangeLabelsKey]: [label],
385
382
  };
386
383
  startLref.addProperties(rangeProp);
387
384
  endLref.addProperties(rangeProp);
388
- const ival = new SequenceInterval(startLref, endLref, intervalType, rangeProp);
385
+ const ival = new SequenceInterval(client, startLref, endLref, intervalType, rangeProp);
389
386
  return ival;
390
387
  }
391
388
  export function defaultIntervalConflictResolver(a, b) {
@@ -641,7 +638,7 @@ export class LocalIntervalCollection {
641
638
  }
642
639
  }
643
640
  LocalIntervalCollection.legacyIdPrefix = "legacy";
644
- const compareSequenceIntervalEnds = (a, b) => a.end.compare(b.end);
641
+ const compareSequenceIntervalEnds = (a, b) => compareReferencePositions(a.end, b.end);
645
642
  class SequenceIntervalCollectionFactory {
646
643
  load(emitter, raw = []) {
647
644
  const helpers = {
@@ -969,10 +966,6 @@ export class IntervalCollection extends TypedEventEmitter {
969
966
  const entries = this.pendingChangesEnd.get(id);
970
967
  return entries && entries.length !== 0;
971
968
  }
972
- /** @deprecated - use ackChange */
973
- changeInterval(serializedInterval, local, op) {
974
- return this.ackChange(serializedInterval, local, op);
975
- }
976
969
  /** @internal */
977
970
  ackChange(serializedInterval, local, op) {
978
971
  var _a, _b, _c, _d;
@@ -1072,7 +1065,7 @@ export class IntervalCollection extends TypedEventEmitter {
1072
1065
  return rebased;
1073
1066
  }
1074
1067
  getSlideToSegment(lref) {
1075
- const segoff = { segment: lref.segment, offset: lref.offset };
1068
+ const segoff = { segment: lref.getSegment(), offset: lref.getOffset() };
1076
1069
  const newSegoff = this.client.getSlideToSegment(segoff);
1077
1070
  const value = (segoff.segment === newSegoff.segment && segoff.offset === newSegoff.offset) ? undefined : newSegoff;
1078
1071
  return value;
@@ -1108,7 +1101,7 @@ export class IntervalCollection extends TypedEventEmitter {
1108
1101
  if (needsStartUpdate || needsEndUpdate) {
1109
1102
  // In this case, where we change the start or end of an interval,
1110
1103
  // it is necessary to remove and re-add the interval listeners.
1111
- // This ensures that the correct listeners are added to the ReferencePosition.
1104
+ // This ensures that the correct listeners are added to the LocalReferencePosition.
1112
1105
  this.localCollection.removeExistingInterval(interval);
1113
1106
  if (needsStartUpdate) {
1114
1107
  const props = interval.start.properties;
@@ -1129,10 +1122,6 @@ export class IntervalCollection extends TypedEventEmitter {
1129
1122
  this.localCollection.add(interval);
1130
1123
  }
1131
1124
  }
1132
- /** @deprecated - use ackAdd */
1133
- addInternal(serializedInterval, local, op) {
1134
- return this.ackAdd(serializedInterval, local, op);
1135
- }
1136
1125
  /** @internal */
1137
1126
  ackAdd(serializedInterval, local, op) {
1138
1127
  var _a;
@@ -1157,10 +1146,6 @@ export class IntervalCollection extends TypedEventEmitter {
1157
1146
  this.emit("addInterval", interval, local, op);
1158
1147
  return interval;
1159
1148
  }
1160
- /** @deprecated - use ackDelete */
1161
- deleteInterval(serializedInterval, local, op) {
1162
- return this.ackDelete(serializedInterval, local, op);
1163
- }
1164
1149
  /** @internal */
1165
1150
  ackDelete(serializedInterval, local, op) {
1166
1151
  if (local) {