@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"}
|
|
@@ -6,24 +6,43 @@
|
|
|
6
6
|
/* eslint-disable import/no-deprecated */
|
|
7
7
|
import { TypedEventEmitter } from "@fluid-internal/client-utils";
|
|
8
8
|
import { assert } from "@fluidframework/core-utils";
|
|
9
|
-
import { addProperties, createMap, getSlideToSegoff, MergeTreeDeltaType, ReferenceType, refTypeIncludesFlag, reservedRangeLabelsKey, UnassignedSequenceNumber, DetachedReferencePosition, UniversalSequenceNumber, } from "@fluidframework/merge-tree";
|
|
9
|
+
import { addProperties, createMap, getSlideToSegoff, MergeTreeDeltaType, ReferenceType, refTypeIncludesFlag, reservedRangeLabelsKey, UnassignedSequenceNumber, DetachedReferencePosition, UniversalSequenceNumber, SlidingPreference, } from "@fluidframework/merge-tree";
|
|
10
10
|
import { LoggingError, UsageError } from "@fluidframework/telemetry-utils";
|
|
11
11
|
import { v4 as uuid } from "uuid";
|
|
12
12
|
import { IntervalOpType, IntervalStickiness, IntervalType, SequenceInterval, createPositionReferenceFromSegoff, endReferenceSlidingPreference, startReferenceSlidingPreference, sequenceIntervalHelpers, createInterval, } from "./intervals";
|
|
13
13
|
import { EndpointIndex, OverlappingIntervalsIndex, createIdIntervalIndex, } from "./intervalIndex";
|
|
14
|
+
/**
|
|
15
|
+
* Defines a side relative to a character in a sequence.
|
|
16
|
+
*
|
|
17
|
+
* @remarks See {@link SequencePlace} for additional context on usage.
|
|
18
|
+
*/
|
|
19
|
+
export var Side;
|
|
20
|
+
(function (Side) {
|
|
21
|
+
Side[Side["Before"] = 0] = "Before";
|
|
22
|
+
Side[Side["After"] = 1] = "After";
|
|
23
|
+
})(Side || (Side = {}));
|
|
14
24
|
const reservedIntervalIdKey = "intervalId";
|
|
25
|
+
export function sidesFromStickiness(stickiness) {
|
|
26
|
+
const startSide = (stickiness & IntervalStickiness.START) !== 0 ? Side.After : Side.Before;
|
|
27
|
+
const endSide = (stickiness & IntervalStickiness.END) !== 0 ? Side.Before : Side.After;
|
|
28
|
+
return { startSide, endSide };
|
|
29
|
+
}
|
|
15
30
|
/**
|
|
16
31
|
* Decompress an interval after loading a summary from JSON. The exact format
|
|
17
32
|
* of this compression is unspecified and subject to change
|
|
18
33
|
*/
|
|
19
34
|
function decompressInterval(interval, label) {
|
|
35
|
+
const stickiness = interval[5] ?? IntervalStickiness.END;
|
|
36
|
+
const { startSide, endSide } = sidesFromStickiness(stickiness);
|
|
20
37
|
return {
|
|
21
38
|
start: interval[0],
|
|
22
39
|
end: interval[1],
|
|
23
40
|
sequenceNumber: interval[2],
|
|
24
41
|
intervalType: interval[3],
|
|
25
42
|
properties: { ...interval[4], [reservedRangeLabelsKey]: [label] },
|
|
26
|
-
stickiness
|
|
43
|
+
stickiness,
|
|
44
|
+
startSide,
|
|
45
|
+
endSide,
|
|
27
46
|
};
|
|
28
47
|
}
|
|
29
48
|
/**
|
|
@@ -32,7 +51,7 @@ function decompressInterval(interval, label) {
|
|
|
32
51
|
*/
|
|
33
52
|
function compressInterval(interval) {
|
|
34
53
|
const { start, end, sequenceNumber, intervalType, properties } = interval;
|
|
35
|
-
|
|
54
|
+
let base = [
|
|
36
55
|
start,
|
|
37
56
|
end,
|
|
38
57
|
sequenceNumber,
|
|
@@ -42,25 +61,56 @@ function compressInterval(interval) {
|
|
|
42
61
|
{ ...properties, [reservedRangeLabelsKey]: undefined },
|
|
43
62
|
];
|
|
44
63
|
if (interval.stickiness !== undefined && interval.stickiness !== IntervalStickiness.END) {
|
|
45
|
-
|
|
64
|
+
// reassignment to make it easier for typescript to reason about types
|
|
65
|
+
base = [...base, interval.stickiness];
|
|
46
66
|
}
|
|
47
67
|
return base;
|
|
48
68
|
}
|
|
69
|
+
export function endpointPosAndSide(start, end) {
|
|
70
|
+
const startIsPlainEndpoint = typeof start === "number" || start === "start" || start === "end";
|
|
71
|
+
const endIsPlainEndpoint = typeof end === "number" || end === "start" || end === "end";
|
|
72
|
+
const startSide = startIsPlainEndpoint ? Side.Before : start?.side;
|
|
73
|
+
const endSide = endIsPlainEndpoint ? Side.Before : end?.side;
|
|
74
|
+
const startPos = startIsPlainEndpoint ? start : start?.pos;
|
|
75
|
+
const endPos = endIsPlainEndpoint ? end : end?.pos;
|
|
76
|
+
return {
|
|
77
|
+
startSide,
|
|
78
|
+
endSide,
|
|
79
|
+
startPos,
|
|
80
|
+
endPos,
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
function toSequencePlace(pos, side) {
|
|
84
|
+
return typeof pos === "number" ? { pos, side } : pos;
|
|
85
|
+
}
|
|
86
|
+
function toOptionalSequencePlace(pos, side = Side.Before) {
|
|
87
|
+
return typeof pos === "number" ? { pos, side } : pos;
|
|
88
|
+
}
|
|
89
|
+
export function computeStickinessFromSide(startPos = -1, startSide = Side.Before, endPos = -1, endSide = Side.Before) {
|
|
90
|
+
let stickiness = IntervalStickiness.NONE;
|
|
91
|
+
if (startSide === Side.After || startPos === "start") {
|
|
92
|
+
stickiness |= IntervalStickiness.START;
|
|
93
|
+
}
|
|
94
|
+
if (endSide === Side.Before || endPos === "end") {
|
|
95
|
+
stickiness |= IntervalStickiness.END;
|
|
96
|
+
}
|
|
97
|
+
return stickiness;
|
|
98
|
+
}
|
|
49
99
|
export function createIntervalIndex() {
|
|
50
100
|
const helpers = {
|
|
51
|
-
compareEnds: (a, b) => a.end - b.end,
|
|
52
101
|
create: createInterval,
|
|
53
102
|
};
|
|
54
|
-
const lc = new LocalIntervalCollection(undefined, "", helpers);
|
|
103
|
+
const lc = new LocalIntervalCollection(undefined, "", helpers, {});
|
|
55
104
|
return lc;
|
|
56
105
|
}
|
|
57
106
|
export class LocalIntervalCollection {
|
|
58
|
-
constructor(client, label, helpers,
|
|
107
|
+
constructor(client, label, helpers, options,
|
|
59
108
|
/** Callback invoked each time one of the endpoints of an interval slides. */
|
|
60
109
|
onPositionChange) {
|
|
61
110
|
this.client = client;
|
|
62
111
|
this.label = label;
|
|
63
112
|
this.helpers = helpers;
|
|
113
|
+
this.options = options;
|
|
64
114
|
this.onPositionChange = onPositionChange;
|
|
65
115
|
this.overlappingIntervalsIndex = new OverlappingIntervalsIndex(client, helpers);
|
|
66
116
|
this.idIntervalIndex = createIdIntervalIndex();
|
|
@@ -118,12 +168,12 @@ export class LocalIntervalCollection {
|
|
|
118
168
|
this.removeIntervalFromIndexes(interval);
|
|
119
169
|
this.removeIntervalListeners(interval);
|
|
120
170
|
}
|
|
121
|
-
createInterval(start, end, intervalType, op
|
|
122
|
-
return this.helpers.create(this.label, start, end, this.client, intervalType, op, undefined,
|
|
171
|
+
createInterval(start, end, intervalType, op) {
|
|
172
|
+
return this.helpers.create(this.label, start, end, this.client, intervalType, op, undefined, this.options.mergeTreeReferencesCanSlideToEndpoint);
|
|
123
173
|
}
|
|
124
|
-
addInterval(start, end, intervalType, props, op
|
|
174
|
+
addInterval(start, end, intervalType, props, op) {
|
|
125
175
|
var _a;
|
|
126
|
-
const interval = this.createInterval(start, end, intervalType, op
|
|
176
|
+
const interval = this.createInterval(start, end, intervalType, op);
|
|
127
177
|
if (interval) {
|
|
128
178
|
if (!interval.properties) {
|
|
129
179
|
interval.properties = createMap();
|
|
@@ -160,7 +210,7 @@ export class LocalIntervalCollection {
|
|
|
160
210
|
this.addIntervalListeners(interval);
|
|
161
211
|
}
|
|
162
212
|
changeInterval(interval, start, end, op, localSeq) {
|
|
163
|
-
const newInterval = interval.modify(this.label, start, end, op, localSeq);
|
|
213
|
+
const newInterval = interval.modify(this.label, start, end, op, localSeq, this.options.mergeTreeReferencesCanSlideToEndpoint);
|
|
164
214
|
if (newInterval) {
|
|
165
215
|
this.removeExistingInterval(interval);
|
|
166
216
|
this.add(newInterval);
|
|
@@ -183,7 +233,7 @@ export class LocalIntervalCollection {
|
|
|
183
233
|
// either, so this must be special-cased.
|
|
184
234
|
return ref;
|
|
185
235
|
}
|
|
186
|
-
return this.client.createLocalReferencePosition(segment, ref.getOffset(), ReferenceType.Transient, ref.properties, ref.slidingPreference);
|
|
236
|
+
return this.client.createLocalReferencePosition(segment, ref.getOffset(), ReferenceType.Transient, ref.properties, ref.slidingPreference, ref.canSlideToEndpoint);
|
|
187
237
|
};
|
|
188
238
|
if (interval instanceof SequenceInterval) {
|
|
189
239
|
let previousInterval;
|
|
@@ -240,7 +290,6 @@ SequenceIntervalCollectionValueType._ops = makeOpsMap();
|
|
|
240
290
|
class IntervalCollectionFactory {
|
|
241
291
|
load(emitter, raw = [], options) {
|
|
242
292
|
const helpers = {
|
|
243
|
-
compareEnds: (a, b) => a.end - b.end,
|
|
244
293
|
create: createInterval,
|
|
245
294
|
};
|
|
246
295
|
const collection = new IntervalCollection(helpers, false, emitter, raw, options);
|
|
@@ -341,6 +390,9 @@ class IntervalCollectionIterator {
|
|
|
341
390
|
* {@inheritdoc IIntervalCollection}
|
|
342
391
|
*/
|
|
343
392
|
export class IntervalCollection extends TypedEventEmitter {
|
|
393
|
+
get attached() {
|
|
394
|
+
return !!this.localCollection;
|
|
395
|
+
}
|
|
344
396
|
/** @internal */
|
|
345
397
|
constructor(helpers, requiresClient, emitter, serializedIntervals, options = {}) {
|
|
346
398
|
super();
|
|
@@ -356,9 +408,6 @@ export class IntervalCollection extends TypedEventEmitter {
|
|
|
356
408
|
? serializedIntervals
|
|
357
409
|
: serializedIntervals.intervals.map((i) => decompressInterval(i, serializedIntervals.label));
|
|
358
410
|
}
|
|
359
|
-
get attached() {
|
|
360
|
-
return !!this.localCollection;
|
|
361
|
-
}
|
|
362
411
|
/**
|
|
363
412
|
* {@inheritdoc IIntervalCollection.attachIndex}
|
|
364
413
|
*/
|
|
@@ -391,6 +440,9 @@ export class IntervalCollection extends TypedEventEmitter {
|
|
|
391
440
|
if (!this.client) {
|
|
392
441
|
throw new LoggingError("mergeTree client must exist");
|
|
393
442
|
}
|
|
443
|
+
if (pos === "start" || pos === "end") {
|
|
444
|
+
return pos;
|
|
445
|
+
}
|
|
394
446
|
const { clientId } = this.client.getCollabWindow();
|
|
395
447
|
const { segment, offset } = this.client.getContainingSegment(pos, {
|
|
396
448
|
referenceSequenceNumber: seqNumberFrom,
|
|
@@ -398,7 +450,7 @@ export class IntervalCollection extends TypedEventEmitter {
|
|
|
398
450
|
}, localSeq);
|
|
399
451
|
// if segment is undefined, it slid off the string
|
|
400
452
|
assert(segment !== undefined, 0x54e /* No segment found */);
|
|
401
|
-
const segoff = getSlideToSegoff({ segment, offset }) ?? segment;
|
|
453
|
+
const segoff = getSlideToSegoff({ segment, offset }, undefined, this.options.mergeTreeReferencesCanSlideToEndpoint) ?? segment;
|
|
402
454
|
// case happens when rebasing op, but concurrently entire string has been deleted
|
|
403
455
|
if (segoff.segment === undefined || segoff.offset === undefined) {
|
|
404
456
|
return DetachedReferencePosition;
|
|
@@ -437,12 +489,18 @@ export class IntervalCollection extends TypedEventEmitter {
|
|
|
437
489
|
}
|
|
438
490
|
});
|
|
439
491
|
}
|
|
440
|
-
this.localCollection = new LocalIntervalCollection(client, label, this.helpers, (interval, previousInterval) => this.emitChange(interval, previousInterval, true, true));
|
|
492
|
+
this.localCollection = new LocalIntervalCollection(client, label, this.helpers, this.options, (interval, previousInterval) => this.emitChange(interval, previousInterval, true, true));
|
|
441
493
|
if (this.savedSerializedIntervals) {
|
|
442
494
|
for (const serializedInterval of this.savedSerializedIntervals) {
|
|
443
495
|
this.localCollection.ensureSerializedId(serializedInterval);
|
|
444
|
-
const { start, end, intervalType, properties,
|
|
445
|
-
const
|
|
496
|
+
const { start: startPos, end: endPos, intervalType, properties, startSide, endSide, } = serializedInterval;
|
|
497
|
+
const start = typeof startPos === "number" && startSide !== undefined
|
|
498
|
+
? { pos: startPos, side: startSide }
|
|
499
|
+
: startPos;
|
|
500
|
+
const end = typeof endPos === "number" && endSide !== undefined
|
|
501
|
+
? { pos: endPos, side: endSide }
|
|
502
|
+
: endPos;
|
|
503
|
+
const interval = this.helpers.create(label, start, end, client, intervalType, undefined, true, this.options.mergeTreeReferencesCanSlideToEndpoint);
|
|
446
504
|
if (properties) {
|
|
447
505
|
interval.addProperties(properties);
|
|
448
506
|
}
|
|
@@ -488,32 +546,44 @@ export class IntervalCollection extends TypedEventEmitter {
|
|
|
488
546
|
}
|
|
489
547
|
return this.localCollection.idIntervalIndex.getIntervalById(id);
|
|
490
548
|
}
|
|
549
|
+
assertStickinessEnabled(start, end) {
|
|
550
|
+
if (!(typeof start === "number" && typeof end === "number") &&
|
|
551
|
+
!this.options.intervalStickinessEnabled) {
|
|
552
|
+
throw new UsageError("attempted to set interval stickiness without enabling `intervalStickinessEnabled` feature flag");
|
|
553
|
+
}
|
|
554
|
+
}
|
|
491
555
|
/**
|
|
492
556
|
* {@inheritdoc IIntervalCollection.add}
|
|
493
557
|
*/
|
|
494
|
-
add(start, end, intervalType, props
|
|
558
|
+
add(start, end, intervalType, props) {
|
|
495
559
|
if (!this.localCollection) {
|
|
496
560
|
throw new LoggingError("attach must be called prior to adding intervals");
|
|
497
561
|
}
|
|
498
562
|
if (intervalType & IntervalType.Transient) {
|
|
499
563
|
throw new LoggingError("Can not add transient intervals");
|
|
500
564
|
}
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
565
|
+
const { startSide, endSide, startPos, endPos } = endpointPosAndSide(start, end);
|
|
566
|
+
assert(startPos !== undefined &&
|
|
567
|
+
endPos !== undefined &&
|
|
568
|
+
startSide !== undefined &&
|
|
569
|
+
endSide !== undefined, 0x793 /* start and end cannot be undefined because they were not passed in as undefined */);
|
|
570
|
+
const stickiness = computeStickinessFromSide(startPos, startSide, endPos, endSide);
|
|
571
|
+
this.assertStickinessEnabled(start, end);
|
|
572
|
+
const interval = this.localCollection.addInterval(toSequencePlace(startPos, startSide), toSequencePlace(endPos, endSide), intervalType, props);
|
|
505
573
|
if (interval) {
|
|
506
574
|
if (!this.isCollaborating && interval instanceof SequenceInterval) {
|
|
507
575
|
setSlideOnRemove(interval.start);
|
|
508
576
|
setSlideOnRemove(interval.end);
|
|
509
577
|
}
|
|
510
578
|
const serializedInterval = {
|
|
511
|
-
|
|
579
|
+
start: startPos,
|
|
580
|
+
end: endPos,
|
|
512
581
|
intervalType,
|
|
513
582
|
properties: interval.properties,
|
|
514
583
|
sequenceNumber: this.client?.getCurrentSeq() ?? 0,
|
|
515
|
-
start,
|
|
516
584
|
stickiness,
|
|
585
|
+
startSide,
|
|
586
|
+
endSide,
|
|
517
587
|
};
|
|
518
588
|
const localSeq = this.getNextLocalSeq();
|
|
519
589
|
this.localSeqToSerializedInterval.set(localSeq, serializedInterval);
|
|
@@ -613,8 +683,13 @@ export class IntervalCollection extends TypedEventEmitter {
|
|
|
613
683
|
setSlideOnRemove(newInterval.end);
|
|
614
684
|
}
|
|
615
685
|
const serializedInterval = interval.serialize();
|
|
616
|
-
|
|
617
|
-
|
|
686
|
+
const { startPos, startSide, endPos, endSide } = endpointPosAndSide(start, end);
|
|
687
|
+
const stickiness = computeStickinessFromSide(startPos, startSide, endPos, endSide);
|
|
688
|
+
serializedInterval.start = startPos;
|
|
689
|
+
serializedInterval.end = endPos;
|
|
690
|
+
serializedInterval.startSide = startSide;
|
|
691
|
+
serializedInterval.endSide = endSide;
|
|
692
|
+
serializedInterval.stickiness = stickiness;
|
|
618
693
|
// Emit a property bag containing only the ID, as we don't intend for this op to change any properties.
|
|
619
694
|
serializedInterval.properties = {
|
|
620
695
|
[reservedIntervalIdKey]: interval.getIntervalId(),
|
|
@@ -728,7 +803,7 @@ export class IntervalCollection extends TypedEventEmitter {
|
|
|
728
803
|
// If changeInterval gives us a new interval, work with that one. Otherwise keep working with
|
|
729
804
|
// the one we originally found in the tree.
|
|
730
805
|
newInterval =
|
|
731
|
-
this.localCollection.changeInterval(interval, start, end, op) ?? interval;
|
|
806
|
+
this.localCollection.changeInterval(interval, toOptionalSequencePlace(start, serializedInterval.startSide), toOptionalSequencePlace(end, serializedInterval.endSide), op) ?? interval;
|
|
732
807
|
}
|
|
733
808
|
const deltaProps = newInterval.addProperties(newProps, true, op.sequenceNumber);
|
|
734
809
|
if (this.onDeserialize) {
|
|
@@ -773,7 +848,7 @@ export class IntervalCollection extends TypedEventEmitter {
|
|
|
773
848
|
if (!this.attached) {
|
|
774
849
|
throw new LoggingError("attachSequence must be called");
|
|
775
850
|
}
|
|
776
|
-
const { intervalType, properties } = serializedInterval;
|
|
851
|
+
const { intervalType, properties, stickiness, startSide, endSide } = serializedInterval;
|
|
777
852
|
const { start: startRebased, end: endRebased } = this.localSeqToRebasedInterval.get(localSeq) ?? this.computeRebasedPositions(localSeq);
|
|
778
853
|
const intervalId = properties?.[reservedIntervalIdKey];
|
|
779
854
|
const localInterval = this.localCollection?.idIntervalIndex.getIntervalById(intervalId);
|
|
@@ -783,6 +858,9 @@ export class IntervalCollection extends TypedEventEmitter {
|
|
|
783
858
|
intervalType,
|
|
784
859
|
sequenceNumber: this.client?.getCurrentSeq() ?? 0,
|
|
785
860
|
properties,
|
|
861
|
+
stickiness,
|
|
862
|
+
startSide,
|
|
863
|
+
endSide,
|
|
786
864
|
};
|
|
787
865
|
if (opName === "change" &&
|
|
788
866
|
(this.hasPendingChangeStart(intervalId) || this.hasPendingChangeEnd(intervalId))) {
|
|
@@ -802,7 +880,7 @@ export class IntervalCollection extends TypedEventEmitter {
|
|
|
802
880
|
assert(localInterval instanceof SequenceInterval, 0x3a0 /* localInterval must be `SequenceInterval` when used with client */);
|
|
803
881
|
// The rebased op may place this interval's endpoints on different segments. Calling `changeInterval` here
|
|
804
882
|
// updates the local client's state to be consistent with the emitted op.
|
|
805
|
-
this.localCollection?.changeInterval(localInterval, startRebased, endRebased, undefined, localSeq);
|
|
883
|
+
this.localCollection?.changeInterval(localInterval, toOptionalSequencePlace(startRebased, startSide), toOptionalSequencePlace(endRebased, endSide), undefined, localSeq);
|
|
806
884
|
}
|
|
807
885
|
return rebased;
|
|
808
886
|
}
|
|
@@ -814,7 +892,7 @@ export class IntervalCollection extends TypedEventEmitter {
|
|
|
814
892
|
if (segoff.segment?.localRefs?.has(lref) !== true) {
|
|
815
893
|
return undefined;
|
|
816
894
|
}
|
|
817
|
-
const newSegoff = getSlideToSegoff(segoff);
|
|
895
|
+
const newSegoff = getSlideToSegoff(segoff, undefined, this.options.mergeTreeReferencesCanSlideToEndpoint);
|
|
818
896
|
const value = segoff.segment === newSegoff.segment && segoff.offset === newSegoff.offset
|
|
819
897
|
? undefined
|
|
820
898
|
: newSegoff;
|
|
@@ -857,7 +935,8 @@ export class IntervalCollection extends TypedEventEmitter {
|
|
|
857
935
|
}
|
|
858
936
|
if (needsStartUpdate) {
|
|
859
937
|
const props = interval.start.properties;
|
|
860
|
-
interval.start = createPositionReferenceFromSegoff(this.client, newStart, interval.start.refType, op, startReferenceSlidingPreference(interval.stickiness))
|
|
938
|
+
interval.start = createPositionReferenceFromSegoff(this.client, newStart, interval.start.refType, op, undefined, undefined, startReferenceSlidingPreference(interval.stickiness), startReferenceSlidingPreference(interval.stickiness) ===
|
|
939
|
+
SlidingPreference.BACKWARD);
|
|
861
940
|
if (props) {
|
|
862
941
|
interval.start.addProperties(props);
|
|
863
942
|
}
|
|
@@ -869,7 +948,8 @@ export class IntervalCollection extends TypedEventEmitter {
|
|
|
869
948
|
}
|
|
870
949
|
if (needsEndUpdate) {
|
|
871
950
|
const props = interval.end.properties;
|
|
872
|
-
interval.end = createPositionReferenceFromSegoff(this.client, newEnd, interval.end.refType, op, endReferenceSlidingPreference(interval.stickiness))
|
|
951
|
+
interval.end = createPositionReferenceFromSegoff(this.client, newEnd, interval.end.refType, op, undefined, undefined, endReferenceSlidingPreference(interval.stickiness), endReferenceSlidingPreference(interval.stickiness) ===
|
|
952
|
+
SlidingPreference.FORWARD);
|
|
873
953
|
if (props) {
|
|
874
954
|
interval.end.addProperties(props);
|
|
875
955
|
}
|
|
@@ -899,7 +979,7 @@ export class IntervalCollection extends TypedEventEmitter {
|
|
|
899
979
|
throw new LoggingError("attachSequence must be called");
|
|
900
980
|
}
|
|
901
981
|
this.localCollection.ensureSerializedId(serializedInterval);
|
|
902
|
-
const interval = this.localCollection.addInterval(serializedInterval.start, serializedInterval.end, serializedInterval.intervalType, serializedInterval.properties, op
|
|
982
|
+
const interval = this.localCollection.addInterval(toSequencePlace(serializedInterval.start, serializedInterval.startSide ?? Side.Before), toSequencePlace(serializedInterval.end, serializedInterval.endSide ?? Side.Before), serializedInterval.intervalType, serializedInterval.properties, op);
|
|
903
983
|
if (interval) {
|
|
904
984
|
if (this.onDeserialize) {
|
|
905
985
|
this.onDeserialize(interval);
|