@fluidframework/sequence 2.0.0-internal.6.4.0 → 2.0.0-internal.7.0.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/CHANGELOG.md +60 -0
- package/README.md +130 -0
- package/dist/defaultMap.d.ts +1 -1
- package/dist/defaultMap.d.ts.map +1 -1
- package/dist/defaultMap.js +6 -6
- package/dist/defaultMap.js.map +1 -1
- package/dist/defaultMapInterfaces.d.ts +21 -2
- package/dist/defaultMapInterfaces.d.ts.map +1 -1
- package/dist/defaultMapInterfaces.js.map +1 -1
- 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 +136 -18
- package/dist/intervalCollection.d.ts.map +1 -1
- package/dist/intervalCollection.js +120 -37
- package/dist/intervalCollection.js.map +1 -1
- package/dist/intervalIndex/endpointInRangeIndex.js +1 -1
- package/dist/intervalIndex/endpointInRangeIndex.js.map +1 -1
- package/dist/intervalIndex/endpointIndex.d.ts.map +1 -1
- package/dist/intervalIndex/endpointIndex.js +1 -2
- package/dist/intervalIndex/endpointIndex.js.map +1 -1
- package/dist/intervalIndex/overlappingIntervalsIndex.d.ts +5 -4
- package/dist/intervalIndex/overlappingIntervalsIndex.d.ts.map +1 -1
- package/dist/intervalIndex/overlappingIntervalsIndex.js +7 -2
- package/dist/intervalIndex/overlappingIntervalsIndex.js.map +1 -1
- package/dist/intervalIndex/startpointInRangeIndex.d.ts.map +1 -1
- package/dist/intervalIndex/startpointInRangeIndex.js +1 -3
- package/dist/intervalIndex/startpointInRangeIndex.js.map +1 -1
- package/dist/intervalTree.d.ts +1 -1
- package/dist/intervalTree.d.ts.map +1 -1
- package/dist/intervals/interval.d.ts +3 -2
- package/dist/intervals/interval.d.ts.map +1 -1
- package/dist/intervals/interval.js +12 -5
- package/dist/intervals/interval.js.map +1 -1
- package/dist/intervals/intervalUtils.d.ts +39 -18
- package/dist/intervals/intervalUtils.d.ts.map +1 -1
- package/dist/intervals/intervalUtils.js +12 -10
- package/dist/intervals/intervalUtils.js.map +1 -1
- package/dist/intervals/sequenceInterval.d.ts +23 -13
- package/dist/intervals/sequenceInterval.d.ts.map +1 -1
- package/dist/intervals/sequenceInterval.js +117 -42
- package/dist/intervals/sequenceInterval.js.map +1 -1
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/revertibles.d.ts +3 -15
- package/dist/revertibles.d.ts.map +1 -1
- package/dist/revertibles.js +6 -17
- package/dist/revertibles.js.map +1 -1
- package/dist/sequence.d.ts +1 -1
- package/dist/sequence.d.ts.map +1 -1
- package/dist/sequence.js +43 -43
- package/dist/sequence.js.map +1 -1
- package/dist/sharedIntervalCollection.js +9 -9
- package/dist/sharedIntervalCollection.js.map +1 -1
- package/dist/sharedSequence.js +6 -6
- package/dist/sharedSequence.js.map +1 -1
- package/dist/sharedString.d.ts +1 -1
- package/dist/sharedString.d.ts.map +1 -1
- package/dist/sharedString.js +5 -5
- package/dist/sharedString.js.map +1 -1
- package/dist/tsdoc-metadata.json +1 -1
- package/lib/defaultMap.d.ts +1 -1
- package/lib/defaultMap.d.ts.map +1 -1
- package/lib/defaultMap.js +6 -6
- package/lib/defaultMap.js.map +1 -1
- package/lib/defaultMapInterfaces.d.ts +21 -2
- package/lib/defaultMapInterfaces.d.ts.map +1 -1
- package/lib/defaultMapInterfaces.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 +136 -18
- package/lib/intervalCollection.d.ts.map +1 -1
- package/lib/intervalCollection.js +117 -37
- package/lib/intervalCollection.js.map +1 -1
- package/lib/intervalIndex/endpointInRangeIndex.js +1 -1
- package/lib/intervalIndex/endpointInRangeIndex.js.map +1 -1
- package/lib/intervalIndex/endpointIndex.d.ts.map +1 -1
- package/lib/intervalIndex/endpointIndex.js +1 -2
- package/lib/intervalIndex/endpointIndex.js.map +1 -1
- package/lib/intervalIndex/overlappingIntervalsIndex.d.ts +5 -4
- package/lib/intervalIndex/overlappingIntervalsIndex.d.ts.map +1 -1
- package/lib/intervalIndex/overlappingIntervalsIndex.js +7 -2
- package/lib/intervalIndex/overlappingIntervalsIndex.js.map +1 -1
- package/lib/intervalIndex/startpointInRangeIndex.d.ts.map +1 -1
- package/lib/intervalIndex/startpointInRangeIndex.js +1 -3
- package/lib/intervalIndex/startpointInRangeIndex.js.map +1 -1
- package/lib/intervalTree.d.ts +1 -1
- package/lib/intervalTree.d.ts.map +1 -1
- package/lib/intervals/interval.d.ts +3 -2
- package/lib/intervals/interval.d.ts.map +1 -1
- package/lib/intervals/interval.js +12 -5
- package/lib/intervals/interval.js.map +1 -1
- package/lib/intervals/intervalUtils.d.ts +39 -18
- package/lib/intervals/intervalUtils.d.ts.map +1 -1
- package/lib/intervals/intervalUtils.js +8 -6
- package/lib/intervals/intervalUtils.js.map +1 -1
- package/lib/intervals/sequenceInterval.d.ts +23 -13
- package/lib/intervals/sequenceInterval.d.ts.map +1 -1
- package/lib/intervals/sequenceInterval.js +118 -41
- package/lib/intervals/sequenceInterval.js.map +1 -1
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/lib/revertibles.d.ts +3 -15
- package/lib/revertibles.d.ts.map +1 -1
- package/lib/revertibles.js +6 -17
- package/lib/revertibles.js.map +1 -1
- package/lib/sequence.d.ts +1 -1
- package/lib/sequence.d.ts.map +1 -1
- package/lib/sequence.js +43 -43
- package/lib/sequence.js.map +1 -1
- package/lib/sharedIntervalCollection.js +9 -9
- package/lib/sharedIntervalCollection.js.map +1 -1
- package/lib/sharedSequence.js +6 -6
- package/lib/sharedSequence.js.map +1 -1
- package/lib/sharedString.d.ts +1 -1
- package/lib/sharedString.d.ts.map +1 -1
- package/lib/sharedString.js +5 -5
- package/lib/sharedString.js.map +1 -1
- package/package.json +48 -20
- package/src/defaultMapInterfaces.ts +21 -2
- package/src/index.ts +3 -0
- package/src/intervalCollection.ts +309 -66
- package/src/intervalIndex/endpointInRangeIndex.ts +1 -1
- package/src/intervalIndex/endpointIndex.ts +1 -2
- package/src/intervalIndex/overlappingIntervalsIndex.ts +17 -9
- package/src/intervalIndex/startpointInRangeIndex.ts +1 -7
- package/src/intervals/interval.ts +28 -7
- package/src/intervals/intervalUtils.ts +47 -26
- package/src/intervals/sequenceInterval.ts +190 -46
- package/src/packageVersion.ts +1 -1
- package/src/revertibles.ts +8 -33
- package/src/sequence.ts +2 -0
|
@@ -9,16 +9,71 @@ import { ISequencedDocumentMessage } from "@fluidframework/protocol-definitions"
|
|
|
9
9
|
import { IMapMessageLocalMetadata, IValueFactory, IValueOpEmitter, IValueOperation, IValueType, SequenceOptions } from "./defaultMapInterfaces";
|
|
10
10
|
import { CompressedSerializedInterval, IIntervalHelpers, Interval, IntervalStickiness, IntervalType, ISerializableInterval, ISerializedInterval, SequenceInterval, SerializedIntervalDelta } from "./intervals";
|
|
11
11
|
import { IEndpointIndex, IIdIntervalIndex, IOverlappingIntervalsIndex, IntervalIndex } from "./intervalIndex";
|
|
12
|
+
/**
|
|
13
|
+
* Defines a position and side relative to a character in a sequence.
|
|
14
|
+
*
|
|
15
|
+
* For this purpose, sequences look like:
|
|
16
|
+
*
|
|
17
|
+
* `{start} - {character 0} - {character 1} - ... - {character N} - {end}`
|
|
18
|
+
*
|
|
19
|
+
* Each `{value}` in the diagram is a character within a sequence.
|
|
20
|
+
* Each `-` in the above diagram is a position where text could be inserted.
|
|
21
|
+
* Each position between a `{value}` and a `-` is a `SequencePlace`.
|
|
22
|
+
*
|
|
23
|
+
* The special endpoints `{start}` and `{end}` refer to positions outside the
|
|
24
|
+
* contents of the string.
|
|
25
|
+
*
|
|
26
|
+
* This gives us 2N + 2 possible positions to refer to within a string, where N
|
|
27
|
+
* is the number of characters.
|
|
28
|
+
*
|
|
29
|
+
* If the position is specified with a bare number, the side defaults to
|
|
30
|
+
* `Side.Before`.
|
|
31
|
+
*
|
|
32
|
+
* If a SequencePlace is the endpoint of a range (e.g. start/end of an interval or search range),
|
|
33
|
+
* the Side value means it is exclusive if it is nearer to the other position and inclusive if it is farther.
|
|
34
|
+
* E.g. the start of a range with Side.After is exclusive of the character at the position.
|
|
35
|
+
*/
|
|
36
|
+
export type SequencePlace = number | "start" | "end" | InteriorSequencePlace;
|
|
37
|
+
/**
|
|
38
|
+
* A sequence place that does not refer to the special endpoint segments.
|
|
39
|
+
*
|
|
40
|
+
* See {@link SequencePlace} for additional context.
|
|
41
|
+
*/
|
|
42
|
+
export interface InteriorSequencePlace {
|
|
43
|
+
pos: number;
|
|
44
|
+
side: Side;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Defines a side relative to a character in a sequence.
|
|
48
|
+
*
|
|
49
|
+
* @remarks See {@link SequencePlace} for additional context on usage.
|
|
50
|
+
*/
|
|
51
|
+
export declare enum Side {
|
|
52
|
+
Before = 0,
|
|
53
|
+
After = 1
|
|
54
|
+
}
|
|
12
55
|
export interface ISerializedIntervalCollectionV2 {
|
|
13
56
|
label: string;
|
|
14
57
|
version: 2;
|
|
15
58
|
intervals: CompressedSerializedInterval[];
|
|
16
59
|
}
|
|
60
|
+
export declare function sidesFromStickiness(stickiness: IntervalStickiness): {
|
|
61
|
+
startSide: Side;
|
|
62
|
+
endSide: Side;
|
|
63
|
+
};
|
|
64
|
+
export declare function endpointPosAndSide(start: SequencePlace | undefined, end: SequencePlace | undefined): {
|
|
65
|
+
startSide: Side | undefined;
|
|
66
|
+
endSide: Side | undefined;
|
|
67
|
+
startPos: number | "start" | "end" | undefined;
|
|
68
|
+
endPos: number | "start" | "end" | undefined;
|
|
69
|
+
};
|
|
70
|
+
export declare function computeStickinessFromSide(startPos?: number | "start" | "end" | undefined, startSide?: Side, endPos?: number | "start" | "end" | undefined, endSide?: Side): IntervalStickiness;
|
|
17
71
|
export declare function createIntervalIndex(): LocalIntervalCollection<Interval>;
|
|
18
72
|
export declare class LocalIntervalCollection<TInterval extends ISerializableInterval> {
|
|
19
73
|
private readonly client;
|
|
20
74
|
private readonly label;
|
|
21
75
|
private readonly helpers;
|
|
76
|
+
private readonly options;
|
|
22
77
|
/** Callback invoked each time one of the endpoints of an interval slides. */
|
|
23
78
|
private readonly onPositionChange?;
|
|
24
79
|
private static readonly legacyIdPrefix;
|
|
@@ -26,10 +81,10 @@ export declare class LocalIntervalCollection<TInterval extends ISerializableInte
|
|
|
26
81
|
readonly idIntervalIndex: IIdIntervalIndex<TInterval>;
|
|
27
82
|
readonly endIntervalIndex: IEndpointIndex<TInterval>;
|
|
28
83
|
private readonly indexes;
|
|
29
|
-
constructor(client: Client, label: string, helpers: IIntervalHelpers<TInterval>,
|
|
84
|
+
constructor(client: Client, label: string, helpers: IIntervalHelpers<TInterval>, options: Partial<SequenceOptions>,
|
|
30
85
|
/** Callback invoked each time one of the endpoints of an interval slides. */
|
|
31
86
|
onPositionChange?: ((interval: TInterval, previousInterval: TInterval) => void) | undefined);
|
|
32
|
-
createLegacyId(start: number, end: number): string;
|
|
87
|
+
createLegacyId(start: number | "start" | "end", end: number | "start" | "end"): string;
|
|
33
88
|
/**
|
|
34
89
|
* Validates that a serialized interval has the ID property. Creates an ID
|
|
35
90
|
* if one does not already exist
|
|
@@ -42,12 +97,12 @@ export declare class LocalIntervalCollection<TInterval extends ISerializableInte
|
|
|
42
97
|
appendIndex(index: IntervalIndex<TInterval>): void;
|
|
43
98
|
removeIndex(index: IntervalIndex<TInterval>): boolean;
|
|
44
99
|
removeExistingInterval(interval: TInterval): void;
|
|
45
|
-
createInterval(start:
|
|
46
|
-
addInterval(start:
|
|
100
|
+
createInterval(start: SequencePlace, end: SequencePlace, intervalType: IntervalType, op?: ISequencedDocumentMessage): TInterval;
|
|
101
|
+
addInterval(start: SequencePlace, end: SequencePlace, intervalType: IntervalType, props?: PropertySet, op?: ISequencedDocumentMessage): TInterval;
|
|
47
102
|
private linkEndpointsToInterval;
|
|
48
103
|
private addIntervalToIndexes;
|
|
49
104
|
add(interval: TInterval): void;
|
|
50
|
-
changeInterval(interval: TInterval, start:
|
|
105
|
+
changeInterval(interval: TInterval, start: SequencePlace | undefined, end: SequencePlace | undefined, op?: ISequencedDocumentMessage, localSeq?: number): TInterval | undefined;
|
|
51
106
|
serialize(): ISerializedIntervalCollectionV2;
|
|
52
107
|
private addIntervalListeners;
|
|
53
108
|
private removeIntervalListeners;
|
|
@@ -69,7 +124,7 @@ export declare class IntervalCollectionValueType implements IValueType<IntervalC
|
|
|
69
124
|
private static readonly _ops;
|
|
70
125
|
}
|
|
71
126
|
export declare function makeOpsMap<T extends ISerializableInterval>(): Map<string, IValueOperation<IntervalCollection<T>>>;
|
|
72
|
-
export
|
|
127
|
+
export type DeserializeCallback = (properties: PropertySet) => void;
|
|
73
128
|
declare class IntervalCollectionIterator<TInterval extends ISerializableInterval> implements Iterator<TInterval> {
|
|
74
129
|
private readonly results;
|
|
75
130
|
private index;
|
|
@@ -141,16 +196,78 @@ export interface IIntervalCollection<TInterval extends ISerializableInterval> ex
|
|
|
141
196
|
getIntervalById(id: string): TInterval | undefined;
|
|
142
197
|
/**
|
|
143
198
|
* Creates a new interval and add it to the collection.
|
|
144
|
-
* @param start - interval start position
|
|
145
|
-
* @param end - interval end position
|
|
146
|
-
* @param intervalType - type of the interval. All intervals are SlideOnRemove.
|
|
199
|
+
* @param start - interval start position
|
|
200
|
+
* @param end - interval end position
|
|
201
|
+
* @param intervalType - type of the interval. All intervals are SlideOnRemove.
|
|
202
|
+
* Intervals may not be Transient.
|
|
147
203
|
* @param props - properties of the interval
|
|
148
|
-
* @param stickiness - {@link (IntervalStickiness:type)} to apply to the added interval.
|
|
149
204
|
* @returns The created interval
|
|
150
|
-
* @remarks See documentation on {@link SequenceInterval} for comments on
|
|
151
|
-
* with how the current
|
|
205
|
+
* @remarks See documentation on {@link SequenceInterval} for comments on
|
|
206
|
+
* interval endpoint semantics: there are subtleties with how the current
|
|
207
|
+
* half-open behavior is represented.
|
|
208
|
+
*
|
|
209
|
+
* Note that intervals may behave unexpectedly if the entire contents
|
|
210
|
+
* of the string are deleted. In this case, it is possible for one endpoint
|
|
211
|
+
* of the interval to become detached, while the other remains on the string.
|
|
212
|
+
*
|
|
213
|
+
* By adjusting the `side` and `pos` values of the `start` and `end` parameters,
|
|
214
|
+
* it is possible to control whether the interval expands to include content
|
|
215
|
+
* inserted at its start or end.
|
|
216
|
+
*
|
|
217
|
+
* See {@link SequencePlace} for more details on the model.
|
|
218
|
+
*
|
|
219
|
+
* @example
|
|
220
|
+
*
|
|
221
|
+
* Given the string "ABCD":
|
|
222
|
+
*
|
|
223
|
+
*```typescript
|
|
224
|
+
* // Refers to "BC". If any content is inserted before B or after C, this
|
|
225
|
+
* // interval will include that content
|
|
226
|
+
* //
|
|
227
|
+
* // Picture:
|
|
228
|
+
* // \{start\} - A[- B - C -]D - \{end\}
|
|
229
|
+
* // \{start\} - A - B - C - D - \{end\}
|
|
230
|
+
* collection.add(\{ pos: 0, side: Side.After \}, \{ pos: 3, side: Side.Before \}, IntervalType.SlideOnRemove);
|
|
231
|
+
* // Equivalent to specifying the same positions and Side.Before.
|
|
232
|
+
* // Refers to "ABC". Content inserted after C will be included in the
|
|
233
|
+
* // interval, but content inserted before A will not.
|
|
234
|
+
* // \{start\} -[A - B - C -]D - \{end\}
|
|
235
|
+
* // \{start\} - A - B - C - D - \{end\}
|
|
236
|
+
* collection.add(0, 3, IntervalType.SlideOnRemove);
|
|
237
|
+
*```
|
|
238
|
+
*
|
|
239
|
+
* In the case of the first example, if text is deleted,
|
|
240
|
+
*
|
|
241
|
+
* ```typescript
|
|
242
|
+
* // Delete the character "B"
|
|
243
|
+
* string.removeRange(1, 2);
|
|
244
|
+
* ```
|
|
245
|
+
*
|
|
246
|
+
* The start point of the interval will slide to the position immediately
|
|
247
|
+
* before "C", and the same will be true.
|
|
248
|
+
*
|
|
249
|
+
* ```
|
|
250
|
+
* \{start\} - A[- C -]D - \{end\}
|
|
251
|
+
* ```
|
|
252
|
+
*
|
|
253
|
+
* In this case, text inserted immediately before "C" would be included in
|
|
254
|
+
* the interval.
|
|
255
|
+
*
|
|
256
|
+
* ```typescript
|
|
257
|
+
* string.insertText(1, "EFG");
|
|
258
|
+
* ```
|
|
259
|
+
*
|
|
260
|
+
* With the string now being,
|
|
261
|
+
*
|
|
262
|
+
* ```
|
|
263
|
+
* \{start\} - A[- E - F - G - C -]D - \{end\}
|
|
264
|
+
* ```
|
|
265
|
+
*
|
|
266
|
+
* @privateRemarks TODO: ADO:5205 the above comment regarding behavior in
|
|
267
|
+
* the case that the entire interval has been deleted should be resolved at
|
|
268
|
+
* the same time as this ticket
|
|
152
269
|
*/
|
|
153
|
-
add(start:
|
|
270
|
+
add(start: SequencePlace, end: SequencePlace, intervalType: IntervalType, props?: PropertySet): TInterval;
|
|
154
271
|
/**
|
|
155
272
|
* Removes an interval from the collection.
|
|
156
273
|
* @param id - Id of the interval to remove
|
|
@@ -167,11 +284,11 @@ export interface IIntervalCollection<TInterval extends ISerializableInterval> ex
|
|
|
167
284
|
/**
|
|
168
285
|
* Changes the endpoints of an existing interval.
|
|
169
286
|
* @param id - Id of the interval to change
|
|
170
|
-
* @param start - New start value
|
|
171
|
-
* @param end - New end value
|
|
287
|
+
* @param start - New start value. This can be the existing position to keep it unchanged.
|
|
288
|
+
* @param end - New end value. This can be the existing position to keep it unchanged.
|
|
172
289
|
* @returns the interval that was changed, if it existed in the collection.
|
|
173
290
|
*/
|
|
174
|
-
change(id: string, start
|
|
291
|
+
change(id: string, start: SequencePlace, end: SequencePlace): TInterval | undefined;
|
|
175
292
|
attachDeserializer(onDeserialize: DeserializeCallback): void;
|
|
176
293
|
/**
|
|
177
294
|
* @returns an iterator over all intervals in this collection.
|
|
@@ -254,10 +371,11 @@ export declare class IntervalCollection<TInterval extends ISerializableInterval>
|
|
|
254
371
|
* {@inheritdoc IIntervalCollection.getIntervalById}
|
|
255
372
|
*/
|
|
256
373
|
getIntervalById(id: string): TInterval | undefined;
|
|
374
|
+
private assertStickinessEnabled;
|
|
257
375
|
/**
|
|
258
376
|
* {@inheritdoc IIntervalCollection.add}
|
|
259
377
|
*/
|
|
260
|
-
add(start:
|
|
378
|
+
add(start: SequencePlace, end: SequencePlace, intervalType: IntervalType, props?: PropertySet): TInterval;
|
|
261
379
|
private deleteExistingInterval;
|
|
262
380
|
/**
|
|
263
381
|
* {@inheritdoc IIntervalCollection.removeIntervalById}
|
|
@@ -270,7 +388,7 @@ export declare class IntervalCollection<TInterval extends ISerializableInterval>
|
|
|
270
388
|
/**
|
|
271
389
|
* {@inheritdoc IIntervalCollection.change}
|
|
272
390
|
*/
|
|
273
|
-
change(id: string, start
|
|
391
|
+
change(id: string, start: SequencePlace, end: SequencePlace): TInterval | undefined;
|
|
274
392
|
private get isCollaborating();
|
|
275
393
|
private addPendingChange;
|
|
276
394
|
private addPendingChangeHelper;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"intervalCollection.d.ts","sourceRoot":"","sources":["../src/intervalCollection.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAEjE,OAAO,EAAE,MAAM,EAAE,MAAM,iCAAiC,CAAC;AACzD,OAAO,EAEN,MAAM,EAKN,WAAW,EACX,sBAAsB,
|
|
1
|
+
{"version":3,"file":"intervalCollection.d.ts","sourceRoot":"","sources":["../src/intervalCollection.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAEjE,OAAO,EAAE,MAAM,EAAE,MAAM,iCAAiC,CAAC;AACzD,OAAO,EAEN,MAAM,EAKN,WAAW,EACX,sBAAsB,EAQtB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,yBAAyB,EAAE,MAAM,sCA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OAEG;IACI,sCAAsC,CAC5C,aAAa,EAAE,MAAM,GACnB,0BAA0B,CAAC,SAAS,CAAC;IAKxC;;OAEG;IACI,uCAAuC,CAC7C,aAAa,EAAE,MAAM,GACnB,0BAA0B,CAAC,SAAS,CAAC;IAKxC;;OAEG;IACI,oCAAoC,CAC1C,WAAW,EAAE,MAAM,GACjB,0BAA0B,CAAC,SAAS,CAAC;IAUxC;;OAEG;IACI,qCAAqC,CAC3C,WAAW,EAAE,MAAM,GACjB,0BAA0B,CAAC,SAAS,CAAC;IAUxC;;OAEG;IACI,sBAAsB,CAC5B,OAAO,EAAE,SAAS,EAAE,EACpB,eAAe,EAAE,OAAO,EACxB,KAAK,CAAC,EAAE,MAAM,EACd,GAAG,CAAC,EAAE,MAAM;IAcb;;OAEG;IACI,wBAAwB,CAAC,aAAa,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,SAAS,EAAE;IAWxF;;OAEG;IACI,GAAG,CAAC,EAAE,EAAE,CAAC,QAAQ,EAAE,SAAS,KAAK,IAAI;IAU5C;;OAEG;IACI,gBAAgB,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS;IAQ3D;;OAEG;IACI,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS;CAOvD;AASD;;GAEG;AACH,MAAM,WAAW,eAAe;IAC/B;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,QAAQ,EAAE,gBAAgB,CAAC;CAC3B;AAED;;;;;GAKG;AACH,wBAAgB,2BAA2B,CAC1C,iBAAiB,EAAE,sBAAsB,GACvC,eAAe,GAAG,SAAS,CAM7B"}
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Licensed under the MIT License.
|
|
5
5
|
*/
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.intervalLocatorFromEndpoint = exports.IntervalCollection = exports.makeOpsMap = exports.IntervalCollectionValueType = exports.SequenceIntervalCollectionValueType = exports.LocalIntervalCollection = exports.createIntervalIndex = void 0;
|
|
7
|
+
exports.intervalLocatorFromEndpoint = exports.IntervalCollection = exports.makeOpsMap = exports.IntervalCollectionValueType = exports.SequenceIntervalCollectionValueType = exports.LocalIntervalCollection = exports.createIntervalIndex = exports.computeStickinessFromSide = exports.endpointPosAndSide = exports.sidesFromStickiness = exports.Side = void 0;
|
|
8
8
|
/* eslint-disable no-bitwise */
|
|
9
9
|
/* eslint-disable import/no-deprecated */
|
|
10
10
|
const client_utils_1 = require("@fluid-internal/client-utils");
|
|
@@ -14,19 +14,39 @@ const telemetry_utils_1 = require("@fluidframework/telemetry-utils");
|
|
|
14
14
|
const uuid_1 = require("uuid");
|
|
15
15
|
const intervals_1 = require("./intervals");
|
|
16
16
|
const intervalIndex_1 = require("./intervalIndex");
|
|
17
|
+
/**
|
|
18
|
+
* Defines a side relative to a character in a sequence.
|
|
19
|
+
*
|
|
20
|
+
* @remarks See {@link SequencePlace} for additional context on usage.
|
|
21
|
+
*/
|
|
22
|
+
var Side;
|
|
23
|
+
(function (Side) {
|
|
24
|
+
Side[Side["Before"] = 0] = "Before";
|
|
25
|
+
Side[Side["After"] = 1] = "After";
|
|
26
|
+
})(Side || (exports.Side = Side = {}));
|
|
17
27
|
const reservedIntervalIdKey = "intervalId";
|
|
28
|
+
function sidesFromStickiness(stickiness) {
|
|
29
|
+
const startSide = (stickiness & intervals_1.IntervalStickiness.START) !== 0 ? Side.After : Side.Before;
|
|
30
|
+
const endSide = (stickiness & intervals_1.IntervalStickiness.END) !== 0 ? Side.Before : Side.After;
|
|
31
|
+
return { startSide, endSide };
|
|
32
|
+
}
|
|
33
|
+
exports.sidesFromStickiness = sidesFromStickiness;
|
|
18
34
|
/**
|
|
19
35
|
* Decompress an interval after loading a summary from JSON. The exact format
|
|
20
36
|
* of this compression is unspecified and subject to change
|
|
21
37
|
*/
|
|
22
38
|
function decompressInterval(interval, label) {
|
|
39
|
+
const stickiness = interval[5] ?? intervals_1.IntervalStickiness.END;
|
|
40
|
+
const { startSide, endSide } = sidesFromStickiness(stickiness);
|
|
23
41
|
return {
|
|
24
42
|
start: interval[0],
|
|
25
43
|
end: interval[1],
|
|
26
44
|
sequenceNumber: interval[2],
|
|
27
45
|
intervalType: interval[3],
|
|
28
46
|
properties: { ...interval[4], [merge_tree_1.reservedRangeLabelsKey]: [label] },
|
|
29
|
-
stickiness
|
|
47
|
+
stickiness,
|
|
48
|
+
startSide,
|
|
49
|
+
endSide,
|
|
30
50
|
};
|
|
31
51
|
}
|
|
32
52
|
/**
|
|
@@ -35,7 +55,7 @@ function decompressInterval(interval, label) {
|
|
|
35
55
|
*/
|
|
36
56
|
function compressInterval(interval) {
|
|
37
57
|
const { start, end, sequenceNumber, intervalType, properties } = interval;
|
|
38
|
-
|
|
58
|
+
let base = [
|
|
39
59
|
start,
|
|
40
60
|
end,
|
|
41
61
|
sequenceNumber,
|
|
@@ -45,26 +65,59 @@ function compressInterval(interval) {
|
|
|
45
65
|
{ ...properties, [merge_tree_1.reservedRangeLabelsKey]: undefined },
|
|
46
66
|
];
|
|
47
67
|
if (interval.stickiness !== undefined && interval.stickiness !== intervals_1.IntervalStickiness.END) {
|
|
48
|
-
|
|
68
|
+
// reassignment to make it easier for typescript to reason about types
|
|
69
|
+
base = [...base, interval.stickiness];
|
|
49
70
|
}
|
|
50
71
|
return base;
|
|
51
72
|
}
|
|
73
|
+
function endpointPosAndSide(start, end) {
|
|
74
|
+
const startIsPlainEndpoint = typeof start === "number" || start === "start" || start === "end";
|
|
75
|
+
const endIsPlainEndpoint = typeof end === "number" || end === "start" || end === "end";
|
|
76
|
+
const startSide = startIsPlainEndpoint ? Side.Before : start?.side;
|
|
77
|
+
const endSide = endIsPlainEndpoint ? Side.Before : end?.side;
|
|
78
|
+
const startPos = startIsPlainEndpoint ? start : start?.pos;
|
|
79
|
+
const endPos = endIsPlainEndpoint ? end : end?.pos;
|
|
80
|
+
return {
|
|
81
|
+
startSide,
|
|
82
|
+
endSide,
|
|
83
|
+
startPos,
|
|
84
|
+
endPos,
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
exports.endpointPosAndSide = endpointPosAndSide;
|
|
88
|
+
function toSequencePlace(pos, side) {
|
|
89
|
+
return typeof pos === "number" ? { pos, side } : pos;
|
|
90
|
+
}
|
|
91
|
+
function toOptionalSequencePlace(pos, side = Side.Before) {
|
|
92
|
+
return typeof pos === "number" ? { pos, side } : pos;
|
|
93
|
+
}
|
|
94
|
+
function computeStickinessFromSide(startPos = -1, startSide = Side.Before, endPos = -1, endSide = Side.Before) {
|
|
95
|
+
let stickiness = intervals_1.IntervalStickiness.NONE;
|
|
96
|
+
if (startSide === Side.After || startPos === "start") {
|
|
97
|
+
stickiness |= intervals_1.IntervalStickiness.START;
|
|
98
|
+
}
|
|
99
|
+
if (endSide === Side.Before || endPos === "end") {
|
|
100
|
+
stickiness |= intervals_1.IntervalStickiness.END;
|
|
101
|
+
}
|
|
102
|
+
return stickiness;
|
|
103
|
+
}
|
|
104
|
+
exports.computeStickinessFromSide = computeStickinessFromSide;
|
|
52
105
|
function createIntervalIndex() {
|
|
53
106
|
const helpers = {
|
|
54
|
-
compareEnds: (a, b) => a.end - b.end,
|
|
55
107
|
create: intervals_1.createInterval,
|
|
56
108
|
};
|
|
57
|
-
const lc = new LocalIntervalCollection(undefined, "", helpers);
|
|
109
|
+
const lc = new LocalIntervalCollection(undefined, "", helpers, {});
|
|
58
110
|
return lc;
|
|
59
111
|
}
|
|
60
112
|
exports.createIntervalIndex = createIntervalIndex;
|
|
61
113
|
class LocalIntervalCollection {
|
|
62
|
-
constructor(client, label, helpers,
|
|
114
|
+
constructor(client, label, helpers, options,
|
|
63
115
|
/** Callback invoked each time one of the endpoints of an interval slides. */
|
|
64
116
|
onPositionChange) {
|
|
65
117
|
this.client = client;
|
|
66
118
|
this.label = label;
|
|
67
119
|
this.helpers = helpers;
|
|
120
|
+
this.options = options;
|
|
68
121
|
this.onPositionChange = onPositionChange;
|
|
69
122
|
this.overlappingIntervalsIndex = new intervalIndex_1.OverlappingIntervalsIndex(client, helpers);
|
|
70
123
|
this.idIntervalIndex = (0, intervalIndex_1.createIdIntervalIndex)();
|
|
@@ -122,12 +175,12 @@ class LocalIntervalCollection {
|
|
|
122
175
|
this.removeIntervalFromIndexes(interval);
|
|
123
176
|
this.removeIntervalListeners(interval);
|
|
124
177
|
}
|
|
125
|
-
createInterval(start, end, intervalType, op
|
|
126
|
-
return this.helpers.create(this.label, start, end, this.client, intervalType, op, undefined,
|
|
178
|
+
createInterval(start, end, intervalType, op) {
|
|
179
|
+
return this.helpers.create(this.label, start, end, this.client, intervalType, op, undefined, this.options.mergeTreeReferencesCanSlideToEndpoint);
|
|
127
180
|
}
|
|
128
|
-
addInterval(start, end, intervalType, props, op
|
|
181
|
+
addInterval(start, end, intervalType, props, op) {
|
|
129
182
|
var _a;
|
|
130
|
-
const interval = this.createInterval(start, end, intervalType, op
|
|
183
|
+
const interval = this.createInterval(start, end, intervalType, op);
|
|
131
184
|
if (interval) {
|
|
132
185
|
if (!interval.properties) {
|
|
133
186
|
interval.properties = (0, merge_tree_1.createMap)();
|
|
@@ -164,7 +217,7 @@ class LocalIntervalCollection {
|
|
|
164
217
|
this.addIntervalListeners(interval);
|
|
165
218
|
}
|
|
166
219
|
changeInterval(interval, start, end, op, localSeq) {
|
|
167
|
-
const newInterval = interval.modify(this.label, start, end, op, localSeq);
|
|
220
|
+
const newInterval = interval.modify(this.label, start, end, op, localSeq, this.options.mergeTreeReferencesCanSlideToEndpoint);
|
|
168
221
|
if (newInterval) {
|
|
169
222
|
this.removeExistingInterval(interval);
|
|
170
223
|
this.add(newInterval);
|
|
@@ -187,7 +240,7 @@ class LocalIntervalCollection {
|
|
|
187
240
|
// either, so this must be special-cased.
|
|
188
241
|
return ref;
|
|
189
242
|
}
|
|
190
|
-
return this.client.createLocalReferencePosition(segment, ref.getOffset(), merge_tree_1.ReferenceType.Transient, ref.properties, ref.slidingPreference);
|
|
243
|
+
return this.client.createLocalReferencePosition(segment, ref.getOffset(), merge_tree_1.ReferenceType.Transient, ref.properties, ref.slidingPreference, ref.canSlideToEndpoint);
|
|
191
244
|
};
|
|
192
245
|
if (interval instanceof intervals_1.SequenceInterval) {
|
|
193
246
|
let previousInterval;
|
|
@@ -246,7 +299,6 @@ SequenceIntervalCollectionValueType._ops = makeOpsMap();
|
|
|
246
299
|
class IntervalCollectionFactory {
|
|
247
300
|
load(emitter, raw = [], options) {
|
|
248
301
|
const helpers = {
|
|
249
|
-
compareEnds: (a, b) => a.end - b.end,
|
|
250
302
|
create: intervals_1.createInterval,
|
|
251
303
|
};
|
|
252
304
|
const collection = new IntervalCollection(helpers, false, emitter, raw, options);
|
|
@@ -349,6 +401,9 @@ class IntervalCollectionIterator {
|
|
|
349
401
|
* {@inheritdoc IIntervalCollection}
|
|
350
402
|
*/
|
|
351
403
|
class IntervalCollection extends client_utils_1.TypedEventEmitter {
|
|
404
|
+
get attached() {
|
|
405
|
+
return !!this.localCollection;
|
|
406
|
+
}
|
|
352
407
|
/** @internal */
|
|
353
408
|
constructor(helpers, requiresClient, emitter, serializedIntervals, options = {}) {
|
|
354
409
|
super();
|
|
@@ -364,9 +419,6 @@ class IntervalCollection extends client_utils_1.TypedEventEmitter {
|
|
|
364
419
|
? serializedIntervals
|
|
365
420
|
: serializedIntervals.intervals.map((i) => decompressInterval(i, serializedIntervals.label));
|
|
366
421
|
}
|
|
367
|
-
get attached() {
|
|
368
|
-
return !!this.localCollection;
|
|
369
|
-
}
|
|
370
422
|
/**
|
|
371
423
|
* {@inheritdoc IIntervalCollection.attachIndex}
|
|
372
424
|
*/
|
|
@@ -399,6 +451,9 @@ class IntervalCollection extends client_utils_1.TypedEventEmitter {
|
|
|
399
451
|
if (!this.client) {
|
|
400
452
|
throw new telemetry_utils_1.LoggingError("mergeTree client must exist");
|
|
401
453
|
}
|
|
454
|
+
if (pos === "start" || pos === "end") {
|
|
455
|
+
return pos;
|
|
456
|
+
}
|
|
402
457
|
const { clientId } = this.client.getCollabWindow();
|
|
403
458
|
const { segment, offset } = this.client.getContainingSegment(pos, {
|
|
404
459
|
referenceSequenceNumber: seqNumberFrom,
|
|
@@ -406,7 +461,7 @@ class IntervalCollection extends client_utils_1.TypedEventEmitter {
|
|
|
406
461
|
}, localSeq);
|
|
407
462
|
// if segment is undefined, it slid off the string
|
|
408
463
|
(0, core_utils_1.assert)(segment !== undefined, 0x54e /* No segment found */);
|
|
409
|
-
const segoff = (0, merge_tree_1.getSlideToSegoff)({ segment, offset }) ?? segment;
|
|
464
|
+
const segoff = (0, merge_tree_1.getSlideToSegoff)({ segment, offset }, undefined, this.options.mergeTreeReferencesCanSlideToEndpoint) ?? segment;
|
|
410
465
|
// case happens when rebasing op, but concurrently entire string has been deleted
|
|
411
466
|
if (segoff.segment === undefined || segoff.offset === undefined) {
|
|
412
467
|
return merge_tree_1.DetachedReferencePosition;
|
|
@@ -445,12 +500,18 @@ class IntervalCollection extends client_utils_1.TypedEventEmitter {
|
|
|
445
500
|
}
|
|
446
501
|
});
|
|
447
502
|
}
|
|
448
|
-
this.localCollection = new LocalIntervalCollection(client, label, this.helpers, (interval, previousInterval) => this.emitChange(interval, previousInterval, true, true));
|
|
503
|
+
this.localCollection = new LocalIntervalCollection(client, label, this.helpers, this.options, (interval, previousInterval) => this.emitChange(interval, previousInterval, true, true));
|
|
449
504
|
if (this.savedSerializedIntervals) {
|
|
450
505
|
for (const serializedInterval of this.savedSerializedIntervals) {
|
|
451
506
|
this.localCollection.ensureSerializedId(serializedInterval);
|
|
452
|
-
const { start, end, intervalType, properties,
|
|
453
|
-
const
|
|
507
|
+
const { start: startPos, end: endPos, intervalType, properties, startSide, endSide, } = serializedInterval;
|
|
508
|
+
const start = typeof startPos === "number" && startSide !== undefined
|
|
509
|
+
? { pos: startPos, side: startSide }
|
|
510
|
+
: startPos;
|
|
511
|
+
const end = typeof endPos === "number" && endSide !== undefined
|
|
512
|
+
? { pos: endPos, side: endSide }
|
|
513
|
+
: endPos;
|
|
514
|
+
const interval = this.helpers.create(label, start, end, client, intervalType, undefined, true, this.options.mergeTreeReferencesCanSlideToEndpoint);
|
|
454
515
|
if (properties) {
|
|
455
516
|
interval.addProperties(properties);
|
|
456
517
|
}
|
|
@@ -496,32 +557,44 @@ class IntervalCollection extends client_utils_1.TypedEventEmitter {
|
|
|
496
557
|
}
|
|
497
558
|
return this.localCollection.idIntervalIndex.getIntervalById(id);
|
|
498
559
|
}
|
|
560
|
+
assertStickinessEnabled(start, end) {
|
|
561
|
+
if (!(typeof start === "number" && typeof end === "number") &&
|
|
562
|
+
!this.options.intervalStickinessEnabled) {
|
|
563
|
+
throw new telemetry_utils_1.UsageError("attempted to set interval stickiness without enabling `intervalStickinessEnabled` feature flag");
|
|
564
|
+
}
|
|
565
|
+
}
|
|
499
566
|
/**
|
|
500
567
|
* {@inheritdoc IIntervalCollection.add}
|
|
501
568
|
*/
|
|
502
|
-
add(start, end, intervalType, props
|
|
569
|
+
add(start, end, intervalType, props) {
|
|
503
570
|
if (!this.localCollection) {
|
|
504
571
|
throw new telemetry_utils_1.LoggingError("attach must be called prior to adding intervals");
|
|
505
572
|
}
|
|
506
573
|
if (intervalType & intervals_1.IntervalType.Transient) {
|
|
507
574
|
throw new telemetry_utils_1.LoggingError("Can not add transient intervals");
|
|
508
575
|
}
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
576
|
+
const { startSide, endSide, startPos, endPos } = endpointPosAndSide(start, end);
|
|
577
|
+
(0, core_utils_1.assert)(startPos !== undefined &&
|
|
578
|
+
endPos !== undefined &&
|
|
579
|
+
startSide !== undefined &&
|
|
580
|
+
endSide !== undefined, 0x793 /* start and end cannot be undefined because they were not passed in as undefined */);
|
|
581
|
+
const stickiness = computeStickinessFromSide(startPos, startSide, endPos, endSide);
|
|
582
|
+
this.assertStickinessEnabled(start, end);
|
|
583
|
+
const interval = this.localCollection.addInterval(toSequencePlace(startPos, startSide), toSequencePlace(endPos, endSide), intervalType, props);
|
|
513
584
|
if (interval) {
|
|
514
585
|
if (!this.isCollaborating && interval instanceof intervals_1.SequenceInterval) {
|
|
515
586
|
setSlideOnRemove(interval.start);
|
|
516
587
|
setSlideOnRemove(interval.end);
|
|
517
588
|
}
|
|
518
589
|
const serializedInterval = {
|
|
519
|
-
|
|
590
|
+
start: startPos,
|
|
591
|
+
end: endPos,
|
|
520
592
|
intervalType,
|
|
521
593
|
properties: interval.properties,
|
|
522
594
|
sequenceNumber: this.client?.getCurrentSeq() ?? 0,
|
|
523
|
-
start,
|
|
524
595
|
stickiness,
|
|
596
|
+
startSide,
|
|
597
|
+
endSide,
|
|
525
598
|
};
|
|
526
599
|
const localSeq = this.getNextLocalSeq();
|
|
527
600
|
this.localSeqToSerializedInterval.set(localSeq, serializedInterval);
|
|
@@ -621,8 +694,13 @@ class IntervalCollection extends client_utils_1.TypedEventEmitter {
|
|
|
621
694
|
setSlideOnRemove(newInterval.end);
|
|
622
695
|
}
|
|
623
696
|
const serializedInterval = interval.serialize();
|
|
624
|
-
|
|
625
|
-
|
|
697
|
+
const { startPos, startSide, endPos, endSide } = endpointPosAndSide(start, end);
|
|
698
|
+
const stickiness = computeStickinessFromSide(startPos, startSide, endPos, endSide);
|
|
699
|
+
serializedInterval.start = startPos;
|
|
700
|
+
serializedInterval.end = endPos;
|
|
701
|
+
serializedInterval.startSide = startSide;
|
|
702
|
+
serializedInterval.endSide = endSide;
|
|
703
|
+
serializedInterval.stickiness = stickiness;
|
|
626
704
|
// Emit a property bag containing only the ID, as we don't intend for this op to change any properties.
|
|
627
705
|
serializedInterval.properties = {
|
|
628
706
|
[reservedIntervalIdKey]: interval.getIntervalId(),
|
|
@@ -736,7 +814,7 @@ class IntervalCollection extends client_utils_1.TypedEventEmitter {
|
|
|
736
814
|
// If changeInterval gives us a new interval, work with that one. Otherwise keep working with
|
|
737
815
|
// the one we originally found in the tree.
|
|
738
816
|
newInterval =
|
|
739
|
-
this.localCollection.changeInterval(interval, start, end, op) ?? interval;
|
|
817
|
+
this.localCollection.changeInterval(interval, toOptionalSequencePlace(start, serializedInterval.startSide), toOptionalSequencePlace(end, serializedInterval.endSide), op) ?? interval;
|
|
740
818
|
}
|
|
741
819
|
const deltaProps = newInterval.addProperties(newProps, true, op.sequenceNumber);
|
|
742
820
|
if (this.onDeserialize) {
|
|
@@ -781,7 +859,7 @@ class IntervalCollection extends client_utils_1.TypedEventEmitter {
|
|
|
781
859
|
if (!this.attached) {
|
|
782
860
|
throw new telemetry_utils_1.LoggingError("attachSequence must be called");
|
|
783
861
|
}
|
|
784
|
-
const { intervalType, properties } = serializedInterval;
|
|
862
|
+
const { intervalType, properties, stickiness, startSide, endSide } = serializedInterval;
|
|
785
863
|
const { start: startRebased, end: endRebased } = this.localSeqToRebasedInterval.get(localSeq) ?? this.computeRebasedPositions(localSeq);
|
|
786
864
|
const intervalId = properties?.[reservedIntervalIdKey];
|
|
787
865
|
const localInterval = this.localCollection?.idIntervalIndex.getIntervalById(intervalId);
|
|
@@ -791,6 +869,9 @@ class IntervalCollection extends client_utils_1.TypedEventEmitter {
|
|
|
791
869
|
intervalType,
|
|
792
870
|
sequenceNumber: this.client?.getCurrentSeq() ?? 0,
|
|
793
871
|
properties,
|
|
872
|
+
stickiness,
|
|
873
|
+
startSide,
|
|
874
|
+
endSide,
|
|
794
875
|
};
|
|
795
876
|
if (opName === "change" &&
|
|
796
877
|
(this.hasPendingChangeStart(intervalId) || this.hasPendingChangeEnd(intervalId))) {
|
|
@@ -810,7 +891,7 @@ class IntervalCollection extends client_utils_1.TypedEventEmitter {
|
|
|
810
891
|
(0, core_utils_1.assert)(localInterval instanceof intervals_1.SequenceInterval, 0x3a0 /* localInterval must be `SequenceInterval` when used with client */);
|
|
811
892
|
// The rebased op may place this interval's endpoints on different segments. Calling `changeInterval` here
|
|
812
893
|
// updates the local client's state to be consistent with the emitted op.
|
|
813
|
-
this.localCollection?.changeInterval(localInterval, startRebased, endRebased, undefined, localSeq);
|
|
894
|
+
this.localCollection?.changeInterval(localInterval, toOptionalSequencePlace(startRebased, startSide), toOptionalSequencePlace(endRebased, endSide), undefined, localSeq);
|
|
814
895
|
}
|
|
815
896
|
return rebased;
|
|
816
897
|
}
|
|
@@ -822,7 +903,7 @@ class IntervalCollection extends client_utils_1.TypedEventEmitter {
|
|
|
822
903
|
if (segoff.segment?.localRefs?.has(lref) !== true) {
|
|
823
904
|
return undefined;
|
|
824
905
|
}
|
|
825
|
-
const newSegoff = (0, merge_tree_1.getSlideToSegoff)(segoff);
|
|
906
|
+
const newSegoff = (0, merge_tree_1.getSlideToSegoff)(segoff, undefined, this.options.mergeTreeReferencesCanSlideToEndpoint);
|
|
826
907
|
const value = segoff.segment === newSegoff.segment && segoff.offset === newSegoff.offset
|
|
827
908
|
? undefined
|
|
828
909
|
: newSegoff;
|
|
@@ -865,7 +946,8 @@ class IntervalCollection extends client_utils_1.TypedEventEmitter {
|
|
|
865
946
|
}
|
|
866
947
|
if (needsStartUpdate) {
|
|
867
948
|
const props = interval.start.properties;
|
|
868
|
-
interval.start = (0, intervals_1.createPositionReferenceFromSegoff)(this.client, newStart, interval.start.refType, op, (0, intervals_1.startReferenceSlidingPreference)(interval.stickiness))
|
|
949
|
+
interval.start = (0, intervals_1.createPositionReferenceFromSegoff)(this.client, newStart, interval.start.refType, op, undefined, undefined, (0, intervals_1.startReferenceSlidingPreference)(interval.stickiness), (0, intervals_1.startReferenceSlidingPreference)(interval.stickiness) ===
|
|
950
|
+
merge_tree_1.SlidingPreference.BACKWARD);
|
|
869
951
|
if (props) {
|
|
870
952
|
interval.start.addProperties(props);
|
|
871
953
|
}
|
|
@@ -877,7 +959,8 @@ class IntervalCollection extends client_utils_1.TypedEventEmitter {
|
|
|
877
959
|
}
|
|
878
960
|
if (needsEndUpdate) {
|
|
879
961
|
const props = interval.end.properties;
|
|
880
|
-
interval.end = (0, intervals_1.createPositionReferenceFromSegoff)(this.client, newEnd, interval.end.refType, op, (0, intervals_1.endReferenceSlidingPreference)(interval.stickiness))
|
|
962
|
+
interval.end = (0, intervals_1.createPositionReferenceFromSegoff)(this.client, newEnd, interval.end.refType, op, undefined, undefined, (0, intervals_1.endReferenceSlidingPreference)(interval.stickiness), (0, intervals_1.endReferenceSlidingPreference)(interval.stickiness) ===
|
|
963
|
+
merge_tree_1.SlidingPreference.FORWARD);
|
|
881
964
|
if (props) {
|
|
882
965
|
interval.end.addProperties(props);
|
|
883
966
|
}
|
|
@@ -907,7 +990,7 @@ class IntervalCollection extends client_utils_1.TypedEventEmitter {
|
|
|
907
990
|
throw new telemetry_utils_1.LoggingError("attachSequence must be called");
|
|
908
991
|
}
|
|
909
992
|
this.localCollection.ensureSerializedId(serializedInterval);
|
|
910
|
-
const interval = this.localCollection.addInterval(serializedInterval.start, serializedInterval.end, serializedInterval.intervalType, serializedInterval.properties, op
|
|
993
|
+
const interval = this.localCollection.addInterval(toSequencePlace(serializedInterval.start, serializedInterval.startSide ?? Side.Before), toSequencePlace(serializedInterval.end, serializedInterval.endSide ?? Side.Before), serializedInterval.intervalType, serializedInterval.properties, op);
|
|
911
994
|
if (interval) {
|
|
912
995
|
if (this.onDeserialize) {
|
|
913
996
|
this.onDeserialize(interval);
|