@fluidframework/sequence 2.31.0 → 2.32.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 +4 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -2
- package/dist/index.js.map +1 -1
- package/dist/intervalCollection.d.ts +5 -9
- package/dist/intervalCollection.d.ts.map +1 -1
- package/dist/intervalCollection.js +38 -104
- package/dist/intervalCollection.js.map +1 -1
- package/dist/intervalCollectionMap.d.ts.map +1 -1
- package/dist/intervalCollectionMap.js +5 -4
- package/dist/intervalCollectionMap.js.map +1 -1
- package/dist/intervalIndex/endpointInRangeIndex.d.ts.map +1 -1
- package/dist/intervalIndex/endpointInRangeIndex.js +2 -2
- package/dist/intervalIndex/endpointInRangeIndex.js.map +1 -1
- package/dist/intervalIndex/endpointIndex.d.ts.map +1 -1
- package/dist/intervalIndex/endpointIndex.js +2 -3
- package/dist/intervalIndex/endpointIndex.js.map +1 -1
- package/dist/intervalIndex/idIntervalIndex.d.ts.map +1 -1
- package/dist/intervalIndex/idIntervalIndex.js +0 -7
- package/dist/intervalIndex/idIntervalIndex.js.map +1 -1
- package/dist/intervalIndex/index.d.ts +0 -1
- package/dist/intervalIndex/index.d.ts.map +1 -1
- package/dist/intervalIndex/index.js +1 -3
- package/dist/intervalIndex/index.js.map +1 -1
- package/dist/intervalIndex/overlappingIntervalsIndex.d.ts.map +1 -1
- package/dist/intervalIndex/overlappingIntervalsIndex.js +2 -2
- package/dist/intervalIndex/overlappingIntervalsIndex.js.map +1 -1
- package/dist/intervalIndex/startpointInRangeIndex.d.ts.map +1 -1
- package/dist/intervalIndex/startpointInRangeIndex.js +2 -2
- package/dist/intervalIndex/startpointInRangeIndex.js.map +1 -1
- package/dist/intervals/index.d.ts +2 -2
- package/dist/intervals/index.d.ts.map +1 -1
- package/dist/intervals/index.js +3 -1
- package/dist/intervals/index.js.map +1 -1
- package/dist/intervals/intervalUtils.d.ts +1 -5
- package/dist/intervals/intervalUtils.d.ts.map +1 -1
- package/dist/intervals/intervalUtils.js.map +1 -1
- package/dist/intervals/sequenceInterval.d.ts +20 -9
- package/dist/intervals/sequenceInterval.d.ts.map +1 -1
- package/dist/intervals/sequenceInterval.js +82 -27
- 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.map +1 -1
- package/dist/revertibles.js +8 -7
- package/dist/revertibles.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 +5 -9
- package/lib/intervalCollection.d.ts.map +1 -1
- package/lib/intervalCollection.js +39 -105
- package/lib/intervalCollection.js.map +1 -1
- package/lib/intervalCollectionMap.d.ts.map +1 -1
- package/lib/intervalCollectionMap.js +6 -5
- package/lib/intervalCollectionMap.js.map +1 -1
- package/lib/intervalIndex/endpointInRangeIndex.d.ts.map +1 -1
- package/lib/intervalIndex/endpointInRangeIndex.js +3 -3
- package/lib/intervalIndex/endpointInRangeIndex.js.map +1 -1
- package/lib/intervalIndex/endpointIndex.d.ts.map +1 -1
- package/lib/intervalIndex/endpointIndex.js +3 -4
- package/lib/intervalIndex/endpointIndex.js.map +1 -1
- package/lib/intervalIndex/idIntervalIndex.d.ts.map +1 -1
- package/lib/intervalIndex/idIntervalIndex.js +0 -7
- package/lib/intervalIndex/idIntervalIndex.js.map +1 -1
- package/lib/intervalIndex/index.d.ts +0 -1
- package/lib/intervalIndex/index.d.ts.map +1 -1
- package/lib/intervalIndex/index.js +0 -1
- package/lib/intervalIndex/index.js.map +1 -1
- package/lib/intervalIndex/overlappingIntervalsIndex.d.ts.map +1 -1
- package/lib/intervalIndex/overlappingIntervalsIndex.js +3 -3
- package/lib/intervalIndex/overlappingIntervalsIndex.js.map +1 -1
- package/lib/intervalIndex/startpointInRangeIndex.d.ts.map +1 -1
- package/lib/intervalIndex/startpointInRangeIndex.js +3 -3
- package/lib/intervalIndex/startpointInRangeIndex.js.map +1 -1
- package/lib/intervals/index.d.ts +2 -2
- package/lib/intervals/index.d.ts.map +1 -1
- package/lib/intervals/index.js +1 -1
- package/lib/intervals/index.js.map +1 -1
- package/lib/intervals/intervalUtils.d.ts +1 -5
- package/lib/intervals/intervalUtils.d.ts.map +1 -1
- package/lib/intervals/intervalUtils.js.map +1 -1
- package/lib/intervals/sequenceInterval.d.ts +20 -9
- package/lib/intervals/sequenceInterval.d.ts.map +1 -1
- package/lib/intervals/sequenceInterval.js +81 -28
- 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.map +1 -1
- package/lib/revertibles.js +8 -7
- package/lib/revertibles.js.map +1 -1
- package/package.json +20 -19
- package/src/index.ts +0 -1
- package/src/intervalCollection.ts +59 -144
- package/src/intervalCollectionMap.ts +5 -5
- package/src/intervalIndex/endpointInRangeIndex.ts +3 -15
- package/src/intervalIndex/endpointIndex.ts +3 -17
- package/src/intervalIndex/idIntervalIndex.ts +0 -7
- package/src/intervalIndex/index.ts +0 -1
- package/src/intervalIndex/overlappingIntervalsIndex.ts +3 -12
- package/src/intervalIndex/startpointInRangeIndex.ts +3 -15
- package/src/intervals/index.ts +2 -1
- package/src/intervals/intervalUtils.ts +0 -7
- package/src/intervals/sequenceInterval.ts +124 -33
- package/src/packageVersion.ts +1 -1
- package/src/revertibles.ts +8 -7
- package/dist/intervalIndex/overlappingSequenceIntervalsIndex.d.ts +0 -11
- package/dist/intervalIndex/overlappingSequenceIntervalsIndex.d.ts.map +0 -1
- package/dist/intervalIndex/overlappingSequenceIntervalsIndex.js +0 -38
- package/dist/intervalIndex/overlappingSequenceIntervalsIndex.js.map +0 -1
- package/lib/intervalIndex/overlappingSequenceIntervalsIndex.d.ts +0 -11
- package/lib/intervalIndex/overlappingSequenceIntervalsIndex.d.ts.map +0 -1
- package/lib/intervalIndex/overlappingSequenceIntervalsIndex.js +0 -34
- package/lib/intervalIndex/overlappingSequenceIntervalsIndex.js.map +0 -1
- package/src/intervalIndex/overlappingSequenceIntervalsIndex.ts +0 -80
|
@@ -3,8 +3,13 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
import { ISequencedDocumentMessage } from "@fluidframework/driver-definitions/internal";
|
|
6
|
-
import { Client, ISegment, LocalReferencePosition,
|
|
7
|
-
import { ISerializableInterval, ISerializedInterval, IntervalStickiness, IntervalType } from "./intervalUtils.js";
|
|
6
|
+
import { Client, ISegment, LocalReferencePosition, PropertySet, ReferenceType, SlidingPreference, SequencePlace, Side } from "@fluidframework/merge-tree/internal";
|
|
7
|
+
import { ISerializableInterval, ISerializedInterval, IntervalStickiness, IntervalType, type SerializedIntervalDelta } from "./intervalUtils.js";
|
|
8
|
+
export declare function getSerializedProperties(serializedInterval: ISerializedInterval | SerializedIntervalDelta): {
|
|
9
|
+
id: string;
|
|
10
|
+
labels: string[];
|
|
11
|
+
properties: PropertySet;
|
|
12
|
+
};
|
|
8
13
|
/**
|
|
9
14
|
* Interval implementation whose ends are associated with positions in a mutatable sequence.
|
|
10
15
|
* As such, when content is inserted into the middle of the interval, the interval expands to
|
|
@@ -98,7 +103,10 @@ export interface SequenceInterval extends ISerializableInterval {
|
|
|
98
103
|
overlapsPos(bstart: number, bend: number): boolean;
|
|
99
104
|
}
|
|
100
105
|
export declare class SequenceIntervalClass implements SequenceInterval {
|
|
106
|
+
#private;
|
|
101
107
|
private readonly client;
|
|
108
|
+
private readonly id;
|
|
109
|
+
private readonly label;
|
|
102
110
|
/**
|
|
103
111
|
* Start endpoint of this interval.
|
|
104
112
|
* @remarks This endpoint can be resolved into a character position using the SharedString it's a part of.
|
|
@@ -115,14 +123,11 @@ export declare class SequenceIntervalClass implements SequenceInterval {
|
|
|
115
123
|
/**
|
|
116
124
|
* {@inheritDoc ISerializableInterval.properties}
|
|
117
125
|
*/
|
|
118
|
-
properties: PropertySet
|
|
119
|
-
|
|
120
|
-
* {@inheritDoc ISerializableInterval.propertyManager}
|
|
121
|
-
*/
|
|
122
|
-
propertyManager?: PropertiesManager;
|
|
126
|
+
get properties(): Readonly<PropertySet>;
|
|
127
|
+
changeProperties(props: PropertySet | undefined, op?: ISequencedDocumentMessage): import("@fluidframework/merge-tree/internal").MapLike<unknown> | undefined;
|
|
123
128
|
/***/
|
|
124
129
|
get stickiness(): IntervalStickiness;
|
|
125
|
-
constructor(client: Client,
|
|
130
|
+
constructor(client: Client, id: string, label: string,
|
|
126
131
|
/**
|
|
127
132
|
* Start endpoint of this interval.
|
|
128
133
|
* @remarks This endpoint can be resolved into a character position using the SharedString it's a part of.
|
|
@@ -146,6 +151,10 @@ export declare class SequenceIntervalClass implements SequenceInterval {
|
|
|
146
151
|
* {@inheritDoc ISerializableInterval.serialize}
|
|
147
152
|
*/
|
|
148
153
|
serialize(): ISerializedInterval;
|
|
154
|
+
serializeDelta({ props, includeEndpoints, }: {
|
|
155
|
+
props: PropertySet | undefined;
|
|
156
|
+
includeEndpoints: boolean;
|
|
157
|
+
}): SerializedIntervalDelta;
|
|
149
158
|
/**
|
|
150
159
|
* {@inheritDoc IInterval.clone}
|
|
151
160
|
*/
|
|
@@ -182,10 +191,12 @@ export declare class SequenceIntervalClass implements SequenceInterval {
|
|
|
182
191
|
* {@inheritDoc IInterval.modify}
|
|
183
192
|
*/
|
|
184
193
|
modify(label: string, start: SequencePlace | undefined, end: SequencePlace | undefined, op?: ISequencedDocumentMessage, localSeq?: number, useNewSlidingBehavior?: boolean): SequenceIntervalClass;
|
|
194
|
+
ackPropertiesChange(newProps: PropertySet, op: ISequencedDocumentMessage): void;
|
|
185
195
|
}
|
|
186
196
|
export declare function createPositionReferenceFromSegoff(client: Client, segoff: {
|
|
187
197
|
segment: ISegment | undefined;
|
|
188
198
|
offset: number | undefined;
|
|
189
199
|
} | "start" | "end", refType: ReferenceType, op?: ISequencedDocumentMessage, localSeq?: number, fromSnapshot?: boolean, slidingPreference?: SlidingPreference, canSlideToEndpoint?: boolean): LocalReferencePosition;
|
|
190
|
-
export declare function
|
|
200
|
+
export declare function createTransientInterval(start: SequencePlace | undefined, end: SequencePlace | undefined, client: Client): SequenceIntervalClass;
|
|
201
|
+
export declare function createSequenceInterval(label: string, id: string, start: SequencePlace | undefined, end: SequencePlace | undefined, client: Client, intervalType: IntervalType, op?: ISequencedDocumentMessage, fromSnapshot?: boolean, useNewSlidingBehavior?: boolean, props?: PropertySet): SequenceIntervalClass;
|
|
191
202
|
//# sourceMappingURL=sequenceInterval.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sequenceInterval.d.ts","sourceRoot":"","sources":["../../src/intervals/sequenceInterval.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,EAAE,yBAAyB,EAAE,MAAM,6CAA6C,CAAC;AACxF,OAAO,EACN,MAAM,EACN,QAAQ,EACR,sBAAsB,
|
|
1
|
+
{"version":3,"file":"sequenceInterval.d.ts","sourceRoot":"","sources":["../../src/intervals/sequenceInterval.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,EAAE,yBAAyB,EAAE,MAAM,6CAA6C,CAAC;AACxF,OAAO,EACN,MAAM,EACN,QAAQ,EACR,sBAAsB,EAEtB,WAAW,EACX,aAAa,EACb,iBAAiB,EASjB,aAAa,EACb,IAAI,EAOJ,MAAM,qCAAqC,CAAC;AAM7C,OAAO,EACN,qBAAqB,EACrB,mBAAmB,EACnB,kBAAkB,EAClB,YAAY,EAGZ,KAAK,uBAAuB,EAC5B,MAAM,oBAAoB,CAAC;AAkC5B,wBAAgB,uBAAuB,CACtC,kBAAkB,EAAE,mBAAmB,GAAG,uBAAuB,GAC/D;IACF,EAAE,EAAE,MAAM,CAAC;IACX,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,MAAM,EAAE,MAAM,yBAUd;AAED,wBAAgB,sBAAsB,CACrC,KAAK,EAAE,MAAM,EACb,EAAE,EAAE,MAAM,EACV,KAAK,EAAE,aAAa,GAAG,SAAS,EAChC,GAAG,EAAE,aAAa,GAAG,SAAS,EAC9B,MAAM,EAAE,MAAM,EACd,YAAY,EAAE,YAAY,EAC1B,EAAE,CAAC,EAAE,yBAAyB,EAC9B,YAAY,CAAC,EAAE,OAAO,EACtB,qBAAqB,GAAE,OAAe,EACtC,KAAK,CAAC,EAAE,WAAW,GACjB,qBAAqB,CA2EvB"}
|
|
@@ -2,11 +2,18 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
6
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
7
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
8
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
9
|
+
};
|
|
10
|
+
var _SequenceIntervalClass_props;
|
|
5
11
|
/* eslint-disable no-bitwise */
|
|
6
12
|
import { assert } from "@fluidframework/core-utils/internal";
|
|
7
|
-
import { ReferenceType, SlidingPreference, compareReferencePositions, createDetachedLocalReferencePosition, createMap, getSlideToSegoff, maxReferencePosition, minReferencePosition, refTypeIncludesFlag, reservedRangeLabelsKey, Side, endpointPosAndSide, addProperties, copyPropertiesAndManager, } from "@fluidframework/merge-tree/internal";
|
|
13
|
+
import { PropertiesManager, ReferenceType, SlidingPreference, compareReferencePositions, createDetachedLocalReferencePosition, createMap, getSlideToSegoff, maxReferencePosition, minReferencePosition, refTypeIncludesFlag, reservedRangeLabelsKey, Side, endpointPosAndSide, addProperties, copyPropertiesAndManager, UnassignedSequenceNumber, UniversalSequenceNumber, } from "@fluidframework/merge-tree/internal";
|
|
8
14
|
import { UsageError } from "@fluidframework/telemetry-utils/internal";
|
|
9
|
-
import {
|
|
15
|
+
import { v4 as uuid } from "uuid";
|
|
16
|
+
import { computeStickinessFromSide } from "../intervalCollection.js";
|
|
10
17
|
import { IntervalType, endReferenceSlidingPreference, startReferenceSlidingPreference, } from "./intervalUtils.js";
|
|
11
18
|
function compareSides(sideA, sideB) {
|
|
12
19
|
if (sideA === sideB) {
|
|
@@ -29,14 +36,37 @@ function maxSide(sideA, sideB) {
|
|
|
29
36
|
}
|
|
30
37
|
return Side.After;
|
|
31
38
|
}
|
|
39
|
+
const reservedIntervalIdKey = "intervalId";
|
|
40
|
+
const legacyIdPrefix = "legacy";
|
|
41
|
+
export function getSerializedProperties(serializedInterval) {
|
|
42
|
+
const { [reservedIntervalIdKey]: maybeId, [reservedRangeLabelsKey]: labels, ...properties } = serializedInterval.properties ?? {};
|
|
43
|
+
// Create a non-unique ID based on start and end to be used on intervals that come from legacy clients
|
|
44
|
+
// without ID's.
|
|
45
|
+
const id = maybeId ?? `${legacyIdPrefix}${serializedInterval.start}-${serializedInterval.end}`;
|
|
46
|
+
return { id, labels, properties };
|
|
47
|
+
}
|
|
32
48
|
export class SequenceIntervalClass {
|
|
49
|
+
/**
|
|
50
|
+
* {@inheritDoc ISerializableInterval.properties}
|
|
51
|
+
*/
|
|
52
|
+
get properties() {
|
|
53
|
+
return __classPrivateFieldGet(this, _SequenceIntervalClass_props, "f").properties;
|
|
54
|
+
}
|
|
55
|
+
changeProperties(props, op) {
|
|
56
|
+
if (props !== undefined) {
|
|
57
|
+
__classPrivateFieldGet(this, _SequenceIntervalClass_props, "f").propertyManager ??= new PropertiesManager();
|
|
58
|
+
return __classPrivateFieldGet(this, _SequenceIntervalClass_props, "f").propertyManager.handleProperties({ props }, __classPrivateFieldGet(this, _SequenceIntervalClass_props, "f"), this.client.getCollabWindow().collaborating
|
|
59
|
+
? (op?.sequenceNumber ?? UnassignedSequenceNumber)
|
|
60
|
+
: UniversalSequenceNumber, op?.minimumSequenceNumber ?? UniversalSequenceNumber, this.client.getCollabWindow().collaborating);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
33
63
|
/***/
|
|
34
64
|
get stickiness() {
|
|
35
65
|
const startSegment = this.start.getSegment();
|
|
36
66
|
const endSegment = this.end.getSegment();
|
|
37
67
|
return computeStickinessFromSide(startSegment?.endpointType, this.startSide, endSegment?.endpointType, this.endSide);
|
|
38
68
|
}
|
|
39
|
-
constructor(client,
|
|
69
|
+
constructor(client, id, label,
|
|
40
70
|
/**
|
|
41
71
|
* Start endpoint of this interval.
|
|
42
72
|
* @remarks This endpoint can be resolved into a character position using the SharedString it's a part of.
|
|
@@ -48,17 +78,16 @@ export class SequenceIntervalClass {
|
|
|
48
78
|
*/
|
|
49
79
|
end, intervalType, props, startSide = Side.Before, endSide = Side.Before) {
|
|
50
80
|
this.client = client;
|
|
81
|
+
this.id = id;
|
|
82
|
+
this.label = label;
|
|
51
83
|
this.start = start;
|
|
52
84
|
this.end = end;
|
|
53
85
|
this.intervalType = intervalType;
|
|
54
86
|
this.startSide = startSide;
|
|
55
87
|
this.endSide = endSide;
|
|
56
|
-
|
|
57
|
-
* {@inheritDoc ISerializableInterval.properties}
|
|
58
|
-
*/
|
|
59
|
-
this.properties = createMap();
|
|
88
|
+
_SequenceIntervalClass_props.set(this, { properties: createMap() });
|
|
60
89
|
if (props) {
|
|
61
|
-
this.properties = addProperties(this.properties, props);
|
|
90
|
+
__classPrivateFieldGet(this, _SequenceIntervalClass_props, "f").properties = addProperties(__classPrivateFieldGet(this, _SequenceIntervalClass_props, "f").properties, props);
|
|
62
91
|
}
|
|
63
92
|
}
|
|
64
93
|
/**
|
|
@@ -90,28 +119,41 @@ export class SequenceIntervalClass {
|
|
|
90
119
|
* {@inheritDoc ISerializableInterval.serialize}
|
|
91
120
|
*/
|
|
92
121
|
serialize() {
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
122
|
+
return this.serializeDelta({
|
|
123
|
+
props: this.properties,
|
|
124
|
+
includeEndpoints: true,
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
serializeDelta({ props, includeEndpoints, }) {
|
|
128
|
+
const startSegment = this.start.getSegment();
|
|
129
|
+
const endSegment = this.end.getSegment();
|
|
130
|
+
const startPosition = includeEndpoints
|
|
131
|
+
? (startSegment?.endpointType ??
|
|
132
|
+
this.client.localReferencePositionToPosition(this.start))
|
|
133
|
+
: undefined;
|
|
134
|
+
const endPosition = includeEndpoints
|
|
135
|
+
? (endSegment?.endpointType ?? this.client.localReferencePositionToPosition(this.end))
|
|
136
|
+
: undefined;
|
|
137
|
+
return {
|
|
97
138
|
end: endPosition,
|
|
98
139
|
intervalType: this.intervalType,
|
|
99
140
|
sequenceNumber: this.client.getCurrentSeq(),
|
|
100
141
|
start: startPosition,
|
|
101
142
|
stickiness: this.stickiness,
|
|
102
|
-
startSide,
|
|
103
|
-
endSide,
|
|
143
|
+
startSide: includeEndpoints ? this.startSide : undefined,
|
|
144
|
+
endSide: includeEndpoints ? this.endSide : undefined,
|
|
145
|
+
properties: {
|
|
146
|
+
...props,
|
|
147
|
+
[reservedIntervalIdKey]: this.id,
|
|
148
|
+
[reservedRangeLabelsKey]: [this.label],
|
|
149
|
+
},
|
|
104
150
|
};
|
|
105
|
-
if (this.properties) {
|
|
106
|
-
serializedInterval.properties = addProperties(serializedInterval.properties, this.properties);
|
|
107
|
-
}
|
|
108
|
-
return serializedInterval;
|
|
109
151
|
}
|
|
110
152
|
/**
|
|
111
153
|
* {@inheritDoc IInterval.clone}
|
|
112
154
|
*/
|
|
113
155
|
clone() {
|
|
114
|
-
return new SequenceIntervalClass(this.client, this.start, this.end, this.intervalType, this.properties, this.startSide, this.endSide);
|
|
156
|
+
return new SequenceIntervalClass(this.client, this.id, this.label, this.start, this.end, this.intervalType, this.properties, this.startSide, this.endSide);
|
|
115
157
|
}
|
|
116
158
|
/**
|
|
117
159
|
* {@inheritDoc IInterval.compare}
|
|
@@ -171,9 +213,7 @@ export class SequenceIntervalClass {
|
|
|
171
213
|
* {@inheritDoc ISerializableInterval.getIntervalId}
|
|
172
214
|
*/
|
|
173
215
|
getIntervalId() {
|
|
174
|
-
|
|
175
|
-
assert(id !== undefined, 0x5e2 /* interval ID should not be undefined */);
|
|
176
|
-
return `${id}`;
|
|
216
|
+
return this.id;
|
|
177
217
|
}
|
|
178
218
|
/**
|
|
179
219
|
* {@inheritDoc IInterval.union}
|
|
@@ -195,7 +235,7 @@ export class SequenceIntervalClass {
|
|
|
195
235
|
else {
|
|
196
236
|
endSide = this.end === newEnd ? this.endSide : b.endSide;
|
|
197
237
|
}
|
|
198
|
-
return new SequenceIntervalClass(this.client, newStart, newEnd, this.intervalType, undefined, startSide, endSide);
|
|
238
|
+
return new SequenceIntervalClass(this.client, uuid(), this.label, newStart, newEnd, this.intervalType, undefined, startSide, endSide);
|
|
199
239
|
}
|
|
200
240
|
/**
|
|
201
241
|
* @returns whether this interval overlaps two numerical positions.
|
|
@@ -235,11 +275,19 @@ export class SequenceIntervalClass {
|
|
|
235
275
|
endRef.addProperties(this.end.properties);
|
|
236
276
|
}
|
|
237
277
|
}
|
|
238
|
-
const newInterval = new SequenceIntervalClass(this.client, startRef, endRef, this.intervalType, undefined, startSide ?? this.startSide, endSide ?? this.endSide);
|
|
239
|
-
copyPropertiesAndManager(this, newInterval);
|
|
278
|
+
const newInterval = new SequenceIntervalClass(this.client, this.id, this.label, startRef, endRef, this.intervalType, undefined, startSide ?? this.startSide, endSide ?? this.endSide);
|
|
279
|
+
copyPropertiesAndManager(__classPrivateFieldGet(this, _SequenceIntervalClass_props, "f"), __classPrivateFieldGet(newInterval, _SequenceIntervalClass_props, "f"));
|
|
240
280
|
return newInterval;
|
|
241
281
|
}
|
|
282
|
+
ackPropertiesChange(newProps, op) {
|
|
283
|
+
__classPrivateFieldGet(this, _SequenceIntervalClass_props, "f").propertyManager ??= new PropertiesManager();
|
|
284
|
+
// Let the propertyManager prune its pending change-properties set.
|
|
285
|
+
__classPrivateFieldGet(this, _SequenceIntervalClass_props, "f").propertyManager.ack(op.sequenceNumber, op.minimumSequenceNumber, {
|
|
286
|
+
props: newProps,
|
|
287
|
+
});
|
|
288
|
+
}
|
|
242
289
|
}
|
|
290
|
+
_SequenceIntervalClass_props = new WeakMap();
|
|
243
291
|
export function createPositionReferenceFromSegoff(client, segoff, refType, op, localSeq, fromSnapshot, slidingPreference, canSlideToEndpoint) {
|
|
244
292
|
if (segoff === "start" || segoff === "end") {
|
|
245
293
|
return client.createLocalReferencePosition(segoff, undefined, refType, undefined, slidingPreference, canSlideToEndpoint);
|
|
@@ -273,7 +321,7 @@ function createPositionReference(client, pos, refType, op, fromSnapshot, localSe
|
|
|
273
321
|
referenceSequenceNumber: op.referenceSequenceNumber,
|
|
274
322
|
clientId: op.clientId,
|
|
275
323
|
});
|
|
276
|
-
segoff = getSlideToSegoff(segoff, slidingPreference, useNewSlidingBehavior);
|
|
324
|
+
segoff = getSlideToSegoff(segoff, slidingPreference, undefined, useNewSlidingBehavior);
|
|
277
325
|
}
|
|
278
326
|
}
|
|
279
327
|
else {
|
|
@@ -285,7 +333,10 @@ function createPositionReference(client, pos, refType, op, fromSnapshot, localSe
|
|
|
285
333
|
}
|
|
286
334
|
return createPositionReferenceFromSegoff(client, segoff, refType, op, localSeq, fromSnapshot, slidingPreference, exclusive);
|
|
287
335
|
}
|
|
288
|
-
export function
|
|
336
|
+
export function createTransientInterval(start, end, client) {
|
|
337
|
+
return createSequenceInterval("transient", uuid(), start, end, client, IntervalType.Transient);
|
|
338
|
+
}
|
|
339
|
+
export function createSequenceInterval(label, id, start, end, client, intervalType, op, fromSnapshot, useNewSlidingBehavior = false, props) {
|
|
289
340
|
const { startPos, startSide, endPos, endSide } = endpointPosAndSide(start ?? "start", end ?? "end");
|
|
290
341
|
assert(startPos !== undefined &&
|
|
291
342
|
endPos !== undefined &&
|
|
@@ -318,7 +369,9 @@ export function createSequenceInterval(label, start, end, client, intervalType,
|
|
|
318
369
|
};
|
|
319
370
|
startLref.addProperties(rangeProp);
|
|
320
371
|
endLref.addProperties(rangeProp);
|
|
321
|
-
const ival = new SequenceIntervalClass(client, startLref, endLref, intervalType,
|
|
372
|
+
const ival = new SequenceIntervalClass(client, id, label, startLref, endLref, intervalType, props === undefined
|
|
373
|
+
? undefined
|
|
374
|
+
: { ...props, [reservedIntervalIdKey]: undefined, [reservedRangeLabelsKey]: undefined }, startSide, endSide);
|
|
322
375
|
return ival;
|
|
323
376
|
}
|
|
324
377
|
//# sourceMappingURL=sequenceInterval.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sequenceInterval.js","sourceRoot":"","sources":["../../src/intervals/sequenceInterval.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,+BAA+B;AAE/B,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAE7D,OAAO,EAMN,aAAa,EACb,iBAAiB,EACjB,yBAAyB,EACzB,oCAAoC,EACpC,SAAS,EACT,gBAAgB,EAChB,oBAAoB,EACpB,oBAAoB,EACpB,mBAAmB,EACnB,sBAAsB,EAEtB,IAAI,EACJ,kBAAkB,EAClB,aAAa,EACb,wBAAwB,GAExB,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAE,MAAM,0CAA0C,CAAC;AAEtE,OAAO,EACN,yBAAyB,EACzB,qBAAqB,EACrB,mBAAmB,GACnB,MAAM,0BAA0B,CAAC;AAElC,OAAO,EAIN,YAAY,EACZ,6BAA6B,EAC7B,+BAA+B,GAC/B,MAAM,oBAAoB,CAAC;AAE5B,SAAS,YAAY,CAAC,KAAW,EAAE,KAAW;IAC7C,IAAI,KAAK,KAAK,KAAK,EAAE,CAAC;QACrB,OAAO,CAAC,CAAC;IACV,CAAC;IAED,IAAI,KAAK,KAAK,IAAI,CAAC,MAAM,EAAE,CAAC;QAC3B,OAAO,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,EACT,OAAO,EACP,YAAY,EACZ,SAAS,EACT,SAAS,EACT,OAAO,CACP,CAAC;IACF,OAAO,IAAI,CAAC;AACb,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/* eslint-disable no-bitwise */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport { ISequencedDocumentMessage } from \"@fluidframework/driver-definitions/internal\";\nimport {\n\tClient,\n\tISegment,\n\tLocalReferencePosition,\n\tPropertiesManager,\n\tPropertySet,\n\tReferenceType,\n\tSlidingPreference,\n\tcompareReferencePositions,\n\tcreateDetachedLocalReferencePosition,\n\tcreateMap,\n\tgetSlideToSegoff,\n\tmaxReferencePosition,\n\tminReferencePosition,\n\trefTypeIncludesFlag,\n\treservedRangeLabelsKey,\n\tSequencePlace,\n\tSide,\n\tendpointPosAndSide,\n\taddProperties,\n\tcopyPropertiesAndManager,\n\ttype ISegmentInternal,\n} from \"@fluidframework/merge-tree/internal\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\n\nimport {\n\tcomputeStickinessFromSide,\n\treservedIntervalIdKey,\n\tsidesFromStickiness,\n} from \"../intervalCollection.js\";\n\nimport {\n\tISerializableInterval,\n\tISerializedInterval,\n\tIntervalStickiness,\n\tIntervalType,\n\tendReferenceSlidingPreference,\n\tstartReferenceSlidingPreference,\n} from \"./intervalUtils.js\";\n\nfunction compareSides(sideA: Side, sideB: Side): number {\n\tif (sideA === sideB) {\n\t\treturn 0;\n\t}\n\n\tif (sideA === Side.Before) {\n\t\treturn 1;\n\t}\n\n\treturn -1;\n}\n\nfunction minSide(sideA: Side, sideB: Side): Side {\n\tif (sideA === Side.After && sideB === Side.After) {\n\t\treturn Side.After;\n\t}\n\n\treturn Side.Before;\n}\n\nfunction maxSide(sideA: Side, sideB: Side): Side {\n\tif (sideA === Side.Before && sideB === Side.Before) {\n\t\treturn Side.Before;\n\t}\n\n\treturn Side.After;\n}\n\n/**\n * Interval implementation whose ends are associated with positions in a mutatable sequence.\n * As such, when content is inserted into the middle of the interval, the interval expands to\n * include that content.\n *\n * @remarks The endpoints' positions should be treated exclusively to get\n * reasonable behavior. E.g., an interval referring to \"hello\" in \"hello world\"\n * should have a start position of 0 and an end position of 5.\n *\n * To see why, consider what happens if \"llo wor\" is removed from the string to make \"held\".\n * The interval's startpoint remains on the \"h\" (it isn't altered), but the interval's endpoint\n * slides forward to the next unremoved position, which is the \"l\" in \"held\".\n * Users would generally expect the interval to now refer to \"he\" (as it is the subset of content\n * remaining after the removal), hence the \"l\" should be excluded.\n * If the interval endpoint was treated inclusively, the interval would now refer to \"hel\", which\n * is undesirable.\n *\n * Since the endpoints of an interval are treated exclusively but cannot be greater\n * than or equal to the length of the associated sequence, there exist special\n * endpoint segments, \"start\" and \"end\", which represent the position immediately\n * before or immediately after the string respectively.\n *\n * If a `SequenceInterval` is created on a sequence with the\n * `mergeTreeReferencesCanSlideToEndpoint` feature flag set to true, the endpoints\n * of the interval that are exclusive will have the ability to slide to these\n * special endpoint segments.\n * @alpha\n * @legacy\n */\nexport interface SequenceInterval extends ISerializableInterval {\n\treadonly start: LocalReferencePosition;\n\t/**\n\t * End endpoint of this interval.\n\t * @remarks This endpoint can be resolved into a character position using the SharedString it's a part of.\n\t */\n\treadonly end: LocalReferencePosition;\n\treadonly intervalType: IntervalType;\n\treadonly startSide: Side;\n\treadonly endSide: Side;\n\treadonly stickiness: IntervalStickiness;\n\n\t/**\n\t * @returns a new interval object with identical semantics.\n\t */\n\tclone(): SequenceInterval;\n\t/**\n\t * Compares this interval to `b` with standard comparator semantics:\n\t * - returns -1 if this is less than `b`\n\t * - returns 1 if this is greater than `b`\n\t * - returns 0 if this is equivalent to `b`\n\t * @param b - Interval to compare against\n\t */\n\tcompare(b: SequenceInterval): number;\n\t/**\n\t * Compares the start endpoint of this interval to `b`'s start endpoint.\n\t * Standard comparator semantics apply.\n\t * @param b - Interval to compare against\n\t */\n\tcompareStart(b: SequenceInterval): number;\n\t/**\n\t * Compares the end endpoint of this interval to `b`'s end endpoint.\n\t * Standard comparator semantics apply.\n\t * @param b - Interval to compare against\n\t */\n\tcompareEnd(b: SequenceInterval): number;\n\t/**\n\t * Modifies one or more of the endpoints of this interval, returning a new interval representing the result.\n\t */\n\tmodify(\n\t\tlabel: string,\n\t\tstart: SequencePlace | undefined,\n\t\tend: SequencePlace | undefined,\n\t\top?: ISequencedDocumentMessage,\n\t\tlocalSeq?: number,\n\t\tuseNewSlidingBehavior?: boolean,\n\t): SequenceInterval | undefined;\n\t/**\n\t * @returns whether this interval overlaps with `b`.\n\t * Intervals are considered to overlap if their intersection is non-empty.\n\t */\n\toverlaps(b: SequenceInterval): boolean;\n\t/**\n\t * Unions this interval with `b`, returning a new interval.\n\t * The union operates as a convex hull, i.e. if the two intervals are disjoint, the return value includes\n\t * intermediate values between the two intervals.\n\t */\n\tunion(b: SequenceInterval): SequenceInterval;\n\n\t/**\n\t * Subscribes to position change events on this interval if there are no current listeners.\n\t */\n\taddPositionChangeListeners(\n\t\tbeforePositionChange: () => void,\n\t\tafterPositionChange: () => void,\n\t): void;\n\n\t/**\n\t * Removes the currently subscribed position change listeners.\n\t */\n\tremovePositionChangeListeners(): void;\n\n\t/**\n\t * @returns whether this interval overlaps two numerical positions.\n\t */\n\toverlapsPos(bstart: number, bend: number): boolean;\n}\n\nexport class SequenceIntervalClass implements SequenceInterval {\n\t/**\n\t * {@inheritDoc ISerializableInterval.properties}\n\t */\n\tpublic properties: PropertySet = createMap<any>();\n\n\t/**\n\t * {@inheritDoc ISerializableInterval.propertyManager}\n\t */\n\tpublic propertyManager?: PropertiesManager;\n\n\t/***/\n\tpublic get stickiness(): IntervalStickiness {\n\t\tconst startSegment: ISegmentInternal | undefined = this.start.getSegment();\n\t\tconst endSegment: ISegmentInternal | undefined = this.end.getSegment();\n\t\treturn computeStickinessFromSide(\n\t\t\tstartSegment?.endpointType,\n\t\t\tthis.startSide,\n\t\t\tendSegment?.endpointType,\n\t\t\tthis.endSide,\n\t\t);\n\t}\n\n\tconstructor(\n\t\tprivate readonly client: Client,\n\t\t/**\n\t\t * Start endpoint of this interval.\n\t\t * @remarks This endpoint can be resolved into a character position using the SharedString it's a part of.\n\t\t */\n\t\tpublic start: LocalReferencePosition,\n\t\t/**\n\t\t * End endpoint of this interval.\n\t\t * @remarks This endpoint can be resolved into a character position using the SharedString it's a part of.\n\t\t */\n\t\tpublic end: LocalReferencePosition,\n\t\tpublic intervalType: IntervalType,\n\t\tprops?: PropertySet,\n\t\tpublic readonly startSide: Side = Side.Before,\n\t\tpublic readonly endSide: Side = Side.Before,\n\t) {\n\t\tif (props) {\n\t\t\tthis.properties = addProperties(this.properties, props);\n\t\t}\n\t}\n\n\tprivate callbacks?: Record<\"beforePositionChange\" | \"afterPositionChange\", () => void>;\n\n\t/**\n\t * Subscribes to position change events on this interval if there are no current listeners.\n\t */\n\tpublic addPositionChangeListeners(\n\t\tbeforePositionChange: () => void,\n\t\tafterPositionChange: () => void,\n\t): void {\n\t\tif (this.callbacks === undefined) {\n\t\t\tthis.callbacks = {\n\t\t\t\tbeforePositionChange,\n\t\t\t\tafterPositionChange,\n\t\t\t};\n\n\t\t\tconst startCbs = (this.start.callbacks ??= {});\n\t\t\tconst endCbs = (this.end.callbacks ??= {});\n\t\t\tstartCbs.beforeSlide = endCbs.beforeSlide = beforePositionChange;\n\t\t\tstartCbs.afterSlide = endCbs.afterSlide = afterPositionChange;\n\t\t}\n\t}\n\n\t/**\n\t * Removes the currently subscribed position change listeners.\n\t */\n\tpublic removePositionChangeListeners(): void {\n\t\tif (this.callbacks) {\n\t\t\tthis.callbacks = undefined;\n\t\t\tthis.start.callbacks = undefined;\n\t\t\tthis.end.callbacks = undefined;\n\t\t}\n\t}\n\n\t/**\n\t * {@inheritDoc ISerializableInterval.serialize}\n\t */\n\tpublic serialize(): ISerializedInterval {\n\t\tconst startPosition = this.client.localReferencePositionToPosition(this.start);\n\t\tconst endPosition = this.client.localReferencePositionToPosition(this.end);\n\t\tconst { startSide, endSide } = sidesFromStickiness(this.stickiness);\n\t\tconst serializedInterval: ISerializedInterval = {\n\t\t\tend: endPosition,\n\t\t\tintervalType: this.intervalType,\n\t\t\tsequenceNumber: this.client.getCurrentSeq(),\n\t\t\tstart: startPosition,\n\t\t\tstickiness: this.stickiness,\n\t\t\tstartSide,\n\t\t\tendSide,\n\t\t};\n\n\t\tif (this.properties) {\n\t\t\tserializedInterval.properties = addProperties(\n\t\t\t\tserializedInterval.properties,\n\t\t\t\tthis.properties,\n\t\t\t);\n\t\t}\n\n\t\treturn serializedInterval;\n\t}\n\n\t/**\n\t * {@inheritDoc IInterval.clone}\n\t */\n\tpublic clone(): SequenceIntervalClass {\n\t\treturn new SequenceIntervalClass(\n\t\t\tthis.client,\n\t\t\tthis.start,\n\t\t\tthis.end,\n\t\t\tthis.intervalType,\n\t\t\tthis.properties,\n\t\t\tthis.startSide,\n\t\t\tthis.endSide,\n\t\t);\n\t}\n\n\t/**\n\t * {@inheritDoc IInterval.compare}\n\t */\n\tpublic compare(b: SequenceInterval) {\n\t\tconst startResult = this.compareStart(b);\n\t\tif (startResult === 0) {\n\t\t\tconst endResult = this.compareEnd(b);\n\t\t\tif (endResult === 0) {\n\t\t\t\tconst thisId = this.getIntervalId();\n\t\t\t\tif (thisId) {\n\t\t\t\t\tconst bId = b.getIntervalId();\n\t\t\t\t\tif (bId) {\n\t\t\t\t\t\treturn thisId > bId ? 1 : thisId < bId ? -1 : 0;\n\t\t\t\t\t}\n\t\t\t\t\treturn 0;\n\t\t\t\t}\n\t\t\t\treturn 0;\n\t\t\t} else {\n\t\t\t\treturn endResult;\n\t\t\t}\n\t\t} else {\n\t\t\treturn startResult;\n\t\t}\n\t}\n\n\t/**\n\t * {@inheritDoc IInterval.compareStart}\n\t */\n\tpublic compareStart(b: SequenceInterval) {\n\t\tconst dist = compareReferencePositions(this.start, b.start);\n\n\t\tif (dist === 0) {\n\t\t\treturn compareSides(this.startSide, b.startSide);\n\t\t}\n\n\t\treturn dist;\n\t}\n\n\t/**\n\t * {@inheritDoc IInterval.compareEnd}\n\t */\n\tpublic compareEnd(b: SequenceInterval): number {\n\t\tconst dist = compareReferencePositions(this.end, b.end);\n\n\t\tif (dist === 0) {\n\t\t\treturn compareSides(b.endSide, this.endSide);\n\t\t}\n\n\t\treturn dist;\n\t}\n\n\t/**\n\t * {@inheritDoc IInterval.overlaps}\n\t */\n\tpublic overlaps(b: SequenceInterval) {\n\t\tconst result =\n\t\t\tcompareReferencePositions(this.start, b.end) <= 0 &&\n\t\t\tcompareReferencePositions(this.end, b.start) >= 0;\n\t\treturn result;\n\t}\n\n\t/**\n\t * {@inheritDoc ISerializableInterval.getIntervalId}\n\t */\n\tpublic getIntervalId(): string {\n\t\tconst id = this.properties?.[reservedIntervalIdKey];\n\t\tassert(id !== undefined, 0x5e2 /* interval ID should not be undefined */);\n\t\treturn `${id}`;\n\t}\n\n\t/**\n\t * {@inheritDoc IInterval.union}\n\t */\n\tpublic union(b: SequenceInterval) {\n\t\tconst newStart = minReferencePosition(this.start, b.start);\n\t\tconst newEnd = maxReferencePosition(this.end, b.end);\n\n\t\tlet startSide: Side;\n\n\t\tif (this.start === b.start) {\n\t\t\tstartSide = minSide(this.startSide, b.startSide);\n\t\t} else {\n\t\t\tstartSide = this.start === newStart ? this.startSide : b.startSide;\n\t\t}\n\n\t\tlet endSide: Side;\n\n\t\tif (this.end === b.end) {\n\t\t\tendSide = maxSide(this.endSide, b.endSide);\n\t\t} else {\n\t\t\tendSide = this.end === newEnd ? this.endSide : b.endSide;\n\t\t}\n\n\t\treturn new SequenceIntervalClass(\n\t\t\tthis.client,\n\t\t\tnewStart,\n\t\t\tnewEnd,\n\t\t\tthis.intervalType,\n\t\t\tundefined,\n\t\t\tstartSide,\n\t\t\tendSide,\n\t\t);\n\t}\n\n\t/**\n\t * @returns whether this interval overlaps two numerical positions.\n\t */\n\tpublic overlapsPos(bstart: number, bend: number) {\n\t\tconst startPos = this.client.localReferencePositionToPosition(this.start);\n\t\tconst endPos = this.client.localReferencePositionToPosition(this.end);\n\t\treturn endPos > bstart && startPos < bend;\n\t}\n\n\t/**\n\t * {@inheritDoc IInterval.modify}\n\t */\n\tpublic modify(\n\t\tlabel: string,\n\t\tstart: SequencePlace | undefined,\n\t\tend: SequencePlace | undefined,\n\t\top?: ISequencedDocumentMessage,\n\t\tlocalSeq?: number,\n\t\tuseNewSlidingBehavior: boolean = false,\n\t) {\n\t\tconst { startSide, endSide, startPos, endPos } = endpointPosAndSide(start, end);\n\t\tconst startSegment: ISegmentInternal | undefined = this.start.getSegment();\n\t\tconst endSegment: ISegmentInternal | undefined = this.end.getSegment();\n\t\tconst stickiness = computeStickinessFromSide(\n\t\t\tstartPos ?? startSegment?.endpointType,\n\t\t\tstartSide ?? this.startSide,\n\t\t\tendPos ?? endSegment?.endpointType,\n\t\t\tendSide ?? this.endSide,\n\t\t);\n\t\tconst getRefType = (baseType: ReferenceType): ReferenceType => {\n\t\t\tlet refType = baseType;\n\t\t\tif (op === undefined) {\n\t\t\t\trefType &= ~ReferenceType.SlideOnRemove;\n\t\t\t\trefType |= ReferenceType.StayOnRemove;\n\t\t\t}\n\t\t\treturn refType;\n\t\t};\n\n\t\tlet startRef = this.start;\n\t\tif (startPos !== undefined) {\n\t\t\tstartRef = createPositionReference(\n\t\t\t\tthis.client,\n\t\t\t\tstartPos,\n\t\t\t\tgetRefType(this.start.refType),\n\t\t\t\top,\n\t\t\t\tundefined,\n\t\t\t\tlocalSeq,\n\t\t\t\tstartReferenceSlidingPreference(stickiness),\n\t\t\t\tstartReferenceSlidingPreference(stickiness) === SlidingPreference.BACKWARD,\n\t\t\t\tuseNewSlidingBehavior,\n\t\t\t);\n\t\t\tif (this.start.properties) {\n\t\t\t\tstartRef.addProperties(this.start.properties);\n\t\t\t}\n\t\t}\n\n\t\tlet endRef = this.end;\n\t\tif (endPos !== undefined) {\n\t\t\tendRef = createPositionReference(\n\t\t\t\tthis.client,\n\t\t\t\tendPos,\n\t\t\t\tgetRefType(this.end.refType),\n\t\t\t\top,\n\t\t\t\tundefined,\n\t\t\t\tlocalSeq,\n\t\t\t\tendReferenceSlidingPreference(stickiness),\n\t\t\t\tendReferenceSlidingPreference(stickiness) === SlidingPreference.FORWARD,\n\t\t\t\tuseNewSlidingBehavior,\n\t\t\t);\n\t\t\tif (this.end.properties) {\n\t\t\t\tendRef.addProperties(this.end.properties);\n\t\t\t}\n\t\t}\n\n\t\tconst newInterval = new SequenceIntervalClass(\n\t\t\tthis.client,\n\t\t\tstartRef,\n\t\t\tendRef,\n\t\t\tthis.intervalType,\n\t\t\tundefined,\n\t\t\tstartSide ?? this.startSide,\n\t\t\tendSide ?? this.endSide,\n\t\t);\n\t\tcopyPropertiesAndManager(this, newInterval);\n\t\treturn newInterval;\n\t}\n}\n\nexport function createPositionReferenceFromSegoff(\n\tclient: Client,\n\tsegoff: { segment: ISegment | undefined; offset: number | undefined } | \"start\" | \"end\",\n\trefType: ReferenceType,\n\top?: ISequencedDocumentMessage,\n\tlocalSeq?: number,\n\tfromSnapshot?: boolean,\n\tslidingPreference?: SlidingPreference,\n\tcanSlideToEndpoint?: boolean,\n): LocalReferencePosition {\n\tif (segoff === \"start\" || segoff === \"end\") {\n\t\treturn client.createLocalReferencePosition(\n\t\t\tsegoff,\n\t\t\tundefined,\n\t\t\trefType,\n\t\t\tundefined,\n\t\t\tslidingPreference,\n\t\t\tcanSlideToEndpoint,\n\t\t);\n\t}\n\n\tif (segoff.segment) {\n\t\tconst ref = client.createLocalReferencePosition(\n\t\t\tsegoff.segment,\n\t\t\tsegoff.offset,\n\t\t\trefType,\n\t\t\tundefined,\n\t\t\tslidingPreference,\n\t\t\tcanSlideToEndpoint,\n\t\t);\n\t\treturn ref;\n\t}\n\n\t// Creating references on detached segments is allowed for:\n\t// - Transient segments\n\t// - References coming from a remote client (location may have been concurrently removed)\n\t// - References being rebased to a new sequence number\n\t// (segment they originally referred to may have been removed with no suitable replacement)\n\tif (\n\t\t!op &&\n\t\t!localSeq &&\n\t\t!fromSnapshot &&\n\t\t!refTypeIncludesFlag(refType, ReferenceType.Transient)\n\t) {\n\t\tthrow new UsageError(\"Non-transient references need segment\");\n\t}\n\n\treturn createDetachedLocalReferencePosition(slidingPreference, refType);\n}\n\nfunction createPositionReference(\n\tclient: Client,\n\tpos: number | \"start\" | \"end\",\n\trefType: ReferenceType,\n\top?: ISequencedDocumentMessage,\n\tfromSnapshot?: boolean,\n\tlocalSeq?: number,\n\tslidingPreference?: SlidingPreference,\n\texclusive: boolean = false,\n\tuseNewSlidingBehavior: boolean = false,\n): LocalReferencePosition {\n\tlet segoff;\n\n\tif (op) {\n\t\tassert(\n\t\t\t(refType & ReferenceType.SlideOnRemove) !== 0,\n\t\t\t0x2f5 /* op create references must be SlideOnRemove */,\n\t\t);\n\t\tif (pos === \"start\" || pos === \"end\") {\n\t\t\tsegoff = pos;\n\t\t} else {\n\t\t\tsegoff = client.getContainingSegment(pos, {\n\t\t\t\treferenceSequenceNumber: op.referenceSequenceNumber,\n\t\t\t\tclientId: op.clientId,\n\t\t\t});\n\t\t\tsegoff = getSlideToSegoff(segoff, slidingPreference, useNewSlidingBehavior);\n\t\t}\n\t} else {\n\t\tassert(\n\t\t\t(refType & ReferenceType.SlideOnRemove) === 0 || !!fromSnapshot,\n\t\t\t0x2f6 /* SlideOnRemove references must be op created */,\n\t\t);\n\t\tsegoff =\n\t\t\tpos === \"start\" || pos === \"end\"\n\t\t\t\t? pos\n\t\t\t\t: client.getContainingSegment(pos, undefined, localSeq);\n\t}\n\n\treturn createPositionReferenceFromSegoff(\n\t\tclient,\n\t\tsegoff,\n\t\trefType,\n\t\top,\n\t\tlocalSeq,\n\t\tfromSnapshot,\n\t\tslidingPreference,\n\t\texclusive,\n\t);\n}\n\nexport function createSequenceInterval(\n\tlabel: string,\n\tstart: SequencePlace | undefined,\n\tend: SequencePlace | undefined,\n\tclient: Client,\n\tintervalType: IntervalType,\n\top?: ISequencedDocumentMessage,\n\tfromSnapshot?: boolean,\n\tuseNewSlidingBehavior: boolean = false,\n): SequenceIntervalClass {\n\tconst { startPos, startSide, endPos, endSide } = endpointPosAndSide(\n\t\tstart ?? \"start\",\n\t\tend ?? \"end\",\n\t);\n\tassert(\n\t\tstartPos !== undefined &&\n\t\t\tendPos !== undefined &&\n\t\t\tstartSide !== undefined &&\n\t\t\tendSide !== undefined,\n\t\t0x794 /* start and end cannot be undefined because they were not passed in as undefined */,\n\t);\n\tconst stickiness = computeStickinessFromSide(startPos, startSide, endPos, endSide);\n\tlet beginRefType = ReferenceType.RangeBegin;\n\tlet endRefType = ReferenceType.RangeEnd;\n\tif (intervalType === IntervalType.Transient) {\n\t\tbeginRefType = ReferenceType.Transient;\n\t\tendRefType = ReferenceType.Transient;\n\t} else {\n\t\t// All non-transient interval references must eventually be SlideOnRemove\n\t\t// To ensure eventual consistency, they must start as StayOnRemove when\n\t\t// pending (created locally and creation op is not acked)\n\t\tif (op ?? fromSnapshot) {\n\t\t\tbeginRefType |= ReferenceType.SlideOnRemove;\n\t\t\tendRefType |= ReferenceType.SlideOnRemove;\n\t\t} else {\n\t\t\tbeginRefType |= ReferenceType.StayOnRemove;\n\t\t\tendRefType |= ReferenceType.StayOnRemove;\n\t\t}\n\t}\n\n\tconst startLref = createPositionReference(\n\t\tclient,\n\t\tstartPos,\n\t\tbeginRefType,\n\t\top,\n\t\tfromSnapshot,\n\t\tundefined,\n\t\tstartReferenceSlidingPreference(stickiness),\n\t\tstartReferenceSlidingPreference(stickiness) === SlidingPreference.BACKWARD,\n\t\tuseNewSlidingBehavior,\n\t);\n\n\tconst endLref = createPositionReference(\n\t\tclient,\n\t\tendPos,\n\t\tendRefType,\n\t\top,\n\t\tfromSnapshot,\n\t\tundefined,\n\t\tendReferenceSlidingPreference(stickiness),\n\t\tendReferenceSlidingPreference(stickiness) === SlidingPreference.FORWARD,\n\t\tuseNewSlidingBehavior,\n\t);\n\n\tconst rangeProp = {\n\t\t[reservedRangeLabelsKey]: [label],\n\t};\n\tstartLref.addProperties(rangeProp);\n\tendLref.addProperties(rangeProp);\n\n\tconst ival = new SequenceIntervalClass(\n\t\tclient,\n\t\tstartLref,\n\t\tendLref,\n\t\tintervalType,\n\t\trangeProp,\n\t\tstartSide,\n\t\tendSide,\n\t);\n\treturn ival;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"sequenceInterval.js","sourceRoot":"","sources":["../../src/intervals/sequenceInterval.ts"],"names":[],"mappings":"AAAA;;;GAGG;;;;;;;AAEH,+BAA+B;AAE/B,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAE7D,OAAO,EAIN,iBAAiB,EAEjB,aAAa,EACb,iBAAiB,EACjB,yBAAyB,EACzB,oCAAoC,EACpC,SAAS,EACT,gBAAgB,EAChB,oBAAoB,EACpB,oBAAoB,EACpB,mBAAmB,EACnB,sBAAsB,EAEtB,IAAI,EACJ,kBAAkB,EAClB,aAAa,EACb,wBAAwB,EAExB,wBAAwB,EACxB,uBAAuB,GACvB,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAE,MAAM,0CAA0C,CAAC;AACtE,OAAO,EAAE,EAAE,IAAI,IAAI,EAAE,MAAM,MAAM,CAAC;AAElC,OAAO,EAAE,yBAAyB,EAAE,MAAM,0BAA0B,CAAC;AAErE,OAAO,EAIN,YAAY,EACZ,6BAA6B,EAC7B,+BAA+B,GAE/B,MAAM,oBAAoB,CAAC;AAE5B,SAAS,YAAY,CAAC,KAAW,EAAE,KAAW;IAC7C,IAAI,KAAK,KAAK,KAAK,EAAE,CAAC;QACrB,OAAO,CAAC,CAAC;IACV,CAAC;IAED,IAAI,KAAK,KAAK,IAAI,CAAC,MAAM,EAAE,CAAC;QAC3B,OAAO,CAAC,CAAC;IACV,CAAC;IAED,OAAO,CAAC,CAAC,CAAC;AACX,CAAC;AAED,SAAS,OAAO,CAAC,KAAW,EAAE,KAAW;IACxC,IAAI,KAAK,KAAK,IAAI,CAAC,KAAK,IA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AAY,IAAI,aAAa,CAAC,aAAa,CAAC;YAC5C,UAAU,IAAI,aAAa,CAAC,aAAa,CAAC;QAC3C,CAAC;aAAM,CAAC;YACP,YAAY,IAAI,aAAa,CAAC,YAAY,CAAC;YAC3C,UAAU,IAAI,aAAa,CAAC,YAAY,CAAC;QAC1C,CAAC;IACF,CAAC;IAED,MAAM,SAAS,GAAG,uBAAuB,CACxC,MAAM,EACN,QAAQ,EACR,YAAY,EACZ,EAAE,EACF,YAAY,EACZ,SAAS,EACT,+BAA+B,CAAC,UAAU,CAAC,EAC3C,+BAA+B,CAAC,UAAU,CAAC,KAAK,iBAAiB,CAAC,QAAQ,EAC1E,qBAAqB,CACrB,CAAC;IAEF,MAAM,OAAO,GAAG,uBAAuB,CACtC,MAAM,EACN,MAAM,EACN,UAAU,EACV,EAAE,EACF,YAAY,EACZ,SAAS,EACT,6BAA6B,CAAC,UAAU,CAAC,EACzC,6BAA6B,CAAC,UAAU,CAAC,KAAK,iBAAiB,CAAC,OAAO,EACvE,qBAAqB,CACrB,CAAC;IAEF,MAAM,SAAS,GAAG;QACjB,CAAC,sBAAsB,CAAC,EAAE,CAAC,KAAK,CAAC;KACjC,CAAC;IACF,SAAS,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC;IACnC,OAAO,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC;IAEjC,MAAM,IAAI,GAAG,IAAI,qBAAqB,CACrC,MAAM,EACN,EAAE,EACF,KAAK,EACL,SAAS,EACT,OAAO,EACP,YAAY,EACZ,KAAK,KAAK,SAAS;QAClB,CAAC,CAAC,SAAS;QACX,CAAC,CAAC,EAAE,GAAG,KAAK,EAAE,CAAC,qBAAqB,CAAC,EAAE,SAAS,EAAE,CAAC,sBAAsB,CAAC,EAAE,SAAS,EAAE,EACxF,SAAS,EACT,OAAO,CACP,CAAC;IACF,OAAO,IAAI,CAAC;AACb,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/* eslint-disable no-bitwise */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport { ISequencedDocumentMessage } from \"@fluidframework/driver-definitions/internal\";\nimport {\n\tClient,\n\tISegment,\n\tLocalReferencePosition,\n\tPropertiesManager,\n\tPropertySet,\n\tReferenceType,\n\tSlidingPreference,\n\tcompareReferencePositions,\n\tcreateDetachedLocalReferencePosition,\n\tcreateMap,\n\tgetSlideToSegoff,\n\tmaxReferencePosition,\n\tminReferencePosition,\n\trefTypeIncludesFlag,\n\treservedRangeLabelsKey,\n\tSequencePlace,\n\tSide,\n\tendpointPosAndSide,\n\taddProperties,\n\tcopyPropertiesAndManager,\n\ttype ISegmentInternal,\n\tUnassignedSequenceNumber,\n\tUniversalSequenceNumber,\n} from \"@fluidframework/merge-tree/internal\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\nimport { v4 as uuid } from \"uuid\";\n\nimport { computeStickinessFromSide } from \"../intervalCollection.js\";\n\nimport {\n\tISerializableInterval,\n\tISerializedInterval,\n\tIntervalStickiness,\n\tIntervalType,\n\tendReferenceSlidingPreference,\n\tstartReferenceSlidingPreference,\n\ttype SerializedIntervalDelta,\n} from \"./intervalUtils.js\";\n\nfunction compareSides(sideA: Side, sideB: Side): number {\n\tif (sideA === sideB) {\n\t\treturn 0;\n\t}\n\n\tif (sideA === Side.Before) {\n\t\treturn 1;\n\t}\n\n\treturn -1;\n}\n\nfunction minSide(sideA: Side, sideB: Side): Side {\n\tif (sideA === Side.After && sideB === Side.After) {\n\t\treturn Side.After;\n\t}\n\n\treturn Side.Before;\n}\n\nfunction maxSide(sideA: Side, sideB: Side): Side {\n\tif (sideA === Side.Before && sideB === Side.Before) {\n\t\treturn Side.Before;\n\t}\n\n\treturn Side.After;\n}\n\nconst reservedIntervalIdKey = \"intervalId\";\n\nconst legacyIdPrefix = \"legacy\";\n\nexport function getSerializedProperties(\n\tserializedInterval: ISerializedInterval | SerializedIntervalDelta,\n): {\n\tid: string;\n\tlabels: string[];\n\tproperties: PropertySet;\n} {\n\tconst {\n\t\t[reservedIntervalIdKey]: maybeId,\n\t\t[reservedRangeLabelsKey]: labels,\n\t\t...properties\n\t} = serializedInterval.properties ?? {};\n\t// Create a non-unique ID based on start and end to be used on intervals that come from legacy clients\n\t// without ID's.\n\tconst id =\n\t\tmaybeId ?? `${legacyIdPrefix}${serializedInterval.start}-${serializedInterval.end}`;\n\n\treturn { id, labels, properties };\n}\n\n/**\n * Interval implementation whose ends are associated with positions in a mutatable sequence.\n * As such, when content is inserted into the middle of the interval, the interval expands to\n * include that content.\n *\n * @remarks The endpoints' positions should be treated exclusively to get\n * reasonable behavior. E.g., an interval referring to \"hello\" in \"hello world\"\n * should have a start position of 0 and an end position of 5.\n *\n * To see why, consider what happens if \"llo wor\" is removed from the string to make \"held\".\n * The interval's startpoint remains on the \"h\" (it isn't altered), but the interval's endpoint\n * slides forward to the next unremoved position, which is the \"l\" in \"held\".\n * Users would generally expect the interval to now refer to \"he\" (as it is the subset of content\n * remaining after the removal), hence the \"l\" should be excluded.\n * If the interval endpoint was treated inclusively, the interval would now refer to \"hel\", which\n * is undesirable.\n *\n * Since the endpoints of an interval are treated exclusively but cannot be greater\n * than or equal to the length of the associated sequence, there exist special\n * endpoint segments, \"start\" and \"end\", which represent the position immediately\n * before or immediately after the string respectively.\n *\n * If a `SequenceInterval` is created on a sequence with the\n * `mergeTreeReferencesCanSlideToEndpoint` feature flag set to true, the endpoints\n * of the interval that are exclusive will have the ability to slide to these\n * special endpoint segments.\n * @alpha\n * @legacy\n */\nexport interface SequenceInterval extends ISerializableInterval {\n\treadonly start: LocalReferencePosition;\n\t/**\n\t * End endpoint of this interval.\n\t * @remarks This endpoint can be resolved into a character position using the SharedString it's a part of.\n\t */\n\treadonly end: LocalReferencePosition;\n\treadonly intervalType: IntervalType;\n\treadonly startSide: Side;\n\treadonly endSide: Side;\n\treadonly stickiness: IntervalStickiness;\n\n\t/**\n\t * @returns a new interval object with identical semantics.\n\t */\n\tclone(): SequenceInterval;\n\t/**\n\t * Compares this interval to `b` with standard comparator semantics:\n\t * - returns -1 if this is less than `b`\n\t * - returns 1 if this is greater than `b`\n\t * - returns 0 if this is equivalent to `b`\n\t * @param b - Interval to compare against\n\t */\n\tcompare(b: SequenceInterval): number;\n\t/**\n\t * Compares the start endpoint of this interval to `b`'s start endpoint.\n\t * Standard comparator semantics apply.\n\t * @param b - Interval to compare against\n\t */\n\tcompareStart(b: SequenceInterval): number;\n\t/**\n\t * Compares the end endpoint of this interval to `b`'s end endpoint.\n\t * Standard comparator semantics apply.\n\t * @param b - Interval to compare against\n\t */\n\tcompareEnd(b: SequenceInterval): number;\n\t/**\n\t * Modifies one or more of the endpoints of this interval, returning a new interval representing the result.\n\t */\n\tmodify(\n\t\tlabel: string,\n\t\tstart: SequencePlace | undefined,\n\t\tend: SequencePlace | undefined,\n\t\top?: ISequencedDocumentMessage,\n\t\tlocalSeq?: number,\n\t\tuseNewSlidingBehavior?: boolean,\n\t): SequenceInterval | undefined;\n\t/**\n\t * @returns whether this interval overlaps with `b`.\n\t * Intervals are considered to overlap if their intersection is non-empty.\n\t */\n\toverlaps(b: SequenceInterval): boolean;\n\t/**\n\t * Unions this interval with `b`, returning a new interval.\n\t * The union operates as a convex hull, i.e. if the two intervals are disjoint, the return value includes\n\t * intermediate values between the two intervals.\n\t */\n\tunion(b: SequenceInterval): SequenceInterval;\n\n\t/**\n\t * Subscribes to position change events on this interval if there are no current listeners.\n\t */\n\taddPositionChangeListeners(\n\t\tbeforePositionChange: () => void,\n\t\tafterPositionChange: () => void,\n\t): void;\n\n\t/**\n\t * Removes the currently subscribed position change listeners.\n\t */\n\tremovePositionChangeListeners(): void;\n\n\t/**\n\t * @returns whether this interval overlaps two numerical positions.\n\t */\n\toverlapsPos(bstart: number, bend: number): boolean;\n}\n\nexport class SequenceIntervalClass implements SequenceInterval {\n\treadonly #props: {\n\t\tpropertyManager?: PropertiesManager;\n\t\tproperties: PropertySet;\n\t} = { properties: createMap<any>() };\n\n\t/**\n\t * {@inheritDoc ISerializableInterval.properties}\n\t */\n\tpublic get properties(): Readonly<PropertySet> {\n\t\treturn this.#props.properties;\n\t}\n\n\tpublic changeProperties(props: PropertySet | undefined, op?: ISequencedDocumentMessage) {\n\t\tif (props !== undefined) {\n\t\t\tthis.#props.propertyManager ??= new PropertiesManager();\n\t\t\treturn this.#props.propertyManager.handleProperties(\n\t\t\t\t{ props },\n\t\t\t\tthis.#props,\n\t\t\t\tthis.client.getCollabWindow().collaborating\n\t\t\t\t\t? (op?.sequenceNumber ?? UnassignedSequenceNumber)\n\t\t\t\t\t: UniversalSequenceNumber,\n\t\t\t\top?.minimumSequenceNumber ?? UniversalSequenceNumber,\n\t\t\t\tthis.client.getCollabWindow().collaborating,\n\t\t\t);\n\t\t}\n\t}\n\n\t/***/\n\tpublic get stickiness(): IntervalStickiness {\n\t\tconst startSegment: ISegmentInternal | undefined = this.start.getSegment();\n\t\tconst endSegment: ISegmentInternal | undefined = this.end.getSegment();\n\t\treturn computeStickinessFromSide(\n\t\t\tstartSegment?.endpointType,\n\t\t\tthis.startSide,\n\t\t\tendSegment?.endpointType,\n\t\t\tthis.endSide,\n\t\t);\n\t}\n\n\tconstructor(\n\t\tprivate readonly client: Client,\n\t\tprivate readonly id: string,\n\t\tprivate readonly label: string,\n\t\t/**\n\t\t * Start endpoint of this interval.\n\t\t * @remarks This endpoint can be resolved into a character position using the SharedString it's a part of.\n\t\t */\n\t\tpublic start: LocalReferencePosition,\n\t\t/**\n\t\t * End endpoint of this interval.\n\t\t * @remarks This endpoint can be resolved into a character position using the SharedString it's a part of.\n\t\t */\n\t\tpublic end: LocalReferencePosition,\n\t\tpublic intervalType: IntervalType,\n\t\tprops?: PropertySet,\n\t\tpublic readonly startSide: Side = Side.Before,\n\t\tpublic readonly endSide: Side = Side.Before,\n\t) {\n\t\tif (props) {\n\t\t\tthis.#props.properties = addProperties(this.#props.properties, props);\n\t\t}\n\t}\n\n\tprivate callbacks?: Record<\"beforePositionChange\" | \"afterPositionChange\", () => void>;\n\n\t/**\n\t * Subscribes to position change events on this interval if there are no current listeners.\n\t */\n\tpublic addPositionChangeListeners(\n\t\tbeforePositionChange: () => void,\n\t\tafterPositionChange: () => void,\n\t): void {\n\t\tif (this.callbacks === undefined) {\n\t\t\tthis.callbacks = {\n\t\t\t\tbeforePositionChange,\n\t\t\t\tafterPositionChange,\n\t\t\t};\n\n\t\t\tconst startCbs = (this.start.callbacks ??= {});\n\t\t\tconst endCbs = (this.end.callbacks ??= {});\n\t\t\tstartCbs.beforeSlide = endCbs.beforeSlide = beforePositionChange;\n\t\t\tstartCbs.afterSlide = endCbs.afterSlide = afterPositionChange;\n\t\t}\n\t}\n\n\t/**\n\t * Removes the currently subscribed position change listeners.\n\t */\n\tpublic removePositionChangeListeners(): void {\n\t\tif (this.callbacks) {\n\t\t\tthis.callbacks = undefined;\n\t\t\tthis.start.callbacks = undefined;\n\t\t\tthis.end.callbacks = undefined;\n\t\t}\n\t}\n\n\t/**\n\t * {@inheritDoc ISerializableInterval.serialize}\n\t */\n\tpublic serialize(): ISerializedInterval {\n\t\treturn this.serializeDelta({\n\t\t\tprops: this.properties,\n\t\t\tincludeEndpoints: true,\n\t\t}) as ISerializedInterval;\n\t}\n\n\tpublic serializeDelta({\n\t\tprops,\n\t\tincludeEndpoints,\n\t}: {\n\t\tprops: PropertySet | undefined;\n\t\tincludeEndpoints: boolean;\n\t}): SerializedIntervalDelta {\n\t\tconst startSegment: ISegmentInternal | undefined = this.start.getSegment();\n\t\tconst endSegment: ISegmentInternal | undefined = this.end.getSegment();\n\t\tconst startPosition = includeEndpoints\n\t\t\t? (startSegment?.endpointType ??\n\t\t\t\tthis.client.localReferencePositionToPosition(this.start))\n\t\t\t: undefined;\n\t\tconst endPosition = includeEndpoints\n\t\t\t? (endSegment?.endpointType ?? this.client.localReferencePositionToPosition(this.end))\n\t\t\t: undefined;\n\t\treturn {\n\t\t\tend: endPosition,\n\t\t\tintervalType: this.intervalType,\n\t\t\tsequenceNumber: this.client.getCurrentSeq(),\n\t\t\tstart: startPosition,\n\t\t\tstickiness: this.stickiness,\n\t\t\tstartSide: includeEndpoints ? this.startSide : undefined,\n\t\t\tendSide: includeEndpoints ? this.endSide : undefined,\n\t\t\tproperties: {\n\t\t\t\t...props,\n\t\t\t\t[reservedIntervalIdKey]: this.id,\n\t\t\t\t[reservedRangeLabelsKey]: [this.label],\n\t\t\t},\n\t\t} satisfies SerializedIntervalDelta;\n\t}\n\n\t/**\n\t * {@inheritDoc IInterval.clone}\n\t */\n\tpublic clone(): SequenceIntervalClass {\n\t\treturn new SequenceIntervalClass(\n\t\t\tthis.client,\n\t\t\tthis.id,\n\t\t\tthis.label,\n\t\t\tthis.start,\n\t\t\tthis.end,\n\t\t\tthis.intervalType,\n\t\t\tthis.properties,\n\t\t\tthis.startSide,\n\t\t\tthis.endSide,\n\t\t);\n\t}\n\n\t/**\n\t * {@inheritDoc IInterval.compare}\n\t */\n\tpublic compare(b: SequenceInterval) {\n\t\tconst startResult = this.compareStart(b);\n\t\tif (startResult === 0) {\n\t\t\tconst endResult = this.compareEnd(b);\n\t\t\tif (endResult === 0) {\n\t\t\t\tconst thisId = this.getIntervalId();\n\t\t\t\tif (thisId) {\n\t\t\t\t\tconst bId = b.getIntervalId();\n\t\t\t\t\tif (bId) {\n\t\t\t\t\t\treturn thisId > bId ? 1 : thisId < bId ? -1 : 0;\n\t\t\t\t\t}\n\t\t\t\t\treturn 0;\n\t\t\t\t}\n\t\t\t\treturn 0;\n\t\t\t} else {\n\t\t\t\treturn endResult;\n\t\t\t}\n\t\t} else {\n\t\t\treturn startResult;\n\t\t}\n\t}\n\n\t/**\n\t * {@inheritDoc IInterval.compareStart}\n\t */\n\tpublic compareStart(b: SequenceInterval) {\n\t\tconst dist = compareReferencePositions(this.start, b.start);\n\n\t\tif (dist === 0) {\n\t\t\treturn compareSides(this.startSide, b.startSide);\n\t\t}\n\n\t\treturn dist;\n\t}\n\n\t/**\n\t * {@inheritDoc IInterval.compareEnd}\n\t */\n\tpublic compareEnd(b: SequenceInterval): number {\n\t\tconst dist = compareReferencePositions(this.end, b.end);\n\n\t\tif (dist === 0) {\n\t\t\treturn compareSides(b.endSide, this.endSide);\n\t\t}\n\n\t\treturn dist;\n\t}\n\n\t/**\n\t * {@inheritDoc IInterval.overlaps}\n\t */\n\tpublic overlaps(b: SequenceInterval) {\n\t\tconst result =\n\t\t\tcompareReferencePositions(this.start, b.end) <= 0 &&\n\t\t\tcompareReferencePositions(this.end, b.start) >= 0;\n\t\treturn result;\n\t}\n\n\t/**\n\t * {@inheritDoc ISerializableInterval.getIntervalId}\n\t */\n\tpublic getIntervalId(): string {\n\t\treturn this.id;\n\t}\n\n\t/**\n\t * {@inheritDoc IInterval.union}\n\t */\n\tpublic union(b: SequenceInterval) {\n\t\tconst newStart = minReferencePosition(this.start, b.start);\n\t\tconst newEnd = maxReferencePosition(this.end, b.end);\n\n\t\tlet startSide: Side;\n\n\t\tif (this.start === b.start) {\n\t\t\tstartSide = minSide(this.startSide, b.startSide);\n\t\t} else {\n\t\t\tstartSide = this.start === newStart ? this.startSide : b.startSide;\n\t\t}\n\n\t\tlet endSide: Side;\n\n\t\tif (this.end === b.end) {\n\t\t\tendSide = maxSide(this.endSide, b.endSide);\n\t\t} else {\n\t\t\tendSide = this.end === newEnd ? this.endSide : b.endSide;\n\t\t}\n\n\t\treturn new SequenceIntervalClass(\n\t\t\tthis.client,\n\t\t\tuuid(),\n\t\t\tthis.label,\n\t\t\tnewStart,\n\t\t\tnewEnd,\n\t\t\tthis.intervalType,\n\t\t\tundefined,\n\t\t\tstartSide,\n\t\t\tendSide,\n\t\t);\n\t}\n\n\t/**\n\t * @returns whether this interval overlaps two numerical positions.\n\t */\n\tpublic overlapsPos(bstart: number, bend: number) {\n\t\tconst startPos = this.client.localReferencePositionToPosition(this.start);\n\t\tconst endPos = this.client.localReferencePositionToPosition(this.end);\n\t\treturn endPos > bstart && startPos < bend;\n\t}\n\n\t/**\n\t * {@inheritDoc IInterval.modify}\n\t */\n\tpublic modify(\n\t\tlabel: string,\n\t\tstart: SequencePlace | undefined,\n\t\tend: SequencePlace | undefined,\n\t\top?: ISequencedDocumentMessage,\n\t\tlocalSeq?: number,\n\t\tuseNewSlidingBehavior: boolean = false,\n\t) {\n\t\tconst { startSide, endSide, startPos, endPos } = endpointPosAndSide(start, end);\n\t\tconst startSegment: ISegmentInternal | undefined = this.start.getSegment();\n\t\tconst endSegment: ISegmentInternal | undefined = this.end.getSegment();\n\t\tconst stickiness = computeStickinessFromSide(\n\t\t\tstartPos ?? startSegment?.endpointType,\n\t\t\tstartSide ?? this.startSide,\n\t\t\tendPos ?? endSegment?.endpointType,\n\t\t\tendSide ?? this.endSide,\n\t\t);\n\t\tconst getRefType = (baseType: ReferenceType): ReferenceType => {\n\t\t\tlet refType = baseType;\n\t\t\tif (op === undefined) {\n\t\t\t\trefType &= ~ReferenceType.SlideOnRemove;\n\t\t\t\trefType |= ReferenceType.StayOnRemove;\n\t\t\t}\n\t\t\treturn refType;\n\t\t};\n\n\t\tlet startRef = this.start;\n\t\tif (startPos !== undefined) {\n\t\t\tstartRef = createPositionReference(\n\t\t\t\tthis.client,\n\t\t\t\tstartPos,\n\t\t\t\tgetRefType(this.start.refType),\n\t\t\t\top,\n\t\t\t\tundefined,\n\t\t\t\tlocalSeq,\n\t\t\t\tstartReferenceSlidingPreference(stickiness),\n\t\t\t\tstartReferenceSlidingPreference(stickiness) === SlidingPreference.BACKWARD,\n\t\t\t\tuseNewSlidingBehavior,\n\t\t\t);\n\t\t\tif (this.start.properties) {\n\t\t\t\tstartRef.addProperties(this.start.properties);\n\t\t\t}\n\t\t}\n\n\t\tlet endRef = this.end;\n\t\tif (endPos !== undefined) {\n\t\t\tendRef = createPositionReference(\n\t\t\t\tthis.client,\n\t\t\t\tendPos,\n\t\t\t\tgetRefType(this.end.refType),\n\t\t\t\top,\n\t\t\t\tundefined,\n\t\t\t\tlocalSeq,\n\t\t\t\tendReferenceSlidingPreference(stickiness),\n\t\t\t\tendReferenceSlidingPreference(stickiness) === SlidingPreference.FORWARD,\n\t\t\t\tuseNewSlidingBehavior,\n\t\t\t);\n\t\t\tif (this.end.properties) {\n\t\t\t\tendRef.addProperties(this.end.properties);\n\t\t\t}\n\t\t}\n\n\t\tconst newInterval = new SequenceIntervalClass(\n\t\t\tthis.client,\n\t\t\tthis.id,\n\t\t\tthis.label,\n\t\t\tstartRef,\n\t\t\tendRef,\n\t\t\tthis.intervalType,\n\t\t\tundefined,\n\t\t\tstartSide ?? this.startSide,\n\t\t\tendSide ?? this.endSide,\n\t\t);\n\t\tcopyPropertiesAndManager(this.#props, newInterval.#props);\n\t\treturn newInterval;\n\t}\n\n\tpublic ackPropertiesChange(newProps: PropertySet, op: ISequencedDocumentMessage) {\n\t\tthis.#props.propertyManager ??= new PropertiesManager();\n\t\t// Let the propertyManager prune its pending change-properties set.\n\t\tthis.#props.propertyManager.ack(op.sequenceNumber, op.minimumSequenceNumber, {\n\t\t\tprops: newProps,\n\t\t});\n\t}\n}\n\nexport function createPositionReferenceFromSegoff(\n\tclient: Client,\n\tsegoff: { segment: ISegment | undefined; offset: number | undefined } | \"start\" | \"end\",\n\trefType: ReferenceType,\n\top?: ISequencedDocumentMessage,\n\tlocalSeq?: number,\n\tfromSnapshot?: boolean,\n\tslidingPreference?: SlidingPreference,\n\tcanSlideToEndpoint?: boolean,\n): LocalReferencePosition {\n\tif (segoff === \"start\" || segoff === \"end\") {\n\t\treturn client.createLocalReferencePosition(\n\t\t\tsegoff,\n\t\t\tundefined,\n\t\t\trefType,\n\t\t\tundefined,\n\t\t\tslidingPreference,\n\t\t\tcanSlideToEndpoint,\n\t\t);\n\t}\n\n\tif (segoff.segment) {\n\t\tconst ref = client.createLocalReferencePosition(\n\t\t\tsegoff.segment,\n\t\t\tsegoff.offset,\n\t\t\trefType,\n\t\t\tundefined,\n\t\t\tslidingPreference,\n\t\t\tcanSlideToEndpoint,\n\t\t);\n\t\treturn ref;\n\t}\n\n\t// Creating references on detached segments is allowed for:\n\t// - Transient segments\n\t// - References coming from a remote client (location may have been concurrently removed)\n\t// - References being rebased to a new sequence number\n\t// (segment they originally referred to may have been removed with no suitable replacement)\n\tif (\n\t\t!op &&\n\t\t!localSeq &&\n\t\t!fromSnapshot &&\n\t\t!refTypeIncludesFlag(refType, ReferenceType.Transient)\n\t) {\n\t\tthrow new UsageError(\"Non-transient references need segment\");\n\t}\n\n\treturn createDetachedLocalReferencePosition(slidingPreference, refType);\n}\n\nfunction createPositionReference(\n\tclient: Client,\n\tpos: number | \"start\" | \"end\",\n\trefType: ReferenceType,\n\top?: ISequencedDocumentMessage,\n\tfromSnapshot?: boolean,\n\tlocalSeq?: number,\n\tslidingPreference?: SlidingPreference,\n\texclusive: boolean = false,\n\tuseNewSlidingBehavior: boolean = false,\n): LocalReferencePosition {\n\tlet segoff;\n\n\tif (op) {\n\t\tassert(\n\t\t\t(refType & ReferenceType.SlideOnRemove) !== 0,\n\t\t\t0x2f5 /* op create references must be SlideOnRemove */,\n\t\t);\n\t\tif (pos === \"start\" || pos === \"end\") {\n\t\t\tsegoff = pos;\n\t\t} else {\n\t\t\tsegoff = client.getContainingSegment(pos, {\n\t\t\t\treferenceSequenceNumber: op.referenceSequenceNumber,\n\t\t\t\tclientId: op.clientId,\n\t\t\t});\n\t\t\tsegoff = getSlideToSegoff(segoff, slidingPreference, undefined, useNewSlidingBehavior);\n\t\t}\n\t} else {\n\t\tassert(\n\t\t\t(refType & ReferenceType.SlideOnRemove) === 0 || !!fromSnapshot,\n\t\t\t0x2f6 /* SlideOnRemove references must be op created */,\n\t\t);\n\t\tsegoff =\n\t\t\tpos === \"start\" || pos === \"end\"\n\t\t\t\t? pos\n\t\t\t\t: client.getContainingSegment(pos, undefined, localSeq);\n\t}\n\n\treturn createPositionReferenceFromSegoff(\n\t\tclient,\n\t\tsegoff,\n\t\trefType,\n\t\top,\n\t\tlocalSeq,\n\t\tfromSnapshot,\n\t\tslidingPreference,\n\t\texclusive,\n\t);\n}\n\nexport function createTransientInterval(\n\tstart: SequencePlace | undefined,\n\tend: SequencePlace | undefined,\n\tclient: Client,\n) {\n\treturn createSequenceInterval(\n\t\t\"transient\",\n\t\tuuid(),\n\t\tstart,\n\t\tend,\n\t\tclient,\n\t\tIntervalType.Transient,\n\t);\n}\n\nexport function createSequenceInterval(\n\tlabel: string,\n\tid: string,\n\tstart: SequencePlace | undefined,\n\tend: SequencePlace | undefined,\n\tclient: Client,\n\tintervalType: IntervalType,\n\top?: ISequencedDocumentMessage,\n\tfromSnapshot?: boolean,\n\tuseNewSlidingBehavior: boolean = false,\n\tprops?: PropertySet,\n): SequenceIntervalClass {\n\tconst { startPos, startSide, endPos, endSide } = endpointPosAndSide(\n\t\tstart ?? \"start\",\n\t\tend ?? \"end\",\n\t);\n\tassert(\n\t\tstartPos !== undefined &&\n\t\t\tendPos !== undefined &&\n\t\t\tstartSide !== undefined &&\n\t\t\tendSide !== undefined,\n\t\t0x794 /* start and end cannot be undefined because they were not passed in as undefined */,\n\t);\n\tconst stickiness = computeStickinessFromSide(startPos, startSide, endPos, endSide);\n\tlet beginRefType = ReferenceType.RangeBegin;\n\tlet endRefType = ReferenceType.RangeEnd;\n\tif (intervalType === IntervalType.Transient) {\n\t\tbeginRefType = ReferenceType.Transient;\n\t\tendRefType = ReferenceType.Transient;\n\t} else {\n\t\t// All non-transient interval references must eventually be SlideOnRemove\n\t\t// To ensure eventual consistency, they must start as StayOnRemove when\n\t\t// pending (created locally and creation op is not acked)\n\t\tif (op ?? fromSnapshot) {\n\t\t\tbeginRefType |= ReferenceType.SlideOnRemove;\n\t\t\tendRefType |= ReferenceType.SlideOnRemove;\n\t\t} else {\n\t\t\tbeginRefType |= ReferenceType.StayOnRemove;\n\t\t\tendRefType |= ReferenceType.StayOnRemove;\n\t\t}\n\t}\n\n\tconst startLref = createPositionReference(\n\t\tclient,\n\t\tstartPos,\n\t\tbeginRefType,\n\t\top,\n\t\tfromSnapshot,\n\t\tundefined,\n\t\tstartReferenceSlidingPreference(stickiness),\n\t\tstartReferenceSlidingPreference(stickiness) === SlidingPreference.BACKWARD,\n\t\tuseNewSlidingBehavior,\n\t);\n\n\tconst endLref = createPositionReference(\n\t\tclient,\n\t\tendPos,\n\t\tendRefType,\n\t\top,\n\t\tfromSnapshot,\n\t\tundefined,\n\t\tendReferenceSlidingPreference(stickiness),\n\t\tendReferenceSlidingPreference(stickiness) === SlidingPreference.FORWARD,\n\t\tuseNewSlidingBehavior,\n\t);\n\n\tconst rangeProp = {\n\t\t[reservedRangeLabelsKey]: [label],\n\t};\n\tstartLref.addProperties(rangeProp);\n\tendLref.addProperties(rangeProp);\n\n\tconst ival = new SequenceIntervalClass(\n\t\tclient,\n\t\tid,\n\t\tlabel,\n\t\tstartLref,\n\t\tendLref,\n\t\tintervalType,\n\t\tprops === undefined\n\t\t\t? undefined\n\t\t\t: { ...props, [reservedIntervalIdKey]: undefined, [reservedRangeLabelsKey]: undefined },\n\t\tstartSide,\n\t\tendSide,\n\t);\n\treturn ival;\n}\n"]}
|
package/lib/packageVersion.d.ts
CHANGED
package/lib/packageVersion.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,CAAC,MAAM,OAAO,GAAG,0BAA0B,CAAC;AAClD,MAAM,CAAC,MAAM,UAAU,GAAG,QAAQ,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n *\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY\n */\n\nexport const pkgName = \"@fluidframework/sequence\";\nexport const pkgVersion = \"2.
|
|
1
|
+
{"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,CAAC,MAAM,OAAO,GAAG,0BAA0B,CAAC;AAClD,MAAM,CAAC,MAAM,UAAU,GAAG,QAAQ,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n *\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY\n */\n\nexport const pkgName = \"@fluidframework/sequence\";\nexport const pkgVersion = \"2.32.0\";\n"]}
|
package/lib/revertibles.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"revertibles.d.ts","sourceRoot":"","sources":["../src/revertibles.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,EACN,sBAAsB,EAEtB,wBAAwB,EAExB,WAAW,EAeX,MAAM,qCAAqC,CAAC;AAE7C,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAyB,MAAM,sBAAsB,CAAC;AAC/F,OAAO,EAAuB,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAClF,OAAO,EAAE,aAAa,EAAuB,MAAM,mBAAmB,CAAC;AAEvE;;;;GAIG;AACH,MAAM,MAAM,sBAAsB,GAAG,wBAAwB,GAAG,kBAAkB,CAAC;AAInF;;;;GAIG;AACH,MAAM,MAAM,kBAAkB,GAC3B;IACA,KAAK,EAAE,OAAO,cAAc,CAAC,MAAM,CAAC;IACpC,QAAQ,EAAE,gBAAgB,CAAC;IAC3B,KAAK,EAAE,sBAAsB,CAAC;IAC9B,GAAG,EAAE,sBAAsB,CAAC;CAC3B,GACD;IACA,KAAK,EAAE,OAAO,cAAc,CAAC,GAAG,CAAC;IACjC,QAAQ,EAAE,gBAAgB,CAAC;CAC1B,GACD;IACA,KAAK,EAAE,OAAO,cAAc,CAAC,MAAM,CAAC;IACpC,QAAQ,EAAE,gBAAgB,CAAC;IAC3B,KAAK,EAAE,sBAAsB,CAAC;IAC9B,GAAG,EAAE,sBAAsB,CAAC;CAC3B,GACD;IACA,KAAK,EAAE,OAAO,cAA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EAAE,MAAM,CAAC;KACnB,EAAE,CAAC;IAEJ,cAAc,EAAE;QACf,UAAU,EAAE,kBAAkB,CAAC;QAC/B,MAAM,EAAE,MAAM,CAAC;QACf,OAAO,EAAE,OAAO,CAAC;KACjB,EAAE,CAAC;IACJ,mBAAmB,EAAE,wBAAwB,CAAC;CAC7C,CAAC;AAeL;;;;GAIG;AACH,wBAAgB,8BAA8B,CAC7C,QAAQ,EAAE,gBAAgB,EAC1B,WAAW,EAAE,sBAAsB,EAAE,4BAQrC;AAED;;;;GAIG;AACH,wBAAgB,iCAAiC,CAChD,MAAM,EAAE,aAAa,EACrB,QAAQ,EAAE,gBAAgB,EAC1B,WAAW,EAAE,sBAAsB,EAAE,GACnC,sBAAsB,EAAE,CAwC1B;AAED;;;;GAIG;AACH,wBAAgB,iCAAiC,CAChD,MAAM,EAAE,aAAa,EACrB,WAAW,EAAE,gBAAgB,EAC7B,gBAAgB,EAAE,gBAAgB,EAClC,WAAW,EAAE,sBAAsB,EAAE,4BAsCrC;AAED;;;;GAIG;AACH,wBAAgB,0CAA0C,CACzD,QAAQ,EAAE,gBAAgB,EAC1B,MAAM,EAAE,WAAW,EACnB,WAAW,EAAE,sBAAsB,EAAE,4BASrC;AA2CD;;;;;GAKG;AACH,wBAAgB,oCAAoC,CACnD,MAAM,EAAE,aAAa,EACrB,KAAK,EAAE,kBAAkB,EACzB,WAAW,EAAE,sBAAsB,EAAE,QAwFrC;AAED;;;;GAIG;AACH,wBAAgB,8BAA8B,CAC7C,YAAY,EAAE,aAAa,EAC3B,WAAW,EAAE,sBAAsB,EAAE,QAUrC;AAwRD;;;;GAIG;AACH,wBAAgB,6BAA6B,CAC5C,YAAY,EAAE,aAAa,EAC3B,WAAW,EAAE,sBAAsB,EAAE,QA8BrC"}
|
package/lib/revertibles.js
CHANGED
|
@@ -180,7 +180,7 @@ export function appendSharedStringDeltaToRevertibles(string, delta, revertibles)
|
|
|
180
180
|
}
|
|
181
181
|
revertible.intervals.push({
|
|
182
182
|
intervalId: interval.getIntervalId(),
|
|
183
|
-
label: interval.properties
|
|
183
|
+
label: interval.start.properties?.referenceRangeLabels[0],
|
|
184
184
|
startOffset: offset,
|
|
185
185
|
endOffset,
|
|
186
186
|
});
|
|
@@ -189,7 +189,7 @@ export function appendSharedStringDeltaToRevertibles(string, delta, revertibles)
|
|
|
189
189
|
endIntervals.forEach(({ interval, offset }) => {
|
|
190
190
|
revertible.intervals.push({
|
|
191
191
|
intervalId: interval.getIntervalId(),
|
|
192
|
-
label: interval.properties
|
|
192
|
+
label: interval.start.properties?.referenceRangeLabels[0],
|
|
193
193
|
endOffset: offset,
|
|
194
194
|
});
|
|
195
195
|
});
|
|
@@ -243,7 +243,7 @@ function isValidRange(start, startSlide, end, endSlide, string) {
|
|
|
243
243
|
}
|
|
244
244
|
function revertLocalAdd(string, revertible) {
|
|
245
245
|
const id = getUpdatedIdFromInterval(revertible.interval);
|
|
246
|
-
const label = revertible.interval.properties
|
|
246
|
+
const label = revertible.interval.start.properties?.referenceRangeLabels[0];
|
|
247
247
|
string.getIntervalCollection(label).removeIntervalById(id);
|
|
248
248
|
}
|
|
249
249
|
function createSequencePlace(pos, newSlidingPreference, oldSlidingPreference = undefined) {
|
|
@@ -262,14 +262,15 @@ function createSequencePlace(pos, newSlidingPreference, oldSlidingPreference = u
|
|
|
262
262
|
: pos; // Avoid setting side if possible since stickiness may not be enabled
|
|
263
263
|
}
|
|
264
264
|
function revertLocalDelete(string, revertible) {
|
|
265
|
-
const label = revertible.interval.properties
|
|
265
|
+
const label = revertible.interval.start.properties?.referenceRangeLabels[0];
|
|
266
266
|
const collection = string.getIntervalCollection(label);
|
|
267
267
|
const start = string.localReferencePositionToPosition(revertible.start);
|
|
268
268
|
const startSlidePos = getSlidePosition(string, revertible.start, start);
|
|
269
269
|
const end = string.localReferencePositionToPosition(revertible.end);
|
|
270
270
|
const endSlidePos = getSlidePosition(string, revertible.end, end);
|
|
271
271
|
// reusing the id causes eventual consistency bugs, so it is removed here and recreated in add
|
|
272
|
-
const {
|
|
272
|
+
const { ...props } = revertible.interval.properties;
|
|
273
|
+
const intervalId = revertible.interval.getIntervalId();
|
|
273
274
|
if (isValidRange(startSlidePos, revertible.start.slidingPreference, endSlidePos, revertible.end.slidingPreference, string)) {
|
|
274
275
|
const int = collection.add({
|
|
275
276
|
start: createSequencePlace(startSlidePos, revertible.start.slidingPreference),
|
|
@@ -287,7 +288,7 @@ function revertLocalDelete(string, revertible) {
|
|
|
287
288
|
string.removeLocalReferencePosition(revertible.end);
|
|
288
289
|
}
|
|
289
290
|
function revertLocalChange(string, revertible) {
|
|
290
|
-
const label = revertible.interval.properties
|
|
291
|
+
const label = revertible.interval.start.properties?.referenceRangeLabels[0];
|
|
291
292
|
const collection = string.getIntervalCollection(label);
|
|
292
293
|
const id = getUpdatedIdFromInterval(revertible.interval);
|
|
293
294
|
const start = string.localReferencePositionToPosition(revertible.start);
|
|
@@ -306,7 +307,7 @@ function revertLocalChange(string, revertible) {
|
|
|
306
307
|
string.removeLocalReferencePosition(revertible.end);
|
|
307
308
|
}
|
|
308
309
|
function revertLocalPropertyChanged(string, revertible) {
|
|
309
|
-
const label = revertible.interval.properties
|
|
310
|
+
const label = revertible.interval.start.properties?.referenceRangeLabels[0];
|
|
310
311
|
const id = getUpdatedIdFromInterval(revertible.interval);
|
|
311
312
|
const newProps = revertible.propertyDeltas;
|
|
312
313
|
string.getIntervalCollection(label).change(id, { props: newProps });
|