@fluidframework/sequence 2.0.0-internal.1.0.0.82693 → 2.0.0-internal.1.1.0
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/.mocharc.js +12 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/intervalCollection.d.ts +31 -4
- package/dist/intervalCollection.d.ts.map +1 -1
- package/dist/intervalCollection.js +84 -24
- 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/sharedString.d.ts +26 -1
- package/dist/sharedString.d.ts.map +1 -1
- package/dist/sharedString.js +29 -5
- package/dist/sharedString.js.map +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -1
- package/lib/index.js.map +1 -1
- package/lib/intervalCollection.d.ts +31 -4
- package/lib/intervalCollection.d.ts.map +1 -1
- package/lib/intervalCollection.js +83 -24
- 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/sharedString.d.ts +26 -1
- package/lib/sharedString.d.ts.map +1 -1
- package/lib/sharedString.js +27 -4
- package/lib/sharedString.js.map +1 -1
- package/package.json +25 -20
- package/src/index.ts +2 -0
- package/src/intervalCollection.ts +131 -26
- package/src/packageVersion.ts +1 -1
- package/src/sharedString.ts +31 -4
package/.mocharc.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
'use strict';
|
|
7
|
+
|
|
8
|
+
const getFluidTestMochaConfig = require('@fluidframework/mocha-test-setup/mocharc-common');
|
|
9
|
+
|
|
10
|
+
const packageDir = __dirname;
|
|
11
|
+
const config = getFluidTestMochaConfig(packageDir);
|
|
12
|
+
module.exports = config;
|
package/dist/index.d.ts
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
*
|
|
14
14
|
* @packageDocumentation
|
|
15
15
|
*/
|
|
16
|
-
export { DeserializeCallback, IIntervalCollectionEvent, IIntervalHelpers, Interval, IntervalCollection, IntervalCollectionIterator, IntervalType, ISerializableInterval, ISerializedInterval, SequenceInterval, ISerializedIntervalCollectionV2, CompressedSerializedInterval, } from "./intervalCollection";
|
|
16
|
+
export { DeserializeCallback, IIntervalCollectionEvent, IIntervalHelpers, Interval, IntervalCollection, IntervalCollectionIterator, IntervalLocator, intervalLocatorFromEndpoint, IntervalType, ISerializableInterval, ISerializedInterval, SequenceInterval, ISerializedIntervalCollectionV2, CompressedSerializedInterval, } from "./intervalCollection";
|
|
17
17
|
export { IMapMessageLocalMetadata, IValueOpEmitter, } from "./defaultMapInterfaces";
|
|
18
18
|
export * from "./sharedString";
|
|
19
19
|
export * from "./sequence";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;;;GAUG;AAEH,OAAO,EACH,mBAAmB,EACnB,wBAAwB,EACxB,gBAAgB,EAChB,QAAQ,EACR,kBAAkB,EAClB,0BAA0B,EAC1B,YAAY,EACZ,qBAAqB,EACrB,mBAAmB,EACnB,gBAAgB,EAChB,+BAA+B,EAC/B,4BAA4B,GAC/B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACH,wBAAwB,EACxB,eAAe,GAClB,MAAM,wBAAwB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,YAAY,CAAC;AAC3B,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,cAAc,kBAAkB,CAAC;AACjC,cAAc,wBAAwB,CAAC;AACvC,cAAc,wBAAwB,CAAC;AACvC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,4BAA4B,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;;;GAUG;AAEH,OAAO,EACH,mBAAmB,EACnB,wBAAwB,EACxB,gBAAgB,EAChB,QAAQ,EACR,kBAAkB,EAClB,0BAA0B,EAC1B,eAAe,EACf,2BAA2B,EAC3B,YAAY,EACZ,qBAAqB,EACrB,mBAAmB,EACnB,gBAAgB,EAChB,+BAA+B,EAC/B,4BAA4B,GAC/B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACH,wBAAwB,EACxB,eAAe,GAClB,MAAM,wBAAwB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,YAAY,CAAC;AAC3B,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,cAAc,kBAAkB,CAAC;AACjC,cAAc,wBAAwB,CAAC;AACvC,cAAc,wBAAwB,CAAC;AACvC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,4BAA4B,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.SequenceInterval = exports.IntervalType = exports.IntervalCollectionIterator = exports.IntervalCollection = exports.Interval = void 0;
|
|
17
|
+
exports.SequenceInterval = exports.IntervalType = exports.intervalLocatorFromEndpoint = exports.IntervalCollectionIterator = exports.IntervalCollection = exports.Interval = void 0;
|
|
18
18
|
/**
|
|
19
19
|
* Supports distributed data structures which are list-like.
|
|
20
20
|
*
|
|
@@ -30,6 +30,7 @@ var intervalCollection_1 = require("./intervalCollection");
|
|
|
30
30
|
Object.defineProperty(exports, "Interval", { enumerable: true, get: function () { return intervalCollection_1.Interval; } });
|
|
31
31
|
Object.defineProperty(exports, "IntervalCollection", { enumerable: true, get: function () { return intervalCollection_1.IntervalCollection; } });
|
|
32
32
|
Object.defineProperty(exports, "IntervalCollectionIterator", { enumerable: true, get: function () { return intervalCollection_1.IntervalCollectionIterator; } });
|
|
33
|
+
Object.defineProperty(exports, "intervalLocatorFromEndpoint", { enumerable: true, get: function () { return intervalCollection_1.intervalLocatorFromEndpoint; } });
|
|
33
34
|
Object.defineProperty(exports, "IntervalType", { enumerable: true, get: function () { return intervalCollection_1.IntervalType; } });
|
|
34
35
|
Object.defineProperty(exports, "SequenceInterval", { enumerable: true, get: function () { return intervalCollection_1.SequenceInterval; } });
|
|
35
36
|
__exportStar(require("./sharedString"), exports);
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;AAEH;;;;;;;;;;GAUG;AAEH,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;AAEH;;;;;;;;;;GAUG;AAEH,2DAe8B;AAX1B,8GAAA,QAAQ,OAAA;AACR,wHAAA,kBAAkB,OAAA;AAClB,gIAAA,0BAA0B,OAAA;AAE1B,iIAAA,2BAA2B,OAAA;AAC3B,kHAAA,YAAY,OAAA;AAGZ,sHAAA,gBAAgB,OAAA;AAQpB,iDAA+B;AAC/B,6CAA2B;AAC3B,oDAAkC;AAClC,uDAAqC;AACrC,mDAAiC;AACjC,yDAAuC;AACvC,yDAAuC;AACvC,iDAA+B;AAC/B,6DAA2C","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/**\n * Supports distributed data structures which are list-like.\n *\n * This package's main export is {@link SharedSequence}, a DDS for storing and simultaneously editing a sequence of\n * text.\n *\n * @remarks Note that SharedString is a sequence DDS but it has additional specialized features and behaviors for\n * working with text.\n *\n * @packageDocumentation\n */\n\nexport {\n DeserializeCallback,\n IIntervalCollectionEvent,\n IIntervalHelpers,\n Interval,\n IntervalCollection,\n IntervalCollectionIterator,\n IntervalLocator,\n intervalLocatorFromEndpoint,\n IntervalType,\n ISerializableInterval,\n ISerializedInterval,\n SequenceInterval,\n ISerializedIntervalCollectionV2,\n CompressedSerializedInterval,\n} from \"./intervalCollection\";\nexport {\n IMapMessageLocalMetadata,\n IValueOpEmitter,\n} from \"./defaultMapInterfaces\";\nexport * from \"./sharedString\";\nexport * from \"./sequence\";\nexport * from \"./sequenceFactory\";\nexport * from \"./sequenceDeltaEvent\";\nexport * from \"./sharedSequence\";\nexport * from \"./sharedObjectSequence\";\nexport * from \"./sharedNumberSequence\";\nexport * from \"./sparsematrix\";\nexport * from \"./sharedIntervalCollection\";\n"]}
|
|
@@ -118,7 +118,7 @@ export declare class SequenceInterval implements ISerializableInterval {
|
|
|
118
118
|
union(b: SequenceInterval): SequenceInterval;
|
|
119
119
|
addProperties(newProps: PropertySet, collab?: boolean, seq?: number, op?: ICombiningOp): PropertySet | undefined;
|
|
120
120
|
overlapsPos(bstart: number, bend: number): boolean;
|
|
121
|
-
modify(label: string, start: number, end: number, op?: ISequencedDocumentMessage): SequenceInterval;
|
|
121
|
+
modify(label: string, start: number, end: number, op?: ISequencedDocumentMessage, localSeq?: number): SequenceInterval;
|
|
122
122
|
private initializeProperties;
|
|
123
123
|
}
|
|
124
124
|
export declare function defaultIntervalConflictResolver(a: Interval, b: Interval): Interval;
|
|
@@ -159,10 +159,11 @@ export declare class LocalIntervalCollection<TInterval extends ISerializableInte
|
|
|
159
159
|
removeExistingInterval(interval: TInterval): void;
|
|
160
160
|
createInterval(start: number, end: number, intervalType: IntervalType, op?: ISequencedDocumentMessage): TInterval;
|
|
161
161
|
addInterval(start: number, end: number, intervalType: IntervalType, props?: PropertySet, op?: ISequencedDocumentMessage): TInterval;
|
|
162
|
+
private linkEndpointsToInterval;
|
|
162
163
|
private addIntervalToIndex;
|
|
163
164
|
add(interval: TInterval): void;
|
|
164
165
|
getIntervalById(id: string): TInterval;
|
|
165
|
-
changeInterval(interval: TInterval, start: number, end: number, op?: ISequencedDocumentMessage): TInterval;
|
|
166
|
+
changeInterval(interval: TInterval, start: number, end: number, op?: ISequencedDocumentMessage, localSeq?: number): TInterval;
|
|
166
167
|
serialize(): ISerializedIntervalCollectionV2;
|
|
167
168
|
private addIntervalListeners;
|
|
168
169
|
private removeIntervalListeners;
|
|
@@ -249,8 +250,14 @@ export declare class IntervalCollection<TInterval extends ISerializableInterval>
|
|
|
249
250
|
ackChange(serializedInterval: ISerializedInterval, local: boolean, op: ISequencedDocumentMessage): void;
|
|
250
251
|
addConflictResolver(conflictResolver: IntervalConflictResolver<TInterval>): void;
|
|
251
252
|
attachDeserializer(onDeserialize: DeserializeCallback): void;
|
|
252
|
-
/**
|
|
253
|
-
|
|
253
|
+
/**
|
|
254
|
+
* @internal
|
|
255
|
+
*
|
|
256
|
+
* Returns new interval after rebasing. If undefined, the interval was
|
|
257
|
+
* deleted as a result of rebasing. This can occur if the interval applies
|
|
258
|
+
* to a range that no longer exists, and the interval was unable to slide.
|
|
259
|
+
*/
|
|
260
|
+
rebaseLocalInterval(opName: string, serializedInterval: ISerializedInterval, localSeq: number): ISerializedInterval | undefined;
|
|
254
261
|
private getSlideToSegment;
|
|
255
262
|
private setSlideOnRemove;
|
|
256
263
|
private ackInterval;
|
|
@@ -273,4 +280,24 @@ export declare class IntervalCollection<TInterval extends ISerializableInterval>
|
|
|
273
280
|
previousInterval(pos: number): TInterval;
|
|
274
281
|
nextInterval(pos: number): TInterval;
|
|
275
282
|
}
|
|
283
|
+
/**
|
|
284
|
+
* Information that identifies an interval within a `Sequence`.
|
|
285
|
+
*/
|
|
286
|
+
export interface IntervalLocator {
|
|
287
|
+
/**
|
|
288
|
+
* Label for the collection the interval is a part of
|
|
289
|
+
*/
|
|
290
|
+
label: string;
|
|
291
|
+
/**
|
|
292
|
+
* Interval within that collection
|
|
293
|
+
*/
|
|
294
|
+
interval: SequenceInterval;
|
|
295
|
+
}
|
|
296
|
+
/**
|
|
297
|
+
* Returns an object that can be used to find the interval a given LocalReferencePosition belongs to.
|
|
298
|
+
* @returns undefined if the reference position is not the endpoint of any interval (e.g. it was created
|
|
299
|
+
* on the merge tree directly by app code), otherwise an {@link IntervalLocator} for the interval this
|
|
300
|
+
* endpoint is a part of.
|
|
301
|
+
*/
|
|
302
|
+
export declare function intervalLocatorFromEndpoint(potentialEndpoint: LocalReferencePosition): IntervalLocator | undefined;
|
|
276
303
|
//# sourceMappingURL=intervalCollection.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"intervalCollection.d.ts","sourceRoot":"","sources":["../src/intervalCollection.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAU,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACzE,OAAO,EAAE,MAAM,EAAE,MAAM,oCAAoC,CAAC;AAE5D,OAAO,EAEH,MAAM,EAIN,YAAY,EACZ,SAAS,EACT,wBAAwB,EAMxB,iBAAiB,EACjB,WAAW,EAEX,sBAAsB,
|
|
1
|
+
{"version":3,"file":"intervalCollection.d.ts","sourceRoot":"","sources":["../src/intervalCollection.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAU,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACzE,OAAO,EAAE,MAAM,EAAE,MAAM,oCAAoC,CAAC;AAE5D,OAAO,EAEH,MAAM,EAIN,YAAY,EACZ,SAAS,EACT,wBAAwB,EAMxB,iBAAiB,EACjB,WAAW,E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,oCAAoC,CAAC,WAAW,EAAE,MAAM,GAAG,0BAA0B,CAAC,SAAS,CAAC;IAKhG,qCAAqC,CAAC,WAAW,EAAE,MAAM,GAAG,0BAA0B,CAAC,SAAS,CAAC;IAKjG,sBAAsB,CACzB,OAAO,EAAE,SAAS,EAAE,EACpB,eAAe,EAAE,OAAO,EACxB,KAAK,CAAC,EAAE,MAAM,EACd,GAAG,CAAC,EAAE,MAAM;IAQT,wBAAwB,CAAC,aAAa,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,SAAS,EAAE;IAQjF,GAAG,CAAC,EAAE,EAAE,CAAC,QAAQ,EAAE,SAAS,KAAK,IAAI;IAQrC,gBAAgB,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS;IAQxC,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS;CAO9C;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC5B;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,QAAQ,EAAE,gBAAgB,CAAC;CAC9B;AAED;;;;;GAKG;AACH,wBAAgB,2BAA2B,CAAC,iBAAiB,EAAE,sBAAsB,GAAG,eAAe,GAAG,SAAS,CAMlH"}
|
|
@@ -15,7 +15,7 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
15
15
|
return t;
|
|
16
16
|
};
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
exports.IntervalCollection = exports.IntervalCollectionIterator = exports.IntervalCollectionValueType = exports.SequenceIntervalCollectionValueType = exports.LocalIntervalCollection = exports.createIntervalIndex = exports.defaultIntervalConflictResolver = exports.SequenceInterval = exports.Interval = exports.IntervalType = void 0;
|
|
18
|
+
exports.intervalLocatorFromEndpoint = exports.IntervalCollection = exports.IntervalCollectionIterator = exports.IntervalCollectionValueType = exports.SequenceIntervalCollectionValueType = exports.LocalIntervalCollection = exports.createIntervalIndex = exports.defaultIntervalConflictResolver = exports.SequenceInterval = exports.Interval = exports.IntervalType = void 0;
|
|
19
19
|
/* eslint-disable no-bitwise */
|
|
20
20
|
const common_utils_1 = require("@fluidframework/common-utils");
|
|
21
21
|
const container_utils_1 = require("@fluidframework/container-utils");
|
|
@@ -50,7 +50,7 @@ function decompressInterval(interval, label) {
|
|
|
50
50
|
end: interval[1],
|
|
51
51
|
sequenceNumber: interval[2],
|
|
52
52
|
intervalType: interval[3],
|
|
53
|
-
properties: Object.assign(Object.assign({}, interval[4]), { [merge_tree_1.reservedRangeLabelsKey]: label }),
|
|
53
|
+
properties: Object.assign(Object.assign({}, interval[4]), { [merge_tree_1.reservedRangeLabelsKey]: [label] }),
|
|
54
54
|
};
|
|
55
55
|
}
|
|
56
56
|
/**
|
|
@@ -95,10 +95,8 @@ class Interval {
|
|
|
95
95
|
this.auxProps.push(props);
|
|
96
96
|
}
|
|
97
97
|
serialize(client) {
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
seq = client.getCurrentSeq();
|
|
101
|
-
}
|
|
98
|
+
var _a;
|
|
99
|
+
const seq = (_a = client === null || client === void 0 ? void 0 : client.getCurrentSeq()) !== null && _a !== void 0 ? _a : 0;
|
|
102
100
|
const serializedInterval = {
|
|
103
101
|
end: this.end,
|
|
104
102
|
intervalType: 0,
|
|
@@ -295,7 +293,7 @@ class SequenceInterval {
|
|
|
295
293
|
const endPos = this.client.localReferencePositionToPosition(this.end);
|
|
296
294
|
return (endPos > bstart) && (startPos < bend);
|
|
297
295
|
}
|
|
298
|
-
modify(label, start, end, op) {
|
|
296
|
+
modify(label, start, end, op, localSeq) {
|
|
299
297
|
const getRefType = (baseType) => {
|
|
300
298
|
let refType = baseType;
|
|
301
299
|
if (op === undefined) {
|
|
@@ -306,12 +304,12 @@ class SequenceInterval {
|
|
|
306
304
|
};
|
|
307
305
|
let startRef = this.start;
|
|
308
306
|
if (start !== undefined) {
|
|
309
|
-
startRef = createPositionReference(this.client, start, getRefType(this.start.refType), op);
|
|
307
|
+
startRef = createPositionReference(this.client, start, getRefType(this.start.refType), op, undefined, localSeq);
|
|
310
308
|
startRef.addProperties(this.start.properties);
|
|
311
309
|
}
|
|
312
310
|
let endRef = this.end;
|
|
313
311
|
if (end !== undefined) {
|
|
314
|
-
endRef = createPositionReference(this.client, end, getRefType(this.end.refType), op);
|
|
312
|
+
endRef = createPositionReference(this.client, end, getRefType(this.end.refType), op, undefined, localSeq);
|
|
315
313
|
endRef.addProperties(this.end.properties);
|
|
316
314
|
}
|
|
317
315
|
const newInterval = new SequenceInterval(this.client, startRef, endRef, this.intervalType);
|
|
@@ -336,14 +334,13 @@ function createPositionReferenceFromSegoff(client, segoff, refType, op) {
|
|
|
336
334
|
const ref = client.createLocalReferencePosition(segoff.segment, segoff.offset, refType, undefined);
|
|
337
335
|
return ref;
|
|
338
336
|
}
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
}
|
|
337
|
+
if (!op && !(0, merge_tree_1.refTypeIncludesFlag)(refType, merge_tree_1.ReferenceType.Transient)) {
|
|
338
|
+
// reference to segment that dne locally
|
|
339
|
+
throw new container_utils_1.UsageError("Non-transient references need segment");
|
|
343
340
|
}
|
|
344
341
|
return (0, merge_tree_1.createDetachedLocalReferencePosition)(refType);
|
|
345
342
|
}
|
|
346
|
-
function createPositionReference(client, pos, refType, op, fromSnapshot) {
|
|
343
|
+
function createPositionReference(client, pos, refType, op, fromSnapshot, localSeq) {
|
|
347
344
|
let segoff;
|
|
348
345
|
if (op) {
|
|
349
346
|
(0, common_utils_1.assert)((refType & merge_tree_1.ReferenceType.SlideOnRemove) !== 0, 0x2f5 /* op create references must be SlideOnRemove */);
|
|
@@ -352,7 +349,7 @@ function createPositionReference(client, pos, refType, op, fromSnapshot) {
|
|
|
352
349
|
}
|
|
353
350
|
else {
|
|
354
351
|
(0, common_utils_1.assert)((refType & merge_tree_1.ReferenceType.SlideOnRemove) === 0 || fromSnapshot, 0x2f6 /* SlideOnRemove references must be op created */);
|
|
355
|
-
segoff = client.getContainingSegment(pos);
|
|
352
|
+
segoff = client.getContainingSegment(pos, undefined, localSeq);
|
|
356
353
|
}
|
|
357
354
|
return createPositionReferenceFromSegoff(client, segoff, refType, op);
|
|
358
355
|
}
|
|
@@ -576,6 +573,8 @@ class LocalIntervalCollection {
|
|
|
576
573
|
return this.helpers.create(this.label, start, end, this.client, intervalType, op);
|
|
577
574
|
}
|
|
578
575
|
addInterval(start, end, intervalType, props, op) {
|
|
576
|
+
var _a;
|
|
577
|
+
var _b;
|
|
579
578
|
const interval = this.createInterval(start, end, intervalType, op);
|
|
580
579
|
if (interval) {
|
|
581
580
|
if (!interval.properties) {
|
|
@@ -584,14 +583,17 @@ class LocalIntervalCollection {
|
|
|
584
583
|
if (props) {
|
|
585
584
|
interval.addProperties(props);
|
|
586
585
|
}
|
|
587
|
-
|
|
588
|
-
// Create a new ID.
|
|
589
|
-
interval.properties[reservedIntervalIdKey] = (0, uuid_1.v4)();
|
|
590
|
-
}
|
|
586
|
+
(_a = (_b = interval.properties)[reservedIntervalIdKey]) !== null && _a !== void 0 ? _a : (_b[reservedIntervalIdKey] = (0, uuid_1.v4)());
|
|
591
587
|
this.add(interval);
|
|
592
588
|
}
|
|
593
589
|
return interval;
|
|
594
590
|
}
|
|
591
|
+
linkEndpointsToInterval(interval) {
|
|
592
|
+
if (interval instanceof SequenceInterval) {
|
|
593
|
+
interval.start.addProperties({ interval });
|
|
594
|
+
interval.end.addProperties({ interval });
|
|
595
|
+
}
|
|
596
|
+
}
|
|
595
597
|
addIntervalToIndex(interval) {
|
|
596
598
|
const id = interval.getIntervalId();
|
|
597
599
|
(0, common_utils_1.assert)(id !== undefined, 0x2c0 /* "ID must be created before adding interval to collection" */);
|
|
@@ -606,14 +608,15 @@ class LocalIntervalCollection {
|
|
|
606
608
|
this.intervalIdMap.set(id, interval);
|
|
607
609
|
}
|
|
608
610
|
add(interval) {
|
|
611
|
+
this.linkEndpointsToInterval(interval);
|
|
609
612
|
this.addIntervalToIndex(interval);
|
|
610
613
|
this.addIntervalListeners(interval);
|
|
611
614
|
}
|
|
612
615
|
getIntervalById(id) {
|
|
613
616
|
return this.intervalIdMap.get(id);
|
|
614
617
|
}
|
|
615
|
-
changeInterval(interval, start, end, op) {
|
|
616
|
-
const newInterval = interval.modify(this.label, start, end, op);
|
|
618
|
+
changeInterval(interval, start, end, op, localSeq) {
|
|
619
|
+
const newInterval = interval.modify(this.label, start, end, op, localSeq);
|
|
617
620
|
if (newInterval) {
|
|
618
621
|
this.removeExistingInterval(interval);
|
|
619
622
|
this.add(newInterval);
|
|
@@ -722,6 +725,11 @@ function makeOpsMap() {
|
|
|
722
725
|
"add",
|
|
723
726
|
{
|
|
724
727
|
process: (collection, params, local, op) => {
|
|
728
|
+
// if params is undefined, the interval was deleted during
|
|
729
|
+
// rebasing
|
|
730
|
+
if (!params) {
|
|
731
|
+
return;
|
|
732
|
+
}
|
|
725
733
|
collection.ackAdd(params, local, op);
|
|
726
734
|
},
|
|
727
735
|
rebase,
|
|
@@ -743,6 +751,11 @@ function makeOpsMap() {
|
|
|
743
751
|
"change",
|
|
744
752
|
{
|
|
745
753
|
process: (collection, params, local, op) => {
|
|
754
|
+
// if params is undefined, the interval was deleted during
|
|
755
|
+
// rebasing
|
|
756
|
+
if (!params) {
|
|
757
|
+
return;
|
|
758
|
+
}
|
|
746
759
|
collection.ackChange(params, local, op);
|
|
747
760
|
},
|
|
748
761
|
rebase,
|
|
@@ -814,7 +827,10 @@ class IntervalCollection extends common_utils_1.TypedEventEmitter {
|
|
|
814
827
|
* Gets the next local sequence number, modifying this client's collab window in doing so.
|
|
815
828
|
*/
|
|
816
829
|
getNextLocalSeq() {
|
|
817
|
-
|
|
830
|
+
if (this.client) {
|
|
831
|
+
return ++this.client.getCollabWindow().localSeq;
|
|
832
|
+
}
|
|
833
|
+
return 0;
|
|
818
834
|
}
|
|
819
835
|
getIntervalById(id) {
|
|
820
836
|
if (!this.attached) {
|
|
@@ -1050,9 +1066,19 @@ class IntervalCollection extends common_utils_1.TypedEventEmitter {
|
|
|
1050
1066
|
onDeserialize(interval);
|
|
1051
1067
|
});
|
|
1052
1068
|
}
|
|
1053
|
-
/**
|
|
1069
|
+
/**
|
|
1070
|
+
* @internal
|
|
1071
|
+
*
|
|
1072
|
+
* Returns new interval after rebasing. If undefined, the interval was
|
|
1073
|
+
* deleted as a result of rebasing. This can occur if the interval applies
|
|
1074
|
+
* to a range that no longer exists, and the interval was unable to slide.
|
|
1075
|
+
*/
|
|
1054
1076
|
rebaseLocalInterval(opName, serializedInterval, localSeq) {
|
|
1055
1077
|
var _a, _b;
|
|
1078
|
+
if (!this.client) {
|
|
1079
|
+
// If there's no associated mergeTree client, the originally submitted op is still correct.
|
|
1080
|
+
return serializedInterval;
|
|
1081
|
+
}
|
|
1056
1082
|
if (!this.attached) {
|
|
1057
1083
|
throw new telemetry_utils_1.LoggingError("attachSequence must be called");
|
|
1058
1084
|
}
|
|
@@ -1062,6 +1088,7 @@ class IntervalCollection extends common_utils_1.TypedEventEmitter {
|
|
|
1062
1088
|
const endRebased = end === undefined ? undefined :
|
|
1063
1089
|
this.client.rebasePosition(end, sequenceNumber, localSeq);
|
|
1064
1090
|
const intervalId = properties === null || properties === void 0 ? void 0 : properties[reservedIntervalIdKey];
|
|
1091
|
+
const localInterval = this.localCollection.getIntervalById(intervalId);
|
|
1065
1092
|
const rebased = {
|
|
1066
1093
|
start: startRebased,
|
|
1067
1094
|
end: endRebased,
|
|
@@ -1073,6 +1100,27 @@ class IntervalCollection extends common_utils_1.TypedEventEmitter {
|
|
|
1073
1100
|
this.removePendingChange(serializedInterval);
|
|
1074
1101
|
this.addPendingChange(intervalId, rebased);
|
|
1075
1102
|
}
|
|
1103
|
+
// if the interval slid off the string, rebase the op to be a noop and
|
|
1104
|
+
// delete the interval
|
|
1105
|
+
if (startRebased === merge_tree_1.DetachedReferencePosition || endRebased === merge_tree_1.DetachedReferencePosition) {
|
|
1106
|
+
if (localInterval) {
|
|
1107
|
+
this.localCollection.removeExistingInterval(localInterval);
|
|
1108
|
+
}
|
|
1109
|
+
return undefined;
|
|
1110
|
+
}
|
|
1111
|
+
if (!localInterval) {
|
|
1112
|
+
return rebased;
|
|
1113
|
+
}
|
|
1114
|
+
// we know we must be using `SequenceInterval` because `this.client` exists
|
|
1115
|
+
(0, common_utils_1.assert)(localInterval instanceof SequenceInterval, 0x3a0 /* localInterval must be `SequenceInterval` when used with client */);
|
|
1116
|
+
const startSegment = this.getSlideToSegment(localInterval.start);
|
|
1117
|
+
const endSegment = this.getSlideToSegment(localInterval.end);
|
|
1118
|
+
// we need to slide because the reference has been removed
|
|
1119
|
+
if (startSegment || endSegment) {
|
|
1120
|
+
const newStart = startSegment && this.client.getPosition(startSegment.segment, localSeq) + startSegment.offset;
|
|
1121
|
+
const newEnd = endSegment && this.client.getPosition(endSegment.segment, localSeq) + endSegment.offset;
|
|
1122
|
+
this.localCollection.changeInterval(localInterval, newStart, newEnd, undefined, localSeq);
|
|
1123
|
+
}
|
|
1076
1124
|
return rebased;
|
|
1077
1125
|
}
|
|
1078
1126
|
getSlideToSegment(lref) {
|
|
@@ -1088,7 +1136,7 @@ class IntervalCollection extends common_utils_1.TypedEventEmitter {
|
|
|
1088
1136
|
lref.refType = refType;
|
|
1089
1137
|
}
|
|
1090
1138
|
ackInterval(interval, op) {
|
|
1091
|
-
//
|
|
1139
|
+
// Only SequenceIntervals need potential sliding
|
|
1092
1140
|
if (!(interval instanceof SequenceInterval)) {
|
|
1093
1141
|
return;
|
|
1094
1142
|
}
|
|
@@ -1235,4 +1283,16 @@ class IntervalCollection extends common_utils_1.TypedEventEmitter {
|
|
|
1235
1283
|
}
|
|
1236
1284
|
}
|
|
1237
1285
|
exports.IntervalCollection = IntervalCollection;
|
|
1286
|
+
/**
|
|
1287
|
+
* Returns an object that can be used to find the interval a given LocalReferencePosition belongs to.
|
|
1288
|
+
* @returns undefined if the reference position is not the endpoint of any interval (e.g. it was created
|
|
1289
|
+
* on the merge tree directly by app code), otherwise an {@link IntervalLocator} for the interval this
|
|
1290
|
+
* endpoint is a part of.
|
|
1291
|
+
*/
|
|
1292
|
+
function intervalLocatorFromEndpoint(potentialEndpoint) {
|
|
1293
|
+
var _a;
|
|
1294
|
+
const { interval, [merge_tree_1.reservedRangeLabelsKey]: collectionNameArray, } = (_a = potentialEndpoint.properties) !== null && _a !== void 0 ? _a : {};
|
|
1295
|
+
return (interval && (collectionNameArray === null || collectionNameArray === void 0 ? void 0 : collectionNameArray.length) === 1) ? { label: collectionNameArray[0], interval } : undefined;
|
|
1296
|
+
}
|
|
1297
|
+
exports.intervalLocatorFromEndpoint = intervalLocatorFromEndpoint;
|
|
1238
1298
|
//# sourceMappingURL=intervalCollection.js.map
|