@fluidframework/sequence 1.2.7 → 2.0.0-dev.1.3.0.96595
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/README.md +19 -18
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -2
- package/dist/index.js.map +1 -1
- package/dist/intervalCollection.d.ts +39 -17
- package/dist/intervalCollection.d.ts.map +1 -1
- package/dist/intervalCollection.js +108 -67
- 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 +13 -22
- package/dist/sequence.d.ts.map +1 -1
- package/dist/sequence.js +11 -32
- package/dist/sequence.js.map +1 -1
- package/dist/sequenceDeltaEvent.d.ts +0 -6
- package/dist/sequenceDeltaEvent.d.ts.map +1 -1
- package/dist/sequenceDeltaEvent.js +0 -1
- package/dist/sequenceDeltaEvent.js.map +1 -1
- package/dist/sharedIntervalCollection.d.ts +5 -5
- package/dist/sharedIntervalCollection.js +5 -5
- package/dist/sharedIntervalCollection.js.map +1 -1
- package/dist/sharedString.d.ts +30 -1
- package/dist/sharedString.d.ts.map +1 -1
- package/dist/sharedString.js +40 -5
- package/dist/sharedString.js.map +1 -1
- package/dist/sparsematrix.d.ts +28 -15
- package/dist/sparsematrix.d.ts.map +1 -1
- package/dist/sparsematrix.js +24 -13
- package/dist/sparsematrix.js.map +1 -1
- package/lib/index.d.ts +2 -2
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +2 -2
- package/lib/index.js.map +1 -1
- package/lib/intervalCollection.d.ts +39 -17
- package/lib/intervalCollection.d.ts.map +1 -1
- package/lib/intervalCollection.js +107 -67
- 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 +13 -22
- package/lib/sequence.d.ts.map +1 -1
- package/lib/sequence.js +12 -33
- package/lib/sequence.js.map +1 -1
- package/lib/sequenceDeltaEvent.d.ts +0 -6
- package/lib/sequenceDeltaEvent.d.ts.map +1 -1
- package/lib/sequenceDeltaEvent.js +0 -1
- package/lib/sequenceDeltaEvent.js.map +1 -1
- package/lib/sharedIntervalCollection.d.ts +5 -5
- package/lib/sharedIntervalCollection.js +5 -5
- package/lib/sharedIntervalCollection.js.map +1 -1
- package/lib/sharedString.d.ts +30 -1
- package/lib/sharedString.d.ts.map +1 -1
- package/lib/sharedString.js +38 -4
- package/lib/sharedString.js.map +1 -1
- package/lib/sparsematrix.d.ts +28 -15
- package/lib/sparsematrix.d.ts.map +1 -1
- package/lib/sparsematrix.js +24 -13
- package/lib/sparsematrix.js.map +1 -1
- package/package.json +70 -25
- package/src/index.ts +3 -1
- package/src/intervalCollection.ts +169 -85
- package/src/packageVersion.ts +1 -1
- package/src/sequence.ts +12 -41
- package/src/sequenceDeltaEvent.ts +0 -7
- package/src/sharedIntervalCollection.ts +5 -5
- package/src/sharedString.ts +44 -6
- package/src/sparsematrix.ts +48 -35
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import { TypedEventEmitter } from "@fluidframework/common-utils";
|
|
6
6
|
import { IEvent } from "@fluidframework/common-definitions";
|
|
7
|
-
import { Client, ICombiningOp, IInterval, IntervalConflictResolver,
|
|
7
|
+
import { Client, ICombiningOp, IInterval, IntervalConflictResolver, PropertiesManager, PropertySet, LocalReferencePosition } from "@fluidframework/merge-tree";
|
|
8
8
|
import { ISequencedDocumentMessage } from "@fluidframework/protocol-definitions";
|
|
9
9
|
import { IValueFactory, IValueOpEmitter, IValueOperation, IValueType } from "./defaultMapInterfaces";
|
|
10
10
|
export declare enum IntervalType {
|
|
@@ -18,8 +18,8 @@ export declare enum IntervalType {
|
|
|
18
18
|
*/
|
|
19
19
|
SlideOnRemove = 2,
|
|
20
20
|
/**
|
|
21
|
-
* @internal
|
|
22
21
|
* A temporary interval, used internally
|
|
22
|
+
* @internal
|
|
23
23
|
*/
|
|
24
24
|
Transient = 4
|
|
25
25
|
}
|
|
@@ -90,21 +90,22 @@ export declare class Interval implements ISerializableInterval {
|
|
|
90
90
|
private initializeProperties;
|
|
91
91
|
}
|
|
92
92
|
export declare class SequenceInterval implements ISerializableInterval {
|
|
93
|
-
|
|
94
|
-
|
|
93
|
+
private readonly client;
|
|
94
|
+
start: LocalReferencePosition;
|
|
95
|
+
end: LocalReferencePosition;
|
|
95
96
|
intervalType: IntervalType;
|
|
96
97
|
properties: PropertySet;
|
|
97
98
|
propertyManager: PropertiesManager;
|
|
98
|
-
constructor(start:
|
|
99
|
+
constructor(client: Client, start: LocalReferencePosition, end: LocalReferencePosition, intervalType: IntervalType, props?: PropertySet);
|
|
99
100
|
private callbacks?;
|
|
100
101
|
/**
|
|
101
|
-
* @internal
|
|
102
102
|
* Subscribes to position change events on this interval if there are no current listeners.
|
|
103
|
+
* @internal
|
|
103
104
|
*/
|
|
104
105
|
addPositionChangeListeners(beforePositionChange: () => void, afterPositionChange: () => void): void;
|
|
105
106
|
/**
|
|
106
|
-
* @internal
|
|
107
107
|
* Removes the currently subscribed position change listeners.
|
|
108
|
+
* @internal
|
|
108
109
|
*/
|
|
109
110
|
removePositionChangeListeners(): void;
|
|
110
111
|
serialize(client: Client): ISerializedInterval;
|
|
@@ -117,7 +118,7 @@ export declare class SequenceInterval implements ISerializableInterval {
|
|
|
117
118
|
union(b: SequenceInterval): SequenceInterval;
|
|
118
119
|
addProperties(newProps: PropertySet, collab?: boolean, seq?: number, op?: ICombiningOp): PropertySet | undefined;
|
|
119
120
|
overlapsPos(bstart: number, bend: number): boolean;
|
|
120
|
-
modify(label: string, start: number, end: number, op?: ISequencedDocumentMessage): SequenceInterval;
|
|
121
|
+
modify(label: string, start: number, end: number, op?: ISequencedDocumentMessage, localSeq?: number): SequenceInterval;
|
|
121
122
|
private initializeProperties;
|
|
122
123
|
}
|
|
123
124
|
export declare function defaultIntervalConflictResolver(a: Interval, b: Interval): Interval;
|
|
@@ -158,10 +159,11 @@ export declare class LocalIntervalCollection<TInterval extends ISerializableInte
|
|
|
158
159
|
removeExistingInterval(interval: TInterval): void;
|
|
159
160
|
createInterval(start: number, end: number, intervalType: IntervalType, op?: ISequencedDocumentMessage): TInterval;
|
|
160
161
|
addInterval(start: number, end: number, intervalType: IntervalType, props?: PropertySet, op?: ISequencedDocumentMessage): TInterval;
|
|
162
|
+
private linkEndpointsToInterval;
|
|
161
163
|
private addIntervalToIndex;
|
|
162
164
|
add(interval: TInterval): void;
|
|
163
165
|
getIntervalById(id: string): TInterval;
|
|
164
|
-
changeInterval(interval: TInterval, start: number, end: number, op?: ISequencedDocumentMessage): TInterval;
|
|
166
|
+
changeInterval(interval: TInterval, start: number, end: number, op?: ISequencedDocumentMessage, localSeq?: number): TInterval;
|
|
165
167
|
serialize(): ISerializedIntervalCollectionV2;
|
|
166
168
|
private addIntervalListeners;
|
|
167
169
|
private removeIntervalListeners;
|
|
@@ -244,23 +246,23 @@ export declare class IntervalCollection<TInterval extends ISerializableInterval>
|
|
|
244
246
|
private removePendingChangeHelper;
|
|
245
247
|
private hasPendingChangeStart;
|
|
246
248
|
private hasPendingChangeEnd;
|
|
247
|
-
/** @deprecated - use ackChange */
|
|
248
|
-
changeInterval(serializedInterval: ISerializedInterval, local: boolean, op: ISequencedDocumentMessage): void;
|
|
249
249
|
/** @internal */
|
|
250
250
|
ackChange(serializedInterval: ISerializedInterval, local: boolean, op: ISequencedDocumentMessage): void;
|
|
251
251
|
addConflictResolver(conflictResolver: IntervalConflictResolver<TInterval>): void;
|
|
252
252
|
attachDeserializer(onDeserialize: DeserializeCallback): void;
|
|
253
|
-
/**
|
|
254
|
-
|
|
253
|
+
/**
|
|
254
|
+
* Returns new interval after rebasing. If undefined, the interval was
|
|
255
|
+
* deleted as a result of rebasing. This can occur if the interval applies
|
|
256
|
+
* to a range that no longer exists, and the interval was unable to slide.
|
|
257
|
+
*
|
|
258
|
+
* @internal
|
|
259
|
+
*/
|
|
260
|
+
rebaseLocalInterval(opName: string, serializedInterval: ISerializedInterval, localSeq: number): ISerializedInterval | undefined;
|
|
255
261
|
private getSlideToSegment;
|
|
256
262
|
private setSlideOnRemove;
|
|
257
263
|
private ackInterval;
|
|
258
|
-
/** @deprecated - use ackAdd */
|
|
259
|
-
addInternal(serializedInterval: ISerializedInterval, local: boolean, op: ISequencedDocumentMessage): TInterval;
|
|
260
264
|
/** @internal */
|
|
261
265
|
ackAdd(serializedInterval: ISerializedInterval, local: boolean, op: ISequencedDocumentMessage): TInterval;
|
|
262
|
-
/** @deprecated - use ackDelete */
|
|
263
|
-
deleteInterval(serializedInterval: ISerializedInterval, local: boolean, op: ISequencedDocumentMessage): void;
|
|
264
266
|
/** @internal */
|
|
265
267
|
ackDelete(serializedInterval: ISerializedInterval, local: boolean, op: ISequencedDocumentMessage): void;
|
|
266
268
|
/**
|
|
@@ -278,4 +280,24 @@ export declare class IntervalCollection<TInterval extends ISerializableInterval>
|
|
|
278
280
|
previousInterval(pos: number): TInterval;
|
|
279
281
|
nextInterval(pos: number): TInterval;
|
|
280
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;
|
|
281
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,
|
|
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,EAQzB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,yBAAyB,EAAE,MAAM,sCAAsC,CAAC;AAGjF,OAAO,EAEH,aAAa,EACb,eAAe,EACf,eAAe,EACf,UAAU,EAEb,MAAM,wBAAwB,CAAC;AAIhC,oBAAY,YAAY;IACpB,MAAM,IAAM;IACZ,IAAI,IAAM;IAEV;;;;;OAKG;IACH,aAAa,IAAM;IAEnB;;;OAGG;IACH,SAAS,IAAM;CAClB;AAED,MAAM,WAAW,mBAAmB;IAChC,cAAc,EAAE,MAAM,CAAC;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,YAAY,EAAE,YAAY,CAAC;IAC3B,UAAU,CAAC,EAAE,WAAW,CAAC;CAC5B;AAED;;;;;GAKG;AACH,oBAAY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9C;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"}
|
|
@@ -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,
|
|
19
|
+
import { addProperties, compareReferencePositions, createMap, IntervalTree, MergeTreeDeltaType, minReferencePosition, PropertiesManager, RedBlackTree, ReferenceType, refTypeIncludesFlag, reservedRangeLabelsKey, UnassignedSequenceNumber, maxReferencePosition, createDetachedLocalReferencePosition, DetachedReferencePosition, } 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";
|
|
@@ -32,8 +32,8 @@ export var IntervalType;
|
|
|
32
32
|
*/
|
|
33
33
|
IntervalType[IntervalType["SlideOnRemove"] = 2] = "SlideOnRemove";
|
|
34
34
|
/**
|
|
35
|
-
* @internal
|
|
36
35
|
* A temporary interval, used internally
|
|
36
|
+
* @internal
|
|
37
37
|
*/
|
|
38
38
|
IntervalType[IntervalType["Transient"] = 4] = "Transient";
|
|
39
39
|
})(IntervalType || (IntervalType = {}));
|
|
@@ -47,7 +47,7 @@ function decompressInterval(interval, label) {
|
|
|
47
47
|
end: interval[1],
|
|
48
48
|
sequenceNumber: interval[2],
|
|
49
49
|
intervalType: interval[3],
|
|
50
|
-
properties: Object.assign(Object.assign({}, interval[4]), { [reservedRangeLabelsKey]: label }),
|
|
50
|
+
properties: Object.assign(Object.assign({}, interval[4]), { [reservedRangeLabelsKey]: [label] }),
|
|
51
51
|
};
|
|
52
52
|
}
|
|
53
53
|
/**
|
|
@@ -92,10 +92,8 @@ export class Interval {
|
|
|
92
92
|
this.auxProps.push(props);
|
|
93
93
|
}
|
|
94
94
|
serialize(client) {
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
seq = client.getCurrentSeq();
|
|
98
|
-
}
|
|
95
|
+
var _a;
|
|
96
|
+
const seq = (_a = client === null || client === void 0 ? void 0 : client.getCurrentSeq()) !== null && _a !== void 0 ? _a : 0;
|
|
99
97
|
const serializedInterval = {
|
|
100
98
|
end: this.end,
|
|
101
99
|
intervalType: 0,
|
|
@@ -180,7 +178,8 @@ export class Interval {
|
|
|
180
178
|
}
|
|
181
179
|
}
|
|
182
180
|
export class SequenceInterval {
|
|
183
|
-
constructor(start, end, intervalType, props) {
|
|
181
|
+
constructor(client, start, end, intervalType, props) {
|
|
182
|
+
this.client = client;
|
|
184
183
|
this.start = start;
|
|
185
184
|
this.end = end;
|
|
186
185
|
this.intervalType = intervalType;
|
|
@@ -191,8 +190,8 @@ export class SequenceInterval {
|
|
|
191
190
|
}
|
|
192
191
|
}
|
|
193
192
|
/**
|
|
194
|
-
* @internal
|
|
195
193
|
* Subscribes to position change events on this interval if there are no current listeners.
|
|
194
|
+
* @internal
|
|
196
195
|
*/
|
|
197
196
|
addPositionChangeListeners(beforePositionChange, afterPositionChange) {
|
|
198
197
|
var _a, _b;
|
|
@@ -209,8 +208,8 @@ export class SequenceInterval {
|
|
|
209
208
|
}
|
|
210
209
|
}
|
|
211
210
|
/**
|
|
212
|
-
* @internal
|
|
213
211
|
* Removes the currently subscribed position change listeners.
|
|
212
|
+
* @internal
|
|
214
213
|
*/
|
|
215
214
|
removePositionChangeListeners() {
|
|
216
215
|
if (this.callbacks) {
|
|
@@ -220,8 +219,8 @@ export class SequenceInterval {
|
|
|
220
219
|
}
|
|
221
220
|
}
|
|
222
221
|
serialize(client) {
|
|
223
|
-
const startPosition = this.start
|
|
224
|
-
const endPosition = this.end
|
|
222
|
+
const startPosition = client.localReferencePositionToPosition(this.start);
|
|
223
|
+
const endPosition = client.localReferencePositionToPosition(this.end);
|
|
225
224
|
const serializedInterval = {
|
|
226
225
|
end: endPosition,
|
|
227
226
|
intervalType: this.intervalType,
|
|
@@ -234,7 +233,7 @@ export class SequenceInterval {
|
|
|
234
233
|
return serializedInterval;
|
|
235
234
|
}
|
|
236
235
|
clone() {
|
|
237
|
-
return new SequenceInterval(this.start, this.end, this.intervalType, this.properties);
|
|
236
|
+
return new SequenceInterval(this.client, this.start, this.end, this.intervalType, this.properties);
|
|
238
237
|
}
|
|
239
238
|
compare(b) {
|
|
240
239
|
const startResult = this.compareStart(b);
|
|
@@ -260,14 +259,14 @@ export class SequenceInterval {
|
|
|
260
259
|
}
|
|
261
260
|
}
|
|
262
261
|
compareStart(b) {
|
|
263
|
-
return this.start
|
|
262
|
+
return compareReferencePositions(this.start, b.start);
|
|
264
263
|
}
|
|
265
264
|
compareEnd(b) {
|
|
266
|
-
return this.end
|
|
265
|
+
return compareReferencePositions(this.end, b.end);
|
|
267
266
|
}
|
|
268
267
|
overlaps(b) {
|
|
269
|
-
const result = (this.start
|
|
270
|
-
(this.end
|
|
268
|
+
const result = (compareReferencePositions(this.start, b.end) <= 0) &&
|
|
269
|
+
(compareReferencePositions(this.end, b.start) >= 0);
|
|
271
270
|
return result;
|
|
272
271
|
}
|
|
273
272
|
getIntervalId() {
|
|
@@ -279,18 +278,18 @@ export class SequenceInterval {
|
|
|
279
278
|
return `${id}`;
|
|
280
279
|
}
|
|
281
280
|
union(b) {
|
|
282
|
-
return new SequenceInterval(this.start
|
|
281
|
+
return new SequenceInterval(this.client, minReferencePosition(this.start, b.start), maxReferencePosition(this.end, b.end), this.intervalType);
|
|
283
282
|
}
|
|
284
283
|
addProperties(newProps, collab = false, seq, op) {
|
|
285
284
|
this.initializeProperties();
|
|
286
285
|
return this.propertyManager.addProperties(this.properties, newProps, op, seq, collab);
|
|
287
286
|
}
|
|
288
287
|
overlapsPos(bstart, bend) {
|
|
289
|
-
const startPos = this.
|
|
290
|
-
const endPos = this.
|
|
288
|
+
const startPos = this.client.localReferencePositionToPosition(this.start);
|
|
289
|
+
const endPos = this.client.localReferencePositionToPosition(this.end);
|
|
291
290
|
return (endPos > bstart) && (startPos < bend);
|
|
292
291
|
}
|
|
293
|
-
modify(label, start, end, op) {
|
|
292
|
+
modify(label, start, end, op, localSeq) {
|
|
294
293
|
const getRefType = (baseType) => {
|
|
295
294
|
let refType = baseType;
|
|
296
295
|
if (op === undefined) {
|
|
@@ -301,17 +300,15 @@ export class SequenceInterval {
|
|
|
301
300
|
};
|
|
302
301
|
let startRef = this.start;
|
|
303
302
|
if (start !== undefined) {
|
|
304
|
-
startRef = createPositionReference(this.
|
|
303
|
+
startRef = createPositionReference(this.client, start, getRefType(this.start.refType), op, undefined, localSeq);
|
|
305
304
|
startRef.addProperties(this.start.properties);
|
|
306
305
|
}
|
|
307
306
|
let endRef = this.end;
|
|
308
307
|
if (end !== undefined) {
|
|
309
|
-
endRef = createPositionReference(this.
|
|
308
|
+
endRef = createPositionReference(this.client, end, getRefType(this.end.refType), op, undefined, localSeq);
|
|
310
309
|
endRef.addProperties(this.end.properties);
|
|
311
310
|
}
|
|
312
|
-
|
|
313
|
-
endRef.pairedRef = startRef;
|
|
314
|
-
const newInterval = new SequenceInterval(startRef, endRef, this.intervalType);
|
|
311
|
+
const newInterval = new SequenceInterval(this.client, startRef, endRef, this.intervalType);
|
|
315
312
|
if (this.properties) {
|
|
316
313
|
newInterval.initializeProperties();
|
|
317
314
|
this.propertyManager.copyTo(this.properties, newInterval.properties, newInterval.propertyManager);
|
|
@@ -332,14 +329,13 @@ function createPositionReferenceFromSegoff(client, segoff, refType, op) {
|
|
|
332
329
|
const ref = client.createLocalReferencePosition(segoff.segment, segoff.offset, refType, undefined);
|
|
333
330
|
return ref;
|
|
334
331
|
}
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
}
|
|
339
|
-
return new LocalReference(client, undefined, 0, refType);
|
|
332
|
+
if (!op && !refTypeIncludesFlag(refType, ReferenceType.Transient)) {
|
|
333
|
+
// reference to segment that dne locally
|
|
334
|
+
throw new UsageError("Non-transient references need segment");
|
|
340
335
|
}
|
|
336
|
+
return createDetachedLocalReferencePosition(refType);
|
|
341
337
|
}
|
|
342
|
-
function createPositionReference(client, pos, refType, op, fromSnapshot) {
|
|
338
|
+
function createPositionReference(client, pos, refType, op, fromSnapshot, localSeq) {
|
|
343
339
|
let segoff;
|
|
344
340
|
if (op) {
|
|
345
341
|
assert((refType & ReferenceType.SlideOnRemove) !== 0, 0x2f5 /* op create references must be SlideOnRemove */);
|
|
@@ -348,7 +344,7 @@ function createPositionReference(client, pos, refType, op, fromSnapshot) {
|
|
|
348
344
|
}
|
|
349
345
|
else {
|
|
350
346
|
assert((refType & ReferenceType.SlideOnRemove) === 0 || fromSnapshot, 0x2f6 /* SlideOnRemove references must be op created */);
|
|
351
|
-
segoff = client.getContainingSegment(pos);
|
|
347
|
+
segoff = client.getContainingSegment(pos, undefined, localSeq);
|
|
352
348
|
}
|
|
353
349
|
return createPositionReferenceFromSegoff(client, segoff, refType, op);
|
|
354
350
|
}
|
|
@@ -378,14 +374,12 @@ function createSequenceInterval(label, start, end, client, intervalType, op, fro
|
|
|
378
374
|
}
|
|
379
375
|
const startLref = createPositionReference(client, start, beginRefType, op, fromSnapshot);
|
|
380
376
|
const endLref = createPositionReference(client, end, endRefType, op, fromSnapshot);
|
|
381
|
-
startLref.pairedRef = endLref;
|
|
382
|
-
endLref.pairedRef = startLref;
|
|
383
377
|
const rangeProp = {
|
|
384
378
|
[reservedRangeLabelsKey]: [label],
|
|
385
379
|
};
|
|
386
380
|
startLref.addProperties(rangeProp);
|
|
387
381
|
endLref.addProperties(rangeProp);
|
|
388
|
-
const ival = new SequenceInterval(startLref, endLref, intervalType, rangeProp);
|
|
382
|
+
const ival = new SequenceInterval(client, startLref, endLref, intervalType, rangeProp);
|
|
389
383
|
return ival;
|
|
390
384
|
}
|
|
391
385
|
export function defaultIntervalConflictResolver(a, b) {
|
|
@@ -572,6 +566,8 @@ export class LocalIntervalCollection {
|
|
|
572
566
|
return this.helpers.create(this.label, start, end, this.client, intervalType, op);
|
|
573
567
|
}
|
|
574
568
|
addInterval(start, end, intervalType, props, op) {
|
|
569
|
+
var _a;
|
|
570
|
+
var _b;
|
|
575
571
|
const interval = this.createInterval(start, end, intervalType, op);
|
|
576
572
|
if (interval) {
|
|
577
573
|
if (!interval.properties) {
|
|
@@ -580,14 +576,17 @@ export class LocalIntervalCollection {
|
|
|
580
576
|
if (props) {
|
|
581
577
|
interval.addProperties(props);
|
|
582
578
|
}
|
|
583
|
-
|
|
584
|
-
// Create a new ID.
|
|
585
|
-
interval.properties[reservedIntervalIdKey] = uuid();
|
|
586
|
-
}
|
|
579
|
+
(_a = (_b = interval.properties)[reservedIntervalIdKey]) !== null && _a !== void 0 ? _a : (_b[reservedIntervalIdKey] = uuid());
|
|
587
580
|
this.add(interval);
|
|
588
581
|
}
|
|
589
582
|
return interval;
|
|
590
583
|
}
|
|
584
|
+
linkEndpointsToInterval(interval) {
|
|
585
|
+
if (interval instanceof SequenceInterval) {
|
|
586
|
+
interval.start.addProperties({ interval });
|
|
587
|
+
interval.end.addProperties({ interval });
|
|
588
|
+
}
|
|
589
|
+
}
|
|
591
590
|
addIntervalToIndex(interval) {
|
|
592
591
|
const id = interval.getIntervalId();
|
|
593
592
|
assert(id !== undefined, 0x2c0 /* "ID must be created before adding interval to collection" */);
|
|
@@ -602,14 +601,15 @@ export class LocalIntervalCollection {
|
|
|
602
601
|
this.intervalIdMap.set(id, interval);
|
|
603
602
|
}
|
|
604
603
|
add(interval) {
|
|
604
|
+
this.linkEndpointsToInterval(interval);
|
|
605
605
|
this.addIntervalToIndex(interval);
|
|
606
606
|
this.addIntervalListeners(interval);
|
|
607
607
|
}
|
|
608
608
|
getIntervalById(id) {
|
|
609
609
|
return this.intervalIdMap.get(id);
|
|
610
610
|
}
|
|
611
|
-
changeInterval(interval, start, end, op) {
|
|
612
|
-
const newInterval = interval.modify(this.label, start, end, op);
|
|
611
|
+
changeInterval(interval, start, end, op, localSeq) {
|
|
612
|
+
const newInterval = interval.modify(this.label, start, end, op, localSeq);
|
|
613
613
|
if (newInterval) {
|
|
614
614
|
this.removeExistingInterval(interval);
|
|
615
615
|
this.add(newInterval);
|
|
@@ -641,7 +641,7 @@ export class LocalIntervalCollection {
|
|
|
641
641
|
}
|
|
642
642
|
}
|
|
643
643
|
LocalIntervalCollection.legacyIdPrefix = "legacy";
|
|
644
|
-
const compareSequenceIntervalEnds = (a, b) => a.end
|
|
644
|
+
const compareSequenceIntervalEnds = (a, b) => compareReferencePositions(a.end, b.end);
|
|
645
645
|
class SequenceIntervalCollectionFactory {
|
|
646
646
|
load(emitter, raw = []) {
|
|
647
647
|
const helpers = {
|
|
@@ -715,6 +715,11 @@ function makeOpsMap() {
|
|
|
715
715
|
"add",
|
|
716
716
|
{
|
|
717
717
|
process: (collection, params, local, op) => {
|
|
718
|
+
// if params is undefined, the interval was deleted during
|
|
719
|
+
// rebasing
|
|
720
|
+
if (!params) {
|
|
721
|
+
return;
|
|
722
|
+
}
|
|
718
723
|
collection.ackAdd(params, local, op);
|
|
719
724
|
},
|
|
720
725
|
rebase,
|
|
@@ -736,6 +741,11 @@ function makeOpsMap() {
|
|
|
736
741
|
"change",
|
|
737
742
|
{
|
|
738
743
|
process: (collection, params, local, op) => {
|
|
744
|
+
// if params is undefined, the interval was deleted during
|
|
745
|
+
// rebasing
|
|
746
|
+
if (!params) {
|
|
747
|
+
return;
|
|
748
|
+
}
|
|
739
749
|
collection.ackChange(params, local, op);
|
|
740
750
|
},
|
|
741
751
|
rebase,
|
|
@@ -770,13 +780,9 @@ export class IntervalCollection extends TypedEventEmitter {
|
|
|
770
780
|
this.emitter = emitter;
|
|
771
781
|
this.pendingChangesStart = new Map();
|
|
772
782
|
this.pendingChangesEnd = new Map();
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
else {
|
|
777
|
-
this.savedSerializedIntervals =
|
|
778
|
-
serializedIntervals.intervals.map((i) => decompressInterval(i, serializedIntervals.label));
|
|
779
|
-
}
|
|
783
|
+
this.savedSerializedIntervals = Array.isArray(serializedIntervals)
|
|
784
|
+
? serializedIntervals
|
|
785
|
+
: serializedIntervals.intervals.map((i) => decompressInterval(i, serializedIntervals.label));
|
|
780
786
|
}
|
|
781
787
|
get attached() {
|
|
782
788
|
return !!this.localCollection;
|
|
@@ -806,7 +812,10 @@ export class IntervalCollection extends TypedEventEmitter {
|
|
|
806
812
|
* Gets the next local sequence number, modifying this client's collab window in doing so.
|
|
807
813
|
*/
|
|
808
814
|
getNextLocalSeq() {
|
|
809
|
-
|
|
815
|
+
if (this.client) {
|
|
816
|
+
return ++this.client.getCollabWindow().localSeq;
|
|
817
|
+
}
|
|
818
|
+
return 0;
|
|
810
819
|
}
|
|
811
820
|
getIntervalById(id) {
|
|
812
821
|
if (!this.attached) {
|
|
@@ -969,10 +978,6 @@ export class IntervalCollection extends TypedEventEmitter {
|
|
|
969
978
|
const entries = this.pendingChangesEnd.get(id);
|
|
970
979
|
return entries && entries.length !== 0;
|
|
971
980
|
}
|
|
972
|
-
/** @deprecated - use ackChange */
|
|
973
|
-
changeInterval(serializedInterval, local, op) {
|
|
974
|
-
return this.ackChange(serializedInterval, local, op);
|
|
975
|
-
}
|
|
976
981
|
/** @internal */
|
|
977
982
|
ackChange(serializedInterval, local, op) {
|
|
978
983
|
var _a, _b, _c, _d;
|
|
@@ -1046,9 +1051,19 @@ export class IntervalCollection extends TypedEventEmitter {
|
|
|
1046
1051
|
onDeserialize(interval);
|
|
1047
1052
|
});
|
|
1048
1053
|
}
|
|
1049
|
-
/**
|
|
1054
|
+
/**
|
|
1055
|
+
* Returns new interval after rebasing. If undefined, the interval was
|
|
1056
|
+
* deleted as a result of rebasing. This can occur if the interval applies
|
|
1057
|
+
* to a range that no longer exists, and the interval was unable to slide.
|
|
1058
|
+
*
|
|
1059
|
+
* @internal
|
|
1060
|
+
*/
|
|
1050
1061
|
rebaseLocalInterval(opName, serializedInterval, localSeq) {
|
|
1051
1062
|
var _a, _b;
|
|
1063
|
+
if (!this.client) {
|
|
1064
|
+
// If there's no associated mergeTree client, the originally submitted op is still correct.
|
|
1065
|
+
return serializedInterval;
|
|
1066
|
+
}
|
|
1052
1067
|
if (!this.attached) {
|
|
1053
1068
|
throw new LoggingError("attachSequence must be called");
|
|
1054
1069
|
}
|
|
@@ -1058,6 +1073,7 @@ export class IntervalCollection extends TypedEventEmitter {
|
|
|
1058
1073
|
const endRebased = end === undefined ? undefined :
|
|
1059
1074
|
this.client.rebasePosition(end, sequenceNumber, localSeq);
|
|
1060
1075
|
const intervalId = properties === null || properties === void 0 ? void 0 : properties[reservedIntervalIdKey];
|
|
1076
|
+
const localInterval = this.localCollection.getIntervalById(intervalId);
|
|
1061
1077
|
const rebased = {
|
|
1062
1078
|
start: startRebased,
|
|
1063
1079
|
end: endRebased,
|
|
@@ -1069,10 +1085,31 @@ export class IntervalCollection extends TypedEventEmitter {
|
|
|
1069
1085
|
this.removePendingChange(serializedInterval);
|
|
1070
1086
|
this.addPendingChange(intervalId, rebased);
|
|
1071
1087
|
}
|
|
1088
|
+
// if the interval slid off the string, rebase the op to be a noop and
|
|
1089
|
+
// delete the interval
|
|
1090
|
+
if (startRebased === DetachedReferencePosition || endRebased === DetachedReferencePosition) {
|
|
1091
|
+
if (localInterval) {
|
|
1092
|
+
this.localCollection.removeExistingInterval(localInterval);
|
|
1093
|
+
}
|
|
1094
|
+
return undefined;
|
|
1095
|
+
}
|
|
1096
|
+
if (!localInterval) {
|
|
1097
|
+
return rebased;
|
|
1098
|
+
}
|
|
1099
|
+
// we know we must be using `SequenceInterval` because `this.client` exists
|
|
1100
|
+
assert(localInterval instanceof SequenceInterval, 0x3a0 /* localInterval must be `SequenceInterval` when used with client */);
|
|
1101
|
+
const startSegment = this.getSlideToSegment(localInterval.start);
|
|
1102
|
+
const endSegment = this.getSlideToSegment(localInterval.end);
|
|
1103
|
+
// we need to slide because the reference has been removed
|
|
1104
|
+
if (startSegment || endSegment) {
|
|
1105
|
+
const newStart = startSegment && this.client.getPosition(startSegment.segment, localSeq) + startSegment.offset;
|
|
1106
|
+
const newEnd = endSegment && this.client.getPosition(endSegment.segment, localSeq) + endSegment.offset;
|
|
1107
|
+
this.localCollection.changeInterval(localInterval, newStart, newEnd, undefined, localSeq);
|
|
1108
|
+
}
|
|
1072
1109
|
return rebased;
|
|
1073
1110
|
}
|
|
1074
1111
|
getSlideToSegment(lref) {
|
|
1075
|
-
const segoff = { segment: lref.
|
|
1112
|
+
const segoff = { segment: lref.getSegment(), offset: lref.getOffset() };
|
|
1076
1113
|
const newSegoff = this.client.getSlideToSegment(segoff);
|
|
1077
1114
|
const value = (segoff.segment === newSegoff.segment && segoff.offset === newSegoff.offset) ? undefined : newSegoff;
|
|
1078
1115
|
return value;
|
|
@@ -1084,7 +1121,7 @@ export class IntervalCollection extends TypedEventEmitter {
|
|
|
1084
1121
|
lref.refType = refType;
|
|
1085
1122
|
}
|
|
1086
1123
|
ackInterval(interval, op) {
|
|
1087
|
-
//
|
|
1124
|
+
// Only SequenceIntervals need potential sliding
|
|
1088
1125
|
if (!(interval instanceof SequenceInterval)) {
|
|
1089
1126
|
return;
|
|
1090
1127
|
}
|
|
@@ -1108,7 +1145,7 @@ export class IntervalCollection extends TypedEventEmitter {
|
|
|
1108
1145
|
if (needsStartUpdate || needsEndUpdate) {
|
|
1109
1146
|
// In this case, where we change the start or end of an interval,
|
|
1110
1147
|
// it is necessary to remove and re-add the interval listeners.
|
|
1111
|
-
// This ensures that the correct listeners are added to the
|
|
1148
|
+
// This ensures that the correct listeners are added to the LocalReferencePosition.
|
|
1112
1149
|
this.localCollection.removeExistingInterval(interval);
|
|
1113
1150
|
if (needsStartUpdate) {
|
|
1114
1151
|
const props = interval.start.properties;
|
|
@@ -1129,10 +1166,6 @@ export class IntervalCollection extends TypedEventEmitter {
|
|
|
1129
1166
|
this.localCollection.add(interval);
|
|
1130
1167
|
}
|
|
1131
1168
|
}
|
|
1132
|
-
/** @deprecated - use ackAdd */
|
|
1133
|
-
addInternal(serializedInterval, local, op) {
|
|
1134
|
-
return this.ackAdd(serializedInterval, local, op);
|
|
1135
|
-
}
|
|
1136
1169
|
/** @internal */
|
|
1137
1170
|
ackAdd(serializedInterval, local, op) {
|
|
1138
1171
|
var _a;
|
|
@@ -1157,10 +1190,6 @@ export class IntervalCollection extends TypedEventEmitter {
|
|
|
1157
1190
|
this.emit("addInterval", interval, local, op);
|
|
1158
1191
|
return interval;
|
|
1159
1192
|
}
|
|
1160
|
-
/** @deprecated - use ackDelete */
|
|
1161
|
-
deleteInterval(serializedInterval, local, op) {
|
|
1162
|
-
return this.ackDelete(serializedInterval, local, op);
|
|
1163
|
-
}
|
|
1164
1193
|
/** @internal */
|
|
1165
1194
|
ackDelete(serializedInterval, local, op) {
|
|
1166
1195
|
if (local) {
|
|
@@ -1238,4 +1267,15 @@ export class IntervalCollection extends TypedEventEmitter {
|
|
|
1238
1267
|
return this.localCollection.nextInterval(pos);
|
|
1239
1268
|
}
|
|
1240
1269
|
}
|
|
1270
|
+
/**
|
|
1271
|
+
* Returns an object that can be used to find the interval a given LocalReferencePosition belongs to.
|
|
1272
|
+
* @returns undefined if the reference position is not the endpoint of any interval (e.g. it was created
|
|
1273
|
+
* on the merge tree directly by app code), otherwise an {@link IntervalLocator} for the interval this
|
|
1274
|
+
* endpoint is a part of.
|
|
1275
|
+
*/
|
|
1276
|
+
export function intervalLocatorFromEndpoint(potentialEndpoint) {
|
|
1277
|
+
var _a;
|
|
1278
|
+
const { interval, [reservedRangeLabelsKey]: collectionNameArray, } = (_a = potentialEndpoint.properties) !== null && _a !== void 0 ? _a : {};
|
|
1279
|
+
return (interval && (collectionNameArray === null || collectionNameArray === void 0 ? void 0 : collectionNameArray.length) === 1) ? { label: collectionNameArray[0], interval } : undefined;
|
|
1280
|
+
}
|
|
1241
1281
|
//# sourceMappingURL=intervalCollection.js.map
|